Office 2000-like Dockable Menu Bar and Intelligent Menus | CodeGuru

Office 2000-like Dockable Menu Bar and Intelligent Menus

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, […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 28, 2000
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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
    to:
    #include "MDIFrmEx.h"
    #include "ToolBarEx.h"
    
    class CMainFrame : public CMDIFrameEx
    and change toolbar class from
    CToolBar to CToolbarEx:
    CToolbar m_wndToolBar;
    becomes:
    CToolbarEx m_wndToolBar;
  5. Edit MainFrm.cpp (main frame window source file) in your project:
    Change:
    IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
    in:
    IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameEx)
    BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameEx)
    and in the function CMainFrame::OnCreate change:
    if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
    in:
    if (CMDIFrameEx::OnCreate(lpCreateStruct) == -1)
  6. Edit MyApp.h (application header file) in your project:
    Change  class declaration from:
    class CTestMDIApp : public CWinApp
    to:
    #include "WinAppEx.h"
    
    class CTestMDIApp : public CWinAppEx
  7. Edit MyApp.cpp (application source file) in your project:
    Change:
    BEGIN_MESSAGE_MAP(CTestMDIApp, CWinApp)
    in:
    #include "DocTplEx.h"
    
    BEGIN_MESSAGE_MAP(CTestMDIApp, CWinAppEx)
    and in function CMyApp::InitInstance replace:
    	CMultiDocTemplate* pDocTemplate;
    	pDocTemplate = new CMultiDocTemplate(
    		IDR_TESTMDTYPE,
    		RUNTIME_CLASS(CTestMDIDoc),
    		// custom MDI child frame
    		RUNTIME_CLASS(CChildFrame),
    		RUNTIME_CLASS(CTestMDIView));
    	AddDocTemplate(pDocTemplate);
    
    	// create main MDI Frame window
    	CMainFrame* pMainFrame = new CMainFrame;
    	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    		return FALSE;
    	m_pMainWnd = pMainFrame;
    with:
    	UINT nID;
    	nID=IDR_MAINFRAME;
    
    	// create main MDI Frame window
    	CMainFrame* pMainFrame = new CMainFrame;
    	if (!pMainFrame->LoadFrame(nID))
    		return FALSE;
    	m_pMainWnd = pMainFrame;
    
    	CMultiDocTemplateEx* pDocTemplate;
    	pDocTemplate = new CMultiDocTemplateEx(
    		IDR_TESTMDTYPE,
    		RUNTIME_CLASS(CTestMDIDoc),
    		// custom MDI child frame
    		RUNTIME_CLASS(CChildFrame),
    		RUNTIME_CLASS(CTestMDIView),
    		&nID,1);
    	AddDocTemplate(pDocTemplate);
    
    	CWinAppEx::InitInstance();
  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.

Downloads


Download demo project 1
Download demo project 2
Download source
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.