CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Menus

  1. #1
    Guest

    Menus

    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.


  2. #2
    Join Date
    May 1999
    Posts
    36

    Re: Menus

    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

  3. #3
    Guest

    Re: Menus

    This easy method doesn't work for some reason, could someone explain the variables.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured