I'm trying to make a custom checkbox in my custom page (because it's a one page installer), is needed only a checkbox without dialogs or anything, the installer that I'm trying to compile is very linear and simple.
I want to bind "FILE3.EXE" on a checkbox in this way: if checkbox is checked copy the file (FILE3.EXE) in DestDir, otherwise if checkbox is unchecked skip the file (FILE3.EXE) during installation.
This is the code that I used, obviously the checkbox code is missing because I'm not able to do that
[Files]
Source: FILE1.EXE; DestDir: {app};
Source: FILE2.EXE; DestDir: {app};
Source: FILE3.EXE; DestDir: {app}; //OPTIONAL
[Code]
procedure ExitProcess(uExitCode: UINT);
external 'ExitProcess@kernel32.dll stdcall';
var
MainPage : TWizardPage;
FolderToInstall : TEdit;
InstallLocation : String;
procedure CancelClick(Sender: TObject);
begin
if ExitSetupMsgBox then
begin
ExitProcess(0);
end;
end;
procedure BrowseClick(Sender : TObject);
var
Dir : String;
begin
Dir := FolderToInstall.Text;
if BrowseForFolder('Browse',Dir,false) then
FolderToInstall.Text := Dir;
WizardForm.DirEdit.Text := Dir;
end;
procedure InitializeWizard();
var
LabelFolder : TLabel;
MainPage := CreateCustomPage(wpWelcome,'','');
LabelFolder := TLabel.Create(MainPage);
LabelFolder.Parent := WizardForm;
LabelFolder.Top := 164;
LabelFolder.Left := 6;
LabelFolder.Caption := 'Directory:'
FolderToInstall := TEdit.Create(MainPage);
FolderToInstall.Parent := WizardForm;
FolderToInstall.Top := 182;
FolderToInstall.Left := 85;
FolderToInstall.Width := 380;
FolderToInstall.Text := WizardDirValue;
FolderToInstall.ReadOnly := True;
end;
You need to make a
Check
function which will return state of the check box from the[Code]
section of your script. Something like this might do what you want, but before the code script I would correct you in the following:TNewEdit
instead ofTEdit
TWizardPage.Surface
as aParent
if you want to have a certain component on the page (here I'm not sure if that's your intention, just pointing this out :-)In the following example I've used
Check
function calledInstallHelpFile
for conditional install of a certain file, in this caseMyProg.chm
. TheCheck
function works simply; when you return True to the function, the file is processed, skipped is when you return False.You don't have to manually create CheckBoxes for that. The standard way to let the user choose what to install is to use the
[Types]
and[Components]
sections of your script file.Take a look at the Componens.iss script located in your iss install folder\examples.
At runtime, the installer presents this dialog within the wizard:
You can do it much easier with CreateInputOptionPage(). See detailed information in Inno Setup help. http://www.jrsoftware.org/ishelp/index.php?topic=scriptpages