Custom Welcome and Finished page with stretched image in Inno Setup - inno-setup

I have created an image that I want to appear over whole Welcome and Finished pages of the installer, with only the bottom buttons showing.
The Welcome wizard page should be like:
The Finished page like:
I'm getting
Please help!
Thanks in advance😊

First, note that the Welcome page is disabled by default since Inno Setup 5.5.7. If you really want it, you have to enable it using DisableWelcomePage=no.
To display images only on the pages, you need to do:
Stretch WizardBitmapImage (Welcome) and WizardBitmapImage2 (Finished) over their respective parent pages.
Hide the other components, mainly the labels.
Make sure that the installer never needs to restart the machine, otherwise you get a restart prompt over the image.
Make sure you do not have any postinstall entries in the [Run] section, for the same reason.
The code is designed for WizardStyle=classic. For modern style it needs to be adjusted.
[Setup]
DisableWelcomePage=no
WizardImageFile=godfather.bmp
[Code]
procedure InitializeWizard();
begin
{ Welcome page }
{ Hide the labels }
WizardForm.WelcomeLabel1.Visible := False;
WizardForm.WelcomeLabel2.Visible := False;
{ Stretch image over whole page }
WizardForm.WizardBitmapImage.Width :=
WizardForm.WizardBitmapImage.Parent.Width;
{ Finished page }
{ Hide the labels }
WizardForm.FinishedLabel.Visible := False;
WizardForm.FinishedHeadingLabel.Visible := False;
{ Stretch image over whole page }
WizardForm.WizardBitmapImage2.Width :=
WizardForm.WizardBitmapImage2.Parent.Width;
end;

Related

Inno Setup: add fields to InputQueryPage depending on components selected

I have an input query page, which asks the user for ports depending on what components are selected.
procedure InitializeWizard;
begin
{ Create the page }
ConfigPage :=
CreateInputQueryPage(
wpSelectComponents, 'User input', 'User input',
'Please specify the following information, then click Next.');
{ Add items (False means it's not a password edit) }
if IsComponentSelected('broker') then
begin
ConfigPage.Add('MQTT Broker port:', False);
{ Set initial values (optional) }
ConfigPage.Values[0] := ExpandConstant('1883');
end;
end;
The issue I am finding here is that InitializeWizard is always called prior to component selection, so IsComponentSelected('broker') is always called.
Is there any way around this? How can I achieve this?
It's not easy. For a really generic solution, you would have to create the custom page only when leaving the components selection page (e.g. in NextButtonClick with CurPageID equal wpSelectComponents). That's doable, but Inno Setup allows user to go back to the components page. When the user does that, you would have to remove the custom page, re-creating it later. But you would lose the data the user might have entered on the custom page. So you would have to persist the data somehow. All that is doable, but lot of work.
If it is about few input boxes only, consider instead disabling the boxes that are not relevant for the current components selection:
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = ConfigPage.ID then
begin
ConfigPage.Edits[0].Enabled := IsComponentSelected('foo');
ConfigPage.PromptLabels[0].Enabled := ConfigPage.Edits[0].Enabled;
ConfigPage.Edits[1].Enabled := IsComponentSelected('bar');
ConfigPage.PromptLabels[1].Enabled := ConfigPage.Edits[1].Enabled;
end;
end;
A step further would be to hide the boxes instead of disabling them (use Visible instead of Enabled). But then you would have to rearrange the boxes. But that's still easier then re-building the page.

Can not create label on Inno Setup Welcome page

I'm trying to create a label (or a bitmap) on the welcome page using this code:
LabelTarget := TLabel.Create(WizardForm);
with LabelTarget do
begin
Parent := WizardForm.WelcomePage;
Left := ScaleX(198);
Top := ScaleY(105);
Caption := 'Target';
end;
It won't work, but if I change the parent for example to WizardForm.InstallingPage it will create that label on Installing page. Where is the problem?
It's because almost whole area of the WelcomePage is covered by an opaque WelcomeLabel2.
The TLabel is not a real Windows control. It is a virtual one, drawn by the form itself. So it gets hidden by any other real Windows control, even if the TLabel is technically on top of it (what it is, as your LabelTarget is created later than the WelcomeLabel2). The WelcomeLabel2 is TStaticText, what is a real control. So it hides your LabelTarget.
To solve this either:
Shrink the WelcomeLabel2 height, or
Change your LabelTarget to TStaticText.

Inno Setup - aligning custom button with the Cancel button

I ve got problems to set a button on the same topsize as the Cancel button when im using WizardSizePercent = 150 in the Setup section.
Here is my code:
AboutButton := TNewButton.Create(WizardForm);
AboutButton.Parent := WizardForm;
AboutButton.Left := WizardForm.CancelButton.Left;
AboutButton.Top := WizardForm.CancelButton.Top;
AboutButton.Width := WizardForm.CancelButton.Width;
AboutButton.Height := WizardForm.CancelButton.Height;
I think Inno Setup doesn't notice the WizardSizePercent, because it only uses the regular WizardForm size.
I assume your code is in InitializeWizard. That event function occurs before WizardSizePercent is applied. If you want your button to correctly align when the wizard window changes size, either due to WizardSizePercent or WizardResizable, you need follow their documentation:
Use Anchors and KeepSizeY properties to add full support for WizardResizable and WizardSizePercent to all your custom controls, custom wizard pages and TSetupForm forms if you have any. See the CodeClasses.iss example script for an example.
So particularly:
AboutButton.Anchors := WizardForm.CancelButton.Anchors;
CancelButton.Anchors is [akRight, akBottom]. If your "About" button should be left-aligned, use:
AboutButton.Anchors := [akLeft, akBottom];
Related question:
Adding a Print button to the License page in Inno Setup (revisited for Inno Setup 6)

Inno Setup: How to display license page before custom page shows from procedure InitializeWizard();

I am using LicenseFile=D:\authorized\Builds\Integration\License.rtf to display license page and procedure InitializeWizard();.
The Problem is that the license page is displayed after the procedure InitializeWizard();. Is there any way we can display it before?
procedure InitializeWizard;
begin
{ Create the pages }
UsagePage := CreateInputOptionPage(wpWelcome,
'App setup information', 'How would you like to install App?',
'Would you like to install App as a service?.',
True, False);
UsagePage.Add('Yes');
UsagePage.Add('No');
UsagePage.Values[0] := true;
end;
It's a misunderstanding. The InitializeWizard function does not display anything. It just creates the custom page(s), it does not display them.
Try adding a MsgBox call at the end of the function. You will see that the message displays before the wizard form even pops up.
The order of the custom pages is determined by the AfterID parameter (the first one) of the Create*Page functions.
If you want the custom page to show after the license page, use wpLicense, instead of wpWelcome.
UsagePage := CreateInputOptionPage(wpLicense, ...);

How to stretch small wizard image over whole area in Inno Setup?

I need to stretch small wizard image in Inno Setup over the whole bitmap area and hide the labels like "select installation folder"... etc. What would be the corresponding code for this?
Set bounds of the WizardSmallBitmapImage to that of its parent
Hide the labels (PageDescriptionLabel and PageNameLabel)
procedure InitializeWizard();
begin
with WizardForm.WizardSmallBitmapImage do
SetBounds(Parent.Left, Parent.Top, Parent.Width, Parent.Height);
WizardForm.PageDescriptionLabel.Visible := False;
WizardForm.PageNameLabel.Visible := False;
end;

Resources