基于对话框程序用ON_UPDATE_COMMAND_UI更新菜单(Dialog based program updates menu with ON_UPDATE_COMMAND_UI).doc
- 1、本文档共8页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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
您可能关注的文档
- 吉林省省五大水利重点工程建成后将惠及千万人口(The five major water conservancy projects in Jilin province will benefit tens of millions of people when they are completed).doc
- 吉林市房屋权属登记条例(Regulations of Jilin Municipality on the registration of housing ownership).doc
- 吉祥三宝活动让幼儿们 文本文档(Auspicious Sambo activities allow children to text documents).doc
- 吉祥话,短信祝福语(Auspicious words, SMS greetings).doc
- 同大海岛今冲刺创业板 PE潜伏抢筹30%股权(This sprint gem PE latent Tongda Island rush to raise 30% stake).doc
- 同声传译训练规(Simultaneous interpretation training rule).doc
- 同声传译(SI)的自我训练方法 ,据说这是学英语事半功(The method of self training in simultaneous interpretation (SI), which is said to be a half thing in English).doc
- 同声传译练习方法(Simultaneous interpretation practice method).doc
- 吉林雾凇预报(Jilin rime forecast).doc
- 同学柯南小学(Classmate Conan primary school).doc
文档评论(0)