Showing run tasks as radio choices instead of chec

2019-06-02 14:41发布

问题:

This is the [Run] section of my script:

[Run]
Filename: "{app}\MeetSchedAssist.exe"; Flags: nowait postinstall skipifsilent runasoriginaluser; Description: "{cm:LaunchProgram,Meeting Schedule Assistant}"
Filename: "{app}\MeetSchedAssist_x64.exe"; Flags: nowait postinstall runasoriginaluser unchecked skipifsilent; Description: "{cm:LaunchProgram,Meeting Schedule Assistant (64 bit)}"; Check: IsWin64
Filename: "{win}\hh.exe"; Parameters: "{app}\MeetSchedAssist.chm::/HelpRevision.htm"; WorkingDir: "{app}"; Flags: nowait postinstall runmaximized; Description: "{cm:ViewChangeHistory}"
Filename: {dotnet40}\regasm.exe; Parameters: PTSTools.dll /codebase; WorkingDir: {app}; Flags: runhidden
Filename: {dotnet4064}\regasm.exe; Parameters: PTSTools.dll /codebase; WorkingDir: {app}; Flags: runhidden; Check: IsWin64;

On the final page of the installer the first three show as check boxes.

I would like the first two to be radios. They will want to start one or the other bit edition. Not both.

Is this possible?

Or, as one check box is ticked the other gets unticked.

回答1:

You would have to re-build the RunList according to your liking.

type
  TRunEntry = record
    Caption: string;
    Checked: Boolean;
    Object: TObject;
  end;

procedure RebuildRunList;
var
  RunEntries: array of TRunEntry;
  I: Integer;
begin
  { Save run list ... }
  SetArrayLength(RunEntries, WizardForm.RunList.Items.Count);
  for I := 0 to WizardForm.RunList.Items.Count - 1 do
  begin
    RunEntries[I].Caption := WizardForm.RunList.ItemCaption[I];
    RunEntries[I].Checked := WizardForm.RunList.Checked[I];
    RunEntries[I].Object := WizardForm.RunList.ItemObject[I];
  end;

  { ... clear it ... }
  WizardForm.RunList.Items.Clear;

  { ... and re-create }
  for I := 0 to GetArrayLength(RunEntries) - 1 do
  begin
    { the first two entries are radio buttons }
    if (I = 0) or (I = 1) then
    begin
      WizardForm.RunList.AddRadioButton(
        RunEntries[I].Caption, '', 0, RunEntries[I].Checked, True, RunEntries[I].Object);
    end
      else
    begin
      WizardForm.RunList.AddCheckBox(
        RunEntries[I].Caption, '', 0, RunEntries[I].Checked, True, True, True,
        RunEntries[I].Object);
    end;
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpFinished then
  begin
    { Only now is the RunList populated. }
    { Two entries are on 64-bit systems only. }
    if IsWin64 then RebuildRunList;
  end;
end;

On 64-bit system:

On 32-bit system:


The other approach with automatically unchecking check box, when the other one is checked, is possible too.

See a similar question about a task list:
Inno Setup Uncheck a task when another task is checked



标签: inno-setup