Programming Tips - How do I change a menu from the CMainFrame class of my MDI application?
Platform: Visual C++
Q. How do I change a menu from the CMainFrame class of my MDI application?
A. Your generated MFC MDI application has two menus:
IDR_MAINFRAME and IDR_MEDIATTYPE. If you do GetMenu() to get a handle
in your CMainFrame's OnCreate() member your changes will disappear
with the menu is changed to IDR_MEDIATTYPE. The solution is to use
ON_UPDATE_COMMAND_UI() like this.
afx_msg void OnUpdateSomething(CCmdUI* pCmdUI);
void CMainFrame::OnUpdateSomething(CCmdUI* pCmdUI)
if (pCmdUI == NULL) return;
This is great to modify an individual menu item but if you want to
add / delete items it doesn't really work.