15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Overriding change of CMainFrame's menu

Terry Evans -- tevans@netcom.com
Sunday, July 07, 1996

Environment: VC++ 4.1 / Win 95

In my application I have 2 distinct menus.  The default menu, which
is used when the application first starts up and a project menu.

Using the default menu a user can open a project, which causes
the main frame's menu to change to the project menu.  I force
the menu change using SetMenu() since just opening a project doesn't
create any windows.  It just sets up some internal data structures.

After a project is opened, the user can open multiple views of
data pertaining to the current project.

The problem occurs when the last view is now closed in the application.
MFC automatically switches the menu for the main frame back to
the default menu for the application instead of leaving it at the
project menu.  I only want the default menu when the user decides to
close the current project.

So, I guess the question is, how do I keep MFC from changing the
menu back when the last view is closed?

Thanks in advance!

Terry Evans
tevans@netcom.com



Paul Kortekaas -- paulk@euronet.nl
Wednesday, July 10, 1996

----------
From: 	Terry Evans[SMTP:tevans@netcom.com]
Sent: 	Monday, July 08, 1996 7:05 AM
To: 	mfc-l@netcom.com
Subject: 	Overriding change of CMainFrame's menu

Try changing the m_hMenuDefault member of CMainFrame

// Destroy original menu and put a new one in place
// hInst is the a handle to the instance where the resource
// can be found. In my case this can also be a resource-only
// DLL which contains translated menus.
::DestroyMenu(((CMainFrame*)m_pMainWnd)->m_hMenuDefault);
((CMainFrame*)m_pMainWnd)->m_hMenuDefault =     ::LoadMenu(hInst,MAKEINTRESOURCE(IDR_NEWMENU));
::SetMenu(m_pMainWnd->m_hWnd, ((CMainFrame*)m_pMainWnd)->m_hMenuDefault);

Paul





| Вернуться в корень Архива |