CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2012
    Posts
    22

    [RESOLVED] Control main menu toolbar

    Hi!
    I want to hide a standard main menu toolbar of my MFC doc/view application. Howto?

    I tried this

    Code:
    ShowControlBar(&m_wndToolBar,TRUE,FALSE);
    - no reaction

    thanks in advance.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Control main menu toolbar

    m_wndToolBar has nothing to do with a menu. It is a toolbar window.
    In a "standard" MFC doc/view application menu bar is not a window, so you cannot just "hide" it. You could however destroy menu or destroy and then recreate it. See:
    How to Use Multiple Menus in MFC App That Uses GetDefaultMenu
    No replacement of Main menu bar
    Victor Nijegorodov

  3. #3
    Join Date
    May 2012
    Posts
    22

    Re: Control main menu toolbar

    Solved:

    Code:
    void CMainFrame::Hide() 
    {		
    	this->SetMenu(NULL);
    }
    
    void CMainFrame::Revoke() 
    {
    	CMenu m_NewMenu;
    	m_NewMenu.LoadMenu(IDR_MAINFRAME);
    	this->SetMenu(&m_NewMenu);
    }

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Control main menu toolbar

    Quote Originally Posted by 330xi View Post
    Solved:

    Code:
    void CMainFrame::Hide() 
    {		
    	this->SetMenu(NULL);
    }
    ...
    This solution is very "dirty" because it produces the leak of menu handles.
    You have to call CMenu::DestroyMenu to
    accomplish this task cleanly.
    See CWnd::SetMenu
    Victor Nijegorodov

  5. #5
    Join Date
    May 2012
    Posts
    22

    Re: Control main menu toolbar

    Oh, thanks for this note! I've read msdn. How could I be so inattentive?..(

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured