how to refresh a page in inno setup - inno-setup

I am completely new to inno setup.
I have an existing inno setup code which loads all the pages in the InitializeWizard(). I am trying to change the caption dynamically in the next page based on the radio button selected in the previous page.
ExpandConstant('Special note for the Microsoft ' + SelectedSQLServerVersion + ' Setup')
Here the SelectedSQLServerVersion is a variable which holds the dynamic value from the previous page and I can see the value in log. I tried to load the page again and was expecting the variable will be replaced with the dynamic value in the second time, but it was empty. Is there any way to solve this.
Thanks in advance,
DeeJay

Wizard pages have two common properties for the top bar labels, Caption and Description. In your case you can update them e.g. when the page is just displayed, from the CurPageChanged event:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
var
MyPage: TWizardPage;
procedure InitializeWizard;
begin
MyPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = MyPage.ID then
begin
MyPage.Caption := 'New caption';
MyPage.Description := 'New description';
end;
end;

Related

The official Inno Setup code to change Next button to Install with DisableReadyPage directive does not work

I'm using the code from:
http://www.jrsoftware.org/ishelp/index.php?topic=setup_disablereadypage
It should change the Next button caption to Install when the "Ready" page is disabled using DisableReadyPage directive.
[Setup]
DisableReadyPage=yes
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectProgramGroup then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
But it does not change Next button caption.
As the description of the code says:
For example, if the new last pre-installation wizard page is the Select Program Group page: ...
In your case the last pre-installation page is not Select Program Group page. It's the Select Destination Location page. Probably because you have DisableProgramGroupPage set to no, or you have set it to auto and you are upgrading (the application is installed already).
If you have the DisableProgramGroupPage set to no, the solution is simple, as the Select Destination Location page is always the last. Just replace the wpSelectProgramGroup with wpSelectDir.
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectDir then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
With auto (the default), you do not get any of Select Program Group and Select Destination Location on upgrade, but you get the Ready to Install even with DisableProgramGroupPage (as there would not be any other page before installation). You can use that fact to use Install both for Select Program Group page (for fresh installs) and Ready to Install (for upgrades).
Another issue with their code is that you should get a Finish button on the "Finished" page (wpFinished). What their code does not care for.
The complete solution is:
procedure CurPageChanged(CurPageID: Integer);
begin
// On fresh install the last pre-install page is "Select Program Group".
// On upgrade the last pre-install page is "Read to Install"
// (forced even with DisableReadyPage)
if (CurPageID = wpSelectProgramGroup) or (CurPageID = wpReady) then
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
// On the Finished page, use "Finish" caption.
else if (CurPageID = wpFinished) then
WizardForm.NextButton.Caption := SetupMessage(msgButtonFinish)
// On all other pages, use "Next" caption.
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
Had you have other pages, like Tasks page, you would have to alter the code accordingly.
Your screenshot shows the wpSelectDir page while in your code you change the button of the wpSelectProgramGroup page.

Inno Setup Skip custom page after execution of some scripts

so i am currently trying to modify the setup script,
What i was trying to do was after installing i enter in a custom page, this custom page executes 2 scritps(one for creating the database and the other for creating the tables).
while this is executing i want to display a custom label,and a continuous progress bar.
When the execution finish, i want to go directly to the finish page.
I wanto to also remove the next button.
Is this possible?
For the moment i have the custom page with a constinuous progress bar, this page appears after install.i will then add the label after finishing the progress bar part.
here is my code:
[CODE]
var
Page: TWizardPage;
ProgressBar3: TNewProgressBar;
procedure CreateTheWizardPages;
begin
Page := CreateCustomPage(wpInstalling, 'Base de dados', 'A verificar a base de dados');
ProgressBar3 := TNewProgressBar.Create(Page);
ProgressBar3.Left := 5;
ProgressBar3.Width := Page.SurfaceWidth - 5;
ProgressBar3.Parent := Page.Surface;
ProgressBar3.Style := npbstMarquee;
end;
procedure InitializeWizard();
begin
CreateTheWizardPages;
end;
//check the current page,if page equals to wpSelectCompnets, then we add the method on choose to the combobox fo types of installation
procedure CurPageChanged(CurPageID: Integer);
begin
//msgbox(IntToStr( CurPageID),mbInformation, MB_OK);
if CurPageID = wpSelectComponents then
begin
comboboxTypesInstalacao:=WizardForm.TypesCombo;
WizardForm.TypesCombo.OnChange:=#ComboBoxChange;
end
else if CurPageID = Page.ID then
begin
try
CreateDBAndTables('idontimedb.des');
finally
//close this custom wizard page and go to finish page
end;
end;
end;
Thanks in advance.

Inno Setup: Add button action for skipping to next page

