Print Page | Close Window

Menu Switching

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=4789
Printed Date: 04 October 2024 at 1:24pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Menu Switching
Posted By: tyousef
Subject: Menu Switching
Date 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



Replies:
Posted By: Oleg
Date Posted: 14 August 2006 at 9:11am
Hi,
 
try manually load menu:
 
pCommandBars->GetMenuBar()->LoadMenu(pMenu);


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


Posted By: tyousef
Date 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?


Posted By: Oleg
Date Posted: 14 August 2006 at 2:07pm
Hi,
Actually MFC and Toolkit already have support of MDI child menus without doc temaplte.
 
See Sample: https://forum.codejock.com/uploads/20060814_140640_ChildMenus.zip - uploads/20060814_140640_ChildMenus.zip
 
https://forum.codejock.com/uploads/20060814_140533_ChildMenus.zip -  


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


Posted By: tyousef
Date 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.




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