var
DirTreeView: TFolderTreeView;
Edit: TEdit;
Reset_Path_Button: TButton;
procedure DirFolderChange(Sender: TObject);
begin
if TFolderTreeView(Sender).Directory <> WizardDirValue then Edit.Text := AddBackslash(TFolderTreeView(Sender).Directory) + '{#SetupSetting("AppName")}' else Edit.Text := TFolderTreeView(Sender).Directory;
Reset_Path_Button.Enabled := Edit.Text <> RemoveBackslash(ExpandConstant('{#SetupSetting("DefaultDirName")}'));
end;
procedure BrowseForm_Buttons_OnClick(Sender: TObject);
begin
case TButton(Sender).Caption of
'Reset':
begin
Edit.Text := RemoveBackslash(ExpandConstant('{#SetupSetting("DefaultDirName")}'));
TButton(Sender).Enabled := False;
end;
SetupMessage(msgButtonNewFolder):
begin
DirTreeView.CreateNewDirectory('Half-Life 2');
Edit.Text := AddBackslash(DirTreeView.Directory) + '{#SetupSetting("AppName")}';
end;
SetupMessage(msgButtonOK): if Edit.Text <> WizardForm.DirEdit.Text then WizardForm.DirEdit.Text := Edit.Text;
end;
end;
procedure BrowseClick(Sender: TObject);
var
DefaultInstallPath: String;
BrowseForm: TForm;
begin
DefaultInstallPath := WizardDirValue;
BrowseForm := TForm.Create(nil);
with BrowseForm do
begin
ClientWidth := ScaleX(387);
ClientHeight := ScaleY(364);
Position := poScreenCenter;
Caption := #32 + SetupMessage(msgBrowseDialogTitle);
with TLabel.Create(nil) do
begin
SetBounds(ScaleX(7), ScaleY(4), ScaleX(207), ScaleY(16));
Caption := SetupMessage(msgBrowseDialogLabel);
Parent := BrowseForm;
end;
DirTreeView := TFolderTreeView.Create(nil)
with DirTreeView do
begin
SetBounds(ScaleX(4), ScaleY(52), ScaleX(379), ScaleY(265));
OnChange := @DirFolderChange;
Parent := BrowseForm;
end;
ActiveControl := DirTreeView;
Edit := TEdit.Create(nil);
with Edit do
begin
SetBounds(ScaleX(4), ScaleY(25), ScaleX(379), ScaleY(21));
Text := DirTreeView.Directory;
Parent := BrowseForm;
end;
with TButton.Create(nil) do
begin
SetBounds(ScaleX(4), ScaleY(330), ScaleX(90), ScaleX(22));
Parent := BrowseForm;
Caption := SetupMessage(msgButtonCancel);
Cursor := crHand;
ModalResult := mrCancel;
end;
Reset_Path_Button := TButton.Create(nil)
with Reset_Path_Button do
begin
SetBounds(ScaleX(99), ScaleY(330), ScaleX(90), ScaleY(22));
Parent := BrowseForm;
Caption := 'Reset';
Enabled := Edit.Text <> RemoveBackslash(ExpandConstant('{#SetupSetting("DefaultDirName")}'))
Cursor := crHand;
OnClick := @BrowseForm_Buttons_OnClick;
end;
with TButton.Create(nil) do
begin
SetBounds(ScaleX(194), ScaleY(330), ScaleX(90), ScaleY(22));
Parent := BrowseForm;
Caption := SetupMessage(msgButtonNewFolder);
Cursor := crHand;
OnClick := @BrowseForm_Buttons_OnClick;
end;
with TButton.Create(nil) do
begin
SetBounds(ScaleX(289), ScaleY(330), ScaleX(90), ScaleY(22));
Parent := BrowseForm;
Caption := SetupMessage(msgButtonOK);
OnClick := @BrowseForm_Buttons_OnClick;
Cursor := crHand;
ModalResult := mrOk;
end;
DirTreeView.ChangeDirectory(AddBackslash(DefaultInstallPath), True);
if ShowModal = mrOk then WizardForm.DirEdit.Text := Edit.Text else WizardForm.DirEdit.Text := DefaultInstallPath;
Free;
end;
end;
procedure InitializeWizard();
begin
WizardForm.DirBrowseButton.OnClick := @BrowseClick;
end;[/SPOILER]