4

Check在组件部分使用参数来检查用户是否选中了某个单选按钮。

在向用户显示自定义页面之前调用我的谓词,并且我总是返回默认值。

如何从自定义页面获取用户输入以影响最终组件选择?

[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;
4

2 回答 2

4

以下脚本在自定义页面上创建两个单选按钮,并根据它们的选择从组合框中选择安装类型(在组件选择页面上)。此选择仅在您离开该自定义页面时发生,因此您在该组合框中所做的选择更改将保留,除非您再次访问该自定义页面:

[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;
于 2013-02-01T04:55:28.827 回答
1

目前没有办法做到这一点。组件的检查函数通常在显示任何向导页面之后InitializeSetup但之前调用。InitializeWizard

有一些解决方法,但在这种情况下,您似乎在滥用组件。

如果您已经有一个自定义页面提供服务器或客户端之间的选择,则无需在“组件”页面上再次呈现相同的选择(组件是纯 UI ——除此之外它们没有特殊含义,与其他一些安装系统不同)。

因此,您应该完全删除组件,Check直接在Files或其他条目上使用,而不是Components条件。

于 2013-01-18T10:07:53.473 回答