Inno setup WordWrap and Autosize - inno-setup

I'm creating a setup using Inno Setup, and I changed license page to not show license, but to link to it instead. I also added a StaticText to show some text, and the problem is that when I add too much text, I need WordWrap := true, and AutoSize := false, and this makes StaticText width in Setup created really small. Why it is sized if AutoSize = false? What to do to prevent it from minimizing when WordWrap = true. Change parent?
procedure InitializeWizard;
var
FormButton: TNewButton;
Page: TWizardPage;
ComboBox: TNewComboBox;
begin
WizardForm.LicenseAcceptedRadio.Hide;
WizardForm.LicenseNotAcceptedRadio.Hide;
LicenseContextText := TNewStaticText.Create(WizardForm.InnerPage);
with LicenseContextText do
begin
Parent := WizardForm.InnerPage;
//TODO: check if we need
Left := ScaleX(250);
Top := ScaleY(50);
Height := ScaleY(100);
Width := ScaleX(1000); //200;
//Color := clBlack;
Font.Color := clGray;
//WordWrap := true;
//AutoSize := false;
Caption := 'Some content text, Some content text, Some content text';//
Visible := false;
end;
LicenseLinkLabel := TNewStaticText.Create(WizardForm.InnerPage);
with LicenseLinkLabel do
begin
Parent := WizardForm.InnerPage;
//TODO: check if we need
Left := 340;
Top := 240;
Height := 100;
Cursor := crHand;
Font.Color := clBlue;
Font.Style := [fsUnderline];
Caption := 'the License Agreement';
OnClick := #LicenseLinkLabelClick;
Visible := false;
end;
LicenseLinkURL := TNewCheckBox.Create(WizardForm.InnerPage);
with LicenseLinkURL do
begin
Parent := WizardForm.InnerPage;
Left := 277;
Top := 238;
Width := 60;
Caption := ' I accept';
OnClick := #OnLicenseCheckBoxClick;
Visible := false;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if (CurPageID = wpLicense) then
begin
WizardForm.Bevel1.Visible := false;
WizardForm.MainPanel.Visible := false;
WizardForm.InnerNotebook.Visible := false;
LicenseLinkLabel.Visible := true;
LicenseLinkURL.Visible := true;
LicenseContextText.Visible := true;

Set the AutoSize and WordWrap properties before you set the Width and Height properties.
This is unrelated, but also rather than hard-coding specific values for the sizes you might want to consider using sizes relative to existing elements in the WizardForm, to eg. have it automatically fit to the width of the page area within the form.

Related

Component Caption + Custom Component Page height