In an Inno Setup installer, I need a separate custom button to mimic the behavior of clicking the next button, is their a function I can apply to the OnClick handler of the custom button to do this?
You can trigger the next button's OnClick event manually for instance this way (the only parameter here is the Sender, which is usually the object which triggered the event, but in the original next button click event handler is this parameter ignored, so let's pass an empty, nil object there):
WizardForm.NextButton.OnClick(nil);
So the rest is about creating your own button and calling a code like above to mimic the next button click, for example:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Code]
procedure MyNextButtonClick(Sender: TObject);
begin
WizardForm.NextButton.OnClick(nil);
end;
procedure InitializeWizard;
var
MyNextButton: TNewButton;
begin
MyNextButton := TNewButton.Create(WizardForm);
MyNextButton.Parent := WizardForm;
MyNextButton.Left := 10;
MyNextButton.Top := WizardForm.NextButton.Top;
MyNextButton.Caption := 'Click me!';
MyNextButton.OnClick := #MyNextButtonClick;
end;

Inno how to add <Skip> button for optional wizard page?

I have an optional wizard page of TInputDirWizardPage type.
How to add button which will not validate data and skip if data were not entered?
Did you check the inno help, here you see the available functions on the TInputDirWizardPage
TInputDirWizardPage = class(TWizardPage)
function Add(const APrompt: String): Integer;
property Buttons[Index: Integer]: TNewButton; read;
property Edits[Index: Integer]: TEdit; read;
property PromptLabels[Index: Integer]: TNewStaticText; read;
property SubCaptionLabel: TNewStaticText; read;
property Values[Index: Integer]: String; read write;
end;
I used this way only if i needed a text input on the page. I recommend you to create a complete custom WizardPage, with that you are more flexible. For the creation of the page you can use a designer, I created all my custom pages with the InnoSetup Form Designer. Here you can see it in action http://www.cenadep.org/2012/02/09/innosetup-form-designer/
I've found simple and working solution. Instead of adding additional button to avoid validation of empty path. I've just added default dir creation. in [Dirs] section.
[Dirs]
Name: {code:WrkGetWorkingDir}; Flags: uninsneveruninstall
My application could accept working dir cmdline arg or create default one if it is not specified. So. I just always specifying that cmdline arg and creating that default dir (if user did not changed that path) in installation script.
Hope this will help
procedure OnClickMyButton(Sender: TObject);
begin
MsgBox('OnClickMyButton', mbInformation, MB_OK);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = YourPageID.ID then
begin
MyButton := TButton.Create(YourPageID);
MyButton.Parent := YourPageID.Buttons[0].Parent;
MyButton.Top := YourPageID.Edits[0].Top + YourPageID.Edits[0].Height + 10;
MyButton.Left := YourPageID.Edits[0].Left;
MyButton.Width := 100;
MyButton.Caption := 'My Custom Button';
MyButton.OnClick := #OnClickMyButton;
end;
end;

inno setup bmp image appear on a single page

I want a bmp image to appear on a single page "selectadditionaltasks" but it appears on all pages. What am I doing wrong?
procedure LogoOnClick(Sender: TObject);
var ResCode: Integer;
begin
end;
procedure LogoWizard();
var
BtnPanel: TPanel;
BtnImage: TBitmapImage;
begin
ExtractTemporaryFile('Logo.bmp')
BtnPanel:=TPanel.Create(WizardForm)
with BtnPanel do begin
Left:=40
Top:=250
Width:=455
Height:=42
Cursor:=crHand
OnClick:=#logoOnClick
Parent:=WizardForm
end
BtnImage:=TBitmapImage.Create(WizardForm)
with BtnImage do begin
AutoSize:=True;
Enabled:=False;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\Logo.bmp')
Parent:=BtnPanel
end
end;
procedure InitializeWizard();
begin
LogoWizard();
end;
image example
By setting a Parent of your BtnPanel to the WizardForm you're telling, that you want that panel to be an immediate child of the whole wizard form. You'd have to change the BtnPanel.Parent property to the page surface, on which you want that panel to appear.
Since you want your image to appear on the Select Additional Tasks wizard page, the best I can suggest is to use just the image without an underlying panel and resize the TasksList check list box, which by default covers also the bottom area of the page, where you want to place your image. And that does the following script. You may follow the commented version of this script as well:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
Source: "Logo.bmp"; Flags: dontcopy
[Tasks]
Name: associate; Description: "&Associate files"; Flags: unchecked
Name: desktopicon; Description: "Create a &desktop icon"; Flags: unchecked
[Code]
procedure LogoOnClick(Sender: TObject);
begin
MsgBox('Hello!', mbInformation, MB_OK);
end;
procedure InitializeWizard;
var
BtnImage: TBitmapImage;
begin
ExtractTemporaryFile('Logo.bmp');
BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
Parent := WizardForm.SelectTasksPage;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\Logo.bmp');
AutoSize := True;
Left := 0;
Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height -
Height - 8;
Cursor := crHand;
OnClick := #LogoOnClick;
end;
WizardForm.TasksList.Height :=
WizardForm.TasksList.Height - BtnImage.Height - 8;
end;

Resources