这是我的任务列表:
[Tasks]
Name: "D3D"; Description: "Install D3D Engine"; GroupDescription: "Engines:"
Name: "GL"; Description: "Install OpenGL Engine"; GroupDescription: "Engines:"; Flags: unchecked
Name: "SW"; Description: "Install Software Engine"; GroupDescription: "Engines:"; Flags: unchecked
Name: "DesktopIcon"; Description: "{cm:CreateDesktopIcon} for the Launcher"; GroupDescription: "{cm:AdditionalIcons}"
Name: "DesktopIconD3D"; Description: "{cm:CreateDesktopIcon} for the D3D Engine"; GroupDescription: "{cm:AdditionalIcons}"
Name: "DesktopIconGL"; Description: "{cm:CreateDesktopIcon} for the OpenGL Engine"; GroupDescription: "{cm:AdditionalIcons}"
Name: "DesktopIconSW"; Description: "{cm:CreateDesktopIcon} for the Software Engine"; GroupDescription: "{cm:AdditionalIcons}"
现在,如果未选择名为DesktopIcon{engine}
的任务,我想要实现的是隐藏名为{engine}
的任务。
当我隐藏其中一个任务,索引列表发生变化,我需要他们专门引用它们时出现问题。
答案 0 :(得分:0)
我确信有一种解决索引问题的方法。但是,您没有向我们展示删除任务的代码,也没有向您展示引用任务的代码。所以我们无法帮助你。
无论如何,隐藏任务并不是解决这个问题的常用方法。您可以使用内置的任务层次结构来解决关系。或者您可以禁用任务,而不是删除它们。
将“图标”任务作为相应“引擎”任务的子任务。
[Tasks]
Name: "DesktopIcon"; Description: "{cm:CreateDesktopIcon} for the Launcher"
Name: "D3D"; Description: "Install D3D Engine"; GroupDescription: "Engines:"; Flags: checkablealone
Name: "D3D\DesktopIcon"; Description: "{cm:CreateDesktopIcon} for the D3D Engine"
Name: "GL"; Description: "Install OpenGL Engine"; GroupDescription: "Engines:"; Flags: unchecked checkablealone
Name: "GL\DesktopIcon"; Description: "{cm:CreateDesktopIcon} for the OpenGL Engine"
Name: "SW"; Description: "Install Software Engine"; GroupDescription: "Engines:"; Flags: unchecked checkablealone
Name: "SW\DesktopIcon"; Description: "{cm:CreateDesktopIcon} for the Software Engine"
这样,当取消选中父“引擎”任务时,Inno Setup会自动取消选中子“icon”任务。
请注意引擎任务中的checkablealone
标志。
如果未选中相应的“引擎”任务,则禁用“图标”任务。
procedure UpdateIconTask(IconIndex: Integer; EngineIndex: Integer);
begin
WizardForm.TasksList.ItemEnabled[IconIndex] := WizardForm.TasksList.Checked[EngineIndex];
if not WizardForm.TasksList.Checked[EngineIndex] then
begin
WizardForm.TasksList.Checked[IconIndex] := False;
end;
end;
procedure UpdateIconTasks();
begin
UpdateIconTask(6, 1);
UpdateIconTask(7, 2);
UpdateIconTask(8, 3);
end;
procedure TasksListClickCheck(Sender: TObject);
begin
UpdateIconTasks();
end;
procedure InitializeWizard();
begin
WizardForm.TasksList.OnClickCheck := @TasksListClickCheck;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
begin
{ Initial update }
UpdateIconTasks();
end;
end;