Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

inno setup - How to force Check predicate to be called after custom page processing

I'm using Check parameter in components section to check if a certain radio button was checked by user.

My predicate is called before custom page is shown to user and I always get default values returned.

How do I get user input from custom page to affect final components selection?

[Components]
Name: common; Description: Common files; Types: server client custom; Flags: fixed
Name: client; Description: Client; Types: client; Check: IsClient
Name: server; Description: Server; Types: server

[Code]
var ClientButton: TNewRadioButton;

procedure InitializeWizard;
var
  CustomPage: TWizardPage;
begin
  CustomPage := CreateCustomPage(wpWelcome, 'Installation type', '');
  { CreateRadioButton function is defined elsewhere }
  ClientButton := CreateRadioButton(CustomPage, 16, 'Client', ''); 
end;

function IsClient: Boolean;
begin
  Log('IsClient() called');
  if Assigned(ClientButton) then
    Result :=  ClientButton.Checked
  else 
    Result :=  True;
end;
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The following script makes two radio buttons on a custom page and based on their selection, chooses the installation type from the combo box (on components selection page). This selection happens only when you're leaving that custom page, so a selection change, you make in that combo box will remain, unless you visit that custom page again:

[Types]
Name: "client"; Description: "Client installation"
Name: "server"; Description: "Server installation"
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "common"; Description: "Common files"; Types: client server custom; Flags: fixed
Name: "client"; Description: "Client files"; Types: client
Name: "server"; Description: "Server files"; Types: server

[Files]
Source: "Common.exe"; DestDir: "{app}"; Components: common
Source: "Client.exe"; DestDir: "{app}"; Components: client
Source: "Server.exe"; DestDir: "{app}"; Components: server

[Code]
var
  CustomPage: TWizardPage;
  ClientButton: TNewRadioButton;
  ServerButton: TNewRadioButton;

function CreateRadioButton(AParent: TWizardPage; ATop: Integer; 
  ACaption: string; AHint: string): TNewRadioButton;
begin
  Result := TNewRadioButton.Create(WizardForm);
  with Result do
  begin
    Parent := AParent.Surface;
    Top := ATop;
    Width := AParent.SurfaceWidth;
    Caption := ACaption;
    Hint := AHint;
  end;
end;

procedure InitializeWizard;
begin
  CustomPage := CreateCustomPage(wpWelcome, 'Installation type', '');
  ClientButton := CreateRadioButton(CustomPage, 16, 'Client', ''); 
  ServerButton := CreateRadioButton(CustomPage, 34, 'Server', '');
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  if CurPageID = CustomPage.ID then
  begin
    if ClientButton.Checked then
      WizardForm.TypesCombo.ItemIndex := 0
    else
    if ServerButton.Checked then
      WizardForm.TypesCombo.ItemIndex := 1;
    WizardForm.TypesCombo.OnChange(WizardForm);
  end;
end;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...