Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A ToolBarCtrl Based Menubar Control

0.00/5 (No votes)
3 Dec 2001 1  
A ToolBarCtrl based menubar control using CMenuXP

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.

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