Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
<DllImport("user32.dll", CallingConvention:=CallingConvention.Cdecl)> _
Public Function EnableMenuItem(ByVal hMenu As IntPtr, ByVal wIDEnableItem As UInteger, ByVal wEnable As UInteger) As IntPtr
End Function;
Private Const SC_CLOSE As Integer = &HF060
Private Const MF_GRAYED As Integer = &H1
<DllImport("user32.dll", CallingConvention:=Runtime.InteropServices.CallingConvention.Cdecl)> _
Private Shared Function GetSystemMenu(ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
End Function
<DllImport("user32.dll", CallingConvention:=Runtime.InteropServices.CallingConvention.Cdecl)> _
Private Shared Function EnableMenuItem(ByVal hMenu As IntPtr, ByVal wIDEnableItem As UInteger, ByVal wEnable As UInteger) As IntPtr
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Disable the form's 'X' button. Note that this does not disable the Alt+F4 functionality.
EnableMenuItem(GetSystemMenu(Me.Handle, False), SC_CLOSE, MF_GRAYED)
End Sub
End Class
Alternative Managed API:
Do you know one? Please contribute it!
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).