Setting control width to half of custom page SurfaceWidth does not work correctly in Inno Setup

That’s because of the akRight in Panel.Anchors and modern WizardStyle (or rather the 120 WizardSizePercent it implies). The wizard is scaled only after the InitializeWizard. With akRight, the panel width will grow linearly (not proportionally) with the wizard. There are solutions, but they depend on how you actually want the panel to behave in the resizable wizard (also implied by the modern style).

See also Inno Setup – how to center an animated gif in resized wizard.

If you want to keep the panel at half size, when the wizard is resized (either automatically due to WizardSizePercent or by the user due to WizardResizable), handle WizardForm.OnResize:

  Page: TWizardPage;
  Panel: TPanel;

procedure WizardFormResize(Sender: TObject);
  Panel.Width := Page.SurfaceWidth div 2;

procedure InitializeWizard();
  Page := CreateCustomPage(
    wpWelcome, 'Custom wizard page controls', 'TButton and others');
  Panel := TPanel.Create(Page);
  Panel.Width := Page.SurfaceWidth div 2;
  // ...
  WizardForm.OnResize := @WizardFormResize;

Make sure you do not set the akRight anchor.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top