Delphi 父窗体按钮
有没有办法禁用父窗口按钮?我有一个被很多表单调用的“工作”表单,我想禁用父表单按钮,直到它完成它的工作。然后重新打开它们。
我想做一些附加到 OnShow 事件和 onClose 事件的事情。
谢谢
-布拉德
Is there a way to disable the parent windows buttons? I have a "working" form that is called by a lot of forms, that I would like to disable the parent form buttons until it's finished doing it's thing. Then turn them back on.
I'd like to do something that is attached to the OnShow event and onClose event.
Thanks
-Brad
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建您想要调用的表单,如下所示:
然后在您想要调用此模态表单的按钮之后:
如果您只想禁用所有按钮,您可以迭代它们,而不是禁用 CallingForm,仅禁用调用表单。请参阅 Stack Overflow 主题(以及我的答案):动态转换表单编辑:或查看
_J_
的答案(基本上显示了主题)。不过,我会使用操作而不是按钮。
Create the form you want to call, as in:
Then after the button where you want to call this modal form:
If you just want to disable all buttons you can iterate through them and in stead of disabling the CallingForm only disable the buttons on the CallingForm. See the Stack Overflow topic (and my answer) at :Cast a form dynamically EDITED: or see answer of
_J_
(which basically show the topic).I would use actions in stead of buttons though.
如果辅助窗口打开,执行某些操作并关闭,那么使用
ShowModal
而不是Show
打开它是有意义的,这样用户就无法使用主窗体直到第二张表格关闭。如果您想遍历所有按钮并禁用或启用它们,代码将如下所示:
If the secondary window opens, does something and closes, then it would make sense to open it with
ShowModal
instead ofShow
, that way the user can't use the main form until the second form has closed.If you want to iterate though all the buttons and disable or enable them, the code would look something like this:
对于这样的东西,您只需要 1 行代码和一个 TActionList 组件。
创建一个包含操作的操作列表,并将该操作链接到按钮。操作具有 OnUpdate 事件,可让您确定是否应启用该操作(以及链接的按钮)。每次操作应该知道是否必须启用它时,都会触发 OnUpdate 事件。
For stuf like this you will need only 1 line of code and an TActionList component.
Create an actionlist with an action and link the action to the button. An action has an OnUpdate event which lets you determine if the action (and thus the linked button) should be enabled. The OnUpdate event is triggered everytime the action should know if it must be enabled or not.