Click here to Skip to main content
15,881,380 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.6K   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

 
GeneralTooltips for Menu Item not working Pin
Darryl Bryk9-Feb-10 13:23
Darryl Bryk9-Feb-10 13:23 
GeneralRe: Tooltips for Menu Item not working Pin
seav7314-Aug-12 4:28
seav7314-Aug-12 4:28 
GeneralRe: Tooltips for Menu Item not working Pin
Darryl Bryk28-Aug-12 10:37
Darryl Bryk28-Aug-12 10:37 
QuestionHas anybody got popup menu item tooltips working? Pin
Dave Streeter25-Aug-09 22:45
Dave Streeter25-Aug-09 22:45 
AnswerRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk27-Apr-10 13:12
Darryl Bryk27-Apr-10 13:12 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips8-Jul-10 17:42
Andrew Phillips8-Jul-10 17:42 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips8-Jul-10 18:45
Andrew Phillips8-Jul-10 18:45 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk9-Jul-10 8:59
Darryl Bryk9-Jul-10 8:59 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips12-Jul-10 8:52
Andrew Phillips12-Jul-10 8:52 
QuestionRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk9-Jul-10 9:20
Darryl Bryk9-Jul-10 9:20 
AnswerRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips12-Jul-10 9:08
Andrew Phillips12-Jul-10 9:08 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk19-Jul-10 9:07
Darryl Bryk19-Jul-10 9:07 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips26-Jul-10 12:07
Andrew Phillips26-Jul-10 12:07 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk2-Aug-10 6:13
Darryl Bryk2-Aug-10 6:13 
AnswerRe: Has anybody got popup menu item tooltips working? Pin
nbnacario12-Mar-14 7:36
nbnacario12-Mar-14 7:36 
GeneralProblem in VC7 Pin
sandip.lad30-Jul-09 19:10
sandip.lad30-Jul-09 19:10 
GeneralI built it with VS2005, when it runs, no tooltips displayed Pin
Bruce Li7-Mar-08 4:38
Bruce Li7-Mar-08 4:38 
Generalhelp i cant get it to work Pin
ywimmer18-Jul-07 16:26
ywimmer18-Jul-07 16:26 
Generalfailure when use XP themes! Pin
Vimvq19878-Apr-05 23:23
Vimvq19878-Apr-05 23:23 
I'm very soorry because my english is to bad.


Tooltips for menu item is excelent, but it's failure when i use XP themes.
It runs well when i don't use manifest file ( myapp.exe.manifest), but when i use, no tooltip is displayed!!!
Can't you tell me the way to solve this problem??
thanks very muchConfused | :confused:
GeneralRe: failure when use XP themes! Pin
Anil K P5-Jul-07 19:33
Anil K P5-Jul-07 19:33 
GeneralTips can display off screen Pin
R.D.H.19-Jan-05 5:20
R.D.H.19-Jan-05 5:20 
GeneralIncorrect show for second, third etc. submenu Pin
Eugene Pustovoyt16-Dec-03 3:03
Eugene Pustovoyt16-Dec-03 3:03 
GeneralRe: Incorrect show for second, third etc. submenu Pin
venu800016-Dec-03 6:00
venu800016-Dec-03 6:00 
GeneralCan't work for dynamic menu Pin
daveice10-Dec-03 21:32
daveice10-Dec-03 21:32 
GeneralNot bad! Pin
WREY24-Nov-03 22:29
WREY24-Nov-03 22:29 

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.