CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    12

    Checking/Unchecking Menu Items

    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
    [email protected]

  2. #2
    Join Date
    May 1999
    Posts
    12

    Re: Checking/Unchecking Menu Items

    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


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