I need create custom page of two destination.
I've done:
#define MyAppName "TESTPROG"
[Setup]
AppName={#MyAppName}
DefaultDirName=C:\test\{#MyAppName}
DefaultGroupName={#MyAppName}
[Code]
var
Page: TInputDirWizardPage;
DataDir: String;
procedure InitializeWizard;
begin
Page := CreateInputDirPage(wpWelcome,
'Select Personal Data Location', 'Where should personal data files be stored?',
'Personal data files will be stored in the following folder.'#13#10#13#10 +
'To continue, click Next. ' +
'If you would like to select a different folder, click Browse.',
False, 'New Folder');
Page.Add('Local APP');
Page.Add('Local Storage');
Page.Values[0] := ('C:\My Program');
Page.Values[1] := ('D:\My Program');
DataDir := Page.Values[0];
end;
I need to know how and where I set DefaultDirName with Page.Values[0]
and Page.Values[1]
I need it because some part of my files will be in a folder and others in other folder.
For example:
[Files]
Source: C:\TEST\DLL1.bat; DestDir: Page.Values[0]\sys1;
Source: C:\TEST\DLL2.bat; DestDir: Page.Values[1]\sys2;
Use a scripted constant:
[Files]
Source: C:\TEST\DLL1.bat; DestDir: "{code:GetDir|0}\sys1"
Source: C:\TEST\DLL2.bat; DestDir: "{code:GetDir|1}\sys2"
[Code]
var
Page: TInputDirWizardPage;
function GetDir(Param: string): string;
begin
Result := Page.Values[StrToInt(Param)];
end;
procedure InitializeWizard;
begin
Page := CreateInputDirPage(...);
...
end;
If you want to use one of the (the first) paths from the TInputDirWizardPage
instead of the path from "Select Destination Location" page, you have three options.
Disable the "Select Destination Location" page using DisableDirPage
directive:
DisableDirPage=yes
Copy the path from the TInputDirWizardPage
to the hidden "Select
Destination Location" page, when the user presses Next button:
var
Page: TInputDirWizardPage;
function InputDirPageNextButtonClick(Sender: TWizardPage): Boolean;
begin
{ Use the first path as the "destination path" }
WizardForm.DirEdit.Text := Page.Values[0];
Result := True;
end;
procedure InitializeWizard();
begin
Page := CreateInputDirPage(...);
...
Page.OnNextButtonClick := @InputDirPageNextButtonClick;
end;
To complement that you may also consider copying the initial WizardForm.DirEdit
to your custom box. This way you make sure that 1) on re-install/upgrade, the previously selected value is reused; 2) /DIR
command-line switch works. For that see How to make Inno Setup /DIR command line switch work with custom path page.
Replace all uses of the {app}
constant with {code:GetDir|0}
.
Make Inno Setup not create the {app}
path using CreateAppDir
directive:
CreateAppDir=no
(this implies DisableDirPage=yes
).
And have the uninstall files be stored in the first path using UninstallFilesDir
directive:
UninstallFilesDir={code:GetDir|0}
Contrary to 1), with this approach the previous installation path won't get reused for the later upgrade/re-install. To implement that see Inno Setup Prompt user for a folder and store the value.
Do not use the CreateInputDirPage
, but rather add a second path input box on the "Select Destination Location" page (SelectDirPage
).