如何验证复选框是否在Delphi TTaskDialog中检查? [英] How to verify if the checkbox is checked in a Delphi TTaskDialog?
问题描述
OK,这应该很简单,但是我找不到解决方案,至少不在不是很好的文档 ..在 TTaskDialog
中,您可以选择添加一个复选框。您可以使用标志
中的 tfVerificationFlagChecked
标志来控制其初始状态。但是如何在对话框中获得状态执行
d?
当然可以使用 OnVerificationClicked
事件,并在每次调用时切换本地变量,最初等于复选框的初始状态。但是人们会期待一个更自然的解决方案。
我的上帝,Embarcadero犯了一个错误。
$ b
我的一些测试表明,如果最初的复选框未被选中,但由用户检查,则 tfVerificationFlagChecked
标志将被设置。但是如果标志被初始设置,并且用户取消选中该框,则 tfVerificationFlagChecked
将不会从标志
组。这不奇怪。 VCL代码
结果:= TaskDialogIndirect(LTaskDialog,{$ IFNDEF CLR} @ {$ ENDIF} LModalResult,
{$ IFNDEF CLR} @ {$ ENDIF} LRadioButton,{$ IFNDEF CLR} @ {$ ENDIF} LVerificationChecked)= S_OK;
FModalResult:= LModalResult;
如果结果然后
开始
FButton:= TTaskDialogButtonItem(FButtons.FindButton(FModalResult));
FRadioButton:= TTaskDialogRadioButtonItem(FRadioButtons.FindButton(LRadioButton));
如果LVerificationChecked然后
包含(FFlags,tfVerificationFlagChecked);
结束
请注意,如果在对话框关闭时勾选复选框,则会包含该标志,但没有代码如果用户未选中该框,则删除该标志。
当然,可以预期后一部分代码可以读取
如果LVerificationChecked然后
包含(FFlags,tfVerificationFlagChecked)
else
排除(FFlags,tfVerificationFlagChecked)
我想我会用 OnVerificationClicked
手动切换方法。
OK, this should be easy, but I do not find the solution, at least not in the not so good documentation.. In a TTaskDialog
, you have the option to add one check-box. You can control its initial state by means of the tfVerificationFlagChecked
flag in Flags
. But how to get the state after the dialog has been Execute
d?
Of course one can use the OnVerificationClicked
event and toggle a local variable, initially equal to the initial state of the checkbox, on each call. But one would expect a more natural solution.
O my God, Embarcadero has made a mistake.
A few tests of mine showed that if the check-box initially is unchecked, but is checked by the user, then the tfVerificationFlagChecked
flag will be set. But if the flag is initally set, and the user unchecks the box, then tfVerificationFlagChecked
will not be removed from the Flags
set. And this is not strange. The VCL code does
Result := TaskDialogIndirect(LTaskDialog, {$IFNDEF CLR}@{$ENDIF}LModalResult,
{$IFNDEF CLR}@{$ENDIF}LRadioButton, {$IFNDEF CLR}@{$ENDIF}LVerificationChecked) = S_OK;
FModalResult := LModalResult;
if Result then
begin
FButton := TTaskDialogButtonItem(FButtons.FindButton(FModalResult));
FRadioButton := TTaskDialogRadioButtonItem(FRadioButtons.FindButton(LRadioButton));
if LVerificationChecked then
Include(FFlags, tfVerificationFlagChecked);
end;
Notice that the flag is included if the checkbox is checked when the dialog closes, but there is no code to remove the flag if the box is unchecked by the user.
Of course, one would expect the latter part of the code to have read
if LVerificationChecked then
Include(FFlags, tfVerificationFlagChecked)
else
Exclude(FFlags, tfVerificationFlagChecked)
I think I'll go with the OnVerificationClicked
manual toggling approach.
这篇关于如何验证复选框是否在Delphi TTaskDialog中检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!