4 * Copyright 1998 Eric Kohl
8 * - Custom draw support.
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.
23 #define ID_TIMERSHOW 1 /* show delay timer */
24 #define ID_TIMERPOP 2 /* auto pop timer */
25 #define ID_TIMERLEAVE 3 /* tool leave timer */
28 extern LPSTR COMCTL32_aSubclass; /* global subclassing atom */
30 /* property name of tooltip window handle */
31 /*#define TT_SUBCLASS_PROP "CC32SubclassInfo" */
33 #define TOOLTIPS_GetInfoPtr(wndPtr) ((TOOLTIPS_INFO *)wndPtr->wExtra[0])
37 TOOLTIPS_SubclassProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam);
41 TOOLTIPS_Refresh (WND *wndPtr, HDC32 hdc)
43 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
48 UINT32 uFlags = DT_EXTERNALLEADING;
50 if (infoPtr->nMaxTipWidth > -1)
51 uFlags |= DT_WORDBREAK;
52 if (wndPtr->dwStyle & TTS_NOPREFIX)
53 uFlags |= DT_NOPREFIX;
54 GetClientRect32 (wndPtr->hwndSelf, &rc);
56 /* fill the background */
57 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
58 FillRect32 (hdc, &rc, hBrush);
59 DeleteObject32 (hBrush);
61 /* calculate text rectangle */
62 rc.left += (2 + infoPtr->rcMargin.left);
63 rc.top += (2 + infoPtr->rcMargin.top);
64 rc.right -= (2 + infoPtr->rcMargin.right);
65 rc.bottom -= (2 + infoPtr->rcMargin.bottom);
68 oldBkMode = SetBkMode32 (hdc, TRANSPARENT);
69 SetTextColor32 (hdc, infoPtr->clrText);
70 hOldFont = SelectObject32 (hdc, infoPtr->hFont);
71 DrawText32W (hdc, infoPtr->szTipText, -1, &rc, uFlags);
72 SelectObject32 (hdc, hOldFont);
73 if (oldBkMode != TRANSPARENT)
74 SetBkMode32 (hdc, oldBkMode);
79 TOOLTIPS_GetTipText (WND *wndPtr, TOOLTIPS_INFO *infoPtr, INT32 nTool)
81 TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
83 if ((toolPtr->hinst) && (HIWORD((UINT32)toolPtr->lpszText) == 0)) {
85 TRACE (tooltips, "load res string %x %x\n",
86 toolPtr->hinst, (int)toolPtr->lpszText);
87 LoadString32W (toolPtr->hinst, (UINT32)toolPtr->lpszText,
88 infoPtr->szTipText, INFOTIPSIZE);
90 else if (toolPtr->lpszText) {
91 if (toolPtr->lpszText == LPSTR_TEXTCALLBACK32W) {
92 NMTTDISPINFO32A ttnmdi;
94 /* fill NMHDR struct */
95 ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFO32A));
96 ttnmdi.hdr.hwndFrom = wndPtr->hwndSelf;
97 ttnmdi.hdr.idFrom = toolPtr->uId;
98 ttnmdi.hdr.code = TTN_GETDISPINFO32A;
99 ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
100 ttnmdi.uFlags = toolPtr->uFlags;
101 ttnmdi.lParam = toolPtr->lParam;
103 TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
104 SendMessage32A (toolPtr->hwnd, WM_NOTIFY,
105 (WPARAM32)toolPtr->uId, (LPARAM)&ttnmdi);
107 if ((ttnmdi.hinst) && (HIWORD((UINT32)ttnmdi.szText) == 0)) {
108 LoadString32W (ttnmdi.hinst, (UINT32)ttnmdi.szText,
109 infoPtr->szTipText, INFOTIPSIZE);
110 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
111 toolPtr->hinst = ttnmdi.hinst;
112 toolPtr->lpszText = (LPWSTR)ttnmdi.szText;
115 else if (ttnmdi.szText[0]) {
116 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.szText, 80);
117 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
118 INT32 len = lstrlen32A (ttnmdi.szText);
120 toolPtr->lpszText = COMCTL32_Alloc ((len+1)* sizeof(WCHAR));
121 lstrcpyAtoW (toolPtr->lpszText, ttnmdi.szText);
124 else if (ttnmdi.lpszText == 0) {
125 /* no text available */
126 infoPtr->szTipText[0] = L'\0';
128 else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACK32A) {
129 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.lpszText, INFOTIPSIZE);
130 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
131 INT32 len = lstrlen32A (ttnmdi.lpszText);
133 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
134 lstrcpyAtoW (toolPtr->lpszText, ttnmdi.lpszText);
138 ERR (tooltips, "recursive text callback!\n");
139 infoPtr->szTipText[0] = '\0';
143 /* the item is a usual (unicode) text */
144 lstrcpyn32W (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
148 /* no text available */
149 infoPtr->szTipText[0] = L'\0';
152 TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
157 TOOLTIPS_CalcTipSize (WND *wndPtr, TOOLTIPS_INFO *infoPtr, LPSIZE32 lpSize)
161 UINT32 uFlags = DT_EXTERNALLEADING | DT_CALCRECT;
162 RECT32 rc = {0, 0, 0, 0};
164 if (infoPtr->nMaxTipWidth > -1) {
165 rc.right = infoPtr->nMaxTipWidth;
166 uFlags |= DT_WORDBREAK;
168 if (wndPtr->dwStyle & TTS_NOPREFIX)
169 uFlags |= DT_NOPREFIX;
170 TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
172 hdc = GetDC32 (wndPtr->hwndSelf);
173 hOldFont = SelectObject32 (hdc, infoPtr->hFont);
174 DrawText32W (hdc, infoPtr->szTipText, -1, &rc, uFlags);
175 SelectObject32 (hdc, hOldFont);
176 ReleaseDC32 (wndPtr->hwndSelf, hdc);
178 lpSize->cx = rc.right - rc.left + 4 +
179 infoPtr->rcMargin.left + infoPtr->rcMargin.right;
180 lpSize->cy = rc.bottom - rc.top + 4 +
181 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
186 TOOLTIPS_Show (WND *wndPtr, TOOLTIPS_INFO *infoPtr)
188 TTTOOL_INFO *toolPtr;
194 if (infoPtr->nTool == -1) {
195 TRACE (tooltips, "invalid tool (-1)!\n");
199 infoPtr->nCurrentTool = infoPtr->nTool;
201 TRACE (tooltips, "Show tooltip pre %d!\n", infoPtr->nTool);
203 TOOLTIPS_GetTipText (wndPtr, infoPtr, infoPtr->nCurrentTool);
205 if (infoPtr->szTipText[0] == L'\0') {
206 infoPtr->nCurrentTool = -1;
210 TRACE (tooltips, "Show tooltip %d!\n", infoPtr->nCurrentTool);
211 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
213 hdr.hwndFrom = wndPtr->hwndSelf;
214 hdr.idFrom = toolPtr->uId;
216 SendMessage32A (toolPtr->hwnd, WM_NOTIFY,
217 (WPARAM32)toolPtr->uId, (LPARAM)&hdr);
219 TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
221 TOOLTIPS_CalcTipSize (wndPtr, infoPtr, &size);
222 TRACE (tooltips, "size %d - %d\n", size.cx, size.cy);
224 if (toolPtr->uFlags & TTF_CENTERTIP) {
227 if (toolPtr->uFlags & TTF_IDISHWND)
228 GetWindowRect32 ((HWND32)toolPtr->uId, &rc);
231 MapWindowPoints32 (toolPtr->hwnd, (HWND32)0, (LPPOINT32)&rc, 2);
233 rect.left = (rc.left + rc.right - size.cx) / 2;
234 rect.top = rc.bottom + 2;
237 GetCursorPos32 ((LPPOINT32)&rect);
241 /* FIXME: check position */
243 TRACE (tooltips, "pos %d - %d\n", rect.left, rect.top);
245 rect.right = rect.left + size.cx;
246 rect.bottom = rect.top + size.cy;
248 AdjustWindowRectEx32 (&rect, wndPtr->dwStyle, FALSE, wndPtr->dwExStyle);
250 SetWindowPos32 (wndPtr->hwndSelf, HWND_TOP, rect.left, rect.top,
251 rect.right - rect.left, rect.bottom - rect.top,
254 /* repaint the tooltip */
255 hdc = GetDC32 (wndPtr->hwndSelf);
256 TOOLTIPS_Refresh (wndPtr, hdc);
257 ReleaseDC32 (wndPtr->hwndSelf, hdc);
259 SetTimer32 (wndPtr->hwndSelf, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
264 TOOLTIPS_Hide (WND *wndPtr, TOOLTIPS_INFO *infoPtr)
266 TTTOOL_INFO *toolPtr;
269 if (infoPtr->nCurrentTool == -1)
272 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
273 TRACE (tooltips, "Hide tooltip %d!\n", infoPtr->nCurrentTool);
274 KillTimer32 (wndPtr->hwndSelf, ID_TIMERPOP);
276 hdr.hwndFrom = wndPtr->hwndSelf;
277 hdr.idFrom = toolPtr->uId;
279 SendMessage32A (toolPtr->hwnd, WM_NOTIFY,
280 (WPARAM32)toolPtr->uId, (LPARAM)&hdr);
282 infoPtr->nCurrentTool = -1;
284 SetWindowPos32 (wndPtr->hwndSelf, HWND_TOP, 0, 0, 0, 0,
285 SWP_NOZORDER | SWP_HIDEWINDOW);
290 TOOLTIPS_TrackShow (WND *wndPtr, TOOLTIPS_INFO *infoPtr)
292 TTTOOL_INFO *toolPtr;
298 if (infoPtr->nTrackTool == -1) {
299 TRACE (tooltips, "invalid tracking tool (-1)!\n");
303 TRACE (tooltips, "show tracking tooltip pre %d!\n", infoPtr->nTrackTool);
305 TOOLTIPS_GetTipText (wndPtr, infoPtr, infoPtr->nTrackTool);
307 if (infoPtr->szTipText[0] == L'\0') {
308 infoPtr->nTrackTool = -1;
312 TRACE (tooltips, "show tracking tooltip %d!\n", infoPtr->nTrackTool);
313 toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
315 hdr.hwndFrom = wndPtr->hwndSelf;
316 hdr.idFrom = toolPtr->uId;
318 SendMessage32A (toolPtr->hwnd, WM_NOTIFY,
319 (WPARAM32)toolPtr->uId, (LPARAM)&hdr);
321 TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
323 TOOLTIPS_CalcTipSize (wndPtr, infoPtr, &size);
324 TRACE (tooltips, "size %d - %d\n", size.cx, size.cy);
326 if (toolPtr->uFlags & TTF_ABSOLUTE) {
327 rect.left = infoPtr->xTrackPos;
328 rect.top = infoPtr->yTrackPos;
330 if (toolPtr->uFlags & TTF_CENTERTIP) {
331 rect.left -= (size.cx / 2);
332 rect.top -= (size.cy / 2);
338 if (toolPtr->uFlags & TTF_IDISHWND)
339 GetWindowRect32 ((HWND32)toolPtr->uId, &rcTool);
341 rcTool = toolPtr->rect;
342 MapWindowPoints32 (toolPtr->hwnd, (HWND32)0, (LPPOINT32)&rcTool, 2);
345 GetCursorPos32 ((LPPOINT32)&rect);
348 if (toolPtr->uFlags & TTF_CENTERTIP) {
349 rect.left -= (size.cx / 2);
350 rect.top -= (size.cy / 2);
353 /* smart placement */
354 if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
355 (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
356 rect.left = rcTool.right;
359 TRACE (tooltips, "pos %d - %d\n", rect.left, rect.top);
361 rect.right = rect.left + size.cx;
362 rect.bottom = rect.top + size.cy;
364 AdjustWindowRectEx32 (&rect, wndPtr->dwStyle, FALSE, wndPtr->dwExStyle);
366 SetWindowPos32 (wndPtr->hwndSelf, HWND_TOP, rect.left, rect.top,
367 rect.right - rect.left, rect.bottom - rect.top,
370 hdc = GetDC32 (wndPtr->hwndSelf);
371 TOOLTIPS_Refresh (wndPtr, hdc);
372 ReleaseDC32 (wndPtr->hwndSelf, hdc);
377 TOOLTIPS_TrackHide (WND *wndPtr, TOOLTIPS_INFO *infoPtr)
379 TTTOOL_INFO *toolPtr;
382 if (infoPtr->nTrackTool == -1)
385 toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
386 TRACE (tooltips, "hide tracking tooltip %d!\n", infoPtr->nTrackTool);
388 hdr.hwndFrom = wndPtr->hwndSelf;
389 hdr.idFrom = toolPtr->uId;
391 SendMessage32A (toolPtr->hwnd, WM_NOTIFY,
392 (WPARAM32)toolPtr->uId, (LPARAM)&hdr);
394 SetWindowPos32 (wndPtr->hwndSelf, HWND_TOP, 0, 0, 0, 0,
395 SWP_NOZORDER | SWP_HIDEWINDOW);
400 TOOLTIPS_GetToolFromInfoA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFO32A lpToolInfo)
402 TTTOOL_INFO *toolPtr;
405 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
406 toolPtr = &infoPtr->tools[nTool];
408 if (!(toolPtr->uFlags & TTF_IDISHWND) &&
409 (lpToolInfo->hwnd == toolPtr->hwnd) &&
410 (lpToolInfo->uId == toolPtr->uId))
414 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
415 toolPtr = &infoPtr->tools[nTool];
417 if ((toolPtr->uFlags & TTF_IDISHWND) &&
418 (lpToolInfo->uId == toolPtr->uId))
427 TOOLTIPS_GetToolFromInfoW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFO32W lpToolInfo)
429 TTTOOL_INFO *toolPtr;
432 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
433 toolPtr = &infoPtr->tools[nTool];
435 if (!(toolPtr->uFlags & TTF_IDISHWND) &&
436 (lpToolInfo->hwnd == toolPtr->hwnd) &&
437 (lpToolInfo->uId == toolPtr->uId))
441 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
442 toolPtr = &infoPtr->tools[nTool];
444 if ((toolPtr->uFlags & TTF_IDISHWND) &&
445 (lpToolInfo->uId == toolPtr->uId))
454 TOOLTIPS_GetToolFromPoint (TOOLTIPS_INFO *infoPtr, HWND32 hwnd, LPPOINT32 lpPt)
456 TTTOOL_INFO *toolPtr;
459 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
460 toolPtr = &infoPtr->tools[nTool];
462 if (!(toolPtr->uFlags & TTF_IDISHWND)) {
463 if (hwnd != toolPtr->hwnd)
465 if (!PtInRect32 (&toolPtr->rect, *lpPt))
471 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
472 toolPtr = &infoPtr->tools[nTool];
474 if (toolPtr->uFlags & TTF_IDISHWND) {
475 if ((HWND32)toolPtr->uId == hwnd)
485 TOOLTIPS_GetToolFromMessage (TOOLTIPS_INFO *infoPtr, HWND32 hwndTool)
490 dwPos = GetMessagePos ();
491 pt.x = (INT32)LOWORD(dwPos);
492 pt.y = (INT32)HIWORD(dwPos);
493 ScreenToClient32 (hwndTool, &pt);
495 return TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
500 TOOLTIPS_IsWindowActive (HWND32 hwnd)
502 HWND32 hwndActive = GetActiveWindow32 ();
505 if (hwndActive == hwnd)
507 return IsChild32 (hwndActive, hwnd);
512 TOOLTIPS_CheckTool (WND *wndPtr, BOOL32 bShowTest)
514 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
519 GetCursorPos32 (&pt);
521 SendMessage32A (wndPtr->hwndSelf, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt);
525 ScreenToClient32 (hwndTool, &pt);
526 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
530 if (!(wndPtr->dwStyle & TTS_ALWAYSTIP) && bShowTest) {
531 if (!TOOLTIPS_IsWindowActive (wndPtr->owner->hwndSelf))
535 TRACE (tooltips, "tool %d\n", nTool);
542 TOOLTIPS_Activate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
544 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
546 infoPtr->bActive = (BOOL32)wParam;
548 if (infoPtr->bActive)
549 TRACE (tooltips, "activate!\n");
551 if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1))
552 TOOLTIPS_Hide (wndPtr, infoPtr);
559 TOOLTIPS_AddTool32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
561 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
562 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
563 TTTOOL_INFO *toolPtr;
565 if (lpToolInfo == NULL)
567 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
570 TRACE (tooltips, "add tool (%x) %x %d%s!\n",
571 wndPtr->hwndSelf, lpToolInfo->hwnd, lpToolInfo->uId,
572 (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
574 if (infoPtr->uNumTools == 0) {
575 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
576 toolPtr = infoPtr->tools;
579 TTTOOL_INFO *oldTools = infoPtr->tools;
581 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
582 memcpy (infoPtr->tools, oldTools,
583 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
584 COMCTL32_Free (oldTools);
585 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
588 infoPtr->uNumTools++;
591 toolPtr->uFlags = lpToolInfo->uFlags;
592 toolPtr->hwnd = lpToolInfo->hwnd;
593 toolPtr->uId = lpToolInfo->uId;
594 toolPtr->rect = lpToolInfo->rect;
595 toolPtr->hinst = lpToolInfo->hinst;
597 if ((lpToolInfo->hinst) && (HIWORD((INT32)lpToolInfo->lpszText) == 0)) {
598 TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
599 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
601 else if (lpToolInfo->lpszText) {
602 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACK32A) {
603 TRACE (tooltips, "add CALLBACK!\n");
604 toolPtr->lpszText = LPSTR_TEXTCALLBACK32W;
607 INT32 len = lstrlen32A (lpToolInfo->lpszText);
608 TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
609 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
610 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
614 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32A))
615 toolPtr->lParam = lpToolInfo->lParam;
617 /* install subclassing hook */
618 if (toolPtr->uFlags & TTF_SUBCLASS) {
619 if (toolPtr->uFlags & TTF_IDISHWND) {
620 LPTT_SUBCLASS_INFO lpttsi =
621 (LPTT_SUBCLASS_INFO)GetProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
622 if (lpttsi == NULL) {
624 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
626 (WNDPROC32)SetWindowLong32A ((HWND32)toolPtr->uId,
627 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
628 lpttsi->hwndToolTip = wndPtr->hwndSelf;
630 SetProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass,
634 WARN (tooltips, "A window tool must only be listed once!\n");
637 LPTT_SUBCLASS_INFO lpttsi =
638 (LPTT_SUBCLASS_INFO)GetProp32A (toolPtr->hwnd, COMCTL32_aSubclass);
639 if (lpttsi == NULL) {
641 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
643 (WNDPROC32)SetWindowLong32A (toolPtr->hwnd,
644 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
645 lpttsi->hwndToolTip = wndPtr->hwndSelf;
647 SetProp32A (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE32)lpttsi);
652 TRACE (tooltips, "subclassing installed!\n");
660 TOOLTIPS_AddTool32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
662 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
663 LPTTTOOLINFO32W lpToolInfo = (LPTTTOOLINFO32W)lParam;
664 TTTOOL_INFO *toolPtr;
666 if (lpToolInfo == NULL)
668 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32W)
671 TRACE (tooltips, "add tool (%x) %x %d%s!\n",
672 wndPtr->hwndSelf, lpToolInfo->hwnd, lpToolInfo->uId,
673 (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
675 if (infoPtr->uNumTools == 0) {
676 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
677 toolPtr = infoPtr->tools;
680 TTTOOL_INFO *oldTools = infoPtr->tools;
682 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
683 memcpy (infoPtr->tools, oldTools,
684 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
685 COMCTL32_Free (oldTools);
686 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
689 infoPtr->uNumTools++;
692 toolPtr->uFlags = lpToolInfo->uFlags;
693 toolPtr->hwnd = lpToolInfo->hwnd;
694 toolPtr->uId = lpToolInfo->uId;
695 toolPtr->rect = lpToolInfo->rect;
696 toolPtr->hinst = lpToolInfo->hinst;
698 if ((lpToolInfo->hinst) && (HIWORD((INT32)lpToolInfo->lpszText) == 0)) {
699 TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
700 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
702 else if (lpToolInfo->lpszText) {
703 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACK32W) {
704 TRACE (tooltips, "add CALLBACK!\n");
705 toolPtr->lpszText = LPSTR_TEXTCALLBACK32W;
708 INT32 len = lstrlen32W (lpToolInfo->lpszText);
709 TRACE (tooltips, "add text \"%s\"!\n",
710 debugstr_w(lpToolInfo->lpszText));
711 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
712 lstrcpy32W (toolPtr->lpszText, lpToolInfo->lpszText);
716 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32W))
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)GetProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
724 if (lpttsi == NULL) {
726 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
728 (WNDPROC32)SetWindowLong32A ((HWND32)toolPtr->uId,
729 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
730 lpttsi->hwndToolTip = wndPtr->hwndSelf;
732 SetProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass,
736 WARN (tooltips, "A window tool must only be listed once!\n");
739 LPTT_SUBCLASS_INFO lpttsi =
740 (LPTT_SUBCLASS_INFO)GetProp32A (toolPtr->hwnd, COMCTL32_aSubclass);
741 if (lpttsi == NULL) {
743 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
745 (WNDPROC32)SetWindowLong32A (toolPtr->hwnd,
746 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
747 lpttsi->hwndToolTip = wndPtr->hwndSelf;
749 SetProp32A (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE32)lpttsi);
754 TRACE (tooltips, "subclassing installed!\n");
762 TOOLTIPS_DelTool32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
764 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
765 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
766 TTTOOL_INFO *toolPtr;
769 if (lpToolInfo == NULL)
771 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
773 if (infoPtr->uNumTools == 0)
776 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
777 if (nTool == -1) return 0;
779 TRACE (tooltips, "tool %d\n", nTool);
781 /* delete text string */
782 toolPtr = &infoPtr->tools[nTool];
783 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
784 if (toolPtr->lpszText != LPSTR_TEXTCALLBACK32W)
785 COMCTL32_Free (toolPtr->lpszText);
788 /* remove subclassing */
789 if (toolPtr->uFlags & TTF_SUBCLASS) {
790 if (toolPtr->uFlags & TTF_IDISHWND) {
791 LPTT_SUBCLASS_INFO lpttsi =
792 (LPTT_SUBCLASS_INFO)GetProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
794 SetWindowLong32A ((HWND32)toolPtr->uId, GWL_WNDPROC,
795 (LONG)lpttsi->wpOrigProc);
796 RemoveProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
797 COMCTL32_Free (&lpttsi);
800 ERR (tooltips, "Invalid data handle!\n");
803 LPTT_SUBCLASS_INFO lpttsi =
804 (LPTT_SUBCLASS_INFO)GetProp32A (toolPtr->hwnd, COMCTL32_aSubclass);
806 if (lpttsi->uRefCount == 1) {
807 SetWindowLong32A ((HWND32)toolPtr->uId, GWL_WNDPROC,
808 (LONG)lpttsi->wpOrigProc);
809 RemoveProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
810 COMCTL32_Free (&lpttsi);
816 ERR (tooltips, "Invalid data handle!\n");
820 /* delete tool from tool list */
821 if (infoPtr->uNumTools == 1) {
822 COMCTL32_Free (infoPtr->tools);
823 infoPtr->tools = NULL;
826 TTTOOL_INFO *oldTools = infoPtr->tools;
828 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
831 memcpy (&infoPtr->tools[0], &oldTools[0],
832 nTool * sizeof(TTTOOL_INFO));
834 if (nTool < infoPtr->uNumTools - 1)
835 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
836 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
838 COMCTL32_Free (oldTools);
841 infoPtr->uNumTools--;
848 TOOLTIPS_DelTool32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
850 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
851 LPTTTOOLINFO32W lpToolInfo = (LPTTTOOLINFO32W)lParam;
852 TTTOOL_INFO *toolPtr;
855 if (lpToolInfo == NULL)
857 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32W)
859 if (infoPtr->uNumTools == 0)
862 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
863 if (nTool == -1) return 0;
865 TRACE (tooltips, "tool %d\n", nTool);
867 /* delete text string */
868 toolPtr = &infoPtr->tools[nTool];
869 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
870 if (toolPtr->lpszText != LPSTR_TEXTCALLBACK32W)
871 COMCTL32_Free (toolPtr->lpszText);
874 /* remove subclassing */
875 if (toolPtr->uFlags & TTF_SUBCLASS) {
876 if (toolPtr->uFlags & TTF_IDISHWND) {
877 LPTT_SUBCLASS_INFO lpttsi =
878 (LPTT_SUBCLASS_INFO)GetProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
880 SetWindowLong32A ((HWND32)toolPtr->uId, GWL_WNDPROC,
881 (LONG)lpttsi->wpOrigProc);
882 RemoveProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
883 COMCTL32_Free (&lpttsi);
886 ERR (tooltips, "Invalid data handle!\n");
889 LPTT_SUBCLASS_INFO lpttsi =
890 (LPTT_SUBCLASS_INFO)GetProp32A (toolPtr->hwnd, COMCTL32_aSubclass);
892 if (lpttsi->uRefCount == 1) {
893 SetWindowLong32A ((HWND32)toolPtr->uId, GWL_WNDPROC,
894 (LONG)lpttsi->wpOrigProc);
895 RemoveProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
896 COMCTL32_Free (&lpttsi);
902 ERR (tooltips, "Invalid data handle!\n");
906 /* delete tool from tool list */
907 if (infoPtr->uNumTools == 1) {
908 COMCTL32_Free (infoPtr->tools);
909 infoPtr->tools = NULL;
912 TTTOOL_INFO *oldTools = infoPtr->tools;
914 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
917 memcpy (&infoPtr->tools[0], &oldTools[0],
918 nTool * sizeof(TTTOOL_INFO));
920 if (nTool < infoPtr->uNumTools - 1)
921 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
922 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
924 COMCTL32_Free (oldTools);
927 infoPtr->uNumTools--;
934 TOOLTIPS_EnumTools32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
936 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
937 UINT32 uIndex = (UINT32)wParam;
938 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
939 TTTOOL_INFO *toolPtr;
941 if (lpToolInfo == NULL)
943 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
945 if (uIndex >= infoPtr->uNumTools)
948 TRACE (tooltips, "index=%u\n", uIndex);
950 toolPtr = &infoPtr->tools[uIndex];
953 lpToolInfo->uFlags = toolPtr->uFlags;
954 lpToolInfo->hwnd = toolPtr->hwnd;
955 lpToolInfo->uId = toolPtr->uId;
956 lpToolInfo->rect = toolPtr->rect;
957 lpToolInfo->hinst = toolPtr->hinst;
958 /* lpToolInfo->lpszText = toolPtr->lpszText; */
959 lpToolInfo->lpszText = NULL; /* FIXME */
961 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32A))
962 lpToolInfo->lParam = toolPtr->lParam;
969 TOOLTIPS_EnumTools32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
971 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
972 UINT32 uIndex = (UINT32)wParam;
973 LPTTTOOLINFO32W lpToolInfo = (LPTTTOOLINFO32W)lParam;
974 TTTOOL_INFO *toolPtr;
976 if (lpToolInfo == NULL)
978 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32W)
980 if (uIndex >= infoPtr->uNumTools)
983 TRACE (tooltips, "index=%u\n", uIndex);
985 toolPtr = &infoPtr->tools[uIndex];
988 lpToolInfo->uFlags = toolPtr->uFlags;
989 lpToolInfo->hwnd = toolPtr->hwnd;
990 lpToolInfo->uId = toolPtr->uId;
991 lpToolInfo->rect = toolPtr->rect;
992 lpToolInfo->hinst = toolPtr->hinst;
993 /* lpToolInfo->lpszText = toolPtr->lpszText; */
994 lpToolInfo->lpszText = NULL; /* FIXME */
996 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32W))
997 lpToolInfo->lParam = toolPtr->lParam;
1004 TOOLTIPS_GetCurrentTool32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1006 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1007 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
1008 TTTOOL_INFO *toolPtr;
1010 if (lpToolInfo == NULL)
1012 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
1016 if (infoPtr->nCurrentTool > -1) {
1017 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1019 /* copy tool data */
1020 lpToolInfo->uFlags = toolPtr->uFlags;
1021 lpToolInfo->rect = toolPtr->rect;
1022 lpToolInfo->hinst = toolPtr->hinst;
1023 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1024 lpToolInfo->lpszText = NULL; /* FIXME */
1026 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32A))
1027 lpToolInfo->lParam = toolPtr->lParam;
1035 return (infoPtr->nCurrentTool != -1);
1042 TOOLTIPS_GetCurrentTool32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1044 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1045 LPTTTOOLINFO32W lpToolInfo = (LPTTTOOLINFO32W)lParam;
1046 TTTOOL_INFO *toolPtr;
1048 if (lpToolInfo == NULL)
1050 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32W)
1054 if (infoPtr->nCurrentTool > -1) {
1055 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1057 /* copy tool data */
1058 lpToolInfo->uFlags = toolPtr->uFlags;
1059 lpToolInfo->rect = toolPtr->rect;
1060 lpToolInfo->hinst = toolPtr->hinst;
1061 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1062 lpToolInfo->lpszText = NULL; /* FIXME */
1064 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32W))
1065 lpToolInfo->lParam = toolPtr->lParam;
1073 return (infoPtr->nCurrentTool != -1);
1080 TOOLTIPS_GetDelayTime (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1082 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1085 case TTDT_AUTOMATIC:
1086 return infoPtr->nAutomaticTime;
1089 return infoPtr->nReshowTime;
1092 return infoPtr->nAutoPopTime;
1095 return infoPtr->nInitialTime;
1103 TOOLTIPS_GetMargin (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1105 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1106 LPRECT32 lpRect = (LPRECT32)lParam;
1108 lpRect->left = infoPtr->rcMargin.left;
1109 lpRect->right = infoPtr->rcMargin.right;
1110 lpRect->bottom = infoPtr->rcMargin.bottom;
1111 lpRect->top = infoPtr->rcMargin.top;
1117 __inline__ static LRESULT
1118 TOOLTIPS_GetMaxTipWidth (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1120 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1122 return infoPtr->nMaxTipWidth;
1127 TOOLTIPS_GetText32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1129 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1130 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
1133 if (lpToolInfo == NULL)
1135 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
1138 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1139 if (nTool == -1) return 0;
1141 lstrcpyWtoA (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
1148 TOOLTIPS_GetText32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1150 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1151 LPTTTOOLINFO32W lpToolInfo = (LPTTTOOLINFO32W)lParam;
1154 if (lpToolInfo == NULL)
1156 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32W)
1159 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1160 if (nTool == -1) return 0;
1162 lstrcpy32W (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
1168 __inline__ static LRESULT
1169 TOOLTIPS_GetTipBkColor (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1171 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1172 return infoPtr->clrBk;
1176 __inline__ static LRESULT
1177 TOOLTIPS_GetTipTextColor (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1179 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1180 return infoPtr->clrText;
1184 __inline__ static LRESULT
1185 TOOLTIPS_GetToolCount (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1187 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1188 return infoPtr->uNumTools;
1193 TOOLTIPS_GetToolInfo32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1195 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1196 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
1197 TTTOOL_INFO *toolPtr;
1200 if (lpToolInfo == NULL)
1202 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
1204 if (infoPtr->uNumTools == 0)
1207 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1211 TRACE (tooltips, "tool %d\n", nTool);
1213 toolPtr = &infoPtr->tools[nTool];
1215 /* copy tool data */
1216 lpToolInfo->uFlags = toolPtr->uFlags;
1217 lpToolInfo->rect = toolPtr->rect;
1218 lpToolInfo->hinst = toolPtr->hinst;
1219 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1220 lpToolInfo->lpszText = NULL; /* FIXME */
1222 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32A))
1223 lpToolInfo->lParam = toolPtr->lParam;
1230 TOOLTIPS_GetToolInfo32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1232 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1233 LPTTTOOLINFO32W lpToolInfo = (LPTTTOOLINFO32W)lParam;
1234 TTTOOL_INFO *toolPtr;
1237 if (lpToolInfo == NULL)
1239 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32W)
1241 if (infoPtr->uNumTools == 0)
1244 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1248 TRACE (tooltips, "tool %d\n", nTool);
1250 toolPtr = &infoPtr->tools[nTool];
1252 /* copy tool data */
1253 lpToolInfo->uFlags = toolPtr->uFlags;
1254 lpToolInfo->rect = toolPtr->rect;
1255 lpToolInfo->hinst = toolPtr->hinst;
1256 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1257 lpToolInfo->lpszText = NULL; /* FIXME */
1259 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32W))
1260 lpToolInfo->lParam = toolPtr->lParam;
1267 TOOLTIPS_HitTest32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1269 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1270 LPTTHITTESTINFO32A lptthit = (LPTTHITTESTINFO32A)lParam;
1271 TTTOOL_INFO *toolPtr;
1277 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1281 TRACE (tooltips, "tool %d!\n", nTool);
1283 /* copy tool data */
1284 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFO32A)) {
1285 toolPtr = &infoPtr->tools[nTool];
1287 lptthit->ti.uFlags = toolPtr->uFlags;
1288 lptthit->ti.hwnd = toolPtr->hwnd;
1289 lptthit->ti.uId = toolPtr->uId;
1290 lptthit->ti.rect = toolPtr->rect;
1291 lptthit->ti.hinst = toolPtr->hinst;
1292 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1293 lptthit->ti.lpszText = NULL; /* FIXME */
1294 lptthit->ti.lParam = toolPtr->lParam;
1302 TOOLTIPS_HitTest32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1304 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1305 LPTTHITTESTINFO32W lptthit = (LPTTHITTESTINFO32W)lParam;
1306 TTTOOL_INFO *toolPtr;
1312 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1316 TRACE (tooltips, "tool %d!\n", nTool);
1318 /* copy tool data */
1319 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFO32W)) {
1320 toolPtr = &infoPtr->tools[nTool];
1322 lptthit->ti.uFlags = toolPtr->uFlags;
1323 lptthit->ti.hwnd = toolPtr->hwnd;
1324 lptthit->ti.uId = toolPtr->uId;
1325 lptthit->ti.rect = toolPtr->rect;
1326 lptthit->ti.hinst = toolPtr->hinst;
1327 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1328 lptthit->ti.lpszText = NULL; /* FIXME */
1329 lptthit->ti.lParam = toolPtr->lParam;
1337 TOOLTIPS_NewToolRect32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1339 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1340 LPTTTOOLINFO32A lpti = (LPTTTOOLINFO32A)lParam;
1345 if (lpti->cbSize < TTTOOLINFO_V1_SIZE32A)
1348 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti);
1349 if (nTool == -1) return 0;
1351 infoPtr->tools[nTool].rect = lpti->rect;
1358 TOOLTIPS_NewToolRect32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1360 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1361 LPTTTOOLINFO32W lpti = (LPTTTOOLINFO32W)lParam;
1366 if (lpti->cbSize < TTTOOLINFO_V1_SIZE32W)
1369 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti);
1370 if (nTool == -1) return 0;
1372 infoPtr->tools[nTool].rect = lpti->rect;
1378 __inline__ static LRESULT
1379 TOOLTIPS_Pop (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1381 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1383 TOOLTIPS_Hide (wndPtr, infoPtr);
1390 TOOLTIPS_RelayEvent (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1392 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1393 LPMSG32 lpMsg = (LPMSG32)lParam;
1397 ERR (tooltips, "lpMsg == NULL!\n");
1401 switch (lpMsg->message) {
1402 case WM_LBUTTONDOWN:
1404 case WM_MBUTTONDOWN:
1406 case WM_RBUTTONDOWN:
1409 ScreenToClient32 (lpMsg->hwnd, &pt);
1410 infoPtr->nOldTool = infoPtr->nTool;
1411 infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
1412 TRACE (tooltips, "tool (%x) %d %d\n",
1413 wndPtr->hwndSelf, infoPtr->nOldTool, infoPtr->nTool);
1414 TOOLTIPS_Hide (wndPtr, infoPtr);
1419 ScreenToClient32 (lpMsg->hwnd, &pt);
1420 infoPtr->nOldTool = infoPtr->nTool;
1421 infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
1422 TRACE (tooltips, "tool (%x) %d %d\n",
1423 wndPtr->hwndSelf, infoPtr->nOldTool, infoPtr->nTool);
1424 TRACE (tooltips, "WM_MOUSEMOVE (%04x %d %d)\n",
1425 wndPtr->hwndSelf, pt.x, pt.y);
1426 if ((infoPtr->bActive) && (infoPtr->nTool != infoPtr->nOldTool)) {
1427 if (infoPtr->nOldTool == -1) {
1428 SetTimer32 (wndPtr->hwndSelf, ID_TIMERSHOW,
1429 infoPtr->nInitialTime, 0);
1430 TRACE (tooltips, "timer 1 started!\n");
1433 TOOLTIPS_Hide (wndPtr, infoPtr);
1434 SetTimer32 (wndPtr->hwndSelf, ID_TIMERSHOW,
1435 infoPtr->nReshowTime, 0);
1436 TRACE (tooltips, "timer 2 started!\n");
1439 if (infoPtr->nCurrentTool != -1) {
1440 SetTimer32 (wndPtr->hwndSelf, ID_TIMERLEAVE, 100, 0);
1441 TRACE (tooltips, "timer 3 started!\n");
1451 TOOLTIPS_SetDelayTime (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1453 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1454 INT32 nTime = (INT32)LOWORD(lParam);
1457 case TTDT_AUTOMATIC:
1459 infoPtr->nAutomaticTime = 500;
1460 infoPtr->nReshowTime = 100;
1461 infoPtr->nAutoPopTime = 5000;
1462 infoPtr->nInitialTime = 500;
1465 infoPtr->nAutomaticTime = nTime;
1466 infoPtr->nReshowTime = nTime / 5;
1467 infoPtr->nAutoPopTime = nTime * 10;
1468 infoPtr->nInitialTime = nTime;
1473 infoPtr->nReshowTime = nTime;
1477 infoPtr->nAutoPopTime = nTime;
1481 infoPtr->nInitialTime = nTime;
1490 TOOLTIPS_SetMargin (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1492 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1493 LPRECT32 lpRect = (LPRECT32)lParam;
1495 infoPtr->rcMargin.left = lpRect->left;
1496 infoPtr->rcMargin.right = lpRect->right;
1497 infoPtr->rcMargin.bottom = lpRect->bottom;
1498 infoPtr->rcMargin.top = lpRect->top;
1504 __inline__ static LRESULT
1505 TOOLTIPS_SetMaxTipWidth (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1507 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1508 INT32 nTemp = infoPtr->nMaxTipWidth;
1510 infoPtr->nMaxTipWidth = (INT32)lParam;
1516 __inline__ static LRESULT
1517 TOOLTIPS_SetTipBkColor (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1519 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1521 infoPtr->clrBk = (COLORREF)wParam;
1527 __inline__ static LRESULT
1528 TOOLTIPS_SetTipTextColor (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1530 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1532 infoPtr->clrText = (COLORREF)wParam;
1539 TOOLTIPS_SetToolInfo32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1541 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1542 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
1543 TTTOOL_INFO *toolPtr;
1546 if (lpToolInfo == NULL)
1548 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
1551 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1552 if (nTool == -1) return 0;
1554 TRACE (tooltips, "tool %d\n", nTool);
1556 toolPtr = &infoPtr->tools[nTool];
1558 /* copy tool data */
1559 toolPtr->uFlags = lpToolInfo->uFlags;
1560 toolPtr->hwnd = lpToolInfo->hwnd;
1561 toolPtr->uId = lpToolInfo->uId;
1562 toolPtr->rect = lpToolInfo->rect;
1563 toolPtr->hinst = lpToolInfo->hinst;
1565 if ((lpToolInfo->hinst) && (HIWORD((INT32)lpToolInfo->lpszText) == 0)) {
1566 TRACE (tooltips, "set string id %x!\n", (INT32)lpToolInfo->lpszText);
1567 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1569 else if (lpToolInfo->lpszText) {
1570 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACK32A)
1571 toolPtr->lpszText = LPSTR_TEXTCALLBACK32W;
1573 if (toolPtr->lpszText) {
1574 COMCTL32_Free (toolPtr->lpszText);
1575 toolPtr->lpszText = NULL;
1577 if (lpToolInfo->lpszText) {
1578 INT32 len = lstrlen32A (lpToolInfo->lpszText);
1579 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1580 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
1585 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32A))
1586 toolPtr->lParam = lpToolInfo->lParam;
1593 TOOLTIPS_SetToolInfo32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1595 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1596 LPTTTOOLINFO32W lpToolInfo = (LPTTTOOLINFO32W)lParam;
1597 TTTOOL_INFO *toolPtr;
1600 if (lpToolInfo == NULL)
1602 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32W)
1605 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1606 if (nTool == -1) return 0;
1608 TRACE (tooltips, "tool %d\n", nTool);
1610 toolPtr = &infoPtr->tools[nTool];
1612 /* copy tool data */
1613 toolPtr->uFlags = lpToolInfo->uFlags;
1614 toolPtr->hwnd = lpToolInfo->hwnd;
1615 toolPtr->uId = lpToolInfo->uId;
1616 toolPtr->rect = lpToolInfo->rect;
1617 toolPtr->hinst = lpToolInfo->hinst;
1619 if ((lpToolInfo->hinst) && (HIWORD((INT32)lpToolInfo->lpszText) == 0)) {
1620 TRACE (tooltips, "set string id %x!\n", (INT32)lpToolInfo->lpszText);
1621 toolPtr->lpszText = lpToolInfo->lpszText;
1623 else if (lpToolInfo->lpszText) {
1624 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACK32W)
1625 toolPtr->lpszText = LPSTR_TEXTCALLBACK32W;
1627 if (toolPtr->lpszText) {
1628 COMCTL32_Free (toolPtr->lpszText);
1629 toolPtr->lpszText = NULL;
1631 if (lpToolInfo->lpszText) {
1632 INT32 len = lstrlen32W (lpToolInfo->lpszText);
1633 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1634 lstrcpy32W (toolPtr->lpszText, lpToolInfo->lpszText);
1639 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO32W))
1640 toolPtr->lParam = lpToolInfo->lParam;
1647 TOOLTIPS_TrackActivate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1649 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1650 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
1652 if (lpToolInfo == NULL)
1654 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
1657 if ((BOOL32)wParam) {
1659 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1660 if (infoPtr->nTrackTool != -1) {
1661 TRACE (tooltips, "activated!\n");
1662 infoPtr->bTrackActive = TRUE;
1663 TOOLTIPS_TrackShow (wndPtr, infoPtr);
1668 TOOLTIPS_TrackHide (wndPtr, infoPtr);
1670 infoPtr->bTrackActive = FALSE;
1671 infoPtr->nTrackTool = -1;
1673 TRACE (tooltips, "deactivated!\n");
1681 TOOLTIPS_TrackPosition (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1683 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1685 infoPtr->xTrackPos = (INT32)LOWORD(lParam);
1686 infoPtr->yTrackPos = (INT32)HIWORD(lParam);
1688 if (infoPtr->bTrackActive) {
1689 TRACE (tooltips, "[%d %d]\n",
1690 infoPtr->xTrackPos, infoPtr->yTrackPos);
1692 TOOLTIPS_TrackShow (wndPtr, infoPtr);
1700 TOOLTIPS_Update (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1702 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1704 if (infoPtr->nCurrentTool != -1)
1705 UpdateWindow32 (wndPtr->hwndSelf);
1712 TOOLTIPS_UpdateTipText32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1714 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1715 LPTTTOOLINFO32A lpToolInfo = (LPTTTOOLINFO32A)lParam;
1716 TTTOOL_INFO *toolPtr;
1719 if (lpToolInfo == NULL)
1721 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32A)
1724 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1725 if (nTool == -1) return 0;
1727 TRACE (tooltips, "tool %d\n", nTool);
1729 toolPtr = &infoPtr->tools[nTool];
1731 /* copy tool text */
1732 toolPtr->hinst = lpToolInfo->hinst;
1734 if ((lpToolInfo->hinst) && (HIWORD((INT32)lpToolInfo->lpszText) == 0)){
1735 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1737 else if (lpToolInfo->lpszText) {
1738 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACK32A)
1739 toolPtr->lpszText = LPSTR_TEXTCALLBACK32W;
1741 if (toolPtr->lpszText) {
1742 COMCTL32_Free (toolPtr->lpszText);
1743 toolPtr->lpszText = NULL;
1745 if (lpToolInfo->lpszText) {
1746 INT32 len = lstrlen32A (lpToolInfo->lpszText);
1747 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1748 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
1754 if (infoPtr->bActive)
1755 TOOLTIPS_Show (wndPtr, infoPtr);
1756 else if (infoPtr->bTrackActive)
1757 TOOLTIPS_TrackShow (wndPtr, infoPtr);
1764 TOOLTIPS_UpdateTipText32W (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1766 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1767 LPTTTOOLINFO32W lpToolInfo = (LPTTTOOLINFO32W)lParam;
1768 TTTOOL_INFO *toolPtr;
1771 if (lpToolInfo == NULL)
1773 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE32W)
1776 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1780 TRACE (tooltips, "tool %d\n", nTool);
1782 toolPtr = &infoPtr->tools[nTool];
1784 /* copy tool text */
1785 toolPtr->hinst = lpToolInfo->hinst;
1787 if ((lpToolInfo->hinst) && (HIWORD((INT32)lpToolInfo->lpszText) == 0)){
1788 toolPtr->lpszText = lpToolInfo->lpszText;
1790 else if (lpToolInfo->lpszText) {
1791 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACK32W)
1792 toolPtr->lpszText = LPSTR_TEXTCALLBACK32W;
1794 if (toolPtr->lpszText) {
1795 COMCTL32_Free (toolPtr->lpszText);
1796 toolPtr->lpszText = NULL;
1798 if (lpToolInfo->lpszText) {
1799 INT32 len = lstrlen32W (lpToolInfo->lpszText);
1800 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1801 lstrcpy32W (toolPtr->lpszText, lpToolInfo->lpszText);
1807 if (infoPtr->bActive)
1808 TOOLTIPS_Show (wndPtr, infoPtr);
1809 else if (infoPtr->bTrackActive)
1810 TOOLTIPS_TrackShow (wndPtr, infoPtr);
1817 TOOLTIPS_WindowFromPoint (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1819 return WindowFromPoint32 (*((LPPOINT32)lParam));
1825 TOOLTIPS_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1827 TOOLTIPS_INFO *infoPtr;
1828 NONCLIENTMETRICS32A nclm;
1831 /* allocate memory for info structure */
1832 infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc (sizeof(TOOLTIPS_INFO));
1833 wndPtr->wExtra[0] = (DWORD)infoPtr;
1835 if (infoPtr == NULL) {
1836 ERR (tooltips, "could not allocate info memory!\n");
1840 /* initialize info structure */
1841 infoPtr->bActive = TRUE;
1842 infoPtr->bTrackActive = FALSE;
1843 infoPtr->clrBk = GetSysColor32 (COLOR_INFOBK);
1844 infoPtr->clrText = GetSysColor32 (COLOR_INFOTEXT);
1846 nclm.cbSize = sizeof(NONCLIENTMETRICS32A);
1847 SystemParametersInfo32A (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
1848 infoPtr->hFont = CreateFontIndirect32A (&nclm.lfStatusFont);
1850 infoPtr->nMaxTipWidth = -1;
1851 infoPtr->nTool = -1;
1852 infoPtr->nOldTool = -1;
1853 infoPtr->nCurrentTool = -1;
1854 infoPtr->nTrackTool = -1;
1856 infoPtr->nAutomaticTime = 500;
1857 infoPtr->nReshowTime = 100;
1858 infoPtr->nAutoPopTime = 5000;
1859 infoPtr->nInitialTime = 500;
1862 (INT32) SendMessage32A (wndPtr->parent->hwndSelf, WM_NOTIFYFORMAT,
1863 (WPARAM32)wndPtr->hwndSelf, (LPARAM)NF_QUERY);
1864 if (nResult == NFR_ANSI)
1865 FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1866 else if (nResult == NFR_UNICODE)
1867 FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1869 FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n");
1871 SetWindowPos32 (wndPtr->hwndSelf, HWND_TOP, 0, 0, 0, 0,
1872 SWP_NOZORDER | SWP_HIDEWINDOW);
1879 TOOLTIPS_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1881 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1882 TTTOOL_INFO *toolPtr;
1886 if (infoPtr->tools) {
1887 for (i = 0; i < infoPtr->uNumTools; i++) {
1888 toolPtr = &infoPtr->tools[i];
1889 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
1890 if (toolPtr->lpszText != LPSTR_TEXTCALLBACK32W)
1891 COMCTL32_Free (toolPtr->lpszText);
1894 /* remove subclassing */
1895 if (toolPtr->uFlags & TTF_SUBCLASS) {
1896 LPTT_SUBCLASS_INFO lpttsi;
1898 if (toolPtr->uFlags & TTF_IDISHWND)
1899 lpttsi = (LPTT_SUBCLASS_INFO)GetProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
1901 lpttsi = (LPTT_SUBCLASS_INFO)GetProp32A (toolPtr->hwnd, COMCTL32_aSubclass);
1904 SetWindowLong32A ((HWND32)toolPtr->uId, GWL_WNDPROC,
1905 (LONG)lpttsi->wpOrigProc);
1906 RemoveProp32A ((HWND32)toolPtr->uId, COMCTL32_aSubclass);
1907 COMCTL32_Free (&lpttsi);
1911 COMCTL32_Free (infoPtr->tools);
1915 DeleteObject32 (infoPtr->hFont);
1917 /* free tool tips info data */
1918 COMCTL32_Free (infoPtr);
1925 TOOLTIPS_EraseBackground (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1927 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1931 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
1932 GetClientRect32 (wndPtr->hwndSelf, &rect);
1933 FillRect32 ((HDC32)wParam, &rect, hBrush);
1934 DeleteObject32 (hBrush);
1941 TOOLTIPS_GetFont (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1943 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1945 return infoPtr->hFont;
1950 TOOLTIPS_MouseMessage (WND *wndPtr, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
1952 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1954 TOOLTIPS_Hide (wndPtr, infoPtr);
1961 TOOLTIPS_NCCreate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1963 wndPtr->dwStyle &= 0x0000FFFF;
1964 wndPtr->dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS);
1971 TOOLTIPS_NCHitTest (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1973 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
1974 INT32 nTool = (infoPtr->bTrackActive) ? infoPtr->nTrackTool : infoPtr->nTool;
1976 TRACE (tooltips, " nTool=%d\n", nTool);
1978 if ((nTool > -1) && (nTool < infoPtr->uNumTools)) {
1979 if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
1980 TRACE (tooltips, "-- in transparent mode!\n");
1981 return HTTRANSPARENT;
1985 return DefWindowProc32A (wndPtr->hwndSelf, WM_NCHITTEST, wParam, lParam);
1990 TOOLTIPS_Paint (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1995 hdc = (wParam == 0) ? BeginPaint32 (wndPtr->hwndSelf, &ps) : (HDC32)wParam;
1996 TOOLTIPS_Refresh (wndPtr, hdc);
1998 EndPaint32 (wndPtr->hwndSelf, &ps);
2004 TOOLTIPS_SetFont (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2006 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
2008 infoPtr->hFont = (HFONT32)wParam;
2010 if ((LOWORD(lParam)) & (infoPtr->nCurrentTool != -1)) {
2011 FIXME (tooltips, "full redraw needed!\n");
2019 TOOLTIPS_Timer (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2021 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
2023 TRACE (tooltips, "timer %d (%x) expired!\n", wParam, wndPtr->hwndSelf);
2028 KillTimer32 (wndPtr->hwndSelf, ID_TIMERSHOW);
2029 if (TOOLTIPS_CheckTool (wndPtr, TRUE) == infoPtr->nTool)
2030 TOOLTIPS_Show (wndPtr, infoPtr);
2034 TOOLTIPS_Hide (wndPtr, infoPtr);
2038 KillTimer32 (wndPtr->hwndSelf, ID_TIMERLEAVE);
2039 if (TOOLTIPS_CheckTool (wndPtr, FALSE) == -1) {
2040 infoPtr->nTool = -1;
2041 infoPtr->nOldTool = -1;
2042 TOOLTIPS_Hide (wndPtr, infoPtr);
2051 TOOLTIPS_WinIniChange (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2053 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
2054 NONCLIENTMETRICS32A nclm;
2056 infoPtr->clrBk = GetSysColor32 (COLOR_INFOBK);
2057 infoPtr->clrText = GetSysColor32 (COLOR_INFOTEXT);
2059 DeleteObject32 (infoPtr->hFont);
2060 nclm.cbSize = sizeof(NONCLIENTMETRICS32A);
2061 SystemParametersInfo32A (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
2062 infoPtr->hFont = CreateFontIndirect32A (&nclm.lfStatusFont);
2069 TOOLTIPS_SubclassProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
2071 LPTT_SUBCLASS_INFO lpttsi =
2072 (LPTT_SUBCLASS_INFO)GetProp32A (hwnd, COMCTL32_aSubclass);
2074 TOOLTIPS_INFO *infoPtr;
2078 case WM_LBUTTONDOWN:
2080 case WM_MBUTTONDOWN:
2082 case WM_RBUTTONDOWN:
2085 wndPtr = WIN_FindWndPtr(lpttsi->hwndToolTip);
2086 infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
2087 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
2089 TRACE (tooltips, "subclassed mouse message %04x\n", uMsg);
2090 infoPtr->nOldTool = infoPtr->nTool;
2091 infoPtr->nTool = nTool;
2092 TOOLTIPS_Hide (wndPtr, infoPtr);
2098 wndPtr = WIN_FindWndPtr(lpttsi->hwndToolTip);
2099 infoPtr = TOOLTIPS_GetInfoPtr(wndPtr);
2100 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
2102 TRACE (tooltips, "subclassed WM_MOUSEMOVE\n");
2103 infoPtr->nOldTool = infoPtr->nTool;
2104 infoPtr->nTool = nTool;
2106 if ((infoPtr->bActive) &&
2107 (infoPtr->nTool != infoPtr->nOldTool)) {
2108 if (infoPtr->nOldTool == -1) {
2109 SetTimer32 (wndPtr->hwndSelf, ID_TIMERSHOW,
2110 infoPtr->nInitialTime, 0);
2111 TRACE (tooltips, "timer 1 started!\n");
2114 TOOLTIPS_Hide (wndPtr, infoPtr);
2115 SetTimer32 (wndPtr->hwndSelf, ID_TIMERSHOW,
2116 infoPtr->nReshowTime, 0);
2117 TRACE (tooltips, "timer 2 started!\n");
2120 if (infoPtr->nCurrentTool != -1) {
2121 SetTimer32 (wndPtr->hwndSelf, ID_TIMERLEAVE, 100, 0);
2122 TRACE (tooltips, "timer 3 started!\n");
2128 return CallWindowProc32A (lpttsi->wpOrigProc, hwnd, uMsg, wParam, lParam);
2133 TOOLTIPS_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
2135 WND *wndPtr = WIN_FindWndPtr(hwnd);
2140 return TOOLTIPS_Activate (wndPtr, wParam, lParam);
2142 case TTM_ADDTOOL32A:
2143 return TOOLTIPS_AddTool32A (wndPtr, wParam, lParam);
2145 case TTM_ADDTOOL32W:
2146 return TOOLTIPS_AddTool32W (wndPtr, wParam, lParam);
2148 case TTM_DELTOOL32A:
2149 return TOOLTIPS_DelTool32A (wndPtr, wParam, lParam);
2151 case TTM_DELTOOL32W:
2152 return TOOLTIPS_DelTool32W (wndPtr, wParam, lParam);
2154 case TTM_ENUMTOOLS32A:
2155 return TOOLTIPS_EnumTools32A (wndPtr, wParam, lParam);
2157 case TTM_ENUMTOOLS32W:
2158 return TOOLTIPS_EnumTools32W (wndPtr, wParam, lParam);
2160 case TTM_GETCURRENTTOOL32A:
2161 return TOOLTIPS_GetCurrentTool32A (wndPtr, wParam, lParam);
2163 case TTM_GETCURRENTTOOL32W:
2164 return TOOLTIPS_GetCurrentTool32W (wndPtr, wParam, lParam);
2166 case TTM_GETDELAYTIME:
2167 return TOOLTIPS_GetDelayTime (wndPtr, wParam, lParam);
2170 return TOOLTIPS_GetMargin (wndPtr, wParam, lParam);
2172 case TTM_GETMAXTIPWIDTH:
2173 return TOOLTIPS_GetMaxTipWidth (wndPtr, wParam, lParam);
2175 case TTM_GETTEXT32A:
2176 return TOOLTIPS_GetText32A (wndPtr, wParam, lParam);
2178 case TTM_GETTEXT32W:
2179 return TOOLTIPS_GetText32W (wndPtr, wParam, lParam);
2181 case TTM_GETTIPBKCOLOR:
2182 return TOOLTIPS_GetTipBkColor (wndPtr, wParam, lParam);
2184 case TTM_GETTIPTEXTCOLOR:
2185 return TOOLTIPS_GetTipTextColor (wndPtr, wParam, lParam);
2187 case TTM_GETTOOLCOUNT:
2188 return TOOLTIPS_GetToolCount (wndPtr, wParam, lParam);
2190 case TTM_GETTOOLINFO32A:
2191 return TOOLTIPS_GetToolInfo32A (wndPtr, wParam, lParam);
2193 case TTM_GETTOOLINFO32W:
2194 return TOOLTIPS_GetToolInfo32W (wndPtr, wParam, lParam);
2196 case TTM_HITTEST32A:
2197 return TOOLTIPS_HitTest32A (wndPtr, wParam, lParam);
2199 case TTM_HITTEST32W:
2200 return TOOLTIPS_HitTest32W (wndPtr, wParam, lParam);
2202 case TTM_NEWTOOLRECT32A:
2203 return TOOLTIPS_NewToolRect32A (wndPtr, wParam, lParam);
2205 case TTM_NEWTOOLRECT32W:
2206 return TOOLTIPS_NewToolRect32W (wndPtr, wParam, lParam);
2209 return TOOLTIPS_Pop (wndPtr, wParam, lParam);
2211 case TTM_RELAYEVENT:
2212 return TOOLTIPS_RelayEvent (wndPtr, wParam, lParam);
2214 case TTM_SETDELAYTIME:
2215 return TOOLTIPS_SetDelayTime (wndPtr, wParam, lParam);
2218 return TOOLTIPS_SetMargin (wndPtr, wParam, lParam);
2220 case TTM_SETMAXTIPWIDTH:
2221 return TOOLTIPS_SetMaxTipWidth (wndPtr, wParam, lParam);
2223 case TTM_SETTIPBKCOLOR:
2224 return TOOLTIPS_SetTipBkColor (wndPtr, wParam, lParam);
2226 case TTM_SETTIPTEXTCOLOR:
2227 return TOOLTIPS_SetTipTextColor (wndPtr, wParam, lParam);
2229 case TTM_SETTOOLINFO32A:
2230 return TOOLTIPS_SetToolInfo32A (wndPtr, wParam, lParam);
2232 case TTM_SETTOOLINFO32W:
2233 return TOOLTIPS_SetToolInfo32W (wndPtr, wParam, lParam);
2235 case TTM_TRACKACTIVATE:
2236 return TOOLTIPS_TrackActivate (wndPtr, wParam, lParam);
2238 case TTM_TRACKPOSITION:
2239 return TOOLTIPS_TrackPosition (wndPtr, wParam, lParam);
2242 return TOOLTIPS_Update (wndPtr, wParam, lParam);
2244 case TTM_UPDATETIPTEXT32A:
2245 return TOOLTIPS_UpdateTipText32A (wndPtr, wParam, lParam);
2247 case TTM_UPDATETIPTEXT32W:
2248 return TOOLTIPS_UpdateTipText32W (wndPtr, wParam, lParam);
2250 case TTM_WINDOWFROMPOINT:
2251 return TOOLTIPS_WindowFromPoint (wndPtr, wParam, lParam);
2255 return TOOLTIPS_Create (wndPtr, wParam, lParam);
2258 return TOOLTIPS_Destroy (wndPtr, wParam, lParam);
2261 return TOOLTIPS_EraseBackground (wndPtr, wParam, lParam);
2264 return TOOLTIPS_GetFont (wndPtr, wParam, lParam);
2266 case WM_LBUTTONDOWN:
2268 case WM_MBUTTONDOWN:
2270 case WM_RBUTTONDOWN:
2273 return TOOLTIPS_MouseMessage (wndPtr, uMsg, wParam, lParam);
2276 return TOOLTIPS_NCCreate (wndPtr, wParam, lParam);
2279 return TOOLTIPS_NCHitTest (wndPtr, wParam, lParam);
2281 /* case WM_NOTIFYFORMAT: */
2282 /* return TOOLTIPS_NotifyFormat (wndPtr, wParam, lParam); */
2285 return TOOLTIPS_Paint (wndPtr, wParam, lParam);
2288 return TOOLTIPS_SetFont (wndPtr, wParam, lParam);
2291 return TOOLTIPS_Timer (wndPtr, wParam, lParam);
2293 case WM_WININICHANGE:
2294 return TOOLTIPS_WinIniChange (wndPtr, wParam, lParam);
2297 if (uMsg >= WM_USER)
2298 ERR (tooltips, "unknown msg %04x wp=%08x lp=%08lx\n",
2299 uMsg, wParam, lParam);
2300 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
2307 TOOLTIPS_Register (VOID)
2309 WNDCLASS32A wndClass;
2311 if (GlobalFindAtom32A (TOOLTIPS_CLASS32A)) return;
2313 ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
2314 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
2315 wndClass.lpfnWndProc = (WNDPROC32)TOOLTIPS_WindowProc;
2316 wndClass.cbClsExtra = 0;
2317 wndClass.cbWndExtra = sizeof(TOOLTIPS_INFO *);
2318 wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
2319 wndClass.hbrBackground = 0;
2320 wndClass.lpszClassName = TOOLTIPS_CLASS32A;
2322 RegisterClass32A (&wndClass);
2327 TOOLTIPS_Unregister (VOID)
2329 if (GlobalFindAtom32A (TOOLTIPS_CLASS32A))
2330 UnregisterClass32A (TOOLTIPS_CLASS32A, (HINSTANCE32)NULL);