Inno Setup: How to set orger wizard pages? [duplicate] - inno-setup

This question already has answers here:
How to add two custom pages in Inno Setup?
(2 answers)
Closed 5 years ago.
I have three wizard pages in my setup, and they have wrong order.
They open:
page 1.
page 2.
pagr 3.
I want order open: page 2 -> page 3 -> page 1.
I found article link and it talk about function CreateInputDirPage(const AfterID: Integer; const ACaption, ADescription, ASubCaption: String; AAppendDir: Boolean; ANewFolderName: String): TInputDirWizardPage;. I think that const AfterID changes order, but i don't know how.
Thank you for any idea.

If you look in the Innosetup documentation of BackButtonClick(), NextButtonClick(), you will see these functions uses a PageID for identification of current wizard page. Some IDs are wpWelcome, wpSelectComponents,...
So if you call FirstPage := CreateInputDirPage(...) for the first page AfterID may be something like wpSelectComponents. The return value is of type TInputDirWizardPage based on TWizardPage containing an ID. Maybe this ID is the wanted ID for the next CreateInputDirPage(...) call.

Related

Inno Setup Disable Next Button if user does not replace 'Enter' with anything else [duplicate]

This question already has answers here:
Inno Setup Disable Next button when input is not valid
(1 answer)
How to disable NextButton when file is not selected on InputFilePage (CreateInputFilePage)?
(1 answer)
Closed 4 years ago.
How do I prevent user from moving on if 'Enter' is not overwritten with anything else. Instead of 'Enter', I can also just make it blank. Regardless, the user must put something in there in order to enable the Next button. This is the second window after the welcome page that I need to do this with.
[Code]
var
SettingEnv: TInputQueryWizardPage;
procedure InitializeWizard;
begin
SettingEnv := CreateInputQueryPage(wpWelcome,
'User Input', '', 'Enter SettingEnv, then click Next.');
SettingEnv.Add('', False);
SettingEnv.Values[0] := 'Enter';
end;
I suggest you use:
function NextButtonClick(CurPageID: Integer): Boolean;
From the documentation:
Called when the user clicks the Next button. If you return True,
the wizard will move to the next page; if you return False, it will
remain on the current page (specified by CurPageID).
Note that this function is called on silent installs as well, even
though there is no Next button that the user can click. Setup instead
simulates "clicks" on the Next button. On a silent install, if your
NextButtonClick function returns False prior to installation starting,
Setup will exit automatically.
There is a related answer to a similar question which has code. This will help.

Inno Setup Change Caption of an existing radio button on custom options page

I'm new to Inno Setup. I'm using the Wizard pages to create an installer.
I've created an option page an some input pages.
On these input pages I get some values. Depending on such values I want to change the caption of an radio button already created in the initialize procedure of the wizard.
So, if a user entered 100-701 on an input page, I want to change the radio buttons caption on a later page to something like this:
(*) 100-701
( ) Standard
Can someone hint me, if there is a way to modify the caption or do i have to create a custom page from scratch?
Thanks,
Klaus
The CreateInputOptionPage function returns an instance of TInputOptionWizardPage class.
The class has CheckListBox property of type TNewCheckListBox, which it turn has ItemCaption property.
var
Page: TInputOptionWizardPage;
{ ... }
Page := CreateInputOptionPage(...);
Page.Add('Option 1');
Page.Add('Option 2');
{ ... }
Page.CheckListBox.ItemCaption[0] := 'Alternative caption for Option 1';
Page.CheckListBox.ItemCaption[1] := 'Alternative caption for Option 2';

Inno Setup - How to increase the separation between all the components of the component list?

I am using this code: Long descriptions on Inno Setup components. How to increase the separation between all the components of the component list?
Example:
And i want to see this:
There's TNewCheckListBox.MinItemHeight property that you can use to make a line in the checklist box higher, effectively increasing the spacing.
But problem is that setting the property does not affect existing items. And at the time the InitializeWizard is called, the WizardForm.ComponentsList is populated already.
What you can do is to programmatically change each item caption to trigger re-measuring of the item. Simple appending of a space will do (you can even strip it after the fact, if you wish).
procedure InitializeWizard();
var
I: Integer;
begin
{ Change line height }
WizardForm.ComponentsList.MinItemHeight := ScaleY(26);
{ Trigger re-measuring of component items }
for I := 0 to WizardForm.ComponentsList.Items.Count - 1 do
begin
WizardForm.ComponentsList.ItemCaption[I] :=
WizardForm.ComponentsList.ItemCaption[I] + ' ';
end;
end;
Or you can completely give up on the built-in components mechanism and build your own components-like page using plain checkboxes. You can layout those any way you like.
For an example of implementing a custom components page, see
Inno Setup - Create a dynamic list of components/types from external source (file or folder contents)
Or similar questions for creating custom task pages:
How to split tasklist at tasks page of Inno Setup into multiple columns?
How to build a Treeview design (a task group with tasks nesting hierarchy) using Inno Setup?

Reading values from custom Inno Setup wizard pages without using global variables

On this support page for creating a custom CreateInputOptionPage, they suggest storing the values of the page by just assigning them to a variable. It's not clear however WHEN this assignment should happen.'
From what I can tell, if you assign this right when you create the page, you will get the default value. This makes sense as when the page is created, user hasn't input any "Input Query"'s yet.
Therefore, I reasoned to assign the values from the page to a variable when the 'Next' button is clicked, using function NextButtonClick(CurPageID: Integer): Boolean;
In order to do that, I needed to access the page's variable (Page.Values[0]) in the NextButtonClick function. Since Page was defined in a different function, is the only way to access those values to have Page be a global variable? That's what I've resolved to do but I was wondering if anyone out there had an alternative to global variables.
Stub of my code so far.
[Code]
var
Page: TInputOptionWizardPage;
InstallationTypeIsClient: boolean;
procedure InitializeWizard();
begin
Page := CreateInputOptionPage(wpWelcome,'Installation Type', 'Select Installation Type', 'No really, do some selecting', True, False)
Page.Add('Server Install');
Page.Add('Client Install');
Page.Values[1] := True;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID=100 then
begin
InstallationTypeIsClient := Page.Values[1];
MsgBox('InstallationTypeIsClient value is ' + Format('%d', [InstallationTypeIsClient]), mbInformation, MB_OK);
end;
Result := True;
end;
Using a global variable to store the reference to the custom page is the correct and the easiest way.
Related question: Inno Setup: Access to custom control from OnClick event of another control.
Though it's questionable whether you really need to store the user value to another variable. Just read the value from the custom page at the moment you need it.
Using global variables in indeed frowned upon, in general. But that's, when you are developing a standalone code. In this case, you are just implementing event hooks for an existing application, so you have no other choice.
The only other way is to recursively lookup the custom page in child controls of the WizardForm. It's lot of code and quite inefficient.
See my answer to Inno Setup: OnHover event for an example of recursive component iteration.

In Inno Setup: How do you use/know the values for CurPageIDs for custom pages?

Lets say we set up a page using the CreateInputQueryPage function and we use the NextButtonClick event to control actions taken on that page. How do we refer to the correct CurPageID within that code?
First initialize your page as a global:
...
[code]
var
UserPage: TInputQueryWizardPage;
...
Then refer to that page variable (for example within the NextButtonClick event handler) like so:
UserPage.ID
See the example file CodeDlg.iss for an a complete example with the variable use in evidence.

Resources