[DllImport("user32.dll")]
static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem,
uint uEnable);
<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;
Constants used with Add/Check/EnableMenuItem:
internal const UInt32 MF_INSERT =0x00000000;
internal const UInt32 MF_CHANGE =0x00000080;
internal const UInt32 MF_APPEND =0x00000100;
internal const UInt32 MF_DELETE =0x00000200;
internal const UInt32 MF_REMOVE =0x00001000;
internal const UInt32 MF_BYCOMMAND =0x00000000;
internal const UInt32 MF_BYPOSITION =0x00000400;
internal const UInt32 MF_SEPARATOR =0x00000800;
internal const UInt32 MF_ENABLED =0x00000000;
internal const UInt32 MF_GRAYED =0x00000001;
internal const UInt32 MF_DISABLED =0x00000002;
internal const UInt32 MF_UNCHECKED =0x00000000;
internal const UInt32 MF_CHECKED =0x00000008;
internal const UInt32 MF_USECHECKBITMAPS =0x00000200;
internal const UInt32 MF_STRING =0x00000000;
internal const UInt32 MF_BITMAP =0x00000004;
internal const UInt32 MF_OWNERDRAW =0x00000100;
internal const UInt32 MF_POPUP =0x00000010;
internal const UInt32 MF_MENUBARBREAK =0x00000020;
internal const UInt32 MF_MENUBREAK =0x00000040;
internal const UInt32 MF_UNHILITE =0x00000000;
internal const UInt32 MF_HILITE =0x00000080;
internal const UInt32 MF_DEFAULT =0x00001000;
internal const UInt32 MF_SYSMENU =0x00002000;
internal const UInt32 MF_HELP =0x00004000;
internal const UInt32 MF_RIGHTJUSTIFY =0x00004000;
internal const UInt32 MF_MOUSESELECT =0x00008000;
internal const UInt32 MF_END =0x00000080; /* Obsolete -- only used by old RES files */
internal const UInt32 MFT_STRING =MF_STRING;
internal const UInt32 MFT_BITMAP =MF_BITMAP;
internal const UInt32 MFT_MENUBARBREAK =MF_MENUBARBREAK;
internal const UInt32 MFT_MENUBREAK =MF_MENUBREAK;
internal const UInt32 MFT_OWNERDRAW =MF_OWNERDRAW;
internal const UInt32 MFT_RADIOCHECK =0x00000200;
internal const UInt32 MFT_SEPARATOR =MF_SEPARATOR;
internal const UInt32 MFT_RIGHTORDER =0x00002000;
internal const UInt32 MFT_RIGHTJUSTIFY =MF_RIGHTJUSTIFY;
internal const UInt32 MFS_GRAYED =0x00000003;
internal const UInt32 MFS_DISABLED =MFS_GRAYED;
internal const UInt32 MFS_CHECKED =MF_CHECKED;
internal const UInt32 MFS_HILITE =MF_HILITE;
internal const UInt32 MFS_ENABLED =MF_ENABLED;
internal const UInt32 MFS_UNCHECKED =MF_UNCHECKED;
internal const UInt32 MFS_UNHILITE =MF_UNHILITE;
internal const UInt32 MFS_DEFAULT =MF_DEFAULT;
None.
Please add some!
Public Class Form1
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
Do you know one? Please contribute it!