0
votes

Here's a list of my tasks:

[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}"

Now, what I want to achieve is hiding the task(s) named DesktopIcon{engine} if the task named {engine} is not selected.

The problem when I hide one of the tasks, the index list changes, and I need them to reference them specifically.

1
Side note: {cm:CreateDesktopIcon} for the D3D Engine - You are combining localizable string with hard-coded string. That's not a good way. - Martin Prikryl

1 Answers

0
votes

I'm sure there's a way to solve your problem with indexes. But you didn't show us your code that deletes the tasks nor your code that references the tasks. So we cannot help you with that.

Anyway, hiding the tasks is not the common way to solve this. There's built in task-hierarchy that you can use to solve the relation. Or you can just disable the tasks, instead of deleting them.


Making a "icon" task a subtask of the respective "engine" task.

[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"

This makes Inno Setup automatically uncheck the child "icon" task when the parent "engine" task is unchecked.

Note the checkablealone flag in engine tasks.

Subtasks


Disabling the "icon" task if the respective "engine" task is unchecked.

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;

In Inno Setup 6, instead of using indexes, you can also use task names with use of WizardIsTaskSelected and WizardSelectTasks.

enter image description here