在我的设置工具中,我想要在“选择组件”向导页面上执行特定行为。安装程序包含几种类型,其中一种是自定义类型。如果用户选择其中一种设置类型,则无法更改复选框(类似于标记为固定的组件)。但是如果用户选择“自定义”,则应该启用复选框。
通过更改程序WizardForm.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;