Search code examples
inno-setuppascalscript

How to make work the new added checkboxes with the tasks?


I have added new checkboxes to my inno setup tasks page but i dont know how to make them work with the tasks, i want them to work with the [Tasks] zone in the script.

[Tasks]
Name: "Newcheckboox1"; Description: "Newcheckbox1"; MinVersion: 0.0,5.0
Name: "Newcheckboox2"; Description: "Newcheckbox2"; MinVersion: 0.0,5.0
other tasks checkboxes here.........

Here an image:

Here the code generated when the checkboxes are added:

[Code]
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
var
  NewGroupBox1: TNewGroupBox;
  NewCheckBox1: TNewCheckBox;
  NewCheckBox2: TNewCheckBox;
  NewCheckBox3: TNewCheckBox;
  NewGroupBox2: TNewGroupBox;
  NewCheckBox4: TNewCheckBox;
  NewCheckBox5: TNewCheckBox;
  NewGroupBox3: TNewGroupBox;
  NewCheckBox6: TNewCheckBox;
  NewCheckBox7: TNewCheckBox;
  NewCheckBox8: TNewCheckBox;

procedure RedesignWizardForm;
begin
  with WizardForm.SelectTasksLabel do
  begin
    Visible := False;
    Left := ScaleX(392);
  end;

  { NewGroupBox1 }
  NewGroupBox1 := TNewGroupBox.Create(WizardForm);
  with NewGroupBox1 do
  begin
    Parent := WizardForm.SelectTasksPage;
    Left := ScaleX(0);
    Top := ScaleY(0);
    Width := ScaleX(145);
    Height := ScaleY(238);
    Caption := 'NewGroupBox1';
  end;

  { NewCheckBox1 }
  NewCheckBox1 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox1 do
  begin
    Parent := NewGroupBox1;
    Left := ScaleX(8);
    Top := ScaleY(16);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox1';
  end;

  { NewCheckBox2 }
  NewCheckBox2 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox2 do
  begin
    Parent := NewGroupBox1;
    Left := ScaleX(8);
    Top := ScaleY(40);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox2';
  end;

  { NewCheckBox3 }
  NewCheckBox3 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox3 do
  begin
    Parent := NewGroupBox1;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox3';
  end;

  NewCheckBox1.TabOrder := 0;
  NewCheckBox2.TabOrder := 1;
  NewCheckBox3.TabOrder := 2;

  { NewGroupBox2 }
  NewGroupBox2 := TNewGroupBox.Create(WizardForm);
  with NewGroupBox2 do
  begin
    Parent := WizardForm.SelectTasksPage;
    Left := ScaleX(152);
    Top := ScaleY(0);
    Width := ScaleX(265);
    Height := ScaleY(97);
    Caption := 'NewGroupBox2';
  end;

  { NewCheckBox4 }
  NewCheckBox4 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox4 do
  begin
    Parent := NewGroupBox2;
    Left := ScaleX(8);
    Top := ScaleY(16);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox4';
  end;

  { NewCheckBox5 }
  NewCheckBox5 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox5 do
  begin
    Parent := NewGroupBox2;
    Left := ScaleX(8);
    Top := ScaleY(40);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox5';
  end;

  NewCheckBox4.TabOrder := 0;
  NewCheckBox5.TabOrder := 1;

  { NewGroupBox3 }
  NewGroupBox3 := TNewGroupBox.Create(WizardForm);
  with NewGroupBox3 do
  begin
    Parent := WizardForm.SelectTasksPage;
    Left := ScaleX(152);
    Top := ScaleY(96);
    Width := ScaleX(265);
    Height := ScaleY(142);
    Caption := 'NewGroupBox3';
  end;

  { NewCheckBox6 }
  NewCheckBox6 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox6 do
  begin
    Parent := NewGroupBox3;
    Left := ScaleX(16);
    Top := ScaleY(24);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox6';
  end;

  { NewCheckBox7 }
  NewCheckBox7 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox7 do
  begin
    Parent := NewGroupBox3;
    Left := ScaleX(16);
    Top := ScaleY(48);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox7';
  end;

  { NewCheckBox8 }
  NewCheckBox8 := TNewCheckBox.Create(WizardForm);
  with NewCheckBox8 do
  begin
    Parent := NewGroupBox3;
    Left := ScaleX(16);
    Top := ScaleY(72);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Caption := 'NewCheckBox8';
  end;

  NewCheckBox6.TabOrder := 0;
  NewCheckBox7.TabOrder := 1;
  NewCheckBox8.TabOrder := 2;

  NewGroupBox1.TabOrder := 2;
  NewGroupBox2.TabOrder := 3;
  NewGroupBox3.TabOrder := 4;

{ ReservationBegin }
  // This part is for you. Add your specialized code here.

{ ReservationEnd }
end;
// Don't modify this section. It is generated automatically.
{ RedesignWizardFormEnd } // Don't remove this line!

procedure InitializeWizard();
begin
  RedesignWizardForm;
end;

Solution

  • You cannot "make them work with Tasks". That does not make sense. The only purpose of Tasks is to automatically create the checkboxes on the "Select Additional Tasks" page. As you create the checkboxes programmatically, there's nothing that Tasks will give you on top of that.

    If you want to use your custom checkboxes as Tasks, use Check parameter, instead of Tasks.

    [Files]
    Source: "MyProg.exe"; DestDir: "{app}"; Check: IsCustomTask1Selected
    
    [Code]
    
    var
      NewCheckBox1: TNewCheckBox;
    
    function IsCustomTask1Selected: Boolean;
    begin
      Result := NewCheckBox1.Checked;
    end;
    

    For a complete solution, see How to split tasklist at tasks page of Inno Setup into multiple columns?

    It works with the latest version of proper Inno Setup, with no need for an obsolete custom build of Inno Setup of doubtful origin.


    Side notes:

    • I'd recommend you to use TNewCheckListBox, instead of TNewGroupBox with individual checkboxes.
    • 5.5.1 is very old version that suffers many security issues.