禁用关闭按钮,参考
全局代码
Public Const SC_CLOSE As Integer = &Hf060
Public Const MF_ENABLED As Integer = &H0
Public Const MF_GRAYED As Integer = &H1
Public Const MF_DISABLED As Integer = &H2
<DllImport("user32.dll", EntryPoint := "GetSystemMenu")> _
Public Function GetSystemMenu(hWnd As IntPtr, bRevert As Integer) As IntPtr
End Function
<DllImport("User32.dll")> _
Public Function EnableMenuItem(hMenu As IntPtr, uIDEnableItem As Integer, uEnable As Integer) As Boolean
End Function
调用代码
Dim hMenu As IntPtr = GetSystemMenu(basemainform.Handle, 0)
EnableMenuItem(hMenu, SC_CLOSE, (MF_DISABLED + MF_GRAYED) Or MF_ENABLED)