商务合作:179001057@qq.com

关于模态非模态对话框不响应菜单的UPDATE

技术2022-05-12  0


某平台价值19860元的编程课程资料免费领取【点我领取】


 

对于模态非模态对话框默认是不响应菜单的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);  } } }


最新回复(0)