May 9th, 1999, 09:14 PM
How do I switch the check between three menu items? Under 'Options' they have a choice of 'Easy','Medium',or 'Hard'. I can't figure out how to switch the check to the one they currently selected.
|
Click to See Complete Forum and Search --> : Menus May 9th, 1999, 09:14 PM How do I switch the check between three menu items? Under 'Options' they have a choice of 'Easy','Medium',or 'Hard'. I can't figure out how to switch the check to the one they currently selected. Harvey Hawes May 9th, 1999, 10:06 PM Hi, There are two ways of doing this; both use CCmdUI: 1) Because there are only three options, you could handle each of the updates using class wiz the normal way. (Use the ON_UPDATE_COMMAND_UI. In this case the handlers could be OnUpdateEasy, OnUpdateMedium, OnUpdateHard... I'm sure you've done it a million times). The update handler should call CCmdUI::SetCheck(). I guess you'd just check a member variable like this... // take the easy option for example void CMyView::OnUpdateEasy(CCmdUI* pCmdUI) { pCmdUI->Enable(m_bEnableOptions); // some var to turn it on/off pCmdUI->SetCheck(m_nOption == MYOPT_EASY); // if the easy option is set... just an eg... } 2) The other way is to handle the 3 all at once using ON_UPDATE_COMMAND_UI_RANGE macro. You have to this yourself (see the docs on how to do this). The difference here is that you have to figure out which ID is being updated (you can use CCmdUI::m_nID). Set the check as above. You can also get a pointer to the menu itself through the CCmdUI::m_pMenu member. This way you can dynamically change text etc... . HTH, Harvey Hawes Software Engineer BioScience Analysis Software Ltd. Masters Candidate Cardiovascular/Respiratory Sciences Faculty of Medicine University of Calgary Calgary, Alberta, Canada May 10th, 1999, 09:44 PM This easy method doesn't work for some reason, could someone explain the variables. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |