![]() |
Desktop Development »
Miscellaneous »
Tooltips
Intermediate
Display ToolTip in any place on the screenBy Zarembo MaximThis article shows how to display tooltips at any location on the screen |
VC6, VC7Win2K, WinXP, MFC, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

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.
uFlagsit is chosen equalTTF_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.
1 Sep 2002 - updated source code
General
News
Question
Answer
Joke
Rant
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 |