using System; using System.Drawing; using System.Runtime.InteropServices; public static class DisplayFusionFunction { [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll")] private static extern int EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable); private const uint Close = 0xF060; private const uint Enabled = 0x00000000; private const uint Disabled = 0x00000002; public static void Run(IntPtr windowHandle) { EnableMenuItem(GetSystemMenu(windowHandle, false), Close, Disabled); // EnableMenuItem(GetSystemMenu(windowHandle, false), Close, Enabled); } }
using System; using System.Drawing; using System.Runtime.InteropServices; public static class DisplayFusionFunction { [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll")] private static extern int EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable); private const uint Close = 0xF060; private const uint Enabled = 0x00000000; private const uint Disabled = 0x00000002; public static void Run(IntPtr windowHandle) { EnableMenuItem(GetSystemMenu(windowHandle, false), Close, Disabled); // EnableMenuItem(GetSystemMenu(windowHandle, false), Close, Enabled); } }
using System; using System.Drawing; using System.Runtime.InteropServices; public static class DisplayFusionFunction { [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll")] private static extern int EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable); private const uint CloseButton = 0xF060; private const uint Enabled = 0x00000000; private const uint Disabled = 0x00000002; public static void Run(IntPtr windowHandle) { if(!BFS.ScriptSettings.ReadValueBool("CloseButtonState")) { EnableMenuItem(GetSystemMenu(windowHandle, false), CloseButton, Enabled); BFS.ScriptSettings.WriteValueBool("CloseButtonState", true); } else { EnableMenuItem(GetSystemMenu(windowHandle, false), CloseButton, Disabled); BFS.ScriptSettings.WriteValueBool("CloseButtonState", false); } } }