Office 2000-like Dockable Menu Bar and Intelligent Menus


Application Security Testing: An Integral Part of DevOps

I was looking for Office 2000 style menu bar with intelligent menues, but my searches were no effect. So I've made a series of classes that emulate a style similar to Office 2000. These classes are based on work made by MB (mb2@geocities.co.jp) and Brent Corkum.

To use Office 2000 menu bar in your applications, you have to perform the following steps.

  1. Open MDI.rc file with Microsoft Visual C++ and copy every Dialog, String (from String Table) and Menu from this file to your project resource file.
  2. Copy Setup Menu from IDR_INT_MENU menu resource to your menu(es) if you want to include menu modification in your application.
  3. Copy every cpp and h file from directory containing library sources into your project folder. Include these files into your project.
  4. Edit MainFrm.h (main frame window header file) in your project:
    Change class declaration from:
    class CMainFrame : public CMDIFrameWnd
    #include "MDIFrmEx.h"
    #include "ToolBarEx.h"
    class CMainFrame : public CMDIFrameEx
    and change toolbar class from CToolBar to CToolbarEx:
    CToolbar m_wndToolBar;
    CToolbarEx m_wndToolBar;
  5. Edit MainFrm.cpp (main frame window source file) in your project:
    and in the function CMainFrame::OnCreate change:
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
    if (CMDIFrameEx::OnCreate(lpCreateStruct) == -1)
  6. Edit MyApp.h (application header file) in your project:
    Change  class declaration from:
    class CTestMDIApp : public CWinApp
    #include "WinAppEx.h"
    class CTestMDIApp : public CWinAppEx
  7. Edit MyApp.cpp (application source file) in your project:
    #include "DocTplEx.h"
    and in function CMyApp::InitInstance replace:
    	CMultiDocTemplate* pDocTemplate;
    	pDocTemplate = new CMultiDocTemplate(
    		// custom MDI child frame
    	// create main MDI Frame window
    	CMainFrame* pMainFrame = new CMainFrame;
    	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    		return FALSE;
    	m_pMainWnd = pMainFrame;
    	UINT nID;
    	// create main MDI Frame window
    	CMainFrame* pMainFrame = new CMainFrame;
    	if (!pMainFrame->LoadFrame(nID))
    		return FALSE;
    	m_pMainWnd = pMainFrame;
    	CMultiDocTemplateEx* pDocTemplate;
    	pDocTemplate = new CMultiDocTemplateEx(
    		// custom MDI child frame
  8. Compile and run your application.

If you wish to implement your own intelligent menu algorithms you can derive a class from CMenuBar and override the following functions:

WORD CMenuBar::IncMenuUsage(CMenuEx *pParent, 
                            UINT pos, 
                            WORD curusage)

BOOL CMenuBar::EvaluateIfGrayed(CMenuEx *pParent, 
                                UINT pos, 
                                WORD &curusage, 
                                int iMed, 
                                int iRange)

First function is called to increment current usage of menues. Second one is called to determine if a menu must be painted grayed or not. This function can also modify current usage of menues.If you need to store application defined data in menues you can use CMenuEx::GetExtraDataPtr(UINT) to obtain this extra data.

For suggestions and/or bug reports please e-mail me.


Download demo project 1
Download demo project 2
Download source


  • menu _ save _ open

    Posted by Legacy on 11/05/2003 12:00am

    Originally posted by: Hanhlona

    surpose i create a project in SDI, when i run, the users will input their data (data will input in a table), and they will save it. So how can i save it and how can i open it?
    Please help me
    Thank you very much

  • Questions with icons/bitmaps on menu

    Posted by Legacy on 03/13/2002 12:00am

    Originally posted by: Dave Galligher

    I've noticed that the icons only appear on the menu for buttons defined on IDR_MAINFRAME toolbar. How can we add bitmaps/icons for something other than what is on the main toolbar?

    Note: I have tried defining another toolbar and linking the individual button to an ID on the menu, but that does not work either. Also, building one toolbar with all the picture elements (icon/bitmaps) I need is not a good solution either, after all who wants a toolbar with 25 buttons? (rhetorical)

    Anybody? Thank you in advance.

    • Questions with icons/bitmaps on menu

      Posted by system32 on 02/18/2005 04:41am

      I have the same problem, as Dave Galligher. Can you help me? Thank you.

  • Problem with Timer

    Posted by Legacy on 04/26/2001 12:00am

    Originally posted by: na

    Sometime Timer works all time. That's not horror, but it's resource leak

  • StatusBar bug?

    Posted by Legacy on 04/25/2001 12:00am

    Originally posted by: Chang Wha Jeong

    I think StatusBar docking mechanism looks strange with
    this class.

    When I docked toolbar to the left, right or bottom,
    the StatusBar should dock fixed at full bottom line
    but, it shrinked or move up to toolbar.

    What is the problem?
    Nobody doesn't matter about it?

  • CRichEditView MDI compatibility?

    Posted by Legacy on 03/16/2001 12:00am

    Originally posted by: Mario M�ller

    Does anyone know the compatibility of these classes when
    used with a CRichEditView based MDI application?

    I'm thinking that it has something to do with the fact that
    CRichEditView uses an OLE container. Maybe these classes are
    not fully compatible with OLE containers.

    I get a runtime assertion error when trying to use these
    menus with a CRichEditView based MDI application, just as a
    new doucment is created or opened.

    If I comment out the OLE support in these classes, it works,
    but then I need to manually set the document menu myself.

    These classes work great with all other views except
    CRichEditView, for me at least.

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Mobility is reaching an inflection point in enterprise. Smart enterprises are moving away from tactical point solutions for mobile device management, looking instead for a secure, comprehensive, unified, and future-proof mobile-app platform. Enterprise applications are now at the heart of mobile productivity, data is shared outside the enterprise walls, and the data itself may reside on multiple devices and clouds. Read this guide to learn how a unified endpoint management (UEM) solution is critical to …

  • Today, Cloud First has become a major movement across the global business landscape. As cloud computing has become an imperative for global enterprises, Cloud First is key in building a long-term roadmap for cloud services by implementing higher application performance, higher scalability, and reduced spending on infrastructure. But how does a business go about developing a Cloud-First strategy that retains a maximum return on investment (ROI)? Read this white paper to discover solutions to hidden costs in the …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.