Change WizardSmallImageFile programmatically - Inno Setup - inno-setup

Is it possible to change the top image on a wizard form depending on the wizard form. I can change the left side image but would like to change the top (small image).
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = 4 then
filename:= 'babylontoolbar.bmp'
else
filename:= 'label2-crop.bmp';
ExtractTemporaryFile(filename);
(*WizardForm.WizardSmallImageFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\'+FileName));*)
WizardForm.WizardBitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\' + FileName));
end;
I just would like to know how to reference the small file to replace the WizardSmallImageFile which does not work.

The WizardSmallImageFile directive is mapped to the WizardSmallBitmapImage control of the WizardForm, so in code you can access it this way (anyway, do not hardcode page ID numbers, but instead use the intended PageID constants):
procedure CurPageChanged(CurPageID: Integer);
var
FileName: string;
begin
if CurPageID = wpInfoBefore then
FileName := 'babylontoolbar.bmp'
else
FileName := 'label2-crop.bmp';
ExtractTemporaryFile(FileName);
WizardForm.WizardSmallBitmapImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\' + FileName));
end;

Once again TLama has the answers, just have to keep googling. For those trying to do something similar to this and having problems finding the answer check out Skipping custom pages based on optional components in Inno Setup

Related

Remove image from the last Finished page of Inno Setup

How to customize last page (wpFinished) to only have a message, but keep the bottom buttons, like this:
I don't want the image on the left that is there by default.
I was trying to create new page, but don't know how to hide the default finished page or add bottom buttons (Back, Finished, Cancel) on new page.
Hide the WizardBitmapImage2 control and extend remaining controls accordingly.
Something like this:
[Code]
procedure ExtendFinishedPageControl(Control: TControl);
begin
Control.Left := Control.Left - WizardForm.WizardBitmapImage2.Width;
Control.Width := Control.Width + WizardForm.WizardBitmapImage2.Width;
end;
procedure InitializeWizard();
begin
WizardForm.WizardBitmapImage2.Visible := False;
ExtendFinishedPageControl(WizardForm.RunList);
ExtendFinishedPageControl(WizardForm.NoRadio);
ExtendFinishedPageControl(WizardForm.YesRadio);
ExtendFinishedPageControl(WizardForm.FinishedLabel);
ExtendFinishedPageControl(WizardForm.FinishedHeadingLabel);
end;

Loop Commands or Functions Until a Condition becomes True in Inno Setup

I want to show a Nice Welcome Animated GIF to my users when running my Program Installer created using Inno Setup.
I want to display some PNG Images to an order (As Inno Setup doesn't support displaying Animated GIFs yet) using Isgsg.dll until Setup finishes initializing my tons of codes.
I wrote a code to show those PNG Images in order, but it stops after last one is shown.
I need to continue showing from first PNG Image after last one shown before.
If Setup was initialized,(I mean if WizardForm is visible) the Looping Procedure should stop.
The Codes I wrote to display those PNG Images:
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
if Result = True then begin
ExtractTemporaryFile('Welcome1.png');
ExtractTemporaryFile('Welcome2.png');
ExtractTemporaryFile('Welcome3.png');
ExtractTemporaryFile('Welcome4.png');
ExtractTemporaryFile('Welcome5.png');
ExtractTemporaryFile('Welcome6.png');
ExtractTemporaryFile('Welcome7.png');
<<< LOOPING SHOULD BEGIN FROM HERE >>>
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome1.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome2.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome3.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome4.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome5.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome6.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome7.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
<<< LOOPING SHOULD CONTINUE FROM HERE IF NOT WizardForm VISIBLE, OTHERWISE LOOPING SHOULD BE STOPPED >>>
...
end;
How can I do this as I expect?
UPDATED QUESTION
I can't think why this Code is not working.
This DLL requires PNG File's Filename as an AnsiString.
But I've provided a String.
Is this gone wrong or any other Synatx Error Here for this to not working?
Not Working means those PNG Images Showing Loop Procedure not working.
The Code I tried to add to do this Conditional Loop using Repeat Until:
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
IMessageHandler: TForm;
X: Integer;
ErrorCode: Integer;
LblWait: TLabel;
if Result := True then begin
DlgWait := TForm.Create(nil);
DlgWait.Hide;
begin
Order:=1;
Repeat
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome+IntToStr(Order)+.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
Order:=Order+1;
Until FileExists(ExpandConstant('{tmp}\Welcome+IntToStr(Order)+.png')) = False;
end;
end;
Are there any syntax Errors?
But Compiler doesn't give any Compiler Warning or Error.
Thanks in Advance.
You need to reset your counter when you've reached the end. Something like this should get you started. (NOTE: Untested - I don't have InnoSetup on this machine. Replace the test in the until with whatever is appropriate to detect the WizardForm being visible.)
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
IMessageHandler: TForm;
X: Integer;
ErrorCode: Integer;
LblWait: TLabel;
const
NumImages = 7;
begin
if Result then
begin
DlgWait := TForm.Create(nil);
DlgWait.Hide;
Order := 1;
repeat
ShowSplashScreen(DlgWait.Handle, ExpandConstant('{tmp}\Welcome' + IntToStr(Order) + '.png'), 0250, 1000, 0250, 0,255, True, $FFFFFF, 10);
Order := Order + 1;
if Order > NumImages then
Order := 1;
until WizardForm.Visible;
end;
end;

Inno Setup Place controls on wpPreparing Page

I am trying to place a label on the wpPreparing page to indicate uninstallation of an existing version, prior to running the new installation. Here is my code:
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
UninstallingLabel: TNewStaticText;
intResultCode: Integer;
begin
with UninstallingLabel do
begin
Caption := 'Uninstalling existing version...';
Left := WizardForm.StatusLabel.Left;
Top := WizardForm.StatusLabel.Top;
Parent := wpPreparing.Surface;
end;
if strExistingInstallPath <> '' then
begin
Exec(GetUninstallString, '/verysilent /suppressmsgboxes', '', SW_HIDE,
ewWaitUntilTerminated, intResultCode);
end;
end;
The trouble is it does not seem to like Parent := wpPreparing.Surface and compiling fails with a
Semicolon (;) expected
error. This syntax works when adding a label to a custom created page. Why does this fail when trying to add it to wpPreparing?
The wpPreparing is not an object, it's just a numerical constant.
The WizardForm.PreparingPage holds a reference to the "Preparing to Install" page. Note that it is of type TNewNotebookPage already, not TWizardPage. So you use it directly as a parent.
Also note that the StatusLabel is on the "Installing" page. You probably want to relate your new label to the PreparingLabel instead.
And you have to create the UninstallingLabel.
UninstallingLabel := TNewStaticText.Create(WizardForm);
with UninstallingLabel do
begin
Caption := 'Uninstalling existing version...';
Left := WizardForm.PreparingLabel.Left;
Top := WizardForm.PreparingLabel.Top;
Parent := WizardForm.PreparingPage;
end;
Though do you really want to shadow the PreparingLabel (as you use its coordinates).
What about reusing it instead?
WizardForm.PreparingLabel.Caption := 'Uninstalling existing version...';
I've replayed your code. It works if you use just WizardForm as the parent. But it's in the top left corner of the form...
wpPreparing is the name of a constant that holds the ID of the correspnding page.
And you have to create an instance of UninstallingLabel

How to disable edit boxes from a TInputQueryWizardPage input page?

Is it possible to conditionally disable or hide edit boxes from a TInputQueryWizardPage input page (page created by using CreateInputQueryPage function) ?
I have 4 edit boxes and I need to disable/hide the last two of them, based on the input from the previous wizard page. How can I do it ?
You can access them through the TInputQueryWizardPage.Edits indexed property:
[Code]
var
FirstEditIndex: Integer;
SecondEditIndex: Integer;
InputPage: TInputQueryWizardPage;
procedure InitializeWizard;
begin
InputPage := CreateInputQueryPage(wpWelcome, 'Caption', 'Dscription', 'SubCaption');
// the Add method returns the Index of the just added edit box, and
// you need to store those indexes to access the edit boxes later on
FirstEditIndex := InputPage.Add('Name:', False);
SecondEditIndex := InputPage.Add('Surname:', False);
// access the edits through the stored indexes; in your case this will
// happen in the other event, so take this script as a showcase
InputPage.Edits[FirstEditIndex].Enabled := False;
InputPage.Edits[SecondEditIndex].Visible := False;
end;

Inno CustomPage with full size background picture

Why my bitmap is not full screen size?
BitmapImage1 := TBitmapImage.Create(Page);
Its somehow made smaller by INNO ?
Tom, you must set the Parent,Align and Stretch properties to fill the background pf the custom page with your image.
try out this code
var
Page : TWizardPage;
BackgroundBitmapImage: TBitmapImage;
s: string;
begin
Page := CreateCustomPage(wpWelcome, 'Custom Page', 'Test');
ExtractTemporaryFile('background.bmp');
s:=ExpandConstant('{tmp}')+'\background.bmp';
BackgroundBitmapImage := TBitmapImage.Create(Page);
BackgroundBitmapImage.Bitmap.LoadFromFile(s);
BackgroundBitmapImage.Parent := Page.Surface;
BackgroundBitmapImage.Align:=alCLient;
BackgroundBitmapImage.Stretch:=True;
end;
is very nousy to do.
You must split your image in almost 3 piece
for WizardForm.MainPanel ( top strip of 60px)
for WizardForm.InnerPage (Center panel around Surface)
for mainPage.Surface (Inside inner Panel)
So is a big work of precise cutting....

Resources