CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2005
    Location
    Ellesmera
    Posts
    427

    Question Disabling::Popup Menu

    Code:
    IDR_MYMENU MENU
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "E&xit", ID_FILE_EXIT
        END
    
        POPUP "&Stuff"
        BEGIN
            MENUITEM "&Go", ID_STUFF_GO
            MENUITEM "G&o somewhere else", 0, GRAYED
        END
    END
    I have the menu above. I can disable each item in the popup based on the ID but I can't grayout the the main popup area. In this case the &File.
    Is their a way to disable it, without knowing its ID?
    *** Con Tu Adios, Te Llevas, Mi Corazon***

    Traveling Encoder...

  2. #2
    Join Date
    Apr 2004
    Location
    USA
    Posts
    147

    Re: Disabling::Popup Menu

    Does this help??
    Unchecking a popup menu

  3. #3
    Join Date
    May 2005
    Location
    Ellesmera
    Posts
    427

    Re: Disabling::Popup Menu

    @shekar: already check that, but not what Im looking for.
    *** Con Tu Adios, Te Llevas, Mi Corazon***

    Traveling Encoder...

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Disabling::Popup Menu

    Something like:
    Code:
    CMenu* pMenu = AfxGetMainWnd()->GetMenu();
    if(pMenu != NULL)
       pMenu->EnableMenuItem(1, MF_BYPOSITION | MF_GRAYED); // disable second (with index '1') menu
    Victor Nijegorodov

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Disabling::Popup Menu

    And please don't miss this point:
    From MSDN
    When you change a window menu, the menu bar is not immediately updated. To force the update, call DrawMenuBar.
    Best regards,
    Igor

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Disabling::Popup Menu

    Good point, Igor!
    (Although in my small and fast test the menu item was disabled without DrawMenuBar call, it is still required if some of menus/submenus was removed or added or the whole menu bar).
    Victor Nijegorodov

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