禁用 Inno Setup Next 按钮,直到用户选择单选按钮

Disable Inno Setup Next button until user selects the radio button

我想创建一个包含两个版本软件的安装程序。我已经实现了单选按钮。但用户也可以单击 “下一步”,安装程序什么也不安装。

我想禁用 “下一步” 按钮,直到用户 select 从页面中选择某些选项。

[Code]
var
  UsagePage: TInputOptionWizardPage;

function IsProVersion(Mode: Integer): Boolean;
begin
  Result := (UsagePage.SelectedValueIndex = Mode);
end;

procedure InitializeWizard();
begin
  UsagePage :=
    CreateInputOptionPage(
      wpInfoBefore, 'Select Edition', 'Select Edition',
      'Select software edition you want to install on your computer.',
      True, False);
  UsagePage.Add('Free version');
  UsagePage.Add('Pro version (30 Days Trial)');
end;


[Files]
Source: "D:\software\free\*"; DestDir: "{app}"; \
    Flags: ignoreversion recursesubdirs createallsubdirs; Check: IsProVersion(0)
Source: "D:\software\pro\*"; DestDir: "{app}"; \
    Flags: ignoreversion recursesubdirs createallsubdirs; Check: IsProVersion(1)

使用 UsagePage.CheckListBox.OnClickCheck 事件检测选择更改并相应地更新 Next 按钮状态:

[Code]

var
  UsagePage: TInputOptionWizardPage;

procedure VerifyUsagePage(Sender: TObject);
var
  AnyChecked: Boolean;
  I: Integer;
begin
  AnyChecked := False;
  for I := 0 to UsagePage.CheckListBox.Items.Count - 1 do
  begin
    if UsagePage.CheckListBox.Checked[I] then
      AnyChecked := True;
  end;
  WizardForm.NextButton.Enabled := AnyChecked;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = UsagePage.ID then
  begin
    // Update the Next button state when entering the page
    VerifyUsagePage(nil);
  end;
end;

procedure InitializeWizard();
begin
  UsagePage :=
    CreateInputOptionPage(
      wpInfoBefore, 'Select Edition', 'Select Edition',
      'Select software edition you want to install on your computer.',
      True, False);
  UsagePage.Add('Free version');
  UsagePage.Add('Pro version (30 Days Trial)');
  // Update the Next button state on the selection change
  UsagePage.CheckListBox.OnClickCheck := @VerifyUsagePage;
end;

尽管要选择安装什么,您最好使用 Inno Setup 的内置机制,例如 installations types and components