Inno Setup:如何在InitializeWizard中使用WizardForm.TasksList.Items?
问题描述:
我有问题弄清楚为什么我不能在InitializeWizard
操纵任务复选框,但我可以CurPageChanged
:Inno Setup:如何在InitializeWizard中使用WizardForm.TasksList.Items?
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"
Name: "Option1"; Description: "Option1"
[Code]
procedure CurPageChanged(CurPageID: Integer);
var Index: Integer;
begin
if CurPageID = wpSelectTasks then
begin
Index := WizardForm.TasksList.Items.IndexOf('Option1');
if Index <> -1 then
MsgBox('Touch device checkbox found.', mbInformation, MB_OK); { THIS WORKS!! }
end;
end;
procedure InitializeWizard();
var Index: Integer;
begin
Index := WizardForm.TasksList.Items.IndexOf('Option1');
if Index <> -1 then
MsgBox('Touch device checkbox found.', mbInformation, MB_OK); { THIS DOES NOT WORK }
end;
我不能在InitializeWizard
使用WizardForm.TasksList.Items
?我希望能够拨打WizardForm.TasksList.Checked[Index] := False;
或可能禁用它,但我宁愿在初始化时执行它,而不必避免调用代码,如果用户点击后退按钮并返回到wpSelectTasks
。
答
由于任务列表根据所选组件填充。
因此,任务列表在InitializeWizard
还未知。任何列表根据选定的组件(重新)生成,只要输入wpSelectTasks
页面。
因此,正如您已经发现的,最早的时刻,您可以使用TasksList
是CurPageChanged(wpSelectTasks)
。
当取消选中任务时,确保在用户返回任务页面时不取消选中它。实际上,您应该只在第一次访问页面时取消选中它。