Re: Substituting the main menu bar(s)
- From: "David Webber" <dave@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 5 Jun 2006 12:36:14 +0100
"Victor" <nijegorodov.otpusk@xxxxxxxxxx> wrote in message
news:uNjx2dAiGHA.4304@xxxxxxxxxxxxxxxxxxxxxxx
Take a look at
http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLD,GGLD:2004-
11,GGLD:en&q=How+to+Use+Multiple+Menus+in+MFC+App+That+Uses+GetDefaultMenu
Victor
Thanks Victor, that was very useful. I don't know how I missed it. It
mentions Ajay's method but indicates a "safer" one which settles my worries.
As a number of people have taken the trouble to help me, and in case any
lurkers are agog with anticipation, let me post the eventual solution
(semi-schematically) which seems to work for me.
1. Store an HMENU as a static member
CMyDocument::m_hMyMenu;
Initialise it to NULL
Return it with the virtual override CMyDocument::GetDefaultMenu()
2. When you want to replace the menus do the following:
// Load the new menus:
HMENU hMenuDoc = .....
// Load new menu for when document is active
HMENU hMenuNoDoc = ...
// Load new menu for when no document is active.
// Note the old menus:
HMENU hMenuDocOld = ...
// Menu stored as static member of CMyDocument
HMENU hMenuNoDocOld =
pFrameWnd->m_hMenuDefault;
// the current default for no active document.
// Make replacements:
CMyDocument::m_hMyMenu = hMenuDoc;
pFrameWnd->m_hMenuDefault = hMenuNoDoc;
// Tell the frame window to show the appropriate replacement:
pFrameWnd->OnUpdateFrameMenu( NULL );
pFrameWnd->DrawMenuBar();
// Tidy up:
if( hMenuDocOld ) DestroyMenu( hMenuDocOld );
if( hMenuNoDocOld ) DestroyMenu( hMenuNoDocOld );
=========
It's as easy as that when you know how, but finding out how is a different
matter. Thanks to everyone who has helped!
Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
.
- Follow-Ups:
- Re: Substituting the main menu bar(s)
- From: KMA
- Re: Substituting the main menu bar(s)
- References:
- Substituting the main menu bar(s)
- From: David Webber
- Re: Substituting the main menu bar(s)
- From: Ajay Kalra
- Re: Substituting the main menu bar(s)
- From: David Webber
- Re: Substituting the main menu bar(s)
- From: Ajay Kalra
- Re: Substituting the main menu bar(s)
- From: David Webber
- Re: Substituting the main menu bar(s)
- From: Victor
- Substituting the main menu bar(s)
- Prev by Date: Toolbar Button's abnormal behavior
- Next by Date: Re: Send message issue
- Previous by thread: Re: Substituting the main menu bar(s)
- Next by thread: Re: Substituting the main menu bar(s)
- Index(es):