如何在 Inno Setup 中将自定义页面上的无线电控件设置为两个不同的组?

How do I make the radio controls on custom page two distinct groups in Inno Setup?

在我的应用程序中我有这个设置 window:

我想在我的 Inno Setup 安装程序中尽可能地复制这个 window。

目前我有以下代码:

procedure pageAutoBackup_Create;
var
    { Controls }
    pageAutoBackup: TWizardPage;
    btnSelectBackupFolder: TNewButton;
    textBackupFolder: TNewEdit;
    lblWhereToBackup: TLabel;
    lblPromptMode: TLabel;
    comboPromptMode: TNewComboBox;
    lblReminder: TLabel;
    radioBackupModeManual: TNewRadioButton;
    radioBackupModeAuto: TNewRadioButton;
    lblHowToBackup: TLabel;
    radioBackupHowEssential: TNewRadioButton;
    radioBackupHowComplete: TNewRadioButton;
    radioBackupHowNone: TNewRadioButton;
    lblWhatToBackup: TLabel;
begin
    pageAutoBackup := CreateCustomPage(wpSelectComponents, 'Automatic Backup', 'Configure automatic backup settings.');

    { lblWhatToBackup (TLabel) }
    lblWhatToBackup := TLabel.Create(pageAutoBackup);
    lblWhatToBackup.Parent := pageAutoBackup.Surface;
    lblWhatToBackup.Enabled := True;
    lblWhatToBackup.Visible := True;
    lblWhatToBackup.Left := ScaleX(0);
    lblWhatToBackup.Top := ScaleY(10);
    lblWhatToBackup.Width := ScaleX(100);
    lblWhatToBackup.Height := ScaleY(17);
    lblWhatToBackup.Font.Color := [=10=]0000;
    lblWhatToBackup.Color := $F0F0F0;
    lblWhatToBackup.Caption := 'What to backup:';

    { radioBackupHowNone (TNewRadioButton) }
    radioBackupHowNone := TNewRadioButton.Create(pageAutoBackup);
    radioBackupHowNone.Parent := pageAutoBackup.Surface;
    radioBackupHowNone.Enabled := True;
    radioBackupHowNone.Visible := True;
    radioBackupHowNone.Left := ScaleX(10);
    radioBackupHowNone.Top := ScaleY(30);
    radioBackupHowNone.Width := ScaleX(476);
    radioBackupHowNone.Height := ScaleY(18);
    radioBackupHowNone.Checked := False;
    radioBackupHowNone.Font.Color := [=10=]0000;
    radioBackupHowNone.Color := $F0F0F0;
    radioBackupHowNone.Caption := 'Don''t perform any backup when the program shuts down';

    { radioBackupHowComplete (TNewRadioButton) }
    radioBackupHowComplete := TNewRadioButton.Create(pageAutoBackup);
    radioBackupHowComplete.Parent := pageAutoBackup.Surface;
    radioBackupHowComplete.Enabled := True;
    radioBackupHowComplete.Visible := True;
    radioBackupHowComplete.Left := ScaleX(10);
    radioBackupHowComplete.Top := ScaleY(54);
    radioBackupHowComplete.Width := ScaleX(478);
    radioBackupHowComplete.Height := ScaleY(19);
    radioBackupHowComplete.Checked := False;
    radioBackupHowComplete.Font.Color := [=10=]0000;
    radioBackupHowComplete.Color := $F0F0F0;
    radioBackupHowComplete.Caption := 'Make a complete backup when the program shuts down';

    { radioBackupHowEssential (TNewRadioButton) }
    radioBackupHowEssential := TNewRadioButton.Create(pageAutoBackup);
    radioBackupHowEssential.Parent := pageAutoBackup.Surface;
    radioBackupHowEssential.Enabled := True;
    radioBackupHowEssential.Visible := True;
    radioBackupHowEssential.Left := ScaleX(10);
    radioBackupHowEssential.Top := ScaleY(78);
    radioBackupHowEssential.Width := ScaleX(472);
    radioBackupHowEssential.Height := ScaleY(18);
    radioBackupHowEssential.Checked := False;
    radioBackupHowEssential.Font.Color := [=10=]0000;
    radioBackupHowEssential.Color := $F0F0F0;
    radioBackupHowEssential.Caption := 'Only make an essential backup when the program shuts down';

    { lblHowToBackup (TLabel) }
    lblHowToBackup := TLabel.Create(pageAutoBackup);
    lblHowToBackup.Parent := pageAutoBackup.Surface;
    lblHowToBackup.Enabled := True;
    lblHowToBackup.Visible := True;
    lblHowToBackup.Left := ScaleX(0);
    lblHowToBackup.Top := ScaleY(110);
    lblHowToBackup.Width := ScaleX(100);
    lblHowToBackup.Height := ScaleY(17);
    lblHowToBackup.Font.Color := [=10=]0000;
    lblHowToBackup.Color := $F0F0F0;
    lblHowToBackup.Caption := 'How to backup:';

    { radioBackupModeAuto (TNewRadioButton) }
    radioBackupModeAuto := TNewRadioButton.Create(pageAutoBackup);
    radioBackupModeAuto.Parent := pageAutoBackup.Surface;
    radioBackupModeAuto.Enabled := True;
    radioBackupModeAuto.Visible := True;
    radioBackupModeAuto.Left := ScaleX(10);
    radioBackupModeAuto.Top := ScaleY(129);
    radioBackupModeAuto.Width := ScaleX(481);
    radioBackupModeAuto.Height := ScaleY(20);
    radioBackupModeAuto.Checked := False;
    radioBackupModeAuto.Font.Color := [=10=]0000;
    radioBackupModeAuto.Color := $F0F0F0;
    radioBackupModeAuto.Caption := 'Perform automatically when the program is shut down';

    { radioBackupModeManual (TNewRadioButton) }
    radioBackupModeManual := TNewRadioButton.Create(pageAutoBackup);
    radioBackupModeManual.Parent := pageAutoBackup.Surface;
    radioBackupModeManual.Enabled := True;
    radioBackupModeManual.Visible := True;
    radioBackupModeManual.Left := ScaleX(10);
    radioBackupModeManual.Top := ScaleY(155);
    radioBackupModeManual.Width := ScaleX(479);
    radioBackupModeManual.Height := ScaleY(19);
    radioBackupModeManual.Checked := False;
    radioBackupModeManual.Font.Color := [=10=]0000;
    radioBackupModeManual.Color := $F0F0F0;
    radioBackupModeManual.Caption := 'Prompt the user when the program is shut down';

    { lblPromptMode (TLabel) }
    lblPromptMode := TLabel.Create(pageAutoBackup);
    lblPromptMode.Parent := pageAutoBackup.Surface;
    lblPromptMode.Enabled := True;
    lblPromptMode.Visible := True;
    lblPromptMode.Left := ScaleX(10);
    lblPromptMode.Top := ScaleY(190);
    lblPromptMode.Width := ScaleX(482);
    lblPromptMode.Height := ScaleY(19);
    lblPromptMode.Font.Color := [=10=]0000;
    lblPromptMode.Color := $F0F0F0;
    lblPromptMode.Caption := 'Also prompt to backup at the following intervals while the application is running:';

    { comboPromptMode (TNewComboBox) }
    comboPromptMode := TNewComboBox.Create(pageAutoBackup);
    comboPromptMode.Parent := pageAutoBackup.Surface;
    comboPromptMode.Enabled := True;
    comboPromptMode.Visible := True;
    comboPromptMode.Left := ScaleX(10);
    comboPromptMode.Top := ScaleY(207);
    comboPromptMode.Width := ScaleX(483);
    comboPromptMode.Height := ScaleY(21);
    comboPromptMode.Font.Color := [=10=]0000;
    comboPromptMode.ItemIndex := 0;
    comboPromptMode.Color := $FFFFFF;
    comboPromptMode.Items.Add('Never prompt to backup');
    comboPromptMode.Items.Add('Prompt to backup everyday');
    comboPromptMode.Items.Add('Prompt to backup once a week');
    comboPromptMode.Items.Add('Prompt to backup once a month');
    comboPromptMode.Items.Add('');

    { lblReminder (TLabel) }
    lblReminder := TLabel.Create(pageAutoBackup);
    lblReminder.Parent := pageAutoBackup.Surface;
    lblReminder.Enabled := True;
    lblReminder.Visible := True;
    lblReminder.Left := ScaleX(20);
    lblReminder.Top := ScaleY(236);
    lblReminder.Width := ScaleX(481);
    lblReminder.Height := ScaleY(23);
    lblReminder.Font.Color := [=10=]0000;
    lblReminder.Color := $F0F0F0;
    lblReminder.Caption := '(You should restart the application atleast once a week to let it perform database maintenance)';

    { lblWhereToBackup (TLabel) }
    lblWhereToBackup := TLabel.Create(pageAutoBackup);
    lblWhereToBackup.Parent := pageAutoBackup.Surface;
    lblWhereToBackup.Enabled := True;
    lblWhereToBackup.Visible := True;
    lblWhereToBackup.Left := ScaleX(0);
    lblWhereToBackup.Top := ScaleY(269);
    lblWhereToBackup.Width := ScaleX(100);
    lblWhereToBackup.Height := ScaleY(15);
    lblWhereToBackup.Font.Color := [=10=]0000;
    lblWhereToBackup.Color := $F0F0F0;
    lblWhereToBackup.Caption := 'Where to backup:';

    { textBackupFolder (TNewEdit) }
    textBackupFolder := TNewEdit.Create(pageAutoBackup);
    textBackupFolder.Parent := pageAutoBackup.Surface;
    textBackupFolder.Enabled := True;
    textBackupFolder.Visible := True;
    textBackupFolder.Left := ScaleX(10);
    textBackupFolder.Top := ScaleY(286);
    textBackupFolder.Width := ScaleX(400);
    textBackupFolder.Height := ScaleY(20);
    textBackupFolder.Font.Color := [=10=]0000;
    textBackupFolder.Color := $F0F0F0;

    { btnSelectBackupFolder (TNewButton) }
    btnSelectBackupFolder := TNewButton.Create(pageAutoBackup);
    btnSelectBackupFolder.Parent := pageAutoBackup.Surface;
    btnSelectBackupFolder.Enabled := True;
    btnSelectBackupFolder.Visible := True;
    btnSelectBackupFolder.Left := ScaleX(425);
    btnSelectBackupFolder.Top := ScaleY(286);
    btnSelectBackupFolder.Width := ScaleX(75);
    btnSelectBackupFolder.Height := ScaleY(23);
    btnSelectBackupFolder.Caption := 'Browse ...';

