gpt4 book ai didi

inno-setup - 创新设置 : how to auto select a component if another component is selected?

转载 作者:行者123 更新时间:2023-12-04 13:22:48 27 4
gpt4 key购买 nike

我有一个文件,只有在安装了特定组件时才必须安装该文件。但我也允许自定义安装。因此,如果还检查了特定组件,则需要自动检查该组件(反之亦然,如果未启用其他组件则禁用)。我知道我可以简单地将文件本身附加到特定组件,但我想向用户提供有关安装此先决条件的反馈。

所以,简短版本:如何自动检查组件 'A' 以检查组件 'B' 的状态?

最佳答案

检查 B 的简单实现,如果检查 A:

[Components]
Name: "A"; Description: "A"
Name: "B"; Description: "B"

[Code]

var
PrevItemAChecked: Boolean;
TypesComboOnChangePrev: TNotifyEvent;
ComponentsListClickCheckPrev: TNotifyEvent;

procedure ComponentsListCheckChanges;
begin
if PrevItemAChecked <> WizardIsComponentSelected('A') then
begin
if WizardIsComponentSelected('A') then
WizardSelectComponents('B');

PrevItemAChecked := WizardIsComponentSelected('A');
end;
end;

procedure ComponentsListClickCheck(Sender: TObject);
begin
{ First let Inno Setup update the components selection }
ComponentsListClickCheckPrev(Sender);
{ And then check for changes }
ComponentsListCheckChanges;
end;

procedure TypesComboOnChange(Sender: TObject);
begin
{ First let Inno Setup update the components selection }
TypesComboOnChangePrev(Sender);
{ And then check for changes }
ComponentsListCheckChanges;
end;

procedure InitializeWizard();
begin
{ The Inno Setup itself relies on the TypesCombo.OnChange and OnClickCheck. }
{ so we have to preserve their handlers. }

ComponentsListClickCheckPrev := WizardForm.ComponentsList.OnClickCheck;
WizardForm.ComponentsList.OnClickCheck := @ComponentsListClickCheck;

TypesComboOnChangePrev := WizardForm.TypesCombo.OnChange;
WizardForm.TypesCombo.OnChange := @TypesComboOnChange;

{ Remember the initial state }
{ (by now the components are already selected according to }
{ the defaults or the previous installation) }
PrevItemAChecked := WizardIsComponentSelected('A');
end;

代码需要 Inno Setup 6 for WizardIsComponentSelected WizardSelectComponents (对于没有这些功能的代码版本,请参阅回答历史)

以上基于 Inno Setup ComponentsList OnClick event .

关于inno-setup - 创新设置 : how to auto select a component if another component is selected?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47431002/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com