Splash screen - Slow image display - inno-setup

I'm trying to display a splash screen before running the installer (Inno Installer). Everything works ok, but I would like the image to appear incrementally and then disappear incrementally. Then the installer starts. Does anyone know what parameter to use for the splash screen ?
Thanks for any advice
Continued display of the splash screen image before launching the installer.
Example:
[] 2
// Show splash
SplashForm := CreateCustomForm;
SplashForm.BorderStyle := bsNone;
SplashBitmap := TBitmapImage.Create(SplashForm);
SplashBitmap.AutoSize := True;
SplashBitmap.Align := alClient;
SplashBitmap.Left := 0;
SplashBitmap.Top := 0;
SplashBitmap.Stretch := True;
SplashBitmap.Parent := SplashForm;
ExtractTemporaryFile('Dahlia.bmp');
SplashBitmap.Bitmap.LoadFromFile(ExpandConstant('{tmp}') + '\Dahlia.bmp');
SplashForm.Width := SplashBitmap.Width;
SplashForm.Height := SplashBitmap.Height;
SplashForm.SizeAndCenterOnShow := True;
SplashForm.Show;
SplashForm.Refresh;
Sleep(8000);
SplashForm.Close;

Related

Can you create a custom page that looks like the Finish page?

Can you create a custom page that looks like the Finish page?
This is the code for custom page,
UserPage2 := CreateCustomPage(
UserPage1.ID,
'Title',
'Details'
);
This custom page,
Needs to look like this,
The reason for this is because, sometimes when the user runs the installer again they will be able to select few options. Based on the options the installer needs to make few changes to the settings used by the installed program without overwriting the files by reinstalling. So the user should get the Finish dialog after the changes.
Recreate the FinishedPage controls on your custom page.
When entering the page, you need to resize WizardForm.InnerNotebook to cover whole wizard window (except for the bottom button area) and hide the page header controls.
var
FakeFinishedPage: TWizardPage;
FakeFinishedBitmapImage: TBitmapImage;
FakeFinishedLabel: TNewStaticText;
FakeFinishedHeadingLabel: TNewStaticText;
procedure CopyBounds(Dest, Source: TControl);
begin
Dest.Left := Source.Left;
Dest.Top := Source.Top;
Dest.Width := Source.Width;
Dest.Height := Source.Height;
end;
procedure FakeFinishedPageActivate(Sender: TWizardPage);
begin
WizardForm.Bevel1.Visible := False;
WizardForm.MainPanel.Visible := False;
WizardForm.InnerNotebook.Left := 0;
WizardForm.InnerNotebook.Top := 0;
WizardForm.InnerNotebook.Width := WizardForm.OuterNotebook.ClientWidth;
WizardForm.InnerNotebook.Height := WizardForm.OuterNotebook.ClientHeight;
// With WizardStyle=modern and/or WizardResizable=yes,
// we cannot copy the sizes in InitializeWizard as they are not final yet.
CopyBounds(FakeFinishedBitmapImage, WizardForm.WizardBitmapImage2);
FakeFinishedBitmapImage.Anchors := WizardForm.WizardBitmapImage2.Anchors;
CopyBounds(FakeFinishedLabel, WizardForm.FinishedLabel);
FakeFinishedLabel.Anchors := WizardForm.FinishedLabel.Anchors;
CopyBounds(FakeFinishedHeadingLabel, WizardForm.FinishedHeadingLabel);
FakeFinishedHeadingLabel.Anchors := WizardForm.FinishedHeadingLabel.Anchors;
WizardForm.BackButton.Visible := False;
WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish);
end;
procedure CopyLabel(Dest, Source: TNewStaticText);
begin
Dest.AutoSize := Source.AutoSize;
Dest.Font := Source.Font;
Dest.ShowAccelChar := Source.ShowAccelChar;
Dest.WordWrap := Source.WordWrap;
end;
procedure InitializeWizard();
var
S: string;
begin
// ...
FakeFinishedPage := CreateCustomPage(UserPage1.ID, '', '');
FakeFinishedPage.OnActivate := #FakeFinishedPageActivate;
FakeFinishedBitmapImage := TBitmapImage.Create(WizardForm);
FakeFinishedBitmapImage.Parent := FakeFinishedPage.Surface;
FakeFinishedBitmapImage.BackColor := WizardForm.WizardBitmapImage2.BackColor;
FakeFinishedBitmapImage.Bitmap := WizardForm.WizardBitmapImage2.Bitmap;
FakeFinishedBitmapImage.Stretch := WizardForm.WizardBitmapImage2.Stretch;
FakeFinishedLabel := TNewStaticText.Create(WizardForm);
FakeFinishedLabel.Parent := FakeFinishedPage.Surface;
CopyLabel(FakeFinishedLabel, WizardForm.FinishedLabel);
S := SetupMessage(msgFinishedLabelNoIcons) + #13#13 + SetupMessage(msgClickFinish);
StringChangeEx(S, '[name]', 'My Program', True);
FakeFinishedLabel.Caption := S;
FakeFinishedHeadingLabel := TNewStaticText.Create(WizardForm);
FakeFinishedHeadingLabel.Parent := FakeFinishedPage.Surface;
CopyLabel(FakeFinishedHeadingLabel, WizardForm.FinishedHeadingLabel);
S := SetupMessage(msgFinishedHeadingLabel);
StringChangeEx(S, '[name]', 'My Program', True);
FakeFinishedHeadingLabel.Caption := S;
end;
There are some limitations:
The code does not handle correctly image resizes, when the wizard resizes (with WizardResizable=yes) – it's easy to fix though.
The solution does not expect that any page will be shown after this fake finish pages shows. I.e. there's no Back button and it's expected that the Finish button is implement to kill the intallater. After all, this is a follow up question to Conditionally skip to a custom page at the end of the Inno Setup installation wizard without installing?
Though to avoid all these hacks, consider allowing the installation to proceed normally, but without changing anything. It might be easier to implement in the end.
Related questions:
Image covering whole page in Inno Setup – An alternative implementation that solves the problem by overlaying a control over whole upper part of the wizard window, hiding/showing it as needed.
Custom Welcome and Finished page with stretched image in Inno Setup
How to hide the main panel and show an image over the whole page?

