Print Page | Close Window

Switching MDI Menus from simple to advanced

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=9589
Printed Date: 17 November 2024 at 10:04pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Switching MDI Menus from simple to advanced
Posted By: Dexter
Subject: Switching MDI Menus from simple to advanced
Date Posted: 14 February 2008 at 9:27pm
I am just finishing an MDI application that has two document templates, each with a separate menu. All works well, in fact extremely well.
But the menus are quite large and I would like to have a simple menu for each of the document templates which would be loaded at the begining but that users could change at any time.

I does not matter that any changes to the menus would be lost, in fact I prefer that if the user changes from simple to advanced mode they start fresh.

I have tried all sorts of things but can't seem to get it to work. The closest seemed to be using CXTPMenuBar::SwitchMDIMenu() as in the simplified code below from the CMainFrame class:

   if ( bSimpleMode ) {
      uMenu = IDR_DOC_DYNAMIC_SIMPLE;
      uMenu = IDR_DOC_STATIC_SIMPLE;
   } else {
      uMenu = IDR_DOC_DYNAMIC; // this is the id of the first template
      uMenu = IDR_DOC_STATIC; // this is the id of the second template
   }

   cMenu.LoadMenu( MIR( uMenu ) );
   CXTPCommandBars* pCommandBars =  GetCommandBars();
   pMenuBar = (CXTPMenuBar *)pCommandBars->GetMenuBar();
   pMenuBar->SwitchMDIMenu( IDR_DOC_DYNAMIC, &cMenu );

and afterwards I tried various ways to redraw the command bars and window but all to no effect.

Any suggestions on how this could be done would be greatly appreciated!

Thanks,
Dexter of FileBoss




Replies:
Posted By: Oleg
Date Posted: 15 February 2008 at 1:41am
Hi,
 
If you don't need keep user customization for menus you can just call
 
pMenuBar->LoadMenu(&cMenu);


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Dexter
Date Posted: 15 February 2008 at 2:11am
Originally posted by oleg oleg wrote:

If you don't need keep user customization for menus you can just call 
 pMenuBar->LoadMenu(&cMenu);


Thanks! Though it does make me feel a little strange as I tried so many different calls, both MFC and in the toolkit but not that one.

It certainly works but still leaves one problem. It will only change the menu for the document template of the current view and child frame. But I have two document templates that need to be changed, i.e. both templates should have either simple or advanced menus not one simple and the other advanced.

If I have to I could set a flag so that the next time a frame belonging to the other document template is activated it would make the appropriate call to CXTPMenuBar::LoadMenu().

But if there is a way to set the menus for both document templates immediately that would certainly be much better.

Thanks,
Dexter



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net