I have two #Martin Prikryl codes that I can't get them to work together.
Larger "Select Components" page in Inno Setup
Long descriptions on Inno Setup components
I followed all the instructions Martin said about the #TLama code, but the codes didn't work together.
Component captions do not appear when I activate the code to change the page height.
I would like a way to merge them and make them work together.
I solved the problem by adding the page's custom height value to the CompLabel.Top of the component captions code.
I also had to change the procedure to CurPageChanged and created an <event( ' ' )> to merge the two codes and created a directive #define CustomPageHeight "ScaleY(200)" to define the custom height of the page.
// Set page height here
#define CustomPageHeight "ScaleY(200)"
[Code]
// Final part of code for component captions
Var StopCall: Boolean;
<event('CurPageChanged')> // Added event here
Procedure CurPageChanged1(CurPageID: Integer);
Begin
If StopCall = false Then
Begin
If CurPageID = wpWelcome Then
Begin
SetTimer(0, 0, 50, CreateCallback(#HoverTimerProc));
CompLabel := TLabel.Create(WizardForm);
CompLabel.Parent := WizardForm.SelectComponentsPage;
CompLabel.Left := WizardForm.ComponentsList.Left;
CompLabel.Width := WizardForm.ComponentsList.Width;
CompLabel.Height := ScaleY(37); // Added here
CompLabel.Top := WizardForm.ComponentsList.Top + WizardForm.ComponentsList.Height + {#CustomPageHeight} - CompLabel.Height;
CompLabel.AutoSize := False;
CompLabel.WordWrap := True;
WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height - CompLabel.Height - ScaleY(2);
StopCall := true;
End;
End;
End;
// Code for custom height page
var
CompPageModified: Boolean;
<event('CurPageChanged')> // Added event here
procedure CurPageChanged2(CurPageID: Integer);
begin
if CurpageID = wpSelectComponents then
begin // Changed here
WizardForm.Height := WizardForm.Height + {#CustomPageHeight};
CompPageModified := True;
end
else
if CompPageModified then
begin // Changed here
WizardForm.Height := WizardForm.Height - {#CustomPageHeight};
CompPageModified := False;
end;
end;

Inno Setup: "Cannot focus disabled or invisible window" while setting ActiveControl property

I am trying to focus a button in a custom options window, which is shown modally. I have already read Prevent button from receiving focus in Inno Setup and tried the use the ActiveControl property to set this. Here is the code:
[Code]
{ Create and show the Options window }
procedure ShowOptionsWindow;
var
OptionsOKButton, OptionsCancelButton: TButton;
begin
OptionsWindowForm := TForm.Create(WizardForm);
with OptionsWindowForm do
begin
Parent := WizardForm;
BorderStyle := bsDialog;
Position := poOwnerFormCenter;
ClientWidth := ScaleX(425);
ClientHeight := ScaleY(165);
Caption := '{#AppName} Options';
end;
{ Define the Options Cancel button }
OptionsCancelButton := TButton.Create(OptionsWindowForm);
with OptionsCancelButton do
begin
Parent := OptionsWindowForm;
Left := (OptionsWindowForm.ClientWidth - WizardForm.NextButton.Width) - (WizardForm.ClientWidth - (WizardForm.CancelButton.Left + WizardForm.CancelButton.Width));
Top := (OptionsWindowForm.ClientHeight - WizardForm.NextButton.Height) - ScaleY(12);
Width := WizardForm.NextButton.Width;
Height := WizardForm.NextButton.Height;
Caption := 'Cancel';
OnClick := #OptionsCancelButtonClick;
end;
{ Define the Options OK button }
OptionsOKButton := TButton.Create(OptionsWindowForm);
with OptionsOKButton do
begin
Parent := OptionsWindowForm;
Left := (OptionsCancelButton.Left - WizardForm.NextButton.Width) - ((WizardForm.CancelButton.Left - WizardForm.NextButton.Left) - WizardForm.NextButton.Width);
Top := OptionsCancelButton.Top;
Width := WizardForm.NextButton.Width;
Height := WizardForm.NextButton.Height;
Caption := 'OK';
OnClick := #OptionsOKButtonClick;
end;
OptionsWindowForm.ActiveControl := OptionsOKButton;
OptionsWindowForm.ShowModal;
end;
However, when running this, it gives the following error:
I tried changing when this is called, by placing it after showing the window, but it doesn't get called until the window is closed, as ShowModal stops the scripts execution, when it still gives the same error. Is there a way to set a button to be focused in a modal window?
Your code is imo correct. It looks like a bug to me.
It's the setting of the OptionsWindowForm.Parent property that triggers the problem. Just remove it.

How to add a region drop-down in Inno Setup?

In the Inno script, I am using the language selection drop down. I am also storing the selected language to a file called "language.properties" using the below code. The installed application uses this "language.properties" file.
procedure CurStepChanged(CurStep: TSetupStep);
var
S: string;
begin
if CurStep = ssPostInstall then
begin
S := Format('language=%s', [ActiveLanguage]);
SaveStringToFile(ExpandConstant('{app}') + '\language.properties', S, False);
end;
end;
Now apart from language selection, I need to add a region selection drop down. The values for the regions is custom, (like America, Europe etc) meaning which there is no need to take from the windows registry.
When the user has selected the region, I need to store that to the same file "language.properties"
I am very new to Inno script. What do you think? How can this be done efficiently?
Edit: Since form the initial comments, it is not possible to customize the "Select Setup Language" dialog, how to add a custom wizard page for region selection?
This is a snippet of my application settings page. I have cut it down:
function AppSettings_CreatePage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
iUserValue: Cardinal;
strPath: String;
begin
Page := CreateCustomPage(
PreviousPageId,
ExpandConstant('{cm:ApplicationPreferences}'),
ExpandConstant('{cm:DefaultSettings}')
);
// lblInfo
lblInfo := TLabel.Create(Page);
with lblInfo do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:SpecifyDefaultSettings}');
Left := ScaleX(8);
Top := ScaleY(8);
Width := ScaleX(387);
Height := ScaleY(29);
end;
// lblDatabase
lblDatabase := TLabel.Create(Page);
with lblDatabase do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:DatabaseLanguage}');
Left := ScaleX(8);
Top := ScaleY(112);
Width := ScaleX(385);
Height := ScaleY(13);
end;
// cbDatabase
cbDatabase := TNewComboBox.Create(Page);
with cbDatabase do
begin
Parent := Page.Surface;
Left := ScaleX(8);
Top := ScaleY(128);
Width := ScaleX(177);
Height := ScaleY(21);
Style := csDropDownList;
TabOrder := 3;
// Languages
Items.Add({#LANG_AFK});
Items.Add({#LANG_TWI});
Items.Add({#LANG_DAN});
Items.Add({#LANG_DEU});
Items.Add({#LANG_ENG});
Items.Add({#LANG_ESP});
Items.Add({#LANG_FRA});
Items.Add({#LANG_IND});
Items.Add({#LANG_ITA});
Items.Add({#LANG_SWK});
Items.Add({#LANG_NLD});
Items.Add({#LANG_PLK});
Items.Add({#LANG_PTB});
Items.Add({#LANG_RUS});
Items.Add({#LANG_SQI});
Items.Add({#LANG_FIN});
Items.Add({#LANG_SVE});
Items.Add({#LANG_FPO});
Items.Add({#LANG_TRK});
Items.Add({#LANG_CHS});
Items.Add({#LANG_BGR});
Items.Add({#LANG_ELL});
Items.Add({#LANG_UKR});
Items.Add({#LANG_KHM});
Items.Add({#LANG_ROM});
Items.Add({#LANG_SMO});
Items.Add({#LANG_VIT});
Items.Add({#LANG_ARA});
// Get path where the program was last install
strPath := GetPathInstalled('Public Talks');
if ActiveLanguage = 'English' then ItemIndex := {#MDB_ENG_INDEX};
if ActiveLanguage = 'German' then ItemIndex := {#MDB_DEU_INDEX};
if ActiveLanguage = 'Spanish' then ItemIndex := {#MDB_ESP_INDEX};
if ActiveLanguage = 'Italian' then ItemIndex := {#MDB_ITA_INDEX};
if ActiveLanguage = 'Dutch' then ItemIndex := {#MDB_NLD_INDEX};
if ActiveLanguage = 'Turkish' then ItemIndex := {#MDB_TRK_INDEX};
if ActiveLanguage = 'Portuguese' then ItemIndex := {#MDB_PTB_INDEX};
if ActiveLanguage = 'Swedish' then ItemIndex := {#MDB_SVE_INDEX};
if ActiveLanguage = 'Danish' then ItemIndex := {#MDB_DAN_INDEX};
if ActiveLanguage = 'Russian' then ItemIndex := {#MDB_RUS_INDEX};
if ActiveLanguage = 'Finnish' then ItemIndex := {#MDB_FIN_INDEX};
if ActiveLanguage = 'Albanian' then ItemIndex := {#MDB_SQI_INDEX};
if ActiveLanguage = 'French' then ItemIndex := {#MDB_FRA_INDEX};
if ActiveLanguage = 'Greek' then ItemIndex := {#MDB_ELL_INDEX};
if ActiveLanguage = 'Romanian' then ItemIndex := {#MDB_ROM_INDEX};
end;
Result := Page.ID;
end;
That shows you how to show a drop list and select an entry.
I should point out that this is also referred to in the Help File supplied with Inno Setup that is also available online. See TNewComboBox topic. I admit it is rather sparse!

Inno Setup Update custom TSetupForm caption with nested TNewNotebook page change

I want to use custom uninstall wizard pages as in my Inno Setup script shown in question Custom Uninstall page (not MsgBox).
The problem I have is that the Caption of the TSetupForm does not update, when a page changes.
I tried using the following code.
[Code]
const
ControlGap = 5;
procedure UpdateButtonsState(Form: TSetupForm);
var
Notebook: TNewNotebook;
BtnBack, BtnNext: TButton;
begin
Notebook := TNewNotebook(Form.FindComponent('Notebook'));
BtnBack := TButton(Form.FindComponent('BtnBack'));
BtnNext := TButton(Form.FindComponent('BtnNext'));
BtnBack.Enabled := (Notebook.ActivePage <> Notebook.Pages[0]);
if Notebook.ActivePage <> Notebook.Pages[Notebook.PageCount - 1] then
begin
BtnNext.Caption := SetupMessage(msgButtonNext)
BtnNext.ModalResult := mrNone;
end
else
begin
BtnNext.Caption := SetupMessage(msgButtonFinish);
BtnNext.ModalResult := mrYes;
end;
end;
procedure BtnPageChangeClick(Sender: TObject);
var
NextPage: TNewNotebookPage;
Notebook: TNewNotebook;
Form: TWinControl;
Button, BtnBack, BtnNext: TButton;
begin
Button := TButton(Sender);
Form := Button;
while not (Form is TSetupForm) do
Form := Form.Parent;
Notebook := TNewNotebook(Form.FindComponent('Notebook'));
BtnBack := TButton(Form.FindComponent('BtnBack'));
BtnNext := TButton(Form.FindComponent('BtnNext'));
if (Button = BtnBack) and (Notebook.ActivePage = Notebook.Pages[0]) then
NextPage := nil
else
if (Button = BtnNext) and (Notebook.ActivePage = Notebook.Pages[Notebook.PageCount - 1]) then
NextPage := nil
else
NextPage := Notebook.FindNextPage(Notebook.ActivePage, Button = BtnNext);
Notebook.ActivePage := NextPage;
UpdateButtonsState(TSetupForm(Form));
end;
function AddPage(NotebookForm: TSetupForm): TNewNotebookPage;
var
Notebook: TNewNotebook;
begin
Notebook := TNewNotebook(NotebookForm.FindComponent('Notebook'));
Result := TNewNotebookPage.Create(Notebook);
Result.Notebook:=Notebook;
Result.Parent:=Notebook;
Result.Align := alClient;
if Notebook.ActivePage = nil then
Notebook.ActivePage := Result;
UpdateButtonsState(NotebookForm);
end;
function CreateNotebookForm: TSetupForm;
var
Notebook: TNewNotebook;
NotebookPage: TNewNotebookPage;
Pan: TPanel;
TmpLabel: TLabel;
MaxWidth, i: Integer;
BtnBack, BtnNext, BtnCancel: TButton;
BtnLabelMsgIDs: Array Of TSetupMessageID;
begin
Result := CreateCustomForm;
Result.SetBounds(0, 0, UninstallProgressForm.Width, UninstallProgressForm.Height);
Result.Position := poOwnerFormCenter;
Notebook := TNewNotebook.Create(Result);
Notebook.Parent := Result;
Notebook.Name := 'Notebook';
Notebook.Align := alClient;
Pan := TPanel.Create(Result);
Pan.Parent := Notebook;
Pan.Caption := '';
Pan.Align := alBottom;
BtnNext := TNewButton.Create(Result);
with BtnNext do
begin
Parent := Pan;
Name := 'BtnNext';
Caption := SetupMessage(msgButtonNext);
OnClick := #BtnPageChangeClick;
ParentFont := True;
end;
BtnBack := TNewButton.Create(Result);
with BtnBack do
begin
Parent := Pan;
Caption := SetupMessage(msgButtonBack);
Name := 'BtnBack';
OnClick := #BtnPageChangeClick;
ParentFont := True;
end;
BtnCancel := TNewButton.Create(Result);
with BtnCancel do
begin
Parent := Pan;
Name := 'BtnCancel';
Caption := SetupMessage(msgButtonCancel);
ModalResult := mrCancel;
Cancel := True;
ParentFont := True;
end;
TmpLabel := TLabel.Create(Result);
with TmpLabel do
begin
Left := 0;
Top := 0;
Parent := Pan;
ParentFont := True;
Visible := False;
WordWrap := False;
Autosize := True;
end;
SetArrayLength(BtnLabelMsgIDs, 4);
BtnLabelMsgIDs[0] := msgButtonBack;
BtnLabelMsgIDs[1] := msgButtonNext;
BtnLabelMsgIDs[2] := msgButtonCancel;
BtnLabelMsgIDs[3] := msgButtonFinish;
MaxWidth := 0;
for i := Low(BtnLabelMsgIDs) to High(BtnLabelMsgIDs) do
begin
TmpLabel.Caption := SetupMessage(BtnLabelMsgIDs[i]) + 'WWW';
if MaxWidth < TmpLabel.Width then
MaxWidth := TmpLabel.Width;
end;
TmpLabel.Caption := 'Yy';
with BtnBack do
begin
Width := MaxWidth;
Height := TmpLabel.Height*2;
Left := Parent.ClientWidth - 3*(MaxWidth + ScaleX(ControlGap));
Top := (Parent.ClientHeight - Height) div 2;
end;
with BtnNext do
begin
Width := MaxWidth;
Height := TmpLabel.Height*2;
Left := Parent.ClientWidth - 2*(MaxWidth + ScaleX(ControlGap));
Top := (Parent.ClientHeight - Height) div 2;
end;
with BtnCancel do
begin
Width := MaxWidth;
Height := TmpLabel.Height*2;
Left := Parent.ClientWidth - 1*(MaxWidth + ScaleX(ControlGap));
Top := (Parent.ClientHeight - Height) div 2;
end;
end;
procedure InitializeUninstallProgressForm;
var
Form: TSetupForm;
i: Integer;
NotebookPage: TNewNotebookPage;
ModResult: Integer;
begin
Form := CreateNotebookForm;
for i := 1 to 4 do
begin
NotebookPage := AddPage(Form);
with NotebookPage do
begin
Color := clWindow;
with TLabel.Create(Form) do
begin
Parent := NotebookPage;
SetBounds(0, 0, 50, 30);
Autosize := true;
Font.Size := 14;
Caption := 'Label ' + IntToStr(i);
end;
Form.Caption := 'CAPTION - ' + IntToStr(i);
{<<<NEVER UPDATES AND KEEPS SHOWING "CAPTION - 4">>>>}
end;
end;
ModResult := Form.ShowModal;
if ModResult = mrYes then
MsgBox('Continuing uninstall', mbInformation, MB_OK)
else
begin
MsgBox('Cancelled', mbInformation, MB_OK);
Abort;
end;
end;
Please help me to find why Caption of the TSetupForm (Here it is declared as Form) never updates.
Thanks in advance.
Of course, it doesn't. You have to update the form caption as the page changes.
A good place for this is the end of the UpdateButtonsState function:
procedure UpdateButtonsState(Form: TSetupForm);
{ ... }
begin
{ ... }
if Notebook.ActivePage <> nil then
Form.Caption := 'CAPTION - ' + IntToStr(Notebook.ActivePage.PageIndex + 1);
end;

Inno setup : How to set timers in between images slide show?

i Was Created one setup for slide show code is perfectly running as you given. But the images are flipping with in short span of time. So in between images i want to set timer so that i can able to see those images clearly. Is that possible ? if possible how to do please help me to do that
[code]
function InitializeSetup: Boolean;
begin
ExtractTemporaryFile('01.bmp');
ExtractTemporaryFile('02.bmp');
Result := True;
end;
procedure CurPageChanged(CurPageID: Integer);
var
BmpFile1, BmpFile2: TBitmapImage;
begin
if CurPageID = wpInstalling then begin
msgbox ('1. where are you' , mbinformation,mb_ok);
BmpFile1:= TBitmapImage.Create(WizardForm);
BmpFile1.Bitmap.LoadFromFile(ExpandConstant('{tmp}\01.bmp'));
BmpFile1.Width:= ScaleX(976);
// here you set Width (417px is Width of ProgressBar) for 1st BMP
BmpFile1.Height:= ScaleY(80);
// here you set Height for 1st BMP
BmpFile1.Stretch := True;
BmpFile1.Left := WizardForm.ProgressGauge.Left + ScaleX(0);
// here you set Left position for 1st BMP
BmpFile1.Top := WizardForm.ProgressGauge.Top + ScaleY(35);
// here you set Top posision for 1st BMP
BmpFile1.Parent:= WizardForm.InstallingPage;
BmpFile2:= TBitmapImage.Create(WizardForm);
BmpFile2.Bitmap.LoadFromFile(ExpandConstant('{tmp}\02.bmp'));
BmpFile2.Width:= ScaleX(976);
BmpFile2.Height:= ScaleY(80);
BmpFile2.Stretch := True;
BmpFile2.Left := WizardForm.ProgressGauge.Left + ScaleX(0);
BmpFile2.Top := BmpFile1.Top + BmpFile1.Height + ScaleY(8);
BmpFile2.Parent:= WizardForm.InstallingPage;
end;
end;

Resources