4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 2004 Robert Shearman
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Sep. 08, 2004, by Robert Shearman.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features or bugs please note them below.
31 * - Custom draw support.
45 * - Run tests using Waite Group Windows95 API Bible Volume 2.
46 * The second cdrom (chapter 3) contains executables activate.exe,
47 * curtool.exe, deltool.exe, enumtools.exe, getinfo.exe, getiptxt.exe,
48 * hittest.exe, needtext.exe, newrect.exe, updtext.exe and winfrpt.exe.
52 * One important point to remember is that tools don't necessarily get
53 * a WM_MOUSEMOVE once the cursor leaves the tool, an example is when
54 * a tool sets TTF_IDISHWND (i.e. an entire window is a tool) because
55 * here WM_MOUSEMOVEs only get sent when the cursor is inside the
56 * client area. Therefore the only reliable way to know that the
57 * cursor has left a tool is to keep a timer running and check the
58 * position every time it expires. This is the role of timer
62 * On entering a tool (detected in a relayed WM_MOUSEMOVE) we start
63 * ID_TIMERSHOW, if this times out and we're still in the tool we show
64 * the tip. On showing a tip we start both ID_TIMERPOP and
65 * ID_TIMERLEAVE. On hiding a tooltip we kill ID_TIMERPOP.
66 * ID_TIMERPOP is restarted on every relayed WM_MOUSEMOVE. If
67 * ID_TIMERPOP expires the tool is hidden and ID_TIMERPOP is killed.
68 * ID_TIMERLEAVE remains running - this is important as we need to
69 * determine when the cursor leaves the tool.
71 * When ID_TIMERLEAVE expires or on a relayed WM_MOUSEMOVE if we're
72 * still in the tool do nothing (apart from restart ID_TIMERPOP if
73 * this is a WM_MOUSEMOVE) (ID_TIMERLEAVE remains running). If we've
74 * left the tool and entered another one then hide the tip and start
75 * ID_TIMERSHOW with time ReshowTime and kill ID_TIMERLEAVE. If we're
76 * outside all tools hide the tip and kill ID_TIMERLEAVE. On Relayed
77 * mouse button messages hide the tip but leave ID_TIMERLEAVE running,
78 * this again will let us keep track of when the cursor leaves the
82 * infoPtr->nTool is the tool the mouse was on on the last relayed MM
83 * or timer expiry or -1 if the mouse was not on a tool.
85 * infoPtr->nCurrentTool is the tool for which the tip is currently
86 * displaying text for or -1 if the tip is not shown. Actually this
87 * will only ever be infoPtr-nTool or -1, so it could be changed to a
99 #include "wine/unicode.h"
103 #include "commctrl.h"
104 #include "comctl32.h"
105 #include "wine/debug.h"
107 WINE_DEFAULT_DEBUG_CHANNEL(tooltips);
109 static HICON hTooltipIcons[TTI_ERROR+1];
126 WCHAR szTipText[INFOTIPSIZE];
137 INT nTool; /* tool that mouse was on on last relayed mouse move */
151 #define ID_TIMERSHOW 1 /* show delay timer */
152 #define ID_TIMERPOP 2 /* auto pop timer */
153 #define ID_TIMERLEAVE 3 /* tool leave timer */
156 #define TOOLTIPS_GetInfoPtr(hWindow) ((TOOLTIPS_INFO *)GetWindowLongPtrW (hWindow, 0))
158 /* offsets from window edge to start of text */
159 #define NORMAL_TEXT_MARGIN 2
160 #define BALLOON_TEXT_MARGIN (NORMAL_TEXT_MARGIN+8)
161 /* value used for CreateRoundRectRgn that specifies how much
162 * each corner is curved */
163 #define BALLOON_ROUNDEDNESS 20
164 #define BALLOON_STEMHEIGHT 13
165 #define BALLOON_STEMWIDTH 10
166 #define BALLOON_STEMINDENT 20
168 #define BALLOON_ICON_TITLE_SPACING 8 /* horizontal spacing between icon and title */
169 #define BALLOON_TITLE_TEXT_SPACING 8 /* vertical spacing between icon/title and main text */
170 #define ICON_HEIGHT 16
171 #define ICON_WIDTH 16
173 static LRESULT CALLBACK
174 TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uId, DWORD_PTR dwRef);
177 static inline UINT_PTR
178 TOOLTIPS_GetTitleIconIndex(HICON hIcon)
181 for (i = 0; i <= TTI_ERROR; i++)
182 if (hTooltipIcons[i] == hIcon)
184 return (UINT_PTR)hIcon;
188 TOOLTIPS_InitSystemSettings (TOOLTIPS_INFO *infoPtr)
190 NONCLIENTMETRICSW nclm;
192 infoPtr->clrBk = GetSysColor (COLOR_INFOBK);
193 infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);
195 DeleteObject (infoPtr->hFont);
196 nclm.cbSize = sizeof(nclm);
197 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof(nclm), &nclm, 0);
198 infoPtr->hFont = CreateFontIndirectW (&nclm.lfStatusFont);
200 DeleteObject (infoPtr->hTitleFont);
201 nclm.lfStatusFont.lfWeight = FW_BOLD;
202 infoPtr->hTitleFont = CreateFontIndirectW (&nclm.lfStatusFont);
206 TOOLTIPS_Refresh (HWND hwnd, HDC hdc)
208 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
213 UINT uFlags = DT_EXTERNALLEADING;
215 DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
217 if (infoPtr->nMaxTipWidth > -1)
218 uFlags |= DT_WORDBREAK;
219 if (GetWindowLongW (hwnd, GWL_STYLE) & TTS_NOPREFIX)
220 uFlags |= DT_NOPREFIX;
221 GetClientRect (hwnd, &rc);
223 hBrush = CreateSolidBrush(infoPtr->clrBk);
225 oldBkMode = SetBkMode (hdc, TRANSPARENT);
226 SetTextColor (hdc, infoPtr->clrText);
228 if (dwStyle & TTS_BALLOON)
230 /* create a region to store result into */
231 hRgn = CreateRectRgn(0, 0, 0, 0);
233 GetWindowRgn(hwnd, hRgn);
235 /* fill the background */
236 FillRgn(hdc, hRgn, hBrush);
237 DeleteObject(hBrush);
242 /* fill the background */
243 FillRect(hdc, &rc, hBrush);
244 DeleteObject(hBrush);
248 if ((dwStyle & TTS_BALLOON) || infoPtr->pszTitle)
250 /* calculate text rectangle */
251 rc.left += (BALLOON_TEXT_MARGIN + infoPtr->rcMargin.left);
252 rc.top += (BALLOON_TEXT_MARGIN + infoPtr->rcMargin.top);
253 rc.right -= (BALLOON_TEXT_MARGIN + infoPtr->rcMargin.right);
254 rc.bottom -= (BALLOON_TEXT_MARGIN + infoPtr->rcMargin.bottom);
255 if(infoPtr->bToolBelow) rc.top += BALLOON_STEMHEIGHT;
257 if (infoPtr->pszTitle)
259 RECT rcTitle = {rc.left, rc.top, rc.right, rc.bottom};
264 icon_present = infoPtr->hTitleIcon &&
265 DrawIconEx(hdc, rc.left, rc.top, infoPtr->hTitleIcon,
266 ICON_WIDTH, ICON_HEIGHT, 0, NULL, DI_NORMAL);
268 rcTitle.left += ICON_WIDTH + BALLOON_ICON_TITLE_SPACING;
270 rcTitle.bottom = rc.top + ICON_HEIGHT;
272 /* draw title text */
273 hOldFont = SelectObject (hdc, infoPtr->hTitleFont);
274 height = DrawTextW(hdc, infoPtr->pszTitle, -1, &rcTitle, DT_BOTTOM | DT_SINGLELINE | DT_NOPREFIX);
275 SelectObject (hdc, hOldFont);
276 rc.top += height + BALLOON_TITLE_TEXT_SPACING;
281 /* calculate text rectangle */
282 rc.left += (NORMAL_TEXT_MARGIN + infoPtr->rcMargin.left);
283 rc.top += (NORMAL_TEXT_MARGIN + infoPtr->rcMargin.top);
284 rc.right -= (NORMAL_TEXT_MARGIN + infoPtr->rcMargin.right);
285 rc.bottom -= (NORMAL_TEXT_MARGIN + infoPtr->rcMargin.bottom);
289 hOldFont = SelectObject (hdc, infoPtr->hFont);
290 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
291 /* be polite and reset the things we changed in the dc */
292 SelectObject (hdc, hOldFont);
293 SetBkMode (hdc, oldBkMode);
295 if (dwStyle & TTS_BALLOON)
297 /* frame region because default window proc doesn't do it */
298 INT width = GetSystemMetrics(SM_CXDLGFRAME) - GetSystemMetrics(SM_CXEDGE);
299 INT height = GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYEDGE);
301 hBrush = GetSysColorBrush(COLOR_WINDOWFRAME);
302 FrameRgn(hdc, hRgn, hBrush, width, height);
309 static void TOOLTIPS_GetDispInfoA(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO *toolPtr)
311 NMTTDISPINFOA ttnmdi;
313 /* fill NMHDR struct */
314 ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
315 ttnmdi.hdr.hwndFrom = hwnd;
316 ttnmdi.hdr.idFrom = toolPtr->uId;
317 ttnmdi.hdr.code = TTN_GETDISPINFOA; /* == TTN_NEEDTEXTA */
318 ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
319 ttnmdi.uFlags = toolPtr->uFlags;
320 ttnmdi.lParam = toolPtr->lParam;
322 TRACE("hdr.idFrom = %lx\n", ttnmdi.hdr.idFrom);
323 SendMessageW(toolPtr->hwnd, WM_NOTIFY,
324 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
326 if (IS_INTRESOURCE(ttnmdi.lpszText)) {
327 LoadStringW(ttnmdi.hinst, LOWORD(ttnmdi.lpszText),
328 infoPtr->szTipText, INFOTIPSIZE);
329 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
330 toolPtr->hinst = ttnmdi.hinst;
331 toolPtr->lpszText = (LPWSTR)ttnmdi.lpszText;
334 else if (ttnmdi.lpszText == 0) {
335 infoPtr->szTipText[0] = '\0';
337 else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
338 Str_GetPtrAtoW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE);
339 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
341 toolPtr->lpszText = NULL;
342 Str_SetPtrW(&toolPtr->lpszText, infoPtr->szTipText);
346 ERR("recursive text callback!\n");
347 infoPtr->szTipText[0] = '\0';
350 /* no text available - try calling parent instead as per native */
351 /* FIXME: Unsure if SETITEM should save the value or not */
352 if (infoPtr->szTipText[0] == 0x00) {
354 SendMessageW(GetParent(toolPtr->hwnd), WM_NOTIFY,
355 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
357 if (IS_INTRESOURCE(ttnmdi.lpszText)) {
358 LoadStringW(ttnmdi.hinst, LOWORD(ttnmdi.lpszText),
359 infoPtr->szTipText, INFOTIPSIZE);
360 } else if (ttnmdi.lpszText &&
361 ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
362 Str_GetPtrAtoW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE);
367 static void TOOLTIPS_GetDispInfoW(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO *toolPtr)
369 NMTTDISPINFOW ttnmdi;
371 /* fill NMHDR struct */
372 ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOW));
373 ttnmdi.hdr.hwndFrom = hwnd;
374 ttnmdi.hdr.idFrom = toolPtr->uId;
375 ttnmdi.hdr.code = TTN_GETDISPINFOW; /* == TTN_NEEDTEXTW */
376 ttnmdi.lpszText = (LPWSTR)&ttnmdi.szText;
377 ttnmdi.uFlags = toolPtr->uFlags;
378 ttnmdi.lParam = toolPtr->lParam;
380 TRACE("hdr.idFrom = %lx\n", ttnmdi.hdr.idFrom);
381 SendMessageW(toolPtr->hwnd, WM_NOTIFY,
382 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
384 if (IS_INTRESOURCE(ttnmdi.lpszText)) {
385 LoadStringW(ttnmdi.hinst, LOWORD(ttnmdi.lpszText),
386 infoPtr->szTipText, INFOTIPSIZE);
387 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
388 toolPtr->hinst = ttnmdi.hinst;
389 toolPtr->lpszText = ttnmdi.lpszText;
392 else if (ttnmdi.lpszText == 0) {
393 infoPtr->szTipText[0] = '\0';
395 else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) {
396 Str_GetPtrW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE);
397 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
399 toolPtr->lpszText = NULL;
400 Str_SetPtrW(&toolPtr->lpszText, infoPtr->szTipText);
404 ERR("recursive text callback!\n");
405 infoPtr->szTipText[0] = '\0';
408 /* no text available - try calling parent instead as per native */
409 /* FIXME: Unsure if SETITEM should save the value or not */
410 if (infoPtr->szTipText[0] == 0x00) {
412 SendMessageW(GetParent(toolPtr->hwnd), WM_NOTIFY,
413 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
415 if (IS_INTRESOURCE(ttnmdi.lpszText)) {
416 LoadStringW(ttnmdi.hinst, LOWORD(ttnmdi.lpszText),
417 infoPtr->szTipText, INFOTIPSIZE);
418 } else if (ttnmdi.lpszText &&
419 ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) {
420 Str_GetPtrW(ttnmdi.lpszText, infoPtr->szTipText, INFOTIPSIZE);
427 TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool)
429 TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
431 if (IS_INTRESOURCE(toolPtr->lpszText) && toolPtr->hinst) {
432 /* load a resource */
433 TRACE("load res string %p %x\n",
434 toolPtr->hinst, LOWORD(toolPtr->lpszText));
435 LoadStringW (toolPtr->hinst, LOWORD(toolPtr->lpszText),
436 infoPtr->szTipText, INFOTIPSIZE);
438 else if (toolPtr->lpszText) {
439 if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
440 if (toolPtr->bNotifyUnicode)
441 TOOLTIPS_GetDispInfoW(hwnd, infoPtr, toolPtr);
443 TOOLTIPS_GetDispInfoA(hwnd, infoPtr, toolPtr);
446 /* the item is a usual (unicode) text */
447 lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE);
451 /* no text available */
452 infoPtr->szTipText[0] = '\0';
455 TRACE("%s\n", debugstr_w(infoPtr->szTipText));
460 TOOLTIPS_CalcTipSize (HWND hwnd, const TOOLTIPS_INFO *infoPtr, LPSIZE lpSize)
464 DWORD style = GetWindowLongW(hwnd, GWL_STYLE);
465 UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT;
466 RECT rc = {0, 0, 0, 0};
469 if (infoPtr->nMaxTipWidth > -1) {
470 rc.right = infoPtr->nMaxTipWidth;
471 uFlags |= DT_WORDBREAK;
473 if (style & TTS_NOPREFIX)
474 uFlags |= DT_NOPREFIX;
475 TRACE("%s\n", debugstr_w(infoPtr->szTipText));
478 if (infoPtr->pszTitle)
480 RECT rcTitle = {0, 0, 0, 0};
481 TRACE("title %s\n", debugstr_w(infoPtr->pszTitle));
482 if (infoPtr->hTitleIcon)
484 title.cx = ICON_WIDTH;
485 title.cy = ICON_HEIGHT;
487 if (title.cx != 0) title.cx += BALLOON_ICON_TITLE_SPACING;
488 hOldFont = SelectObject (hdc, infoPtr->hTitleFont);
489 DrawTextW(hdc, infoPtr->pszTitle, -1, &rcTitle, DT_SINGLELINE | DT_NOPREFIX | DT_CALCRECT);
490 SelectObject (hdc, hOldFont);
491 title.cy = max(title.cy, rcTitle.bottom - rcTitle.top) + BALLOON_TITLE_TEXT_SPACING;
492 title.cx += (rcTitle.right - rcTitle.left);
494 hOldFont = SelectObject (hdc, infoPtr->hFont);
495 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
496 SelectObject (hdc, hOldFont);
497 ReleaseDC (hwnd, hdc);
499 if ((style & TTS_BALLOON) || infoPtr->pszTitle)
501 lpSize->cx = max(rc.right - rc.left, title.cx) + 2*BALLOON_TEXT_MARGIN +
502 infoPtr->rcMargin.left + infoPtr->rcMargin.right;
503 lpSize->cy = title.cy + rc.bottom - rc.top + 2*BALLOON_TEXT_MARGIN +
504 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top +
509 lpSize->cx = rc.right - rc.left + 2*NORMAL_TEXT_MARGIN +
510 infoPtr->rcMargin.left + infoPtr->rcMargin.right;
511 lpSize->cy = rc.bottom - rc.top + 2*NORMAL_TEXT_MARGIN +
512 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
518 TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate)
520 TTTOOL_INFO *toolPtr;
522 MONITORINFO mon_info;
527 DWORD style = GetWindowLongW(hwnd, GWL_STYLE);
532 if (infoPtr->nTrackTool == -1)
534 TRACE("invalid tracking tool (-1)!\n");
537 nTool = infoPtr->nTrackTool;
541 if (infoPtr->nTool == -1)
543 TRACE("invalid tool (-1)!\n");
546 nTool = infoPtr->nTool;
549 TRACE("Show tooltip pre %d! (%p)\n", nTool, hwnd);
551 TOOLTIPS_GetTipText (hwnd, infoPtr, nTool);
553 if (infoPtr->szTipText[0] == '\0')
556 toolPtr = &infoPtr->tools[nTool];
559 infoPtr->nCurrentTool = infoPtr->nTool;
561 TRACE("Show tooltip %d!\n", nTool);
564 hdr.idFrom = toolPtr->uId;
566 SendMessageW (toolPtr->hwnd, WM_NOTIFY,
567 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
569 TRACE("%s\n", debugstr_w(infoPtr->szTipText));
571 TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
572 TRACE("size %d x %d\n", size.cx, size.cy);
576 rect.left = infoPtr->xTrackPos;
577 rect.top = infoPtr->yTrackPos;
580 if (toolPtr->uFlags & TTF_CENTERTIP)
582 rect.left -= (size.cx / 2);
583 if (!(style & TTS_BALLOON))
584 rect.top -= (size.cy / 2);
586 infoPtr->bToolBelow = TRUE;
588 if (!(toolPtr->uFlags & TTF_ABSOLUTE))
590 if (style & TTS_BALLOON)
591 rect.left -= BALLOON_STEMINDENT;
596 if (toolPtr->uFlags & TTF_IDISHWND)
597 GetWindowRect ((HWND)toolPtr->uId, &rcTool);
600 rcTool = toolPtr->rect;
601 MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rcTool, 2);
604 /* smart placement */
605 if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
606 (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
607 rect.left = rcTool.right;
613 if (toolPtr->uFlags & TTF_CENTERTIP)
617 if (toolPtr->uFlags & TTF_IDISHWND)
618 GetWindowRect ((HWND)toolPtr->uId, &rc);
621 MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rc, 2);
623 rect.left = (rc.left + rc.right - size.cx) / 2;
624 if (style & TTS_BALLOON)
626 ptfx = rc.left + ((rc.right - rc.left) / 2);
628 /* CENTERTIP ballon tooltips default to below the field
629 * if they fit on the screen */
630 if (rc.bottom + size.cy > GetSystemMetrics(SM_CYSCREEN))
632 rect.top = rc.top - size.cy;
633 infoPtr->bToolBelow = FALSE;
637 infoPtr->bToolBelow = TRUE;
638 rect.top = rc.bottom;
640 rect.left = max(0, rect.left - BALLOON_STEMINDENT);
644 rect.top = rc.bottom + 2;
645 infoPtr->bToolBelow = TRUE;
650 GetCursorPos ((LPPOINT)&rect);
651 if (style & TTS_BALLOON)
654 if(rect.top - size.cy >= 0)
657 infoPtr->bToolBelow = FALSE;
661 infoPtr->bToolBelow = TRUE;
664 rect.left = max(0, rect.left - BALLOON_STEMINDENT);
669 infoPtr->bToolBelow = TRUE;
674 TRACE("pos %d - %d\n", rect.left, rect.top);
676 rect.right = rect.left + size.cx;
677 rect.bottom = rect.top + size.cy;
681 monitor = MonitorFromRect( &rect, MONITOR_DEFAULTTOPRIMARY );
682 mon_info.cbSize = sizeof(mon_info);
683 GetMonitorInfoW( monitor, &mon_info );
685 if( rect.right > mon_info.rcWork.right ) {
686 rect.left -= rect.right - mon_info.rcWork.right + 2;
687 rect.right = mon_info.rcWork.right - 2;
689 if (rect.left < mon_info.rcWork.left) rect.left = mon_info.rcWork.left;
691 if( rect.bottom > mon_info.rcWork.bottom ) {
694 if (toolPtr->uFlags & TTF_IDISHWND)
695 GetWindowRect ((HWND)toolPtr->uId, &rc);
698 MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rc, 2);
700 rect.bottom = rc.top - 2;
701 rect.top = rect.bottom - size.cy;
704 AdjustWindowRectEx (&rect, GetWindowLongW (hwnd, GWL_STYLE),
705 FALSE, GetWindowLongW (hwnd, GWL_EXSTYLE));
707 if (style & TTS_BALLOON)
715 if(infoPtr->bToolBelow)
719 pts[1].x = max(BALLOON_STEMINDENT, ptfx - (BALLOON_STEMWIDTH / 2));
720 pts[1].y = BALLOON_STEMHEIGHT;
721 pts[2].x = pts[1].x + BALLOON_STEMWIDTH;
723 if(pts[2].x > (rect.right - rect.left) - BALLOON_STEMINDENT)
725 pts[2].x = (rect.right - rect.left) - BALLOON_STEMINDENT;
726 pts[1].x = pts[2].x - BALLOON_STEMWIDTH;
731 pts[0].x = max(BALLOON_STEMINDENT, ptfx - (BALLOON_STEMWIDTH / 2));
732 pts[0].y = (rect.bottom - rect.top) - BALLOON_STEMHEIGHT;
733 pts[1].x = pts[0].x + BALLOON_STEMWIDTH;
736 pts[2].y = (rect.bottom - rect.top);
737 if(pts[1].x > (rect.right - rect.left) - BALLOON_STEMINDENT)
739 pts[1].x = (rect.right - rect.left) - BALLOON_STEMINDENT;
740 pts[0].x = pts[1].x - BALLOON_STEMWIDTH;
744 hrStem = CreatePolygonRgn(pts, sizeof(pts) / sizeof(pts[0]), ALTERNATE);
746 hRgn = CreateRoundRectRgn(0,
747 (infoPtr->bToolBelow ? BALLOON_STEMHEIGHT : 0),
748 rect.right - rect.left,
749 (infoPtr->bToolBelow ? rect.bottom - rect.top : rect.bottom - rect.top - BALLOON_STEMHEIGHT),
750 BALLOON_ROUNDEDNESS, BALLOON_ROUNDEDNESS);
752 CombineRgn(hRgn, hRgn, hrStem, RGN_OR);
753 DeleteObject(hrStem);
755 SetWindowRgn(hwnd, hRgn, FALSE);
756 /* we don't free the region handle as the system deletes it when
757 * it is no longer needed */
760 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
761 rect.right - rect.left, rect.bottom - rect.top,
762 SWP_SHOWWINDOW | SWP_NOACTIVATE);
764 /* repaint the tooltip */
765 InvalidateRect(hwnd, NULL, TRUE);
770 SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
771 TRACE("timer 2 started!\n");
772 SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0);
773 TRACE("timer 3 started!\n");
779 TOOLTIPS_Hide (HWND hwnd, TOOLTIPS_INFO *infoPtr)
781 TTTOOL_INFO *toolPtr;
784 TRACE("Hide tooltip %d! (%p)\n", infoPtr->nCurrentTool, hwnd);
786 if (infoPtr->nCurrentTool == -1)
789 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
790 KillTimer (hwnd, ID_TIMERPOP);
793 hdr.idFrom = toolPtr->uId;
795 SendMessageW (toolPtr->hwnd, WM_NOTIFY,
796 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
798 infoPtr->nCurrentTool = -1;
800 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
801 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
806 TOOLTIPS_TrackShow (HWND hwnd, TOOLTIPS_INFO *infoPtr)
808 TOOLTIPS_Show(hwnd, infoPtr, TRUE);
813 TOOLTIPS_TrackHide (HWND hwnd, const TOOLTIPS_INFO *infoPtr)
815 TTTOOL_INFO *toolPtr;
818 TRACE("hide tracking tooltip %d\n", infoPtr->nTrackTool);
820 if (infoPtr->nTrackTool == -1)
823 toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
826 hdr.idFrom = toolPtr->uId;
828 SendMessageW (toolPtr->hwnd, WM_NOTIFY,
829 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
831 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
832 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
837 TOOLTIPS_GetToolFromInfoA (const TOOLTIPS_INFO *infoPtr, const TTTOOLINFOA *lpToolInfo)
839 TTTOOL_INFO *toolPtr;
842 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
843 toolPtr = &infoPtr->tools[nTool];
845 if (!(toolPtr->uFlags & TTF_IDISHWND) &&
846 (lpToolInfo->hwnd == toolPtr->hwnd) &&
847 (lpToolInfo->uId == toolPtr->uId))
851 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
852 toolPtr = &infoPtr->tools[nTool];
854 if ((toolPtr->uFlags & TTF_IDISHWND) &&
855 (lpToolInfo->uId == toolPtr->uId))
864 TOOLTIPS_GetToolFromInfoW (const TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *lpToolInfo)
866 TTTOOL_INFO *toolPtr;
869 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
870 toolPtr = &infoPtr->tools[nTool];
872 if (!(toolPtr->uFlags & TTF_IDISHWND) &&
873 (lpToolInfo->hwnd == toolPtr->hwnd) &&
874 (lpToolInfo->uId == toolPtr->uId))
878 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
879 toolPtr = &infoPtr->tools[nTool];
881 if ((toolPtr->uFlags & TTF_IDISHWND) &&
882 (lpToolInfo->uId == toolPtr->uId))
891 TOOLTIPS_GetToolFromPoint (const TOOLTIPS_INFO *infoPtr, HWND hwnd, const POINT *lpPt)
893 TTTOOL_INFO *toolPtr;
896 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
897 toolPtr = &infoPtr->tools[nTool];
899 if (!(toolPtr->uFlags & TTF_IDISHWND)) {
900 if (hwnd != toolPtr->hwnd)
902 if (!PtInRect (&toolPtr->rect, *lpPt))
908 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
909 toolPtr = &infoPtr->tools[nTool];
911 if (toolPtr->uFlags & TTF_IDISHWND) {
912 if ((HWND)toolPtr->uId == hwnd)
922 TOOLTIPS_IsWindowActive (HWND hwnd)
924 HWND hwndActive = GetActiveWindow ();
927 if (hwndActive == hwnd)
929 return IsChild (hwndActive, hwnd);
934 TOOLTIPS_CheckTool (HWND hwnd, BOOL bShowTest)
936 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
942 hwndTool = (HWND)SendMessageW (hwnd, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt);
946 ScreenToClient (hwndTool, &pt);
947 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
951 if (!(GetWindowLongW (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) {
952 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER)))
956 TRACE("tool %d\n", nTool);
963 TOOLTIPS_Activate (HWND hwnd, WPARAM wParam, LPARAM lParam)
965 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
967 infoPtr->bActive = (BOOL)wParam;
969 if (infoPtr->bActive)
970 TRACE("activate!\n");
972 if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1))
973 TOOLTIPS_Hide (hwnd, infoPtr);
980 TOOLTIPS_AddToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
982 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
983 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
984 TTTOOL_INFO *toolPtr;
987 if (lpToolInfo == NULL)
989 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
992 TRACE("add tool (%p) %p %ld%s!\n",
993 hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
994 (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
996 if (infoPtr->uNumTools == 0) {
997 infoPtr->tools = Alloc (sizeof(TTTOOL_INFO));
998 toolPtr = infoPtr->tools;
1001 TTTOOL_INFO *oldTools = infoPtr->tools;
1003 Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
1004 memcpy (infoPtr->tools, oldTools,
1005 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
1007 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
1010 infoPtr->uNumTools++;
1012 /* copy tool data */
1013 toolPtr->uFlags = lpToolInfo->uFlags;
1014 toolPtr->hwnd = lpToolInfo->hwnd;
1015 toolPtr->uId = lpToolInfo->uId;
1016 toolPtr->rect = lpToolInfo->rect;
1017 toolPtr->hinst = lpToolInfo->hinst;
1019 if (IS_INTRESOURCE(lpToolInfo->lpszText)) {
1020 TRACE("add string id %x!\n", LOWORD(lpToolInfo->lpszText));
1021 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1023 else if (lpToolInfo->lpszText) {
1024 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) {
1025 TRACE("add CALLBACK!\n");
1026 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1029 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
1031 TRACE("add text \"%s\"!\n", lpToolInfo->lpszText);
1032 toolPtr->lpszText = Alloc (len * sizeof(WCHAR));
1033 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
1034 toolPtr->lpszText, len);
1038 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1039 toolPtr->lParam = lpToolInfo->lParam;
1041 /* install subclassing hook */
1042 if (toolPtr->uFlags & TTF_SUBCLASS) {
1043 if (toolPtr->uFlags & TTF_IDISHWND) {
1044 SetWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1,
1048 SetWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1,
1051 TRACE("subclassing installed!\n");
1054 nResult = (INT) SendMessageW (toolPtr->hwnd, WM_NOTIFYFORMAT,
1055 (WPARAM)hwnd, (LPARAM)NF_QUERY);
1056 if (nResult == NFR_ANSI) {
1057 toolPtr->bNotifyUnicode = FALSE;
1058 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1059 } else if (nResult == NFR_UNICODE) {
1060 toolPtr->bNotifyUnicode = TRUE;
1061 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1063 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1071 TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1073 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1074 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1075 TTTOOL_INFO *toolPtr;
1078 if (lpToolInfo == NULL)
1080 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
1083 TRACE("add tool (%p) %p %ld%s!\n",
1084 hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
1085 (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
1087 if (infoPtr->uNumTools == 0) {
1088 infoPtr->tools = Alloc (sizeof(TTTOOL_INFO));
1089 toolPtr = infoPtr->tools;
1092 TTTOOL_INFO *oldTools = infoPtr->tools;
1094 Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
1095 memcpy (infoPtr->tools, oldTools,
1096 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
1098 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
1101 infoPtr->uNumTools++;
1103 /* copy tool data */
1104 toolPtr->uFlags = lpToolInfo->uFlags;
1105 toolPtr->hwnd = lpToolInfo->hwnd;
1106 toolPtr->uId = lpToolInfo->uId;
1107 toolPtr->rect = lpToolInfo->rect;
1108 toolPtr->hinst = lpToolInfo->hinst;
1110 if (IS_INTRESOURCE(lpToolInfo->lpszText)) {
1111 TRACE("add string id %x\n", LOWORD(lpToolInfo->lpszText));
1112 toolPtr->lpszText = lpToolInfo->lpszText;
1114 else if (lpToolInfo->lpszText) {
1115 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
1116 TRACE("add CALLBACK!\n");
1117 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1120 INT len = lstrlenW (lpToolInfo->lpszText);
1121 TRACE("add text %s!\n",
1122 debugstr_w(lpToolInfo->lpszText));
1123 toolPtr->lpszText = Alloc ((len + 1)*sizeof(WCHAR));
1124 strcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
1128 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1129 toolPtr->lParam = lpToolInfo->lParam;
1131 /* install subclassing hook */
1132 if (toolPtr->uFlags & TTF_SUBCLASS) {
1133 if (toolPtr->uFlags & TTF_IDISHWND) {
1134 SetWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1,
1138 SetWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1,
1141 TRACE("subclassing installed!\n");
1144 nResult = (INT) SendMessageW (toolPtr->hwnd, WM_NOTIFYFORMAT,
1145 (WPARAM)hwnd, (LPARAM)NF_QUERY);
1146 if (nResult == NFR_ANSI) {
1147 toolPtr->bNotifyUnicode = FALSE;
1148 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1149 } else if (nResult == NFR_UNICODE) {
1150 toolPtr->bNotifyUnicode = TRUE;
1151 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1153 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1161 TOOLTIPS_DelToolCommon (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool)
1163 TTTOOL_INFO *toolPtr;
1165 TRACE("tool %d\n", nTool);
1170 /* make sure the tooltip has disappeared before deleting it */
1171 TOOLTIPS_Hide(hwnd, infoPtr);
1173 /* delete text string */
1174 toolPtr = &infoPtr->tools[nTool];
1175 if (toolPtr->lpszText) {
1176 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
1177 !IS_INTRESOURCE(toolPtr->lpszText) )
1178 Free (toolPtr->lpszText);
1181 /* remove subclassing */
1182 if (toolPtr->uFlags & TTF_SUBCLASS) {
1183 if (toolPtr->uFlags & TTF_IDISHWND) {
1184 RemoveWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1);
1187 RemoveWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1);
1191 /* delete tool from tool list */
1192 if (infoPtr->uNumTools == 1) {
1193 Free (infoPtr->tools);
1194 infoPtr->tools = NULL;
1197 TTTOOL_INFO *oldTools = infoPtr->tools;
1199 Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
1202 memcpy (&infoPtr->tools[0], &oldTools[0],
1203 nTool * sizeof(TTTOOL_INFO));
1205 if (nTool < infoPtr->uNumTools - 1)
1206 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
1207 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
1212 /* update any indices affected by delete */
1214 /* destroying tool that mouse was on on last relayed mouse move */
1215 if (infoPtr->nTool == nTool)
1216 /* -1 means no current tool (0 means first tool) */
1217 infoPtr->nTool = -1;
1218 else if (infoPtr->nTool > nTool)
1221 if (infoPtr->nTrackTool == nTool)
1222 /* -1 means no current tool (0 means first tool) */
1223 infoPtr->nTrackTool = -1;
1224 else if (infoPtr->nTrackTool > nTool)
1225 infoPtr->nTrackTool--;
1227 if (infoPtr->nCurrentTool == nTool)
1228 /* -1 means no current tool (0 means first tool) */
1229 infoPtr->nCurrentTool = -1;
1230 else if (infoPtr->nCurrentTool > nTool)
1231 infoPtr->nCurrentTool--;
1233 infoPtr->uNumTools--;
1237 TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1239 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1240 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1243 if (lpToolInfo == NULL)
1245 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
1247 if (infoPtr->uNumTools == 0)
1250 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1252 TOOLTIPS_DelToolCommon (hwnd, infoPtr, nTool);
1259 TOOLTIPS_DelToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1261 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1262 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1265 if (lpToolInfo == NULL)
1267 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
1269 if (infoPtr->uNumTools == 0)
1272 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1274 TOOLTIPS_DelToolCommon (hwnd, infoPtr, nTool);
1281 TOOLTIPS_EnumToolsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1283 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1284 UINT uIndex = (UINT)wParam;
1285 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1286 TTTOOL_INFO *toolPtr;
1288 if (lpToolInfo == NULL)
1290 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
1292 if (uIndex >= infoPtr->uNumTools)
1295 TRACE("index=%u\n", uIndex);
1297 toolPtr = &infoPtr->tools[uIndex];
1299 /* copy tool data */
1300 lpToolInfo->uFlags = toolPtr->uFlags;
1301 lpToolInfo->hwnd = toolPtr->hwnd;
1302 lpToolInfo->uId = toolPtr->uId;
1303 lpToolInfo->rect = toolPtr->rect;
1304 lpToolInfo->hinst = toolPtr->hinst;
1305 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1306 lpToolInfo->lpszText = NULL; /* FIXME */
1308 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1309 lpToolInfo->lParam = toolPtr->lParam;
1316 TOOLTIPS_EnumToolsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1318 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1319 UINT uIndex = (UINT)wParam;
1320 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1321 TTTOOL_INFO *toolPtr;
1323 if (lpToolInfo == NULL)
1325 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
1327 if (uIndex >= infoPtr->uNumTools)
1330 TRACE("index=%u\n", uIndex);
1332 toolPtr = &infoPtr->tools[uIndex];
1334 /* copy tool data */
1335 lpToolInfo->uFlags = toolPtr->uFlags;
1336 lpToolInfo->hwnd = toolPtr->hwnd;
1337 lpToolInfo->uId = toolPtr->uId;
1338 lpToolInfo->rect = toolPtr->rect;
1339 lpToolInfo->hinst = toolPtr->hinst;
1340 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1341 lpToolInfo->lpszText = NULL; /* FIXME */
1343 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1344 lpToolInfo->lParam = toolPtr->lParam;
1350 TOOLTIPS_GetBubbleSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1352 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1353 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1357 if (lpToolInfo == NULL)
1359 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
1362 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1363 if (nTool == -1) return 0;
1365 TRACE("tool %d\n", nTool);
1367 TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
1368 TRACE("size %d x %d\n", size.cx, size.cy);
1370 return MAKELRESULT(size.cx, size.cy);
1374 TOOLTIPS_GetCurrentToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1376 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1377 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1378 TTTOOL_INFO *toolPtr;
1381 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
1384 if (infoPtr->nCurrentTool > -1) {
1385 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1387 /* copy tool data */
1388 lpToolInfo->uFlags = toolPtr->uFlags;
1389 lpToolInfo->rect = toolPtr->rect;
1390 lpToolInfo->hinst = toolPtr->hinst;
1391 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1392 lpToolInfo->lpszText = NULL; /* FIXME */
1394 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1395 lpToolInfo->lParam = toolPtr->lParam;
1403 return (infoPtr->nCurrentTool != -1);
1408 TOOLTIPS_GetCurrentToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1410 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1411 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1412 TTTOOL_INFO *toolPtr;
1415 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
1418 if (infoPtr->nCurrentTool > -1) {
1419 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1421 /* copy tool data */
1422 lpToolInfo->uFlags = toolPtr->uFlags;
1423 lpToolInfo->rect = toolPtr->rect;
1424 lpToolInfo->hinst = toolPtr->hinst;
1425 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1426 lpToolInfo->lpszText = NULL; /* FIXME */
1428 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1429 lpToolInfo->lParam = toolPtr->lParam;
1437 return (infoPtr->nCurrentTool != -1);
1442 TOOLTIPS_GetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
1444 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1448 return infoPtr->nReshowTime;
1451 return infoPtr->nAutoPopTime;
1454 case TTDT_AUTOMATIC: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */
1455 return infoPtr->nInitialTime;
1458 WARN("Invalid wParam %lx\n", wParam);
1467 TOOLTIPS_GetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1469 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1470 LPRECT lpRect = (LPRECT)lParam;
1472 lpRect->left = infoPtr->rcMargin.left;
1473 lpRect->right = infoPtr->rcMargin.right;
1474 lpRect->bottom = infoPtr->rcMargin.bottom;
1475 lpRect->top = infoPtr->rcMargin.top;
1481 static inline LRESULT
1482 TOOLTIPS_GetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1484 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1486 return infoPtr->nMaxTipWidth;
1491 TOOLTIPS_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1493 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1494 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1497 if (lpToolInfo == NULL)
1499 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
1502 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1503 if (nTool == -1) return 0;
1505 /* NB this API is broken, there is no way for the app to determine
1506 what size buffer it requires nor a way to specify how long the
1507 one it supplies is. We'll assume it's up to INFOTIPSIZE */
1509 WideCharToMultiByte(CP_ACP, 0, infoPtr->tools[nTool].lpszText, -1,
1510 lpToolInfo->lpszText, INFOTIPSIZE, NULL, NULL);
1517 TOOLTIPS_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1519 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1520 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1523 if (lpToolInfo == NULL)
1525 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
1528 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1529 if (nTool == -1) return 0;
1531 strcpyW (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
1537 static inline LRESULT
1538 TOOLTIPS_GetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1540 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1541 return infoPtr->clrBk;
1545 static inline LRESULT
1546 TOOLTIPS_GetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1548 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1549 return infoPtr->clrText;
1553 static inline LRESULT
1554 TOOLTIPS_GetToolCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1556 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1557 return infoPtr->uNumTools;
1562 TOOLTIPS_GetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1564 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1565 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1566 TTTOOL_INFO *toolPtr;
1569 if (lpToolInfo == NULL)
1571 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
1573 if (infoPtr->uNumTools == 0)
1576 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1580 TRACE("tool %d\n", nTool);
1582 toolPtr = &infoPtr->tools[nTool];
1584 /* copy tool data */
1585 lpToolInfo->uFlags = toolPtr->uFlags;
1586 lpToolInfo->rect = toolPtr->rect;
1587 lpToolInfo->hinst = toolPtr->hinst;
1588 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1589 lpToolInfo->lpszText = NULL; /* FIXME */
1591 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1592 lpToolInfo->lParam = toolPtr->lParam;
1599 TOOLTIPS_GetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1601 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1602 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1603 TTTOOL_INFO *toolPtr;
1606 if (lpToolInfo == NULL)
1608 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
1610 if (infoPtr->uNumTools == 0)
1613 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1617 TRACE("tool %d\n", nTool);
1619 toolPtr = &infoPtr->tools[nTool];
1621 /* copy tool data */
1622 lpToolInfo->uFlags = toolPtr->uFlags;
1623 lpToolInfo->rect = toolPtr->rect;
1624 lpToolInfo->hinst = toolPtr->hinst;
1625 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1626 lpToolInfo->lpszText = NULL; /* FIXME */
1628 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1629 lpToolInfo->lParam = toolPtr->lParam;
1636 TOOLTIPS_HitTestA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1638 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1639 LPTTHITTESTINFOA lptthit = (LPTTHITTESTINFOA)lParam;
1640 TTTOOL_INFO *toolPtr;
1646 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1650 TRACE("tool %d!\n", nTool);
1652 /* copy tool data */
1653 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) {
1654 toolPtr = &infoPtr->tools[nTool];
1656 lptthit->ti.uFlags = toolPtr->uFlags;
1657 lptthit->ti.hwnd = toolPtr->hwnd;
1658 lptthit->ti.uId = toolPtr->uId;
1659 lptthit->ti.rect = toolPtr->rect;
1660 lptthit->ti.hinst = toolPtr->hinst;
1661 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1662 lptthit->ti.lpszText = NULL; /* FIXME */
1663 lptthit->ti.lParam = toolPtr->lParam;
1671 TOOLTIPS_HitTestW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1673 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1674 LPTTHITTESTINFOW lptthit = (LPTTHITTESTINFOW)lParam;
1675 TTTOOL_INFO *toolPtr;
1681 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1685 TRACE("tool %d!\n", nTool);
1687 /* copy tool data */
1688 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) {
1689 toolPtr = &infoPtr->tools[nTool];
1691 lptthit->ti.uFlags = toolPtr->uFlags;
1692 lptthit->ti.hwnd = toolPtr->hwnd;
1693 lptthit->ti.uId = toolPtr->uId;
1694 lptthit->ti.rect = toolPtr->rect;
1695 lptthit->ti.hinst = toolPtr->hinst;
1696 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1697 lptthit->ti.lpszText = NULL; /* FIXME */
1698 lptthit->ti.lParam = toolPtr->lParam;
1706 TOOLTIPS_NewToolRectA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1708 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1709 LPTTTOOLINFOA lpti = (LPTTTOOLINFOA)lParam;
1714 if (lpti->cbSize < TTTOOLINFOA_V1_SIZE)
1717 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti);
1719 TRACE("nTool = %d, rect = %s\n", nTool, wine_dbgstr_rect(&lpti->rect));
1721 if (nTool == -1) return 0;
1723 infoPtr->tools[nTool].rect = lpti->rect;
1730 TOOLTIPS_NewToolRectW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1732 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1733 LPTTTOOLINFOW lpti = (LPTTTOOLINFOW)lParam;
1738 if (lpti->cbSize < TTTOOLINFOW_V1_SIZE)
1741 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti);
1743 TRACE("nTool = %d, rect = %s\n", nTool, wine_dbgstr_rect(&lpti->rect));
1745 if (nTool == -1) return 0;
1747 infoPtr->tools[nTool].rect = lpti->rect;
1753 static inline LRESULT
1754 TOOLTIPS_Pop (HWND hwnd, WPARAM wParam, LPARAM lParam)
1756 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1757 TOOLTIPS_Hide (hwnd, infoPtr);
1764 TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1766 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1767 LPMSG lpMsg = (LPMSG)lParam;
1772 ERR("lpMsg == NULL!\n");
1776 switch (lpMsg->message) {
1777 case WM_LBUTTONDOWN:
1779 case WM_MBUTTONDOWN:
1781 case WM_RBUTTONDOWN:
1783 TOOLTIPS_Hide (hwnd, infoPtr);
1787 pt.x = (short)LOWORD(lpMsg->lParam);
1788 pt.y = (short)HIWORD(lpMsg->lParam);
1789 nOldTool = infoPtr->nTool;
1790 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr, lpMsg->hwnd,
1792 TRACE("tool (%p) %d %d %d\n", hwnd, nOldTool,
1793 infoPtr->nTool, infoPtr->nCurrentTool);
1794 TRACE("WM_MOUSEMOVE (%p %d %d)\n", hwnd, pt.x, pt.y);
1796 if (infoPtr->nTool != nOldTool) {
1797 if(infoPtr->nTool == -1) { /* Moved out of all tools */
1798 TOOLTIPS_Hide(hwnd, infoPtr);
1799 KillTimer(hwnd, ID_TIMERLEAVE);
1800 } else if (nOldTool == -1) { /* Moved from outside */
1801 if(infoPtr->bActive) {
1802 SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
1803 TRACE("timer 1 started!\n");
1805 } else { /* Moved from one to another */
1806 TOOLTIPS_Hide (hwnd, infoPtr);
1807 KillTimer(hwnd, ID_TIMERLEAVE);
1808 if(infoPtr->bActive) {
1809 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
1810 TRACE("timer 1 started!\n");
1813 } else if(infoPtr->nCurrentTool != -1) { /* restart autopop */
1814 KillTimer(hwnd, ID_TIMERPOP);
1815 SetTimer(hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
1816 TRACE("timer 2 restarted\n");
1817 } else if(infoPtr->nTool != -1 && infoPtr->bActive) {
1818 /* previous show attempt didn't result in tooltip so try again */
1819 SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
1820 TRACE("timer 1 started!\n");
1830 TOOLTIPS_SetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
1832 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1833 INT nTime = (INT)LOWORD(lParam);
1836 case TTDT_AUTOMATIC:
1838 nTime = GetDoubleClickTime();
1839 infoPtr->nReshowTime = nTime / 5;
1840 infoPtr->nAutoPopTime = nTime * 10;
1841 infoPtr->nInitialTime = nTime;
1846 nTime = GetDoubleClickTime() / 5;
1847 infoPtr->nReshowTime = nTime;
1852 nTime = GetDoubleClickTime() * 10;
1853 infoPtr->nAutoPopTime = nTime;
1858 nTime = GetDoubleClickTime();
1859 infoPtr->nInitialTime = nTime;
1863 WARN("Invalid wParam %lx\n", wParam);
1872 TOOLTIPS_SetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1874 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1875 LPRECT lpRect = (LPRECT)lParam;
1877 infoPtr->rcMargin.left = lpRect->left;
1878 infoPtr->rcMargin.right = lpRect->right;
1879 infoPtr->rcMargin.bottom = lpRect->bottom;
1880 infoPtr->rcMargin.top = lpRect->top;
1886 static inline LRESULT
1887 TOOLTIPS_SetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1889 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1890 INT nTemp = infoPtr->nMaxTipWidth;
1892 infoPtr->nMaxTipWidth = (INT)lParam;
1898 static inline LRESULT
1899 TOOLTIPS_SetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1901 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1903 infoPtr->clrBk = (COLORREF)wParam;
1909 static inline LRESULT
1910 TOOLTIPS_SetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1912 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1914 infoPtr->clrText = (COLORREF)wParam;
1921 TOOLTIPS_SetTitleA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1923 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1924 LPCSTR pszTitle = (LPCSTR)lParam;
1925 UINT_PTR uTitleIcon = (UINT_PTR)wParam;
1928 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_a(pszTitle),
1931 Free(infoPtr->pszTitle);
1935 size = sizeof(WCHAR)*MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, NULL, 0);
1936 infoPtr->pszTitle = Alloc(size);
1937 if (!infoPtr->pszTitle)
1939 MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, infoPtr->pszTitle, size/sizeof(WCHAR));
1942 infoPtr->pszTitle = NULL;
1944 if (uTitleIcon <= TTI_ERROR)
1945 infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon];
1947 infoPtr->hTitleIcon = CopyIcon((HICON)wParam);
1954 TOOLTIPS_SetTitleW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1956 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1957 LPCWSTR pszTitle = (LPCWSTR)lParam;
1958 UINT_PTR uTitleIcon = (UINT_PTR)wParam;
1961 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_w(pszTitle),
1964 Free(infoPtr->pszTitle);
1968 size = (strlenW(pszTitle)+1)*sizeof(WCHAR);
1969 infoPtr->pszTitle = Alloc(size);
1970 if (!infoPtr->pszTitle)
1972 memcpy(infoPtr->pszTitle, pszTitle, size);
1975 infoPtr->pszTitle = NULL;
1977 if (uTitleIcon <= TTI_ERROR)
1978 infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon];
1980 infoPtr->hTitleIcon = CopyIcon((HICON)wParam);
1982 TRACE("icon = %p\n", infoPtr->hTitleIcon);
1989 TOOLTIPS_SetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1991 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1992 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1993 TTTOOL_INFO *toolPtr;
1996 if (lpToolInfo == NULL)
1998 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
2001 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
2002 if (nTool == -1) return 0;
2004 TRACE("tool %d\n", nTool);
2006 toolPtr = &infoPtr->tools[nTool];
2008 /* copy tool data */
2009 toolPtr->uFlags = lpToolInfo->uFlags;
2010 toolPtr->hwnd = lpToolInfo->hwnd;
2011 toolPtr->uId = lpToolInfo->uId;
2012 toolPtr->rect = lpToolInfo->rect;
2013 toolPtr->hinst = lpToolInfo->hinst;
2015 if (IS_INTRESOURCE(lpToolInfo->lpszText)) {
2016 TRACE("set string id %x\n", LOWORD(lpToolInfo->lpszText));
2017 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
2019 else if (lpToolInfo->lpszText) {
2020 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
2021 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
2023 if ( (toolPtr->lpszText) &&
2024 !IS_INTRESOURCE(toolPtr->lpszText) ) {
2025 if( toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
2026 Free (toolPtr->lpszText);
2027 toolPtr->lpszText = NULL;
2029 if (lpToolInfo->lpszText) {
2030 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText,
2032 toolPtr->lpszText = Alloc (len * sizeof(WCHAR));
2033 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
2034 toolPtr->lpszText, len);
2039 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
2040 toolPtr->lParam = lpToolInfo->lParam;
2047 TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2049 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2050 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
2051 TTTOOL_INFO *toolPtr;
2054 if (lpToolInfo == NULL)
2056 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
2059 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
2060 if (nTool == -1) return 0;
2062 TRACE("tool %d\n", nTool);
2064 toolPtr = &infoPtr->tools[nTool];
2066 /* copy tool data */
2067 toolPtr->uFlags = lpToolInfo->uFlags;
2068 toolPtr->hwnd = lpToolInfo->hwnd;
2069 toolPtr->uId = lpToolInfo->uId;
2070 toolPtr->rect = lpToolInfo->rect;
2071 toolPtr->hinst = lpToolInfo->hinst;
2073 if (IS_INTRESOURCE(lpToolInfo->lpszText)) {
2074 TRACE("set string id %x!\n", LOWORD(lpToolInfo->lpszText));
2075 toolPtr->lpszText = lpToolInfo->lpszText;
2078 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
2079 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
2081 if ( (toolPtr->lpszText) &&
2082 !IS_INTRESOURCE(toolPtr->lpszText) ) {
2083 if( toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
2084 Free (toolPtr->lpszText);
2085 toolPtr->lpszText = NULL;
2087 if (lpToolInfo->lpszText) {
2088 INT len = lstrlenW (lpToolInfo->lpszText);
2089 toolPtr->lpszText = Alloc ((len+1)*sizeof(WCHAR));
2090 strcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
2095 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
2096 toolPtr->lParam = lpToolInfo->lParam;
2098 if (infoPtr->nCurrentTool == nTool)
2100 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool);
2102 if (infoPtr->szTipText[0] == 0)
2103 TOOLTIPS_Hide(hwnd, infoPtr);
2105 TOOLTIPS_Show (hwnd, infoPtr, FALSE);
2113 TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2115 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2118 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
2120 if (lpToolInfo == NULL)
2122 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
2126 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
2127 if (infoPtr->nTrackTool != -1) {
2128 TRACE("activated!\n");
2129 infoPtr->bTrackActive = TRUE;
2130 TOOLTIPS_TrackShow (hwnd, infoPtr);
2135 TOOLTIPS_TrackHide (hwnd, infoPtr);
2137 infoPtr->bTrackActive = FALSE;
2138 infoPtr->nTrackTool = -1;
2140 TRACE("deactivated!\n");
2148 TOOLTIPS_TrackPosition (HWND hwnd, WPARAM wParam, LPARAM lParam)
2150 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2152 infoPtr->xTrackPos = (INT)LOWORD(lParam);
2153 infoPtr->yTrackPos = (INT)HIWORD(lParam);
2155 if (infoPtr->bTrackActive) {
2157 infoPtr->xTrackPos, infoPtr->yTrackPos);
2159 TOOLTIPS_TrackShow (hwnd, infoPtr);
2167 TOOLTIPS_Update (HWND hwnd, WPARAM wParam, LPARAM lParam)
2169 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2171 if (infoPtr->nCurrentTool != -1)
2172 UpdateWindow (hwnd);
2179 TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2181 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2182 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
2183 TTTOOL_INFO *toolPtr;
2186 if (lpToolInfo == NULL)
2188 if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
2191 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
2192 if (nTool == -1) return 0;
2194 TRACE("tool %d\n", nTool);
2196 toolPtr = &infoPtr->tools[nTool];
2198 /* copy tool text */
2199 toolPtr->hinst = lpToolInfo->hinst;
2201 if (IS_INTRESOURCE(lpToolInfo->lpszText)){
2202 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
2204 else if (lpToolInfo->lpszText) {
2205 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
2206 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
2208 if ( (toolPtr->lpszText) &&
2209 !IS_INTRESOURCE(toolPtr->lpszText) ) {
2210 if( toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
2211 Free (toolPtr->lpszText);
2212 toolPtr->lpszText = NULL;
2214 if (lpToolInfo->lpszText) {
2215 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText,
2217 toolPtr->lpszText = Alloc (len * sizeof(WCHAR));
2218 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1,
2219 toolPtr->lpszText, len);
2224 if(infoPtr->nCurrentTool == -1) return 0;
2226 if (infoPtr->bActive)
2227 TOOLTIPS_Show (hwnd, infoPtr, FALSE);
2228 else if (infoPtr->bTrackActive)
2229 TOOLTIPS_TrackShow (hwnd, infoPtr);
2236 TOOLTIPS_UpdateTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2238 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2239 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
2240 TTTOOL_INFO *toolPtr;
2243 if (lpToolInfo == NULL)
2245 if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
2248 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
2252 TRACE("tool %d\n", nTool);
2254 toolPtr = &infoPtr->tools[nTool];
2256 /* copy tool text */
2257 toolPtr->hinst = lpToolInfo->hinst;
2259 if (IS_INTRESOURCE(lpToolInfo->lpszText)){
2260 toolPtr->lpszText = lpToolInfo->lpszText;
2262 else if (lpToolInfo->lpszText) {
2263 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
2264 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
2266 if ( (toolPtr->lpszText) &&
2267 !IS_INTRESOURCE(toolPtr->lpszText) ) {
2268 if( toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
2269 Free (toolPtr->lpszText);
2270 toolPtr->lpszText = NULL;
2272 if (lpToolInfo->lpszText) {
2273 INT len = lstrlenW (lpToolInfo->lpszText);
2274 toolPtr->lpszText = Alloc ((len+1)*sizeof(WCHAR));
2275 strcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
2280 if(infoPtr->nCurrentTool == -1) return 0;
2282 if (infoPtr->bActive)
2283 TOOLTIPS_Show (hwnd, infoPtr, FALSE);
2284 else if (infoPtr->bTrackActive)
2285 TOOLTIPS_Show (hwnd, infoPtr, TRUE);
2292 TOOLTIPS_WindowFromPoint (HWND hwnd, WPARAM wParam, LPARAM lParam)
2294 return (LRESULT)WindowFromPoint (*((LPPOINT)lParam));
2300 TOOLTIPS_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
2302 TOOLTIPS_INFO *infoPtr;
2304 /* allocate memory for info structure */
2305 infoPtr = (TOOLTIPS_INFO *)Alloc (sizeof(TOOLTIPS_INFO));
2306 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
2308 /* initialize info structure */
2309 infoPtr->bActive = TRUE;
2310 infoPtr->bTrackActive = FALSE;
2312 infoPtr->nMaxTipWidth = -1;
2313 infoPtr->nTool = -1;
2314 infoPtr->nCurrentTool = -1;
2315 infoPtr->nTrackTool = -1;
2317 /* initialize colours and fonts */
2318 TOOLTIPS_InitSystemSettings(infoPtr);
2320 TOOLTIPS_SetDelayTime(hwnd, TTDT_AUTOMATIC, 0L);
2322 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
2329 TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2331 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2332 TTTOOL_INFO *toolPtr;
2336 if (infoPtr->tools) {
2337 for (i = 0; i < infoPtr->uNumTools; i++) {
2338 toolPtr = &infoPtr->tools[i];
2339 if (toolPtr->lpszText) {
2340 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
2341 !IS_INTRESOURCE(toolPtr->lpszText) )
2343 Free (toolPtr->lpszText);
2344 toolPtr->lpszText = NULL;
2348 /* remove subclassing */
2349 if (toolPtr->uFlags & TTF_SUBCLASS) {
2350 if (toolPtr->uFlags & TTF_IDISHWND) {
2351 RemoveWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1);
2354 RemoveWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1);
2358 Free (infoPtr->tools);
2361 /* free title string */
2362 Free (infoPtr->pszTitle);
2363 /* free title icon if not a standard one */
2364 if (TOOLTIPS_GetTitleIconIndex(infoPtr->hTitleIcon) > TTI_ERROR)
2365 DeleteObject(infoPtr->hTitleIcon);
2368 DeleteObject (infoPtr->hFont);
2369 DeleteObject (infoPtr->hTitleFont);
2371 /* free tool tips info data */
2373 SetWindowLongPtrW(hwnd, 0, 0);
2379 TOOLTIPS_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2381 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2383 return (LRESULT)infoPtr->hFont;
2388 TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2390 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2392 TOOLTIPS_Hide (hwnd, infoPtr);
2399 TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2401 DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
2402 DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
2404 dwStyle &= ~(WS_CHILD | /*WS_MAXIMIZE |*/ WS_BORDER | WS_DLGFRAME);
2405 dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS);
2407 /* WS_BORDER only draws a border round the window rect, not the
2408 * window region, therefore it is useless to us in balloon mode */
2409 if (dwStyle & TTS_BALLOON) dwStyle &= ~WS_BORDER;
2411 SetWindowLongW (hwnd, GWL_STYLE, dwStyle);
2413 dwExStyle |= WS_EX_TOOLWINDOW;
2414 SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle);
2421 TOOLTIPS_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
2423 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2424 INT nTool = (infoPtr->bTrackActive) ? infoPtr->nTrackTool : infoPtr->nTool;
2426 TRACE(" nTool=%d\n", nTool);
2428 if ((nTool > -1) && (nTool < infoPtr->uNumTools)) {
2429 if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
2430 TRACE("-- in transparent mode!\n");
2431 return HTTRANSPARENT;
2435 return DefWindowProcW (hwnd, WM_NCHITTEST, wParam, lParam);
2440 TOOLTIPS_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2442 FIXME ("hwnd=%p wParam=%lx lParam=%lx\n", hwnd, wParam, lParam);
2449 TOOLTIPS_Paint (HWND hwnd, WPARAM wParam, LPARAM lParam)
2454 hdc = (wParam == 0) ? BeginPaint (hwnd, &ps) : (HDC)wParam;
2455 TOOLTIPS_Refresh (hwnd, hdc);
2457 EndPaint (hwnd, &ps);
2463 TOOLTIPS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2465 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2468 if(!GetObjectW((HFONT)wParam, sizeof(lf), &lf))
2471 DeleteObject (infoPtr->hFont);
2472 infoPtr->hFont = CreateFontIndirectW(&lf);
2474 DeleteObject (infoPtr->hTitleFont);
2475 lf.lfWeight = FW_BOLD;
2476 infoPtr->hTitleFont = CreateFontIndirectW(&lf);
2478 if ((LOWORD(lParam)) & (infoPtr->nCurrentTool != -1)) {
2479 FIXME("full redraw needed!\n");
2485 /******************************************************************
2486 * TOOLTIPS_GetTextLength
2488 * This function is called when the tooltip receive a
2489 * WM_GETTEXTLENGTH message.
2493 * returns the length, in characters, of the tip text
2496 TOOLTIPS_GetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam)
2498 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2499 return strlenW(infoPtr->szTipText);
2502 /******************************************************************
2503 * TOOLTIPS_OnWMGetText
2505 * This function is called when the tooltip receive a
2506 * WM_GETTEXT message.
2507 * wParam : specifies the maximum number of characters to be copied
2508 * lParam : is the pointer to the buffer that will receive
2511 * returns the number of characters copied
2514 TOOLTIPS_OnWMGetText (HWND hwnd, WPARAM wParam, LPARAM lParam)
2516 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2518 LPWSTR pszText = (LPWSTR)lParam;
2520 if(!infoPtr->szTipText || !wParam)
2523 res = min(strlenW(infoPtr->szTipText)+1, wParam);
2524 memcpy(pszText, infoPtr->szTipText, res*sizeof(WCHAR));
2525 pszText[res-1] = '\0';
2530 TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam)
2532 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2535 TRACE("timer %ld (%p) expired!\n", wParam, hwnd);
2539 KillTimer (hwnd, ID_TIMERSHOW);
2540 nOldTool = infoPtr->nTool;
2541 if ((infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, TRUE)) == nOldTool)
2542 TOOLTIPS_Show (hwnd, infoPtr, FALSE);
2546 TOOLTIPS_Hide (hwnd, infoPtr);
2550 nOldTool = infoPtr->nTool;
2551 infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, FALSE);
2552 TRACE("tool (%p) %d %d %d\n", hwnd, nOldTool,
2553 infoPtr->nTool, infoPtr->nCurrentTool);
2554 if (infoPtr->nTool != nOldTool) {
2555 if(infoPtr->nTool == -1) { /* Moved out of all tools */
2556 TOOLTIPS_Hide(hwnd, infoPtr);
2557 KillTimer(hwnd, ID_TIMERLEAVE);
2558 } else if (nOldTool == -1) { /* Moved from outside */
2559 ERR("How did this happen?\n");
2560 } else { /* Moved from one to another */
2561 TOOLTIPS_Hide (hwnd, infoPtr);
2562 KillTimer(hwnd, ID_TIMERLEAVE);
2563 if(infoPtr->bActive) {
2564 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
2565 TRACE("timer 1 started!\n");
2572 ERR("Unknown timer id %ld\n", wParam);
2580 TOOLTIPS_WinIniChange (HWND hwnd, WPARAM wParam, LPARAM lParam)
2582 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2584 TOOLTIPS_InitSystemSettings (infoPtr);
2590 static LRESULT CALLBACK
2591 TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uID, DWORD_PTR dwRef)
2597 case WM_LBUTTONDOWN:
2599 case WM_MBUTTONDOWN:
2601 case WM_RBUTTONDOWN:
2605 msg.wParam = wParam;
2606 msg.lParam = lParam;
2607 TOOLTIPS_RelayEvent((HWND)dwRef, 0, (LPARAM)&msg);
2613 return DefSubclassProc(hwnd, uMsg, wParam, lParam);
2617 static LRESULT CALLBACK
2618 TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2620 TRACE("hwnd=%p msg=%x wparam=%lx lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2621 if (!TOOLTIPS_GetInfoPtr(hwnd) && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE))
2622 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2626 return TOOLTIPS_Activate (hwnd, wParam, lParam);
2629 return TOOLTIPS_AddToolA (hwnd, wParam, lParam);
2632 return TOOLTIPS_AddToolW (hwnd, wParam, lParam);
2635 return TOOLTIPS_DelToolA (hwnd, wParam, lParam);
2638 return TOOLTIPS_DelToolW (hwnd, wParam, lParam);
2640 case TTM_ENUMTOOLSA:
2641 return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam);
2643 case TTM_ENUMTOOLSW:
2644 return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam);
2646 case TTM_GETBUBBLESIZE:
2647 return TOOLTIPS_GetBubbleSize (hwnd, wParam, lParam);
2649 case TTM_GETCURRENTTOOLA:
2650 return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam);
2652 case TTM_GETCURRENTTOOLW:
2653 return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam);
2655 case TTM_GETDELAYTIME:
2656 return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam);
2659 return TOOLTIPS_GetMargin (hwnd, wParam, lParam);
2661 case TTM_GETMAXTIPWIDTH:
2662 return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam);
2665 return TOOLTIPS_GetTextA (hwnd, wParam, lParam);
2668 return TOOLTIPS_GetTextW (hwnd, wParam, lParam);
2670 case TTM_GETTIPBKCOLOR:
2671 return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam);
2673 case TTM_GETTIPTEXTCOLOR:
2674 return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam);
2676 case TTM_GETTOOLCOUNT:
2677 return TOOLTIPS_GetToolCount (hwnd, wParam, lParam);
2679 case TTM_GETTOOLINFOA:
2680 return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam);
2682 case TTM_GETTOOLINFOW:
2683 return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam);
2686 return TOOLTIPS_HitTestA (hwnd, wParam, lParam);
2689 return TOOLTIPS_HitTestW (hwnd, wParam, lParam);
2691 case TTM_NEWTOOLRECTA:
2692 return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam);
2694 case TTM_NEWTOOLRECTW:
2695 return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam);
2698 return TOOLTIPS_Pop (hwnd, wParam, lParam);
2700 case TTM_RELAYEVENT:
2701 return TOOLTIPS_RelayEvent (hwnd, wParam, lParam);
2703 case TTM_SETDELAYTIME:
2704 return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam);
2707 return TOOLTIPS_SetMargin (hwnd, wParam, lParam);
2709 case TTM_SETMAXTIPWIDTH:
2710 return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam);
2712 case TTM_SETTIPBKCOLOR:
2713 return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam);
2715 case TTM_SETTIPTEXTCOLOR:
2716 return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam);
2719 return TOOLTIPS_SetTitleA (hwnd, wParam, lParam);
2722 return TOOLTIPS_SetTitleW (hwnd, wParam, lParam);
2724 case TTM_SETTOOLINFOA:
2725 return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam);
2727 case TTM_SETTOOLINFOW:
2728 return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam);
2730 case TTM_TRACKACTIVATE:
2731 return TOOLTIPS_TrackActivate (hwnd, wParam, lParam);
2733 case TTM_TRACKPOSITION:
2734 return TOOLTIPS_TrackPosition (hwnd, wParam, lParam);
2737 return TOOLTIPS_Update (hwnd, wParam, lParam);
2739 case TTM_UPDATETIPTEXTA:
2740 return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam);
2742 case TTM_UPDATETIPTEXTW:
2743 return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam);
2745 case TTM_WINDOWFROMPOINT:
2746 return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam);
2750 return TOOLTIPS_Create (hwnd, (LPCREATESTRUCTW)lParam);
2753 return TOOLTIPS_Destroy (hwnd, wParam, lParam);
2756 /* we draw the background in WM_PAINT */
2760 return TOOLTIPS_GetFont (hwnd, wParam, lParam);
2763 return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam);
2765 case WM_GETTEXTLENGTH:
2766 return TOOLTIPS_GetTextLength (hwnd, wParam, lParam);
2768 case WM_LBUTTONDOWN:
2770 case WM_MBUTTONDOWN:
2772 case WM_RBUTTONDOWN:
2775 return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
2778 return TOOLTIPS_NCCreate (hwnd, wParam, lParam);
2781 return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
2783 case WM_NOTIFYFORMAT:
2784 return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam);
2786 case WM_PRINTCLIENT:
2788 return TOOLTIPS_Paint (hwnd, wParam, lParam);
2791 return TOOLTIPS_SetFont (hwnd, wParam, lParam);
2794 return TOOLTIPS_Timer (hwnd, wParam, lParam);
2796 case WM_WININICHANGE:
2797 return TOOLTIPS_WinIniChange (hwnd, wParam, lParam);
2800 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
2801 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
2802 uMsg, wParam, lParam);
2803 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2809 TOOLTIPS_Register (void)
2813 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
2814 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
2815 wndClass.lpfnWndProc = TOOLTIPS_WindowProc;
2816 wndClass.cbClsExtra = 0;
2817 wndClass.cbWndExtra = sizeof(TOOLTIPS_INFO *);
2818 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
2819 wndClass.hbrBackground = 0;
2820 wndClass.lpszClassName = TOOLTIPS_CLASSW;
2822 RegisterClassW (&wndClass);
2824 hTooltipIcons[TTI_NONE] = NULL;
2825 hTooltipIcons[TTI_INFO] = LoadImageW(COMCTL32_hModule,
2826 (LPCWSTR)MAKEINTRESOURCE(IDI_TT_INFO_SM), IMAGE_ICON, 0, 0, 0);
2827 hTooltipIcons[TTI_WARNING] = LoadImageW(COMCTL32_hModule,
2828 (LPCWSTR)MAKEINTRESOURCE(IDI_TT_WARN_SM), IMAGE_ICON, 0, 0, 0);
2829 hTooltipIcons[TTI_ERROR] = LoadImageW(COMCTL32_hModule,
2830 (LPCWSTR)MAKEINTRESOURCE(IDI_TT_ERROR_SM), IMAGE_ICON, 0, 0, 0);
2835 TOOLTIPS_Unregister (void)
2838 for (i = TTI_INFO; i <= TTI_ERROR; i++)
2839 DestroyIcon(hTooltipIcons[i]);
2840 UnregisterClassW (TOOLTIPS_CLASSW, NULL);