非模态对话框使用ON_UPDATE_COMMAND_UI

本文探讨了如何使MFC中的模式对话框能够进行闲置处理。由于模式对话框使用自身的消息循环,不能自动接收WM_KICKIDLE消息启动闲置处理。文章提供了一种解决方案,通过父窗口发送WM_IDLEUPDATECMDUI消息来触发模式对话框的闲置更新。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ON_UPDATE_COMMAND_UI for Modeless Dialogs
Modeless dialogs can't automatically use the WM_KICKIDLE message to start idle processing. This is because MFC uses it's own model dialog message loop that sends WM_KICKIDLE messages. But modeless dialogs use the standard dialog message loop in Windows. This one doesn't send WM_KICKIDLE messages.

So by taking a look at how MFC allows dialog bars to do idle processing, this is the best I can come up with.

1. Keep a pointer to the modeless dialog in the parent window that created the dialog. Frame or view.
2. In the parent window add a message map for WM_IDLEUPDATECMDUI. This message is pumped out by the app's OnIdle loop.
3. Send WM_IDLEUPDATECMDUI to the modeless dialog from the parent's OnIdleUpdateCmdUI function.
4. Add a message map for WM_IDLEUPDATECMDUI in the dialog and call UpdateDialogControls
5. Use ON_UPDATE_COMMAND_UI message maps as needed.

Notes:
WM_IDLEUPDATECMDUI is defined in afxpriv.h.
You could send the dialog WM_KICKIDLE messages. I just used WM_IDLEUPDATECMDUI to fit in with the way MFC does things.

 

Legacy CodeGuru | 10/07/1998 12:00am
close comment
Originally posted by: Tim McColl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值