Title: Display ToolTip in any place of the screen
Author: Zarembo Maxim
Environment: VC++ 6.0, NT 4.0, Win9x, Win2k
Section Miscellaneous Controls
SubSection Tooltips
Display ToolTip in any place of the screen.
It is originally necessary to create a window of class TOOLTIPS_CLASS , then to fill structure TOOLINFO:
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 have for us interest uFlags and lpszText .
uFlags it is chosen equal TTF_TRACK , that means an opportunity of use of a sending messages choosing a position for ToolTip and 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 message TTM_TRACKPOSITION which sets 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 in last turn we send the message on activization ToolTip SendMessage(hwndTT, TTM_TRACKACTIVATE, true, (LPARAM)(LPTOOLINFO)*ti); where true parameter indicating on display ToolTip, at a choice false , the ToolTip will be hiden.
|