g_toolItem is a global TOOLINFO
(HWND CreateTrackingToolTip(toolID, hDlg,pText
Create a tooltip'
hwndTT=CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,WS_POPUP Or TTS_NOPREFIX Or TTS_ALWAYSTIP, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,hDlg, NULL,
(g_hInst,NULL,
g_toolItem.cbSize = sizeof(TOOLINFO) g_toolItem.uFlags=TTF_IDISHWND Or TTF_TRACK Or TTF_ABSOLUTE g_toolItem.hwnd=hDlg
g_toolItem.hinst=g_hInst g_toolItem.lpszText=pText
g_toolItem.uId=hDlg
GetClientRect hDlg, &g_toolItem.rect) 'Associate the tooltip with the tool window.
SendMessage hwndTT,TTM_ADDTOOL,0, (LPARAM) (LPTOOLINFO) &g_toolItem
CreateTrackingToolTip=hwndTT
g_hwndTrackingTT is a global HWND variable'
case WM_INITDIALOG
()InitCommonControls
g_hwndTrackingTT=CreateTrackingToolTip(IDC_BUTTON1,
(hDlg,""
return TRUE
case WM_MOUSELEAVE
'The mouse pointer has left our window. Deactivate'
the tooltip.
SendMessage g_hwndTrackingTT, TTM_TRACKACTIVATE,(WPARAM)FALSE,
(LPARAM)&g_toolItem),
g_TrackingMouse = FALSE
return FALSE
:case WM_MOUSEMOVE
static oldX, oldY
Dim newX, newY
if (!g_TrackingMouse) Then 'The mouse has just entered the window.
Request notification when the mouse leaves.
Dim tme As TRACKMOUSEEVENT
(tme =sizeof(TRACKMOUSEEVENT
tme.hwndTrack=hDlg
tme.dwFlags=TME_LEAVE
TrackMouseEvent &tme
Activate the tooltip.'
SendMessage g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM)&g_toolItem
g_TrackingMouse = TRUE
(newX = GET_X_LPARAM(lParam
(newY = GET_Y_LPARAM(lParam
Make sure the mouse has actually moved. The '
presence of the tooltip causes Windows to send the message continuously
((if ((newX <> oldX) Or (newY<> oldY
oldX = newX
oldY = newY
Update the text.'
g_toolItem.lpszText=newX & newY
SendMessage g_hwndTrackingTT, TTM_SETTOOLINFO, 0,(LPARAM)&g_toolItem
Position the tooltip. The coordinates are adjusted so '
that the tooltip does not overlap the mouse pointer
{POINT pt = { newX, newY
ClientToScreen hDlg, &pt
SendMessage
,g_hwndTrackingTT,TTM_TRACKPOSITION,0
((LPARAM)MAKELONG(pt.x+10,pt.y-20
return FALSE
sub CreateToolTip(ByVal hwnd as HWND,ByVal txt As
(String,ByVal tthwnd as HWND
dim iccex As INITCOMMONCONTROLSEX
dim ti As TOOLINFOA
iccex.dwICC=ICC_WIN95_CLASSES
(iccex.dwSize =sizeof(INITCOMMONCONTROLSEX
InitCommonControlsEx iccex
hwndTT=CreateWindowEx(0, TOOLTIPS_CLASS,VbNullStrinh,WS_POPUP or TTS_NOPREFIX or TTS_ALWAYSTIP,CW_USEDEFAULT,
,CW_USEDEFAULT,CW_USEDEFAULT,
(CW_USEDEFAULT,tthwnd,0,0, 0
SetWindowPos hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE
(ti.cbSize = 40 'sizeof(TOOLINFOW
ti.uFlags = TTF_SUBCLASS
ti.hwnd = hwnd
ti.hinst =0
(ti.lpszText=strptr(text
GetClientRect hwnd,ti.rect
SendMessage hwndTT,TTM_ADDTOOL, 0 , ti
End sub