Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Menu Switching
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Menu Switching

 Post Reply Post Reply
Author
Message
tyousef View Drop Down
Newbie
Newbie
Avatar

Joined: 14 August 2006
Location: Egypt
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote tyousef Quote  Post ReplyReply Direct Link To This Post Topic: Menu Switching
    Posted: 14 August 2006 at 1:59am

Hi,

I'm working in a multi-Doc application with no Doc-view arch. Just different child frame are loaded in the main frame. Each child frame is dynamically loaded from a separate dll. I need to switch to a different menu with each child frame. So, I simply load each menu in its dll
 
int CModuleFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   ...
   HINSTANCE hClientResources = AfxGetResourceHandle();
   HINSTANCE hnewInst = ::GetModuleHandle(_T("Module1.dll"));
   AfxSetResourceHandle(hnewInst);
   m_hMenuShared= ::LoadMenu(hnewInst, MAKEINTRESOURCE(IDR_MODULE1_MENU));
   AfxSetResourceHandle(hClientResources);
 
 
   ...
}
 
and then set it on the MDI activation message.
 
void CModuleFrame::OnMDIActivate(BOOL bActivate,CWnd* pActivateWnd,CWnd* pDeactivateWnd)
{
     CMDIFrameWnd* pFrame = GetMDIFrame();
     if (pFrame)
    {
        ::SendMessage(pFrame->m_hWndMDIClient, WM_MDISETMENU,  (WPARAM)m_hMenuShared, (LPARAM)NULL);
        pFrame->DrawMenuBar();
    }
}
 
but this doesn't work?
 
Am I missing something??
 
Thanks
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: 14 August 2006 at 9:11am
Hi,
 
try manually load menu:
 
pCommandBars->GetMenuBar()->LoadMenu(pMenu);
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
tyousef View Drop Down
Newbie
Newbie
Avatar

Joined: 14 August 2006
Location: Egypt
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote tyousef Quote  Post ReplyReply Direct Link To This Post Posted: 14 August 2006 at 1:01pm
Thanks a lot oleg. It works.
 
BUT, is it good to load the menu each time the frame is switched? Don't I need to free (unload) something before each loading?
 
Also, what is the best way to restore the Mainframe menu when closing all the child frames?
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: 14 August 2006 at 2:07pm
Hi,
Actually MFC and Toolkit already have support of MDI child menus without doc temaplte.
 
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
tyousef View Drop Down
Newbie
Newbie
Avatar

Joined: 14 August 2006
Location: Egypt
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote tyousef Quote  Post ReplyReply Direct Link To This Post Posted: 16 August 2006 at 3:27am

Thanks oleg.

This is much better. I found out what I was missing and it's working now.

Thanks.

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