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
)
520 TTTOOL_INFO
*toolPtr
;
522 MONITORINFO mon_info
;
527 DWORD style
= GetWindowLongW(hwnd
, GWL_STYLE
);
529 if (infoPtr
->nTool
== -1) {
530 TRACE("invalid tool (-1)!\n");
534 infoPtr
->nCurrentTool
= infoPtr
->nTool
;
536 TRACE("Show tooltip pre %d! (%p)\n", infoPtr
->nTool
, hwnd
);
538 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nCurrentTool
);
540 if (infoPtr
->szTipText
[0] == '\0') {
541 infoPtr
->nCurrentTool
= -1;
545 TRACE("Show tooltip %d!\n", infoPtr
->nCurrentTool
);
546 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
549 hdr
.idFrom
= toolPtr
->uId
;
551 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
552 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
554 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
556 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
557 TRACE("size %d x %d\n", size
.cx
, size
.cy
);
559 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
562 if (toolPtr
->uFlags
& TTF_IDISHWND
)
563 GetWindowRect ((HWND
)toolPtr
->uId
, &rc
);
566 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rc
, 2);
568 rect
.left
= (rc
.left
+ rc
.right
- size
.cx
) / 2;
569 if (style
& TTS_BALLOON
)
571 ptfx
= rc
.left
+ ((rc
.right
- rc
.left
) / 2);
573 /* CENTERTIP ballon tooltips default to below the field
574 if they fit on the screen */
575 if(rc
.bottom
+ size
.cy
> GetSystemMetrics(SM_CYSCREEN
))
577 rect
.top
= rc
.top
- size
.cy
;
578 infoPtr
->bToolBelow
= FALSE
;
582 infoPtr
->bToolBelow
= TRUE
;
583 rect
.top
= rc
.bottom
;
585 rect
.left
= max(0, rect
.left
- BALLOON_STEMINDENT
);
589 rect
.top
= rc
.bottom
+ 2;
590 infoPtr
->bToolBelow
= TRUE
;
594 GetCursorPos ((LPPOINT
)&rect
);
595 if (style
& TTS_BALLOON
)
598 if(rect
.top
- size
.cy
>= 0)
601 infoPtr
->bToolBelow
= FALSE
;
605 infoPtr
->bToolBelow
= TRUE
;
608 rect
.left
= max(0, rect
.left
- BALLOON_STEMINDENT
);
613 infoPtr
->bToolBelow
= TRUE
;
617 TRACE("pos %d - %d\n", rect
.left
, rect
.top
);
619 rect
.right
= rect
.left
+ size
.cx
;
620 rect
.bottom
= rect
.top
+ size
.cy
;
624 monitor
= MonitorFromRect( &rect
, MONITOR_DEFAULTTOPRIMARY
);
625 mon_info
.cbSize
= sizeof(mon_info
);
626 GetMonitorInfoW( monitor
, &mon_info
);
628 if( rect
.right
> mon_info
.rcWork
.right
) {
629 rect
.left
-= rect
.right
- mon_info
.rcWork
.right
+ 2;
630 rect
.right
= mon_info
.rcWork
.right
- 2;
632 if (rect
.left
< mon_info
.rcWork
.left
) rect
.left
= mon_info
.rcWork
.left
;
634 if( rect
.bottom
> mon_info
.rcWork
.bottom
) {
637 if (toolPtr
->uFlags
& TTF_IDISHWND
)
638 GetWindowRect ((HWND
)toolPtr
->uId
, &rc
);
641 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rc
, 2);
643 rect
.bottom
= rc
.top
- 2;
644 rect
.top
= rect
.bottom
- size
.cy
;
647 AdjustWindowRectEx (&rect
, GetWindowLongW (hwnd
, GWL_STYLE
),
648 FALSE
, GetWindowLongW (hwnd
, GWL_EXSTYLE
));
650 if (style
& TTS_BALLOON
)
658 if(infoPtr
->bToolBelow
)
662 pts
[1].x
= max(BALLOON_STEMINDENT
, ptfx
- (BALLOON_STEMWIDTH
/ 2));
663 pts
[1].y
= BALLOON_STEMHEIGHT
;
664 pts
[2].x
= pts
[1].x
+ BALLOON_STEMWIDTH
;
666 if(pts
[2].x
> (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
)
668 pts
[2].x
= (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
;
669 pts
[1].x
= pts
[2].x
- BALLOON_STEMWIDTH
;
674 pts
[0].x
= max(BALLOON_STEMINDENT
, ptfx
- (BALLOON_STEMWIDTH
/ 2));
675 pts
[0].y
= (rect
.bottom
- rect
.top
) - BALLOON_STEMHEIGHT
;
676 pts
[1].x
= pts
[0].x
+ BALLOON_STEMWIDTH
;
679 pts
[2].y
= (rect
.bottom
- rect
.top
);
680 if(pts
[1].x
> (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
)
682 pts
[1].x
= (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
;
683 pts
[0].x
= pts
[1].x
- BALLOON_STEMWIDTH
;
687 hrStem
= CreatePolygonRgn(pts
, sizeof(pts
) / sizeof(pts
[0]), ALTERNATE
);
689 hRgn
= CreateRoundRectRgn(0,
690 (infoPtr
->bToolBelow
? BALLOON_STEMHEIGHT
: 0),
691 rect
.right
- rect
.left
,
692 (infoPtr
->bToolBelow
? rect
.bottom
- rect
.top
: rect
.bottom
- rect
.top
- BALLOON_STEMHEIGHT
),
693 BALLOON_ROUNDEDNESS
, BALLOON_ROUNDEDNESS
);
695 CombineRgn(hRgn
, hRgn
, hrStem
, RGN_OR
);
696 DeleteObject(hrStem
);
698 SetWindowRgn(hwnd
, hRgn
, FALSE
);
699 /* we don't free the region handle as the system deletes it when
700 * it is no longer needed */
703 SetWindowPos (hwnd
, HWND_TOP
, rect
.left
, rect
.top
,
704 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
705 SWP_SHOWWINDOW
| SWP_NOACTIVATE
);
707 /* repaint the tooltip */
708 InvalidateRect(hwnd
, NULL
, TRUE
);
711 SetTimer (hwnd
, ID_TIMERPOP
, infoPtr
->nAutoPopTime
, 0);
712 TRACE("timer 2 started!\n");
713 SetTimer (hwnd
, ID_TIMERLEAVE
, infoPtr
->nReshowTime
, 0);
714 TRACE("timer 3 started!\n");
719 TOOLTIPS_Hide (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
721 TTTOOL_INFO
*toolPtr
;
724 TRACE("Hide tooltip %d! (%p)\n", infoPtr
->nCurrentTool
, hwnd
);
726 if (infoPtr
->nCurrentTool
== -1)
729 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
730 KillTimer (hwnd
, ID_TIMERPOP
);
733 hdr
.idFrom
= toolPtr
->uId
;
735 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
736 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
738 infoPtr
->nCurrentTool
= -1;
740 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0,
741 SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
746 TOOLTIPS_TrackShow (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
748 TTTOOL_INFO
*toolPtr
;
753 if (infoPtr
->nTrackTool
== -1) {
754 TRACE("invalid tracking tool (-1)!\n");
758 TRACE("show tracking tooltip pre %d!\n", infoPtr
->nTrackTool
);
760 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nTrackTool
);
762 if (infoPtr
->szTipText
[0] == '\0') {
763 infoPtr
->nTrackTool
= -1;
767 TRACE("show tracking tooltip %d!\n", infoPtr
->nTrackTool
);
768 toolPtr
= &infoPtr
->tools
[infoPtr
->nTrackTool
];
771 hdr
.idFrom
= toolPtr
->uId
;
773 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
774 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
776 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
778 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
779 TRACE("size %d x %d\n", size
.cx
, size
.cy
);
781 if (toolPtr
->uFlags
& TTF_ABSOLUTE
) {
782 rect
.left
= infoPtr
->xTrackPos
;
783 rect
.top
= infoPtr
->yTrackPos
;
785 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
786 rect
.left
-= (size
.cx
/ 2);
787 rect
.top
-= (size
.cy
/ 2);
793 if (toolPtr
->uFlags
& TTF_IDISHWND
)
794 GetWindowRect ((HWND
)toolPtr
->uId
, &rcTool
);
796 rcTool
= toolPtr
->rect
;
797 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rcTool
, 2);
800 GetCursorPos ((LPPOINT
)&rect
);
803 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
804 rect
.left
-= (size
.cx
/ 2);
805 rect
.top
-= (size
.cy
/ 2);
808 /* smart placement */
809 if ((rect
.left
+ size
.cx
> rcTool
.left
) && (rect
.left
< rcTool
.right
) &&
810 (rect
.top
+ size
.cy
> rcTool
.top
) && (rect
.top
< rcTool
.bottom
))
811 rect
.left
= rcTool
.right
;
814 TRACE("pos %d - %d\n", rect
.left
, rect
.top
);
816 rect
.right
= rect
.left
+ size
.cx
;
817 rect
.bottom
= rect
.top
+ size
.cy
;
819 AdjustWindowRectEx (&rect
, GetWindowLongW (hwnd
, GWL_STYLE
),
820 FALSE
, GetWindowLongW (hwnd
, GWL_EXSTYLE
));
822 if (GetWindowLongW(hwnd
, GWL_STYLE
) & TTS_BALLOON
)
826 /* FIXME: need to add pointy bit using CreatePolyRgn & CombinRgn */
827 hRgn
= CreateRoundRectRgn(0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, BALLOON_ROUNDEDNESS
, BALLOON_ROUNDEDNESS
);
829 SetWindowRgn(hwnd
, hRgn
, FALSE
);
830 /* we don't free the region handle as the system deletes it when
831 * it is no longer needed */
834 SetWindowPos (hwnd
, HWND_TOP
, rect
.left
, rect
.top
,
835 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
836 SWP_SHOWWINDOW
| SWP_NOACTIVATE
);
838 InvalidateRect(hwnd
, NULL
, TRUE
);
844 TOOLTIPS_TrackHide (HWND hwnd
, const TOOLTIPS_INFO
*infoPtr
)
846 TTTOOL_INFO
*toolPtr
;
849 TRACE("hide tracking tooltip %d\n", infoPtr
->nTrackTool
);
851 if (infoPtr
->nTrackTool
== -1)
854 toolPtr
= &infoPtr
->tools
[infoPtr
->nTrackTool
];
857 hdr
.idFrom
= toolPtr
->uId
;
859 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
860 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
862 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0,
863 SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
868 TOOLTIPS_GetToolFromInfoA (const TOOLTIPS_INFO
*infoPtr
, const TTTOOLINFOA
*lpToolInfo
)
870 TTTOOL_INFO
*toolPtr
;
873 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
874 toolPtr
= &infoPtr
->tools
[nTool
];
876 if (!(toolPtr
->uFlags
& TTF_IDISHWND
) &&
877 (lpToolInfo
->hwnd
== toolPtr
->hwnd
) &&
878 (lpToolInfo
->uId
== toolPtr
->uId
))
882 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
883 toolPtr
= &infoPtr
->tools
[nTool
];
885 if ((toolPtr
->uFlags
& TTF_IDISHWND
) &&
886 (lpToolInfo
->uId
== toolPtr
->uId
))
895 TOOLTIPS_GetToolFromInfoW (const TOOLTIPS_INFO
*infoPtr
, const TTTOOLINFOW
*lpToolInfo
)
897 TTTOOL_INFO
*toolPtr
;
900 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
901 toolPtr
= &infoPtr
->tools
[nTool
];
903 if (!(toolPtr
->uFlags
& TTF_IDISHWND
) &&
904 (lpToolInfo
->hwnd
== toolPtr
->hwnd
) &&
905 (lpToolInfo
->uId
== toolPtr
->uId
))
909 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
910 toolPtr
= &infoPtr
->tools
[nTool
];
912 if ((toolPtr
->uFlags
& TTF_IDISHWND
) &&
913 (lpToolInfo
->uId
== toolPtr
->uId
))
922 TOOLTIPS_GetToolFromPoint (const TOOLTIPS_INFO
*infoPtr
, HWND hwnd
, const POINT
*lpPt
)
924 TTTOOL_INFO
*toolPtr
;
927 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
928 toolPtr
= &infoPtr
->tools
[nTool
];
930 if (!(toolPtr
->uFlags
& TTF_IDISHWND
)) {
931 if (hwnd
!= toolPtr
->hwnd
)
933 if (!PtInRect (&toolPtr
->rect
, *lpPt
))
939 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
940 toolPtr
= &infoPtr
->tools
[nTool
];
942 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
943 if ((HWND
)toolPtr
->uId
== hwnd
)
953 TOOLTIPS_IsWindowActive (HWND hwnd
)
955 HWND hwndActive
= GetActiveWindow ();
958 if (hwndActive
== hwnd
)
960 return IsChild (hwndActive
, hwnd
);
965 TOOLTIPS_CheckTool (HWND hwnd
, BOOL bShowTest
)
967 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
973 hwndTool
= (HWND
)SendMessageW (hwnd
, TTM_WINDOWFROMPOINT
, 0, (LPARAM
)&pt
);
977 ScreenToClient (hwndTool
, &pt
);
978 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, hwndTool
, &pt
);
982 if (!(GetWindowLongW (hwnd
, GWL_STYLE
) & TTS_ALWAYSTIP
) && bShowTest
) {
983 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd
, GW_OWNER
)))
987 TRACE("tool %d\n", nTool
);
994 TOOLTIPS_Activate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
996 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
998 infoPtr
->bActive
= (BOOL
)wParam
;
1000 if (infoPtr
->bActive
)
1001 TRACE("activate!\n");
1003 if (!(infoPtr
->bActive
) && (infoPtr
->nCurrentTool
!= -1))
1004 TOOLTIPS_Hide (hwnd
, infoPtr
);
1011 TOOLTIPS_AddToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1013 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1014 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1015 TTTOOL_INFO
*toolPtr
;
1018 if (lpToolInfo
== NULL
)
1020 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1023 TRACE("add tool (%p) %p %ld%s!\n",
1024 hwnd
, lpToolInfo
->hwnd
, lpToolInfo
->uId
,
1025 (lpToolInfo
->uFlags
& TTF_IDISHWND
) ? " TTF_IDISHWND" : "");
1027 if (infoPtr
->uNumTools
== 0) {
1028 infoPtr
->tools
= Alloc (sizeof(TTTOOL_INFO
));
1029 toolPtr
= infoPtr
->tools
;
1032 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1034 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
+ 1));
1035 memcpy (infoPtr
->tools
, oldTools
,
1036 infoPtr
->uNumTools
* sizeof(TTTOOL_INFO
));
1038 toolPtr
= &infoPtr
->tools
[infoPtr
->uNumTools
];
1041 infoPtr
->uNumTools
++;
1043 /* copy tool data */
1044 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
1045 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
1046 toolPtr
->uId
= lpToolInfo
->uId
;
1047 toolPtr
->rect
= lpToolInfo
->rect
;
1048 toolPtr
->hinst
= lpToolInfo
->hinst
;
1050 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)) {
1051 TRACE("add string id %x!\n", LOWORD(lpToolInfo
->lpszText
));
1052 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
1054 else if (lpToolInfo
->lpszText
) {
1055 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
) {
1056 TRACE("add CALLBACK!\n");
1057 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
1060 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
1062 TRACE("add text \"%s\"!\n", lpToolInfo
->lpszText
);
1063 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
1064 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
1065 toolPtr
->lpszText
, len
);
1069 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1070 toolPtr
->lParam
= lpToolInfo
->lParam
;
1072 /* install subclassing hook */
1073 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1074 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1075 SetWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1,
1079 SetWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1,
1082 TRACE("subclassing installed!\n");
1085 nResult
= (INT
) SendMessageW (toolPtr
->hwnd
, WM_NOTIFYFORMAT
,
1086 (WPARAM
)hwnd
, (LPARAM
)NF_QUERY
);
1087 if (nResult
== NFR_ANSI
) {
1088 toolPtr
->bNotifyUnicode
= FALSE
;
1089 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1090 } else if (nResult
== NFR_UNICODE
) {
1091 toolPtr
->bNotifyUnicode
= TRUE
;
1092 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1094 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1102 TOOLTIPS_AddToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1104 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1105 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1106 TTTOOL_INFO
*toolPtr
;
1109 if (lpToolInfo
== NULL
)
1111 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1114 TRACE("add tool (%p) %p %ld%s!\n",
1115 hwnd
, lpToolInfo
->hwnd
, lpToolInfo
->uId
,
1116 (lpToolInfo
->uFlags
& TTF_IDISHWND
) ? " TTF_IDISHWND" : "");
1118 if (infoPtr
->uNumTools
== 0) {
1119 infoPtr
->tools
= Alloc (sizeof(TTTOOL_INFO
));
1120 toolPtr
= infoPtr
->tools
;
1123 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1125 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
+ 1));
1126 memcpy (infoPtr
->tools
, oldTools
,
1127 infoPtr
->uNumTools
* sizeof(TTTOOL_INFO
));
1129 toolPtr
= &infoPtr
->tools
[infoPtr
->uNumTools
];
1132 infoPtr
->uNumTools
++;
1134 /* copy tool data */
1135 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
1136 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
1137 toolPtr
->uId
= lpToolInfo
->uId
;
1138 toolPtr
->rect
= lpToolInfo
->rect
;
1139 toolPtr
->hinst
= lpToolInfo
->hinst
;
1141 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)) {
1142 TRACE("add string id %x\n", LOWORD(lpToolInfo
->lpszText
));
1143 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
1145 else if (lpToolInfo
->lpszText
) {
1146 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
) {
1147 TRACE("add CALLBACK!\n");
1148 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
1151 INT len
= lstrlenW (lpToolInfo
->lpszText
);
1152 TRACE("add text %s!\n",
1153 debugstr_w(lpToolInfo
->lpszText
));
1154 toolPtr
->lpszText
= Alloc ((len
+ 1)*sizeof(WCHAR
));
1155 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
1159 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1160 toolPtr
->lParam
= lpToolInfo
->lParam
;
1162 /* install subclassing hook */
1163 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1164 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1165 SetWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1,
1169 SetWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1,
1172 TRACE("subclassing installed!\n");
1175 nResult
= (INT
) SendMessageW (toolPtr
->hwnd
, WM_NOTIFYFORMAT
,
1176 (WPARAM
)hwnd
, (LPARAM
)NF_QUERY
);
1177 if (nResult
== NFR_ANSI
) {
1178 toolPtr
->bNotifyUnicode
= FALSE
;
1179 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1180 } else if (nResult
== NFR_UNICODE
) {
1181 toolPtr
->bNotifyUnicode
= TRUE
;
1182 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1184 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1192 TOOLTIPS_DelToolCommon (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, INT nTool
)
1194 TTTOOL_INFO
*toolPtr
;
1196 TRACE("tool %d\n", nTool
);
1201 /* make sure the tooltip has disappeared before deleting it */
1202 TOOLTIPS_Hide(hwnd
, infoPtr
);
1204 /* delete text string */
1205 toolPtr
= &infoPtr
->tools
[nTool
];
1206 if (toolPtr
->lpszText
) {
1207 if ( (toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
) &&
1208 !IS_INTRESOURCE(toolPtr
->lpszText
) )
1209 Free (toolPtr
->lpszText
);
1212 /* remove subclassing */
1213 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1214 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1215 RemoveWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1);
1218 RemoveWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1);
1222 /* delete tool from tool list */
1223 if (infoPtr
->uNumTools
== 1) {
1224 Free (infoPtr
->tools
);
1225 infoPtr
->tools
= NULL
;
1228 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1230 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
- 1));
1233 memcpy (&infoPtr
->tools
[0], &oldTools
[0],
1234 nTool
* sizeof(TTTOOL_INFO
));
1236 if (nTool
< infoPtr
->uNumTools
- 1)
1237 memcpy (&infoPtr
->tools
[nTool
], &oldTools
[nTool
+ 1],
1238 (infoPtr
->uNumTools
- nTool
- 1) * sizeof(TTTOOL_INFO
));
1243 /* update any indices affected by delete */
1245 /* destroying tool that mouse was on on last relayed mouse move */
1246 if (infoPtr
->nTool
== nTool
)
1247 /* -1 means no current tool (0 means first tool) */
1248 infoPtr
->nTool
= -1;
1249 else if (infoPtr
->nTool
> nTool
)
1252 if (infoPtr
->nTrackTool
== nTool
)
1253 /* -1 means no current tool (0 means first tool) */
1254 infoPtr
->nTrackTool
= -1;
1255 else if (infoPtr
->nTrackTool
> nTool
)
1256 infoPtr
->nTrackTool
--;
1258 if (infoPtr
->nCurrentTool
== nTool
)
1259 /* -1 means no current tool (0 means first tool) */
1260 infoPtr
->nCurrentTool
= -1;
1261 else if (infoPtr
->nCurrentTool
> nTool
)
1262 infoPtr
->nCurrentTool
--;
1264 infoPtr
->uNumTools
--;
1268 TOOLTIPS_DelToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1270 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1271 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1274 if (lpToolInfo
== NULL
)
1276 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1278 if (infoPtr
->uNumTools
== 0)
1281 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1283 TOOLTIPS_DelToolCommon (hwnd
, infoPtr
, nTool
);
1290 TOOLTIPS_DelToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1292 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1293 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1296 if (lpToolInfo
== NULL
)
1298 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1300 if (infoPtr
->uNumTools
== 0)
1303 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1305 TOOLTIPS_DelToolCommon (hwnd
, infoPtr
, nTool
);
1312 TOOLTIPS_EnumToolsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1314 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1315 UINT uIndex
= (UINT
)wParam
;
1316 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1317 TTTOOL_INFO
*toolPtr
;
1319 if (lpToolInfo
== NULL
)
1321 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1323 if (uIndex
>= infoPtr
->uNumTools
)
1326 TRACE("index=%u\n", uIndex
);
1328 toolPtr
= &infoPtr
->tools
[uIndex
];
1330 /* copy tool data */
1331 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1332 lpToolInfo
->hwnd
= toolPtr
->hwnd
;
1333 lpToolInfo
->uId
= toolPtr
->uId
;
1334 lpToolInfo
->rect
= toolPtr
->rect
;
1335 lpToolInfo
->hinst
= toolPtr
->hinst
;
1336 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1337 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1339 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1340 lpToolInfo
->lParam
= toolPtr
->lParam
;
1347 TOOLTIPS_EnumToolsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1349 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1350 UINT uIndex
= (UINT
)wParam
;
1351 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1352 TTTOOL_INFO
*toolPtr
;
1354 if (lpToolInfo
== NULL
)
1356 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1358 if (uIndex
>= infoPtr
->uNumTools
)
1361 TRACE("index=%u\n", uIndex
);
1363 toolPtr
= &infoPtr
->tools
[uIndex
];
1365 /* copy tool data */
1366 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1367 lpToolInfo
->hwnd
= toolPtr
->hwnd
;
1368 lpToolInfo
->uId
= toolPtr
->uId
;
1369 lpToolInfo
->rect
= toolPtr
->rect
;
1370 lpToolInfo
->hinst
= toolPtr
->hinst
;
1371 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1372 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1374 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1375 lpToolInfo
->lParam
= toolPtr
->lParam
;
1381 TOOLTIPS_GetBubbleSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1383 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1384 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1388 if (lpToolInfo
== NULL
)
1390 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1393 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1394 if (nTool
== -1) return 0;
1396 TRACE("tool %d\n", nTool
);
1398 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
1399 TRACE("size %d x %d\n", size
.cx
, size
.cy
);
1401 return MAKELRESULT(size
.cx
, size
.cy
);
1405 TOOLTIPS_GetCurrentToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1407 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1408 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1409 TTTOOL_INFO
*toolPtr
;
1412 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1415 if (infoPtr
->nCurrentTool
> -1) {
1416 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
1418 /* copy tool data */
1419 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1420 lpToolInfo
->rect
= toolPtr
->rect
;
1421 lpToolInfo
->hinst
= toolPtr
->hinst
;
1422 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1423 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1425 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1426 lpToolInfo
->lParam
= toolPtr
->lParam
;
1434 return (infoPtr
->nCurrentTool
!= -1);
1439 TOOLTIPS_GetCurrentToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1441 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1442 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1443 TTTOOL_INFO
*toolPtr
;
1446 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1449 if (infoPtr
->nCurrentTool
> -1) {
1450 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
1452 /* copy tool data */
1453 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1454 lpToolInfo
->rect
= toolPtr
->rect
;
1455 lpToolInfo
->hinst
= toolPtr
->hinst
;
1456 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1457 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1459 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1460 lpToolInfo
->lParam
= toolPtr
->lParam
;
1468 return (infoPtr
->nCurrentTool
!= -1);
1473 TOOLTIPS_GetDelayTime (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1475 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1479 return infoPtr
->nReshowTime
;
1482 return infoPtr
->nAutoPopTime
;
1485 case TTDT_AUTOMATIC
: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */
1486 return infoPtr
->nInitialTime
;
1489 WARN("Invalid wParam %lx\n", wParam
);
1498 TOOLTIPS_GetMargin (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1500 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1501 LPRECT lpRect
= (LPRECT
)lParam
;
1503 lpRect
->left
= infoPtr
->rcMargin
.left
;
1504 lpRect
->right
= infoPtr
->rcMargin
.right
;
1505 lpRect
->bottom
= infoPtr
->rcMargin
.bottom
;
1506 lpRect
->top
= infoPtr
->rcMargin
.top
;
1512 static inline LRESULT
1513 TOOLTIPS_GetMaxTipWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1515 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1517 return infoPtr
->nMaxTipWidth
;
1522 TOOLTIPS_GetTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1524 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1525 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1528 if (lpToolInfo
== NULL
)
1530 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1533 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1534 if (nTool
== -1) return 0;
1536 /* NB this API is broken, there is no way for the app to determine
1537 what size buffer it requires nor a way to specify how long the
1538 one it supplies is. We'll assume it's up to INFOTIPSIZE */
1540 WideCharToMultiByte(CP_ACP
, 0, infoPtr
->tools
[nTool
].lpszText
, -1,
1541 lpToolInfo
->lpszText
, INFOTIPSIZE
, NULL
, NULL
);
1548 TOOLTIPS_GetTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1550 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1551 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1554 if (lpToolInfo
== NULL
)
1556 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1559 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1560 if (nTool
== -1) return 0;
1562 strcpyW (lpToolInfo
->lpszText
, infoPtr
->tools
[nTool
].lpszText
);
1568 static inline LRESULT
1569 TOOLTIPS_GetTipBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1571 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1572 return infoPtr
->clrBk
;
1576 static inline LRESULT
1577 TOOLTIPS_GetTipTextColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1579 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1580 return infoPtr
->clrText
;
1584 static inline LRESULT
1585 TOOLTIPS_GetToolCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1587 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1588 return infoPtr
->uNumTools
;
1593 TOOLTIPS_GetToolInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1595 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1596 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1597 TTTOOL_INFO
*toolPtr
;
1600 if (lpToolInfo
== NULL
)
1602 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1604 if (infoPtr
->uNumTools
== 0)
1607 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1611 TRACE("tool %d\n", nTool
);
1613 toolPtr
= &infoPtr
->tools
[nTool
];
1615 /* copy tool data */
1616 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1617 lpToolInfo
->rect
= toolPtr
->rect
;
1618 lpToolInfo
->hinst
= toolPtr
->hinst
;
1619 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1620 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1622 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1623 lpToolInfo
->lParam
= toolPtr
->lParam
;
1630 TOOLTIPS_GetToolInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1632 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1633 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1634 TTTOOL_INFO
*toolPtr
;
1637 if (lpToolInfo
== NULL
)
1639 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1641 if (infoPtr
->uNumTools
== 0)
1644 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1648 TRACE("tool %d\n", nTool
);
1650 toolPtr
= &infoPtr
->tools
[nTool
];
1652 /* copy tool data */
1653 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1654 lpToolInfo
->rect
= toolPtr
->rect
;
1655 lpToolInfo
->hinst
= toolPtr
->hinst
;
1656 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1657 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1659 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1660 lpToolInfo
->lParam
= toolPtr
->lParam
;
1667 TOOLTIPS_HitTestA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1669 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1670 LPTTHITTESTINFOA lptthit
= (LPTTHITTESTINFOA
)lParam
;
1671 TTTOOL_INFO
*toolPtr
;
1677 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, lptthit
->hwnd
, &lptthit
->pt
);
1681 TRACE("tool %d!\n", nTool
);
1683 /* copy tool data */
1684 if (lptthit
->ti
.cbSize
>= sizeof(TTTOOLINFOA
)) {
1685 toolPtr
= &infoPtr
->tools
[nTool
];
1687 lptthit
->ti
.uFlags
= toolPtr
->uFlags
;
1688 lptthit
->ti
.hwnd
= toolPtr
->hwnd
;
1689 lptthit
->ti
.uId
= toolPtr
->uId
;
1690 lptthit
->ti
.rect
= toolPtr
->rect
;
1691 lptthit
->ti
.hinst
= toolPtr
->hinst
;
1692 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1693 lptthit
->ti
.lpszText
= NULL
; /* FIXME */
1694 lptthit
->ti
.lParam
= toolPtr
->lParam
;
1702 TOOLTIPS_HitTestW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1704 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1705 LPTTHITTESTINFOW lptthit
= (LPTTHITTESTINFOW
)lParam
;
1706 TTTOOL_INFO
*toolPtr
;
1712 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, lptthit
->hwnd
, &lptthit
->pt
);
1716 TRACE("tool %d!\n", nTool
);
1718 /* copy tool data */
1719 if (lptthit
->ti
.cbSize
>= sizeof(TTTOOLINFOW
)) {
1720 toolPtr
= &infoPtr
->tools
[nTool
];
1722 lptthit
->ti
.uFlags
= toolPtr
->uFlags
;
1723 lptthit
->ti
.hwnd
= toolPtr
->hwnd
;
1724 lptthit
->ti
.uId
= toolPtr
->uId
;
1725 lptthit
->ti
.rect
= toolPtr
->rect
;
1726 lptthit
->ti
.hinst
= toolPtr
->hinst
;
1727 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1728 lptthit
->ti
.lpszText
= NULL
; /* FIXME */
1729 lptthit
->ti
.lParam
= toolPtr
->lParam
;
1737 TOOLTIPS_NewToolRectA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1739 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1740 LPTTTOOLINFOA lpti
= (LPTTTOOLINFOA
)lParam
;
1745 if (lpti
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1748 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpti
);
1750 TRACE("nTool = %d, rect = %s\n", nTool
, wine_dbgstr_rect(&lpti
->rect
));
1752 if (nTool
== -1) return 0;
1754 infoPtr
->tools
[nTool
].rect
= lpti
->rect
;
1761 TOOLTIPS_NewToolRectW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1763 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1764 LPTTTOOLINFOW lpti
= (LPTTTOOLINFOW
)lParam
;
1769 if (lpti
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1772 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpti
);
1774 TRACE("nTool = %d, rect = %s\n", nTool
, wine_dbgstr_rect(&lpti
->rect
));
1776 if (nTool
== -1) return 0;
1778 infoPtr
->tools
[nTool
].rect
= lpti
->rect
;
1784 static inline LRESULT
1785 TOOLTIPS_Pop (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1787 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1788 TOOLTIPS_Hide (hwnd
, infoPtr
);
1795 TOOLTIPS_RelayEvent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1797 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1798 LPMSG lpMsg
= (LPMSG
)lParam
;
1803 ERR("lpMsg == NULL!\n");
1807 switch (lpMsg
->message
) {
1808 case WM_LBUTTONDOWN
:
1810 case WM_MBUTTONDOWN
:
1812 case WM_RBUTTONDOWN
:
1814 TOOLTIPS_Hide (hwnd
, infoPtr
);
1818 pt
.x
= (short)LOWORD(lpMsg
->lParam
);
1819 pt
.y
= (short)HIWORD(lpMsg
->lParam
);
1820 nOldTool
= infoPtr
->nTool
;
1821 infoPtr
->nTool
= TOOLTIPS_GetToolFromPoint(infoPtr
, lpMsg
->hwnd
,
1823 TRACE("tool (%p) %d %d %d\n", hwnd
, nOldTool
,
1824 infoPtr
->nTool
, infoPtr
->nCurrentTool
);
1825 TRACE("WM_MOUSEMOVE (%p %d %d)\n", hwnd
, pt
.x
, pt
.y
);
1827 if (infoPtr
->nTool
!= nOldTool
) {
1828 if(infoPtr
->nTool
== -1) { /* Moved out of all tools */
1829 TOOLTIPS_Hide(hwnd
, infoPtr
);
1830 KillTimer(hwnd
, ID_TIMERLEAVE
);
1831 } else if (nOldTool
== -1) { /* Moved from outside */
1832 if(infoPtr
->bActive
) {
1833 SetTimer(hwnd
, ID_TIMERSHOW
, infoPtr
->nInitialTime
, 0);
1834 TRACE("timer 1 started!\n");
1836 } else { /* Moved from one to another */
1837 TOOLTIPS_Hide (hwnd
, infoPtr
);
1838 KillTimer(hwnd
, ID_TIMERLEAVE
);
1839 if(infoPtr
->bActive
) {
1840 SetTimer (hwnd
, ID_TIMERSHOW
, infoPtr
->nReshowTime
, 0);
1841 TRACE("timer 1 started!\n");
1844 } else if(infoPtr
->nCurrentTool
!= -1) { /* restart autopop */
1845 KillTimer(hwnd
, ID_TIMERPOP
);
1846 SetTimer(hwnd
, ID_TIMERPOP
, infoPtr
->nAutoPopTime
, 0);
1847 TRACE("timer 2 restarted\n");
1848 } else if(infoPtr
->nTool
!= -1 && infoPtr
->bActive
) {
1849 /* previous show attempt didn't result in tooltip so try again */
1850 SetTimer(hwnd
, ID_TIMERSHOW
, infoPtr
->nInitialTime
, 0);
1851 TRACE("timer 1 started!\n");
1861 TOOLTIPS_SetDelayTime (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1863 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1864 INT nTime
= (INT
)LOWORD(lParam
);
1867 case TTDT_AUTOMATIC
:
1869 nTime
= GetDoubleClickTime();
1870 infoPtr
->nReshowTime
= nTime
/ 5;
1871 infoPtr
->nAutoPopTime
= nTime
* 10;
1872 infoPtr
->nInitialTime
= nTime
;
1877 nTime
= GetDoubleClickTime() / 5;
1878 infoPtr
->nReshowTime
= nTime
;
1883 nTime
= GetDoubleClickTime() * 10;
1884 infoPtr
->nAutoPopTime
= nTime
;
1889 nTime
= GetDoubleClickTime();
1890 infoPtr
->nInitialTime
= nTime
;
1894 WARN("Invalid wParam %lx\n", wParam
);
1903 TOOLTIPS_SetMargin (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1905 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1906 LPRECT lpRect
= (LPRECT
)lParam
;
1908 infoPtr
->rcMargin
.left
= lpRect
->left
;
1909 infoPtr
->rcMargin
.right
= lpRect
->right
;
1910 infoPtr
->rcMargin
.bottom
= lpRect
->bottom
;
1911 infoPtr
->rcMargin
.top
= lpRect
->top
;
1917 static inline LRESULT
1918 TOOLTIPS_SetMaxTipWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1920 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1921 INT nTemp
= infoPtr
->nMaxTipWidth
;
1923 infoPtr
->nMaxTipWidth
= (INT
)lParam
;
1929 static inline LRESULT
1930 TOOLTIPS_SetTipBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1932 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1934 infoPtr
->clrBk
= (COLORREF
)wParam
;
1940 static inline LRESULT
1941 TOOLTIPS_SetTipTextColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1943 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1945 infoPtr
->clrText
= (COLORREF
)wParam
;
1952 TOOLTIPS_SetTitleA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1954 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1955 LPCSTR pszTitle
= (LPCSTR
)lParam
;
1956 UINT_PTR uTitleIcon
= (UINT_PTR
)wParam
;
1959 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd
, debugstr_a(pszTitle
),
1962 Free(infoPtr
->pszTitle
);
1966 size
= sizeof(WCHAR
)*MultiByteToWideChar(CP_ACP
, 0, pszTitle
, -1, NULL
, 0);
1967 infoPtr
->pszTitle
= Alloc(size
);
1968 if (!infoPtr
->pszTitle
)
1970 MultiByteToWideChar(CP_ACP
, 0, pszTitle
, -1, infoPtr
->pszTitle
, size
/sizeof(WCHAR
));
1973 infoPtr
->pszTitle
= NULL
;
1975 if (uTitleIcon
<= TTI_ERROR
)
1976 infoPtr
->hTitleIcon
= hTooltipIcons
[uTitleIcon
];
1978 infoPtr
->hTitleIcon
= CopyIcon((HICON
)wParam
);
1985 TOOLTIPS_SetTitleW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1987 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1988 LPCWSTR pszTitle
= (LPCWSTR
)lParam
;
1989 UINT_PTR uTitleIcon
= (UINT_PTR
)wParam
;
1992 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd
, debugstr_w(pszTitle
),
1995 Free(infoPtr
->pszTitle
);
1999 size
= (strlenW(pszTitle
)+1)*sizeof(WCHAR
);
2000 infoPtr
->pszTitle
= Alloc(size
);
2001 if (!infoPtr
->pszTitle
)
2003 memcpy(infoPtr
->pszTitle
, pszTitle
, size
);
2006 infoPtr
->pszTitle
= NULL
;
2008 if (uTitleIcon
<= TTI_ERROR
)
2009 infoPtr
->hTitleIcon
= hTooltipIcons
[uTitleIcon
];
2011 infoPtr
->hTitleIcon
= CopyIcon((HICON
)wParam
);
2013 TRACE("icon = %p\n", infoPtr
->hTitleIcon
);
2020 TOOLTIPS_SetToolInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2022 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2023 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2024 TTTOOL_INFO
*toolPtr
;
2027 if (lpToolInfo
== NULL
)
2029 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2032 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2033 if (nTool
== -1) return 0;
2035 TRACE("tool %d\n", nTool
);
2037 toolPtr
= &infoPtr
->tools
[nTool
];
2039 /* copy tool data */
2040 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
2041 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
2042 toolPtr
->uId
= lpToolInfo
->uId
;
2043 toolPtr
->rect
= lpToolInfo
->rect
;
2044 toolPtr
->hinst
= lpToolInfo
->hinst
;
2046 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)) {
2047 TRACE("set string id %x\n", LOWORD(lpToolInfo
->lpszText
));
2048 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
2050 else if (lpToolInfo
->lpszText
) {
2051 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
)
2052 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2054 if ( (toolPtr
->lpszText
) &&
2055 !IS_INTRESOURCE(toolPtr
->lpszText
) ) {
2056 if( toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
)
2057 Free (toolPtr
->lpszText
);
2058 toolPtr
->lpszText
= NULL
;
2060 if (lpToolInfo
->lpszText
) {
2061 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
,
2063 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
2064 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
2065 toolPtr
->lpszText
, len
);
2070 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
2071 toolPtr
->lParam
= lpToolInfo
->lParam
;
2078 TOOLTIPS_SetToolInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2080 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2081 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
2082 TTTOOL_INFO
*toolPtr
;
2085 if (lpToolInfo
== NULL
)
2087 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
2090 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
2091 if (nTool
== -1) return 0;
2093 TRACE("tool %d\n", nTool
);
2095 toolPtr
= &infoPtr
->tools
[nTool
];
2097 /* copy tool data */
2098 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
2099 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
2100 toolPtr
->uId
= lpToolInfo
->uId
;
2101 toolPtr
->rect
= lpToolInfo
->rect
;
2102 toolPtr
->hinst
= lpToolInfo
->hinst
;
2104 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)) {
2105 TRACE("set string id %x!\n", LOWORD(lpToolInfo
->lpszText
));
2106 toolPtr
->lpszText
= lpToolInfo
->lpszText
;
2109 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
)
2110 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2112 if ( (toolPtr
->lpszText
) &&
2113 !IS_INTRESOURCE(toolPtr
->lpszText
) ) {
2114 if( toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
)
2115 Free (toolPtr
->lpszText
);
2116 toolPtr
->lpszText
= NULL
;
2118 if (lpToolInfo
->lpszText
) {
2119 INT len
= lstrlenW (lpToolInfo
->lpszText
);
2120 toolPtr
->lpszText
= Alloc ((len
+1)*sizeof(WCHAR
));
2121 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
2126 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
2127 toolPtr
->lParam
= lpToolInfo
->lParam
;
2129 if (infoPtr
->nCurrentTool
== nTool
)
2131 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nCurrentTool
);
2133 if (infoPtr
->szTipText
[0] == 0)
2134 TOOLTIPS_Hide(hwnd
, infoPtr
);
2136 TOOLTIPS_Show (hwnd
, infoPtr
);
2144 TOOLTIPS_TrackActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2146 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2149 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2151 if (lpToolInfo
== NULL
)
2153 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2157 infoPtr
->nTrackTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2158 if (infoPtr
->nTrackTool
!= -1) {
2159 TRACE("activated!\n");
2160 infoPtr
->bTrackActive
= TRUE
;
2161 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2166 TOOLTIPS_TrackHide (hwnd
, infoPtr
);
2168 infoPtr
->bTrackActive
= FALSE
;
2169 infoPtr
->nTrackTool
= -1;
2171 TRACE("deactivated!\n");
2179 TOOLTIPS_TrackPosition (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2181 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2183 infoPtr
->xTrackPos
= (INT
)LOWORD(lParam
);
2184 infoPtr
->yTrackPos
= (INT
)HIWORD(lParam
);
2186 if (infoPtr
->bTrackActive
) {
2188 infoPtr
->xTrackPos
, infoPtr
->yTrackPos
);
2190 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2198 TOOLTIPS_Update (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2200 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2202 if (infoPtr
->nCurrentTool
!= -1)
2203 UpdateWindow (hwnd
);
2210 TOOLTIPS_UpdateTipTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2212 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2213 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2214 TTTOOL_INFO
*toolPtr
;
2217 if (lpToolInfo
== NULL
)
2219 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2222 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2223 if (nTool
== -1) return 0;
2225 TRACE("tool %d\n", nTool
);
2227 toolPtr
= &infoPtr
->tools
[nTool
];
2229 /* copy tool text */
2230 toolPtr
->hinst
= lpToolInfo
->hinst
;
2232 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)){
2233 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
2235 else if (lpToolInfo
->lpszText
) {
2236 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
)
2237 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2239 if ( (toolPtr
->lpszText
) &&
2240 !IS_INTRESOURCE(toolPtr
->lpszText
) ) {
2241 if( toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
)
2242 Free (toolPtr
->lpszText
);
2243 toolPtr
->lpszText
= NULL
;
2245 if (lpToolInfo
->lpszText
) {
2246 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
,
2248 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
2249 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
2250 toolPtr
->lpszText
, len
);
2255 if(infoPtr
->nCurrentTool
== -1) return 0;
2257 if (infoPtr
->bActive
)
2258 TOOLTIPS_Show (hwnd
, infoPtr
);
2259 else if (infoPtr
->bTrackActive
)
2260 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2267 TOOLTIPS_UpdateTipTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2269 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2270 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
2271 TTTOOL_INFO
*toolPtr
;
2274 if (lpToolInfo
== NULL
)
2276 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
2279 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
2283 TRACE("tool %d\n", nTool
);
2285 toolPtr
= &infoPtr
->tools
[nTool
];
2287 /* copy tool text */
2288 toolPtr
->hinst
= lpToolInfo
->hinst
;
2290 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)){
2291 toolPtr
->lpszText
= lpToolInfo
->lpszText
;
2293 else if (lpToolInfo
->lpszText
) {
2294 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
)
2295 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2297 if ( (toolPtr
->lpszText
) &&
2298 !IS_INTRESOURCE(toolPtr
->lpszText
) ) {
2299 if( toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
)
2300 Free (toolPtr
->lpszText
);
2301 toolPtr
->lpszText
= NULL
;
2303 if (lpToolInfo
->lpszText
) {
2304 INT len
= lstrlenW (lpToolInfo
->lpszText
);
2305 toolPtr
->lpszText
= Alloc ((len
+1)*sizeof(WCHAR
));
2306 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
2311 if(infoPtr
->nCurrentTool
== -1) return 0;
2313 if (infoPtr
->bActive
)
2314 TOOLTIPS_Show (hwnd
, infoPtr
);
2315 else if (infoPtr
->bTrackActive
)
2316 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2323 TOOLTIPS_WindowFromPoint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2325 return (LRESULT
)WindowFromPoint (*((LPPOINT
)lParam
));
2331 TOOLTIPS_Create (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
2333 TOOLTIPS_INFO
*infoPtr
;
2335 /* allocate memory for info structure */
2336 infoPtr
= (TOOLTIPS_INFO
*)Alloc (sizeof(TOOLTIPS_INFO
));
2337 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
2339 /* initialize info structure */
2340 infoPtr
->bActive
= TRUE
;
2341 infoPtr
->bTrackActive
= FALSE
;
2343 infoPtr
->nMaxTipWidth
= -1;
2344 infoPtr
->nTool
= -1;
2345 infoPtr
->nCurrentTool
= -1;
2346 infoPtr
->nTrackTool
= -1;
2348 /* initialize colours and fonts */
2349 TOOLTIPS_InitSystemSettings(infoPtr
);
2351 TOOLTIPS_SetDelayTime(hwnd
, TTDT_AUTOMATIC
, 0L);
2353 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
2360 TOOLTIPS_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2362 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2363 TTTOOL_INFO
*toolPtr
;
2367 if (infoPtr
->tools
) {
2368 for (i
= 0; i
< infoPtr
->uNumTools
; i
++) {
2369 toolPtr
= &infoPtr
->tools
[i
];
2370 if (toolPtr
->lpszText
) {
2371 if ( (toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
) &&
2372 !IS_INTRESOURCE(toolPtr
->lpszText
) )
2374 Free (toolPtr
->lpszText
);
2375 toolPtr
->lpszText
= NULL
;
2379 /* remove subclassing */
2380 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
2381 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
2382 RemoveWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1);
2385 RemoveWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1);
2389 Free (infoPtr
->tools
);
2392 /* free title string */
2393 Free (infoPtr
->pszTitle
);
2394 /* free title icon if not a standard one */
2395 if (TOOLTIPS_GetTitleIconIndex(infoPtr
->hTitleIcon
) > TTI_ERROR
)
2396 DeleteObject(infoPtr
->hTitleIcon
);
2399 DeleteObject (infoPtr
->hFont
);
2400 DeleteObject (infoPtr
->hTitleFont
);
2402 /* free tool tips info data */
2404 SetWindowLongPtrW(hwnd
, 0, 0);
2410 TOOLTIPS_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2412 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2414 return (LRESULT
)infoPtr
->hFont
;
2419 TOOLTIPS_MouseMessage (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2421 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2423 TOOLTIPS_Hide (hwnd
, infoPtr
);
2430 TOOLTIPS_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2432 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
2433 DWORD dwExStyle
= GetWindowLongW (hwnd
, GWL_EXSTYLE
);
2435 dwStyle
&= ~(WS_CHILD
| /*WS_MAXIMIZE |*/ WS_BORDER
| WS_DLGFRAME
);
2436 dwStyle
|= (WS_POPUP
| WS_BORDER
| WS_CLIPSIBLINGS
);
2438 /* WS_BORDER only draws a border round the window rect, not the
2439 * window region, therefore it is useless to us in balloon mode */
2440 if (dwStyle
& TTS_BALLOON
) dwStyle
&= ~WS_BORDER
;
2442 SetWindowLongW (hwnd
, GWL_STYLE
, dwStyle
);
2444 dwExStyle
|= WS_EX_TOOLWINDOW
;
2445 SetWindowLongW (hwnd
, GWL_EXSTYLE
, dwExStyle
);
2452 TOOLTIPS_NCHitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2454 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2455 INT nTool
= (infoPtr
->bTrackActive
) ? infoPtr
->nTrackTool
: infoPtr
->nTool
;
2457 TRACE(" nTool=%d\n", nTool
);
2459 if ((nTool
> -1) && (nTool
< infoPtr
->uNumTools
)) {
2460 if (infoPtr
->tools
[nTool
].uFlags
& TTF_TRANSPARENT
) {
2461 TRACE("-- in transparent mode!\n");
2462 return HTTRANSPARENT
;
2466 return DefWindowProcW (hwnd
, WM_NCHITTEST
, wParam
, lParam
);
2471 TOOLTIPS_NotifyFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2473 FIXME ("hwnd=%p wParam=%lx lParam=%lx\n", hwnd
, wParam
, lParam
);
2480 TOOLTIPS_Paint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2485 hdc
= (wParam
== 0) ? BeginPaint (hwnd
, &ps
) : (HDC
)wParam
;
2486 TOOLTIPS_Refresh (hwnd
, hdc
);
2488 EndPaint (hwnd
, &ps
);
2494 TOOLTIPS_SetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2496 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2499 if(!GetObjectW((HFONT
)wParam
, sizeof(lf
), &lf
))
2502 DeleteObject (infoPtr
->hFont
);
2503 infoPtr
->hFont
= CreateFontIndirectW(&lf
);
2505 DeleteObject (infoPtr
->hTitleFont
);
2506 lf
.lfWeight
= FW_BOLD
;
2507 infoPtr
->hTitleFont
= CreateFontIndirectW(&lf
);
2509 if ((LOWORD(lParam
)) & (infoPtr
->nCurrentTool
!= -1)) {
2510 FIXME("full redraw needed!\n");
2516 /******************************************************************
2517 * TOOLTIPS_GetTextLength
2519 * This function is called when the tooltip receive a
2520 * WM_GETTEXTLENGTH message.
2524 * returns the length, in characters, of the tip text
2527 TOOLTIPS_GetTextLength(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2529 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2530 return strlenW(infoPtr
->szTipText
);
2533 /******************************************************************
2534 * TOOLTIPS_OnWMGetText
2536 * This function is called when the tooltip receive a
2537 * WM_GETTEXT message.
2538 * wParam : specifies the maximum number of characters to be copied
2539 * lParam : is the pointer to the buffer that will receive
2542 * returns the number of characters copied
2545 TOOLTIPS_OnWMGetText (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2547 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2549 LPWSTR pszText
= (LPWSTR
)lParam
;
2551 if(!infoPtr
->szTipText
|| !wParam
)
2554 res
= min(strlenW(infoPtr
->szTipText
)+1, wParam
);
2555 memcpy(pszText
, infoPtr
->szTipText
, res
*sizeof(WCHAR
));
2556 pszText
[res
-1] = '\0';
2561 TOOLTIPS_Timer (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2563 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2566 TRACE("timer %ld (%p) expired!\n", wParam
, hwnd
);
2570 KillTimer (hwnd
, ID_TIMERSHOW
);
2571 nOldTool
= infoPtr
->nTool
;
2572 if ((infoPtr
->nTool
= TOOLTIPS_CheckTool (hwnd
, TRUE
)) == nOldTool
)
2573 TOOLTIPS_Show (hwnd
, infoPtr
);
2577 TOOLTIPS_Hide (hwnd
, infoPtr
);
2581 nOldTool
= infoPtr
->nTool
;
2582 infoPtr
->nTool
= TOOLTIPS_CheckTool (hwnd
, FALSE
);
2583 TRACE("tool (%p) %d %d %d\n", hwnd
, nOldTool
,
2584 infoPtr
->nTool
, infoPtr
->nCurrentTool
);
2585 if (infoPtr
->nTool
!= nOldTool
) {
2586 if(infoPtr
->nTool
== -1) { /* Moved out of all tools */
2587 TOOLTIPS_Hide(hwnd
, infoPtr
);
2588 KillTimer(hwnd
, ID_TIMERLEAVE
);
2589 } else if (nOldTool
== -1) { /* Moved from outside */
2590 ERR("How did this happen?\n");
2591 } else { /* Moved from one to another */
2592 TOOLTIPS_Hide (hwnd
, infoPtr
);
2593 KillTimer(hwnd
, ID_TIMERLEAVE
);
2594 if(infoPtr
->bActive
) {
2595 SetTimer (hwnd
, ID_TIMERSHOW
, infoPtr
->nReshowTime
, 0);
2596 TRACE("timer 1 started!\n");
2603 ERR("Unknown timer id %ld\n", wParam
);
2611 TOOLTIPS_WinIniChange (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2613 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2615 TOOLTIPS_InitSystemSettings (infoPtr
);
2621 static LRESULT CALLBACK
2622 TOOLTIPS_SubclassProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
2628 case WM_LBUTTONDOWN
:
2630 case WM_MBUTTONDOWN
:
2632 case WM_RBUTTONDOWN
:
2636 msg
.wParam
= wParam
;
2637 msg
.lParam
= lParam
;
2638 TOOLTIPS_RelayEvent((HWND
)dwRef
, 0, (LPARAM
)&msg
);
2644 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
2648 static LRESULT CALLBACK
2649 TOOLTIPS_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2651 TRACE("hwnd=%p msg=%x wparam=%lx lParam=%lx\n", hwnd
, uMsg
, wParam
, lParam
);
2652 if (!TOOLTIPS_GetInfoPtr(hwnd
) && (uMsg
!= WM_CREATE
) && (uMsg
!= WM_NCCREATE
))
2653 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2657 return TOOLTIPS_Activate (hwnd
, wParam
, lParam
);
2660 return TOOLTIPS_AddToolA (hwnd
, wParam
, lParam
);
2663 return TOOLTIPS_AddToolW (hwnd
, wParam
, lParam
);
2666 return TOOLTIPS_DelToolA (hwnd
, wParam
, lParam
);
2669 return TOOLTIPS_DelToolW (hwnd
, wParam
, lParam
);
2671 case TTM_ENUMTOOLSA
:
2672 return TOOLTIPS_EnumToolsA (hwnd
, wParam
, lParam
);
2674 case TTM_ENUMTOOLSW
:
2675 return TOOLTIPS_EnumToolsW (hwnd
, wParam
, lParam
);
2677 case TTM_GETBUBBLESIZE
:
2678 return TOOLTIPS_GetBubbleSize (hwnd
, wParam
, lParam
);
2680 case TTM_GETCURRENTTOOLA
:
2681 return TOOLTIPS_GetCurrentToolA (hwnd
, wParam
, lParam
);
2683 case TTM_GETCURRENTTOOLW
:
2684 return TOOLTIPS_GetCurrentToolW (hwnd
, wParam
, lParam
);
2686 case TTM_GETDELAYTIME
:
2687 return TOOLTIPS_GetDelayTime (hwnd
, wParam
, lParam
);
2690 return TOOLTIPS_GetMargin (hwnd
, wParam
, lParam
);
2692 case TTM_GETMAXTIPWIDTH
:
2693 return TOOLTIPS_GetMaxTipWidth (hwnd
, wParam
, lParam
);
2696 return TOOLTIPS_GetTextA (hwnd
, wParam
, lParam
);
2699 return TOOLTIPS_GetTextW (hwnd
, wParam
, lParam
);
2701 case TTM_GETTIPBKCOLOR
:
2702 return TOOLTIPS_GetTipBkColor (hwnd
, wParam
, lParam
);
2704 case TTM_GETTIPTEXTCOLOR
:
2705 return TOOLTIPS_GetTipTextColor (hwnd
, wParam
, lParam
);
2707 case TTM_GETTOOLCOUNT
:
2708 return TOOLTIPS_GetToolCount (hwnd
, wParam
, lParam
);
2710 case TTM_GETTOOLINFOA
:
2711 return TOOLTIPS_GetToolInfoA (hwnd
, wParam
, lParam
);
2713 case TTM_GETTOOLINFOW
:
2714 return TOOLTIPS_GetToolInfoW (hwnd
, wParam
, lParam
);
2717 return TOOLTIPS_HitTestA (hwnd
, wParam
, lParam
);
2720 return TOOLTIPS_HitTestW (hwnd
, wParam
, lParam
);
2722 case TTM_NEWTOOLRECTA
:
2723 return TOOLTIPS_NewToolRectA (hwnd
, wParam
, lParam
);
2725 case TTM_NEWTOOLRECTW
:
2726 return TOOLTIPS_NewToolRectW (hwnd
, wParam
, lParam
);
2729 return TOOLTIPS_Pop (hwnd
, wParam
, lParam
);
2731 case TTM_RELAYEVENT
:
2732 return TOOLTIPS_RelayEvent (hwnd
, wParam
, lParam
);
2734 case TTM_SETDELAYTIME
:
2735 return TOOLTIPS_SetDelayTime (hwnd
, wParam
, lParam
);
2738 return TOOLTIPS_SetMargin (hwnd
, wParam
, lParam
);
2740 case TTM_SETMAXTIPWIDTH
:
2741 return TOOLTIPS_SetMaxTipWidth (hwnd
, wParam
, lParam
);
2743 case TTM_SETTIPBKCOLOR
:
2744 return TOOLTIPS_SetTipBkColor (hwnd
, wParam
, lParam
);
2746 case TTM_SETTIPTEXTCOLOR
:
2747 return TOOLTIPS_SetTipTextColor (hwnd
, wParam
, lParam
);
2750 return TOOLTIPS_SetTitleA (hwnd
, wParam
, lParam
);
2753 return TOOLTIPS_SetTitleW (hwnd
, wParam
, lParam
);
2755 case TTM_SETTOOLINFOA
:
2756 return TOOLTIPS_SetToolInfoA (hwnd
, wParam
, lParam
);
2758 case TTM_SETTOOLINFOW
:
2759 return TOOLTIPS_SetToolInfoW (hwnd
, wParam
, lParam
);
2761 case TTM_TRACKACTIVATE
:
2762 return TOOLTIPS_TrackActivate (hwnd
, wParam
, lParam
);
2764 case TTM_TRACKPOSITION
:
2765 return TOOLTIPS_TrackPosition (hwnd
, wParam
, lParam
);
2768 return TOOLTIPS_Update (hwnd
, wParam
, lParam
);
2770 case TTM_UPDATETIPTEXTA
:
2771 return TOOLTIPS_UpdateTipTextA (hwnd
, wParam
, lParam
);
2773 case TTM_UPDATETIPTEXTW
:
2774 return TOOLTIPS_UpdateTipTextW (hwnd
, wParam
, lParam
);
2776 case TTM_WINDOWFROMPOINT
:
2777 return TOOLTIPS_WindowFromPoint (hwnd
, wParam
, lParam
);
2781 return TOOLTIPS_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
2784 return TOOLTIPS_Destroy (hwnd
, wParam
, lParam
);
2787 /* we draw the background in WM_PAINT */
2791 return TOOLTIPS_GetFont (hwnd
, wParam
, lParam
);
2794 return TOOLTIPS_OnWMGetText (hwnd
, wParam
, lParam
);
2796 case WM_GETTEXTLENGTH
:
2797 return TOOLTIPS_GetTextLength (hwnd
, wParam
, lParam
);
2799 case WM_LBUTTONDOWN
:
2801 case WM_MBUTTONDOWN
:
2803 case WM_RBUTTONDOWN
:
2806 return TOOLTIPS_MouseMessage (hwnd
, uMsg
, wParam
, lParam
);
2809 return TOOLTIPS_NCCreate (hwnd
, wParam
, lParam
);
2812 return TOOLTIPS_NCHitTest (hwnd
, wParam
, lParam
);
2814 case WM_NOTIFYFORMAT
:
2815 return TOOLTIPS_NotifyFormat (hwnd
, wParam
, lParam
);
2817 case WM_PRINTCLIENT
:
2819 return TOOLTIPS_Paint (hwnd
, wParam
, lParam
);
2822 return TOOLTIPS_SetFont (hwnd
, wParam
, lParam
);
2825 return TOOLTIPS_Timer (hwnd
, wParam
, lParam
);
2827 case WM_WININICHANGE
:
2828 return TOOLTIPS_WinIniChange (hwnd
, wParam
, lParam
);
2831 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
2832 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
2833 uMsg
, wParam
, lParam
);
2834 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2840 TOOLTIPS_Register (void)
2844 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
2845 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
| CS_SAVEBITS
;
2846 wndClass
.lpfnWndProc
= TOOLTIPS_WindowProc
;
2847 wndClass
.cbClsExtra
= 0;
2848 wndClass
.cbWndExtra
= sizeof(TOOLTIPS_INFO
*);
2849 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
2850 wndClass
.hbrBackground
= 0;
2851 wndClass
.lpszClassName
= TOOLTIPS_CLASSW
;
2853 RegisterClassW (&wndClass
);
2855 hTooltipIcons
[TTI_NONE
] = NULL
;
2856 hTooltipIcons
[TTI_INFO
] = LoadImageW(COMCTL32_hModule
,
2857 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_INFO_SM
), IMAGE_ICON
, 0, 0, 0);
2858 hTooltipIcons
[TTI_WARNING
] = LoadImageW(COMCTL32_hModule
,
2859 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_WARN_SM
), IMAGE_ICON
, 0, 0, 0);
2860 hTooltipIcons
[TTI_ERROR
] = LoadImageW(COMCTL32_hModule
,
2861 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_ERROR_SM
), IMAGE_ICON
, 0, 0, 0);
2866 TOOLTIPS_Unregister (void)
2869 for (i
= TTI_INFO
; i
<= TTI_ERROR
; i
++)
2870 DestroyIcon(hTooltipIcons
[i
]);
2871 UnregisterClassW (TOOLTIPS_CLASSW
, NULL
);