Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > General Discussion
  New Posts New Posts RSS Feed - Manually changing main menu in an MDI app
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Manually changing main menu in an MDI app

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


Joined: 25 May 2005
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote JayW Quote  Post ReplyReply Direct Link To This Post Topic: Manually changing main menu in an MDI app
    Posted: 23 June 2005 at 8:12am

I have an application with several MDI-based editor windows (similar in appearance to Visual Studio/Dreamweaver, etc.), but it also has docking panes containing tree controls and properties which are not doc/view windows. Using the CMultiDocTemplate template class, I faithfully registered each editor document type with its own resources (menus, accelerator tables, etc.) and menus change properly when you switch back and forth between different editor views as expected. However, I cannot seem to manually load menus when, for example, a pane containing a tree view of the document hierarchy gets focus. I tried the following code but strangely, when I look at it in the debugger, m_hMenuDefault is always NULL when entering the function, which obviously will not work (it's hard to destroy a menu that doesn't exist...)

void CMainFrame::SetMainMenu(UINT nIDResource)
{

    ASSERT(nIDResource);

    // Remove/destroy old menu
    SetMenu(NULL);
    ::DestroyMenu(m_hMenuDefault);

    // Add the requested menu
    m_defaultMenu.LoadMenu(nIDResource);
    ASSERT(m_defaultMenu);

    SetMenu(&m_defaultMenu);
    m_hMenuDefault = m_defaultMenu.m_hMenu;

}

Thanks in advance,

Jay

Back to Top
JayW View Drop Down
Newbie
Newbie


Joined: 25 May 2005
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote JayW Quote  Post ReplyReply Direct Link To This Post Posted: 23 June 2005 at 2:06pm

Well, I found a fix for MFC/Windows in general, but it isn't going to work with Command Bars.  I'm going to post a more honed request in a different thread so consider this one dead.

Jay

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2005 at 2:04am

try.

pCommandBars->GetMenuBar()->LoadMenu

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.141 seconds.