How to disable the Close button (borderstyle)?
I want to combine that with hiding "About Setup" command from system menu:
Inno Setup - BorderIcons dropdown menu
How to disable the Close button (borderstyle)?
I want to combine that with hiding "About Setup" command from system menu:
Inno Setup - BorderIcons dropdown menu
Use EnableMenuItem
WinAPI function:
function GetSystemMenu(hWnd: THandle; bRevert: Boolean): THandle;
external 'GetSystemMenu@user32.dll stdcall';
function EnableMenuItem(hMenu: UINT; uIDEnableItem, uEnable: UINT): Boolean;
external 'EnableMenuItem@user32.dll stdcall';
const
MF_GRAYED = $1;
MF_BYCOMMAND = $0;
SC_CLOSE = $F060;
procedure DisableCloseButton;
var
Menu: THandle;
begin
Menu := GetSystemMenu(WizardForm.Handle, False);
EnableMenuItem(Menu, SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
end;
You have to call the DisableCloseButton
later than from the InitializeWizard
event function.
There maybe a better place to call it, but for a simplicity you can call it from CurPageChanged
:
procedure CurPageChanged(CurPageID: Integer);
begin
DisableCloseButton;
end;
But note that you need to keep the code to hide "About Setup" command in InitializeWizard
as that needs to be called only once (and it works there correctly).
The screenshot shows both codes combined: