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

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';

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.

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, ...);

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?

Show the download progress by default and no hide button

When starting to download files from my setup, it only appears total progress and the button details to show what appears in the next image:
What I want to do is to have that step by default without hitting details button and not showing the hide button.
I assume, that we are talking about this Inno Download Plugin. On its source code page I found the idp.iss script file which seems to be an interface to the library. It contains the idpShowDetails function which if you call with the show parameter set to True will show the detail components, that you can see by clicking the details button. What remains then is hiding that details button, which in the script is accessible through the IDPForm record variable's DetailsButton member. Through this member you can set the Visible property to False to hide that button.
To realize this without modifying the original scripts you can include the following piece of code into your existing script:
procedure CurPageChanged(CurPageID: Integer);
begin
// if the downloader page was just shown, then...
if CurPageID = IDPForm.Page.ID then
begin
// show the detail components
idpShowDetails(True);
// and hide the details button
IDPForm.DetailsButton.Visible := False;
end;
end;
And a screenshot:

Is it appropriate to create controls in the CurPageChanged procedure?

I have code in CurPageChanged that adds a button to the license window. My CurPageChanged starts like this:
procedure CurPageChanged(CurPageID: Integer);
var Button123 TButton;
begin
if CurPageID = wpLicense then begin
Button123 := TButton.Create(WizardForm.LicenseMemo.Parent);
My question is wouldn't that create a button each time the page is changed to the wpLicense page? So if a user clicks past the license dialog, then goes back to it, wouldn't that create another button? How can I ensure that only one button is created? What I'm looking for is the most appropriate procedure from which to add a control --once-- to an existing wp. Thanks
My question is wouldn't that create a button each time the page is changed to the wpLicense page? So if a user clicks past the license dialog, then goes back to it, wouldn't that create another button?
Yes, it would create multiple buttons each time. Because the pages do not get destroyed, the controls on them do not get destroyed. But you can actually take advantage of that fact to create a single control and then show/hide it when necessary.
To start, modify the InitializeWizard method, which is called only once before the wizard is displayed. Create the button in here, like so:
procedure InitializeWizard();
var
MyButton: TButton;
begin
MyButton := TButton.Create(WizardForm.LicenseMemo.Parent);
MyButton.Parent := WizardForm.LicenseMemo.Parent;
MyButton.Top := 0;
MyButton.Left := 0;
MyButton.Caption := 'My Custom Button';
...
end;

Resources