The following sample shows how to disable the Next
button when you reach the SelectDir
page and enable it only when you enter (or choose from the browse directory dialog) the C:MySecretDir
folder (the MySecretDir
constant). The comparing is case insensitive since user can enter whatever he (or she) wants.
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}My Program
[Code]
const
MySecretDir = 'C:MySecretDir';
procedure OnDirEditChange(Sender: TObject);
begin
WizardForm.NextButton.Enabled := CompareText(WizardDirValue, MySecretDir) = 0;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectDir then
OnDirEditChange(nil);
end;
procedure InitializeWizard;
begin
WizardForm.DirEdit.OnChange := @OnDirEditChange;
end;
Or if you want to enable the Next
button only if there's a specific file MyUniqueFile.exe
in the chosen directory, modify the code in OnDirEditChange
event handler this way:
procedure OnDirEditChange(Sender: TObject);
begin
WizardForm.NextButton.Enabled := FileExists(AddBackslash(WizardDirValue) +
'MyUniqueFile.exe');
end;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…