CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

follow us on Twitter

Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















Home >> Visual C++ / C++ >> Controls >> Menu >> Alternative menu


Office 2000-like Dockable Menu Bar and Intelligent Menus
Rating: none

Piero Viano (view profile)
August 28, 2000

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.
(continued)



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

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
menu _ save _ open - Legacy CodeGuru (11/05/2003)
Problem with default ID_FILE_CLOSE - Legacy CodeGuru (03/13/2002)
Questions with icons/bitmaps on menu - Legacy CodeGuru (03/13/2002)
SDI version? - Legacy CodeGuru (05/08/2001)
Problem with Timer - Legacy CodeGuru (04/26/2001)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES