Click here to Skip to main content
15,889,909 members
Articles / Desktop Programming / MFC
Article

Tooltips for Menu Item and popup menuitem

Rate me:
Please Sign up or sign in to vote.
2.93/5 (11 votes)
19 Nov 2003 136.9K   2.5K   36   32
Simple and best way to add tooltips to the menu items. All you have to do is simply include the header file and call Create and hook the WM_MENUSELECT message.

Sample Image - menuitemtooltip.gif

Introduction

This article describes what is in my opinion the simplest and best way to add tool tips to the menu items. All you have to do is simply include the header file and call Create and hook the WM_MENUSELECT message.

Call this Create function in OnInitDialog or OnCreate functions of your main window

myMenuToolTip.Create(m_hWnd, _T("Sample Menu Text"), 
    AfxGetResourceHandle(), TTS_NOPREFIX | TTS_BALLOON 
         // play with this flags to get your own style of toolips
, _T("My Best Tool Tip Title") // title for the tooltips
);

When your window receives WM_MENUSELECT, call OnMenuSelect function to notify my helper class

myMenuToolTip.OnMenuSelect(nItemID, nFlags, hSubMenu);

Helper Class implementation

  1. Creates a tool tip window and adds the parent as tool to tooltip window
  2. Makes the tool as trackable tool
  3. On MenuSelect (Highlight) based on selected item, helper class activates the tooltip and positions it next selected menu item.
  4. On MenuSelect (Unhighlight) deactivates the tooltip

Instead of just calling OnMenuSelect you could handle the menu messages by looking at default implementation in the helper class

Note: Tip text is extracted from resource just like MFC/WTL extracts text for status bar messages.

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralPaul di Lascia Pin
topus20-Nov-03 23:45
topus20-Nov-03 23:45 
GeneralVC7 Debug Pin
Andrew Phillips18-Jan-05 21:12
Andrew Phillips18-Jan-05 21:12 
GeneralTwo easy things to add Pin
dog_spawn20-Nov-03 13:45
dog_spawn20-Nov-03 13:45 
GeneralRe: Two easy things to add Pin
venu800020-Nov-03 14:44
venu800020-Nov-03 14:44 
GeneralRe: Two easy things to add Pin
dog_spawn20-Nov-03 15:38
dog_spawn20-Nov-03 15:38 
GeneralRe: Pin
Suresh200519753-Jul-09 20:15
Suresh200519753-Jul-09 20:15 
GeneralRe: Pin
Suresh200519753-Jul-09 20:17
Suresh200519753-Jul-09 20:17 

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.