I would like to perform a overall font size increment in a InnoSetup installer, by an arbitrary multiplier factor (let's say 1.5x) or a percent value (let's say 150%).
This means changing the font size of ALL the controls that displays a text in the wizard pages (labels, textboxes, checkboxes, etc).
I'm allowed to set the WizardStyle directive to "Modern" if required to allow bigger texts to be shown properly within the wizard page. WizardResizable directive should be False.
Basically I'm requesting to learn how to do something similar like what WizardSizePercent directive does, but in my case something that is also able to change the font size of controls.
I'm not sure if I can already use one of the built-in directives for this. I didn't found anything in the docs.
I only found limited font sizes that I can change in the LangOptions section. I think none of these directives affects the font size of the controls within the wizard pages, except for the WelcomeFontSize directive.
Then, how could I achieve this?. Maybe with pascal-script I could do a for loop to iterate all the controls of the active wizard page and change the font size of each one?. Someone could provide an example of this for loop?.
UPDATE:
Thanks to ChatGPT AI and a lot of research from my side, "we" managed to partially achieve the task that performs an overall font text increase, with this code:
[Code]
procedure ChangeFontSize(Page: TWizardPage; Percent: Double);
var
Index: Integer;
Control: TControl;
StaticText: TNewStaticText;
PreviousSize: Integer;
NewSize: Integer;
PercentString: String;
begin
for Index := 0 to Page.Surface.ControlCount - 1 do
begin
Control := Page.Surface.Controls[Index];
if Control is TNewStaticText then
begin
StaticText := TNewStaticText(Control);
PreviousSize := StaticText.Font.Size;
PercentString := Copy(FloatToStr(Percent * 100), 1, 3) + '%'
NewSize := Round(PreviousSize * Percent);
StaticText.Font.Size:= NewSize;
// MsgBox(Format('Control Name: %s' + #13#10 +
// 'Previous Size: %d' + #13#10 +
// 'New Size: %d' + #13#10 +
// 'Percent: %s', [Control.Name, PreviousSize, NewSize, PercentString]), mbInformation, MB_OK);
end;
end;
end;
procedure InitializeWizard();
var
Pages: array of Integer;
Page: TWizardPage;
Index: Integer;
Percent: Double;
begin
Pages := [wpWelcome, wpLicense, wpPassword, wpInfoBefore,
wpUserInfo, wpSelectDir, wpSelectComponents,
wpSelectProgramGroup, wpSelectTasks, wpReady,
wpPreparing, wpInstalling, wpInfoAfter, wpFinished];
for Index := 0 to Length(Pages) - 1 do
begin
Page := PageFromID(Pages[Index])
Percent := 1.50 // +50% size increment
ChangeFontSize(Page, Percent);
end;
end;
The problems:
Some controls (see the image below) are not iterated in the loop of the code above. I think this is due "Page.Surface.Controls" does not contain those controls, or maybe the condition: "if Control is TNewStaticText" is of different type.
The font size of some controls are increased, yes, however, their bounds are not automatically adapted to this new size, so the text becomes unintelligible (see the image below).
This code update I think it almost fixes 1st problem, and makes a tiny little better work around 2nd problem, however still imperfect (useless):
[Code]
procedure ChangeFontSize(Page: TWizardPage; Percent: Double);
var
Index: Integer;
Control: TControl;
PercentString: String;
PreviousFontSize, NewFontSize: Integer;
NewControlWidth, NewControlHeight: Integer;
begin
for Index := 0 to Page.Surface.ControlCount - 1 do
begin
Control := Page.Surface.Controls[Index];
if Control is TButton then
PreviousFontSize := TButton(Control).Font.Size
else if Control is TCheckBox then
PreviousFontSize := TCheckBox(Control).Font.Size
else if Control is TComboBox then
PreviousFontSize := TComboBox(Control).Font.Size
else if Control is TEdit then
PreviousFontSize := TEdit(Control).Font.Size
else if Control is TForm then
PreviousFontSize := TForm(Control).Font.Size
else if Control is TLabel then
PreviousFontSize := TLabel(Control).Font.Size
else if Control is TListBox then
PreviousFontSize := TListBox(Control).Font.Size
else if Control is TMemo then
PreviousFontSize := TMemo(Control).Font.Size
else if Control is TNewCheckListBox then
PreviousFontSize := TNewCheckListBox(Control).Font.Size
else if Control is TNewStaticText then
PreviousFontSize := TNewStaticText(Control).Font.Size
else if Control is TPanel then
PreviousFontSize := TPanel(Control).Font.Size
else if Control is TPasswordEdit then
PreviousFontSize := TPasswordEdit(Control).Font.Size
else if Control is TRadioButton then
PreviousFontSize := TRadioButton(Control).Font.Size
else
Continue;
PercentString := Copy(FloatToStr(Percent * 100), 1, 3) + '%';
NewFontSize := Round(PreviousFontSize * Percent);
NewControlWidth := Round((Control.Width * NewFontSize) / PreviousFontSize)
NewControlHeight := Round(Control.Height * Percent);
if Control is TButton then
TButton(Control).Font.Size := NewFontSize
else if Control is TCheckBox then
TCheckBox(Control).Font.Size := NewFontSize
else if Control is TComboBox then
TComboBox(Control).Font.Size := NewFontSize
else if Control is TEdit then
TEdit(Control).Font.Size := NewFontSize
else if Control is TForm then
TForm(Control).Font.Size := NewFontSize
else if Control is TLabel then
TLabel(Control).Font.Size := NewFontSize
else if Control is TListBox then
TListBox(Control).Font.Size := NewFontSize
else if Control is TMemo then
TMemo(Control).Font.Size := NewFontSize
else if Control is TNewCheckListBox then
TNewCheckListBox(Control).Font.Size := NewFontSize
else if Control is TNewStaticText then
TNewStaticText(Control).Font.Size := NewFontSize
else if Control is TPanel then
TPanel(Control).Font.Size := NewFontSize
else if Control is TPasswordEdit then
TPasswordEdit(Control).Font.Size := NewFontSize
else if Control is TRadioButton then
TRadioButton(Control).Font.Size := NewFontSize
else
Continue;
Control.Width := NewControlWidth;
Control.Height := NewControlHeight;
// Control.Top := ...
// Control.Left := ...
// WizardForm.ClientWidth := Round(WizardForm.ClientWidth * Percent);
// MsgBox(Format('Control Name: %s' + #13#10 +
// 'Previous Size: %d' + #13#10 +
// 'New Size: %d' + #13#10 +
// 'Percent: %s', [Control.Name, PreviousFontSize, NewFontSize, PercentString]), mbInformation, MB_OK);
end;
end;
procedure InitializeWizard();
var
Pages: array of Integer;
Page: TWizardPage;
Index: Integer;
Percent: Double;
begin
Pages := [wpWelcome, wpLicense, wpPassword, wpInfoBefore,
wpUserInfo, wpSelectDir, wpSelectComponents,
wpSelectProgramGroup, wpSelectTasks, wpReady,
wpPreparing, wpInstalling, wpInfoAfter, wpFinished];
for Index := 0 to Length(Pages) - 1 do
begin
Page := PageFromID(Pages[Index])
Percent := 1.80 // +50% size increment
ChangeFontSize(Page, Percent);
end;
end;