基于对话框程序用ON_UPDATE_COMMAND_UI更新菜单(Dialog based program updates menu with ON_UPDATE_COMMAND_UI).doc

基于对话框程序用ON_UPDATE_COMMAND_UI更新菜单(Dialog based program updates menu with ON_UPDATE_COMMAND_UI).doc

  1. 1、本文档共8页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
基于对话框程序用ON_UPDATE_COMMAND_UI更新菜单(Dialog based program updates menu with ON_UPDATE_COMMAND_UI)

基于对话框程序用ON_UPDATE_COMMAND_UI更新菜单(Dialog based program updates menu with ON_UPDATE_COMMAND_UI) 2009-05-11 21:58 in the MFC dialog based application, to set up a dialog box menu, want menu is selected, the corresponding menu item displayed before the mark or point, but can not use the ON_UPDATE_COMMAND_UI update. From the command user interface processing function (Command UI handler) to change the menu state (enable / disable, select / deselect, change text), not working properly when handled by the dialog box. Void CTestDlg:: OnUpdateFileExit (CCmdUI*, pCmdUI) { . PCmdUI-SetCheck (TRUE); / / no text before the selected marker. PCmdUI-SetRadio (TRUE); / / show no point in the text. PCmdUI-SetText (Close); / / does not change the menu text. } Reason When the drop-down menu is displayed, the WM_INITMENUPOPUP message is sent first to display the menu item. MFC CFrameWnd:: OnInitMenuPopup function to traverse the menu item for each menu item and update call order processing function (if any). The appearance of the menu is updated to reflect the state of it (enabled / disabled, select / deselect) Update the user interface mechanism in the work can not be the dialog application based on CDialog because no OnInitMenuPopup processing function, and using the CWnds default processing function, the function is not for the menu item update call order processing function. Solve Apply the following steps to solve the problem Add ON_WM_INITMENUPOPUP items to the message map: BEGIN_MESSAGE_MAP (CTestDlg, CDialog) //{{AFX_MSG_MAP (CTestDlg) ........................ ........................ //}}AFX_MSG_MAP ON_WM_INITMENUPOPUP () END_MESSAGE_MAP () Add the OnInitMenuPopup member function to your dialog box class and copy the following code to the function (note that the code is basically copied from CFrameWnd:: OnInitMenuPopup (in WinFrm.cpp): Void CTestDlg:: OnInitMenuPopup (CMenu, *pPopupMenu, UINT, nIndex, BOOL, bSysMenu) { ASSERT (pPopupMenu = = NULL); Check the enabled state of va

您可能关注的文档

文档评论(0)

jgx3536 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:6111134150000003

1亿VIP精品文档

相关文档