Popup Menu - Check Menu Item
-
Hi, I have a dialog box with a pop-up menu and one of the menu entry in there has the 'Checked' property set to true (as default). Now during the execution of my program, I would like to un-check the check mark next to this menu item, but I can't seem to be able to accomplish this, the check-mark seems to be there always. Debugging through the code, it seems to execute the correct statements, but the GUI does not seem to get updated. Any help would be greatly apperciated. VS2005, C++ (MFC) Code:
CMenu menuTst;
VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));
CMenu* pPopupTest = menuTst.GetSubMenu(0);UINT state = pPopupTest->GetMenuState(ID\_OPEN\_LOGFILE, MF\_BYCOMMAND); ASSERT(state != 0xFFFFFFFF); if (state & MF\_CHECKED) pPopupTest->CheckMenuItem(ID\_OPEN\_LOGFILE, MF\_UNCHECKED | MF\_BYCOMMAND); else pPopupTest->CheckMenuItem(ID\_OPEN\_LOGFILE, MF\_CHECKED | MF\_BYCOMMAND);
-
Hi, I have a dialog box with a pop-up menu and one of the menu entry in there has the 'Checked' property set to true (as default). Now during the execution of my program, I would like to un-check the check mark next to this menu item, but I can't seem to be able to accomplish this, the check-mark seems to be there always. Debugging through the code, it seems to execute the correct statements, but the GUI does not seem to get updated. Any help would be greatly apperciated. VS2005, C++ (MFC) Code:
CMenu menuTst;
VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));
CMenu* pPopupTest = menuTst.GetSubMenu(0);UINT state = pPopupTest->GetMenuState(ID\_OPEN\_LOGFILE, MF\_BYCOMMAND); ASSERT(state != 0xFFFFFFFF); if (state & MF\_CHECKED) pPopupTest->CheckMenuItem(ID\_OPEN\_LOGFILE, MF\_UNCHECKED | MF\_BYCOMMAND); else pPopupTest->CheckMenuItem(ID\_OPEN\_LOGFILE, MF\_CHECKED | MF\_BYCOMMAND);
You are loading menu locally in the function that,s why its not affecting the changes. make CMenu menuTst; member of class and load (VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));) somewhere like initdialog();
Sudhir Kumar
-
You are loading menu locally in the function that,s why its not affecting the changes. make CMenu menuTst; member of class and load (VERIFY(menuTst.LoadMenu(IDR_MENU_HELP));) somewhere like initdialog();
Sudhir Kumar
Hmm..unfortunately making the CMenu variable member of the class didn't seem to work either. I tried adding an ON_UPDATE_COMMAND_UI function for my menu item to try it in there, with no success!
void CTestDialog::OnUpdateOpenLogfile(CCmdUI *pCmdUI)
{//pCmdUI->SetCheck(1); pCmdUI->SetCheck(0);
}
-
Hmm..unfortunately making the CMenu variable member of the class didn't seem to work either. I tried adding an ON_UPDATE_COMMAND_UI function for my menu item to try it in there, with no success!
void CTestDialog::OnUpdateOpenLogfile(CCmdUI *pCmdUI)
{//pCmdUI->SetCheck(1); pCmdUI->SetCheck(0);
}
Why CMenu doesnt work?