对于模态非模态对话框默认是不响应菜单的UPDATE_COMMAND_UI消息的,需要增加对WM_INITMENUPOPUP消息的处理以后,才可以响应UPDATE_COMMAND_UI。
- void CXXXDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
- {
- CDialog::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
-
-
- if(!bSysMenu && pPopupMenu)
- {
- CCmdUI cmdUI;
- cmdUI.m_pOther = NULL;
- cmdUI.m_pMenu = pPopupMenu;
- cmdUI.m_pSubMenu = NULL;
-
- UINT count = pPopupMenu->GetMenuItemCount();
- cmdUI.m_nIndexMax = count;
- for(UINT i=0; i<count; i++)
- {
- UINT nID = pPopupMenu->GetMenuItemID(i);
- if(-1 == nID || 0 == nID)
- {
- continue;
- }
- cmdUI.m_nID = nID;
- cmdUI.m_nIndex = i;
- cmdUI.DoUpdate(this, FALSE);
- }
- }
- }
http://blog.csdn.net/visualeleven/article/details/5513648