Made HEAP_strdup* functions inline (temporary).
[wine/multimedia.git] / dlls / comctl32 / tooltips.c
blob5cd9f25c4074030bafea07aa47a3b84c2034234f
1 /*
2 * Tool tip control
4 * Copyright 1998, 1999 Eric Kohl
6 * TODO:
7 * - Unicode support (started).
8 * - Custom draw support.
10 * Testing:
11 * - Run tests using Waite Group Windows95 API Bible Volume 2.
12 * The second cdrom (chapter 3) contains executables activate.exe,
13 * curtool.exe, deltool.exe, enumtools.exe, getinfo.exe, getiptxt.exe,
14 * hittest.exe, needtext.exe, newrect.exe, updtext.exe and winfrpt.exe.
16 * Timer logic.
18 * One important point to remember is that tools don't necessarily get
19 * a WM_MOUSEMOVE once the cursor leaves the tool, an example is when
20 * a tool sets TTF_IDISHWND (i.e. an entire window is a tool) because
21 * here WM_MOUSEMOVEs only get sent when the cursor is inside the
22 * client area. Therefore the only reliable way to know that the
23 * cursor has left a tool is to keep a timer running and check the
24 * position every time it expires. This is the role of timer
25 * ID_TIMERLEAVE.
28 * On entering a tool (detected in a relayed WM_MOUSEMOVE) we start
29 * ID_TIMERSHOW, if this times out and we're still in the tool we show
30 * the tip. On showing a tip we start both ID_TIMERPOP and
31 * ID_TIMERLEAVE. On hiding a tooltip we kill ID_TIMERPOP.
32 * ID_TIMERPOP is restarted on every relayed WM_MOUSEMOVE. If
33 * ID_TIMERPOP expires the tool is hidden and ID_TIMERPOP is killed.
34 * ID_TIMERLEAVE remains running - this is important as we need to
35 * determine when the cursor leaves the tool.
37 * When ID_TIMERLEAVE expires or on a relayed WM_MOUSEMOVE if we're
38 * still in the tool do nothing (apart from restart ID_TIMERPOP if
39 * this is a WM_MOUSEMOVE) (ID_TIMERLEAVE remains running). If we've
40 * left the tool and entered another one then hide the tip and start
41 * ID_TIMERSHOW with time ReshowTime and kill ID_TIMERLEAVE. If we're
42 * outside all tools hide the tip and kill ID_TIMERLEAVE. On Relayed
43 * mouse button messages hide the tip but leave ID_TIMERLEAVE running,
44 * this again will let us keep track of when the cursor leaves the
45 * tool.
48 * infoPtr->nTool is the tool the mouse was on on the last relayed MM
49 * or timer expiry or -1 if the mouse was not on a tool.
51 * infoPtr->nCurrentTool is the tool for which the tip is currently
52 * displaying text for or -1 if the tip is not shown. Actually this
53 * will only ever be infoPtr-nTool or -1, so it could be changed to a
54 * BOOL.
60 #include <string.h>
62 #include "winbase.h"
63 #include "wine/unicode.h"
64 #include "commctrl.h"
65 #include "debugtools.h"
67 DEFAULT_DEBUG_CHANNEL(tooltips);
69 typedef struct
71 WNDPROC wpOrigProc;
72 HWND hwndToolTip;
73 UINT uRefCount;
74 } TT_SUBCLASS_INFO, *LPTT_SUBCLASS_INFO;
77 typedef struct
79 UINT uFlags;
80 HWND hwnd;
81 UINT uId;
82 RECT rect;
83 HINSTANCE hinst;
84 LPWSTR lpszText;
85 LPARAM lParam;
86 } TTTOOL_INFO;
89 typedef struct
91 WCHAR szTipText[INFOTIPSIZE];
92 BOOL bActive;
93 BOOL bTrackActive;
94 UINT uNumTools;
95 COLORREF clrBk;
96 COLORREF clrText;
97 HFONT hFont;
98 INT xTrackPos;
99 INT yTrackPos;
100 INT nMaxTipWidth;
101 INT nTool;
102 INT nCurrentTool;
103 INT nTrackTool;
104 INT nReshowTime;
105 INT nAutoPopTime;
106 INT nInitialTime;
107 RECT rcMargin;
108 BOOL bNotifyUnicode;
110 TTTOOL_INFO *tools;
111 } TOOLTIPS_INFO;
113 #define ID_TIMERSHOW 1 /* show delay timer */
114 #define ID_TIMERPOP 2 /* auto pop timer */
115 #define ID_TIMERLEAVE 3 /* tool leave timer */
118 extern LPSTR COMCTL32_aSubclass; /* global subclassing atom */
120 /* property name of tooltip window handle */
121 /*#define TT_SUBCLASS_PROP "CC32SubclassInfo" */
123 #define TOOLTIPS_GetInfoPtr(hWindow) ((TOOLTIPS_INFO *)GetWindowLongA (hWindow, 0))
126 LRESULT CALLBACK
127 TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
130 static VOID
131 TOOLTIPS_Refresh (HWND hwnd, HDC hdc)
133 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
134 RECT rc;
135 INT oldBkMode;
136 HFONT hOldFont;
137 HBRUSH hBrush;
138 UINT uFlags = DT_EXTERNALLEADING;
140 if (infoPtr->nMaxTipWidth > -1)
141 uFlags |= DT_WORDBREAK;
142 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
143 uFlags |= DT_NOPREFIX;
144 GetClientRect (hwnd, &rc);
146 /* fill the background */
147 hBrush = CreateSolidBrush (infoPtr->clrBk);
148 FillRect (hdc, &rc, hBrush);
149 DeleteObject (hBrush);
151 /* calculate text rectangle */
152 rc.left += (2 + infoPtr->rcMargin.left);
153 rc.top += (2 + infoPtr->rcMargin.top);
154 rc.right -= (2 + infoPtr->rcMargin.right);
155 rc.bottom -= (2 + infoPtr->rcMargin.bottom);
157 /* draw text */
158 oldBkMode = SetBkMode (hdc, TRANSPARENT);
159 SetTextColor (hdc, infoPtr->clrText);
160 hOldFont = SelectObject (hdc, infoPtr->hFont);
161 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
162 SelectObject (hdc, hOldFont);
163 if (oldBkMode != TRANSPARENT)
164 SetBkMode (hdc, oldBkMode);
168 static VOID
169 TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool)
171 TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
173 if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) {
174 /* load a resource */
175 TRACE("load res string %x %x\n",
176 toolPtr->hinst, (int)toolPtr->lpszText);
177 LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText,
178 infoPtr->szTipText, INFOTIPSIZE);
180 else if (toolPtr->lpszText) {
181 if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
182 NMTTDISPINFOA ttnmdi;
184 /* fill NMHDR struct */
185 ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
186 ttnmdi.hdr.hwndFrom = hwnd;
187 ttnmdi.hdr.idFrom = toolPtr->uId;
188 ttnmdi.hdr.code = TTN_GETDISPINFOA;
189 ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
190 ttnmdi.uFlags = toolPtr->uFlags;
191 ttnmdi.lParam = toolPtr->lParam;
193 TRACE("hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
194 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
195 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
197 if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.lpszText) == 0)) {
198 LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.lpszText,
199 infoPtr->szTipText, INFOTIPSIZE);
200 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
201 toolPtr->hinst = ttnmdi.hinst;
202 toolPtr->lpszText = (LPWSTR)ttnmdi.lpszText;
205 else if (ttnmdi.szText[0]) {
206 MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText, 80,
207 infoPtr->szTipText, INFOTIPSIZE);
208 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
209 INT len = MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText,
210 80, NULL, 0);
211 toolPtr->hinst = 0;
212 toolPtr->lpszText = COMCTL32_Alloc (len * sizeof(WCHAR));
213 MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText, 80,
214 toolPtr->lpszText, len);
217 else if (ttnmdi.lpszText == 0) {
218 /* no text available */
219 infoPtr->szTipText[0] = L'\0';
221 else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
222 MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1,
223 infoPtr->szTipText, INFOTIPSIZE);
224 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
225 INT len = MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText,
226 -1, NULL, 0);
227 toolPtr->hinst = 0;
228 toolPtr->lpszText = COMCTL32_Alloc (len * sizeof(WCHAR));
229 MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1,
230 toolPtr->lpszText, len);
233 else {
234 ERR("recursive text callback!\n");
235 infoPtr->szTipText[0] = '\0';
238 else {
239 /* the item is a usual (unicode) text */
240 lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
243 else {
244 /* no text available */
245 infoPtr->szTipText[0] = L'\0';
248 TRACE("%s\n", debugstr_w(infoPtr->szTipText));
252 static VOID
253 TOOLTIPS_CalcTipSize (HWND hwnd, TOOLTIPS_INFO *infoPtr, LPSIZE lpSize)
255 HDC hdc;
256 HFONT hOldFont;
257 UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT;
258 RECT rc = {0, 0, 0, 0};
260 if (infoPtr->nMaxTipWidth > -1) {
261 rc.right = infoPtr->nMaxTipWidth;
262 uFlags |= DT_WORDBREAK;
264 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
265 uFlags |= DT_NOPREFIX;
266 TRACE("%s\n", debugstr_w(infoPtr->szTipText));
268 hdc = GetDC (hwnd);
269 hOldFont = SelectObject (hdc, infoPtr->hFont);
270 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
271 SelectObject (hdc, hOldFont);
272 ReleaseDC (hwnd, hdc);
274 lpSize->cx = rc.right - rc.left + 4 +
275 infoPtr->rcMargin.left + infoPtr->rcMargin.right;
276 lpSize->cy = rc.bottom - rc.top + 4 +
277 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
281 static VOID
282 TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr)
284 TTTOOL_INFO *toolPtr;
285 RECT rect, wndrect;
286 SIZE size;
287 NMHDR hdr;
289 if (infoPtr->nTool == -1) {
290 TRACE("invalid tool (-1)!\n");
291 return;
294 infoPtr->nCurrentTool = infoPtr->nTool;
296 TRACE("Show tooltip pre %d! (%04x)\n", infoPtr->nTool, hwnd);
298 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool);
300 if (infoPtr->szTipText[0] == L'\0') {
301 infoPtr->nCurrentTool = -1;
302 return;
305 TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool);
306 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
308 hdr.hwndFrom = hwnd;
309 hdr.idFrom = toolPtr->uId;
310 hdr.code = TTN_SHOW;
311 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
312 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
314 TRACE("%s\n", debugstr_w(infoPtr->szTipText));
316 TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
317 TRACE("size %ld x %ld\n", size.cx, size.cy);
319 if (toolPtr->uFlags & TTF_CENTERTIP) {
320 RECT rc;
322 if (toolPtr->uFlags & TTF_IDISHWND)
323 GetWindowRect ((HWND)toolPtr->uId, &rc);
324 else {
325 rc = toolPtr->rect;
326 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
328 rect.left = (rc.left + rc.right - size.cx) / 2;
329 rect.top = rc.bottom + 2;
331 else {
332 GetCursorPos ((LPPOINT)&rect);
333 rect.top += 20;
336 TRACE("pos %d - %d\n", rect.left, rect.top);
338 rect.right = rect.left + size.cx;
339 rect.bottom = rect.top + size.cy;
341 /* check position */
342 wndrect.right = GetSystemMetrics( SM_CXSCREEN );
343 if( rect.right > wndrect.right ) {
344 rect.left -= rect.right - wndrect.right + 2;
345 rect.right = wndrect.right - 2;
347 wndrect.bottom = GetSystemMetrics( SM_CYSCREEN );
348 if( rect.bottom > wndrect.bottom ) {
349 RECT rc;
351 if (toolPtr->uFlags & TTF_IDISHWND)
352 GetWindowRect ((HWND)toolPtr->uId, &rc);
353 else {
354 rc = toolPtr->rect;
355 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
357 rect.bottom = rc.top - 2;
358 rect.top = rect.bottom - size.cy;
361 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
362 FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
364 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
365 rect.right - rect.left, rect.bottom - rect.top,
366 SWP_SHOWWINDOW | SWP_NOACTIVATE);
368 /* repaint the tooltip */
369 InvalidateRect(hwnd, NULL, TRUE);
370 UpdateWindow(hwnd);
372 SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
373 TRACE("timer 2 started!\n");
374 SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0);
375 TRACE("timer 3 started!\n");
379 static VOID
380 TOOLTIPS_Hide (HWND hwnd, TOOLTIPS_INFO *infoPtr)
382 TTTOOL_INFO *toolPtr;
383 NMHDR hdr;
385 TRACE("Hide tooltip %d! (%04x)\n", infoPtr->nCurrentTool, hwnd);
387 if (infoPtr->nCurrentTool == -1)
388 return;
390 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
391 KillTimer (hwnd, ID_TIMERPOP);
393 hdr.hwndFrom = hwnd;
394 hdr.idFrom = toolPtr->uId;
395 hdr.code = TTN_POP;
396 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
397 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
399 infoPtr->nCurrentTool = -1;
401 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
402 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
406 static VOID
407 TOOLTIPS_TrackShow (HWND hwnd, TOOLTIPS_INFO *infoPtr)
409 TTTOOL_INFO *toolPtr;
410 RECT rect;
411 SIZE size;
412 NMHDR hdr;
414 if (infoPtr->nTrackTool == -1) {
415 TRACE("invalid tracking tool (-1)!\n");
416 return;
419 TRACE("show tracking tooltip pre %d!\n", infoPtr->nTrackTool);
421 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nTrackTool);
423 if (infoPtr->szTipText[0] == L'\0') {
424 infoPtr->nTrackTool = -1;
425 return;
428 TRACE("show tracking tooltip %d!\n", infoPtr->nTrackTool);
429 toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
431 hdr.hwndFrom = hwnd;
432 hdr.idFrom = toolPtr->uId;
433 hdr.code = TTN_SHOW;
434 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
435 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
437 TRACE("%s\n", debugstr_w(infoPtr->szTipText));
439 TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
440 TRACE("size %ld x %ld\n", size.cx, size.cy);
442 if (toolPtr->uFlags & TTF_ABSOLUTE) {
443 rect.left = infoPtr->xTrackPos;
444 rect.top = infoPtr->yTrackPos;
446 if (toolPtr->uFlags & TTF_CENTERTIP) {
447 rect.left -= (size.cx / 2);
448 rect.top -= (size.cy / 2);
451 else {
452 RECT rcTool;
454 if (toolPtr->uFlags & TTF_IDISHWND)
455 GetWindowRect ((HWND)toolPtr->uId, &rcTool);
456 else {
457 rcTool = toolPtr->rect;
458 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rcTool, 2);
461 GetCursorPos ((LPPOINT)&rect);
462 rect.top += 20;
464 if (toolPtr->uFlags & TTF_CENTERTIP) {
465 rect.left -= (size.cx / 2);
466 rect.top -= (size.cy / 2);
469 /* smart placement */
470 if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
471 (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
472 rect.left = rcTool.right;
475 TRACE("pos %d - %d\n", rect.left, rect.top);
477 rect.right = rect.left + size.cx;
478 rect.bottom = rect.top + size.cy;
480 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
481 FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
483 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
484 rect.right - rect.left, rect.bottom - rect.top,
485 SWP_SHOWWINDOW | SWP_NOACTIVATE );
487 InvalidateRect(hwnd, NULL, TRUE);
488 UpdateWindow(hwnd);
492 static VOID
493 TOOLTIPS_TrackHide (HWND hwnd, TOOLTIPS_INFO *infoPtr)
495 TTTOOL_INFO *toolPtr;
496 NMHDR hdr;
498 if (infoPtr->nTrackTool == -1)
499 return;
501 toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
502 TRACE("hide tracking tooltip %d!\n", infoPtr->nTrackTool);
504 hdr.hwndFrom = hwnd;
505 hdr.idFrom = toolPtr->uId;
506 hdr.code = TTN_POP;
507 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
508 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
510 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
511 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
515 static INT
516 TOOLTIPS_GetToolFromInfoA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo)
518 TTTOOL_INFO *toolPtr;
519 INT nTool;
521 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
522 toolPtr = &infoPtr->tools[nTool];
524 if (!(toolPtr->uFlags & TTF_IDISHWND) &&
525 (lpToolInfo->hwnd == toolPtr->hwnd) &&
526 (lpToolInfo->uId == toolPtr->uId))
527 return nTool;
530 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
531 toolPtr = &infoPtr->tools[nTool];
533 if ((toolPtr->uFlags & TTF_IDISHWND) &&
534 (lpToolInfo->uId == toolPtr->uId))
535 return nTool;
538 return -1;
542 static INT
543 TOOLTIPS_GetToolFromInfoW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo)
545 TTTOOL_INFO *toolPtr;
546 INT nTool;
548 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
549 toolPtr = &infoPtr->tools[nTool];
551 if (!(toolPtr->uFlags & TTF_IDISHWND) &&
552 (lpToolInfo->hwnd == toolPtr->hwnd) &&
553 (lpToolInfo->uId == toolPtr->uId))
554 return nTool;
557 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
558 toolPtr = &infoPtr->tools[nTool];
560 if ((toolPtr->uFlags & TTF_IDISHWND) &&
561 (lpToolInfo->uId == toolPtr->uId))
562 return nTool;
565 return -1;
569 static INT
570 TOOLTIPS_GetToolFromPoint (TOOLTIPS_INFO *infoPtr, HWND hwnd, LPPOINT lpPt)
572 TTTOOL_INFO *toolPtr;
573 INT nTool;
575 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
576 toolPtr = &infoPtr->tools[nTool];
578 if (!(toolPtr->uFlags & TTF_IDISHWND)) {
579 if (hwnd != toolPtr->hwnd)
580 continue;
581 if (!PtInRect (&toolPtr->rect, *lpPt))
582 continue;
583 return nTool;
587 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
588 toolPtr = &infoPtr->tools[nTool];
590 if (toolPtr->uFlags & TTF_IDISHWND) {
591 if ((HWND)toolPtr->uId == hwnd)
592 return nTool;
596 return -1;
600 static BOOL
601 TOOLTIPS_IsWindowActive (HWND hwnd)
603 HWND hwndActive = GetActiveWindow ();
604 if (!hwndActive)
605 return FALSE;
606 if (hwndActive == hwnd)
607 return TRUE;
608 return IsChild (hwndActive, hwnd);
612 static INT
613 TOOLTIPS_CheckTool (HWND hwnd, BOOL bShowTest)
615 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
616 POINT pt;
617 HWND hwndTool;
618 INT nTool;
620 GetCursorPos (&pt);
621 hwndTool = SendMessageA (hwnd, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt);
622 if (hwndTool == 0)
623 return -1;
625 ScreenToClient (hwndTool, &pt);
626 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
627 if (nTool == -1)
628 return -1;
630 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) {
631 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER)))
632 return -1;
635 TRACE("tool %d\n", nTool);
637 return nTool;
641 static LRESULT
642 TOOLTIPS_Activate (HWND hwnd, WPARAM wParam, LPARAM lParam)
644 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
646 infoPtr->bActive = (BOOL)wParam;
648 if (infoPtr->bActive)
649 TRACE("activate!\n");
651 if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1))
652 TOOLTIPS_Hide (hwnd, infoPtr);
654 return 0;
658 static LRESULT
659 TOOLTIPS_AddToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
661 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
662 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
663 TTTOOL_INFO *toolPtr;
665 if (lpToolInfo == NULL)
666 return FALSE;
667 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
668 return FALSE;
670 TRACE("add tool (%x) %x %d%s!\n",
671 hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
672 (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
674 if (infoPtr->uNumTools == 0) {
675 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
676 toolPtr = infoPtr->tools;
678 else {
679 TTTOOL_INFO *oldTools = infoPtr->tools;
680 infoPtr->tools =
681 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
682 memcpy (infoPtr->tools, oldTools,
683 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
684 COMCTL32_Free (oldTools);
685 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
688 infoPtr->uNumTools++;
690 /* copy tool data */
691 toolPtr->uFlags = lpToolInfo->uFlags;
692 toolPtr->hwnd = lpToolInfo->hwnd;
693 toolPtr->uId = lpToolInfo->uId;
694 toolPtr->rect = lpToolInfo->rect;
695 toolPtr->hinst = lpToolInfo->hinst;
697 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
698 TRACE("add string id %x!\n", (int)lpToolInfo->lpszText);
699 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
701 else if (lpToolInfo->lpszText) {
702 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) {
703 TRACE("add CALLBACK!\n");
704 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
706 else {
707 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
708 NULL, 0);
709 TRACE("add text \"%s\"!\n", lpToolInfo->lpszText);
710 toolPtr->lpszText = COMCTL32_Alloc (len * sizeof(WCHAR));
711 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
712 toolPtr->lpszText, len);
716 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
717 toolPtr->lParam = lpToolInfo->lParam;
719 /* install subclassing hook */
720 if (toolPtr->uFlags & TTF_SUBCLASS) {
721 if (toolPtr->uFlags & TTF_IDISHWND) {
722 LPTT_SUBCLASS_INFO lpttsi =
723 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
724 if (lpttsi == NULL) {
725 lpttsi =
726 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
727 lpttsi->wpOrigProc =
728 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
729 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
730 lpttsi->hwndToolTip = hwnd;
731 lpttsi->uRefCount++;
732 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
733 (HANDLE)lpttsi);
735 else
736 WARN("A window tool must only be listed once!\n");
738 else {
739 LPTT_SUBCLASS_INFO lpttsi =
740 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
741 if (lpttsi == NULL) {
742 lpttsi =
743 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
744 lpttsi->wpOrigProc =
745 (WNDPROC)SetWindowLongA (toolPtr->hwnd,
746 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
747 lpttsi->hwndToolTip = hwnd;
748 lpttsi->uRefCount++;
749 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
751 else
752 lpttsi->uRefCount++;
754 TRACE("subclassing installed!\n");
757 return TRUE;
761 static LRESULT
762 TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
764 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
765 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
766 TTTOOL_INFO *toolPtr;
768 if (lpToolInfo == NULL)
769 return FALSE;
770 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
771 return FALSE;
773 TRACE("add tool (%x) %x %d%s!\n",
774 hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
775 (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
777 if (infoPtr->uNumTools == 0) {
778 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
779 toolPtr = infoPtr->tools;
781 else {
782 TTTOOL_INFO *oldTools = infoPtr->tools;
783 infoPtr->tools =
784 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
785 memcpy (infoPtr->tools, oldTools,
786 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
787 COMCTL32_Free (oldTools);
788 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
791 infoPtr->uNumTools++;
793 /* copy tool data */
794 toolPtr->uFlags = lpToolInfo->uFlags;
795 toolPtr->hwnd = lpToolInfo->hwnd;
796 toolPtr->uId = lpToolInfo->uId;
797 toolPtr->rect = lpToolInfo->rect;
798 toolPtr->hinst = lpToolInfo->hinst;
800 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
801 TRACE("add string id %x!\n", (int)lpToolInfo->lpszText);
802 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
804 else if (lpToolInfo->lpszText) {
805 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
806 TRACE("add CALLBACK!\n");
807 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
809 else {
810 INT len = lstrlenW (lpToolInfo->lpszText);
811 TRACE("add text %s!\n",
812 debugstr_w(lpToolInfo->lpszText));
813 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
814 strcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
818 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
819 toolPtr->lParam = lpToolInfo->lParam;
821 /* install subclassing hook */
822 if (toolPtr->uFlags & TTF_SUBCLASS) {
823 if (toolPtr->uFlags & TTF_IDISHWND) {
824 LPTT_SUBCLASS_INFO lpttsi =
825 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
826 if (lpttsi == NULL) {
827 lpttsi =
828 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
829 lpttsi->wpOrigProc =
830 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
831 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
832 lpttsi->hwndToolTip = hwnd;
833 lpttsi->uRefCount++;
834 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
835 (HANDLE)lpttsi);
837 else
838 WARN("A window tool must only be listed once!\n");
840 else {
841 LPTT_SUBCLASS_INFO lpttsi =
842 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
843 if (lpttsi == NULL) {
844 lpttsi =
845 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
846 lpttsi->wpOrigProc =
847 (WNDPROC)SetWindowLongA (toolPtr->hwnd,
848 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
849 lpttsi->hwndToolTip = hwnd;
850 lpttsi->uRefCount++;
851 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
853 else
854 lpttsi->uRefCount++;
856 TRACE("subclassing installed!\n");
859 return TRUE;
863 static LRESULT
864 TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
866 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
867 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
868 TTTOOL_INFO *toolPtr;
869 INT nTool;
871 if (lpToolInfo == NULL)
872 return 0;
873 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
874 return 0;
875 if (infoPtr->uNumTools == 0)
876 return 0;
878 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
879 if (nTool == -1) return 0;
881 TRACE("tool %d\n", nTool);
883 /* make sure the tooltip has disappeared before deleting it */
884 TOOLTIPS_Hide(hwnd, infoPtr);
886 /* delete text string */
887 toolPtr = &infoPtr->tools[nTool];
888 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
889 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
890 (HIWORD((INT)toolPtr->lpszText) != 0) )
891 COMCTL32_Free (toolPtr->lpszText);
894 /* remove subclassing */
895 if (toolPtr->uFlags & TTF_SUBCLASS) {
896 if (toolPtr->uFlags & TTF_IDISHWND) {
897 LPTT_SUBCLASS_INFO lpttsi =
898 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
899 if (lpttsi) {
900 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
901 (LONG)lpttsi->wpOrigProc);
902 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
903 COMCTL32_Free (&lpttsi);
905 else
906 ERR("Invalid data handle!\n");
908 else {
909 LPTT_SUBCLASS_INFO lpttsi =
910 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
911 if (lpttsi) {
912 if (lpttsi->uRefCount == 1) {
913 SetWindowLongA ((HWND)toolPtr->hwnd, GWL_WNDPROC,
914 (LONG)lpttsi->wpOrigProc);
915 RemovePropA ((HWND)toolPtr->hwnd, COMCTL32_aSubclass);
916 COMCTL32_Free (&lpttsi);
918 else
919 lpttsi->uRefCount--;
921 else
922 ERR("Invalid data handle!\n");
926 /* delete tool from tool list */
927 if (infoPtr->uNumTools == 1) {
928 COMCTL32_Free (infoPtr->tools);
929 infoPtr->tools = NULL;
931 else {
932 TTTOOL_INFO *oldTools = infoPtr->tools;
933 infoPtr->tools =
934 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
936 if (nTool > 0)
937 memcpy (&infoPtr->tools[0], &oldTools[0],
938 nTool * sizeof(TTTOOL_INFO));
940 if (nTool < infoPtr->uNumTools - 1)
941 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
942 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
944 COMCTL32_Free (oldTools);
947 /* destroying tool that mouse was on on last relayed mouse move */
948 if (infoPtr->nTool == nTool)
950 /* no current tool (0 means first tool) */
951 infoPtr->nTool = -1;
954 infoPtr->uNumTools--;
956 return 0;
960 static LRESULT
961 TOOLTIPS_DelToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
963 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
964 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
965 TTTOOL_INFO *toolPtr;
966 INT nTool;
968 if (lpToolInfo == NULL)
969 return 0;
970 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
971 return 0;
972 if (infoPtr->uNumTools == 0)
973 return 0;
975 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
976 if (nTool == -1) return 0;
978 TRACE("tool %d\n", nTool);
980 /* make sure the tooltip has disappeared before deleting it */
981 TOOLTIPS_Hide(hwnd, infoPtr);
983 /* delete text string */
984 toolPtr = &infoPtr->tools[nTool];
985 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
986 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
987 (HIWORD((INT)toolPtr->lpszText) != 0) )
988 COMCTL32_Free (toolPtr->lpszText);
991 /* remove subclassing */
992 if (toolPtr->uFlags & TTF_SUBCLASS) {
993 if (toolPtr->uFlags & TTF_IDISHWND) {
994 LPTT_SUBCLASS_INFO lpttsi =
995 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
996 if (lpttsi) {
997 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
998 (LONG)lpttsi->wpOrigProc);
999 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
1000 COMCTL32_Free (&lpttsi);
1002 else
1003 ERR("Invalid data handle!\n");
1005 else {
1006 LPTT_SUBCLASS_INFO lpttsi =
1007 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
1008 if (lpttsi) {
1009 if (lpttsi->uRefCount == 1) {
1010 SetWindowLongA ((HWND)toolPtr->hwnd, GWL_WNDPROC,
1011 (LONG)lpttsi->wpOrigProc);
1012 RemovePropA ((HWND)toolPtr->hwnd, COMCTL32_aSubclass);
1013 COMCTL32_Free (&lpttsi);
1015 else
1016 lpttsi->uRefCount--;
1018 else
1019 ERR("Invalid data handle!\n");
1023 /* delete tool from tool list */
1024 if (infoPtr->uNumTools == 1) {
1025 COMCTL32_Free (infoPtr->tools);
1026 infoPtr->tools = NULL;
1028 else {
1029 TTTOOL_INFO *oldTools = infoPtr->tools;
1030 infoPtr->tools =
1031 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
1033 if (nTool > 0)
1034 memcpy (&infoPtr->tools[0], &oldTools[0],
1035 nTool * sizeof(TTTOOL_INFO));
1037 if (nTool < infoPtr->uNumTools - 1)
1038 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
1039 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
1041 COMCTL32_Free (oldTools);
1044 /* destroying tool that mouse was on on last relayed mouse move */
1045 if (infoPtr->nTool == nTool)
1047 /* no current tool (0 means first tool) */
1048 infoPtr->nTool = -1;
1051 infoPtr->uNumTools--;
1053 return 0;
1057 static LRESULT
1058 TOOLTIPS_EnumToolsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1060 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1061 UINT uIndex = (UINT)wParam;
1062 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1063 TTTOOL_INFO *toolPtr;
1065 if (lpToolInfo == NULL)
1066 return FALSE;
1067 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1068 return FALSE;
1069 if (uIndex >= infoPtr->uNumTools)
1070 return FALSE;
1072 TRACE("index=%u\n", uIndex);
1074 toolPtr = &infoPtr->tools[uIndex];
1076 /* copy tool data */
1077 lpToolInfo->uFlags = toolPtr->uFlags;
1078 lpToolInfo->hwnd = toolPtr->hwnd;
1079 lpToolInfo->uId = toolPtr->uId;
1080 lpToolInfo->rect = toolPtr->rect;
1081 lpToolInfo->hinst = toolPtr->hinst;
1082 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1083 lpToolInfo->lpszText = NULL; /* FIXME */
1085 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1086 lpToolInfo->lParam = toolPtr->lParam;
1088 return TRUE;
1092 static LRESULT
1093 TOOLTIPS_EnumToolsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1095 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1096 UINT uIndex = (UINT)wParam;
1097 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1098 TTTOOL_INFO *toolPtr;
1100 if (lpToolInfo == NULL)
1101 return FALSE;
1102 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1103 return FALSE;
1104 if (uIndex >= infoPtr->uNumTools)
1105 return FALSE;
1107 TRACE("index=%u\n", uIndex);
1109 toolPtr = &infoPtr->tools[uIndex];
1111 /* copy tool data */
1112 lpToolInfo->uFlags = toolPtr->uFlags;
1113 lpToolInfo->hwnd = toolPtr->hwnd;
1114 lpToolInfo->uId = toolPtr->uId;
1115 lpToolInfo->rect = toolPtr->rect;
1116 lpToolInfo->hinst = toolPtr->hinst;
1117 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1118 lpToolInfo->lpszText = NULL; /* FIXME */
1120 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1121 lpToolInfo->lParam = toolPtr->lParam;
1123 return TRUE;
1127 static LRESULT
1128 TOOLTIPS_GetCurrentToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1130 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1131 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1132 TTTOOL_INFO *toolPtr;
1134 if (lpToolInfo == NULL)
1135 return FALSE;
1136 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1137 return FALSE;
1139 if (lpToolInfo) {
1140 if (infoPtr->nCurrentTool > -1) {
1141 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1143 /* copy tool data */
1144 lpToolInfo->uFlags = toolPtr->uFlags;
1145 lpToolInfo->rect = toolPtr->rect;
1146 lpToolInfo->hinst = toolPtr->hinst;
1147 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1148 lpToolInfo->lpszText = NULL; /* FIXME */
1150 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1151 lpToolInfo->lParam = toolPtr->lParam;
1153 return TRUE;
1155 else
1156 return FALSE;
1158 else
1159 return (infoPtr->nCurrentTool != -1);
1161 return FALSE;
1165 static LRESULT
1166 TOOLTIPS_GetCurrentToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1168 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1169 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1170 TTTOOL_INFO *toolPtr;
1172 if (lpToolInfo == NULL)
1173 return FALSE;
1174 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1175 return FALSE;
1177 if (lpToolInfo) {
1178 if (infoPtr->nCurrentTool > -1) {
1179 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1181 /* copy tool data */
1182 lpToolInfo->uFlags = toolPtr->uFlags;
1183 lpToolInfo->rect = toolPtr->rect;
1184 lpToolInfo->hinst = toolPtr->hinst;
1185 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1186 lpToolInfo->lpszText = NULL; /* FIXME */
1188 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1189 lpToolInfo->lParam = toolPtr->lParam;
1191 return TRUE;
1193 else
1194 return FALSE;
1196 else
1197 return (infoPtr->nCurrentTool != -1);
1199 return FALSE;
1203 static LRESULT
1204 TOOLTIPS_GetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
1206 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1208 switch (wParam) {
1209 case TTDT_RESHOW:
1210 return infoPtr->nReshowTime;
1212 case TTDT_AUTOPOP:
1213 return infoPtr->nAutoPopTime;
1215 case TTDT_INITIAL:
1216 case TTDT_AUTOMATIC: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */
1217 return infoPtr->nInitialTime;
1219 default:
1220 WARN("Invalid wParam %x\n", wParam);
1221 break;
1224 return -1;
1228 static LRESULT
1229 TOOLTIPS_GetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1231 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1232 LPRECT lpRect = (LPRECT)lParam;
1234 lpRect->left = infoPtr->rcMargin.left;
1235 lpRect->right = infoPtr->rcMargin.right;
1236 lpRect->bottom = infoPtr->rcMargin.bottom;
1237 lpRect->top = infoPtr->rcMargin.top;
1239 return 0;
1243 inline static LRESULT
1244 TOOLTIPS_GetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1246 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1248 return infoPtr->nMaxTipWidth;
1252 static LRESULT
1253 TOOLTIPS_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1255 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1256 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1257 INT nTool;
1259 if (lpToolInfo == NULL)
1260 return 0;
1261 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1262 return 0;
1264 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1265 if (nTool == -1) return 0;
1267 /* NB this API is broken, there is no way for the app to determine
1268 what size buffer it requires nor a way to specify how long the
1269 one it supplies is. We'll assume it's upto INFOTIPSIZE */
1271 WideCharToMultiByte(CP_ACP, 0, infoPtr->tools[nTool].lpszText, -1,
1272 lpToolInfo->lpszText, INFOTIPSIZE, NULL, NULL);
1274 return 0;
1278 static LRESULT
1279 TOOLTIPS_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1281 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1282 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1283 INT nTool;
1285 if (lpToolInfo == NULL)
1286 return 0;
1287 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1288 return 0;
1290 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1291 if (nTool == -1) return 0;
1293 strcpyW (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
1295 return 0;
1299 inline static LRESULT
1300 TOOLTIPS_GetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1302 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1303 return infoPtr->clrBk;
1307 inline static LRESULT
1308 TOOLTIPS_GetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1310 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1311 return infoPtr->clrText;
1315 inline static LRESULT
1316 TOOLTIPS_GetToolCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1318 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1319 return infoPtr->uNumTools;
1323 static LRESULT
1324 TOOLTIPS_GetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1326 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1327 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1328 TTTOOL_INFO *toolPtr;
1329 INT nTool;
1331 if (lpToolInfo == NULL)
1332 return FALSE;
1333 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1334 return FALSE;
1335 if (infoPtr->uNumTools == 0)
1336 return FALSE;
1338 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1339 if (nTool == -1)
1340 return FALSE;
1342 TRACE("tool %d\n", nTool);
1344 toolPtr = &infoPtr->tools[nTool];
1346 /* copy tool data */
1347 lpToolInfo->uFlags = toolPtr->uFlags;
1348 lpToolInfo->rect = toolPtr->rect;
1349 lpToolInfo->hinst = toolPtr->hinst;
1350 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1351 lpToolInfo->lpszText = NULL; /* FIXME */
1353 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1354 lpToolInfo->lParam = toolPtr->lParam;
1356 return TRUE;
1360 static LRESULT
1361 TOOLTIPS_GetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1363 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1364 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1365 TTTOOL_INFO *toolPtr;
1366 INT nTool;
1368 if (lpToolInfo == NULL)
1369 return FALSE;
1370 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1371 return FALSE;
1372 if (infoPtr->uNumTools == 0)
1373 return FALSE;
1375 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1376 if (nTool == -1)
1377 return FALSE;
1379 TRACE("tool %d\n", nTool);
1381 toolPtr = &infoPtr->tools[nTool];
1383 /* copy tool data */
1384 lpToolInfo->uFlags = toolPtr->uFlags;
1385 lpToolInfo->rect = toolPtr->rect;
1386 lpToolInfo->hinst = toolPtr->hinst;
1387 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1388 lpToolInfo->lpszText = NULL; /* FIXME */
1390 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1391 lpToolInfo->lParam = toolPtr->lParam;
1393 return TRUE;
1397 static LRESULT
1398 TOOLTIPS_HitTestA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1400 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1401 LPTTHITTESTINFOA lptthit = (LPTTHITTESTINFOA)lParam;
1402 TTTOOL_INFO *toolPtr;
1403 INT nTool;
1405 if (lptthit == 0)
1406 return FALSE;
1408 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1409 if (nTool == -1)
1410 return FALSE;
1412 TRACE("tool %d!\n", nTool);
1414 /* copy tool data */
1415 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) {
1416 toolPtr = &infoPtr->tools[nTool];
1418 lptthit->ti.uFlags = toolPtr->uFlags;
1419 lptthit->ti.hwnd = toolPtr->hwnd;
1420 lptthit->ti.uId = toolPtr->uId;
1421 lptthit->ti.rect = toolPtr->rect;
1422 lptthit->ti.hinst = toolPtr->hinst;
1423 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1424 lptthit->ti.lpszText = NULL; /* FIXME */
1425 lptthit->ti.lParam = toolPtr->lParam;
1428 return TRUE;
1432 static LRESULT
1433 TOOLTIPS_HitTestW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1435 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1436 LPTTHITTESTINFOW lptthit = (LPTTHITTESTINFOW)lParam;
1437 TTTOOL_INFO *toolPtr;
1438 INT nTool;
1440 if (lptthit == 0)
1441 return FALSE;
1443 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1444 if (nTool == -1)
1445 return FALSE;
1447 TRACE("tool %d!\n", nTool);
1449 /* copy tool data */
1450 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) {
1451 toolPtr = &infoPtr->tools[nTool];
1453 lptthit->ti.uFlags = toolPtr->uFlags;
1454 lptthit->ti.hwnd = toolPtr->hwnd;
1455 lptthit->ti.uId = toolPtr->uId;
1456 lptthit->ti.rect = toolPtr->rect;
1457 lptthit->ti.hinst = toolPtr->hinst;
1458 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1459 lptthit->ti.lpszText = NULL; /* FIXME */
1460 lptthit->ti.lParam = toolPtr->lParam;
1463 return TRUE;
1467 static LRESULT
1468 TOOLTIPS_NewToolRectA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1470 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1471 LPTTTOOLINFOA lpti = (LPTTTOOLINFOA)lParam;
1472 INT nTool;
1474 if (lpti == NULL)
1475 return 0;
1476 if (lpti->cbSize < TTTOOLINFO_V1_SIZEA)
1477 return FALSE;
1479 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti);
1480 if (nTool == -1) return 0;
1482 infoPtr->tools[nTool].rect = lpti->rect;
1484 return 0;
1488 static LRESULT
1489 TOOLTIPS_NewToolRectW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1491 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1492 LPTTTOOLINFOW lpti = (LPTTTOOLINFOW)lParam;
1493 INT nTool;
1495 if (lpti == NULL)
1496 return 0;
1497 if (lpti->cbSize < TTTOOLINFO_V1_SIZEW)
1498 return FALSE;
1500 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti);
1501 if (nTool == -1) return 0;
1503 infoPtr->tools[nTool].rect = lpti->rect;
1505 return 0;
1509 inline static LRESULT
1510 TOOLTIPS_Pop (HWND hwnd, WPARAM wParam, LPARAM lParam)
1512 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1513 TOOLTIPS_Hide (hwnd, infoPtr);
1515 return 0;
1519 static LRESULT
1520 TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1522 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1523 LPMSG lpMsg = (LPMSG)lParam;
1524 POINT pt;
1525 INT nOldTool;
1527 if (lParam == 0) {
1528 ERR("lpMsg == NULL!\n");
1529 return 0;
1532 switch (lpMsg->message) {
1533 case WM_LBUTTONDOWN:
1534 case WM_LBUTTONUP:
1535 case WM_MBUTTONDOWN:
1536 case WM_MBUTTONUP:
1537 case WM_RBUTTONDOWN:
1538 case WM_RBUTTONUP:
1539 TOOLTIPS_Hide (hwnd, infoPtr);
1540 break;
1542 case WM_MOUSEMOVE:
1543 pt.x = LOWORD(lpMsg->lParam);
1544 pt.y = HIWORD(lpMsg->lParam);
1545 nOldTool = infoPtr->nTool;
1546 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr, lpMsg->hwnd,
1547 &pt);
1548 TRACE("tool (%x) %d %d %d\n", hwnd, nOldTool,
1549 infoPtr->nTool, infoPtr->nCurrentTool);
1550 TRACE("WM_MOUSEMOVE (%04x %ld %ld)\n", hwnd, pt.x, pt.y);
1552 if (infoPtr->nTool != nOldTool) {
1553 if(infoPtr->nTool == -1) { /* Moved out of all tools */
1554 TOOLTIPS_Hide(hwnd, infoPtr);
1555 KillTimer(hwnd, ID_TIMERLEAVE);
1556 } else if (nOldTool == -1) { /* Moved from outside */
1557 if(infoPtr->bActive) {
1558 SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
1559 TRACE("timer 1 started!\n");
1561 } else { /* Moved from one to another */
1562 TOOLTIPS_Hide (hwnd, infoPtr);
1563 KillTimer(hwnd, ID_TIMERLEAVE);
1564 if(infoPtr->bActive) {
1565 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
1566 TRACE("timer 1 started!\n");
1569 } else if(infoPtr->nCurrentTool != -1) { /* restart autopop */
1570 KillTimer(hwnd, ID_TIMERPOP);
1571 SetTimer(hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
1572 TRACE("timer 2 restarted\n");
1574 break;
1577 return 0;
1581 static LRESULT
1582 TOOLTIPS_SetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
1584 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1585 INT nTime = (INT)LOWORD(lParam);
1587 switch (wParam) {
1588 case TTDT_AUTOMATIC:
1589 if (nTime <= 0)
1590 nTime = GetDoubleClickTime();
1591 infoPtr->nReshowTime = nTime / 5;
1592 infoPtr->nAutoPopTime = nTime * 10;
1593 infoPtr->nInitialTime = nTime;
1594 break;
1596 case TTDT_RESHOW:
1597 if(nTime < 0)
1598 nTime = GetDoubleClickTime() / 5;
1599 infoPtr->nReshowTime = nTime;
1600 break;
1602 case TTDT_AUTOPOP:
1603 if(nTime < 0)
1604 nTime = GetDoubleClickTime() * 10;
1605 infoPtr->nAutoPopTime = nTime;
1606 break;
1608 case TTDT_INITIAL:
1609 if(nTime < 0)
1610 nTime = GetDoubleClickTime();
1611 infoPtr->nInitialTime = nTime;
1612 break;
1614 default:
1615 WARN("Invalid wParam %x\n", wParam);
1616 break;
1619 return 0;
1623 static LRESULT
1624 TOOLTIPS_SetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1626 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1627 LPRECT lpRect = (LPRECT)lParam;
1629 infoPtr->rcMargin.left = lpRect->left;
1630 infoPtr->rcMargin.right = lpRect->right;
1631 infoPtr->rcMargin.bottom = lpRect->bottom;
1632 infoPtr->rcMargin.top = lpRect->top;
1634 return 0;
1638 inline static LRESULT
1639 TOOLTIPS_SetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1641 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1642 INT nTemp = infoPtr->nMaxTipWidth;
1644 infoPtr->nMaxTipWidth = (INT)lParam;
1646 return nTemp;
1650 inline static LRESULT
1651 TOOLTIPS_SetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1653 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1655 infoPtr->clrBk = (COLORREF)wParam;
1657 return 0;
1661 inline static LRESULT
1662 TOOLTIPS_SetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1664 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1666 infoPtr->clrText = (COLORREF)wParam;
1668 return 0;
1672 static LRESULT
1673 TOOLTIPS_SetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1675 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1676 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1677 TTTOOL_INFO *toolPtr;
1678 INT nTool;
1680 if (lpToolInfo == NULL)
1681 return 0;
1682 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1683 return 0;
1685 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1686 if (nTool == -1) return 0;
1688 TRACE("tool %d\n", nTool);
1690 toolPtr = &infoPtr->tools[nTool];
1692 /* copy tool data */
1693 toolPtr->uFlags = lpToolInfo->uFlags;
1694 toolPtr->hwnd = lpToolInfo->hwnd;
1695 toolPtr->uId = lpToolInfo->uId;
1696 toolPtr->rect = lpToolInfo->rect;
1697 toolPtr->hinst = lpToolInfo->hinst;
1699 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
1700 TRACE("set string id %x!\n", (INT)lpToolInfo->lpszText);
1701 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1703 else if (lpToolInfo->lpszText) {
1704 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
1705 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1706 else {
1707 if ( (toolPtr->lpszText) &&
1708 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
1709 COMCTL32_Free (toolPtr->lpszText);
1710 toolPtr->lpszText = NULL;
1712 if (lpToolInfo->lpszText) {
1713 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText,
1714 -1, NULL, 0);
1715 toolPtr->lpszText = COMCTL32_Alloc (len * sizeof(WCHAR));
1716 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
1717 toolPtr->lpszText, len);
1722 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1723 toolPtr->lParam = lpToolInfo->lParam;
1725 return 0;
1729 static LRESULT
1730 TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1732 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1733 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1734 TTTOOL_INFO *toolPtr;
1735 INT nTool;
1737 if (lpToolInfo == NULL)
1738 return 0;
1739 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1740 return 0;
1742 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1743 if (nTool == -1) return 0;
1745 TRACE("tool %d\n", nTool);
1747 toolPtr = &infoPtr->tools[nTool];
1749 /* copy tool data */
1750 toolPtr->uFlags = lpToolInfo->uFlags;
1751 toolPtr->hwnd = lpToolInfo->hwnd;
1752 toolPtr->uId = lpToolInfo->uId;
1753 toolPtr->rect = lpToolInfo->rect;
1754 toolPtr->hinst = lpToolInfo->hinst;
1756 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
1757 TRACE("set string id %x!\n", (INT)lpToolInfo->lpszText);
1758 toolPtr->lpszText = lpToolInfo->lpszText;
1760 else if (lpToolInfo->lpszText) {
1761 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
1762 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1763 else {
1764 if ( (toolPtr->lpszText) &&
1765 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
1766 COMCTL32_Free (toolPtr->lpszText);
1767 toolPtr->lpszText = NULL;
1769 if (lpToolInfo->lpszText) {
1770 INT len = lstrlenW (lpToolInfo->lpszText);
1771 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1772 strcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
1777 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1778 toolPtr->lParam = lpToolInfo->lParam;
1780 return 0;
1784 static LRESULT
1785 TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1787 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1788 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1790 if (lpToolInfo == NULL)
1791 return 0;
1792 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1793 return FALSE;
1795 if ((BOOL)wParam) {
1796 /* activate */
1797 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1798 if (infoPtr->nTrackTool != -1) {
1799 TRACE("activated!\n");
1800 infoPtr->bTrackActive = TRUE;
1801 TOOLTIPS_TrackShow (hwnd, infoPtr);
1804 else {
1805 /* deactivate */
1806 TOOLTIPS_TrackHide (hwnd, infoPtr);
1808 infoPtr->bTrackActive = FALSE;
1809 infoPtr->nTrackTool = -1;
1811 TRACE("deactivated!\n");
1814 return 0;
1818 static LRESULT
1819 TOOLTIPS_TrackPosition (HWND hwnd, WPARAM wParam, LPARAM lParam)
1821 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1823 infoPtr->xTrackPos = (INT)LOWORD(lParam);
1824 infoPtr->yTrackPos = (INT)HIWORD(lParam);
1826 if (infoPtr->bTrackActive) {
1827 TRACE("[%d %d]\n",
1828 infoPtr->xTrackPos, infoPtr->yTrackPos);
1830 TOOLTIPS_TrackShow (hwnd, infoPtr);
1833 return 0;
1837 static LRESULT
1838 TOOLTIPS_Update (HWND hwnd, WPARAM wParam, LPARAM lParam)
1840 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1842 if (infoPtr->nCurrentTool != -1)
1843 UpdateWindow (hwnd);
1845 return 0;
1849 static LRESULT
1850 TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1852 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1853 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1854 TTTOOL_INFO *toolPtr;
1855 INT nTool;
1857 if (lpToolInfo == NULL)
1858 return 0;
1859 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1860 return FALSE;
1862 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1863 if (nTool == -1) return 0;
1865 TRACE("tool %d\n", nTool);
1867 toolPtr = &infoPtr->tools[nTool];
1869 /* copy tool text */
1870 toolPtr->hinst = lpToolInfo->hinst;
1872 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
1873 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1875 else if (lpToolInfo->lpszText) {
1876 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
1877 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1878 else {
1879 if ( (toolPtr->lpszText) &&
1880 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
1881 COMCTL32_Free (toolPtr->lpszText);
1882 toolPtr->lpszText = NULL;
1884 if (lpToolInfo->lpszText) {
1885 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText,
1886 -1, NULL, 0);
1887 toolPtr->lpszText = COMCTL32_Alloc (len * sizeof(WCHAR));
1888 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
1889 toolPtr->lpszText, len);
1894 if(infoPtr->nCurrentTool == -1) return 0;
1895 /* force repaint */
1896 if (infoPtr->bActive)
1897 TOOLTIPS_Show (hwnd, infoPtr);
1898 else if (infoPtr->bTrackActive)
1899 TOOLTIPS_TrackShow (hwnd, infoPtr);
1901 return 0;
1905 static LRESULT
1906 TOOLTIPS_UpdateTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1908 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1909 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1910 TTTOOL_INFO *toolPtr;
1911 INT nTool;
1913 if (lpToolInfo == NULL)
1914 return 0;
1915 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1916 return FALSE;
1918 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1919 if (nTool == -1)
1920 return 0;
1922 TRACE("tool %d\n", nTool);
1924 toolPtr = &infoPtr->tools[nTool];
1926 /* copy tool text */
1927 toolPtr->hinst = lpToolInfo->hinst;
1929 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
1930 toolPtr->lpszText = lpToolInfo->lpszText;
1932 else if (lpToolInfo->lpszText) {
1933 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
1934 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1935 else {
1936 if ( (toolPtr->lpszText) &&
1937 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
1938 COMCTL32_Free (toolPtr->lpszText);
1939 toolPtr->lpszText = NULL;
1941 if (lpToolInfo->lpszText) {
1942 INT len = lstrlenW (lpToolInfo->lpszText);
1943 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1944 strcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
1949 if(infoPtr->nCurrentTool == -1) return 0;
1950 /* force repaint */
1951 if (infoPtr->bActive)
1952 TOOLTIPS_Show (hwnd, infoPtr);
1953 else if (infoPtr->bTrackActive)
1954 TOOLTIPS_TrackShow (hwnd, infoPtr);
1956 return 0;
1960 static LRESULT
1961 TOOLTIPS_WindowFromPoint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1963 return WindowFromPoint (*((LPPOINT)lParam));
1968 static LRESULT
1969 TOOLTIPS_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1971 TOOLTIPS_INFO *infoPtr;
1972 NONCLIENTMETRICSA nclm;
1973 INT nResult;
1975 /* allocate memory for info structure */
1976 infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc (sizeof(TOOLTIPS_INFO));
1977 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1979 /* initialize info structure */
1980 infoPtr->bActive = TRUE;
1981 infoPtr->bTrackActive = FALSE;
1982 infoPtr->clrBk = GetSysColor (COLOR_INFOBK);
1983 infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);
1985 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1986 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
1987 infoPtr->hFont = CreateFontIndirectA (&nclm.lfStatusFont);
1989 infoPtr->nMaxTipWidth = -1;
1990 infoPtr->nTool = -1;
1991 infoPtr->nCurrentTool = -1;
1992 infoPtr->nTrackTool = -1;
1994 TOOLTIPS_SetDelayTime(hwnd, TTDT_AUTOMATIC, 0L);
1996 nResult = (INT) SendMessageA (GetParent (hwnd), WM_NOTIFYFORMAT,
1997 (WPARAM)hwnd, (LPARAM)NF_QUERY);
1998 if (nResult == NFR_ANSI) {
1999 infoPtr->bNotifyUnicode = FALSE;
2000 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
2002 else if (nResult == NFR_UNICODE) {
2003 infoPtr->bNotifyUnicode = TRUE;
2004 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
2006 else {
2007 ERR (" -- WM_NOTIFYFORMAT returns: error!\n");
2010 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
2012 return 0;
2016 static LRESULT
2017 TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2019 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2020 TTTOOL_INFO *toolPtr;
2021 INT i;
2023 /* free tools */
2024 if (infoPtr->tools) {
2025 for (i = 0; i < infoPtr->uNumTools; i++) {
2026 toolPtr = &infoPtr->tools[i];
2027 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
2028 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
2029 (HIWORD((INT)toolPtr->lpszText) != 0) )
2031 COMCTL32_Free (toolPtr->lpszText);
2032 toolPtr->lpszText = NULL;
2036 /* remove subclassing */
2037 if (toolPtr->uFlags & TTF_SUBCLASS) {
2038 LPTT_SUBCLASS_INFO lpttsi;
2040 if (toolPtr->uFlags & TTF_IDISHWND) {
2041 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
2042 if (lpttsi) {
2043 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
2044 (LONG)lpttsi->wpOrigProc);
2045 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
2046 COMCTL32_Free (&lpttsi);
2049 else {
2050 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
2051 if (lpttsi) {
2052 SetWindowLongA ((HWND)toolPtr->hwnd, GWL_WNDPROC,
2053 (LONG)lpttsi->wpOrigProc);
2054 RemovePropA ((HWND)toolPtr->hwnd, COMCTL32_aSubclass);
2055 COMCTL32_Free (&lpttsi);
2060 COMCTL32_Free (infoPtr->tools);
2063 /* delete font */
2064 DeleteObject (infoPtr->hFont);
2066 /* free tool tips info data */
2067 COMCTL32_Free (infoPtr);
2068 SetWindowLongA(hwnd, 0, 0);
2069 return 0;
2073 static LRESULT
2074 TOOLTIPS_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2076 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2077 RECT rect;
2078 HBRUSH hBrush;
2080 hBrush = CreateSolidBrush (infoPtr->clrBk);
2081 GetClientRect (hwnd, &rect);
2082 FillRect ((HDC)wParam, &rect, hBrush);
2083 DeleteObject (hBrush);
2085 return FALSE;
2089 static LRESULT
2090 TOOLTIPS_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2092 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2094 return infoPtr->hFont;
2098 static LRESULT
2099 TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2101 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2103 TOOLTIPS_Hide (hwnd, infoPtr);
2105 return 0;
2109 static LRESULT
2110 TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2112 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2114 dwStyle &= 0x0000FFFF;
2115 dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS);
2116 SetWindowLongA (hwnd, GWL_STYLE, dwStyle);
2118 return TRUE;
2122 static LRESULT
2123 TOOLTIPS_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
2125 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2126 INT nTool = (infoPtr->bTrackActive) ? infoPtr->nTrackTool : infoPtr->nTool;
2128 TRACE(" nTool=%d\n", nTool);
2130 if ((nTool > -1) && (nTool < infoPtr->uNumTools)) {
2131 if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
2132 TRACE("-- in transparent mode!\n");
2133 return HTTRANSPARENT;
2137 return DefWindowProcA (hwnd, WM_NCHITTEST, wParam, lParam);
2141 static LRESULT
2142 TOOLTIPS_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2144 FIXME ("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
2146 return 0;
2150 static LRESULT
2151 TOOLTIPS_Paint (HWND hwnd, WPARAM wParam, LPARAM lParam)
2153 HDC hdc;
2154 PAINTSTRUCT ps;
2156 hdc = (wParam == 0) ? BeginPaint (hwnd, &ps) : (HDC)wParam;
2157 TOOLTIPS_Refresh (hwnd, hdc);
2158 if (!wParam)
2159 EndPaint (hwnd, &ps);
2160 return 0;
2164 static LRESULT
2165 TOOLTIPS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2167 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2169 infoPtr->hFont = (HFONT)wParam;
2171 if ((LOWORD(lParam)) & (infoPtr->nCurrentTool != -1)) {
2172 FIXME("full redraw needed!\n");
2175 return 0;
2177 /******************************************************************
2178 * TOOLTIPS_OnWMGetTextLength
2180 * This function is called when the tooltip receive a
2181 * WM_GETTEXTLENGTH message.
2182 * wParam : not used
2183 * lParam : not used
2185 * returns the length, in characters, of the tip text
2186 ******************************************************************/
2187 static LRESULT
2188 TOOLTIPS_OnWMGetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam)
2190 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2191 return lstrlenW(infoPtr->szTipText);
2194 /******************************************************************
2195 * TOOLTIPS_OnWMGetText
2197 * This function is called when the tooltip receive a
2198 * WM_GETTEXT message.
2199 * wParam : specifies the maximum number of characters to be copied
2200 * lParam : is the pointer to the buffer that will receive
2201 * the tip text
2203 * returns the number of characters copied
2204 ******************************************************************/
2205 static LRESULT
2206 TOOLTIPS_OnWMGetText (HWND hwnd, WPARAM wParam, LPARAM lParam)
2208 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2210 if(!infoPtr || !(infoPtr->szTipText))
2211 return 0;
2213 return WideCharToMultiByte(CP_ACP, 0, infoPtr->szTipText, -1,
2214 (LPSTR)lParam, wParam, NULL, NULL);
2217 static LRESULT
2218 TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam)
2220 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2221 INT nOldTool;
2223 TRACE("timer %d (%x) expired!\n", wParam, hwnd);
2225 switch (wParam) {
2226 case ID_TIMERSHOW:
2227 KillTimer (hwnd, ID_TIMERSHOW);
2228 nOldTool = infoPtr->nTool;
2229 if ((infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, TRUE)) == nOldTool)
2230 TOOLTIPS_Show (hwnd, infoPtr);
2231 break;
2233 case ID_TIMERPOP:
2234 TOOLTIPS_Hide (hwnd, infoPtr);
2235 break;
2237 case ID_TIMERLEAVE:
2238 nOldTool = infoPtr->nTool;
2239 infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, FALSE);
2240 TRACE("tool (%x) %d %d %d\n", hwnd, nOldTool,
2241 infoPtr->nTool, infoPtr->nCurrentTool);
2242 if (infoPtr->nTool != nOldTool) {
2243 if(infoPtr->nTool == -1) { /* Moved out of all tools */
2244 TOOLTIPS_Hide(hwnd, infoPtr);
2245 KillTimer(hwnd, ID_TIMERLEAVE);
2246 } else if (nOldTool == -1) { /* Moved from outside */
2247 ERR("How did this happen?\n");
2248 } else { /* Moved from one to another */
2249 TOOLTIPS_Hide (hwnd, infoPtr);
2250 KillTimer(hwnd, ID_TIMERLEAVE);
2251 if(infoPtr->bActive) {
2252 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
2253 TRACE("timer 1 started!\n");
2257 break;
2259 default:
2260 ERR("Unknown timer id %d\n", wParam);
2261 break;
2263 return 0;
2267 static LRESULT
2268 TOOLTIPS_WinIniChange (HWND hwnd, WPARAM wParam, LPARAM lParam)
2270 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2271 NONCLIENTMETRICSA nclm;
2273 infoPtr->clrBk = GetSysColor (COLOR_INFOBK);
2274 infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);
2276 DeleteObject (infoPtr->hFont);
2277 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
2278 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
2279 infoPtr->hFont = CreateFontIndirectA (&nclm.lfStatusFont);
2281 return 0;
2285 LRESULT CALLBACK
2286 TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2288 LPTT_SUBCLASS_INFO lpttsi =
2289 (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass);
2290 MSG msg;
2292 switch(uMsg) {
2293 case WM_MOUSEMOVE:
2294 case WM_LBUTTONDOWN:
2295 case WM_LBUTTONUP:
2296 case WM_MBUTTONDOWN:
2297 case WM_MBUTTONUP:
2298 case WM_RBUTTONDOWN:
2299 case WM_RBUTTONUP:
2300 msg.hwnd = hwnd;
2301 msg.message = uMsg;
2302 msg.wParam = wParam;
2303 msg.lParam = lParam;
2304 TOOLTIPS_RelayEvent(lpttsi->hwndToolTip, 0, (LPARAM)&msg);
2305 break;
2307 default:
2308 break;
2310 return CallWindowProcA (lpttsi->wpOrigProc, hwnd, uMsg, wParam, lParam);
2314 static LRESULT CALLBACK
2315 TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2317 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2318 if (!TOOLTIPS_GetInfoPtr(hwnd) && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE))
2319 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2320 switch (uMsg)
2322 case TTM_ACTIVATE:
2323 return TOOLTIPS_Activate (hwnd, wParam, lParam);
2325 case TTM_ADDTOOLA:
2326 return TOOLTIPS_AddToolA (hwnd, wParam, lParam);
2328 case TTM_ADDTOOLW:
2329 return TOOLTIPS_AddToolW (hwnd, wParam, lParam);
2331 case TTM_DELTOOLA:
2332 return TOOLTIPS_DelToolA (hwnd, wParam, lParam);
2334 case TTM_DELTOOLW:
2335 return TOOLTIPS_DelToolW (hwnd, wParam, lParam);
2337 case TTM_ENUMTOOLSA:
2338 return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam);
2340 case TTM_ENUMTOOLSW:
2341 return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam);
2343 case TTM_GETCURRENTTOOLA:
2344 return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam);
2346 case TTM_GETCURRENTTOOLW:
2347 return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam);
2349 case TTM_GETDELAYTIME:
2350 return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam);
2352 case TTM_GETMARGIN:
2353 return TOOLTIPS_GetMargin (hwnd, wParam, lParam);
2355 case TTM_GETMAXTIPWIDTH:
2356 return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam);
2358 case TTM_GETTEXTA:
2359 return TOOLTIPS_GetTextA (hwnd, wParam, lParam);
2361 case TTM_GETTEXTW:
2362 return TOOLTIPS_GetTextW (hwnd, wParam, lParam);
2364 case TTM_GETTIPBKCOLOR:
2365 return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam);
2367 case TTM_GETTIPTEXTCOLOR:
2368 return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam);
2370 case TTM_GETTOOLCOUNT:
2371 return TOOLTIPS_GetToolCount (hwnd, wParam, lParam);
2373 case TTM_GETTOOLINFOA:
2374 return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam);
2376 case TTM_GETTOOLINFOW:
2377 return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam);
2379 case TTM_HITTESTA:
2380 return TOOLTIPS_HitTestA (hwnd, wParam, lParam);
2382 case TTM_HITTESTW:
2383 return TOOLTIPS_HitTestW (hwnd, wParam, lParam);
2385 case TTM_NEWTOOLRECTA:
2386 return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam);
2388 case TTM_NEWTOOLRECTW:
2389 return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam);
2391 case TTM_POP:
2392 return TOOLTIPS_Pop (hwnd, wParam, lParam);
2394 case TTM_RELAYEVENT:
2395 return TOOLTIPS_RelayEvent (hwnd, wParam, lParam);
2397 case TTM_SETDELAYTIME:
2398 return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam);
2400 case TTM_SETMARGIN:
2401 return TOOLTIPS_SetMargin (hwnd, wParam, lParam);
2403 case TTM_SETMAXTIPWIDTH:
2404 return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam);
2406 case TTM_SETTIPBKCOLOR:
2407 return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam);
2409 case TTM_SETTIPTEXTCOLOR:
2410 return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam);
2412 case TTM_SETTOOLINFOA:
2413 return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam);
2415 case TTM_SETTOOLINFOW:
2416 return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam);
2418 case TTM_TRACKACTIVATE:
2419 return TOOLTIPS_TrackActivate (hwnd, wParam, lParam);
2421 case TTM_TRACKPOSITION:
2422 return TOOLTIPS_TrackPosition (hwnd, wParam, lParam);
2424 case TTM_UPDATE:
2425 return TOOLTIPS_Update (hwnd, wParam, lParam);
2427 case TTM_UPDATETIPTEXTA:
2428 return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam);
2430 case TTM_UPDATETIPTEXTW:
2431 return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam);
2433 case TTM_WINDOWFROMPOINT:
2434 return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam);
2437 case WM_CREATE:
2438 return TOOLTIPS_Create (hwnd, wParam, lParam);
2440 case WM_DESTROY:
2441 return TOOLTIPS_Destroy (hwnd, wParam, lParam);
2443 case WM_ERASEBKGND:
2444 return TOOLTIPS_EraseBackground (hwnd, wParam, lParam);
2446 case WM_GETFONT:
2447 return TOOLTIPS_GetFont (hwnd, wParam, lParam);
2449 case WM_GETTEXT:
2450 return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam);
2452 case WM_GETTEXTLENGTH:
2453 return TOOLTIPS_OnWMGetTextLength (hwnd, wParam, lParam);
2456 case WM_LBUTTONDOWN:
2457 case WM_LBUTTONUP:
2458 case WM_MBUTTONDOWN:
2459 case WM_MBUTTONUP:
2460 case WM_RBUTTONDOWN:
2461 case WM_RBUTTONUP:
2462 case WM_MOUSEMOVE:
2463 return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
2465 case WM_NCCREATE:
2466 return TOOLTIPS_NCCreate (hwnd, wParam, lParam);
2468 case WM_NCHITTEST:
2469 return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
2471 case WM_NOTIFYFORMAT:
2472 return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam);
2474 case WM_PAINT:
2475 return TOOLTIPS_Paint (hwnd, wParam, lParam);
2477 case WM_SETFONT:
2478 return TOOLTIPS_SetFont (hwnd, wParam, lParam);
2480 case WM_TIMER:
2481 return TOOLTIPS_Timer (hwnd, wParam, lParam);
2483 case WM_WININICHANGE:
2484 return TOOLTIPS_WinIniChange (hwnd, wParam, lParam);
2486 default:
2487 if (uMsg >= WM_USER)
2488 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2489 uMsg, wParam, lParam);
2490 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2492 return 0;
2496 VOID
2497 TOOLTIPS_Register (void)
2499 WNDCLASSA wndClass;
2501 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2502 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
2503 wndClass.lpfnWndProc = (WNDPROC)TOOLTIPS_WindowProc;
2504 wndClass.cbClsExtra = 0;
2505 wndClass.cbWndExtra = sizeof(TOOLTIPS_INFO *);
2506 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
2507 wndClass.hbrBackground = 0;
2508 wndClass.lpszClassName = TOOLTIPS_CLASSA;
2510 RegisterClassA (&wndClass);
2514 VOID
2515 TOOLTIPS_Unregister (void)
2517 UnregisterClassA (TOOLTIPS_CLASSA, (HINSTANCE)NULL);