Disabling/Enabling the System Menu close button
   


This procedure will enable or disable the system menu close button (the 'x' on the top right corner of the application). Pass False to disable it, True to enable it. This will also enable/disable the Close menu option of the application icon (top left corner). Note: your users will still be able to close the application by pressing ALT-F4.

procedure EnableSystemMenuCloseButton(Hnd: THandle; Enabled: boolean);
var
  hMenu: THandle;
begin
  
{ Enable/Disable the system menu close button. }
  hMenu := GetSystemMenu(Hnd, False);
  if Enabled then
    EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED)
  else
    EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
end;



Blue Orb Software

[email protected]