How can I add a image banner on the bottom left of the wizard window?

How can I add an image to the setup wizard, the bottom left?
As #TLama commented: Create a TBitmapImage, set its parent to WizardForm, position it where you want and load the picture from file.
[Files]
Source: "logo.bmp"; Flags: dontcopy
[Code]
<event('InitializeWizard')>
procedure InitializeWizardAddLogo();
var
Image: TBitmapImage;
begin
Image := TBitmapImage.Create(WizardForm);
with Image do
begin
Parent := WizardForm;
ExtractTemporaryFile('logo.bmp');
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\logo.bmp');
AutoSize := True;
AutoSize := False;
Width := ScaleX(Width);
Height := ScaleY(Height);
Stretch := True;
Left := ScaleX(10);
Top :=
(WizardForm.ClientHeight + WizardForm.Bevel.Top +
WizardForm.Bevel.Height - Height)
div 2;
end;
end;
(the code [with event attribute] is for Inno Setup 6)
Though tricky part is to handle screen scaling correctly. Hence, the AutoSize trick and Scale* calls.
You even might need to have different versions of the logo for different scaling factors.
See Inno Setup WizardImageFile looks bad with font scaling on Windows 7

Inno Setup: "Cannot focus disabled or invisible window" while setting ActiveControl property

I am trying to focus a button in a custom options window, which is shown modally. I have already read Prevent button from receiving focus in Inno Setup and tried the use the ActiveControl property to set this. Here is the code:
[Code]
{ Create and show the Options window }
procedure ShowOptionsWindow;
var
OptionsOKButton, OptionsCancelButton: TButton;
begin
OptionsWindowForm := TForm.Create(WizardForm);
with OptionsWindowForm do
begin
Parent := WizardForm;
BorderStyle := bsDialog;
Position := poOwnerFormCenter;
ClientWidth := ScaleX(425);
ClientHeight := ScaleY(165);
Caption := '{#AppName} Options';
end;
{ Define the Options Cancel button }
OptionsCancelButton := TButton.Create(OptionsWindowForm);
with OptionsCancelButton do
begin
Parent := OptionsWindowForm;
Left := (OptionsWindowForm.ClientWidth - WizardForm.NextButton.Width) - (WizardForm.ClientWidth - (WizardForm.CancelButton.Left + WizardForm.CancelButton.Width));
Top := (OptionsWindowForm.ClientHeight - WizardForm.NextButton.Height) - ScaleY(12);
Width := WizardForm.NextButton.Width;
Height := WizardForm.NextButton.Height;
Caption := 'Cancel';
OnClick := #OptionsCancelButtonClick;
end;
{ Define the Options OK button }
OptionsOKButton := TButton.Create(OptionsWindowForm);
with OptionsOKButton do
begin
Parent := OptionsWindowForm;
Left := (OptionsCancelButton.Left - WizardForm.NextButton.Width) - ((WizardForm.CancelButton.Left - WizardForm.NextButton.Left) - WizardForm.NextButton.Width);
Top := OptionsCancelButton.Top;
Width := WizardForm.NextButton.Width;
Height := WizardForm.NextButton.Height;
Caption := 'OK';
OnClick := #OptionsOKButtonClick;
end;
OptionsWindowForm.ActiveControl := OptionsOKButton;
OptionsWindowForm.ShowModal;
end;
However, when running this, it gives the following error:
I tried changing when this is called, by placing it after showing the window, but it doesn't get called until the window is closed, as ShowModal stops the scripts execution, when it still gives the same error. Is there a way to set a button to be focused in a modal window?
Your code is imo correct. It looks like a bug to me.
It's the setting of the OptionsWindowForm.Parent property that triggers the problem. Just remove it.

