Menu Switching |
Post Reply |
Author | |
tyousef
Newbie Joined: 14 August 2006 Location: Egypt Status: Offline Points: 5 |
Post Options
Thanks(0)
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
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
try manually load menu:
pCommandBars->GetMenuBar()->LoadMenu(pMenu);
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
tyousef
Newbie Joined: 14 August 2006 Location: Egypt Status: Offline Points: 5 |
Post Options
Thanks(0)
|
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?
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Actually MFC and Toolkit already have support of MDI child menus without doc temaplte.
See Sample: uploads/20060814_140640_ChildMenus.zip
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
tyousef
Newbie Joined: 14 August 2006 Location: Egypt Status: Offline Points: 5 |
Post Options
Thanks(0)
|
Thanks oleg. This is much better. I found out what I was missing and it's working now. Thanks. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |