Click here to Skip to main content
6,290,315 members and growing! (16,249 online)
Email Password   helpLost your password?
Desktop Development » Menus » Custom menus     Intermediate

CMenuXP - The Office XP Style Menu

By Jean-Michel LE FOL

Owner drawn menu with the Office XP visual style
VC6, VC7Win2K, WinXP, MFC, Dev
Posted:7 Feb 2002
Updated:13 Jul 2003
Views:483,011
Bookmarked:190 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
137 votes for this article.
Popularity: 10.12 Rating: 4.74 out of 5
2 votes, 1.9%
1
2 votes, 1.9%
2
2 votes, 1.9%
3
7 votes, 6.6%
4
93 votes, 87.7%
5

Sample Image - MenuXP.gif

Menus in dialog windows : Sample Image (Menus in Dialog Window)- MenuXP_dlg.gif

Introduction

This article presents an implementation of an owner drawn menu with the Office XP and Visual Studio .NET visual style.

Using the code

To use the CMenuXP class in your projects, you have to add 3 macros in your code:

  1. In the header file of the class that handles the menu (probably the MainFrame):
    #include "Tools/MenuXP.h"    // Before the declaration of the class
    
    // ...
    
    
    DECLARE_MENUXP()             // Into the definition of the class
  2. In the source file of the same class:
    IMPLEMENT_MENUXP(className, baseClass);
  3. In the message map of the class:
    BEGIN_MESSAGE_MAP(className, baseClass)
        // ...
    
        ON_MENUXP_MESSAGES()   // <-- Added line
    
    END_MESSAGE_MAP()

To make borders flat, I subclass the popup menu window managed by the system. To make it possible, you have to add those 2 calls in your code:

  1. In the InitInstance method of your CWinApp derived class:
    CMenuXP::InitializeHook();
    
  2. In the ExitInstance method of your CWinApp derived class:
    CMenuXP::UninitializeHook();

To make the menubar flat, you must do this call:

CMenuXP::UpdateMenuBar (pFrameWnd); // pFrameWnd refers to the frame that 

                                    // contains the MenuBar

The best place for this call depends of the frame type:

  • For MDI application, into the OnUpdateFrameMenu method of the child windows.
  • For SDI application, into the LoadFrame method of the main frame.

Finally, don't forget the last call:

CMenuXP::SetXPLookNFeel (pFrameWnd); // refers to the frame that contains 

                                     // the MenuBar

Without this call, menus will appear in a standard mode.

    To draw the menu items, I reused some classes already presented in my article: Office XP look & feel.

    History

    • 02/08/2002 - First release.
    • 01/06/2003 - Adding flat borders and flat menubar.
    • 05/31/2003 - Kris Wojtas has updated the source code to allow MenuXP to draw "radio", "check" state and gradient under bitmaps.
    • 06/02/2003 - Corrections, radio items support (thanks to Kris Wojtas) and new demos (flat controls and dialog based sample). You can get the latest update to this article at www.azsoft.free.fr.
    • 14 Jul 03 - further update by Kris:

      Sample Image

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Jean-Michel LE FOL


    Member
    Jean-Michel LE FOL is a GraphTalk product architect.
    GraphTalk is a set of products which cover the whole scope of the development process. GraphTalk is used by the main insurance compagnies over the world.
    The development team is currently based in France near Paris.
    Occupation: Web Developer
    Company: CSC
    Location: France France

    Other popular Menus articles:

    Article Top
    You must Sign In to use this message board.
    FAQ FAQ 
     
    Noise Tolerance  Layout  Per page   
     Msgs 1 to 25 of 333 (Total in Forum: 333) (Refresh)FirstPrevNext
    GeneralLisence for this code Pinmemberramanujamkv20:06 29 Jun '09  
    GeneralRe: License for this code PinmemberJean-Michel LE FOL23:25 29 Jun '09  
    GeneralRe: License for this code Pinmemberramanujamkv1:14 30 Jun '09  
    GeneralI'm new player,english is very poor,my skype ID is "liu_zheng82" we are make friend Pinmembermimijiang22:59 31 May '09  
    GeneralThe system nenu was mess up Pinmemberjohnxwang10:34 15 Oct '08  
    GeneralRe: The system nenu was mess up Pinmemberjohnxwang10:45 15 Oct '08  
    QuestionExcellent project. Did anyone try to implement this in a non-mfc app (.c file) PinmemberSukar9:32 16 Jun '08  
    GeneralBig icons PinmemberNguyen Hoang Quynh0:02 3 Mar '08  
    Questionsystem menu is bad in SDI? PinmemberAjean16:58 9 Apr '07  
    Generalhelp i can not make menu item greyed. PinmemberRichard Chan7:06 26 Nov '06  
    GeneralRe: help i can not make menu item greyed. PinmemberOgottogottogott22:23 13 Dec '06  
    GeneralIt doesn't work with dialog based programme Pinmembersting_lee22:56 5 Jul '06  
    GeneralChanging Menu Font at run-time ??? Pinmemberana_v12322:22 5 Apr '06  
    QuestionCMenuXP on certain menus Pinmembermyst4ever14:28 26 Feb '06  
    AnswerRe: CMenuXP on certain menus PinmemberParampreet Sidhu6:02 2 Mar '07  
    GeneralBug: It doesn't work with right to left style Pinmemberk_dehairy23:42 15 Feb '06  
    GeneralAnyone can help to solve this? PinmemberEinst14:01 7 Jan '06  
    GeneralRe: Anyone can help to solve this? Pinmemberbarnabe4221:42 30 Jan '07  
    GeneralThank You PinmemberEinst1:24 7 Jan '06  
    GeneralNovice-I need help to implement this class!! Pinmemberneobavesten6:58 28 Nov '05  
    GeneralNew Use Pinmemberphome15:46 20 Nov '05  
    GeneralTransparencies? Pinsussjgt026:16 28 Sep '05  
    Generalthe same question Pinmemberahoye21:44 12 Jul '06  
    GeneralFix for SystemMenu PinmemberIngo H. de Boer14:08 14 May '05  
    GeneralRe: Fix for SystemMenu PinmemberMORICHIKA5:12 6 Sep '05  

    General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    PermaLink | Privacy | Terms of Use
    Last Updated: 13 Jul 2003
    Editor: Chris Maunder
    Copyright 2002 by Jean-Michel LE FOL
    Everything else Copyright © CodeProject, 1999-2009
    Web19 | Advertise on the Code Project