如何验证 Delphi TTaskDialog 中的复选框是否被选中?
好的,这应该很容易,但我没有找到解决方案,至少在 中找不到解决方案文档不太好.. 在TTaskDialog
中,您可以选择添加一个复选框。您可以通过Flags
中的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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
天哪,内河码头犯了一个错误。
我的一些测试表明,如果该复选框最初未被选中,但被用户选中,则将设置 tfVerificationFlagChecked 标志。但是,如果最初设置了该标志,并且用户取消选中该框,则
tfVerificationFlagChecked
将不会从Flags
集中删除。这并不奇怪。 VCL 代码确实注意到,如果在对话框关闭时选中该复选框,则包含该标志,但如果用户未选中该框,则没有代码可以删除该标志。
当然,人们会期望代码的后半部分已经阅读过
,我想我会采用
OnVerificationClicked
手动切换方法。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, thentfVerificationFlagChecked
will not be removed from theFlags
set. And this is not strange. The VCL code doesNotice 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
I think I'll go with the
OnVerificationClicked
manual toggling approach.您不能在对话框关闭后读取
Flags
来查看tfVerificationFlagChecked
是否仍然存在吗?Can't you read
Flags
after the dialog is closed to see whethertfVerificationFlagChecked
is still present?在 Delphi XE7(也可能是早期版本)中,这个问题似乎已经得到解决。
choice,一个布尔变量,可以返回选中的状态。
In Delphi XE7 (possibly earlier versions, too) this seems to have been resolved.
choice, a boolean variable, can return the checked status.
看起来它在 Delphi 10.4 中有效。
Flags
属性tfVerificationFlagChecked
现在是一个可靠的指示,即使用户多次更改该值也是如此。Seems like it works in Delphi 10.4. The
Flags
property,tfVerificationFlagChecked
, is now a reliable indication, even if the value is changed multiple times by the user.