end;

这是它的样子:

我最初的问题是:

我有两个广播组:

目前我的无线电控制作为一个大组。如何使它成为两种不同的无线电组模式?

在Windows中,具有相同容器控件的单选按钮属于同一组。

如果您需要单独的组,则必须将单选按钮放在单独的容器控件中。在您的应用程序中,您可以通过将它们放入不同的组框中来解决这个问题。

很遗憾,Inno Setup 不支持组框。

相反,您可以使用 TPanel control。它可以配置为完全无缝呈现:

Panel := TPanel.Create(WizardForm);
Panel.Caption := '';
Panel.BevelOuter := bvNone;
Panel.BevelInner := bvNone; { default }
Panel.BevelKind := bkNone;

如果您将单选按钮放在单独的面板上,您的自定义页面仍然可以看起来完全一样。


另一种选择是使用 TNewCheckListBox 及其 AddGroup

PageAutoBackup := CreateCustomPage(...);

CheckListBox := TNewCheckListBox.Create(WizardForm);

CheckListBox.Parent := PageAutoBackup.Surface;
CheckListBox.Top := WizardForm.SelectTasksLabel.Top;
CheckListBox.Width := WizardForm.TasksList.Width;
CheckListBox.Left := WizardForm.TasksList.Left;
CheckListBox.Height :=
  WizardForm.TasksList.Top + WizardForm.TasksList.Height - CheckListBox.Top;

CheckListBox.WantTabs := True;
CheckListBox.Color := clBtnFace;
CheckListBox.BorderStyle := bsNone;

CheckListBox.AddGroup('What to backup:', '', 0, nil);
CheckListBox.AddRadioButton(
  'Don''t perform any backup when the program shuts down', '', 0, False, True, nil);
CheckListBox.AddRadioButton(
  'Make a complete backup when the program shuts down', '', 0, False, True, nil);
CheckListBox.AddRadioButton(
  'Only make an essential backup when the program shuts down', '', 0, False, True, nil);

CheckListBox.AddGroup('How to backup:', '', 0, nil);
CheckListBox.AddRadioButton(
  'Perform automatically when the program is shut down', '', 0, False, True, nil);
CheckListBox.AddRadioButton(
  'Prompt the user when the program is shut down', '', 0, False, True, nil);