DevStudio style Dockable Menu Bar (does not require MSIE) | CodeGuru

DevStudio style Dockable Menu Bar (does not require MSIE)

This article was contributed by MB. Environment: VC5/6 win95/98 I’m looking for Visual C++ 5.0 style menu bar, but most of products require MSIE4 or a new comctrl32.dll(don’t encourage me do update) . So I’ve made a class called CMenuBar which don’t use any common controls. To use CMenuBar in a MFC application, you have […]

Written By
CodeGuru Staff
CodeGuru Staff
Dec 29, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

This article was contributed by MB.

Environment: VC5/6 win95/98

I’m looking for Visual C++ 5.0 style menu bar,
but most of products require MSIE4 or a new comctrl32.dll(don’t encourage me do update) .
So I’ve made a class called CMenuBar which don’t use any common controls.

To use CMenuBar in a MFC application, you have to perform the following steps.

1. #include “MenuBar.h” in either StdAfx.h or MainFrm.h

2. Add CMenuBar m_wndMenuBar; to CMainFrame class

3. Add a following code to CMainFrame::OnCreate

    if (!m_wndMenuBar.CreateEx(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
        | CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_RAISEDBORDER) ||
        !m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
    {
        TRACE0(“Failed to create menubar\n”);
        return -1;      // failed to create
    }

4. Add a following code to CMainFrame::OnCreate after CStatusBar::Create and

before
CToolBar::EnableDocking and any other CMainFrame::EnableDocking.

    m_wndMenuBar.EnableDockingEx(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndMenuBar);

5. Overide PreTranslateMessage in CMainFrame with a following code

    BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
    {
        if (m_wndMenuBar.TranslateFrameMessage(pMsg))
            return TRUE;
        return CFrameWnd::PreTranslateMessage(pMsg);
    }
Update History :
July 01, 1999
    First submitted to CodeGuru.
July 11, 1999
    Posted on CodeGuru site.
    Fatal hanged up problem fixed.
        (I guess CMenuBar::SizeMenuBar had entered endless loop).
    Support a MDI application.
    Crash in debug mode fixed by Mark Gentry.Thanks!
    Gripper graphics changed a little.
    Rewrite most of codes.
    Use the latest CSubclassWnd.
October 06, 1999 version 2.08
    Cope with MFC6.(gripper graphics is changed.)
    Cope with CReBar easily.
    Insist own dock line by CMenuBar::EnableDockingEx.
November 13, 1999 version 2.10
    CMenuDockBar fixed
December 02, 1999 version 2.12
    Support OLE menu
Known Problems :
    Can't determine a direction of popupmenu as MSIE5 can't.
        (please check out _ComputeMenuTrackPoint)
    OLE menu support is not enough, but I can't add 5000 lines for perfect support.
Special Thanks to :
    Paul DiLascia an MSJ columnist
    This article is based on his *PixieLib*.

Downloads

Download demo project – 58 Kb
Download source – 26 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.