Click here to Skip to main content
13,249,813 members (84,683 online)
Click here to Skip to main content
Add your own
alternative version


31 bookmarked
Posted 5 Nov 2002

WTL Button Menu Class

, 5 Nov 2002
Rate this:
Please Sign up or sign in to vote.
Add a button that displays a menu when clicked to your WTL application
<!-- Download Links --> <!-- Article image -->

Sample Image - WTLButtonMenu.jpg

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


A small CButton-derived class that will display a popup menu when clicked. Easy to use and very handy for dialog based application.

Using CButtonMenu

To use this class with a WTL dialog, first include the header file in the MainDlg.h file:

#include <span class="code-string">"buttonmenu.h"</span>

Next, add a CButtonMenu object to the class:

CButtonMenu m_wndButtonMenu;

Next (and this is important), add a REFLECT_NOTIFICATIONS() call to your dialogs message map (else the button won't get the BN_CLICKED notification message):


Now subclass an existing button control and set the popup menu that you want displayed in your dialogs OnInitDialog function:

// Create button menu
// Set the menu ID that the button displays

Finally, add the necessary COMMAND_ID_HANDLERs for your popup menu commands.

That's it! The button will be displayed with an arrow (using the Marlett font if available), and will display a popup menu when clicked.


When designing a dialog-box that uses this class, instead of using a normal button control, use a checkbox control that has the "Push like" style-bit set. The advantage of using a checkbox is that the button will stay pushed whilst the popup menu is displayed (see the example project for more details)


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

You may also be interested in...

Comments and Discussions

GeneralMarlett Arrow Pin
Armen Hakobyan24-Mar-04 9:58
memberArmen Hakobyan24-Mar-04 9:58 
GeneralRe: Marlett Arrow Pin
Robert Edward Caldecott25-Mar-04 5:09
memberRobert Edward Caldecott25-Mar-04 5:09 
GeneralRe: Very nice, what about the dialog look? Pin
Robert Edward Caldecott17-Feb-03 23:05
memberRobert Edward Caldecott17-Feb-03 23:05 
GeneralVC6.0 AtlInitCommonControls missing Pin
Martin Holzherr6-Nov-02 7:18
memberMartin Holzherr6-Nov-02 7:18 
GeneralRe: VC6.0 AtlInitCommonControls missing Pin
Robert Edward Caldecott6-Nov-02 7:38
memberRobert Edward Caldecott6-Nov-02 7:38 
GeneralRe: VC6.0 AtlInitCommonControls missing Pin
Robert Edward Caldecott6-Nov-02 7:39
memberRobert Edward Caldecott6-Nov-02 7:39 
GeneralNice Pin
Anatoly Ivasyuk6-Nov-02 5:32
memberAnatoly Ivasyuk6-Nov-02 5:32 
Nice work! One suggestion I have is that when the arrow in the button is pointing to the right, the menu should appear to the right of the button rather than under it.


Anatoly Ivasyuk is co-founder of DTLink Software, a company specializing in Internet software and technologies. He is the author of DTLink's Windows products: AnswerTool, FAQTool, AppUpdate, and Personal Stock Monitor
GeneralRe: Nice Pin
Robert Edward Caldecott6-Nov-02 5:37
memberRobert Edward Caldecott6-Nov-02 5:37 
GeneralRe: Nice Pin
Paul Selormey6-Nov-02 14:39
memberPaul Selormey6-Nov-02 14:39 

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
Web03 | 2.8.171114.1 | Last Updated 6 Nov 2002
Article Copyright 2002 by Rob Caldecott
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid