How can I hide a menu item under certain conditions in MFC?
I'm not interested in just graying it out.
views:
1145answers:
2
+5
A:
Add an Update Handler for your menu item (using ON_UPDATE_COMMAND_UI).
This line should appear in your message map:
ON_UPDATE_COMMAND_UI(ID_MYMENUITEM, OnUpdateMyMenuItem)
In the handler, use this code:
void CMainFrame::OnUpdateMyMenuItem(CCmdUI *pCmdUI)
{
if (pCmdUI->m_pMenu!=NULL)
pCmdUI->m_pMenu->DeleteMenu(pCmdUI->m_nID, MF_BYCOMMAND);
}
Serge - appTranslator
2009-01-05 16:09:26
+2
A:
Or if you are removing a single menu item use CMenu::RemoveMenu
Shane MacLaughlin
2009-01-05 16:12:30