/// <summary> /// Remove the entire menu bar of a window. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void RemoveMenu(IntPtr hWnd) { IntPtr hMenu = WinAPI.GetMenu(hWnd); int count = WinAPI.GetMenuItemCount(hMenu); //loop & remove for (int i = 0; i < count; i++) { WinAPI.RemoveMenu(hMenu, 0, (0x400 | 0x1000)); } //force a redraw WinAPI.DrawMenuBar(hWnd); }
/// <summary> /// Disable a window's close button. /// </summary> /// <param name="hWnd">The handle to the window.</param> public static void DisableCloseButton(IntPtr hWnd) { IntPtr hMenu; int n; hMenu = WinAPI.GetSystemMenu(hWnd, false); if (hMenu != IntPtr.Zero) { n = WinAPI.GetMenuItemCount(hMenu); if (n > 0) { WinAPI.RemoveMenu(hMenu, (uint)(n - 1), 0x400 | 0x1000); WinAPI.RemoveMenu(hMenu, (uint)(n - 2), 0x400 | 0x1000); WinAPI.DrawMenuBar(hWnd); } } }