Replacing Radio Buttons with Check Box on License

2019-07-14 07:57发布

问题:

Is there any easy way to replace standard 2 radio buttons on License Wizard Page with single (checked/unchecked) Check Box in Inno Setup whithout creating Custom Page?

回答1:

Since there are no settings to switch between license radio buttons and some license check box (at least just because there's no component for it on the WizardForm) you need to create it by your own.

The following code hide the original license radio buttons and creates a check box on the same place at the wizard initialization. This license check box is simulating the radio buttons selections in its OnClick event handler to keep their original functionality. Here is the code, which allows you to access the license check box out of the scope of the wizard initialization event. If you don't need to access this check box later on, you can use this version of the post:

[code]

var
  LicenseCheckBox: TNewCheckBox;

procedure OnLicenseCheckBoxClick(Sender: TObject);
var
  LicenseAccepted: Boolean;
begin
  LicenseAccepted := (Sender as TNewCheckBox).Checked;
  WizardForm.LicenseAcceptedRadio.Checked := LicenseAccepted;
  WizardForm.LicenseNotAcceptedRadio.Checked := not LicenseAccepted;
end;

procedure InitializeWizard;
begin
  WizardForm.LicenseAcceptedRadio.Hide;
  WizardForm.LicenseNotAcceptedRadio.Hide;

  LicenseCheckBox := TNewCheckBox.Create(WizardForm);
  LicenseCheckBox.Parent := WizardForm.LicensePage;
  LicenseCheckBox.Left := 0;
  LicenseCheckBox.Top := WizardForm.LicenseMemo.Top + 
    WizardForm.LicenseMemo.Height + 8;
  LicenseCheckBox.Width := WizardForm.LicenseMemo.Width;
  LicenseCheckBox.Caption := ' I accept the license agreement';
  LicenseCheckBox.OnClick := @OnLicenseCheckBoxClick;
end;