问题描述
|
我添加了InputoptionWizardPage用于选择任务。这工作正常,但我想添加一些自定义功能。一个任务依赖于另一个任务,因此,如果选中了第二个复选框,则第一个复选框应选中并显示为灰色。
为此,我需要访问复选框的属性。我找到了使用完全自定义页面执行此操作的方法,该页面我将在其中自己显式创建复选框,但这将需要大量工作,因为到目前为止我所拥有的大部分内容都令人满意。
我如何使用
MyInputoptionWizardPage.Add(\'This will add a checkBox with this caption\')
钩挂由Inno Setup创建的复选框?
解决方法
试图直接回答您的问题。
我怀疑您使用了
CreateInputOptionPage()
会返回TInputOptionWizardPage
它具有您提到的\'。Add(\'Example \')`方法。
TInputOptionWizard
从TComponent
降到TWizardPage
,has5ѭ具有您需要的方法。
更新:替换了原始代码,该示例基于对ScriptClasses_C.pas的InnoSetup源代码中可用选项的审查,我认为我的原始示例
分别由TRadioButton
和TCheckBox
控制。相反,它们的一个控件称为TNewCheckListBox
。有人可以采用几种方法,但最安全的方法是使用。
这个例子是一个完整的Inno Setup脚本。
[Setup]
AppName=\'Test Date Script\'
AppVerName=\'Test Date Script\'
DefaultDirName={pf}\\test
[Code]
const
cCheckBox = false;
cRadioButton = true;
var
Opt : TInputOptionWizardPage;
function BoolToStr(Value : Boolean) : String;
begin
if Value then
result := \'true\'
else
result := \'false\';
end;
procedure ClickEvent(Sender : TObject);
var
Msg : String;
I : Integer;
begin
// Click Event,allowing inspection of the Values.
Msg := \'The Following Items are Checked\' +#10#13;
Msg := Msg + \'Values[0]=\' + BoolToStr(Opt.Values[0]) +#10#13;
Msg := Msg + \'Values[1]=\' + BoolToStr(Opt.Values[1]) +#10#13;
Msg := Msg + \'Values[2]=\' + BoolToStr(Opt.Values[2]);
MsgBox(Msg,mbInformation,MB_OK);
end;
procedure InitializeWizard();
var
I : Integer;
ControlType : Boolean;
begin
ControlType := cCheckBox;
Opt := CreateInputOptionPage(1,\'Caption\',\'Desc\',\'SubCaption\',ControlType,false);
Opt.Add(\'Test1\');
Opt.Add(\'Test2\');
Opt.Add(\'Test3\');
// Assign the Click Event.
Opt.CheckListBox.OnClickCheck := @ClickEvent;
end;
,您还可以通过父级关系来控制任务,它使您的行为与您的要求类似,但并非100%相同。我知道这并不能直接回答您的问题,而是打算为您提供一个可能更易于实现的选项。这样,您完全不必担心管理自定义对话框。
[Setup]
;This allows you to show Lines showing parent / Child Relationships
ShowTasksTreeLines=yes
[Tasks]
;Parent Tasks don\'t use \"\\\"
Name: p1; Description: P1 Test;
;Child Tasks are named ParentTaskName\\ChildTaskName
;Flag don\'t inheritcheck:Specifies that the task
;should not automatically become checked when its parent is checked
Name: p1\\c1; Description: C1 Test; Flags: dontinheritcheck;
Name: p1\\c2; Description: C2 Test;
;Default behavior is that child must be selected
;when a parent is selected
;this can be overridden using the:
;doninheritcheck flag and the checkablealone flag.
Name: p2; Description: P2 Test; Flags: checkablealone;
Name: p2\\c1; Description: P2-C1 Test; Flags: dontinheritcheck;
Name: p2\\c2; Description: P2-C2 Test; Flags: dontinheritcheck;