In Inno Setup I have created a custom page with following code which has 3 text boxes.
Now I want to validate that text box on custom form next button click. If in text.text='2121212' something text is entered by user then only next button enabled.
[CustomMessages]
CustomForm_Caption=CustomForm Caption
CustomForm_Description=CustomForm Description
CustomForm_Label1_Caption0=College Name:
CustomForm_Label2_Caption0=Product Type:
CustomForm_Label3_Caption0=Product ID:
[Code]
var
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
{ CustomForm_Activate }
procedure CustomForm_Activate(Page: TWizardPage);
begin
// enter code here...
end;
{ CustomForm_ShouldSkipPage }
function CustomForm_ShouldSkipPage(Page: TWizardPage): Boolean;
begin
Result := False;
end;
{ CustomForm_BackButtonClick }
function CustomForm_BackButtonClick(Page: TWizardPage): Boolean;
begin
Result := True;
end;
{ CustomForm_NextkButtonClick }
function CustomForm_NextButtonClick(Page: TWizardPage): Boolean;
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\SGS2.2\CS',
'College Name', Edit1.Text);
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\SGS2.2\CS',
'Product Type', Edit2.Text);
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\SGS2.2\CS',
'Product ID', Edit3.Text);
Result := True;
end;
{ CustomForm_CancelButtonClick }
procedure CustomForm_CancelButtonClick(Page: TWizardPage; var Cancel, Confirm: Boolean);
begin
// enter code here...
end;
{ CustomForm_CreatePage }
function CustomForm_CreatePage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
begin
Page := CreateCustomPage(
PreviousPageId,
ExpandConstant('{cm:CustomForm_Caption}'),
ExpandConstant('{cm:CustomForm_Description}')
);
{ Label1 }
Label1 := TLabel.Create(Page);
with Label1 do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_Label1_Caption0}');
Left := ScaleX(16);
Top := ScaleY(24);
Width := ScaleX(70);
Height := ScaleY(13);
end;
{ Label2 }
Label2 := TLabel.Create(Page);
with Label2 do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_Label2_Caption0}');
Left := ScaleX(17);
Top := ScaleY(56);
Width := ScaleX(70);
Height := ScaleY(13);
end;
{ Label3 }
Label3 := TLabel.Create(Page);
with Label3 do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:CustomForm_Label3_Caption0}');
Left := ScaleX(17);
Top := ScaleY(88);
Width := ScaleX(70);
Height := ScaleY(13);
end;
{ Edit1 }
Edit1 := TEdit.Create(Page);
with Edit1 do
begin
Parent := Page.Surface;
Left := ScaleX(115);
Top := ScaleY(24);
Width := ScaleX(273);
Height := ScaleY(21);
TabOrder := 0;
end;
{ Edit2 }
Edit2 := TEdit.Create(Page);
with Edit2 do
begin
Parent := Page.Surface;
Left := ScaleX(115);
Top := ScaleY(56);
Width := ScaleX(273);
Height := ScaleY(21);
TabOrder := 1;
end;
{ Edit3 }
Edit3 := TEdit.Create(Page);
with Edit3 do
begin
Parent := Page.Surface;
Left := ScaleX(115);
Top := ScaleY(88);
Width := ScaleX(273);
Height := ScaleY(21);
TabOrder := 2;
end;
with Page do
begin
OnActivate := #CustomForm_Activate;
OnShouldSkipPage := #CustomForm_ShouldSkipPage;
OnBackButtonClick := #CustomForm_BackButtonClick;
OnNextButtonClick := #CustomForm_NextButtonClick;
OnCancelButtonClick := #CustomForm_CancelButtonClick;
end;
Result := Page.ID;
end;
{ CustomForm_InitializeWizard }
procedure InitializeWizard();
begin
CustomForm_CreatePage(wpWelcome);
end;
This should get you started:
; -- CodeDlg.iss --
;
; This script shows how to insert custom wizard pages into Setup and how to handle
; these pages. Furthermore it shows how to 'communicate' between the [Code] section
; and the regular Inno Setup sections using {code:...} constants. Finally it shows
; how to customize the settings text on the 'Ready To Install' page.
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DisableProgramGroupPage = yes
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
[CustomMessages]
CustomForm_Caption=CustomForm Caption
CustomForm_Description=CustomForm Description
CustomForm_Label1_Caption0=College Name:
CustomForm_Label2_Caption0=Product Type:
CustomForm_Label3_Caption0=Product ID:
[Code]
Var
Page: TWizardPage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
procedure EdtOnChange (Sender: TObject);
Var
MyEdit : TEdit;
begin
MyEdit := TEdit(Sender);
if MyEdit.Text = '2121212' then
WizardForm.NextButton.Enabled := true
Else
WizardForm.NextButton.Enabled := false;
end;
procedure InitializeWizard;
Var
CheckBox: TCheckBox;
begin
Page := CreateCustomPage( wpWelcome, ExpandConstant('{cm:CustomForm_Caption}'), ExpandConstant('{cm:CustomForm_Description}') );
{ Label1 } Label1 := TLabel.Create(Page); with Label1 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm:CustomForm_Label1_Caption0}'); Left := ScaleX(16); Top := ScaleY(24); Width := ScaleX(70); Height := ScaleY(13); end;
{ Label2 } Label2 := TLabel.Create(Page); with Label2 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm:CustomForm_Label2_Caption0}'); Left := ScaleX(17); Top := ScaleY(56); Width := ScaleX(70); Height := ScaleY(13); end;
{ Label3 } Label3 := TLabel.Create(Page); with Label3 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm:CustomForm_Label3_Caption0}'); Left := ScaleX(17); Top := ScaleY(88); Width := ScaleX(70); Height := ScaleY(13); end;
{ Edit1 } Edit1 := TEdit.Create(Page); with Edit1 do begin Parent := Page.Surface; Left := ScaleX(115); Top := ScaleY(24); Width := ScaleX(273); Height := ScaleY(21); TabOrder := 0; end;
{ Edit2 } Edit2 := TEdit.Create(Page); with Edit2 do begin Parent := Page.Surface; Left := ScaleX(115); Top := ScaleY(56); Width := ScaleX(273); Height := ScaleY(21); TabOrder := 1; end;
{ Edit3 } Edit3 := TEdit.Create(Page); with Edit3 do begin Parent := Page.Surface; Left := ScaleX(115); Top := ScaleY(88); Width := ScaleX(273); Height := ScaleY(21); TabOrder := 2; end;
Edit3.OnChange := #EdtOnChange;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
If CurPageID = Page.ID Then
WizardForm.NextButton.Enabled := false;
end;
end.
As it's written, it checks the third text box for the '2121212' value. If you'd like it on the first or second box, you'd want to add an OnChange event handler for the appropriate edit box.
Related
How can I make a button or a text in the Inno Setup installer that opens a web page when clicked?
To open a webpage, use:
procedure OpenBrowser(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
See also How to show a hyperlink in Inno Setup?
To link this with a button, use:
procedure ButtonClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;
procedure InitializeWizard();
var
Button: TButton;
begin
Button := TButton.Create(WizardForm);
Button.Parent := WizardForm;
Button.Left := ScaleX(16);
Button.Top := WizardForm.NextButton.Top;
Button.Width := WizardForm.NextButton.Width;
Button.Height := WizardForm.NextButton.Height;
Button.Caption := 'Link';
Button.OnClick := #ButtonClick;
end;
To link this with a label, use:
procedure LinkLabelClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;
procedure InitializeWizard();
var
LinkLabel: TLabel;
begin
LinkLabel := TLabel.Create(WizardForm);
LinkLabel.Parent := WizardForm;
LinkLabel.Left := ScaleX(16);
LinkLabel.Top :=
WizardForm.NextButton.Top + (WizardForm.NextButton.Height div 2) -
(LinkLabel.Height div 2);
LinkLabel.Caption := 'Link';
LinkLabel.ParentFont := True;
LinkLabel.Font.Style := LinkLabel.Font.Style + [fsUnderline];
LinkLabel.Font.Color := clBlue;
LinkLabel.Cursor := crHand;
LinkLabel.OnClick := #LinkLabelClick;
end;
I'm trying to create something like this:
I want the check box to be hidden behind the lock image, and clicking on it will open a form requesting code entry, and if the code is correct the image will be removed and the check box will be available.
Here's what I tried:
[files]
Source: "Lock.bmp"; Flags: dontcopy
{...}
[code]
var
CustomFuncPage: TWizardPage;
CBAdvFunctions: TNewCheckBox;
Locked: TBitmapImage;
procedure OnClickLock(Sender: TObject);
var
PassForm: TSetupForm;
Edit: TNewEdit;
OKButton, CancelButton: TNewButton;
begin
PassForm := CreateCustomForm();
PassForm.ClientWidth := ScaleX(256);
PassForm.ClientHeight := ScaleY(128);
PassForm.Caption := 'Password required';
Edit := TNewEdit.Create(PassForm);
Edit.Top := ScaleY(10);
Edit.Left := ScaleX(10);
Edit.Width := PassForm.ClientWidth - ScaleX(20);
Edit.Height := ScaleY(23);
Edit.Anchors := [akLeft, akTop, akRight];
Edit.Parent := PassForm;
OKButton := TNewButton.Create(PassForm);
OKButton.Parent := PassForm;
OKButton.Caption := 'OK';
OKButton.Left := PassForm.ClientWidth - ScaleX(166);
OKButton.Top := PassForm.ClientHeight - ScaleY(33);
OKButton.Height := ScaleY(23);
OKButton.Anchors := [akRight, akBottom]
OKButton.ModalResult := mrOk;
OKButton.Default := True;
CancelButton := TNewButton.Create(PassForm);
CancelButton.Parent := PassForm;
CancelButton.Caption := 'Cancel';
CancelButton.Left := PassForm.ClientWidth - ScaleX(85);
CancelButton.Top := PassForm.ClientHeight - ScaleY(33);
CancelButton.Height := ScaleY(23);
CancelButton.Anchors := [akRight, akBottom]
CancelButton.ModalResult := mrCancel;
CancelButton.Cancel := True;
PassForm.ActiveControl := Edit;
if PassForm.ShowModal() = mrOk then
begin
if Edit.Text = '1234' then
begin
Locked.Free;
PassForm.Free;
end else
begin
MsgBox('Password incorrect', mbError, MB_OK);
PassForm.Free;
end;
end else
begin
PassForm.Free;
end;
end;
Procedure InitializeWizard;
begin
CustomFuncPage := CreateCustomPage(wpSelectProgramGroup, {...}, {...});
CBAdvFunctions := TNewCheckBox.Create(CustomFuncPage);
CBAdvFunctions.Parent := CustomFuncPage.Surface;
CBAdvFunctions.Top := 0;
CBAdvFunctions.Left := 0;
CBAdvFunctions.Caption := 'Advanced Functions'
CBAdvFunctions.Width := ScaleX(130);
CBAdvFunctions.Cursor := 1;
CBAdvFunctions.SendToBack;
ExtractTemporaryFile('Lock.bmp');
Locked := TBitmapImage.Create(CustomFuncPage);
Locked.Parent := CustomFuncPage.Surface;
Locked.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Lock.bmp'));
Locked.Bitmap.AlphaFormat := afPremultiplied;
Locked.SetBounds(0, 0, CBAdvFunctions.Width, CBAdvFunctions.Height);
Locked.Stretch := True;
Locked.BringToFront;
Locked.OnClick := #OnClickLock;
{...}
And this is the result:
This is the image I used:
I tried a few ways, but was unable to get the image to cover the checkbox.
Maybe someone has an idea?
By the way, maybe someone has an explanation for why the background of the image is not transparent?
I have added new checkboxes to my inno setup tasks page but i dont know how to make them work with the tasks, i want them to work with the [Tasks] zone in the script.
[Tasks]
Name: "Newcheckboox1"; Description: "Newcheckbox1"; MinVersion: 0.0,5.0
Name: "Newcheckboox2"; Description: "Newcheckbox2"; MinVersion: 0.0,5.0
other tasks checkboxes here.........
Here an image:
Here the code generated when the checkboxes are added:
[Code]
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
var
NewGroupBox1: TNewGroupBox;
NewCheckBox1: TNewCheckBox;
NewCheckBox2: TNewCheckBox;
NewCheckBox3: TNewCheckBox;
NewGroupBox2: TNewGroupBox;
NewCheckBox4: TNewCheckBox;
NewCheckBox5: TNewCheckBox;
NewGroupBox3: TNewGroupBox;
NewCheckBox6: TNewCheckBox;
NewCheckBox7: TNewCheckBox;
NewCheckBox8: TNewCheckBox;
procedure RedesignWizardForm;
begin
with WizardForm.SelectTasksLabel do
begin
Visible := False;
Left := ScaleX(392);
end;
{ NewGroupBox1 }
NewGroupBox1 := TNewGroupBox.Create(WizardForm);
with NewGroupBox1 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(0);
Top := ScaleY(0);
Width := ScaleX(145);
Height := ScaleY(238);
Caption := 'NewGroupBox1';
end;
{ NewCheckBox1 }
NewCheckBox1 := TNewCheckBox.Create(WizardForm);
with NewCheckBox1 do
begin
Parent := NewGroupBox1;
Left := ScaleX(8);
Top := ScaleY(16);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox1';
end;
{ NewCheckBox2 }
NewCheckBox2 := TNewCheckBox.Create(WizardForm);
with NewCheckBox2 do
begin
Parent := NewGroupBox1;
Left := ScaleX(8);
Top := ScaleY(40);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox2';
end;
{ NewCheckBox3 }
NewCheckBox3 := TNewCheckBox.Create(WizardForm);
with NewCheckBox3 do
begin
Parent := NewGroupBox1;
Left := ScaleX(8);
Top := ScaleY(64);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox3';
end;
NewCheckBox1.TabOrder := 0;
NewCheckBox2.TabOrder := 1;
NewCheckBox3.TabOrder := 2;
{ NewGroupBox2 }
NewGroupBox2 := TNewGroupBox.Create(WizardForm);
with NewGroupBox2 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(152);
Top := ScaleY(0);
Width := ScaleX(265);
Height := ScaleY(97);
Caption := 'NewGroupBox2';
end;
{ NewCheckBox4 }
NewCheckBox4 := TNewCheckBox.Create(WizardForm);
with NewCheckBox4 do
begin
Parent := NewGroupBox2;
Left := ScaleX(8);
Top := ScaleY(16);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox4';
end;
{ NewCheckBox5 }
NewCheckBox5 := TNewCheckBox.Create(WizardForm);
with NewCheckBox5 do
begin
Parent := NewGroupBox2;
Left := ScaleX(8);
Top := ScaleY(40);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox5';
end;
NewCheckBox4.TabOrder := 0;
NewCheckBox5.TabOrder := 1;
{ NewGroupBox3 }
NewGroupBox3 := TNewGroupBox.Create(WizardForm);
with NewGroupBox3 do
begin
Parent := WizardForm.SelectTasksPage;
Left := ScaleX(152);
Top := ScaleY(96);
Width := ScaleX(265);
Height := ScaleY(142);
Caption := 'NewGroupBox3';
end;
{ NewCheckBox6 }
NewCheckBox6 := TNewCheckBox.Create(WizardForm);
with NewCheckBox6 do
begin
Parent := NewGroupBox3;
Left := ScaleX(16);
Top := ScaleY(24);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox6';
end;
{ NewCheckBox7 }
NewCheckBox7 := TNewCheckBox.Create(WizardForm);
with NewCheckBox7 do
begin
Parent := NewGroupBox3;
Left := ScaleX(16);
Top := ScaleY(48);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox7';
end;
{ NewCheckBox8 }
NewCheckBox8 := TNewCheckBox.Create(WizardForm);
with NewCheckBox8 do
begin
Parent := NewGroupBox3;
Left := ScaleX(16);
Top := ScaleY(72);
Width := ScaleX(97);
Height := ScaleY(17);
Caption := 'NewCheckBox8';
end;
NewCheckBox6.TabOrder := 0;
NewCheckBox7.TabOrder := 1;
NewCheckBox8.TabOrder := 2;
NewGroupBox1.TabOrder := 2;
NewGroupBox2.TabOrder := 3;
NewGroupBox3.TabOrder := 4;
{ ReservationBegin }
// This part is for you. Add your specialized code here.
{ ReservationEnd }
end;
// Don't modify this section. It is generated automatically.
{ RedesignWizardFormEnd } // Don't remove this line!
procedure InitializeWizard();
begin
RedesignWizardForm;
end;
You cannot "make them work with Tasks". That does not make sense. The only purpose of Tasks is to automatically create the checkboxes on the "Select Additional Tasks" page. As you create the checkboxes programmatically, there's nothing that Tasks will give you on top of that.
If you want to use your custom checkboxes as Tasks, use Check parameter, instead of Tasks.
[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Check: IsCustomTask1Selected
[Code]
var
NewCheckBox1: TNewCheckBox;
function IsCustomTask1Selected: Boolean;
begin
Result := NewCheckBox1.Checked;
end;
For a complete solution, see How to split tasklist at tasks page of Inno Setup into multiple columns?
It works with the latest version of proper Inno Setup, with no need for an obsolete custom build of Inno Setup of doubtful origin.
Side notes:
I'd recommend you to use TNewCheckListBox, instead of TNewGroupBox with individual checkboxes.
5.5.1 is very old version that suffers many security issues.
Add a method for OnClickCheck event,
procedure InitializeWizard;
begin
WizardForm.TasksList.OnClickCheck := #TasksListClickCheck
end;
Then implement TasksListClickCheck method,
procedure TasksListClickCheck(Sender: TObject);
begin
/** Do whatever you want here **/
end;
How can I make a button or a text in the Inno Setup installer that opens a web page when clicked?
To open a webpage, use:
procedure OpenBrowser(Url: string);
var
ErrorCode: Integer;
begin
ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
See also How to show a hyperlink in Inno Setup?
To link this with a button, use:
procedure ButtonClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;
procedure InitializeWizard();
var
Button: TButton;
begin
Button := TButton.Create(WizardForm);
Button.Parent := WizardForm;
Button.Left := ScaleX(16);
Button.Top := WizardForm.NextButton.Top;
Button.Width := WizardForm.NextButton.Width;
Button.Height := WizardForm.NextButton.Height;
Button.Caption := 'Link';
Button.OnClick := #ButtonClick;
end;
To link this with a label, use:
procedure LinkLabelClick(Sender: TObject);
begin
OpenBrowser('https://www.example.com/');
end;
procedure InitializeWizard();
var
LinkLabel: TLabel;
begin
LinkLabel := TLabel.Create(WizardForm);
LinkLabel.Parent := WizardForm;
LinkLabel.Left := ScaleX(16);
LinkLabel.Top :=
WizardForm.NextButton.Top + (WizardForm.NextButton.Height div 2) -
(LinkLabel.Height div 2);
LinkLabel.Caption := 'Link';
LinkLabel.ParentFont := True;
LinkLabel.Font.Style := LinkLabel.Font.Style + [fsUnderline];
LinkLabel.Font.Color := clBlue;
LinkLabel.Cursor := crHand;
LinkLabel.OnClick := #LinkLabelClick;
end;
I am making use of Inno Setup (it's amazing!). I was hoping to customise the installer so that I can accept a string from the user in the form of an input field and maybe add a message to it.
How can I do this? I had a look through the docs, google search and not much came up!
Thanks all for any help
You can use Pascal scripting in InnoSetup to create new pages for the installer. These pages can be integrated into the normal installation flow. This is well documented within the InnoSetup documentation (Google search should also come up with samples). Also the Samples folder within your Program Files\InnoSetup has some code examples.
Some time ago, there was a software called InnoSetup Form designer, which allowed you to visually design the page. The link is still there, but on the page I could not find the download. Maybe if you look around a bit you can find it?
EDIT
This is a sample for a page I made once. This is the code section of the ISS file.[Code]
var
EnableFolderPage: Boolean;
lblBlobFileFolder: TLabel;
lblBlobFileWarning1: TLabel;
lblBlobFileWarning2: TLabel;
tbBlobFileFolder: TEdit;
btnBlobFileFolder: TButton;
function GetBlobFolder(param: String): String;
begin
Result := Trim(tbBlobFileFolder.Text);
end;
{ BlobFileForm_Activate }
procedure BlobFileForm_Activate(Page: TWizardPage);
var
s: string;
begin
s := Trim(tbBlobFileFolder.Text);
if (s = '') then
begin
tbBlobFileFolder.Text := ExpandConstant('{sys}');
end;
end;
{ BlobFileForm_NextButtonClick }
function BlobFileForm_NextButtonClick(Page: TWizardPage): Boolean;
var
s: string;
begin
s := Trim(tbBlobFileFolder.Text);
if (s = '') then
begin
MsgBox(ExpandConstant('{cm:BlobFileForm_NoFolder}'), mbError, MB_OK);
Result := false;
end else
begin
if not DirExists(s) then
begin
MsgBox(ExpandConstant('{cm:BlobFileForm_DirDoesntExist}'), mbError, MB_OK);
Result := false;
end else
begin
Result := True;
end;
end;
end;
procedure btnBlobFileFolder_Click(sender: TObject);
var
directory: string;
begin
if BrowseForFolder('', directory, true) then
begin
tbBlobFileFolder.Text := directory;
end;
end;
{ BlobFileForm_CreatePage }
function BlobFileForm_CreatePage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
begin
Page := CreateCustomPage(
PreviousPageId,
ExpandConstant('{cm:BlobFileForm_Caption}'),
ExpandConstant('{cm:BlobFileForm_Description}')
);
{ lblBlobFileFolder }
lblBlobFileFolder := TLabel.Create(Page);
with lblBlobFileFolder do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:BlobFileForm_lblBlobFileFolder_Caption0}');
Left := ScaleX(8);
Top := ScaleY(8);
Width := ScaleX(167);
Height := ScaleY(13);
end;
{ lblBlobFileWarning1 }
lblBlobFileWarning1 := TLabel.Create(Page);
with lblBlobFileWarning1 do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:BlobFileForm_lblBlobFileWarning1_Caption0}');
Left := ScaleX(8);
Top := ScaleY(80);
Width := ScaleX(50);
Height := ScaleY(13);
Font.Color := -16777208;
Font.Height := ScaleY(-11);
Font.Name := 'Tahoma';
Font.Style := [fsBold];
end;
{ lblBlobFileWarning2 }
lblBlobFileWarning2 := TLabel.Create(Page);
with lblBlobFileWarning2 do
begin
Parent := Page.Surface;
Caption :=
ExpandConstant('{cm:BlobFileForm_lblBlobFileWarning2_Caption0}') + #13 +
ExpandConstant('{cm:BlobFileForm_lblBlobFileWarning2_Caption1}') + #13 +
ExpandConstant('{cm:BlobFileForm_lblBlobFileWarning2_Caption2}') + #13 +
ExpandConstant('{cm:BlobFileForm_lblBlobFileWarning2_Caption3}') + #13 +
ExpandConstant('{cm:BlobFileForm_lblBlobFileWarning2_Caption4}');
Left := ScaleX(8);
Top := ScaleY(96);
Width := ScaleX(399);
Height := ScaleY(133);
AutoSize := False;
WordWrap := True;
end;
{ tbBlobFileFolder }
tbBlobFileFolder := TEdit.Create(Page);
with tbBlobFileFolder do
begin
Parent := Page.Surface;
Left := ScaleX(8);
Top := ScaleY(24);
Width := ScaleX(401);
Height := ScaleY(21);
TabOrder := 0;
end;
{ btnBlobFileFolder }
btnBlobFileFolder := TButton.Create(Page);
with btnBlobFileFolder do
begin
Parent := Page.Surface;
Caption := ExpandConstant('{cm:BlobFileForm_btnBlobFileFolder_Caption0}');
Left := ScaleX(320);
Top := ScaleY(48);
Width := ScaleX(91);
Height := ScaleY(23);
TabOrder := 1;
end;
with Page do
begin
OnActivate := #BlobFileForm_Activate;
OnNextButtonClick := #BlobFileForm_NextButtonClick;
end;
with btnBlobFileFolder do
begin
OnClick := #btnBlobFileFolder_Click;
end;
Result := Page.ID;
end;
procedure InitializeWizard();
begin
BlobFileForm_CreatePage(wpSelectDir);
end;
EDIT 2
To write the value the user entered to a registry key, create a new function:
function GetUserEnteredText(param: String): String;
begin
Result := Trim(tbTextBox.Text);
end;
This function simply returns what was entered in the text box. Please note that the function must take a string parameter - even though you ignore it!
In the [Registry] section of your script, declare the key that should be written like that:
Root: HKLM; Subkey: SOFTWARE\MyCompany\MyTool; ValueType: string; ValueName: MyValue; ValueData: {code:GetUserEnteredText}; Flags: createvalueifdoesntexist uninsdeletekeyifempty uninsdeletevalue
This creates a registry value named "MyValue" in HKLM\SOFTWARE\MyCompany\MyTool that contains what the user entered in the text box.
Here is shorter code to add a custom page to Inno Setup installer with an Input Field:
var
CustomQueryPage: TInputQueryWizardPage;
procedure AddCustomQueryPage();
begin
CustomQueryPage := CreateInputQueryPage(
wpWelcome,
'Custom message',
'Custom description',
'Custom instructions');
{ Add items (False means it's not a password edit) }
CustomQueryPage.Add('Custom Field:', False);
end;
procedure InitializeWizard();
begin
AddCustomQueryPage();
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
{ Read custom value }
MsgBox('Custom Value = ' + CustomQueryPage.Values[0], mbInformation, MB_OK);
end;
end;