inno-setup - 如何在自定义页面处理后强制调用 Check 谓词

标签 inno-setup pascalscript

我正在使用 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;

最佳答案

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

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

关于inno-setup - 如何在自定义页面处理后强制调用 Check 谓词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14393738/

相关文章:

batch-file - 调试从 Inno Setup 安装程序执行的非工作批处理文件或命令

registry - Inno Setup 不允许访问所有注册表项,为什么?

registry - 在 Inno Setup 中如何将用户输入保存到注册表?

inno-setup - 合并不同来源的事件函数(InitializeWizard)实现

inno-setup - 在临时文件夹中创建文件夹

inno-setup - 如何禁用 Inno Setup 中向导表单上的 "Next"按钮?

arrays - 如何获取静态数组的长度?

delphi - 在 Windows XP 和 Inno Setup 中迭代 SWbemObjectSet

visual-studio-2017 - 在 Inno Setup 安装程序中,卸载由 InstallShield LE 进行的安装

inno-setup - Inno 安装程序 : Custom classes