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

A ToolBarCtrl Based Menubar Control

By , 3 Dec 2001
 

Sample Image - MenuBarXP.jpg

Introduction

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.

Implementation

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:

	ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, CToolBarXP::OnCustomDraw)

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.

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

Neil Yao
China China
Member
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 | :)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generalctoolbarxp didn't display textmemberwanglinhai88821 Feb '10 - 20:16 
GeneralSubMenu Bugmemberbenjamin2321 May '08 - 4:39 
The code doesn't seem to catch submenus when using keyboard navigation.
To do that you have to catch WM_MENUSELECT and set a flag when the menu item is a popupmenu so the right works as it is supposed.
GeneralApp suddenly exitsmemberChris982121 Apr '08 - 8:59 
GeneralRe: App suddenly exitsmemberhujian_19827 Sep '09 - 19:39 
QuestionSEPARATOR bugmemberlihe20057 Sep '06 - 20:16 
GeneralSome improvement (XP themes)memberAlexXF24 Nov '04 - 7:29 
GeneralRe: Some improvement (XP themes)memberFrank Overcast22 Jan '06 - 15:40 
GeneralCatch Click Eventsmembernaumankhan15 Apr '04 - 21:44 
GeneralRe: Catch Click EventsmemberYao Zhifeng15 Apr '04 - 21:59 
GeneralRe: Catch Click Eventsmemberjagan_gadela21 Apr '04 - 1:33 
GeneralRe: Catch Click Eventsmemberjagan_gadela21 Apr '04 - 1:58 
GeneralRe: Catch Click EventsmemberYao Zhifeng21 Apr '04 - 4:10 
GeneralRe: Catch Click Eventsmemberjagan_gadela22 Apr '04 - 2:05 
GeneralRe: Catch Click EventsmemberYao Zhifeng22 Apr '04 - 23:12 
GeneralRe: Catch Click EventsmemberJim Tomasko24 Apr '04 - 22:38 
Questionpossible to use this on SDI???memberHirosh16 Feb '03 - 20:57 
GeneralPretty cool, only one thing thoughmemberAnonymous11 May '02 - 0:50 
Questionhow to change the color of the toolbar?memberAnonymous1 May '02 - 19:40 
GeneralI have a problem!!!memberCSZX3 Apr '02 - 0:48 
GeneralDoesn't work with dropdown arrow.memberDuc Truong14 Jan '02 - 14:23 
GeneralChanging background color of MenumemberRitesh2321 Dec '01 - 22:36 
GeneralGood jobmemberCool_worm19 Dec '01 - 1:37 
GeneralMenu icon lost itself when mousemove on the popup menu itemsmemberGolden Lee10 Dec '01 - 15:46 
GeneralGetParentmemberorcun colak6 Dec '01 - 17:44 
GeneralRe: GetParentmemberYao Zhifeng7 Dec '01 - 4:13 
GeneralThanksmemberJeremy Davis5 Dec '01 - 1:26 

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

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