Hello.
I wish to enable and disable items in my dialog's main menu (File, Edit, View, etc.) depending on the circumstance. I get the File Menu's object like this:
CMenu *MainMenu = AfxGetApp()->m_pMainWnd->GetMenu();
CMenu *pFileMenu = MainMenu->GetSubMenu( 0 );
Since File is the first menu on the list, this should get the object for me. I set a breakpoint here to verify that pFileMenu is not NULL after this funciton is called, and indeed it is not.
So, to disable a menu item, I do the following:
UINT result = pFileMenu->EnableMenuItem( ID_FILE_MENUITEM, MF_BYCOMMAND | MF_GRAYED);
I set a break point here, and the result IS valid. However, when I hit F5 to resume execution of the program, and then look at the menu item, it is not grayed out like it is supposed to be. Does anyone know what I'm doing wrong?