Search code examples
inno-setuppascalscript

Change the focused control on Inno Setup start


How can I change the focused control on welcome page? It is currently focused on NextButton. But I need to change it to CancelButton (or even any other buttons which I have added them programmatically like an About Button)

I tried this on InitializeWizard event:

WizardForm.ActiveControl := CancelButton;
CancelButton.Default := true;

but no success. Even I tried something described here: http://www.delphigroups.info/2/f3/324879.html

SendMessage(Handle, WM_NEXTDLGCTL, 0, 0 );

and no success.

How to solve this issue?


Solution

  • Changing wizard's ActiveControl in InitializeWizard is too early. It will get changed afterwards to the Next button.

    Do it in the CurPageChanged(wpWelcome):

    procedure CurPageChanged(CurPageID: Integer);
    begin
      if CurPageID = wpWelcome then
        WizardForm.ActiveControl := WizardForm.CancelButton;
    end;