Click here to Skip to main content
12,689,305 members (28,385 online)
Click here to Skip to main content
Add your own
alternative version

Stats

160.8K views
6.3K downloads
54 bookmarked
Posted

Display ToolTip in any place on the screen

, 1 Sep 2002
Rate this:
Please Sign up or sign in to vote.
This article shows how to display tooltips at any location on the screen

Sample ToolTip

Introduction

This article shows how to display tooltips at any location on the screen.

To create a tooltip it is necessary to create a window of class TOOLTIPS_CLASS, then to fill a TOOLINFO structure: <pre lang=c++>typedef struct tagTOOLINFO{ UINT cbSize; UINT uFlags; HWND hwnd; UINT_PTR uId; RECT rect; HINSTANCE hinst; LPTSTR lpszText; #if (_WIN32_IE >= 0x0300) LPARAM lParam; #endif } TOOLINFO, NEAR *PTOOLINFO, FAR *LPTOOLINFO;

We determine two parameters in this structure which are interesting to us: uFlags and lpszText.

uFlags it is chosen equal TTF_TRACK, that gives us an opportunity of use message sending to choosing a position for ToolTip and control visibility.

lpszText - the task of the text which we want display.

Now we send the message in system, about desire to create the emerging help where we transfer the reference to our structure TOOLINFO <pre lang=c++>SendMessage (hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) *ti);

Then we send a TTM_TRACKPOSITION message  which sets the coordinates of ToolTip <pre lang=c++>SendMessage (hwndTT, TTM_TRACKPOSITION, 0, (LPARAM) (DWORD) MAKELONG (m_x, m_y)); where m_x and m_y coordinates x and y on the screen.

And finally we send the message to activate the ToolTip <pre lang=c++>SendMessage (hwndTT, TTM_TRACKACTIVATE, true, (LPARAM) (LPTOOLINFO) *ti); where the true value indicates we will display the ToolTip. If we specified false, the ToolTip will be hidden.

History

1 Sep 2002 - updated source code

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

Zarembo Maxim
Software Developer
Belarus Belarus
I work as the programmer. I live in Belarus in Minsk. At me higher education. I have experience development programs at use TCP/IP, Win32, MFC, HTTP, SNMP, HASP4, eToken, OpenGl, Hooks. Recently I use packages of development Visual Studio 6.0 and .Net.

You may also be interested in...

Pro

Comments and Discussions

 
GeneralThank you very much Pin
roxxxxssss21-Jul-16 17:41
memberroxxxxssss21-Jul-16 17:41 
QuestionLearn english ! Pin
Elmue13-Nov-15 19:20
memberElmue13-Nov-15 19:20 
AnswerRe: Learn english ! Pin
wilkoVerweij1-Jan-16 10:51
memberwilkoVerweij1-Jan-16 10:51 
QuestionAttaching tool tip to a control Pin
masteryoda216-May-15 8:23
membermasteryoda216-May-15 8:23 
QuestionTooltip does not displays when I compile source code and run the program Pin
AlwaysLearningNewStuff30-Jan-14 9:03
memberAlwaysLearningNewStuff30-Jan-14 9:03 
AnswerRe: Tooltip does not displays when I compile source code and run the program Pin
Zarembo Maxim24-Jul-14 8:41
memberZarembo Maxim24-Jul-14 8:41 
AnswerRe: Tooltip does not displays when I compile source code and run the program Pin
Member 37225838-Feb-15 19:50
memberMember 37225838-Feb-15 19:50 
AnswerFix for newer Visual Studio versions Pin
Elmue13-Nov-15 19:30
memberElmue13-Nov-15 19:30 
GeneralGreat Job - clean concise source Pin
Member 44391222-Nov-09 5:59
memberMember 44391222-Nov-09 5:59 
GeneralEverything U need & Nothing U Don't Pin
pg--az24-Apr-09 20:23
memberpg--az24-Apr-09 20:23 
GeneralTo create Tooltip for picture control in MSVS 2008(VC++) Pin
shruthikl26-Aug-08 2:03
membershruthikl26-Aug-08 2:03 
GeneralGDI OBJECT LEAK Pin
carloscorpia10-Mar-06 0:17
membercarloscorpia10-Mar-06 0:17 
GeneralDe source does not work... the sample exe does. Pin
Peter Hendrix11-May-05 3:09
memberPeter Hendrix11-May-05 3:09 
GeneralRe: De source does not work... the sample exe does. Pin
Zarembo Maxim11-May-05 18:40
memberZarembo Maxim11-May-05 18:40 
GeneralRe: De source does not work... the sample exe does. [modified] Pin
GMBarak16-Jan-07 21:10
memberGMBarak16-Jan-07 21:10 
GeneralRe: De source does not work. vs manifest Pin
pg--az24-Apr-09 20:19
memberpg--az24-Apr-09 20:19 
GeneralMAHAssistance: a Nifty program that used this article (Thanks to Author) Pin
Behzad Ebrahimi7-Nov-04 23:48
memberBehzad Ebrahimi7-Nov-04 23:48 
GeneralRe: MAHAssistance: a Nifty program that used this article (Thanks to Author) Pin
Zarembo Maxim8-Nov-04 10:31
memberZarembo Maxim8-Nov-04 10:31 
GeneralThanks very much! Pin
Chris Hills7-Jul-04 6:04
memberChris Hills7-Jul-04 6:04 
GeneralRe: Thanks very much! Pin
Zarembo Maxim29-Jul-04 2:21
memberZarembo Maxim29-Jul-04 2:21 
GeneralWrapping the text Pin
Balkrishna Talele22-Apr-04 1:49
memberBalkrishna Talele22-Apr-04 1:49 
GeneralRe: Wrapping the text Pin
Zarembo Maxim22-Apr-04 3:56
memberZarembo Maxim22-Apr-04 3:56 
GeneralUnregistering Tooltips rect Pin
Majid Shahabfar16-Dec-02 2:28
memberMajid Shahabfar16-Dec-02 2:28 
GeneralExcellent article Pin
dabs3-Sep-02 1:36
memberdabs3-Sep-02 1:36 
GeneralAdding tooltip to picture control Pin
Anonymous2-Sep-02 1:38
sussAnonymous2-Sep-02 1:38 

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.170113.4 | Last Updated 2 Sep 2002
Article Copyright 2002 by Zarembo Maxim
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid