Inno Setup的 - Pascal脚本 - 有条件地隐藏/显示任务
问题描述:
这里是我的任务列表:Inno Setup的 - Pascal脚本 - 有条件地隐藏/显示任务
[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}
任务(S)如果该任务命名为{engine}
未选中。
隐藏其中一个任务,索引列表发生变化,我需要他们专门引用它们的问题。
答
我确定有一种方法可以解决索引问题。但是您没有向我们展示删除任务的代码,也没有显示引用任务的代码。所以我们无法帮助你。
无论如何,隐藏任务并不是解决这个问题的常用方法。内置的任务层次结构可以用来解决关系。或者您可以禁用任务,而不是删除它们。
使“图标”任务成为相应“引擎”任务的子任务。
[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安装程序在未选中父引擎任务时自动取消选中子图标任务。
注意引擎任务中的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;
旁注:'{厘米:CreateDesktopIcon}为D3D Engine' - 你是本地化的字符串与硬编码字符串相结合。这不是一个好方法。 –