Click here to Skip to main content
13,300,002 members (49,842 online)
Click here to Skip to main content
Add your own
alternative version


239 bookmarked
Posted 7 Feb 2002

CMenuXP - The Office XP Style Menu

, 13 Jul 2003
Rate this:
Please Sign up or sign in to vote.
Owner drawn menu with the Office XP visual style

Sample Image - MenuXP.gif

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


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

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:
  2. In the ExitInstance method of your CWinApp derived class:

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.


    • 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
    • 14 Jul 03 - further update by Kris:

      Sample Image


    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


    About the Author

    Jean-Michel LE FOL
    Web Developer CSC
    France France
    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.

    You may also be interested in...

    Comments and Discussions

    BugOnDrawItem error Pin
    Rui Frazao10-Sep-12 14:33
    memberRui Frazao10-Sep-12 14:33 
    GeneralRe: OnDrawItem error Pin
    Koma Wang30-Aug-14 2:03
    memberKoma Wang30-Aug-14 2:03 
    GeneralRe: OnDrawItem error Pin
    Koma Wang31-Aug-14 19:18
    memberKoma Wang31-Aug-14 19:18 
    GeneralMy vote of 4 Pin
    unlimited298919-Apr-11 18:48
    memberunlimited298919-Apr-11 18:48 
    QuestionHow did it redraw the background of the menu bar? Pin
    lihnux10-Jun-10 16:42
    memberlihnux10-Jun-10 16:42 
    GeneralMenubar background bug Pin
    sapero_13-Dec-09 12:23
    membersapero_13-Dec-09 12:23 
    QuestionWould not see why VS2008 is the menu? Pin
    lee eun sung2-Dec-09 18:49
    memberlee eun sung2-Dec-09 18:49 
    Generalimages for submenus (i know how) Pin
    Toxa-TLT22-Sep-09 3:41
    memberToxa-TLT22-Sep-09 3:41 
    GeneralLisence for this code Pin
    ramanujamkv29-Jun-09 20:06
    memberramanujamkv29-Jun-09 20:06 
    GeneralRe: License for this code Pin
    Jean-Michel LE FOL29-Jun-09 23:25
    memberJean-Michel LE FOL29-Jun-09 23:25 
    GeneralRe: License for this code Pin
    ramanujamkv30-Jun-09 1:14
    memberramanujamkv30-Jun-09 1:14 
    GeneralI'm new player,english is very poor,my skype ID is "liu_zheng82" we are make friend Pin
    mimijiang31-May-09 22:59
    membermimijiang31-May-09 22:59 
    GeneralThe system nenu was mess up Pin
    johnxwang15-Oct-08 10:34
    memberjohnxwang15-Oct-08 10:34 
    GeneralRe: The system nenu was mess up Pin
    johnxwang15-Oct-08 10:45
    memberjohnxwang15-Oct-08 10:45 
    QuestionExcellent project. Did anyone try to implement this in a non-mfc app (.c file) Pin
    Sukar16-Jun-08 9:32
    memberSukar16-Jun-08 9:32 
    GeneralBig icons Pin
    Nguyen Hoang Quynh3-Mar-08 0:02
    memberNguyen Hoang Quynh3-Mar-08 0:02 
    Questionsystem menu is bad in SDI? Pin
    Ajean9-Apr-07 16:58
    memberAjean9-Apr-07 16:58 
    Generalhelp i can not make menu item greyed. Pin
    Richard Chan26-Nov-06 7:06
    memberRichard Chan26-Nov-06 7:06 
    GeneralRe: help i can not make menu item greyed. Pin
    Ogottogottogott13-Dec-06 22:23
    memberOgottogottogott13-Dec-06 22:23 
    GeneralIt doesn't work with dialog based programme Pin
    sting_lee5-Jul-06 22:56
    membersting_lee5-Jul-06 22:56 
    QuestionChanging Menu Font at run-time ??? Pin
    ana_v1235-Apr-06 22:22
    memberana_v1235-Apr-06 22:22 
    QuestionCMenuXP on certain menus Pin
    myst4ever26-Feb-06 14:28
    membermyst4ever26-Feb-06 14:28 
    AnswerRe: CMenuXP on certain menus Pin
    Parampreet Sidhu2-Mar-07 6:02
    memberParampreet Sidhu2-Mar-07 6:02 
    GeneralBug: It doesn't work with right to left style Pin
    k_dehairy15-Feb-06 23:42
    memberk_dehairy15-Feb-06 23:42 
    QuestionAnyone can help to solve this? Pin
    Einst7-Jan-06 14:01
    memberEinst7-Jan-06 14:01 
    I use this class for trial and it seems work. However when i apply this code into application class to stop creating a new MDI child automatically, the menuXP didn't perform correctly AT FIRST TIME. But when you open the file or create a new file, the menuXP class perform well.

    you can try to implement this code below in your application class and see what i mean Wink | ;)

    // Don't display a new MDI child window during startup
    if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)<br />
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;


    -- modified at 19:02 Saturday 7th January, 2006
    AnswerRe: Anyone can help to solve this? Pin
    barnabe4230-Jan-07 21:42
    memberbarnabe4230-Jan-07 21:42 
    GeneralThank You Pin
    Einst7-Jan-06 1:24
    memberEinst7-Jan-06 1:24 
    GeneralNovice-I need help to implement this class!! Pin
    neobavesten28-Nov-05 6:58
    memberneobavesten28-Nov-05 6:58 
    GeneralNew Use Pin
    phome20-Nov-05 15:46
    memberphome20-Nov-05 15:46 
    QuestionTransparencies? Pin
    jgt0228-Sep-05 6:16
    sussjgt0228-Sep-05 6:16 
    Answerthe same question Pin
    ahoye12-Jul-06 21:44
    memberahoye12-Jul-06 21:44 
    GeneralFix for SystemMenu Pin
    Ingo H. de Boer14-May-05 14:08
    memberIngo H. de Boer14-May-05 14:08 
    GeneralRe: Fix for SystemMenu Pin
    MORICHIKA6-Sep-05 5:12
    memberMORICHIKA6-Sep-05 5:12 
    GeneralGreate Fix! Re: Fix for SystemMenu Pin
    xuell001-Dec-05 16:50
    memberxuell001-Dec-05 16:50 
    GeneralRe: Fix for SystemMenu Pin
    Adiga7-Nov-06 18:51
    memberAdiga7-Nov-06 18:51 
    Questionhow to change icons Pin
    gogo82102829-Apr-05 16:54
    membergogo82102829-Apr-05 16:54 
    AnswerRe: how to change icons Pin
    Adiga7-Nov-06 19:18
    memberAdiga7-Nov-06 19:18 
    AnswerRe: how to change icons Pin
    dragonren_tj27-Dec-07 18:02
    memberdragonren_tj27-Dec-07 18:02 
    QuestionAre 24-bit images supported in this menu? Pin
    kkconcome27-Apr-05 14:51
    susskkconcome27-Apr-05 14:51 
    QuestionCDateTimeCtrl? Pin
    poiut6-Apr-05 9:18
    memberpoiut6-Apr-05 9:18 
    GeneralImages for popup items Pin
    ferret-e23-Mar-05 8:22
    memberferret-e23-Mar-05 8:22 
    GeneralBugs !! Pin
    DJ Mantra13-Feb-05 5:49
    memberDJ Mantra13-Feb-05 5:49 
    Generalchange the icons.... Pin
    Manoj Singh K31-Jan-05 2:30
    memberManoj Singh K31-Jan-05 2:30 
    GeneralRe: change the icons.... Pin
    hghn1-Apr-05 16:45
    memberhghn1-Apr-05 16:45 
    GeneralRe: change the icons.... Pin
    zwergerl16-May-05 4:16
    memberzwergerl16-May-05 4:16 
    GeneralRe: change the icons.... Pin
    zwergerl15-May-05 8:01
    memberzwergerl15-May-05 8:01 
    QuestionGreat ! But help me to fix a bug ? Pin
    Nguyen Duc Thien29-Jan-05 3:41
    memberNguyen Duc Thien29-Jan-05 3:41 
    AnswerRe: Great ! But help me to fix a bug ? Pin
    fjlaga28-Aug-06 12:55
    memberfjlaga28-Aug-06 12:55 
    GeneralMenu Bar Flicker Pin
    Graham G Pearson19-Jan-05 1:20
    memberGraham G Pearson19-Jan-05 1:20 
    QuestionGreat job! Can it support left-side bar? Pin
    lbjerry25-Dec-04 4:11
    memberlbjerry25-Dec-04 4:11 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web03 | 2.8.171207.1 | Last Updated 14 Jul 2003
    Article Copyright 2002 by Jean-Michel LE FOL
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid