Click here to Skip to main content
12,813,787 members (32,504 online)
Click here to Skip to main content
Add your own
alternative version


33 bookmarked
Posted 4 Jan 2001

CMenuEX - A bitmap menu class

, 4 Jan 2001
Rate this:
Please Sign up or sign in to vote.
Implementing an Ownerdrawn menu
<!-- Download Links -->
  • Download demo project - 35 Kb
  • <!-- Article image -->

    Sample Image - MenuEx1.gif  

    <!-- Main HTML starts here -->


    MS Visual studio and MS Office products have menus with bitmaps next to commands which are associated with toolbar buttons. The aim of this class was to provide a quick and easy method of implementing these types of menus. The menu class can be used to replace the mainframe window menu as well being used as a context menu.



    • ToolBarWrapper.h & ToolBarWrapper.cpp (Toolbar resource wrapper)
    • MenuEx.h & MenuEx.cpp (principle Menu class)

    Add the above files to your project.

    Next add the view header file to your projects header file where the menu is to be used for instance Mainfrm.h

    #include "MenuEx.h"

    CMenuEx is the class to be included to implement the menu.

    class CMainFrame : public CFrameWnd
     ... Some other code
     CMenuEx m_menu; 

    To initialise the menu for a frame window, call CMenuEx::Initialize in the OnCreate procedure.

    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
      if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;
    // MENUEX_ADD - Mainframe menu is initialized with parent window
      if (!m_menu.Initialize(IDR_MAINFRAME,this))
        return -1;
     ... Some other code

    We now need to provide support for sizing and drawing the menu, the requires processing the WM_MEASUREITEM and WM_DRAWITEM messages. Use the class wizard to create the message handlers (Note: You change the message filter option in the class wizard to Window).

    For menu items which use the Radio feature in MFC require this adding to your project where the SetRadio option is used to update the command user interface.

    // Example message handle for radio buttons
    void CMainFrame::OnUpdateRadioItem3(CCmdUI* pCmdUI)
      pCmdUI->SetRadio(m_nRadioGroup == 3);
      m_menu.SetRadio(pCmdUI,m_nRadioGroup == 3); // Set radio button here

    That's it, the next versions will support the intelligent menus and the new fangled MS Visual Studio 7.0beta menus.


    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

    Software Developer (Senior) Software Kinetics
    United Kingdom United Kingdom

    Software Kinetics
    are experts in developing customised and bespoke applications and have expertise in the development of desktop, mobile and internet applications on Windows.

    We specialise in:

    • User Interface Design

    • Desktop Development

    • Windows Phone Development

    • Windows Presentation Framework

    • Windows Forms

    • Windows Communication Framework

    • Windows Services

    • Network Applications

    • Database Applications

    • Web Development

    • Web Services

    • Silverlight


    Visit Software Kinetics

    You may also be interested in...

    Comments and Discussions

    QuestionGood but how to support multiple toolbars ? Pin
    LZL101023-Aug-06 17:28
    memberLZL101023-Aug-06 17:28 
    QuestionHow to response the click of menu?? Pin
    joynet28-Jul-04 23:38
    memberjoynet28-Jul-04 23:38 
    GeneralWhy Can't work in MDI Main Menu Pin
    qyq0011-Sep-03 19:32
    memberqyq0011-Sep-03 19:32 
    GeneralMemory Leak Pin
    Wolfram Steinke22-Mar-02 18:32
    memberWolfram Steinke22-Mar-02 18:32 
    GeneralProblem in ShortKey text Pin
    Mehul4-Mar-02 23:05
    memberMehul4-Mar-02 23:05 
    GeneralCoolMenu and outer calls Pin
    Anonymous10-Feb-02 20:33
    memberAnonymous10-Feb-02 20:33 
    GeneralRemake CmenuEx Pin
    Gennady Knoll14-Jan-02 0:12
    memberGennady Knoll14-Jan-02 0:12 
    GeneralDisabling the menu Pin
    James Bleakney9-Nov-01 10:38
    memberJames Bleakney9-Nov-01 10:38 
    GeneralBug when loading popup submenus with certain amount of items Pin
    Zdenek Breitenbacher18-Oct-01 22:05
    memberZdenek Breitenbacher18-Oct-01 22:05 
    QuestionBitmap Menu for Dialog Apps?? Pin
    James Bleakney18-Oct-01 4:43
    memberJames Bleakney18-Oct-01 4:43 
    General"good but" Pin
    peterchen17-Aug-01 2:23
    memberpeterchen17-Aug-01 2:23 
    GeneralRe: "good but" Pin
    Norm Almond18-Sep-01 23:23
    memberNorm Almond18-Sep-01 23:23 
    GeneralRe: "good but" Pin
    peterchen19-Sep-01 1:10
    memberpeterchen19-Sep-01 1:10 
    GeneralBug.. Pin
    Franc Milan21-Feb-01 2:16
    memberFranc Milan21-Feb-01 2:16 
    GeneralChange Font Pin
    Susanne Schmidt-Ott23-Jan-01 2:05
    memberSusanne Schmidt-Ott23-Jan-01 2:05 
    QuestionSupport for single menu/multiple toolbars? Pin
    Craig Henderson8-Jan-01 2:14
    memberCraig Henderson8-Jan-01 2:14 
    GeneralGiving Error Pin
    Anonymous8-Jan-01 1:03
    memberAnonymous8-Jan-01 1:03 
    GeneralRe: Giving Error Pin
    WREY7-Jan-04 20:16
    memberWREY7-Jan-04 20:16 
    QuestionWhere's your homepage? Pin
    Dandy Cheung7-Jan-01 17:07
    memberDandy Cheung7-Jan-01 17:07 
    AnswerRe: Where's your homepage? Pin
    Brett Kapilik8-Jan-01 5:50
    memberBrett Kapilik8-Jan-01 5:50 

    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
    Web02 | 2.8.170308.1 | Last Updated 5 Jan 2001
    Article Copyright 2001 by NormDroid
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid