HWND hWnd = Form1-> Handle;//here Handle the necessary window
HMENU hMenu = GetSystemMenu (hWnd, false);
if (hMenu)
{
EnableMenuItem (hMenu, SC_CLOSE, MF_GRAYED);
}
If it is necessary to delete menu item to "Close", instead of "EnableMenuItem (hMenu........" We write:
DeleteMenu (hMenu, SC_CLOSE, MF_BYCOMMAND);
And if it wanted to mock at the user we write:
EnableMenuItem (hMenu, SC_CLOSE, MF_DISABLED);
Then button "X" will be ungeared", but the menu item will"Close""is included", though it will not work :)