Click here to Skip to main content
Click here to Skip to main content

A ToolBarCtrl Based Menubar Control

, 3 Dec 2001
Rate this:
Please Sign up or sign in to vote.
A ToolBarCtrl based menubar control using CMenuXP
<!-- Download Links --> <!-- Article image -->

Sample Image - MenuBarXP.jpg

<!-- Add the rest of your HTML here -->


This menubar control is based on the CToolBarCtrl class rather than CToolBar, so it never assumes that it has a parent window derived from CFrameWnd. It lacks some features like docking or automatic tooltips, but it can be used with any window whose parent is derived from CWnd. You must of course be using MFC.


Between CMenuBar and CToolBarCtrl, I wrote a class named CToolBarXP to process customdraw. If you don't need this feature, just modify the base class as CToolBarCtrl, and remove the following line from the messagemap:


CToolBarXP includes a LoadToolBar member function to load a toolbar resource. It may be useful to you, even if you don't care about menubars or customdraw.

CMenuXP is used as the menu class to implement ownerdraw. CMenuXP is derived from CMenu so it has all the features of CMenu. If you don't need a ownerdraw menu, just use the CMenu members to construct the menu.

The included sample is simple and far from powerful, but it is a good start I hope.


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

Neil Yao

China China
I'm a chinese programer living in Shanghai, currently working for a software company whose main business is to deliver computer based testing. Software simulation for computer based testing and certifications is my main responsibility in this company. Execpt for software development, I like out-door activities and photography. I am willing to make friends in China and all over the world, so contact me if you have anything in common with meSmile | :)

Comments and Discussions

Generalctoolbarxp didn't display text Pinmemberwanglinhai88821-Feb-10 21:16 
GeneralSubMenu Bug Pinmemberbenjamin2321-May-08 5:39 
GeneralApp suddenly exits PinmemberChris982121-Apr-08 9:59 
GeneralRe: App suddenly exits Pinmemberhujian_19827-Sep-09 20:39 
QuestionSEPARATOR bug Pinmemberlihe20057-Sep-06 21:16 
GeneralSome improvement (XP themes) PinmemberAlexXF24-Nov-04 8:29 
GeneralRe: Some improvement (XP themes) PinmemberFrank Overcast22-Jan-06 16:40 
GeneralCatch Click Events Pinmembernaumankhan15-Apr-04 22:44 
GeneralRe: Catch Click Events PinmemberYao Zhifeng15-Apr-04 22:59 
GeneralRe: Catch Click Events Pinmemberjagan_gadela21-Apr-04 2:33 
GeneralRe: Catch Click Events Pinmemberjagan_gadela21-Apr-04 2:58 
GeneralRe: Catch Click Events PinmemberYao Zhifeng21-Apr-04 5:10 
GeneralRe: Catch Click Events Pinmemberjagan_gadela22-Apr-04 3:05 
GeneralRe: Catch Click Events PinmemberYao Zhifeng23-Apr-04 0:12 
GeneralRe: Catch Click Events PinmemberJim Tomasko24-Apr-04 23:38 
Questionpossible to use this on SDI??? PinmemberHirosh16-Feb-03 21:57 
GeneralPretty cool, only one thing though PinmemberAnonymous11-May-02 1:50 
Questionhow to change the color of the toolbar? PinmemberAnonymous1-May-02 20:40 
GeneralI have a problem!!! PinmemberCSZX3-Apr-02 1:48 
GeneralDoesn't work with dropdown arrow. PinmemberDuc Truong14-Jan-02 15:23 
GeneralChanging background color of Menu PinmemberRitesh2321-Dec-01 23:36 
GeneralGood job PinmemberCool_worm19-Dec-01 2:37 
GeneralMenu icon lost itself when mousemove on the popup menu items PinmemberGolden Lee10-Dec-01 16:46 
Hi, Mr. Yao Zhifeng:
Thank you for your cool XP-style MenuBar class. In addition to for menu icon to lost itself when mousemoving the popup menu
items with "a bit of speed", it generally works great in my dialog-based app. What precautions could I take to avoid this fly
in butter?
In reply to the question "What about message handle", your answer is simple and easy to follow. This seems to make the menu
item's ON_IDM_XXX:COMMAND message to be treated easy, no response to ON_IDM_XXX:UPDATE_COMMANDD_UI messages. I know that any
OnUpdate handlers which included in the dialog's message map will never be called in a dialog-based application. But by
handling the dialog's WM_KICKIDLE message, and mimicking MFC's routing of its UPDATE_UI messages, you can implement this with
a little work (John Wismar: I follow this article in a step-by-step way to
try to toggle the check mark initially put in front of a menu item using the statement
pPopup->AppendODMenu(MF_CHECKED, new CMenuXPText(IDM_SETTINGS_FTP, "&FTP Transfer")); in OnUpdateFTPTRansfer(CCmdUI* pCmdUI)
message handler, but nothing was happened. Any suggestions as well as some tips will be highly appreprited.
Thank you for your nice code again!
Golden Lee
Golden Lee
GeneralGetParent Pinmemberorcun colak6-Dec-01 18:44 
GeneralRe: GetParent PinmemberYao Zhifeng7-Dec-01 5:13 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150123.1 | Last Updated 4 Dec 2001
Article Copyright 2001 by Neil Yao
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid