public enum SysCommands : int
{
SC_MINIMIZE = 0xF020,
SC_MAXIMIZE = 0xF030,
SC_CLOSE = 0xF060
}
public enum MenuFlags : int
{
MF_ENABLED = 0x0;
MF_GRAYED = 0x1;
MF_DISABLED = 0x2;
}
/// <summary>
/// The EnableMenuItem function enables, disables, or grays the specified menu item.
/// </summary>
/// <param name="hMenu">Handle to the menu.</param>
/// <param name="uIDEnableItem">
/// Specifies the menu item to be enabled, disabled, or grayed,
/// as determined by the uEnable parameter. This parameter specifies an item in a menu bar, menu, or submenu.
/// </param>
/// <param name="uEnable">
/// Controls the interpretation of the uIDEnableItem parameter and indicate whether the menu item is enabled, disabled, or grayed.
/// This parameter must be a combination of either MF_BYCOMMAND or MF_BYPOSITION and MF_ENABLED, MF_DISABLED, or MF_GRAYED.
/// </param>
/// <returns>The return value specifies the previous state of the menu item (it is either MF_DISABLED, MF_ENABLED, or MF_GRAYED). If the menu item does not exist, the return value is -1.</returns>
[DllImport("user32.dll")]
public static extern int EnableMenuItem(IntPtr hMenu, SysCommands uIDEnableItem, MenuFlags uEnable);
/// <summary>
/// The GetSystemMenu function allows the application to access the window menu (also known as the system menu or the control menu) for copying and modifying.
/// </summary>
/// <param name="hWnd">Handle to the window that will own a copy of the window menu.</param>
/// <param name="bRevert">
/// Specifies the action to be taken. If this parameter is FALSE, GetSystemMenu returns a handle to the copy of the window menu currently in use.
/// The copy is initially identical to the window menu, but it can be modified. If this parameter is TRUE, GetSystemMenu resets the window menu back to the default state.
/// The previous window menu, if any, is destroyed.
/// </param>
/// <returns>If the bRevert parameter is FALSE, the return value is a handle to a copy of the window menu. If the bRevert parameter is TRUE, the return value is NULL.</returns>
[DllImport("user32.dll")]
public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);