如何使用任务创建新添加的复选框?

时间:2017-07-10 04:20:54

标签: inno-setup pascalscript

我在我的inno设置任务页面中添加了新的复选框,但我不知道如何使它们与任务一起工作,我希望它们能够与脚本中的[任务]区域一起使用。

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

这是一张图片:

这里添加了复选框时生成的代码:

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

2 个答案:

答案 0 :(得分:2)

你不能"让它们与Tasks" 一起使用。那没有意义。 Tasks的唯一目的是自动创建"选择其他任务" 页面上的复选框。当您以编程方式创建复选框时,Tasks将无法为您提供任何内容。

如果您想将自定义复选框用作 Tasks,请使用Check parameter,而不是Tasks

[Files]
Source: "MyProg.exe"; DestDir: "{app}"; Check: IsCustomTask1Selected

[Code]

var
  NewCheckBox1: TNewCheckBox;

function IsCustomTask1Selected: Boolean;
begin
  Result := NewCheckBox1.Checked;
end;

要获得完整的解决方案,请参阅How to split tasklist at tasks page of Inno Setup into multiple columns?

它适用于最新版本的适当Inno设置,无需过时的可疑来源的Inno Setup定制版本。

附注:

  • 我建议您使用TNewCheckListBox,而不是TNewGroupBox使用单独的复选框。
  • 5.5.1是一个很老的版本,会遇到很多安全问题。

答案 1 :(得分:0)

OnClickCheck 事件

添加方法
procedure InitializeWizard;
begin
    WizardForm.TasksList.OnClickCheck := @TasksListClickCheck
end;

然后实现 TasksListClickCheck 方法,

procedure TasksListClickCheck(Sender: TObject);
begin
    /** Do whatever you want here **/
end;