问题描述
我有一个基于对话框的MFC应用程序。我的对话框有一个菜单,我使用的技术描述在对话框中启用菜单加速器。
这很好,但我似乎没有找到任何方法来实现菜单命令更新处理程序。或者,我实现了更新处理程序,但似乎找不到一个好的方法来让MFC调用它们。
搜索网络,我发现函数 UpdateDialogControls()
来实现对话框子控件的命令更新处理程序。
任何建议?
虽然 WM_KICKIDLE
最初似乎有希望这个消息到对话框,当他们进入空闲模式),我终于解决了技术描述在。
本文介绍如何处理 OnInitMenuPopup()
,然后将代码从 CMainFrame
复制到处理程序。
我不知道为什么MS没有提供更好的支持在这里对话框。但我有它为我的目的工作。
I have a dialog-based MFC application. My dialog box has a menu and I'm using the technique described here to enable menu accelerators in the dialog box.
This works fine but I can't seem to find any way to implement menu command update handlers. Or, rather, I've implemented update handlers but can't seem to find a good way to get MFC to call them.
Searching the web, I've found functions like UpdateDialogControls()
to implement command update handlers for dialog child controls. But I want to do this for commands in a dialog box menu.
Any suggestions?
I've got this working.
Although WM_KICKIDLE
initially seemed promising (MFC sends this message to dialog boxes when they enter idle mode), I finally settled on the technique described in the article Update Command UI Handlers Do Not Work for Menu Attached to a Dialog Box.
This article shows how to handle OnInitMenuPopup()
and then copy code from CMainFrame
to the handler.
I'm not sure why MS didn't provide better support here for dialog boxes. But I have it working for my purposes.
这篇关于菜单命令在对话框中更新处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!