Inno Setup - Customize installing page

How can I customize the installing page of Inno Setup?
Here exactly shows the changes that are going to be made.
Before
After
Now, status text 'Installing Collectica' will be static and not dynamic.
Also, adding extra time to the progress bar.
I will appreciate your answers. Thanks
You have to customize WizardForm.InstallingPage:
Hide the FilenameLabel and StatusLabel
Add you custom label
Add the image
For the first two:
procedure InitializeWizard();
var
CustomStatusLabel: TNewStaticText;
begin
WizardForm.FilenameLabel.Visible := False;
WizardForm.StatusLabel.Visible := False;
WizardForm.ProgressGauge.Top := WizardForm.InstallingPage.Height - ScaleY(60);
CustomStatusLabel := TNewStaticText.Create(WizardForm);
CustomStatusLabel.Parent := WizardForm.InstallingPage;
CustomStatusLabel.Caption := 'Installing Colectica';
CustomStatusLabel.Font.Size := CustomStatusLabel.Font.Size + 4;
CustomStatusLabel.Font.Style := [fsBold];
CustomStatusLabel.AutoSize := True;
CustomStatusLabel.Top :=
WizardForm.ProgressGauge.Top - CustomStatusLabel.Height - ScaleY(8);
CustomStatusLabel.Left :=
WizardForm.ProgressGauge.Left +
((WizardForm.ProgressGauge.Width - CustomStatusLabel.Width) div 2);
end;
For the image, see:
Inno Setup Placing image/control on custom page

Image covering whole page in Inno Setup

Following on from this: Inno Setup Placing image/control on custom page.
This is doing what I need:
CustomPage := CreateCustomPage(wpLicense, 'Heading', 'Sub heading.');
ExtractTemporaryFile('image.bmp');
BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
Parent := CustomPage.Surface;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
AutoSize := True;
AutoSize := False;
Height := ScaleX(Height);
Width := ScaleY(Width);
Stretch := True;
Left := ScaleX(90);
Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height -
Height - ScaleY(8);
Cursor := crHand;
OnClick := #ImageOnClick;
end;
However I would like the background image to be the full size of the space bellow the heading and above the footer with no side margins. I was trying various stretch/margin/height/width, but the results are messy. What's the best way to achieve this that looks good no matter the DPI?
You can retrieve a size of the (custom) page surface using TWizardPage.SurfaceHeight and TWizardPage.SurfaceWidth.
BtnImage.Height := CustomPage.SurfaceHeight;
BtnImage.Width := CustomPage.SurfaceWidth;
// Needed for WizardStyle=modern
BtnImage.Anchors := [akLeft, akTop, akRight, akBottom];
Though you will see that the (custom) page does not cover whole area between "header" (MainPanel) and "footer" (bottom part with buttons).
If you want to display image across the whole area between "header" and "footer", you cannot place it on the (custom) page. You have to place it on the InnerPage (what is a parent control of all pages with the "header").
BtnImage.Parent := WizardForm.InnerPage;
BtnImage.Left := 0;
BtnImage.Top := WizardForm.Bevel1.Top + 1;
BtnImage.Width := WizardForm.InnerPage.ClientWidth;
BtnImage.Height := WizardForm.InnerPage.ClientHeight - BtnImage.Top;
// Needed for WizardStyle=modern
BtnImage.Anchors := [akLeft, akTop, akRight, akBottom];
But that way the image won't get automatically shown/hidden as the custom page shows/hides. You have to code it. Use CurPageChanged event function.
procedure CurPageChanged(CurPageID: Integer);
begin
WizardForm.InnerNoteBook.Visible := (CurPageID <> CustomPage.ID);
BtnImage.Visible := (CurPageID = CustomPage.ID);
end;
Similar questions:
An alternative implementation that resizes the "pages" to cover whole upper parts of the wizard window:
Can you create a custom page that looks like the Finish page?
Displaying an image even over the "header":
How to hide the main panel and show an image over the whole page?
Displaying an image as a background of whole window: Inno Setup - Image as installer background.

Resources