2016-04-25 219 views
0

這裏是我的任務列表: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}未選中。

隱藏其中一個任務,索引列表發生變化,我需要他們專門引用它們的問題。

+0

旁註:'{釐米:CreateDesktopIcon}爲D3D Engine' - 你是本地化的字符串與硬編碼字符串相結合。這不是一個好方法。 –

回答

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安裝程序在未選中父引擎任務時自動取消選中子圖標任務。

注意引擎任務中的checkablealone標誌。

Subtasks


禁用 「圖標」 的任務,如果相應的 「引擎」 的任務是聽之任之。

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; 

enter image description here

相關問題