Print Page | Close Window

SetMenu does not work ?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=440
Printed Date: 23 December 2024 at 11:22am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: SetMenu does not work ?
Posted By: coradinibr
Subject: SetMenu does not work ?
Date Posted: 12 February 2004 at 2:19pm

Hi,

I need to change the menu based on the context of my application.

I have tried to change it by the conventional way, but it doesn't work !

I did the following :

1) Create a static CMenu member in My CMDIChildWnd my class where I can load the menu resources that I want.

2) On the OnCreate function I load the resource menu and call SetMenu to change it.

 

// part of the code

// s_menu is the static member !

 menu.LoadMenu(IDR_MY_MENU_RESOURCE);
 m_hMenuShared = menu.m_hMenu; // set the menu for all windows

// get the CommandBar created in the CMainFrame

 CXTPCommandBars* pCommandBar = theApp.m_pMainFrame->GetCommandBars();

// get the menu attached to it

CXTPMenuBar* pMenuBar = pCommandBar->GetMenuBar();

// load the new menu

 pMenuBar->SetMenu(&menu);

 

I get no ASSERT or errors.

The menu appears to load, but it appears on the border of the old menu.

When I try to access the menu itens, the menu change to the old one.

I'm using XTPro.

 

Thanks

Evandro Coradini




Replies:
Posted By: coradinibr
Date Posted: 13 February 2004 at 10:25am

Hi,

I figure out how to do it !

SetMenu does not work because it can be created only 1 time (the first time object is created).
We must use LoadMenu() for it !

Simple example:

CMenu menu;
menu.LoadMenu(MY_MENU);

CXTPCommandBars* pCommandBar;
CXTPToolBar*     pToolBar = NULL;
CXTPMenuBar*   pMenuBar;
pCommandBar = GetCommandBars();
pMenuBar = pCommandBar->GetMenuBar();
pMenuBar->LoadMenu(&menu);

Bye

Evandro Coradini




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