关于模态/非模态对话框不响应菜单的UPDATE_COMMAND_UI消息

对于模态非模态对话框默认是不响应菜单的UPDATE_COMMAND_UI消息的,需要增加对WM_INITMENUPOPUP消息的处理以后,才可以响应UPDATE_COMMAND_UI。

 void CXXXDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) { CDialog::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); // TODO: Add your message handler code here 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); } } }

你可能感兴趣的:(UI,command,null)