自定义页面处理后如何强制调用Check谓词 [英] How to force Check predicate to be called after custom page processing

查看:28
本文介绍了自定义页面处理后如何强制调用Check谓词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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;

推荐答案

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

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;

这篇关于自定义页面处理后如何强制调用Check谓词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