Skip to main content
Email Password   helpLost your password?

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:

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

    You must Sign In to use this message board.
     
     
    Per page   
     FirstPrevNext
    Generalimages for submenus (i know how) Pin
    Toxa-TLT
    3:41 22 Sep '09  
    GeneralLisence for this code Pin
    ramanujamkv
    20:06 29 Jun '09  
    GeneralRe: License for this code Pin
    Jean-Michel LE FOL
    23:25 29 Jun '09  
    GeneralRe: License for this code Pin
    ramanujamkv
    1:14 30 Jun '09  
    GeneralI'm new player,english is very poor,my skype ID is "liu_zheng82" we are make friend Pin
    mimijiang
    22:59 31 May '09  
    GeneralThe system nenu was mess up Pin
    johnxwang
    10:34 15 Oct '08  
    GeneralRe: The system nenu was mess up Pin
    johnxwang
    10:45 15 Oct '08  
    QuestionExcellent project. Did anyone try to implement this in a non-mfc app (.c file) Pin
    Sukar
    9:32 16 Jun '08  
    GeneralBig icons Pin
    Nguyen Hoang Quynh
    0:02 3 Mar '08  
    Questionsystem menu is bad in SDI? Pin
    Ajean
    16:58 9 Apr '07  
    Generalhelp i can not make menu item greyed. Pin
    Richard Chan
    7:06 26 Nov '06  
    GeneralRe: help i can not make menu item greyed. Pin
    Ogottogottogott
    22:23 13 Dec '06  
    GeneralIt doesn't work with dialog based programme Pin
    sting_lee
    22:56 5 Jul '06  
    GeneralChanging Menu Font at run-time ??? Pin
    ana_v123
    22:22 5 Apr '06  
    QuestionCMenuXP on certain menus Pin
    myst4ever
    14:28 26 Feb '06  
    AnswerRe: CMenuXP on certain menus Pin
    Parampreet Sidhu
    6:02 2 Mar '07  
    GeneralBug: It doesn't work with right to left style Pin
    k_dehairy
    23:42 15 Feb '06  
    GeneralAnyone can help to solve this? Pin
    Einst
    14:01 7 Jan '06  
    GeneralRe: Anyone can help to solve this? Pin
    barnabe42
    21:42 30 Jan '07  
    GeneralThank You Pin
    Einst
    1:24 7 Jan '06  
    GeneralNovice-I need help to implement this class!! Pin
    neobavesten
    6:58 28 Nov '05  
    GeneralNew Use Pin
    phome
    15:46 20 Nov '05  
    GeneralTransparencies? Pin
    jgt02
    6:16 28 Sep '05  
    Generalthe same question Pin
    ahoye
    21:44 12 Jul '06  
    GeneralFix for SystemMenu Pin
    Ingo H. de Boer
    14:08 14 May '05  


    Last Updated 13 Jul 2003 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009