这无法正常工作。我的代码被删除了。
InitializeWizard
: procedure InitializeWizard();
var
strBackupFolder: String;
begin
idAutoBackupPage := pageAutoBackup_CreatePage(wpSelectTasks)
{ Backup Local Path }
strBackupFolder := '';
if (IsWin64) then
begin
RegQueryStringValue(HKLM64,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupAtShutdownLocalPath', strBackupFolder);
end else
begin
RegQueryStringValue(HKLM,
'Software\MeetSchedAssist\Meeting Schedule Assistant\Options',
'BackupAtShutdownLocalPath', strBackupFolder);
end;
textBackupFolder.Text := strBackupFolder;
end;
因此,我们的控件具有来自reg的路径。我已将reg中的路径设置为空(如新安装)。
CurPageChanged
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = pageAutoBackup.ID then
begin
EnableAutoBackupSettingsNextPageButton();
end;
end;
这是EnableAuto ...例程的代码:
procedure EnableAutoBackupSettingsNextPageButton();
begin
if(radBackupWhatNone.Checked = False) then
begin
{ Can we proceed? }
if(DirExists(textBackupFolder.Text)) then
begin
{ Yes, it is OK to proceed }
Wizardform.NextButton.Enabled := True
end
else begin
{ No, it is NOT to proceed }
Wizardform.NextButton.Enabled := True;
end;
end else
{ OK to proceed with Next }
Wizardform.NextButton.Enabled := True;
end;
{ Sets the state of the controls }
procedure EnableAutoBackupSettingPageControls(bEnable: Boolean);
begin
pnlBackupMode.Enabled := bEnable;
lblBackupMode.Enabled := bEnable;
radBackupModeAuto.Enabled := bEnable;
radBackupModeManual.Enabled := bEnable;
lblPromptMode.Enabled := bEnable;
cmbPromptMode.Enabled := bEnable;
lblBackupFolder.Enabled := bEnable;
textBackupFolder.Enabled := bEnable;
btnSelectBackupFolder.Enabled := bEnable;
EnableAutoBackupSettingsNextPageButton();
end;
简而言之,它需要根据需要启用无线电控件并启用 Next 向导按钮。
最后:
{ Ask user to select the backup Folder location }
procedure btnSelectBackupFolder_Click(Sender: TObject);
var
strFolder: string;
begin
strFolder := textBackupFolder.Text;
{ Display Browse Window }
if(BrowseForFolder('', strFolder, True)) then
begin
textBackupFolder.Text := strFolder;
end;
end;
{ Action handler }
procedure radBackupWhatNone_Click(Sender: TObject);
begin
{ Set control states }
EnableAutoBackupSettingPageControls(False);
end;
{ Action handler }
procedure radBackupWhatComplete_Click(Sender: TObject);
begin
{ Set control states }
EnableAutoBackupSettingPageControls(True);
end;
{ Action handler }
procedure radBackupWhatEssential_Click(Sender: TObject);
begin
{ Set control states }
EnableAutoBackupSettingPageControls(True);
end;
{ Ask user to select the backup Folder location }
procedure btnSelectBackupFolder_Click(Sender: TObject);
var
strFolder: string;
begin
strFolder := textBackupFolder.Text;
{ Display Browse Window }
if(BrowseForFolder('', strFolder, True)) then
begin
textBackupFolder.Text := strFolder;
end;
EnableAutoBackupSettingsNextPageButton();
end;
当我运行此代码并激活该页面时,所有控件均应正确启用主向导的“下一步”按钮。这仍然是事实。当我单击单选按钮时。主要控件启用/禁用。但不是“下一步”按钮。
答案 0 :(得分:0)
这个article帮助了我。它指的是取消按钮并说:
另一种手动执行此操作的方法是:
procedure DisableCancelButton(); begin WizardForm.CancelButton.Enabled := False; WizardForm.Update; end; procedure EnableCancelButton(); begin WizardForm.CancelButton.Enabled := True; WizardForm.Update; end;
但是原理是一样的。所以我调整了这种方法:
{ Sets the state of the controls }
procedure EnableAutoBackupSettingPageControls(bEnable: Boolean);
begin
pnlBackupMode.Enabled := bEnable;
lblBackupMode.Enabled := bEnable;
radBackupModeAuto.Enabled := bEnable;
radBackupModeManual.Enabled := bEnable;
lblPromptMode.Enabled := bEnable;
cmbPromptMode.Enabled := bEnable;
lblBackupFolder.Enabled := bEnable;
textBackupFolder.Enabled := bEnable;
btnSelectBackupFolder.Enabled := bEnable;
if(radBackupWhatNone.Checked = True) then
Wizardform.NextButton.Enabled := True
else
Wizardform.NextButton.Enabled := DirExists(textBackupFolder.Text);
WizardForm.Update;
end;
我调整了这个:
{ Ask user to select the backup Folder location }
procedure btnSelectBackupFolder_Click(Sender: TObject);
var
strFolder: string;
begin
strFolder := textBackupFolder.Text;
{ Display Browse Window }
if(BrowseForFolder('', strFolder, True)) then
begin
textBackupFolder.Text := strFolder;
Wizardform.NextButton.Enabled := DirExists(textBackupFolder.Text);
WizardForm.Update;
end;
end;
我还必须添加CurPageChanged
处理程序:
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = pageAutoBackup.ID then
begin
{ Get the state of the Next button correct }
if(radBackupWhatNone.Checked = True) then
Wizardform.NextButton.Enabled := True
else
Wizardform.NextButton.Enabled := DirExists(textBackupFolder.Text);
WizardForm.Update;
end;
end;