Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Custom Menus
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Custom Menus

 Post Reply Post Reply
Author
Message
MacW View Drop Down
Senior Member
Senior Member


Joined: 26 June 2007
Status: Offline
Points: 253
Post Options Post Options   Thanks (0) Thanks(0)   Quote MacW Quote  Post ReplyReply Direct Link To This Post Topic: Custom Menus
    Posted: 20 July 2007 at 12:20pm
Hi,

I keep all menus in my application in an external XML resource file (to support multi-language applications). My resource manager gives me a CMenu object when I load a menu.

I want to set this as the main frame menu in my XTP application, and also use dynamic menus for my document templates.

This all works beautifully as long as I use the standard menus provides by the MFC. I can set the mainframe menu, and use the GetDefaultMenu virtual in my document classes to switch menus at runtime. When all documents are closed, the MFC takes care that the default mainframe menu is restored.


This works only so-so since I switched to XTP command bars.

To set the main frame menu, I copied some code from a XTP sample. This seems to set the correct menu, but I'm not sure if this is enough, or the right way to do it.



// Load the menu from somewhere
CMenu mnu;
mnu.CreateMenu();
PTResManager::Instance().GetMenu(IDM_MAINFRAME_MENU,mnu);

// Set the menu into the command bar
// (all copied from one of the MDI sample applications)

pCommandBars->SetMenu(PTResManager::Instance().GetString(PTR_MENUNAME_MAIN), IDR_MAINFRAME);
CXTPMenuBar* pmnubar = pCommandBars->GetMenuBar();
pmnubar->LoadMenu(&mnu,TRUE);




At runtime, the MDI document templates replace this menu as usual.
But when all documents are closed, XTP does not properly restore the standard mainframe menu. The menu set by the last document template remains even if there is no document anymore.

  • What do I need to override to make XTP work in a MDI app with dynamic menus?
  • I need to dynamically set the main frame menu (command bar) from a HMENU or CMenu
  • I need to set the menu dynamically at runtime when my app switches between multiple document templates
  • What is the right way to load a menu into a command bar for the main frame, or to switch the menus used by different document templates or views within a splitter?

I know how to do this correctly with the MFC. I need to know how to do this with XTP.

I've already searched the class list documentation, and also the samples you provide to no avail. The "one line per method" documentation on command bars unfortunately does not help much to understand how to use your classes

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.