向标准 Inno Setup 页面添加其他控件?

问题描述

如何在 Inno Setup 创建的文件夹选择对话框中添加复选框,如下图所示?

enter image description here

这不是自定义对话框。它由 Inno Setup 自动创建。

解决方法

将复选框的 Parent 属性设置为 WizardForm.SelectDirPage

var
  Checkbox: TNewCheckBox;

procedure InitializeWizard();
begin
  Checkbox := TNewCheckBox.Create(WizardForm.SelectDirPage);
  Checkbox.Parent := WizardForm.SelectDirPage;
  Checkbox.Top := WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + ScaleY(8);
  Checkbox.Left := WizardForm.DirEdit.Left;
  Checkbox.Caption := 'My checkbox';
  // See https://stackoverflow.com/q/30469660/850848
  Checkbox.Height := ScaleY(Checkbox.Height);
end;

enter image description here