CMFCMenuBar menu manipulation problem.
-
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.
-
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.
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.
-
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.
-
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!