How can i add a checkbox for optional files during install? (innosetup)

Posted by Globulorozzo on Stack Overflow See other posts from Stack Overflow or by Globulorozzo
Published on 2012-11-21T21:29:48Z Indexed on 2012/11/21 22:59 UTC
Read the original article Hit count: 1664

Filed under:

i'm trying to make a custom checkbox in my custom page (because is 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 use, 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 '[email protected] 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;

begin
WizardForm.ClientWidth:=ScaleX(550);
WizardForm.ClientHeight:=ScaleY(250);
WizardForm.Center;
WizardForm.OuterNotebook.Hide;
WizardForm.InnerNotebook.Hide;
WizardForm.Bevel.hide;
Wizardform.NextButton.top := 180;
Wizardform.NextButton.Left := 470;
WizardForm.NextButton.Height := 25;
WizardForm.StatusLabel.Parent := WizardForm;
WizardForm.StatusLabel.Left := 6;
WizardForm.StatusLabel.Top := 206;
WizardForm.FilenameLabel.Parent := WizardForm;
WizardForm.FilenameLabel.Left := 87;
WizardForm.FilenameLabel.Top := 206;
WizardForm.FilenameLabel.Width := ScaleX(383);
WizardForm.ProgressGauge.Parent := WizardForm;
WizardForm.ProgressGauge.Left :=5;
WizardForm.ProgressGauge.Top := 222;
WizardForm.ProgressGauge.Width := ScaleX(460);


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;

© Stack Overflow or respective owner

Related posts about inno-setup