如何让窗体右上角的关闭叉不可点击,就是点击无效也可

解决方案 »

  1.   

    把FormBorderStyle 设置为None,这样就没有标题栏了。
    当然,我也认为这样不好。
      

  2.   

    或者你可以在Closing事件中拦截。
      

  3.   

    你直接把窗体的 controlbox设置为false,不让它显示就是了呀
      

  4.   

    Option Explicit On 
    Option Strict OnPublic Class CloseButton  Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Integer, ByVal revert As Integer) As Integer
      Private Declare Function EnableMenuItem Lib "user32" (ByVal menu As Integer, ByVal ideEnableItem As Integer, ByVal enable As Integer) As Integer  Private Const SC_CLOSE As Integer = &HF060
      Private Const MF_BYCOMMAND As Integer = &H0
      Private Const MF_GRAYED As Integer = &H1
      Private Const MF_ENABLED As Integer = &H0  Private Sub New()
      End Sub  Public Shared Sub Disable(ByVal form As System.Windows.Forms.Form)
        ' The return value specifies the previous state of the menu item 
        ' (it is either MF_ENABLED or MF_GRAYED). 0xFFFFFFFF indicates that 
        ' the menu item does not exist.
        Select Case EnableMenuItem(GetSystemMenu(form.Handle.ToInt32, 0), SC_CLOSE, MF_BYCOMMAND Or MF_GRAYED)
          Case MF_ENABLED
          Case MF_GRAYED
          Case &HFFFFFFFF
            Throw New Exception("The Close menu item does not exist.")
          Case Else
        End Select
      End SubEnd Class先用上面的代码做成一个vb的Dll类库
    再到程序里引用
    最后在程序调 用
    CloseButton.Disable(this);
    那个X按钮就不能显示了
      

  5.   

    我同意  mmcl(Constor) ( ) 信誉:100 
    的说法,自己制作任何效果都可以的,界面
      

  6.   

    挺~~whmjw(明年今日十年之后) 
    虽然麻烦了一点。
      

  7.   

    在Closing事件中设置e.Cancel = true;
      

  8.   

    to 如何让窗体右上角的关闭叉不可点击,就是点击无效也可前一部分要修改系统菜单,上面已经有方法了;
    我说说后者的办法,参看
    http://www.syncfusion.com/faq/windowsforms/search/608.aspx
      

  9.   

    在Closing事件中设置e.Cancel = true;
    e.Cancel = true 表示已经处理。