Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CMFCMenuBar menu manipulation problem.

CMFCMenuBar menu manipulation problem.

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oleg63
    wrote on last edited by
    #1

    I've started moving an MFC application to VS2008 MFC Feature Pack and got some problem with MainFrame menu manipulation. Now the menu class is CMFCMenuBar is derived from CMFCToolbar and not rely anymore on CMenu. Seems I need to rewrite whole menu manipulation chunk the new way. I didn't found any example of dynamic menu manipulation in Internet(like former: RemoveMenu, GetSubMenu, InsertMenu, GetSubMenu, AppendMenu, ModifyMenu, etc.) - Is there any web resources/solutions on CMFCMenuBar dynamic menu manipulations? Appreciate any suggestions. Thanks.

    S 1 Reply Last reply
    0
    • O oleg63

      I've started moving an MFC application to VS2008 MFC Feature Pack and got some problem with MainFrame menu manipulation. Now the menu class is CMFCMenuBar is derived from CMFCToolbar and not rely anymore on CMenu. Seems I need to rewrite whole menu manipulation chunk the new way. I didn't found any example of dynamic menu manipulation in Internet(like former: RemoveMenu, GetSubMenu, InsertMenu, GetSubMenu, AppendMenu, ModifyMenu, etc.) - Is there any web resources/solutions on CMFCMenuBar dynamic menu manipulations? Appreciate any suggestions. Thanks.

      S Offline
      S Offline
      Shashikant_2006
      wrote on last edited by
      #2

      use CMenu* pMenu = CMenu::FromHandle(mBar->GetHMenu()); where mBar is your CMFCMenuBar, now you can apply all the CMenu function on pMenu .

      Never complain,never explain,just do your work.

      O 1 Reply Last reply
      0
      • S Shashikant_2006

        use CMenu* pMenu = CMenu::FromHandle(mBar->GetHMenu()); where mBar is your CMFCMenuBar, now you can apply all the CMenu function on pMenu .

        Never complain,never explain,just do your work.

        O Offline
        O Offline
        oleg63
        wrote on last edited by
        #3

        Thanks, it works on pop-up menus, but don't work for top level menu.

        N 1 Reply Last reply
        0
        • O oleg63

          Thanks, it works on pop-up menus, but don't work for top level menu.

          N Offline
          N Offline
          neuroscript
          wrote on last edited by
          #4

          The problem is a "glitch" (that's how I refer to it) in BCG's design of these extensions. The correct code is below (an example for removing an item), but be sure to look below the code for the important part. NOTE: "n" = your sub menu and "ID" = the ID of the menu item you want to remove. CMenu* pMenu = CMenu::FromHandle( m_wndMenuBar.GetHMenu() ); CMenu* pSubMenu = pMenu ? pMenu->GetSubMenu( 0 ) : NULL; if( pSubMenu ) pSubMenu->RemoveMenu( ID, MF_BYCOMMAND ); IMPORTANT (see below, too): You must FIRST go to the registry and DELETE the entry for you product. HKCU/Software/Your Product. You can just delete the correct folder for the menu, but that's up to you to figure out which one it is. PROBLEM: This will solve it for you and new users of your product. However, existing users will never see the changes. There is a function CWinAppEx::CleanState(), which is supposed to remove memory from the registry. But, you will then have an app with no memory of toolbars, menus, etc...meaning customization is pointless. Good luck!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups