Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - SetMenu does not work ?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SetMenu does not work ?

 Post Reply Post Reply
Author
Message
coradinibr View Drop Down
Newbie
Newbie


Joined: 10 February 2004
Location: Brazil
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote coradinibr Quote  Post ReplyReply Direct Link To This Post Topic: SetMenu does not work ?
    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

Back to Top
coradinibr View Drop Down
Newbie
Newbie


Joined: 10 February 2004
Location: Brazil
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote coradinibr Quote  Post ReplyReply Direct Link To This Post 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

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.188 seconds.