Click here to Skip to main content
12,627,681 members (33,314 online)
Click here to Skip to main content
Add your own
alternative version

Stats

103.4K views
2.1K downloads
35 bookmarked
Posted

Tooltips for Menu Item and popup menuitem

, 19 Nov 2003
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

venu8000
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralTooltips for Menu Item not working Pin
Darryl Bryk9-Feb-10 14:23
memberDarryl Bryk9-Feb-10 14:23 
GeneralRe: Tooltips for Menu Item not working Pin
seav7314-Aug-12 5:28
memberseav7314-Aug-12 5:28 
GeneralRe: Tooltips for Menu Item not working Pin
Darryl Bryk28-Aug-12 11:37
memberDarryl Bryk28-Aug-12 11:37 
QuestionHas anybody got popup menu item tooltips working? Pin
Dave Streeter25-Aug-09 23:45
memberDave Streeter25-Aug-09 23:45 
AnswerRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk27-Apr-10 14:12
memberDarryl Bryk27-Apr-10 14:12 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips8-Jul-10 18:42
memberAndrew Phillips8-Jul-10 18:42 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips8-Jul-10 19:45
memberAndrew Phillips8-Jul-10 19:45 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk9-Jul-10 9:59
memberDarryl Bryk9-Jul-10 9:59 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips12-Jul-10 9:52
memberAndrew Phillips12-Jul-10 9:52 
QuestionRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk9-Jul-10 10:20
memberDarryl Bryk9-Jul-10 10:20 
AnswerRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips12-Jul-10 10:08
memberAndrew Phillips12-Jul-10 10:08 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk19-Jul-10 10:07
memberDarryl Bryk19-Jul-10 10:07 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Andrew Phillips26-Jul-10 13:07
memberAndrew Phillips26-Jul-10 13:07 
GeneralRe: Has anybody got popup menu item tooltips working? Pin
Darryl Bryk2-Aug-10 7:13
memberDarryl Bryk2-Aug-10 7:13 
AnswerRe: Has anybody got popup menu item tooltips working? Pin
nbnacario12-Mar-14 8:36
membernbnacario12-Mar-14 8:36 
GeneralProblem in VC7 Pin
sandip.lad30-Jul-09 20:10
membersandip.lad30-Jul-09 20:10 
GeneralI built it with VS2005, when it runs, no tooltips displayed Pin
Bruce Li7-Mar-08 5:38
memberBruce Li7-Mar-08 5:38 
Generalhelp i cant get it to work Pin
yotamwimmer18-Jul-07 17:26
memberyotamwimmer18-Jul-07 17:26 
Generalfailure when use XP themes! Pin
maiquan19879-Apr-05 0:23
membermaiquan19879-Apr-05 0:23 
GeneralRe: failure when use XP themes! Pin
Anil K P5-Jul-07 20:33
memberAnil K P5-Jul-07 20:33 
GeneralTips can display off screen Pin
R.D.H.19-Jan-05 6:20
memberR.D.H.19-Jan-05 6:20 
GeneralIncorrect show for second, third etc. submenu Pin
Eugene Pustovoyt16-Dec-03 4:03
memberEugene Pustovoyt16-Dec-03 4:03 
GeneralRe: Incorrect show for second, third etc. submenu Pin
venu800016-Dec-03 7:00
membervenu800016-Dec-03 7:00 
GeneralCan't work for dynamic menu Pin
daveice10-Dec-03 22:32
memberdaveice10-Dec-03 22:32 
GeneralNot bad! Pin
WREY24-Nov-03 23:29
memberWREY24-Nov-03 23:29 
GeneralPaul di Lascia Pin
topus21-Nov-03 0:45
membertopus21-Nov-03 0:45 
GeneralVC7 Debug Pin
Andrew Phillips18-Jan-05 22:12
memberAndrew Phillips18-Jan-05 22:12 
GeneralTwo easy things to add Pin
dog_spawn20-Nov-03 14:45
memberdog_spawn20-Nov-03 14:45 
GeneralRe: Two easy things to add Pin
venu800020-Nov-03 15:44
membervenu800020-Nov-03 15:44 
GeneralRe: Two easy things to add Pin
dog_spawn20-Nov-03 16:38
memberdog_spawn20-Nov-03 16:38 
GeneralRe: Pin
Suresh200519753-Jul-09 21:15
memberSuresh200519753-Jul-09 21:15 
GeneralRe: Pin
Suresh200519753-Jul-09 21:17
memberSuresh200519753-Jul-09 21: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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.3 | Last Updated 20 Nov 2003
Article Copyright 2003 by venu8000
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid