Is it possible to manipulate the menu of my CMDIFrameWndEx's CMFCMenuBar?

主宰稳场 提交于 2019-12-05 16:16:49

One way to do this is to handle the WM_INITMENUPOPUP message. Just before a menu is displayed, OnInitMenuPopup will get called with a pointer to the menu.

Note that this gets called each time the menu is about to pop up, and any changes you make are lost between invocations (you have to add your menu items each time OnInitMenuPopup is called).

The trick to using this is figuring out how to identify the menu that has been invoked. One way would be to compare the menu item ID of a known item. For example, if the first item on the menu is ID_FILE_OPEN, you could look for that. If found, you would assume that your “File” menu is the one being opened, and you could add your custom submenu.

Possibly you could also use the dwMenuData member of the MENUINFO struct, although I seem to recall having problems with this due to the way CMFCMenuBar builds the menu.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!