Forbid to close the console program with a cross on b. OS: Windows
1 answer
If you delete the "Close" command from the window (system) menu, then the "cross" button becomes inaccessible
HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMenu(hwnd, FALSE); DeleteMenu(hmenu, SC_CLOSE, MF_BYCOMMAND); Instead of deleting a menu item, you can simply make it inactive.
EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED); This, however, does not prohibit the closing of the window by Alt - F4 .
|