Inno Setup - 更改任务描述标签的颜色并换行

Inno Setup - Change a task description label's color and have a line break

[Components]
Name: "Slasher"; Description: "Dagon Slasher"; Types: Slasher Full
Name: "Frankenstein"; Description: "Dagon Frankenstein"; Types: Frankenstein Full

[Types]
Name: "Full"; Description: "Dagon Video Tools"
Name: "Slasher"; Description: "Dagon Slasher"
Name: "Frankenstein"; Description: "Dagon FrankenStein"

[Tasks]
Name: "Debug"; Description: "Debug. Warning: This will result in a non-functional ""Join in FrankenStein"" button in the Tools Menu."; Components: not Slasher
Name: "Vid"; Description: "Install Extra Codecs for Frankenstein"; Flags: unchecked; Components: not Slasher

我需要 Warning: This will result in... 以红色字体换行显示。我找到了 TLama's solution in InnoSetup: How to add line break into component description,但结果是 List index out of bounds(0),因为如您所见,任务在我的脚本中有条件地显示。

如果您尝试更新 InitializeWizard 中的 TasksList,您必须获得异常,因为此时 TasksList 尚未填充,无论任务是否已完成是否有条件。

TasksList 只有在您移至 "Select Additional Tasks" 页面后才会填充。

所以你只需要在CurPageChanged(wpSelectTasks). And test for not WizardIsComponentSelected('Slasher')(Inno Setup 6.0.2 之前的IsComponentSelected)更新任务标题,然后再这样做(详见代码中的注释)。

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectTasks then
  begin
    { This has to be kept in sync with the expression in "Components" parameter }
    { of the respective task. Though note that in your specific case the test }
    { is redundant as when "Slasher" is selected, you have no tasks, }
    { and the "Tasks" page is completely skipped, so you do not even get  here. }
    { Before Inno Setup 6.0.2, use IsComponentSelected. } 
    if not WizardIsComponentSelected('Slasher') then
    begin
      WizardForm.TasksList.ItemCaption[0] :=
        'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed id' + #13#10 +
        'venenatis erat, ac vehicula sapien. Etiam convallis ligula eros,' + #13#10 +
        'in ullamcorper turpis pulvinar sit amet.';
    end;
  end;
end;

我很确定没有办法改变一个特定任务的颜色。您所能做的就是为每组任务创建一个单独的 TNewCheckListBox,这些任务应该具有不同的颜色(并使用其 .Font.Color 属性 设置颜色)。


如果您想了解更多详细信息,您应该提出一个单独的问题。换行符和颜色是两个不同的问题。

另见类似问题:Disable controls based on components selection in Inno Setup.