Inno setup 用于在inno设置中更改类型组合框的默认行为和自定义行为

Inno setup 用于在inno设置中更改类型组合框的默认行为和自定义行为,inno-setup,Inno Setup,在我的安装工具中,我希望在“选择组件向导”页面上有一个特定的行为。安装程序包含几种类型,其中一种是自定义类型。如果用户选择其中一种设置类型,则无法更改复选框(类似于标记为固定的组件)。但如果用户选择“自定义”,则应启用复选框 通过更改过程向导form.TypesCombo.OnChange,可以轻松启用和禁用复选框。不幸的是,执行此操作时,根据设置类型选择组件的默认行为不再起作用 问题是,如何在类型组合框的“更改”事件上同时执行这两项操作 我试图将默认实现存储到函数指针中,并在自定义更改过程中调

在我的安装工具中,我希望在“选择组件向导”页面上有一个特定的行为。安装程序包含几种类型,其中一种是自定义类型。如果用户选择其中一种设置类型,则无法更改复选框(类似于标记为固定的组件)。但如果用户选择“自定义”,则应启用复选框

通过更改过程
向导form.TypesCombo.OnChange
,可以轻松启用和禁用复选框。不幸的是,执行此操作时,根据设置类型选择组件的默认行为不再起作用

问题是,如何在类型组合框的“更改”事件上同时执行这两项操作

我试图将默认实现存储到函数指针中,并在自定义更改过程中调用它(请参见代码中的注释行),但没有成功。我遇到了编译器错误

以下是我的inno安装脚本:

[Setup]
AppId={{8D76F99A-82A1-4995-A470-BA9B69F83F67}
AppName=MyAppName
AppVersion=1.0.1
Uninstallable=no
DefaultDirName=C:\MyPath\Versions
SetupLogging=yes

[Types]
Name: "full";     Description: "Complete installation (Base System & optional 3rd Party SW)";
Name: "base_only"; Description: "Basic installation without optional";
Name: "custom"; Description: "Custom installation"; Flags: iscustom

[Components]
Name: "Base"; Description: "Base with required 3rd Party SW"; Types: full base_only ; 
Name: "Base\Redist"; Description: "Redistributables"; Types: full base_only ;  
Name: "Base\NTP"; Description: "NTP"; Types: full base_only ;   
Name: "Base\WinSCP"; Description: "WinSCP"; Types: full base_only ;   
Name: "ThirdPartyOptional"; Description: "Optional 3rd Party SW"; Types: full ;  
Name: "ThirdPartyOptional\7Zip"; Description: "7Zip"; Types: full ;  
Name: "ThirdPartyOptional\WinMerge"; Description: "WinMerge"; Types: full ;  
Name: "ThirdPartyOptional\Notepad"; Description: "Notepad++"; Types: full ;  
Name: "ThirdPartyOptional\Putty"; Description: "Putty"; Types: full ;  

[Code]
type
  TMyOnChange = procedure(Sender: TObject);

procedure TypeChange (Sender: TObject);
var
  i:        Integer;

begin
  for i := 0 to WizardForm.ComponentsList.Items.count - 1 do 
  begin
    WizardForm.ComponentsList.ItemEnabled[i] := (WizardForm.TypesCombo.Text = 'Custom installation');
  end;
  //TMyOnChange(Sender);  // this throws an compiler error: type mismatch
end;

procedure InitializeWizard;
begin
  // try to get default implementation of types combo change
  //TMyOnChange := WizardForm.TypesCombo.OnChange; // this throws an compiler error: internal error (20)
  // add callback function for type changed
  WizardForm.TypesCombo.OnChange := @TypeChange;
  // initialize the wpSelectComponents page
  TypeChange(nil);

end;

您需要将原始的
OnChange
事件方法存储到
TNotifyEvent
类型变量,并通过该变量触发该方法。为什么要禁用非自定义类型的复选框?实际上,如果在所有位置更改复选框,则类型将自动更改为“自定义”。所以效果是一样的,但对用户来说更容易。