Custom Page Wizard of Inno Setup
12,243
Solution 1
Try this:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "NewSampleSetup"
#define MyAppVersion "1.0"
#define MyAppPublisher "Example"
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "BarChartExample2.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{8226770F-1270-434F-B53E-5539E78AD05B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputDir=C:\Users\sandaa\Desktop
OutputBaseFilename=Setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: " {cm:AdditionalIcons}"; Flags: unchecked
[Files]
;Source: "C:\Users\stajyer1\Documents\Visual Studio 2012\Projects\BarChartExample2\BarChartExample2\bin\Debug\BarChartExample2.exe"; DestDir: " {app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram, {#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
var
FirstLabel: TLabel;
SecondLabel: TLabel;
ThirdLabel: TLabel;
FourthLabel: TLabel;
ServerNameTextBox: TEdit;
WindowsRadioButton: TRadioButton;
SQLRadioButton: TRadioButton;
txtUserName: TEdit;
txtPassword: TEdit;
function AuthenticateDataPage(Page: TWizardPage): Boolean;
begin
Result :=True;
if ServerNameTextBox.Text <> '' then
begin
if SQLRadioButton.Checked then
begin
if txtUserName.Text ='' then
begin
MsgBox('You should enter user name', mbError, MB_OK);
Result :=False;
end
else
begin
if txtPassword.Text ='' then
begin
MsgBox('You should enter password', mbError, MB_OK);
Result :=False;
end
end
end
end
else
begin
MsgBox('You should enter path to SQL Server Database', mbError, MB_OK);
Result :=False;
end;
end;
function CreateDataPage(PreviousPageId: Integer): Integer;
var
Page: TWizardPage;
begin
Page :=CreateCustomPage(PreviousPageId,'SQL Server Database Setup',
'Choose SQL Server database you will be using (ask your administrator about its parameters');
FirstLabel :=TLabel.Create(Page);
with FirstLabel do
begin
Parent :=Page.Surface;
Caption :='Server Name';
Left :=ScaleX(16);
Top :=ScaleY(0);
Width :=ScaleX(84);
Height :=ScaleY(17);
end;
SecondLabel :=TLabel.Create(Page);
With SecondLabel Do
begin
Parent :=Page.Surface;
Caption :='Enter Path to SQL Server (e.g. .\SQLEXPRESS; DEVSERVER)';
Left :=ScaleX(16);
Top :=ScaleY(56);
Width :=ScaleX(300);
Height :=ScaleY(17);
end;
ThirdLabel :=TLabel.Create(Page);
with ThirdLabel do
begin
Parent :=Page.Surface;
Caption :='User name';
Left :=ScaleX(56);
Top :=ScaleY(136);
Width :=ScaleX(70);
Height :=ScaleY(17);
end;
FourthLabel :=TLabel.Create(Page);
with FourthLabel do
begin
Parent :=Page.Surface;
Caption :='Password';
Left :=ScaleX(56);
Top :=ScaleY(168);
Width :=ScaleX(63);
Height :=ScaleY(17);
end;
ServerNameTextBox :=TEdit.Create(Page);
with ServerNameTextBox do
begin
Parent :=Page.Surface;
Left :=ScaleX(16);
Top :=ScaleY(24);
Width :=ScaleX(257);
Height :=ScaleY(25);
TabOrder :=0;
Text :='';
end;
WindowsRadioButton :=TRadioButton.Create(Page);
with WindowsRadioButton do
begin
Parent :=Page.Surface;
Caption :='Use Windows Authentication';
Left :=ScaleX(16);
Top :=ScaleY(88);
Width :=ScaleX(225);
Height :=ScaleY(17);
Checked :=True;
TabOrder :=1;
TabStop :=True;
end;
SQLRadioButton :=TRadioButton.Create(Page);
with SQLRadioButton do
begin
Parent :=Page.Surface;
Caption :='Use SQL Authentication';
Left :=ScaleX(16);
Top :=ScaleY(112);
Width :=ScaleX(193);
Height :=ScaleY(17);
TabOrder :=2;
end;
txtUserName :=TEdit.Create(Page);
with txtUserName do
begin
Parent :=Page.Surface;
Left :=ScaleX(136);
Top :=ScaleY(136);
Width :=ScaleX(121);
Height :=ScaleY(25);
TabOrder :=3;
Text :='';
end;
txtPassword :=TEdit.Create(Page);
with txtPassword do
begin
Parent :=Page.Surface;
Left :=ScaleX(136);
Top :=ScaleY(168);
Width :=ScaleX(121);
Height :=ScaleY(25);
TabOrder :=4;
PasswordChar :='*';
Text :='';
end;
with Page do
begin
OnNextButtonClick :=@AuthenticateDataPage;
end;
Result :=Page.ID;
end;
procedure InitializeWizard();
begin
CreateDataPage(wpLicense);
end;
The only thing I left out is the custommessages.
Solution 2
You can forward-declare a method, like authentication_form_CreatePage
if you don't like to reorder your methods:
//forward declaration
function authentication_form_CreatePage(PreviousPageId: Integer): Integer; forward;
procedure InitializeWizard();
begin
//the method is known to the compiler, even before he looked into it
authentication_form_CreatePage(wpLicense);
end;
function authentication_form_CreatePage(PreviousPageId: Integer): Integer;
begin
... actual implementation ...
end;
Author by
hburakceng
Interested in computer science, programming also student of computer engineering
Updated on June 04, 2022Comments
-
hburakceng almost 2 years
I have been working on custom pages on Inno Setup. I have the example code sample below, but when I run in on my Inno setup script editor, a compiler error pops up. It says: "Compiler error: Line 63: Column 3: Unknown identifier "authentication_form_CreatePage". I cannot see any mistake. But there is one. If anyone can see it and knows about it, can you help me to cope with this please?
; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "NewSampleSetup" #define MyAppVersion "1.0" #define MyAppPublisher "Example" #define MyAppURL "http://www.example.com/" #define MyAppExeName "BarChartExample2.exe" [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppId={{8226770F-1270-434F-B53E-5539E78AD05B} AppName={#MyAppName} AppVersion={#MyAppVersion} ;AppVerName={#MyAppName} {#MyAppVersion} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputDir=C:\Users\Intern1\Documents\Inno Setup Examples Output OutputBaseFilename=Setup Compression=lzma SolidCompression=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: " {cm:AdditionalIcons}"; Flags: unchecked [Files] Source: "C:\Users\stajyer1\Documents\Visual Studio 2012\Projects\BarChartExample2\BarChartExample2\bin\Debug\BarChartExample2.exe"; DestDir: " {app}"; Flags: ignoreversion ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram, {#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [CustomMessages] authentication_form_Caption=SQL Server Database Setup authentication_form_Description=Choose SQL Server database you will be using (ask your administrator about its parameters) authentication_form_Label1_Caption0=Server Name: authentication_form_Label2_Caption0=Enter Path to SQL Server (e.g. .\SQLEXPRESS; DEVSERVER) authentication_form_Label3_Caption0=User name: authentication_form_Label4_Caption0=Password: authentication_form_ServerNameEdit_Text0=- authentication_form_WindowsRadioButton_Caption0=Use Windows Authentication authentication_form_SqlRadioButton_Caption0=Use SQL Authentication authentication_form_UserEdit_Text0=- authentication_form_PasswordEdit_Text0=- [Code] procedure InitializeWizard(); begin authentication_form_CreatePage(wpLicense); end; var Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; ServerNameEdit: TEdit; WindowsRadioButton: TRadioButton; SqlRadioButton: TRadioButton; UserEdit: TEdit; PasswordEdit: TEdit; function authentication_form_CreatePage(PreviousPageId: Integer): Integer; var Page: TWizardPage; begin Page := CreateCustomPage( PreviousPageId, ExpandConstant('{cm:authentication_form_Caption}'), ExpandConstant('{cm:authentication_form_Description}') ); Label1 := TLabel.Create(Page); with Label1 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm:authentication_form_Label1_Caption0}'); Left := ScaleX(16); Top := ScaleY(0); Width := ScaleX(84); Height := ScaleY(17); end; Label2 := TLabel.Create(Page); with Label2 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm: authentication_form_Label2_Caption0}'); Left := ScaleX(16); Top := ScaleY(56); Width := ScaleX(300); Height := ScaleY(17); end; Label3 := TLabel.Create(Page); with Label3 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm: authentication_form_Label3_Caption0}'); Left := ScaleX(56); Top := ScaleY(136); Width := ScaleX(70); Height := ScaleY(17); end; Label4 := TLabel.Create(Page); with Label4 do begin Parent := Page.Surface; Caption := ExpandConstant('{cm: authentication_form_Label4_Caption0}'); Left := ScaleX(56); Top := ScaleY(168); Width := ScaleX(63); Height := ScaleY(17); end; ServerNameEdit := TEdit.Create(Page); with ServerNameEdit do begin Parent := Page.Surface; Left := ScaleX(16); Top := ScaleY(24); Width := ScaleX(257); Height := ScaleY(25); TabOrder := 0; Text := ExpandConstant('{cm: authentication_form_ServerNameEdit_Text0}'); end; WindowsRadioButton := TRadioButton.Create(Page); with WindowsRadioButton do begin Parent := Page.Surface; Caption := ExpandConstant('{cm: authentication_form_WindowsRadioButton_Caption0}'); Left := ScaleX(16); Top := ScaleY(88); Width := ScaleX(225); Height := ScaleY(17); Checked := True; TabOrder := 1; TabStop := True; end; SqlRadioButton := TRadioButton.Create(Page); with SqlRadioButton do begin Parent := Page.Surface; Caption := ExpandConstant('{cm: authentication_form_SqlRadioButton_Caption0}'); Left := ScaleX(16); Top := ScaleY(112); Width := ScaleX(193); Height := ScaleY(17); TabOrder := 2; end; UserEdit := TEdit.Create(Page); with UserEdit do begin Parent := Page.Surface; Left := ScaleX(136); Top := ScaleY(136); Width := ScaleX(121); Height := ScaleY(25); TabOrder := 3; Text := ExpandConstant('{cm: authentication_form_UserEdit_Text0}'); end; PasswordEdit := TEdit.Create(Page); with PasswordEdit do begin Parent := Page.Surface; Left := ScaleX(136); Top := ScaleY(168); Width := ScaleX(121); Height := ScaleY(25); TabOrder := 4; PasswordChar := '*'; Text := ExpandConstant('{cm: authentication_form_PasswordEdit_Text0}'); end; with Page do begin OnNextButtonClick := @authentication_form_NextButtonClick; end; Result := Page.ID; end; function authentication_form_NextButtonClick(Page: TWizardPage): Boolean; begin Result := True; if ServerNameEdit.Text <> '' then begin if SqlRadioButton.Checked then begin if UserEdit.Text = '' then begin MsgBox('You should enter user name', mbError, MB_OK); Result := False; end else begin if PasswordEdit.Text = '' then begin MsgBox('You should enter password', mbError, MB_OK); Result := False; end end end end else begin MsgBox('You should enter path to SQL Server Database', mbError, MB_OK); Result := False; end; end;