Click here to Skip to main content
6,597,576 members and growing! (20,146 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » Tooltips     Intermediate

Display ToolTip in any place on the screen

By Zarembo Maxim

This article shows how to display tooltips at any location on the screen
VC6, VC7Win2K, WinXP, MFC, Dev
Posted:10 Jun 2002
Updated:1 Sep 2002
Views:104,361
Bookmarked:39 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
43 votes for this article.
Popularity: 6.05 Rating: 3.71 out of 5
3 votes, 10.7%
1

2
2 votes, 7.1%
3
7 votes, 25.0%
4
16 votes, 57.1%
5

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:

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

SendMessage (hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) *ti);

Then we send a TTM_TRACKPOSITION message  which sets the coordinates of ToolTip

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

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

About the Author

Zarembo Maxim


Member
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.
Occupation: Web Developer
Location: Belarus Belarus

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 31 (Total in Forum: 31) (Refresh)FirstPrevNext
GeneralEverything U need & Nothing U Don't Pinmemberpg--az20:23 24 Apr '09  
GeneralTo create Tooltip for picture control in MSVS 2008(VC++) Pinmembershruthikl2:03 26 Aug '08  
GeneralGDI OBJECT LEAK Pinmembercarloscorpia0:17 10 Mar '06  
GeneralDe source does not work... the sample exe does. PinmemberPeter Hendrix3:09 11 May '05  
GeneralRe: De source does not work... the sample exe does. PinmemberZarembo Maxim18:40 11 May '05  
GeneralRe: De source does not work... the sample exe does. [modified] PinmemberGMBarak21:10 16 Jan '07  
GeneralRe: De source does not work. vs manifest Pinmemberpg--az20:19 24 Apr '09  
GeneralMAHAssistance: a Nifty program that used this article (Thanks to Author) PinmemberBehzad Ebrahimi23:48 7 Nov '04  
GeneralRe: MAHAssistance: a Nifty program that used this article (Thanks to Author) PinmemberZarembo Maxim10:31 8 Nov '04  
GeneralThanks very much! PinmemberChris Hills6:04 7 Jul '04  
GeneralRe: Thanks very much! PinmemberZarembo Maxim2:21 29 Jul '04  
GeneralWrapping the text PinmemberBalkrishna Talele1:49 22 Apr '04  
GeneralRe: Wrapping the text PinmemberZarembo Maxim3:56 22 Apr '04  
GeneralUnregistering Tooltips rect PinmemberMajid Shahabfar2:28 16 Dec '02  
GeneralExcellent article Pinmemberdabs1:36 3 Sep '02  
GeneralAdding tooltip to picture control PinsussAnonymous1:38 2 Sep '02  
GeneralRe: Adding tooltip to picture control PinmemberChopper1:27 18 Dec '02  
Generalres directory missing from source PinmemberAndreas Saurwein23:59 1 Sep '02  
GeneralRe: res directory missing from source PinsussAnonymous0:47 2 Sep '02  
GeneralC++ .NET question PinsussAnonymous4:45 12 Aug '02  
GeneralRe: C++ .NET question PinsussAnonymous22:19 12 Aug '02  
GeneralRe: C++ .NET question PinsussAnonymous1:05 2 Sep '02  
GeneralRe: C++ .NET question PinmemberRedwings7:42 18 Sep '02  
GeneralRe: C++ .NET question PinsussAnonymous18:01 16 Oct '02  
GeneralRe: C++ .NET question PinmemberJaseNet0:51 3 Dec '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 1 Sep 2002
Editor: Chris Maunder
Copyright 2002 by Zarembo Maxim
Everything else Copyright © CodeProject, 1999-2009
Web16 | Advertise on the Code Project