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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 inline static 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
;
318 ttnmdi
.lpszText
= (LPSTR
)&ttnmdi
.szText
;
319 ttnmdi
.uFlags
= toolPtr
->uFlags
;
320 ttnmdi
.lParam
= toolPtr
->lParam
;
322 TRACE("hdr.idFrom = %x\n", ttnmdi
.hdr
.idFrom
);
323 SendMessageW(toolPtr
->hwnd
, WM_NOTIFY
,
324 (WPARAM
)toolPtr
->uId
, (LPARAM
)&ttnmdi
);
326 if (HIWORD((UINT
)ttnmdi
.lpszText
) == 0) {
327 LoadStringW(ttnmdi
.hinst
, (UINT
)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 /* no text available */
336 infoPtr
->szTipText
[0] = '\0';
338 else if (ttnmdi
.lpszText
!= LPSTR_TEXTCALLBACKA
) {
339 INT max_len
= (ttnmdi
.lpszText
== &ttnmdi
.szText
[0]) ?
340 sizeof(ttnmdi
.szText
)/sizeof(ttnmdi
.szText
[0]) : -1;
341 MultiByteToWideChar(CP_ACP
, 0, ttnmdi
.lpszText
, max_len
,
342 infoPtr
->szTipText
, INFOTIPSIZE
);
343 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
344 INT len
= MultiByteToWideChar(CP_ACP
, 0, ttnmdi
.lpszText
,
347 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
348 MultiByteToWideChar(CP_ACP
, 0, ttnmdi
.lpszText
, -1,
349 toolPtr
->lpszText
, len
);
353 ERR("recursive text callback!\n");
354 infoPtr
->szTipText
[0] = '\0';
358 static void TOOLTIPS_GetDispInfoW(HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, TTTOOL_INFO
*toolPtr
)
360 NMTTDISPINFOW ttnmdi
;
362 /* fill NMHDR struct */
363 ZeroMemory (&ttnmdi
, sizeof(NMTTDISPINFOW
));
364 ttnmdi
.hdr
.hwndFrom
= hwnd
;
365 ttnmdi
.hdr
.idFrom
= toolPtr
->uId
;
366 ttnmdi
.hdr
.code
= TTN_GETDISPINFOW
;
367 ttnmdi
.lpszText
= (LPWSTR
)&ttnmdi
.szText
;
368 ttnmdi
.uFlags
= toolPtr
->uFlags
;
369 ttnmdi
.lParam
= toolPtr
->lParam
;
371 TRACE("hdr.idFrom = %x\n", ttnmdi
.hdr
.idFrom
);
372 SendMessageW(toolPtr
->hwnd
, WM_NOTIFY
,
373 (WPARAM
)toolPtr
->uId
, (LPARAM
)&ttnmdi
);
375 if (HIWORD((UINT
)ttnmdi
.lpszText
) == 0) {
376 LoadStringW(ttnmdi
.hinst
, (UINT
)ttnmdi
.lpszText
,
377 infoPtr
->szTipText
, INFOTIPSIZE
);
378 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
379 toolPtr
->hinst
= ttnmdi
.hinst
;
380 toolPtr
->lpszText
= ttnmdi
.lpszText
;
383 else if (ttnmdi
.lpszText
== 0) {
384 /* no text available */
385 infoPtr
->szTipText
[0] = '\0';
387 else if (ttnmdi
.lpszText
!= LPSTR_TEXTCALLBACKW
) {
388 INT max_len
= (ttnmdi
.lpszText
== &ttnmdi
.szText
[0]) ?
389 sizeof(ttnmdi
.szText
)/sizeof(ttnmdi
.szText
[0]) : INFOTIPSIZE
-1;
390 lstrcpynW(infoPtr
->szTipText
, ttnmdi
.lpszText
, max_len
);
391 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
392 INT len
= max(strlenW(ttnmdi
.lpszText
), max_len
);
394 toolPtr
->lpszText
= Alloc ((len
+1) * sizeof(WCHAR
));
395 memcpy(toolPtr
->lpszText
, ttnmdi
.lpszText
, (len
+1) * sizeof(WCHAR
));
399 ERR("recursive text callback!\n");
400 infoPtr
->szTipText
[0] = '\0';
405 TOOLTIPS_GetTipText (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, INT nTool
)
407 TTTOOL_INFO
*toolPtr
= &infoPtr
->tools
[nTool
];
409 if (HIWORD((UINT
)toolPtr
->lpszText
) == 0 && toolPtr
->hinst
) {
410 /* load a resource */
411 TRACE("load res string %p %x\n",
412 toolPtr
->hinst
, (int)toolPtr
->lpszText
);
413 LoadStringW (toolPtr
->hinst
, (UINT
)toolPtr
->lpszText
,
414 infoPtr
->szTipText
, INFOTIPSIZE
);
416 else if (toolPtr
->lpszText
) {
417 if (toolPtr
->lpszText
== LPSTR_TEXTCALLBACKW
) {
418 if (toolPtr
->bNotifyUnicode
)
419 TOOLTIPS_GetDispInfoW(hwnd
, infoPtr
, toolPtr
);
421 TOOLTIPS_GetDispInfoA(hwnd
, infoPtr
, toolPtr
);
424 /* the item is a usual (unicode) text */
425 lstrcpynW (infoPtr
->szTipText
, toolPtr
->lpszText
, INFOTIPSIZE
);
429 /* no text available */
430 infoPtr
->szTipText
[0] = L
'\0';
433 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
438 TOOLTIPS_CalcTipSize (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, LPSIZE lpSize
)
442 DWORD style
= GetWindowLongW(hwnd
, GWL_STYLE
);
443 UINT uFlags
= DT_EXTERNALLEADING
| DT_CALCRECT
;
444 RECT rc
= {0, 0, 0, 0};
447 if (infoPtr
->nMaxTipWidth
> -1) {
448 rc
.right
= infoPtr
->nMaxTipWidth
;
449 uFlags
|= DT_WORDBREAK
;
451 if (style
& TTS_NOPREFIX
)
452 uFlags
|= DT_NOPREFIX
;
453 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
456 if (infoPtr
->pszTitle
)
458 RECT rcTitle
= {0, 0, 0, 0};
459 TRACE("title %s\n", debugstr_w(infoPtr
->pszTitle
));
460 if (infoPtr
->hTitleIcon
)
462 title
.cx
= ICON_WIDTH
;
463 title
.cy
= ICON_HEIGHT
;
465 if (title
.cx
!= 0) title
.cx
+= BALLOON_ICON_TITLE_SPACING
;
466 hOldFont
= SelectObject (hdc
, infoPtr
->hTitleFont
);
467 DrawTextW(hdc
, infoPtr
->pszTitle
, -1, &rcTitle
, DT_SINGLELINE
| DT_NOPREFIX
| DT_CALCRECT
);
468 SelectObject (hdc
, hOldFont
);
469 title
.cy
= max(title
.cy
, rcTitle
.bottom
- rcTitle
.top
) + BALLOON_TITLE_TEXT_SPACING
;
470 title
.cx
+= (rcTitle
.right
- rcTitle
.left
);
472 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
473 DrawTextW (hdc
, infoPtr
->szTipText
, -1, &rc
, uFlags
);
474 SelectObject (hdc
, hOldFont
);
475 ReleaseDC (hwnd
, hdc
);
477 if ((style
& TTS_BALLOON
) || infoPtr
->pszTitle
)
479 lpSize
->cx
= max(rc
.right
- rc
.left
, title
.cx
) + 2*BALLOON_TEXT_MARGIN
+
480 infoPtr
->rcMargin
.left
+ infoPtr
->rcMargin
.right
;
481 lpSize
->cy
= title
.cy
+ rc
.bottom
- rc
.top
+ 2*BALLOON_TEXT_MARGIN
+
482 infoPtr
->rcMargin
.bottom
+ infoPtr
->rcMargin
.top
+
487 lpSize
->cx
= rc
.right
- rc
.left
+ 2*NORMAL_TEXT_MARGIN
+
488 infoPtr
->rcMargin
.left
+ infoPtr
->rcMargin
.right
;
489 lpSize
->cy
= rc
.bottom
- rc
.top
+ 2*NORMAL_TEXT_MARGIN
+
490 infoPtr
->rcMargin
.bottom
+ infoPtr
->rcMargin
.top
;
496 TOOLTIPS_Show (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
498 TTTOOL_INFO
*toolPtr
;
503 DWORD style
= GetWindowLongW(hwnd
, GWL_STYLE
);
505 if (infoPtr
->nTool
== -1) {
506 TRACE("invalid tool (-1)!\n");
510 infoPtr
->nCurrentTool
= infoPtr
->nTool
;
512 TRACE("Show tooltip pre %d! (%p)\n", infoPtr
->nTool
, hwnd
);
514 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nCurrentTool
);
516 if (infoPtr
->szTipText
[0] == L
'\0') {
517 infoPtr
->nCurrentTool
= -1;
521 TRACE("Show tooltip %d!\n", infoPtr
->nCurrentTool
);
522 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
525 hdr
.idFrom
= toolPtr
->uId
;
527 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
528 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
530 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
532 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
533 TRACE("size %ld x %ld\n", size
.cx
, size
.cy
);
535 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
538 if (toolPtr
->uFlags
& TTF_IDISHWND
)
539 GetWindowRect ((HWND
)toolPtr
->uId
, &rc
);
542 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rc
, 2);
544 rect
.left
= (rc
.left
+ rc
.right
- size
.cx
) / 2;
545 if (style
& TTS_BALLOON
)
547 ptfx
= rc
.left
+ ((rc
.right
- rc
.left
) / 2);
548 if(rect
.top
- size
.cy
>= 0)
551 infoPtr
->bToolBelow
= FALSE
;
555 infoPtr
->bToolBelow
= TRUE
;
558 rect
.left
= max(0, rect
.left
- BALLOON_STEMINDENT
);
562 rect
.top
= rc
.bottom
+ 2;
563 infoPtr
->bToolBelow
= TRUE
;
567 GetCursorPos ((LPPOINT
)&rect
);
568 if (style
& TTS_BALLOON
)
571 if(rect
.top
- size
.cy
>= 0)
574 infoPtr
->bToolBelow
= FALSE
;
578 infoPtr
->bToolBelow
= TRUE
;
581 rect
.left
= max(0, rect
.left
- BALLOON_STEMINDENT
);
586 infoPtr
->bToolBelow
= TRUE
;
590 TRACE("pos %ld - %ld\n", rect
.left
, rect
.top
);
592 rect
.right
= rect
.left
+ size
.cx
;
593 rect
.bottom
= rect
.top
+ size
.cy
;
596 wndrect
.right
= GetSystemMetrics( SM_CXSCREEN
);
597 if( rect
.right
> wndrect
.right
) {
598 rect
.left
-= rect
.right
- wndrect
.right
+ 2;
599 rect
.right
= wndrect
.right
- 2;
601 wndrect
.bottom
= GetSystemMetrics( SM_CYSCREEN
);
602 if( rect
.bottom
> wndrect
.bottom
) {
605 if (toolPtr
->uFlags
& TTF_IDISHWND
)
606 GetWindowRect ((HWND
)toolPtr
->uId
, &rc
);
609 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rc
, 2);
611 rect
.bottom
= rc
.top
- 2;
612 rect
.top
= rect
.bottom
- size
.cy
;
615 AdjustWindowRectEx (&rect
, GetWindowLongW (hwnd
, GWL_STYLE
),
616 FALSE
, GetWindowLongW (hwnd
, GWL_EXSTYLE
));
618 if (style
& TTS_BALLOON
)
626 if(infoPtr
->bToolBelow
)
630 pts
[1].x
= max(BALLOON_STEMINDENT
, ptfx
- (BALLOON_STEMWIDTH
/ 2));
631 pts
[1].y
= BALLOON_STEMHEIGHT
;
632 pts
[2].x
= pts
[1].x
+ BALLOON_STEMWIDTH
;
634 if(pts
[2].x
> (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
)
636 pts
[2].x
= (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
;
637 pts
[1].x
= pts
[2].x
- BALLOON_STEMWIDTH
;
642 pts
[0].x
= max(BALLOON_STEMINDENT
, ptfx
- (BALLOON_STEMWIDTH
/ 2));
643 pts
[0].y
= (rect
.bottom
- rect
.top
) - BALLOON_STEMHEIGHT
;
644 pts
[1].x
= pts
[0].x
+ BALLOON_STEMWIDTH
;
647 pts
[2].y
= (rect
.bottom
- rect
.top
);
648 if(pts
[1].x
> (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
)
650 pts
[1].x
= (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
;
651 pts
[0].x
= pts
[1].x
- BALLOON_STEMWIDTH
;
655 hrStem
= CreatePolygonRgn(pts
, sizeof(pts
) / sizeof(pts
[0]), ALTERNATE
);
657 hRgn
= CreateRoundRectRgn(0,
658 (infoPtr
->bToolBelow
? BALLOON_STEMHEIGHT
: 0),
659 rect
.right
- rect
.left
,
660 (infoPtr
->bToolBelow
? rect
.bottom
- rect
.top
: rect
.bottom
- rect
.top
- BALLOON_STEMHEIGHT
),
661 BALLOON_ROUNDEDNESS
, BALLOON_ROUNDEDNESS
);
663 CombineRgn(hRgn
, hRgn
, hrStem
, RGN_OR
);
664 DeleteObject(hrStem
);
666 SetWindowRgn(hwnd
, hRgn
, FALSE
);
667 /* we don't free the region handle as the system deletes it when
668 * it is no longer needed */
671 SetWindowPos (hwnd
, HWND_TOP
, rect
.left
, rect
.top
,
672 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
673 SWP_SHOWWINDOW
| SWP_NOACTIVATE
);
675 /* repaint the tooltip */
676 InvalidateRect(hwnd
, NULL
, TRUE
);
679 SetTimer (hwnd
, ID_TIMERPOP
, infoPtr
->nAutoPopTime
, 0);
680 TRACE("timer 2 started!\n");
681 SetTimer (hwnd
, ID_TIMERLEAVE
, infoPtr
->nReshowTime
, 0);
682 TRACE("timer 3 started!\n");
687 TOOLTIPS_Hide (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
689 TTTOOL_INFO
*toolPtr
;
692 TRACE("Hide tooltip %d! (%p)\n", infoPtr
->nCurrentTool
, hwnd
);
694 if (infoPtr
->nCurrentTool
== -1)
697 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
698 KillTimer (hwnd
, ID_TIMERPOP
);
701 hdr
.idFrom
= toolPtr
->uId
;
703 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
704 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
706 infoPtr
->nCurrentTool
= -1;
708 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0,
709 SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
714 TOOLTIPS_TrackShow (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
716 TTTOOL_INFO
*toolPtr
;
721 if (infoPtr
->nTrackTool
== -1) {
722 TRACE("invalid tracking tool (-1)!\n");
726 TRACE("show tracking tooltip pre %d!\n", infoPtr
->nTrackTool
);
728 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nTrackTool
);
730 if (infoPtr
->szTipText
[0] == L
'\0') {
731 infoPtr
->nTrackTool
= -1;
735 TRACE("show tracking tooltip %d!\n", infoPtr
->nTrackTool
);
736 toolPtr
= &infoPtr
->tools
[infoPtr
->nTrackTool
];
739 hdr
.idFrom
= toolPtr
->uId
;
741 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
742 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
744 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
746 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
747 TRACE("size %ld x %ld\n", size
.cx
, size
.cy
);
749 if (toolPtr
->uFlags
& TTF_ABSOLUTE
) {
750 rect
.left
= infoPtr
->xTrackPos
;
751 rect
.top
= infoPtr
->yTrackPos
;
753 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
754 rect
.left
-= (size
.cx
/ 2);
755 rect
.top
-= (size
.cy
/ 2);
761 if (toolPtr
->uFlags
& TTF_IDISHWND
)
762 GetWindowRect ((HWND
)toolPtr
->uId
, &rcTool
);
764 rcTool
= toolPtr
->rect
;
765 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rcTool
, 2);
768 GetCursorPos ((LPPOINT
)&rect
);
771 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
772 rect
.left
-= (size
.cx
/ 2);
773 rect
.top
-= (size
.cy
/ 2);
776 /* smart placement */
777 if ((rect
.left
+ size
.cx
> rcTool
.left
) && (rect
.left
< rcTool
.right
) &&
778 (rect
.top
+ size
.cy
> rcTool
.top
) && (rect
.top
< rcTool
.bottom
))
779 rect
.left
= rcTool
.right
;
782 TRACE("pos %ld - %ld\n", rect
.left
, rect
.top
);
784 rect
.right
= rect
.left
+ size
.cx
;
785 rect
.bottom
= rect
.top
+ size
.cy
;
787 AdjustWindowRectEx (&rect
, GetWindowLongW (hwnd
, GWL_STYLE
),
788 FALSE
, GetWindowLongW (hwnd
, GWL_EXSTYLE
));
790 if (GetWindowLongW(hwnd
, GWL_STYLE
) & TTS_BALLOON
)
794 /* FIXME: need to add pointy bit using CreatePolyRgn & CombinRgn */
795 hRgn
= CreateRoundRectRgn(0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, BALLOON_ROUNDEDNESS
, BALLOON_ROUNDEDNESS
);
797 SetWindowRgn(hwnd
, hRgn
, FALSE
);
798 /* we don't free the region handle as the system deletes it when
799 * it is no longer needed */
802 SetWindowPos (hwnd
, HWND_TOP
, rect
.left
, rect
.top
,
803 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
804 SWP_SHOWWINDOW
| SWP_NOACTIVATE
);
806 InvalidateRect(hwnd
, NULL
, TRUE
);
812 TOOLTIPS_TrackHide (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
814 TTTOOL_INFO
*toolPtr
;
817 TRACE("hide tracking tooltip %d\n", infoPtr
->nTrackTool
);
819 if (infoPtr
->nTrackTool
== -1)
822 toolPtr
= &infoPtr
->tools
[infoPtr
->nTrackTool
];
825 hdr
.idFrom
= toolPtr
->uId
;
827 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
828 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
830 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0,
831 SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
836 TOOLTIPS_GetToolFromInfoA (TOOLTIPS_INFO
*infoPtr
, LPTTTOOLINFOA lpToolInfo
)
838 TTTOOL_INFO
*toolPtr
;
841 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
842 toolPtr
= &infoPtr
->tools
[nTool
];
844 if (!(toolPtr
->uFlags
& TTF_IDISHWND
) &&
845 (lpToolInfo
->hwnd
== toolPtr
->hwnd
) &&
846 (lpToolInfo
->uId
== toolPtr
->uId
))
850 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
851 toolPtr
= &infoPtr
->tools
[nTool
];
853 if ((toolPtr
->uFlags
& TTF_IDISHWND
) &&
854 (lpToolInfo
->uId
== toolPtr
->uId
))
863 TOOLTIPS_GetToolFromInfoW (TOOLTIPS_INFO
*infoPtr
, LPTTTOOLINFOW lpToolInfo
)
865 TTTOOL_INFO
*toolPtr
;
868 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
869 toolPtr
= &infoPtr
->tools
[nTool
];
871 if (!(toolPtr
->uFlags
& TTF_IDISHWND
) &&
872 (lpToolInfo
->hwnd
== toolPtr
->hwnd
) &&
873 (lpToolInfo
->uId
== toolPtr
->uId
))
877 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
878 toolPtr
= &infoPtr
->tools
[nTool
];
880 if ((toolPtr
->uFlags
& TTF_IDISHWND
) &&
881 (lpToolInfo
->uId
== toolPtr
->uId
))
890 TOOLTIPS_GetToolFromPoint (TOOLTIPS_INFO
*infoPtr
, HWND hwnd
, LPPOINT lpPt
)
892 TTTOOL_INFO
*toolPtr
;
895 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
896 toolPtr
= &infoPtr
->tools
[nTool
];
898 if (!(toolPtr
->uFlags
& TTF_IDISHWND
)) {
899 if (hwnd
!= toolPtr
->hwnd
)
901 if (!PtInRect (&toolPtr
->rect
, *lpPt
))
907 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
908 toolPtr
= &infoPtr
->tools
[nTool
];
910 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
911 if ((HWND
)toolPtr
->uId
== hwnd
)
921 TOOLTIPS_IsWindowActive (HWND hwnd
)
923 HWND hwndActive
= GetActiveWindow ();
926 if (hwndActive
== hwnd
)
928 return IsChild (hwndActive
, hwnd
);
933 TOOLTIPS_CheckTool (HWND hwnd
, BOOL bShowTest
)
935 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
941 hwndTool
= (HWND
)SendMessageW (hwnd
, TTM_WINDOWFROMPOINT
, 0, (LPARAM
)&pt
);
945 ScreenToClient (hwndTool
, &pt
);
946 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, hwndTool
, &pt
);
950 if (!(GetWindowLongW (hwnd
, GWL_STYLE
) & TTS_ALWAYSTIP
) && bShowTest
) {
951 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd
, GW_OWNER
)))
955 TRACE("tool %d\n", nTool
);
962 TOOLTIPS_Activate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
964 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
966 infoPtr
->bActive
= (BOOL
)wParam
;
968 if (infoPtr
->bActive
)
969 TRACE("activate!\n");
971 if (!(infoPtr
->bActive
) && (infoPtr
->nCurrentTool
!= -1))
972 TOOLTIPS_Hide (hwnd
, infoPtr
);
979 TOOLTIPS_AddToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
981 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
982 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
983 TTTOOL_INFO
*toolPtr
;
986 if (lpToolInfo
== NULL
)
988 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
991 TRACE("add tool (%p) %p %d%s!\n",
992 hwnd
, lpToolInfo
->hwnd
, lpToolInfo
->uId
,
993 (lpToolInfo
->uFlags
& TTF_IDISHWND
) ? " TTF_IDISHWND" : "");
995 if (infoPtr
->uNumTools
== 0) {
996 infoPtr
->tools
= Alloc (sizeof(TTTOOL_INFO
));
997 toolPtr
= infoPtr
->tools
;
1000 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1002 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
+ 1));
1003 memcpy (infoPtr
->tools
, oldTools
,
1004 infoPtr
->uNumTools
* sizeof(TTTOOL_INFO
));
1006 toolPtr
= &infoPtr
->tools
[infoPtr
->uNumTools
];
1009 infoPtr
->uNumTools
++;
1011 /* copy tool data */
1012 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
1013 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
1014 toolPtr
->uId
= lpToolInfo
->uId
;
1015 toolPtr
->rect
= lpToolInfo
->rect
;
1016 toolPtr
->hinst
= lpToolInfo
->hinst
;
1018 if (HIWORD(lpToolInfo
->lpszText
) == 0) {
1019 TRACE("add string id %x!\n", (int)lpToolInfo
->lpszText
);
1020 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
1022 else if (lpToolInfo
->lpszText
) {
1023 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
) {
1024 TRACE("add CALLBACK!\n");
1025 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
1028 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
1030 TRACE("add text \"%s\"!\n", lpToolInfo
->lpszText
);
1031 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
1032 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
1033 toolPtr
->lpszText
, len
);
1037 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1038 toolPtr
->lParam
= lpToolInfo
->lParam
;
1040 /* install subclassing hook */
1041 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1042 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1043 SetWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1,
1047 SetWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1,
1050 TRACE("subclassing installed!\n");
1053 nResult
= (INT
) SendMessageW (toolPtr
->hwnd
, WM_NOTIFYFORMAT
,
1054 (WPARAM
)hwnd
, (LPARAM
)NF_QUERY
);
1055 if (nResult
== NFR_ANSI
) {
1056 toolPtr
->bNotifyUnicode
= FALSE
;
1057 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1058 } else if (nResult
== NFR_UNICODE
) {
1059 toolPtr
->bNotifyUnicode
= TRUE
;
1060 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1062 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1070 TOOLTIPS_AddToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1072 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1073 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1074 TTTOOL_INFO
*toolPtr
;
1077 if (lpToolInfo
== NULL
)
1079 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1082 TRACE("add tool (%p) %p %d%s!\n",
1083 hwnd
, lpToolInfo
->hwnd
, lpToolInfo
->uId
,
1084 (lpToolInfo
->uFlags
& TTF_IDISHWND
) ? " TTF_IDISHWND" : "");
1086 if (infoPtr
->uNumTools
== 0) {
1087 infoPtr
->tools
= Alloc (sizeof(TTTOOL_INFO
));
1088 toolPtr
= infoPtr
->tools
;
1091 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1093 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
+ 1));
1094 memcpy (infoPtr
->tools
, oldTools
,
1095 infoPtr
->uNumTools
* sizeof(TTTOOL_INFO
));
1097 toolPtr
= &infoPtr
->tools
[infoPtr
->uNumTools
];
1100 infoPtr
->uNumTools
++;
1102 /* copy tool data */
1103 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
1104 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
1105 toolPtr
->uId
= lpToolInfo
->uId
;
1106 toolPtr
->rect
= lpToolInfo
->rect
;
1107 toolPtr
->hinst
= lpToolInfo
->hinst
;
1109 if (HIWORD(lpToolInfo
->lpszText
) == 0) {
1110 TRACE("add string id %x!\n", (int)lpToolInfo
->lpszText
);
1111 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
1113 else if (lpToolInfo
->lpszText
) {
1114 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
) {
1115 TRACE("add CALLBACK!\n");
1116 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
1119 INT len
= lstrlenW (lpToolInfo
->lpszText
);
1120 TRACE("add text %s!\n",
1121 debugstr_w(lpToolInfo
->lpszText
));
1122 toolPtr
->lpszText
= Alloc ((len
+ 1)*sizeof(WCHAR
));
1123 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
1127 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1128 toolPtr
->lParam
= lpToolInfo
->lParam
;
1130 /* install subclassing hook */
1131 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1132 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1133 SetWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1,
1137 SetWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1,
1140 TRACE("subclassing installed!\n");
1143 nResult
= (INT
) SendMessageW (toolPtr
->hwnd
, WM_NOTIFYFORMAT
,
1144 (WPARAM
)hwnd
, (LPARAM
)NF_QUERY
);
1145 if (nResult
== NFR_ANSI
) {
1146 toolPtr
->bNotifyUnicode
= FALSE
;
1147 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1148 } else if (nResult
== NFR_UNICODE
) {
1149 toolPtr
->bNotifyUnicode
= TRUE
;
1150 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1152 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1160 TOOLTIPS_DelToolCommon (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, INT nTool
)
1162 TTTOOL_INFO
*toolPtr
;
1164 TRACE("tool %d\n", nTool
);
1169 /* make sure the tooltip has disappeared before deleting it */
1170 TOOLTIPS_Hide(hwnd
, infoPtr
);
1172 /* delete text string */
1173 toolPtr
= &infoPtr
->tools
[nTool
];
1174 if (toolPtr
->lpszText
) {
1175 if ( (toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
) &&
1176 (HIWORD((INT
)toolPtr
->lpszText
) != 0) )
1177 Free (toolPtr
->lpszText
);
1180 /* remove subclassing */
1181 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1182 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1183 RemoveWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1);
1186 RemoveWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1);
1190 /* delete tool from tool list */
1191 if (infoPtr
->uNumTools
== 1) {
1192 Free (infoPtr
->tools
);
1193 infoPtr
->tools
= NULL
;
1196 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1198 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
- 1));
1201 memcpy (&infoPtr
->tools
[0], &oldTools
[0],
1202 nTool
* sizeof(TTTOOL_INFO
));
1204 if (nTool
< infoPtr
->uNumTools
- 1)
1205 memcpy (&infoPtr
->tools
[nTool
], &oldTools
[nTool
+ 1],
1206 (infoPtr
->uNumTools
- nTool
- 1) * sizeof(TTTOOL_INFO
));
1211 /* update any indices affected by delete */
1213 /* destroying tool that mouse was on on last relayed mouse move */
1214 if (infoPtr
->nTool
== nTool
)
1215 /* -1 means no current tool (0 means first tool) */
1216 infoPtr
->nTool
= -1;
1217 else if (infoPtr
->nTool
> nTool
)
1220 if (infoPtr
->nTrackTool
== nTool
)
1221 /* -1 means no current tool (0 means first tool) */
1222 infoPtr
->nTrackTool
= -1;
1223 else if (infoPtr
->nTrackTool
> nTool
)
1224 infoPtr
->nTrackTool
--;
1226 if (infoPtr
->nCurrentTool
== nTool
)
1227 /* -1 means no current tool (0 means first tool) */
1228 infoPtr
->nCurrentTool
= -1;
1229 else if (infoPtr
->nCurrentTool
> nTool
)
1230 infoPtr
->nCurrentTool
--;
1232 infoPtr
->uNumTools
--;
1236 TOOLTIPS_DelToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1238 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1239 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1242 if (lpToolInfo
== NULL
)
1244 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1246 if (infoPtr
->uNumTools
== 0)
1249 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1251 TOOLTIPS_DelToolCommon (hwnd
, infoPtr
, nTool
);
1258 TOOLTIPS_DelToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1260 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1261 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1264 if (lpToolInfo
== NULL
)
1266 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1268 if (infoPtr
->uNumTools
== 0)
1271 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1273 TOOLTIPS_DelToolCommon (hwnd
, infoPtr
, nTool
);
1280 TOOLTIPS_EnumToolsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1282 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1283 UINT uIndex
= (UINT
)wParam
;
1284 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1285 TTTOOL_INFO
*toolPtr
;
1287 if (lpToolInfo
== NULL
)
1289 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1291 if (uIndex
>= infoPtr
->uNumTools
)
1294 TRACE("index=%u\n", uIndex
);
1296 toolPtr
= &infoPtr
->tools
[uIndex
];
1298 /* copy tool data */
1299 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1300 lpToolInfo
->hwnd
= toolPtr
->hwnd
;
1301 lpToolInfo
->uId
= toolPtr
->uId
;
1302 lpToolInfo
->rect
= toolPtr
->rect
;
1303 lpToolInfo
->hinst
= toolPtr
->hinst
;
1304 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1305 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1307 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1308 lpToolInfo
->lParam
= toolPtr
->lParam
;
1315 TOOLTIPS_EnumToolsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1317 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1318 UINT uIndex
= (UINT
)wParam
;
1319 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1320 TTTOOL_INFO
*toolPtr
;
1322 if (lpToolInfo
== NULL
)
1324 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1326 if (uIndex
>= infoPtr
->uNumTools
)
1329 TRACE("index=%u\n", uIndex
);
1331 toolPtr
= &infoPtr
->tools
[uIndex
];
1333 /* copy tool data */
1334 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1335 lpToolInfo
->hwnd
= toolPtr
->hwnd
;
1336 lpToolInfo
->uId
= toolPtr
->uId
;
1337 lpToolInfo
->rect
= toolPtr
->rect
;
1338 lpToolInfo
->hinst
= toolPtr
->hinst
;
1339 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1340 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1342 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1343 lpToolInfo
->lParam
= toolPtr
->lParam
;
1349 TOOLTIPS_GetBubbleSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1351 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1352 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1356 if (lpToolInfo
== NULL
)
1358 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1361 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1362 if (nTool
== -1) return 0;
1364 TRACE("tool %d\n", nTool
);
1366 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
1367 TRACE("size %ld x %ld\n", size
.cx
, size
.cy
);
1369 return MAKELRESULT(size
.cx
, size
.cy
);
1373 TOOLTIPS_GetCurrentToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1375 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1376 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1377 TTTOOL_INFO
*toolPtr
;
1379 if (lpToolInfo
== NULL
)
1381 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1385 if (infoPtr
->nCurrentTool
> -1) {
1386 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
1388 /* copy tool data */
1389 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1390 lpToolInfo
->rect
= toolPtr
->rect
;
1391 lpToolInfo
->hinst
= toolPtr
->hinst
;
1392 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1393 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1395 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1396 lpToolInfo
->lParam
= toolPtr
->lParam
;
1404 return (infoPtr
->nCurrentTool
!= -1);
1409 TOOLTIPS_GetCurrentToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1411 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1412 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1413 TTTOOL_INFO
*toolPtr
;
1415 if (lpToolInfo
== NULL
)
1417 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1421 if (infoPtr
->nCurrentTool
> -1) {
1422 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
1424 /* copy tool data */
1425 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1426 lpToolInfo
->rect
= toolPtr
->rect
;
1427 lpToolInfo
->hinst
= toolPtr
->hinst
;
1428 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1429 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1431 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1432 lpToolInfo
->lParam
= toolPtr
->lParam
;
1440 return (infoPtr
->nCurrentTool
!= -1);
1445 TOOLTIPS_GetDelayTime (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1447 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1451 return infoPtr
->nReshowTime
;
1454 return infoPtr
->nAutoPopTime
;
1457 case TTDT_AUTOMATIC
: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */
1458 return infoPtr
->nInitialTime
;
1461 WARN("Invalid wParam %x\n", wParam
);
1470 TOOLTIPS_GetMargin (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1472 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1473 LPRECT lpRect
= (LPRECT
)lParam
;
1475 lpRect
->left
= infoPtr
->rcMargin
.left
;
1476 lpRect
->right
= infoPtr
->rcMargin
.right
;
1477 lpRect
->bottom
= infoPtr
->rcMargin
.bottom
;
1478 lpRect
->top
= infoPtr
->rcMargin
.top
;
1484 inline static LRESULT
1485 TOOLTIPS_GetMaxTipWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1487 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1489 return infoPtr
->nMaxTipWidth
;
1494 TOOLTIPS_GetTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1496 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1497 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1500 if (lpToolInfo
== NULL
)
1502 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1505 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1506 if (nTool
== -1) return 0;
1508 /* NB this API is broken, there is no way for the app to determine
1509 what size buffer it requires nor a way to specify how long the
1510 one it supplies is. We'll assume it's upto INFOTIPSIZE */
1512 WideCharToMultiByte(CP_ACP
, 0, infoPtr
->tools
[nTool
].lpszText
, -1,
1513 lpToolInfo
->lpszText
, INFOTIPSIZE
, NULL
, NULL
);
1520 TOOLTIPS_GetTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1522 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1523 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1526 if (lpToolInfo
== NULL
)
1528 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1531 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1532 if (nTool
== -1) return 0;
1534 strcpyW (lpToolInfo
->lpszText
, infoPtr
->tools
[nTool
].lpszText
);
1540 inline static LRESULT
1541 TOOLTIPS_GetTipBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1543 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1544 return infoPtr
->clrBk
;
1548 inline static LRESULT
1549 TOOLTIPS_GetTipTextColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1551 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1552 return infoPtr
->clrText
;
1556 inline static LRESULT
1557 TOOLTIPS_GetToolCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1559 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1560 return infoPtr
->uNumTools
;
1565 TOOLTIPS_GetToolInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1567 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1568 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1569 TTTOOL_INFO
*toolPtr
;
1572 if (lpToolInfo
== NULL
)
1574 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1576 if (infoPtr
->uNumTools
== 0)
1579 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1583 TRACE("tool %d\n", nTool
);
1585 toolPtr
= &infoPtr
->tools
[nTool
];
1587 /* copy tool data */
1588 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1589 lpToolInfo
->rect
= toolPtr
->rect
;
1590 lpToolInfo
->hinst
= toolPtr
->hinst
;
1591 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1592 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1594 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1595 lpToolInfo
->lParam
= toolPtr
->lParam
;
1602 TOOLTIPS_GetToolInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1604 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1605 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1606 TTTOOL_INFO
*toolPtr
;
1609 if (lpToolInfo
== NULL
)
1611 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1613 if (infoPtr
->uNumTools
== 0)
1616 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1620 TRACE("tool %d\n", nTool
);
1622 toolPtr
= &infoPtr
->tools
[nTool
];
1624 /* copy tool data */
1625 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1626 lpToolInfo
->rect
= toolPtr
->rect
;
1627 lpToolInfo
->hinst
= toolPtr
->hinst
;
1628 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1629 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1631 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1632 lpToolInfo
->lParam
= toolPtr
->lParam
;
1639 TOOLTIPS_HitTestA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1641 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1642 LPTTHITTESTINFOA lptthit
= (LPTTHITTESTINFOA
)lParam
;
1643 TTTOOL_INFO
*toolPtr
;
1649 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, lptthit
->hwnd
, &lptthit
->pt
);
1653 TRACE("tool %d!\n", nTool
);
1655 /* copy tool data */
1656 if (lptthit
->ti
.cbSize
>= sizeof(TTTOOLINFOA
)) {
1657 toolPtr
= &infoPtr
->tools
[nTool
];
1659 lptthit
->ti
.uFlags
= toolPtr
->uFlags
;
1660 lptthit
->ti
.hwnd
= toolPtr
->hwnd
;
1661 lptthit
->ti
.uId
= toolPtr
->uId
;
1662 lptthit
->ti
.rect
= toolPtr
->rect
;
1663 lptthit
->ti
.hinst
= toolPtr
->hinst
;
1664 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1665 lptthit
->ti
.lpszText
= NULL
; /* FIXME */
1666 lptthit
->ti
.lParam
= toolPtr
->lParam
;
1674 TOOLTIPS_HitTestW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1676 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1677 LPTTHITTESTINFOW lptthit
= (LPTTHITTESTINFOW
)lParam
;
1678 TTTOOL_INFO
*toolPtr
;
1684 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, lptthit
->hwnd
, &lptthit
->pt
);
1688 TRACE("tool %d!\n", nTool
);
1690 /* copy tool data */
1691 if (lptthit
->ti
.cbSize
>= sizeof(TTTOOLINFOW
)) {
1692 toolPtr
= &infoPtr
->tools
[nTool
];
1694 lptthit
->ti
.uFlags
= toolPtr
->uFlags
;
1695 lptthit
->ti
.hwnd
= toolPtr
->hwnd
;
1696 lptthit
->ti
.uId
= toolPtr
->uId
;
1697 lptthit
->ti
.rect
= toolPtr
->rect
;
1698 lptthit
->ti
.hinst
= toolPtr
->hinst
;
1699 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1700 lptthit
->ti
.lpszText
= NULL
; /* FIXME */
1701 lptthit
->ti
.lParam
= toolPtr
->lParam
;
1709 TOOLTIPS_NewToolRectA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1711 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1712 LPTTTOOLINFOA lpti
= (LPTTTOOLINFOA
)lParam
;
1717 if (lpti
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1720 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpti
);
1722 TRACE("nTool = %d, rect = %s\n", nTool
, wine_dbgstr_rect(&lpti
->rect
));
1724 if (nTool
== -1) return 0;
1726 infoPtr
->tools
[nTool
].rect
= lpti
->rect
;
1733 TOOLTIPS_NewToolRectW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1735 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1736 LPTTTOOLINFOW lpti
= (LPTTTOOLINFOW
)lParam
;
1741 if (lpti
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1744 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpti
);
1746 TRACE("nTool = %d, rect = %s\n", nTool
, wine_dbgstr_rect(&lpti
->rect
));
1748 if (nTool
== -1) return 0;
1750 infoPtr
->tools
[nTool
].rect
= lpti
->rect
;
1756 inline static LRESULT
1757 TOOLTIPS_Pop (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1759 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1760 TOOLTIPS_Hide (hwnd
, infoPtr
);
1767 TOOLTIPS_RelayEvent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1769 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1770 LPMSG lpMsg
= (LPMSG
)lParam
;
1775 ERR("lpMsg == NULL!\n");
1779 switch (lpMsg
->message
) {
1780 case WM_LBUTTONDOWN
:
1782 case WM_MBUTTONDOWN
:
1784 case WM_RBUTTONDOWN
:
1786 TOOLTIPS_Hide (hwnd
, infoPtr
);
1790 pt
.x
= LOWORD(lpMsg
->lParam
);
1791 pt
.y
= HIWORD(lpMsg
->lParam
);
1792 nOldTool
= infoPtr
->nTool
;
1793 infoPtr
->nTool
= TOOLTIPS_GetToolFromPoint(infoPtr
, lpMsg
->hwnd
,
1795 TRACE("tool (%p) %d %d %d\n", hwnd
, nOldTool
,
1796 infoPtr
->nTool
, infoPtr
->nCurrentTool
);
1797 TRACE("WM_MOUSEMOVE (%p %ld %ld)\n", hwnd
, pt
.x
, pt
.y
);
1799 if (infoPtr
->nTool
!= nOldTool
) {
1800 if(infoPtr
->nTool
== -1) { /* Moved out of all tools */
1801 TOOLTIPS_Hide(hwnd
, infoPtr
);
1802 KillTimer(hwnd
, ID_TIMERLEAVE
);
1803 } else if (nOldTool
== -1) { /* Moved from outside */
1804 if(infoPtr
->bActive
) {
1805 SetTimer(hwnd
, ID_TIMERSHOW
, infoPtr
->nInitialTime
, 0);
1806 TRACE("timer 1 started!\n");
1808 } else { /* Moved from one to another */
1809 TOOLTIPS_Hide (hwnd
, infoPtr
);
1810 KillTimer(hwnd
, ID_TIMERLEAVE
);
1811 if(infoPtr
->bActive
) {
1812 SetTimer (hwnd
, ID_TIMERSHOW
, infoPtr
->nReshowTime
, 0);
1813 TRACE("timer 1 started!\n");
1816 } else if(infoPtr
->nCurrentTool
!= -1) { /* restart autopop */
1817 KillTimer(hwnd
, ID_TIMERPOP
);
1818 SetTimer(hwnd
, ID_TIMERPOP
, infoPtr
->nAutoPopTime
, 0);
1819 TRACE("timer 2 restarted\n");
1820 } else if(infoPtr
->nTool
!= -1 && infoPtr
->bActive
) {
1821 /* previous show attempt didn't result in tooltip so try again */
1822 SetTimer(hwnd
, ID_TIMERSHOW
, infoPtr
->nInitialTime
, 0);
1823 TRACE("timer 1 started!\n");
1833 TOOLTIPS_SetDelayTime (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1835 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1836 INT nTime
= (INT
)LOWORD(lParam
);
1839 case TTDT_AUTOMATIC
:
1841 nTime
= GetDoubleClickTime();
1842 infoPtr
->nReshowTime
= nTime
/ 5;
1843 infoPtr
->nAutoPopTime
= nTime
* 10;
1844 infoPtr
->nInitialTime
= nTime
;
1849 nTime
= GetDoubleClickTime() / 5;
1850 infoPtr
->nReshowTime
= nTime
;
1855 nTime
= GetDoubleClickTime() * 10;
1856 infoPtr
->nAutoPopTime
= nTime
;
1861 nTime
= GetDoubleClickTime();
1862 infoPtr
->nInitialTime
= nTime
;
1866 WARN("Invalid wParam %x\n", wParam
);
1875 TOOLTIPS_SetMargin (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1877 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1878 LPRECT lpRect
= (LPRECT
)lParam
;
1880 infoPtr
->rcMargin
.left
= lpRect
->left
;
1881 infoPtr
->rcMargin
.right
= lpRect
->right
;
1882 infoPtr
->rcMargin
.bottom
= lpRect
->bottom
;
1883 infoPtr
->rcMargin
.top
= lpRect
->top
;
1889 inline static LRESULT
1890 TOOLTIPS_SetMaxTipWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1892 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1893 INT nTemp
= infoPtr
->nMaxTipWidth
;
1895 infoPtr
->nMaxTipWidth
= (INT
)lParam
;
1901 inline static LRESULT
1902 TOOLTIPS_SetTipBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1904 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1906 infoPtr
->clrBk
= (COLORREF
)wParam
;
1912 inline static LRESULT
1913 TOOLTIPS_SetTipTextColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1915 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1917 infoPtr
->clrText
= (COLORREF
)wParam
;
1924 TOOLTIPS_SetTitleA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1926 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1927 LPCSTR pszTitle
= (LPCSTR
)lParam
;
1928 UINT_PTR uTitleIcon
= (UINT_PTR
)wParam
;
1931 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd
, debugstr_a(pszTitle
),
1934 Free(infoPtr
->pszTitle
);
1938 size
= sizeof(WCHAR
)*MultiByteToWideChar(CP_ACP
, 0, pszTitle
, -1, NULL
, 0);
1939 infoPtr
->pszTitle
= Alloc(size
);
1940 if (!infoPtr
->pszTitle
)
1942 MultiByteToWideChar(CP_ACP
, 0, pszTitle
, -1, infoPtr
->pszTitle
, size
/sizeof(WCHAR
));
1945 infoPtr
->pszTitle
= NULL
;
1947 if (uTitleIcon
<= TTI_ERROR
)
1948 infoPtr
->hTitleIcon
= hTooltipIcons
[uTitleIcon
];
1950 infoPtr
->hTitleIcon
= CopyIcon((HICON
)wParam
);
1957 TOOLTIPS_SetTitleW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1959 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1960 LPCWSTR pszTitle
= (LPCWSTR
)lParam
;
1961 UINT_PTR uTitleIcon
= (UINT_PTR
)wParam
;
1964 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd
, debugstr_w(pszTitle
),
1967 Free(infoPtr
->pszTitle
);
1971 size
= (strlenW(pszTitle
)+1)*sizeof(WCHAR
);
1972 infoPtr
->pszTitle
= Alloc(size
);
1973 if (!infoPtr
->pszTitle
)
1975 memcpy(infoPtr
->pszTitle
, pszTitle
, size
);
1978 infoPtr
->pszTitle
= NULL
;
1980 if (uTitleIcon
<= TTI_ERROR
)
1981 infoPtr
->hTitleIcon
= hTooltipIcons
[uTitleIcon
];
1983 infoPtr
->hTitleIcon
= CopyIcon((HICON
)wParam
);
1985 TRACE("icon = %p\n", infoPtr
->hTitleIcon
);
1992 TOOLTIPS_SetToolInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1994 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1995 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1996 TTTOOL_INFO
*toolPtr
;
1999 if (lpToolInfo
== NULL
)
2001 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2004 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2005 if (nTool
== -1) return 0;
2007 TRACE("tool %d\n", nTool
);
2009 toolPtr
= &infoPtr
->tools
[nTool
];
2011 /* copy tool data */
2012 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
2013 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
2014 toolPtr
->uId
= lpToolInfo
->uId
;
2015 toolPtr
->rect
= lpToolInfo
->rect
;
2016 toolPtr
->hinst
= lpToolInfo
->hinst
;
2018 if (HIWORD(lpToolInfo
->lpszText
) == 0) {
2019 TRACE("set string id %x!\n", (INT
)lpToolInfo
->lpszText
);
2020 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
2022 else if (lpToolInfo
->lpszText
) {
2023 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
)
2024 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2026 if ( (toolPtr
->lpszText
) &&
2027 (HIWORD((INT
)toolPtr
->lpszText
) != 0) ) {
2028 Free (toolPtr
->lpszText
);
2029 toolPtr
->lpszText
= NULL
;
2031 if (lpToolInfo
->lpszText
) {
2032 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
,
2034 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
2035 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
2036 toolPtr
->lpszText
, len
);
2041 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
2042 toolPtr
->lParam
= lpToolInfo
->lParam
;
2049 TOOLTIPS_SetToolInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2051 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2052 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
2053 TTTOOL_INFO
*toolPtr
;
2056 if (lpToolInfo
== NULL
)
2058 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
2061 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
2062 if (nTool
== -1) return 0;
2064 TRACE("tool %d\n", nTool
);
2066 toolPtr
= &infoPtr
->tools
[nTool
];
2068 /* copy tool data */
2069 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
2070 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
2071 toolPtr
->uId
= lpToolInfo
->uId
;
2072 toolPtr
->rect
= lpToolInfo
->rect
;
2073 toolPtr
->hinst
= lpToolInfo
->hinst
;
2075 if (HIWORD(lpToolInfo
->lpszText
) == 0) {
2076 TRACE("set string id %x!\n", (INT
)lpToolInfo
->lpszText
);
2077 toolPtr
->lpszText
= lpToolInfo
->lpszText
;
2080 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
)
2081 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2083 if ( (toolPtr
->lpszText
) &&
2084 (HIWORD((INT
)toolPtr
->lpszText
) != 0) ) {
2085 Free (toolPtr
->lpszText
);
2086 toolPtr
->lpszText
= NULL
;
2088 if (lpToolInfo
->lpszText
) {
2089 INT len
= lstrlenW (lpToolInfo
->lpszText
);
2090 toolPtr
->lpszText
= Alloc ((len
+1)*sizeof(WCHAR
));
2091 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
2096 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
2097 toolPtr
->lParam
= lpToolInfo
->lParam
;
2099 if (infoPtr
->nCurrentTool
== nTool
)
2101 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nCurrentTool
);
2103 if (infoPtr
->szTipText
[0] == 0)
2104 TOOLTIPS_Hide(hwnd
, infoPtr
);
2106 TOOLTIPS_Show (hwnd
, infoPtr
);
2114 TOOLTIPS_TrackActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2116 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2119 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2121 if (lpToolInfo
== NULL
)
2123 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2127 infoPtr
->nTrackTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2128 if (infoPtr
->nTrackTool
!= -1) {
2129 TRACE("activated!\n");
2130 infoPtr
->bTrackActive
= TRUE
;
2131 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2136 TOOLTIPS_TrackHide (hwnd
, infoPtr
);
2138 infoPtr
->bTrackActive
= FALSE
;
2139 infoPtr
->nTrackTool
= -1;
2141 TRACE("deactivated!\n");
2149 TOOLTIPS_TrackPosition (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2151 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2153 infoPtr
->xTrackPos
= (INT
)LOWORD(lParam
);
2154 infoPtr
->yTrackPos
= (INT
)HIWORD(lParam
);
2156 if (infoPtr
->bTrackActive
) {
2158 infoPtr
->xTrackPos
, infoPtr
->yTrackPos
);
2160 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2168 TOOLTIPS_Update (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2170 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2172 if (infoPtr
->nCurrentTool
!= -1)
2173 UpdateWindow (hwnd
);
2180 TOOLTIPS_UpdateTipTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2182 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2183 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2184 TTTOOL_INFO
*toolPtr
;
2187 if (lpToolInfo
== NULL
)
2189 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2192 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2193 if (nTool
== -1) return 0;
2195 TRACE("tool %d\n", nTool
);
2197 toolPtr
= &infoPtr
->tools
[nTool
];
2199 /* copy tool text */
2200 toolPtr
->hinst
= lpToolInfo
->hinst
;
2202 if (HIWORD(lpToolInfo
->lpszText
) == 0){
2203 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
2205 else if (lpToolInfo
->lpszText
) {
2206 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
)
2207 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2209 if ( (toolPtr
->lpszText
) &&
2210 (HIWORD((INT
)toolPtr
->lpszText
) != 0) ) {
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
);
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 (HIWORD(lpToolInfo
->lpszText
) == 0){
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 (HIWORD((INT
)toolPtr
->lpszText
) != 0) ) {
2268 Free (toolPtr
->lpszText
);
2269 toolPtr
->lpszText
= NULL
;
2271 if (lpToolInfo
->lpszText
) {
2272 INT len
= lstrlenW (lpToolInfo
->lpszText
);
2273 toolPtr
->lpszText
= Alloc ((len
+1)*sizeof(WCHAR
));
2274 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
2279 if(infoPtr
->nCurrentTool
== -1) return 0;
2281 if (infoPtr
->bActive
)
2282 TOOLTIPS_Show (hwnd
, infoPtr
);
2283 else if (infoPtr
->bTrackActive
)
2284 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2291 TOOLTIPS_WindowFromPoint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2293 return (LRESULT
)WindowFromPoint (*((LPPOINT
)lParam
));
2299 TOOLTIPS_Create (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
2301 TOOLTIPS_INFO
*infoPtr
;
2303 /* allocate memory for info structure */
2304 infoPtr
= (TOOLTIPS_INFO
*)Alloc (sizeof(TOOLTIPS_INFO
));
2305 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
2307 /* initialize info structure */
2308 infoPtr
->bActive
= TRUE
;
2309 infoPtr
->bTrackActive
= FALSE
;
2311 infoPtr
->nMaxTipWidth
= -1;
2312 infoPtr
->nTool
= -1;
2313 infoPtr
->nCurrentTool
= -1;
2314 infoPtr
->nTrackTool
= -1;
2316 /* initialize colours and fonts */
2317 TOOLTIPS_InitSystemSettings(infoPtr
);
2319 TOOLTIPS_SetDelayTime(hwnd
, TTDT_AUTOMATIC
, 0L);
2321 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
2328 TOOLTIPS_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2330 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2331 TTTOOL_INFO
*toolPtr
;
2335 if (infoPtr
->tools
) {
2336 for (i
= 0; i
< infoPtr
->uNumTools
; i
++) {
2337 toolPtr
= &infoPtr
->tools
[i
];
2338 if (toolPtr
->lpszText
) {
2339 if ( (toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
) &&
2340 (HIWORD((INT
)toolPtr
->lpszText
) != 0) )
2342 Free (toolPtr
->lpszText
);
2343 toolPtr
->lpszText
= NULL
;
2347 /* remove subclassing */
2348 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
2349 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
2350 RemoveWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1);
2353 RemoveWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1);
2357 Free (infoPtr
->tools
);
2360 /* free title string */
2361 Free (infoPtr
->pszTitle
);
2362 /* free title icon if not a standard one */
2363 if (TOOLTIPS_GetTitleIconIndex(infoPtr
->hTitleIcon
) > TTI_ERROR
)
2364 DeleteObject(infoPtr
->hTitleIcon
);
2367 DeleteObject (infoPtr
->hFont
);
2368 DeleteObject (infoPtr
->hTitleFont
);
2370 /* free tool tips info data */
2372 SetWindowLongPtrW(hwnd
, 0, 0);
2378 TOOLTIPS_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2380 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2382 return (LRESULT
)infoPtr
->hFont
;
2387 TOOLTIPS_MouseMessage (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2389 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2391 TOOLTIPS_Hide (hwnd
, infoPtr
);
2398 TOOLTIPS_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2400 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
2401 DWORD dwExStyle
= GetWindowLongW (hwnd
, GWL_EXSTYLE
);
2403 dwStyle
&= 0x0000FFFF;
2404 dwStyle
|= (WS_POPUP
| WS_BORDER
| WS_CLIPSIBLINGS
);
2406 /* WS_BORDER only draws a border round the window rect, not the
2407 * window region, therefore it is useless to us in balloon mode */
2408 if (dwStyle
& TTS_BALLOON
) dwStyle
&= ~WS_BORDER
;
2410 SetWindowLongW (hwnd
, GWL_STYLE
, dwStyle
);
2412 dwExStyle
|= WS_EX_TOOLWINDOW
;
2413 SetWindowLongW (hwnd
, GWL_EXSTYLE
, dwExStyle
);
2420 TOOLTIPS_NCHitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2422 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2423 INT nTool
= (infoPtr
->bTrackActive
) ? infoPtr
->nTrackTool
: infoPtr
->nTool
;
2425 TRACE(" nTool=%d\n", nTool
);
2427 if ((nTool
> -1) && (nTool
< infoPtr
->uNumTools
)) {
2428 if (infoPtr
->tools
[nTool
].uFlags
& TTF_TRANSPARENT
) {
2429 TRACE("-- in transparent mode!\n");
2430 return HTTRANSPARENT
;
2434 return DefWindowProcW (hwnd
, WM_NCHITTEST
, wParam
, lParam
);
2439 TOOLTIPS_NotifyFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2441 FIXME ("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2448 TOOLTIPS_Paint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2453 hdc
= (wParam
== 0) ? BeginPaint (hwnd
, &ps
) : (HDC
)wParam
;
2454 TOOLTIPS_Refresh (hwnd
, hdc
);
2456 EndPaint (hwnd
, &ps
);
2462 TOOLTIPS_SetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2464 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2467 if(!GetObjectW((HFONT
)wParam
, sizeof(lf
), &lf
))
2470 DeleteObject (infoPtr
->hFont
);
2471 infoPtr
->hFont
= CreateFontIndirectW(&lf
);
2473 DeleteObject (infoPtr
->hTitleFont
);
2474 lf
.lfWeight
= FW_BOLD
;
2475 infoPtr
->hTitleFont
= CreateFontIndirectW(&lf
);
2477 if ((LOWORD(lParam
)) & (infoPtr
->nCurrentTool
!= -1)) {
2478 FIXME("full redraw needed!\n");
2484 /******************************************************************
2485 * TOOLTIPS_GetTextLength
2487 * This function is called when the tooltip receive a
2488 * WM_GETTEXTLENGTH message.
2492 * returns the length, in characters, of the tip text
2495 TOOLTIPS_GetTextLength(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2497 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2498 return strlenW(infoPtr
->szTipText
);
2501 /******************************************************************
2502 * TOOLTIPS_OnWMGetText
2504 * This function is called when the tooltip receive a
2505 * WM_GETTEXT message.
2506 * wParam : specifies the maximum number of characters to be copied
2507 * lParam : is the pointer to the buffer that will receive
2510 * returns the number of characters copied
2513 TOOLTIPS_OnWMGetText (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2515 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2517 LPWSTR pszText
= (LPWSTR
)lParam
;
2519 if(!infoPtr
->szTipText
|| !wParam
)
2522 res
= min(strlenW(infoPtr
->szTipText
)+1, wParam
);
2523 memcpy(pszText
, infoPtr
->szTipText
, res
*sizeof(WCHAR
));
2524 pszText
[res
-1] = '\0';
2529 TOOLTIPS_Timer (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2531 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2534 TRACE("timer %d (%p) expired!\n", wParam
, hwnd
);
2538 KillTimer (hwnd
, ID_TIMERSHOW
);
2539 nOldTool
= infoPtr
->nTool
;
2540 if ((infoPtr
->nTool
= TOOLTIPS_CheckTool (hwnd
, TRUE
)) == nOldTool
)
2541 TOOLTIPS_Show (hwnd
, infoPtr
);
2545 TOOLTIPS_Hide (hwnd
, infoPtr
);
2549 nOldTool
= infoPtr
->nTool
;
2550 infoPtr
->nTool
= TOOLTIPS_CheckTool (hwnd
, FALSE
);
2551 TRACE("tool (%p) %d %d %d\n", hwnd
, nOldTool
,
2552 infoPtr
->nTool
, infoPtr
->nCurrentTool
);
2553 if (infoPtr
->nTool
!= nOldTool
) {
2554 if(infoPtr
->nTool
== -1) { /* Moved out of all tools */
2555 TOOLTIPS_Hide(hwnd
, infoPtr
);
2556 KillTimer(hwnd
, ID_TIMERLEAVE
);
2557 } else if (nOldTool
== -1) { /* Moved from outside */
2558 ERR("How did this happen?\n");
2559 } else { /* Moved from one to another */
2560 TOOLTIPS_Hide (hwnd
, infoPtr
);
2561 KillTimer(hwnd
, ID_TIMERLEAVE
);
2562 if(infoPtr
->bActive
) {
2563 SetTimer (hwnd
, ID_TIMERSHOW
, infoPtr
->nReshowTime
, 0);
2564 TRACE("timer 1 started!\n");
2571 ERR("Unknown timer id %d\n", wParam
);
2579 TOOLTIPS_WinIniChange (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2581 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2583 TOOLTIPS_InitSystemSettings (infoPtr
);
2589 static LRESULT CALLBACK
2590 TOOLTIPS_SubclassProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
2596 case WM_LBUTTONDOWN
:
2598 case WM_MBUTTONDOWN
:
2600 case WM_RBUTTONDOWN
:
2604 msg
.wParam
= wParam
;
2605 msg
.lParam
= lParam
;
2606 TOOLTIPS_RelayEvent((HWND
)dwRef
, 0, (LPARAM
)&msg
);
2612 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
2616 static LRESULT CALLBACK
2617 TOOLTIPS_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2619 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd
, uMsg
, wParam
, lParam
);
2620 if (!TOOLTIPS_GetInfoPtr(hwnd
) && (uMsg
!= WM_CREATE
) && (uMsg
!= WM_NCCREATE
))
2621 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2625 return TOOLTIPS_Activate (hwnd
, wParam
, lParam
);
2628 return TOOLTIPS_AddToolA (hwnd
, wParam
, lParam
);
2631 return TOOLTIPS_AddToolW (hwnd
, wParam
, lParam
);
2634 return TOOLTIPS_DelToolA (hwnd
, wParam
, lParam
);
2637 return TOOLTIPS_DelToolW (hwnd
, wParam
, lParam
);
2639 case TTM_ENUMTOOLSA
:
2640 return TOOLTIPS_EnumToolsA (hwnd
, wParam
, lParam
);
2642 case TTM_ENUMTOOLSW
:
2643 return TOOLTIPS_EnumToolsW (hwnd
, wParam
, lParam
);
2645 case TTM_GETBUBBLESIZE
:
2646 return TOOLTIPS_GetBubbleSize (hwnd
, wParam
, lParam
);
2648 case TTM_GETCURRENTTOOLA
:
2649 return TOOLTIPS_GetCurrentToolA (hwnd
, wParam
, lParam
);
2651 case TTM_GETCURRENTTOOLW
:
2652 return TOOLTIPS_GetCurrentToolW (hwnd
, wParam
, lParam
);
2654 case TTM_GETDELAYTIME
:
2655 return TOOLTIPS_GetDelayTime (hwnd
, wParam
, lParam
);
2658 return TOOLTIPS_GetMargin (hwnd
, wParam
, lParam
);
2660 case TTM_GETMAXTIPWIDTH
:
2661 return TOOLTIPS_GetMaxTipWidth (hwnd
, wParam
, lParam
);
2664 return TOOLTIPS_GetTextA (hwnd
, wParam
, lParam
);
2667 return TOOLTIPS_GetTextW (hwnd
, wParam
, lParam
);
2669 case TTM_GETTIPBKCOLOR
:
2670 return TOOLTIPS_GetTipBkColor (hwnd
, wParam
, lParam
);
2672 case TTM_GETTIPTEXTCOLOR
:
2673 return TOOLTIPS_GetTipTextColor (hwnd
, wParam
, lParam
);
2675 case TTM_GETTOOLCOUNT
:
2676 return TOOLTIPS_GetToolCount (hwnd
, wParam
, lParam
);
2678 case TTM_GETTOOLINFOA
:
2679 return TOOLTIPS_GetToolInfoA (hwnd
, wParam
, lParam
);
2681 case TTM_GETTOOLINFOW
:
2682 return TOOLTIPS_GetToolInfoW (hwnd
, wParam
, lParam
);
2685 return TOOLTIPS_HitTestA (hwnd
, wParam
, lParam
);
2688 return TOOLTIPS_HitTestW (hwnd
, wParam
, lParam
);
2690 case TTM_NEWTOOLRECTA
:
2691 return TOOLTIPS_NewToolRectA (hwnd
, wParam
, lParam
);
2693 case TTM_NEWTOOLRECTW
:
2694 return TOOLTIPS_NewToolRectW (hwnd
, wParam
, lParam
);
2697 return TOOLTIPS_Pop (hwnd
, wParam
, lParam
);
2699 case TTM_RELAYEVENT
:
2700 return TOOLTIPS_RelayEvent (hwnd
, wParam
, lParam
);
2702 case TTM_SETDELAYTIME
:
2703 return TOOLTIPS_SetDelayTime (hwnd
, wParam
, lParam
);
2706 return TOOLTIPS_SetMargin (hwnd
, wParam
, lParam
);
2708 case TTM_SETMAXTIPWIDTH
:
2709 return TOOLTIPS_SetMaxTipWidth (hwnd
, wParam
, lParam
);
2711 case TTM_SETTIPBKCOLOR
:
2712 return TOOLTIPS_SetTipBkColor (hwnd
, wParam
, lParam
);
2714 case TTM_SETTIPTEXTCOLOR
:
2715 return TOOLTIPS_SetTipTextColor (hwnd
, wParam
, lParam
);
2718 return TOOLTIPS_SetTitleA (hwnd
, wParam
, lParam
);
2721 return TOOLTIPS_SetTitleW (hwnd
, wParam
, lParam
);
2723 case TTM_SETTOOLINFOA
:
2724 return TOOLTIPS_SetToolInfoA (hwnd
, wParam
, lParam
);
2726 case TTM_SETTOOLINFOW
:
2727 return TOOLTIPS_SetToolInfoW (hwnd
, wParam
, lParam
);
2729 case TTM_TRACKACTIVATE
:
2730 return TOOLTIPS_TrackActivate (hwnd
, wParam
, lParam
);
2732 case TTM_TRACKPOSITION
:
2733 return TOOLTIPS_TrackPosition (hwnd
, wParam
, lParam
);
2736 return TOOLTIPS_Update (hwnd
, wParam
, lParam
);
2738 case TTM_UPDATETIPTEXTA
:
2739 return TOOLTIPS_UpdateTipTextA (hwnd
, wParam
, lParam
);
2741 case TTM_UPDATETIPTEXTW
:
2742 return TOOLTIPS_UpdateTipTextW (hwnd
, wParam
, lParam
);
2744 case TTM_WINDOWFROMPOINT
:
2745 return TOOLTIPS_WindowFromPoint (hwnd
, wParam
, lParam
);
2749 return TOOLTIPS_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
2752 return TOOLTIPS_Destroy (hwnd
, wParam
, lParam
);
2755 /* we draw the background in WM_PAINT */
2759 return TOOLTIPS_GetFont (hwnd
, wParam
, lParam
);
2762 return TOOLTIPS_OnWMGetText (hwnd
, wParam
, lParam
);
2764 case WM_GETTEXTLENGTH
:
2765 return TOOLTIPS_GetTextLength (hwnd
, wParam
, lParam
);
2767 case WM_LBUTTONDOWN
:
2769 case WM_MBUTTONDOWN
:
2771 case WM_RBUTTONDOWN
:
2774 return TOOLTIPS_MouseMessage (hwnd
, uMsg
, wParam
, lParam
);
2777 return TOOLTIPS_NCCreate (hwnd
, wParam
, lParam
);
2780 return TOOLTIPS_NCHitTest (hwnd
, wParam
, lParam
);
2782 case WM_NOTIFYFORMAT
:
2783 return TOOLTIPS_NotifyFormat (hwnd
, wParam
, lParam
);
2786 return TOOLTIPS_Paint (hwnd
, wParam
, lParam
);
2789 return TOOLTIPS_SetFont (hwnd
, wParam
, lParam
);
2792 return TOOLTIPS_Timer (hwnd
, wParam
, lParam
);
2794 case WM_WININICHANGE
:
2795 return TOOLTIPS_WinIniChange (hwnd
, wParam
, lParam
);
2798 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
2799 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2800 uMsg
, wParam
, lParam
);
2801 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2807 TOOLTIPS_Register (void)
2811 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
2812 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
| CS_SAVEBITS
;
2813 wndClass
.lpfnWndProc
= TOOLTIPS_WindowProc
;
2814 wndClass
.cbClsExtra
= 0;
2815 wndClass
.cbWndExtra
= sizeof(TOOLTIPS_INFO
*);
2816 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
2817 wndClass
.hbrBackground
= 0;
2818 wndClass
.lpszClassName
= TOOLTIPS_CLASSW
;
2820 RegisterClassW (&wndClass
);
2822 hTooltipIcons
[TTI_NONE
] = NULL
;
2823 hTooltipIcons
[TTI_INFO
] = LoadImageW(COMCTL32_hModule
,
2824 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_INFO_SM
), IMAGE_ICON
, 0, 0, 0);
2825 hTooltipIcons
[TTI_WARNING
] = LoadImageW(COMCTL32_hModule
,
2826 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_WARN_SM
), IMAGE_ICON
, 0, 0, 0);
2827 hTooltipIcons
[TTI_ERROR
] = LoadImageW(COMCTL32_hModule
,
2828 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_ERROR_SM
), IMAGE_ICON
, 0, 0, 0);
2833 TOOLTIPS_Unregister (void)
2836 for (i
= TTI_INFO
; i
<= TTI_ERROR
; i
++)
2837 DestroyIcon(hTooltipIcons
[i
]);
2838 UnregisterClassW (TOOLTIPS_CLASSW
, NULL
);