Click to See Complete Forum and Search --> : Checking/Unchecking Menu Items
Adrian Mongeli
May 6th, 1999, 10:27 PM
I need to allow a user to toggle a menu item.. checked on/unchecked off.
How do you code this? Can you provide an example?
Thank you for your assistance.
- Adrian
Adrian Mongeli
DigicodeSys@earthlink.net
shridhar rao
May 6th, 1999, 11:49 PM
Hi,
You'll have to handle the UPDATE_COMMAND_UI handler for each of the menu items you want to check or uncheck. Now have a BOOL variable which toggles everytime the user clicks on the menu item in the COMMAND handler of the same menu item. In the UPDATE... handler just use
pCmdUI->SetCheck(YourBool);
An example
I'll declare a variable bCheck as BOOL
In the constructor I'll assign bCheck = FALSE;
CMyClass::OnXXX()
{
bCheck^=1; // This toggles the state;
//do your menu related operations
}
CMyClass::OnUpdateXXX(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(bCheck);
}
I hope this will help
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.