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
, toolPtr
->uId
, (LPARAM
)&ttnmdi
);
325 if (IS_INTRESOURCE(ttnmdi
.lpszText
)) {
326 LoadStringW(ttnmdi
.hinst
, LOWORD(ttnmdi
.lpszText
),
327 infoPtr
->szTipText
, INFOTIPSIZE
);
328 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
329 toolPtr
->hinst
= ttnmdi
.hinst
;
330 toolPtr
->lpszText
= (LPWSTR
)ttnmdi
.lpszText
;
333 else if (ttnmdi
.lpszText
== 0) {
334 infoPtr
->szTipText
[0] = '\0';
336 else if (ttnmdi
.lpszText
!= LPSTR_TEXTCALLBACKA
) {
337 Str_GetPtrAtoW(ttnmdi
.lpszText
, infoPtr
->szTipText
, INFOTIPSIZE
);
338 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
340 toolPtr
->lpszText
= NULL
;
341 Str_SetPtrW(&toolPtr
->lpszText
, infoPtr
->szTipText
);
345 ERR("recursive text callback!\n");
346 infoPtr
->szTipText
[0] = '\0';
349 /* no text available - try calling parent instead as per native */
350 /* FIXME: Unsure if SETITEM should save the value or not */
351 if (infoPtr
->szTipText
[0] == 0x00) {
353 SendMessageW(GetParent(toolPtr
->hwnd
), WM_NOTIFY
, toolPtr
->uId
, (LPARAM
)&ttnmdi
);
355 if (IS_INTRESOURCE(ttnmdi
.lpszText
)) {
356 LoadStringW(ttnmdi
.hinst
, LOWORD(ttnmdi
.lpszText
),
357 infoPtr
->szTipText
, INFOTIPSIZE
);
358 } else if (ttnmdi
.lpszText
&&
359 ttnmdi
.lpszText
!= LPSTR_TEXTCALLBACKA
) {
360 Str_GetPtrAtoW(ttnmdi
.lpszText
, infoPtr
->szTipText
, INFOTIPSIZE
);
365 static void TOOLTIPS_GetDispInfoW(HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, TTTOOL_INFO
*toolPtr
)
367 NMTTDISPINFOW ttnmdi
;
369 /* fill NMHDR struct */
370 ZeroMemory (&ttnmdi
, sizeof(NMTTDISPINFOW
));
371 ttnmdi
.hdr
.hwndFrom
= hwnd
;
372 ttnmdi
.hdr
.idFrom
= toolPtr
->uId
;
373 ttnmdi
.hdr
.code
= TTN_GETDISPINFOW
; /* == TTN_NEEDTEXTW */
374 ttnmdi
.lpszText
= (LPWSTR
)&ttnmdi
.szText
;
375 ttnmdi
.uFlags
= toolPtr
->uFlags
;
376 ttnmdi
.lParam
= toolPtr
->lParam
;
378 TRACE("hdr.idFrom = %lx\n", ttnmdi
.hdr
.idFrom
);
379 SendMessageW(toolPtr
->hwnd
, WM_NOTIFY
, toolPtr
->uId
, (LPARAM
)&ttnmdi
);
381 if (IS_INTRESOURCE(ttnmdi
.lpszText
)) {
382 LoadStringW(ttnmdi
.hinst
, LOWORD(ttnmdi
.lpszText
),
383 infoPtr
->szTipText
, INFOTIPSIZE
);
384 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
385 toolPtr
->hinst
= ttnmdi
.hinst
;
386 toolPtr
->lpszText
= ttnmdi
.lpszText
;
389 else if (ttnmdi
.lpszText
== 0) {
390 infoPtr
->szTipText
[0] = '\0';
392 else if (ttnmdi
.lpszText
!= LPSTR_TEXTCALLBACKW
) {
393 Str_GetPtrW(ttnmdi
.lpszText
, infoPtr
->szTipText
, INFOTIPSIZE
);
394 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
396 toolPtr
->lpszText
= NULL
;
397 Str_SetPtrW(&toolPtr
->lpszText
, infoPtr
->szTipText
);
401 ERR("recursive text callback!\n");
402 infoPtr
->szTipText
[0] = '\0';
405 /* no text available - try calling parent instead as per native */
406 /* FIXME: Unsure if SETITEM should save the value or not */
407 if (infoPtr
->szTipText
[0] == 0x00) {
409 SendMessageW(GetParent(toolPtr
->hwnd
), WM_NOTIFY
, toolPtr
->uId
, (LPARAM
)&ttnmdi
);
411 if (IS_INTRESOURCE(ttnmdi
.lpszText
)) {
412 LoadStringW(ttnmdi
.hinst
, LOWORD(ttnmdi
.lpszText
),
413 infoPtr
->szTipText
, INFOTIPSIZE
);
414 } else if (ttnmdi
.lpszText
&&
415 ttnmdi
.lpszText
!= LPSTR_TEXTCALLBACKW
) {
416 Str_GetPtrW(ttnmdi
.lpszText
, infoPtr
->szTipText
, INFOTIPSIZE
);
423 TOOLTIPS_GetTipText (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, INT nTool
)
425 TTTOOL_INFO
*toolPtr
= &infoPtr
->tools
[nTool
];
427 if (IS_INTRESOURCE(toolPtr
->lpszText
) && toolPtr
->hinst
) {
428 /* load a resource */
429 TRACE("load res string %p %x\n",
430 toolPtr
->hinst
, LOWORD(toolPtr
->lpszText
));
431 LoadStringW (toolPtr
->hinst
, LOWORD(toolPtr
->lpszText
),
432 infoPtr
->szTipText
, INFOTIPSIZE
);
434 else if (toolPtr
->lpszText
) {
435 if (toolPtr
->lpszText
== LPSTR_TEXTCALLBACKW
) {
436 if (toolPtr
->bNotifyUnicode
)
437 TOOLTIPS_GetDispInfoW(hwnd
, infoPtr
, toolPtr
);
439 TOOLTIPS_GetDispInfoA(hwnd
, infoPtr
, toolPtr
);
442 /* the item is a usual (unicode) text */
443 lstrcpynW (infoPtr
->szTipText
, toolPtr
->lpszText
, INFOTIPSIZE
);
447 /* no text available */
448 infoPtr
->szTipText
[0] = '\0';
451 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
456 TOOLTIPS_CalcTipSize (HWND hwnd
, const TOOLTIPS_INFO
*infoPtr
, LPSIZE lpSize
)
460 DWORD style
= GetWindowLongW(hwnd
, GWL_STYLE
);
461 UINT uFlags
= DT_EXTERNALLEADING
| DT_CALCRECT
;
462 RECT rc
= {0, 0, 0, 0};
465 if (infoPtr
->nMaxTipWidth
> -1) {
466 rc
.right
= infoPtr
->nMaxTipWidth
;
467 uFlags
|= DT_WORDBREAK
;
469 if (style
& TTS_NOPREFIX
)
470 uFlags
|= DT_NOPREFIX
;
471 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
474 if (infoPtr
->pszTitle
)
476 RECT rcTitle
= {0, 0, 0, 0};
477 TRACE("title %s\n", debugstr_w(infoPtr
->pszTitle
));
478 if (infoPtr
->hTitleIcon
)
480 title
.cx
= ICON_WIDTH
;
481 title
.cy
= ICON_HEIGHT
;
483 if (title
.cx
!= 0) title
.cx
+= BALLOON_ICON_TITLE_SPACING
;
484 hOldFont
= SelectObject (hdc
, infoPtr
->hTitleFont
);
485 DrawTextW(hdc
, infoPtr
->pszTitle
, -1, &rcTitle
, DT_SINGLELINE
| DT_NOPREFIX
| DT_CALCRECT
);
486 SelectObject (hdc
, hOldFont
);
487 title
.cy
= max(title
.cy
, rcTitle
.bottom
- rcTitle
.top
) + BALLOON_TITLE_TEXT_SPACING
;
488 title
.cx
+= (rcTitle
.right
- rcTitle
.left
);
490 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
491 DrawTextW (hdc
, infoPtr
->szTipText
, -1, &rc
, uFlags
);
492 SelectObject (hdc
, hOldFont
);
493 ReleaseDC (hwnd
, hdc
);
495 if ((style
& TTS_BALLOON
) || infoPtr
->pszTitle
)
497 lpSize
->cx
= max(rc
.right
- rc
.left
, title
.cx
) + 2*BALLOON_TEXT_MARGIN
+
498 infoPtr
->rcMargin
.left
+ infoPtr
->rcMargin
.right
;
499 lpSize
->cy
= title
.cy
+ rc
.bottom
- rc
.top
+ 2*BALLOON_TEXT_MARGIN
+
500 infoPtr
->rcMargin
.bottom
+ infoPtr
->rcMargin
.top
+
505 lpSize
->cx
= rc
.right
- rc
.left
+ 2*NORMAL_TEXT_MARGIN
+
506 infoPtr
->rcMargin
.left
+ infoPtr
->rcMargin
.right
;
507 lpSize
->cy
= rc
.bottom
- rc
.top
+ 2*NORMAL_TEXT_MARGIN
+
508 infoPtr
->rcMargin
.bottom
+ infoPtr
->rcMargin
.top
;
514 TOOLTIPS_Show (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, BOOL track_activate
)
516 TTTOOL_INFO
*toolPtr
;
518 MONITORINFO mon_info
;
523 DWORD style
= GetWindowLongW(hwnd
, GWL_STYLE
);
528 if (infoPtr
->nTrackTool
== -1)
530 TRACE("invalid tracking tool (-1)!\n");
533 nTool
= infoPtr
->nTrackTool
;
537 if (infoPtr
->nTool
== -1)
539 TRACE("invalid tool (-1)!\n");
542 nTool
= infoPtr
->nTool
;
545 TRACE("Show tooltip pre %d! (%p)\n", nTool
, hwnd
);
547 TOOLTIPS_GetTipText (hwnd
, infoPtr
, nTool
);
549 if (infoPtr
->szTipText
[0] == '\0')
552 toolPtr
= &infoPtr
->tools
[nTool
];
555 infoPtr
->nCurrentTool
= infoPtr
->nTool
;
557 TRACE("Show tooltip %d!\n", nTool
);
560 hdr
.idFrom
= toolPtr
->uId
;
562 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
, toolPtr
->uId
, (LPARAM
)&hdr
);
564 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
566 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
567 TRACE("size %d x %d\n", size
.cx
, size
.cy
);
571 rect
.left
= infoPtr
->xTrackPos
;
572 rect
.top
= infoPtr
->yTrackPos
;
575 if (toolPtr
->uFlags
& TTF_CENTERTIP
)
577 rect
.left
-= (size
.cx
/ 2);
578 if (!(style
& TTS_BALLOON
))
579 rect
.top
-= (size
.cy
/ 2);
581 infoPtr
->bToolBelow
= TRUE
;
583 if (!(toolPtr
->uFlags
& TTF_ABSOLUTE
))
585 if (style
& TTS_BALLOON
)
586 rect
.left
-= BALLOON_STEMINDENT
;
591 if (toolPtr
->uFlags
& TTF_IDISHWND
)
592 GetWindowRect ((HWND
)toolPtr
->uId
, &rcTool
);
595 rcTool
= toolPtr
->rect
;
596 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rcTool
, 2);
599 /* smart placement */
600 if ((rect
.left
+ size
.cx
> rcTool
.left
) && (rect
.left
< rcTool
.right
) &&
601 (rect
.top
+ size
.cy
> rcTool
.top
) && (rect
.top
< rcTool
.bottom
))
602 rect
.left
= rcTool
.right
;
608 if (toolPtr
->uFlags
& TTF_CENTERTIP
)
612 if (toolPtr
->uFlags
& TTF_IDISHWND
)
613 GetWindowRect ((HWND
)toolPtr
->uId
, &rc
);
616 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rc
, 2);
618 rect
.left
= (rc
.left
+ rc
.right
- size
.cx
) / 2;
619 if (style
& TTS_BALLOON
)
621 ptfx
= rc
.left
+ ((rc
.right
- rc
.left
) / 2);
623 /* CENTERTIP ballon tooltips default to below the field
624 * if they fit on the screen */
625 if (rc
.bottom
+ size
.cy
> GetSystemMetrics(SM_CYSCREEN
))
627 rect
.top
= rc
.top
- size
.cy
;
628 infoPtr
->bToolBelow
= FALSE
;
632 infoPtr
->bToolBelow
= TRUE
;
633 rect
.top
= rc
.bottom
;
635 rect
.left
= max(0, rect
.left
- BALLOON_STEMINDENT
);
639 rect
.top
= rc
.bottom
+ 2;
640 infoPtr
->bToolBelow
= TRUE
;
645 GetCursorPos ((LPPOINT
)&rect
);
646 if (style
& TTS_BALLOON
)
649 if(rect
.top
- size
.cy
>= 0)
652 infoPtr
->bToolBelow
= FALSE
;
656 infoPtr
->bToolBelow
= TRUE
;
659 rect
.left
= max(0, rect
.left
- BALLOON_STEMINDENT
);
664 infoPtr
->bToolBelow
= TRUE
;
669 TRACE("pos %d - %d\n", rect
.left
, rect
.top
);
671 rect
.right
= rect
.left
+ size
.cx
;
672 rect
.bottom
= rect
.top
+ size
.cy
;
676 monitor
= MonitorFromRect( &rect
, MONITOR_DEFAULTTOPRIMARY
);
677 mon_info
.cbSize
= sizeof(mon_info
);
678 GetMonitorInfoW( monitor
, &mon_info
);
680 if( rect
.right
> mon_info
.rcWork
.right
) {
681 rect
.left
-= rect
.right
- mon_info
.rcWork
.right
+ 2;
682 rect
.right
= mon_info
.rcWork
.right
- 2;
684 if (rect
.left
< mon_info
.rcWork
.left
) rect
.left
= mon_info
.rcWork
.left
;
686 if( rect
.bottom
> mon_info
.rcWork
.bottom
) {
689 if (toolPtr
->uFlags
& TTF_IDISHWND
)
690 GetWindowRect ((HWND
)toolPtr
->uId
, &rc
);
693 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rc
, 2);
695 rect
.bottom
= rc
.top
- 2;
696 rect
.top
= rect
.bottom
- size
.cy
;
699 AdjustWindowRectEx (&rect
, GetWindowLongW (hwnd
, GWL_STYLE
),
700 FALSE
, GetWindowLongW (hwnd
, GWL_EXSTYLE
));
702 if (style
& TTS_BALLOON
)
710 if(infoPtr
->bToolBelow
)
714 pts
[1].x
= max(BALLOON_STEMINDENT
, ptfx
- (BALLOON_STEMWIDTH
/ 2));
715 pts
[1].y
= BALLOON_STEMHEIGHT
;
716 pts
[2].x
= pts
[1].x
+ BALLOON_STEMWIDTH
;
718 if(pts
[2].x
> (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
)
720 pts
[2].x
= (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
;
721 pts
[1].x
= pts
[2].x
- BALLOON_STEMWIDTH
;
726 pts
[0].x
= max(BALLOON_STEMINDENT
, ptfx
- (BALLOON_STEMWIDTH
/ 2));
727 pts
[0].y
= (rect
.bottom
- rect
.top
) - BALLOON_STEMHEIGHT
;
728 pts
[1].x
= pts
[0].x
+ BALLOON_STEMWIDTH
;
731 pts
[2].y
= (rect
.bottom
- rect
.top
);
732 if(pts
[1].x
> (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
)
734 pts
[1].x
= (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
;
735 pts
[0].x
= pts
[1].x
- BALLOON_STEMWIDTH
;
739 hrStem
= CreatePolygonRgn(pts
, sizeof(pts
) / sizeof(pts
[0]), ALTERNATE
);
741 hRgn
= CreateRoundRectRgn(0,
742 (infoPtr
->bToolBelow
? BALLOON_STEMHEIGHT
: 0),
743 rect
.right
- rect
.left
,
744 (infoPtr
->bToolBelow
? rect
.bottom
- rect
.top
: rect
.bottom
- rect
.top
- BALLOON_STEMHEIGHT
),
745 BALLOON_ROUNDEDNESS
, BALLOON_ROUNDEDNESS
);
747 CombineRgn(hRgn
, hRgn
, hrStem
, RGN_OR
);
748 DeleteObject(hrStem
);
750 SetWindowRgn(hwnd
, hRgn
, FALSE
);
751 /* we don't free the region handle as the system deletes it when
752 * it is no longer needed */
755 SetWindowPos (hwnd
, HWND_TOPMOST
, rect
.left
, rect
.top
,
756 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
757 SWP_SHOWWINDOW
| SWP_NOACTIVATE
);
759 /* repaint the tooltip */
760 InvalidateRect(hwnd
, NULL
, TRUE
);
765 SetTimer (hwnd
, ID_TIMERPOP
, infoPtr
->nAutoPopTime
, 0);
766 TRACE("timer 2 started!\n");
767 SetTimer (hwnd
, ID_TIMERLEAVE
, infoPtr
->nReshowTime
, 0);
768 TRACE("timer 3 started!\n");
774 TOOLTIPS_Hide (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
776 TTTOOL_INFO
*toolPtr
;
779 TRACE("Hide tooltip %d! (%p)\n", infoPtr
->nCurrentTool
, hwnd
);
781 if (infoPtr
->nCurrentTool
== -1)
784 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
785 KillTimer (hwnd
, ID_TIMERPOP
);
788 hdr
.idFrom
= toolPtr
->uId
;
790 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
, toolPtr
->uId
, (LPARAM
)&hdr
);
792 infoPtr
->nCurrentTool
= -1;
794 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0,
795 SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
800 TOOLTIPS_TrackShow (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
802 TOOLTIPS_Show(hwnd
, infoPtr
, TRUE
);
807 TOOLTIPS_TrackHide (HWND hwnd
, const TOOLTIPS_INFO
*infoPtr
)
809 TTTOOL_INFO
*toolPtr
;
812 TRACE("hide tracking tooltip %d\n", infoPtr
->nTrackTool
);
814 if (infoPtr
->nTrackTool
== -1)
817 toolPtr
= &infoPtr
->tools
[infoPtr
->nTrackTool
];
820 hdr
.idFrom
= toolPtr
->uId
;
822 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
, toolPtr
->uId
, (LPARAM
)&hdr
);
824 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0,
825 SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
830 TOOLTIPS_GetToolFromInfoA (const TOOLTIPS_INFO
*infoPtr
, const TTTOOLINFOA
*lpToolInfo
)
832 TTTOOL_INFO
*toolPtr
;
835 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
836 toolPtr
= &infoPtr
->tools
[nTool
];
838 if (!(toolPtr
->uFlags
& TTF_IDISHWND
) &&
839 (lpToolInfo
->hwnd
== toolPtr
->hwnd
) &&
840 (lpToolInfo
->uId
== toolPtr
->uId
))
844 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
845 toolPtr
= &infoPtr
->tools
[nTool
];
847 if ((toolPtr
->uFlags
& TTF_IDISHWND
) &&
848 (lpToolInfo
->uId
== toolPtr
->uId
))
857 TOOLTIPS_GetToolFromInfoW (const TOOLTIPS_INFO
*infoPtr
, const TTTOOLINFOW
*lpToolInfo
)
859 TTTOOL_INFO
*toolPtr
;
862 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
863 toolPtr
= &infoPtr
->tools
[nTool
];
865 if (!(toolPtr
->uFlags
& TTF_IDISHWND
) &&
866 (lpToolInfo
->hwnd
== toolPtr
->hwnd
) &&
867 (lpToolInfo
->uId
== toolPtr
->uId
))
871 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
872 toolPtr
= &infoPtr
->tools
[nTool
];
874 if ((toolPtr
->uFlags
& TTF_IDISHWND
) &&
875 (lpToolInfo
->uId
== toolPtr
->uId
))
884 TOOLTIPS_GetToolFromPoint (const TOOLTIPS_INFO
*infoPtr
, HWND hwnd
, const POINT
*lpPt
)
886 TTTOOL_INFO
*toolPtr
;
889 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
890 toolPtr
= &infoPtr
->tools
[nTool
];
892 if (!(toolPtr
->uFlags
& TTF_IDISHWND
)) {
893 if (hwnd
!= toolPtr
->hwnd
)
895 if (!PtInRect (&toolPtr
->rect
, *lpPt
))
901 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
902 toolPtr
= &infoPtr
->tools
[nTool
];
904 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
905 if ((HWND
)toolPtr
->uId
== hwnd
)
915 TOOLTIPS_IsWindowActive (HWND hwnd
)
917 HWND hwndActive
= GetActiveWindow ();
920 if (hwndActive
== hwnd
)
922 return IsChild (hwndActive
, hwnd
);
927 TOOLTIPS_CheckTool (HWND hwnd
, BOOL bShowTest
)
929 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
935 hwndTool
= (HWND
)SendMessageW (hwnd
, TTM_WINDOWFROMPOINT
, 0, (LPARAM
)&pt
);
939 ScreenToClient (hwndTool
, &pt
);
940 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, hwndTool
, &pt
);
944 if (!(GetWindowLongW (hwnd
, GWL_STYLE
) & TTS_ALWAYSTIP
) && bShowTest
) {
945 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd
, GW_OWNER
)))
949 TRACE("tool %d\n", nTool
);
956 TOOLTIPS_Activate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
958 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
960 infoPtr
->bActive
= (BOOL
)wParam
;
962 if (infoPtr
->bActive
)
963 TRACE("activate!\n");
965 if (!(infoPtr
->bActive
) && (infoPtr
->nCurrentTool
!= -1))
966 TOOLTIPS_Hide (hwnd
, infoPtr
);
973 TOOLTIPS_AddToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
975 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
976 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
977 TTTOOL_INFO
*toolPtr
;
980 if (lpToolInfo
== NULL
)
982 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
985 TRACE("add tool (%p) %p %ld%s!\n",
986 hwnd
, lpToolInfo
->hwnd
, lpToolInfo
->uId
,
987 (lpToolInfo
->uFlags
& TTF_IDISHWND
) ? " TTF_IDISHWND" : "");
989 if (infoPtr
->uNumTools
== 0) {
990 infoPtr
->tools
= Alloc (sizeof(TTTOOL_INFO
));
991 toolPtr
= infoPtr
->tools
;
994 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
996 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
+ 1));
997 memcpy (infoPtr
->tools
, oldTools
,
998 infoPtr
->uNumTools
* sizeof(TTTOOL_INFO
));
1000 toolPtr
= &infoPtr
->tools
[infoPtr
->uNumTools
];
1003 infoPtr
->uNumTools
++;
1005 /* copy tool data */
1006 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
1007 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
1008 toolPtr
->uId
= lpToolInfo
->uId
;
1009 toolPtr
->rect
= lpToolInfo
->rect
;
1010 toolPtr
->hinst
= lpToolInfo
->hinst
;
1012 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)) {
1013 TRACE("add string id %x!\n", LOWORD(lpToolInfo
->lpszText
));
1014 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
1016 else if (lpToolInfo
->lpszText
) {
1017 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
) {
1018 TRACE("add CALLBACK!\n");
1019 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
1022 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
1024 TRACE("add text \"%s\"!\n", lpToolInfo
->lpszText
);
1025 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
1026 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
1027 toolPtr
->lpszText
, len
);
1031 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1032 toolPtr
->lParam
= lpToolInfo
->lParam
;
1034 /* install subclassing hook */
1035 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1036 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1037 SetWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1,
1041 SetWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1,
1044 TRACE("subclassing installed!\n");
1047 nResult
= (INT
) SendMessageW (toolPtr
->hwnd
, WM_NOTIFYFORMAT
,
1048 (WPARAM
)hwnd
, (LPARAM
)NF_QUERY
);
1049 if (nResult
== NFR_ANSI
) {
1050 toolPtr
->bNotifyUnicode
= FALSE
;
1051 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1052 } else if (nResult
== NFR_UNICODE
) {
1053 toolPtr
->bNotifyUnicode
= TRUE
;
1054 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1056 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1064 TOOLTIPS_AddToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1066 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1067 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1068 TTTOOL_INFO
*toolPtr
;
1071 if (lpToolInfo
== NULL
)
1073 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1076 TRACE("add tool (%p) %p %ld%s!\n",
1077 hwnd
, lpToolInfo
->hwnd
, lpToolInfo
->uId
,
1078 (lpToolInfo
->uFlags
& TTF_IDISHWND
) ? " TTF_IDISHWND" : "");
1080 if (infoPtr
->uNumTools
== 0) {
1081 infoPtr
->tools
= Alloc (sizeof(TTTOOL_INFO
));
1082 toolPtr
= infoPtr
->tools
;
1085 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1087 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
+ 1));
1088 memcpy (infoPtr
->tools
, oldTools
,
1089 infoPtr
->uNumTools
* sizeof(TTTOOL_INFO
));
1091 toolPtr
= &infoPtr
->tools
[infoPtr
->uNumTools
];
1094 infoPtr
->uNumTools
++;
1096 /* copy tool data */
1097 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
1098 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
1099 toolPtr
->uId
= lpToolInfo
->uId
;
1100 toolPtr
->rect
= lpToolInfo
->rect
;
1101 toolPtr
->hinst
= lpToolInfo
->hinst
;
1103 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)) {
1104 TRACE("add string id %x\n", LOWORD(lpToolInfo
->lpszText
));
1105 toolPtr
->lpszText
= lpToolInfo
->lpszText
;
1107 else if (lpToolInfo
->lpszText
) {
1108 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
) {
1109 TRACE("add CALLBACK!\n");
1110 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
1113 INT len
= lstrlenW (lpToolInfo
->lpszText
);
1114 TRACE("add text %s!\n",
1115 debugstr_w(lpToolInfo
->lpszText
));
1116 toolPtr
->lpszText
= Alloc ((len
+ 1)*sizeof(WCHAR
));
1117 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
1121 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1122 toolPtr
->lParam
= lpToolInfo
->lParam
;
1124 /* install subclassing hook */
1125 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1126 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1127 SetWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1,
1131 SetWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1,
1134 TRACE("subclassing installed!\n");
1137 nResult
= (INT
) SendMessageW (toolPtr
->hwnd
, WM_NOTIFYFORMAT
,
1138 (WPARAM
)hwnd
, (LPARAM
)NF_QUERY
);
1139 if (nResult
== NFR_ANSI
) {
1140 toolPtr
->bNotifyUnicode
= FALSE
;
1141 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1142 } else if (nResult
== NFR_UNICODE
) {
1143 toolPtr
->bNotifyUnicode
= TRUE
;
1144 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1146 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1154 TOOLTIPS_DelToolCommon (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, INT nTool
)
1156 TTTOOL_INFO
*toolPtr
;
1158 TRACE("tool %d\n", nTool
);
1163 /* make sure the tooltip has disappeared before deleting it */
1164 TOOLTIPS_Hide(hwnd
, infoPtr
);
1166 /* delete text string */
1167 toolPtr
= &infoPtr
->tools
[nTool
];
1168 if (toolPtr
->lpszText
) {
1169 if ( (toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
) &&
1170 !IS_INTRESOURCE(toolPtr
->lpszText
) )
1171 Free (toolPtr
->lpszText
);
1174 /* remove subclassing */
1175 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1176 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1177 RemoveWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1);
1180 RemoveWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1);
1184 /* delete tool from tool list */
1185 if (infoPtr
->uNumTools
== 1) {
1186 Free (infoPtr
->tools
);
1187 infoPtr
->tools
= NULL
;
1190 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1192 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
- 1));
1195 memcpy (&infoPtr
->tools
[0], &oldTools
[0],
1196 nTool
* sizeof(TTTOOL_INFO
));
1198 if (nTool
< infoPtr
->uNumTools
- 1)
1199 memcpy (&infoPtr
->tools
[nTool
], &oldTools
[nTool
+ 1],
1200 (infoPtr
->uNumTools
- nTool
- 1) * sizeof(TTTOOL_INFO
));
1205 /* update any indices affected by delete */
1207 /* destroying tool that mouse was on on last relayed mouse move */
1208 if (infoPtr
->nTool
== nTool
)
1209 /* -1 means no current tool (0 means first tool) */
1210 infoPtr
->nTool
= -1;
1211 else if (infoPtr
->nTool
> nTool
)
1214 if (infoPtr
->nTrackTool
== nTool
)
1215 /* -1 means no current tool (0 means first tool) */
1216 infoPtr
->nTrackTool
= -1;
1217 else if (infoPtr
->nTrackTool
> nTool
)
1218 infoPtr
->nTrackTool
--;
1220 if (infoPtr
->nCurrentTool
== nTool
)
1221 /* -1 means no current tool (0 means first tool) */
1222 infoPtr
->nCurrentTool
= -1;
1223 else if (infoPtr
->nCurrentTool
> nTool
)
1224 infoPtr
->nCurrentTool
--;
1226 infoPtr
->uNumTools
--;
1230 TOOLTIPS_DelToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1232 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1233 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1236 if (lpToolInfo
== NULL
)
1238 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1240 if (infoPtr
->uNumTools
== 0)
1243 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1245 TOOLTIPS_DelToolCommon (hwnd
, infoPtr
, nTool
);
1252 TOOLTIPS_DelToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1254 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1255 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1258 if (lpToolInfo
== NULL
)
1260 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1262 if (infoPtr
->uNumTools
== 0)
1265 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1267 TOOLTIPS_DelToolCommon (hwnd
, infoPtr
, nTool
);
1274 TOOLTIPS_EnumToolsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1276 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1277 UINT uIndex
= (UINT
)wParam
;
1278 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1279 TTTOOL_INFO
*toolPtr
;
1281 if (lpToolInfo
== NULL
)
1283 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1285 if (uIndex
>= infoPtr
->uNumTools
)
1288 TRACE("index=%u\n", uIndex
);
1290 toolPtr
= &infoPtr
->tools
[uIndex
];
1292 /* copy tool data */
1293 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1294 lpToolInfo
->hwnd
= toolPtr
->hwnd
;
1295 lpToolInfo
->uId
= toolPtr
->uId
;
1296 lpToolInfo
->rect
= toolPtr
->rect
;
1297 lpToolInfo
->hinst
= toolPtr
->hinst
;
1298 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1299 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1301 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1302 lpToolInfo
->lParam
= toolPtr
->lParam
;
1309 TOOLTIPS_EnumToolsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1311 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1312 UINT uIndex
= (UINT
)wParam
;
1313 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1314 TTTOOL_INFO
*toolPtr
;
1316 if (lpToolInfo
== NULL
)
1318 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1320 if (uIndex
>= infoPtr
->uNumTools
)
1323 TRACE("index=%u\n", uIndex
);
1325 toolPtr
= &infoPtr
->tools
[uIndex
];
1327 /* copy tool data */
1328 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1329 lpToolInfo
->hwnd
= toolPtr
->hwnd
;
1330 lpToolInfo
->uId
= toolPtr
->uId
;
1331 lpToolInfo
->rect
= toolPtr
->rect
;
1332 lpToolInfo
->hinst
= toolPtr
->hinst
;
1333 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1334 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1336 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1337 lpToolInfo
->lParam
= toolPtr
->lParam
;
1343 TOOLTIPS_GetBubbleSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1345 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1346 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1350 if (lpToolInfo
== NULL
)
1352 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1355 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1356 if (nTool
== -1) return 0;
1358 TRACE("tool %d\n", nTool
);
1360 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
1361 TRACE("size %d x %d\n", size
.cx
, size
.cy
);
1363 return MAKELRESULT(size
.cx
, size
.cy
);
1367 TOOLTIPS_GetCurrentToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1369 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1370 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1371 TTTOOL_INFO
*toolPtr
;
1374 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1377 if (infoPtr
->nCurrentTool
> -1) {
1378 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
1380 /* copy tool data */
1381 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1382 lpToolInfo
->rect
= toolPtr
->rect
;
1383 lpToolInfo
->hinst
= toolPtr
->hinst
;
1384 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1385 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1387 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1388 lpToolInfo
->lParam
= toolPtr
->lParam
;
1396 return (infoPtr
->nCurrentTool
!= -1);
1401 TOOLTIPS_GetCurrentToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1403 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1404 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1405 TTTOOL_INFO
*toolPtr
;
1408 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1411 if (infoPtr
->nCurrentTool
> -1) {
1412 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
1414 /* copy tool data */
1415 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1416 lpToolInfo
->rect
= toolPtr
->rect
;
1417 lpToolInfo
->hinst
= toolPtr
->hinst
;
1418 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1419 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1421 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1422 lpToolInfo
->lParam
= toolPtr
->lParam
;
1430 return (infoPtr
->nCurrentTool
!= -1);
1435 TOOLTIPS_GetDelayTime (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1437 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1441 return infoPtr
->nReshowTime
;
1444 return infoPtr
->nAutoPopTime
;
1447 case TTDT_AUTOMATIC
: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */
1448 return infoPtr
->nInitialTime
;
1451 WARN("Invalid wParam %lx\n", wParam
);
1460 TOOLTIPS_GetMargin (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1462 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1463 LPRECT lpRect
= (LPRECT
)lParam
;
1465 lpRect
->left
= infoPtr
->rcMargin
.left
;
1466 lpRect
->right
= infoPtr
->rcMargin
.right
;
1467 lpRect
->bottom
= infoPtr
->rcMargin
.bottom
;
1468 lpRect
->top
= infoPtr
->rcMargin
.top
;
1474 static inline LRESULT
1475 TOOLTIPS_GetMaxTipWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1477 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1479 return infoPtr
->nMaxTipWidth
;
1484 TOOLTIPS_GetTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1486 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1487 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1490 if (lpToolInfo
== NULL
)
1492 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1495 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1496 if (nTool
== -1) return 0;
1498 /* NB this API is broken, there is no way for the app to determine
1499 what size buffer it requires nor a way to specify how long the
1500 one it supplies is. We'll assume it's up to INFOTIPSIZE */
1502 WideCharToMultiByte(CP_ACP
, 0, infoPtr
->tools
[nTool
].lpszText
, -1,
1503 lpToolInfo
->lpszText
, INFOTIPSIZE
, NULL
, NULL
);
1510 TOOLTIPS_GetTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1512 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1513 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1516 if (lpToolInfo
== NULL
)
1518 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1521 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1522 if (nTool
== -1) return 0;
1524 strcpyW (lpToolInfo
->lpszText
, infoPtr
->tools
[nTool
].lpszText
);
1530 static inline LRESULT
1531 TOOLTIPS_GetTipBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1533 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1534 return infoPtr
->clrBk
;
1538 static inline LRESULT
1539 TOOLTIPS_GetTipTextColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1541 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1542 return infoPtr
->clrText
;
1546 static inline LRESULT
1547 TOOLTIPS_GetToolCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1549 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1550 return infoPtr
->uNumTools
;
1555 TOOLTIPS_GetToolInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1557 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1558 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1559 TTTOOL_INFO
*toolPtr
;
1562 if (lpToolInfo
== NULL
)
1564 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1566 if (infoPtr
->uNumTools
== 0)
1569 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1573 TRACE("tool %d\n", nTool
);
1575 toolPtr
= &infoPtr
->tools
[nTool
];
1577 /* copy tool data */
1578 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1579 lpToolInfo
->rect
= toolPtr
->rect
;
1580 lpToolInfo
->hinst
= toolPtr
->hinst
;
1581 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1582 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1584 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1585 lpToolInfo
->lParam
= toolPtr
->lParam
;
1592 TOOLTIPS_GetToolInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1594 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1595 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1596 TTTOOL_INFO
*toolPtr
;
1599 if (lpToolInfo
== NULL
)
1601 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1603 if (infoPtr
->uNumTools
== 0)
1606 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1610 TRACE("tool %d\n", nTool
);
1612 toolPtr
= &infoPtr
->tools
[nTool
];
1614 /* copy tool data */
1615 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1616 lpToolInfo
->rect
= toolPtr
->rect
;
1617 lpToolInfo
->hinst
= toolPtr
->hinst
;
1618 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1619 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1621 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1622 lpToolInfo
->lParam
= toolPtr
->lParam
;
1629 TOOLTIPS_HitTestA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1631 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1632 LPTTHITTESTINFOA lptthit
= (LPTTHITTESTINFOA
)lParam
;
1633 TTTOOL_INFO
*toolPtr
;
1639 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, lptthit
->hwnd
, &lptthit
->pt
);
1643 TRACE("tool %d!\n", nTool
);
1645 /* copy tool data */
1646 if (lptthit
->ti
.cbSize
>= sizeof(TTTOOLINFOA
)) {
1647 toolPtr
= &infoPtr
->tools
[nTool
];
1649 lptthit
->ti
.uFlags
= toolPtr
->uFlags
;
1650 lptthit
->ti
.hwnd
= toolPtr
->hwnd
;
1651 lptthit
->ti
.uId
= toolPtr
->uId
;
1652 lptthit
->ti
.rect
= toolPtr
->rect
;
1653 lptthit
->ti
.hinst
= toolPtr
->hinst
;
1654 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1655 lptthit
->ti
.lpszText
= NULL
; /* FIXME */
1656 lptthit
->ti
.lParam
= toolPtr
->lParam
;
1664 TOOLTIPS_HitTestW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1666 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1667 LPTTHITTESTINFOW lptthit
= (LPTTHITTESTINFOW
)lParam
;
1668 TTTOOL_INFO
*toolPtr
;
1674 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, lptthit
->hwnd
, &lptthit
->pt
);
1678 TRACE("tool %d!\n", nTool
);
1680 /* copy tool data */
1681 if (lptthit
->ti
.cbSize
>= sizeof(TTTOOLINFOW
)) {
1682 toolPtr
= &infoPtr
->tools
[nTool
];
1684 lptthit
->ti
.uFlags
= toolPtr
->uFlags
;
1685 lptthit
->ti
.hwnd
= toolPtr
->hwnd
;
1686 lptthit
->ti
.uId
= toolPtr
->uId
;
1687 lptthit
->ti
.rect
= toolPtr
->rect
;
1688 lptthit
->ti
.hinst
= toolPtr
->hinst
;
1689 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1690 lptthit
->ti
.lpszText
= NULL
; /* FIXME */
1691 lptthit
->ti
.lParam
= toolPtr
->lParam
;
1699 TOOLTIPS_NewToolRectA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1701 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1702 LPTTTOOLINFOA lpti
= (LPTTTOOLINFOA
)lParam
;
1707 if (lpti
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1710 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpti
);
1712 TRACE("nTool = %d, rect = %s\n", nTool
, wine_dbgstr_rect(&lpti
->rect
));
1714 if (nTool
== -1) return 0;
1716 infoPtr
->tools
[nTool
].rect
= lpti
->rect
;
1723 TOOLTIPS_NewToolRectW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1725 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1726 LPTTTOOLINFOW lpti
= (LPTTTOOLINFOW
)lParam
;
1731 if (lpti
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1734 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpti
);
1736 TRACE("nTool = %d, rect = %s\n", nTool
, wine_dbgstr_rect(&lpti
->rect
));
1738 if (nTool
== -1) return 0;
1740 infoPtr
->tools
[nTool
].rect
= lpti
->rect
;
1746 static inline LRESULT
1747 TOOLTIPS_Pop (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1749 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1750 TOOLTIPS_Hide (hwnd
, infoPtr
);
1757 TOOLTIPS_RelayEvent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1759 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1760 LPMSG lpMsg
= (LPMSG
)lParam
;
1765 ERR("lpMsg == NULL!\n");
1769 switch (lpMsg
->message
) {
1770 case WM_LBUTTONDOWN
:
1772 case WM_MBUTTONDOWN
:
1774 case WM_RBUTTONDOWN
:
1776 TOOLTIPS_Hide (hwnd
, infoPtr
);
1780 pt
.x
= (short)LOWORD(lpMsg
->lParam
);
1781 pt
.y
= (short)HIWORD(lpMsg
->lParam
);
1782 nOldTool
= infoPtr
->nTool
;
1783 infoPtr
->nTool
= TOOLTIPS_GetToolFromPoint(infoPtr
, lpMsg
->hwnd
,
1785 TRACE("tool (%p) %d %d %d\n", hwnd
, nOldTool
,
1786 infoPtr
->nTool
, infoPtr
->nCurrentTool
);
1787 TRACE("WM_MOUSEMOVE (%p %d %d)\n", hwnd
, pt
.x
, pt
.y
);
1789 if (infoPtr
->nTool
!= nOldTool
) {
1790 if(infoPtr
->nTool
== -1) { /* Moved out of all tools */
1791 TOOLTIPS_Hide(hwnd
, infoPtr
);
1792 KillTimer(hwnd
, ID_TIMERLEAVE
);
1793 } else if (nOldTool
== -1) { /* Moved from outside */
1794 if(infoPtr
->bActive
) {
1795 SetTimer(hwnd
, ID_TIMERSHOW
, infoPtr
->nInitialTime
, 0);
1796 TRACE("timer 1 started!\n");
1798 } else { /* Moved from one to another */
1799 TOOLTIPS_Hide (hwnd
, infoPtr
);
1800 KillTimer(hwnd
, ID_TIMERLEAVE
);
1801 if(infoPtr
->bActive
) {
1802 SetTimer (hwnd
, ID_TIMERSHOW
, infoPtr
->nReshowTime
, 0);
1803 TRACE("timer 1 started!\n");
1806 } else if(infoPtr
->nCurrentTool
!= -1) { /* restart autopop */
1807 KillTimer(hwnd
, ID_TIMERPOP
);
1808 SetTimer(hwnd
, ID_TIMERPOP
, infoPtr
->nAutoPopTime
, 0);
1809 TRACE("timer 2 restarted\n");
1810 } else if(infoPtr
->nTool
!= -1 && infoPtr
->bActive
) {
1811 /* previous show attempt didn't result in tooltip so try again */
1812 SetTimer(hwnd
, ID_TIMERSHOW
, infoPtr
->nInitialTime
, 0);
1813 TRACE("timer 1 started!\n");
1823 TOOLTIPS_SetDelayTime (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1825 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1826 INT nTime
= (INT
)LOWORD(lParam
);
1829 case TTDT_AUTOMATIC
:
1831 nTime
= GetDoubleClickTime();
1832 infoPtr
->nReshowTime
= nTime
/ 5;
1833 infoPtr
->nAutoPopTime
= nTime
* 10;
1834 infoPtr
->nInitialTime
= nTime
;
1839 nTime
= GetDoubleClickTime() / 5;
1840 infoPtr
->nReshowTime
= nTime
;
1845 nTime
= GetDoubleClickTime() * 10;
1846 infoPtr
->nAutoPopTime
= nTime
;
1851 nTime
= GetDoubleClickTime();
1852 infoPtr
->nInitialTime
= nTime
;
1856 WARN("Invalid wParam %lx\n", wParam
);
1865 TOOLTIPS_SetMargin (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1867 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1868 LPRECT lpRect
= (LPRECT
)lParam
;
1870 infoPtr
->rcMargin
.left
= lpRect
->left
;
1871 infoPtr
->rcMargin
.right
= lpRect
->right
;
1872 infoPtr
->rcMargin
.bottom
= lpRect
->bottom
;
1873 infoPtr
->rcMargin
.top
= lpRect
->top
;
1879 static inline LRESULT
1880 TOOLTIPS_SetMaxTipWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1882 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1883 INT nTemp
= infoPtr
->nMaxTipWidth
;
1885 infoPtr
->nMaxTipWidth
= (INT
)lParam
;
1891 static inline LRESULT
1892 TOOLTIPS_SetTipBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1894 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1896 infoPtr
->clrBk
= (COLORREF
)wParam
;
1902 static inline LRESULT
1903 TOOLTIPS_SetTipTextColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1905 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1907 infoPtr
->clrText
= (COLORREF
)wParam
;
1914 TOOLTIPS_SetTitleA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1916 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1917 LPCSTR pszTitle
= (LPCSTR
)lParam
;
1918 UINT_PTR uTitleIcon
= wParam
;
1921 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd
, debugstr_a(pszTitle
),
1924 Free(infoPtr
->pszTitle
);
1928 size
= sizeof(WCHAR
)*MultiByteToWideChar(CP_ACP
, 0, pszTitle
, -1, NULL
, 0);
1929 infoPtr
->pszTitle
= Alloc(size
);
1930 if (!infoPtr
->pszTitle
)
1932 MultiByteToWideChar(CP_ACP
, 0, pszTitle
, -1, infoPtr
->pszTitle
, size
/sizeof(WCHAR
));
1935 infoPtr
->pszTitle
= NULL
;
1937 if (uTitleIcon
<= TTI_ERROR
)
1938 infoPtr
->hTitleIcon
= hTooltipIcons
[uTitleIcon
];
1940 infoPtr
->hTitleIcon
= CopyIcon((HICON
)wParam
);
1947 TOOLTIPS_SetTitleW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1949 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1950 LPCWSTR pszTitle
= (LPCWSTR
)lParam
;
1951 UINT_PTR uTitleIcon
= wParam
;
1954 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd
, debugstr_w(pszTitle
),
1957 Free(infoPtr
->pszTitle
);
1961 size
= (strlenW(pszTitle
)+1)*sizeof(WCHAR
);
1962 infoPtr
->pszTitle
= Alloc(size
);
1963 if (!infoPtr
->pszTitle
)
1965 memcpy(infoPtr
->pszTitle
, pszTitle
, size
);
1968 infoPtr
->pszTitle
= NULL
;
1970 if (uTitleIcon
<= TTI_ERROR
)
1971 infoPtr
->hTitleIcon
= hTooltipIcons
[uTitleIcon
];
1973 infoPtr
->hTitleIcon
= CopyIcon((HICON
)wParam
);
1975 TRACE("icon = %p\n", infoPtr
->hTitleIcon
);
1982 TOOLTIPS_SetToolInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1984 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1985 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1986 TTTOOL_INFO
*toolPtr
;
1989 if (lpToolInfo
== NULL
)
1991 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1994 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1995 if (nTool
== -1) return 0;
1997 TRACE("tool %d\n", nTool
);
1999 toolPtr
= &infoPtr
->tools
[nTool
];
2001 /* copy tool data */
2002 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
2003 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
2004 toolPtr
->uId
= lpToolInfo
->uId
;
2005 toolPtr
->rect
= lpToolInfo
->rect
;
2006 toolPtr
->hinst
= lpToolInfo
->hinst
;
2008 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)) {
2009 TRACE("set string id %x\n", LOWORD(lpToolInfo
->lpszText
));
2010 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
2012 else if (lpToolInfo
->lpszText
) {
2013 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
)
2014 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2016 if ( (toolPtr
->lpszText
) &&
2017 !IS_INTRESOURCE(toolPtr
->lpszText
) ) {
2018 if( toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
)
2019 Free (toolPtr
->lpszText
);
2020 toolPtr
->lpszText
= NULL
;
2022 if (lpToolInfo
->lpszText
) {
2023 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
,
2025 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
2026 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
2027 toolPtr
->lpszText
, len
);
2032 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
2033 toolPtr
->lParam
= lpToolInfo
->lParam
;
2040 TOOLTIPS_SetToolInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2042 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2043 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
2044 TTTOOL_INFO
*toolPtr
;
2047 if (lpToolInfo
== NULL
)
2049 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
2052 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
2053 if (nTool
== -1) return 0;
2055 TRACE("tool %d\n", nTool
);
2057 toolPtr
= &infoPtr
->tools
[nTool
];
2059 /* copy tool data */
2060 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
2061 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
2062 toolPtr
->uId
= lpToolInfo
->uId
;
2063 toolPtr
->rect
= lpToolInfo
->rect
;
2064 toolPtr
->hinst
= lpToolInfo
->hinst
;
2066 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)) {
2067 TRACE("set string id %x!\n", LOWORD(lpToolInfo
->lpszText
));
2068 toolPtr
->lpszText
= lpToolInfo
->lpszText
;
2071 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
)
2072 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2074 if ( (toolPtr
->lpszText
) &&
2075 !IS_INTRESOURCE(toolPtr
->lpszText
) ) {
2076 if( toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
)
2077 Free (toolPtr
->lpszText
);
2078 toolPtr
->lpszText
= NULL
;
2080 if (lpToolInfo
->lpszText
) {
2081 INT len
= lstrlenW (lpToolInfo
->lpszText
);
2082 toolPtr
->lpszText
= Alloc ((len
+1)*sizeof(WCHAR
));
2083 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
2088 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
2089 toolPtr
->lParam
= lpToolInfo
->lParam
;
2091 if (infoPtr
->nCurrentTool
== nTool
)
2093 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nCurrentTool
);
2095 if (infoPtr
->szTipText
[0] == 0)
2096 TOOLTIPS_Hide(hwnd
, infoPtr
);
2098 TOOLTIPS_Show (hwnd
, infoPtr
, FALSE
);
2106 TOOLTIPS_TrackActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2108 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2111 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2113 if (lpToolInfo
== NULL
)
2115 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2119 infoPtr
->nTrackTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2120 if (infoPtr
->nTrackTool
!= -1) {
2121 TRACE("activated!\n");
2122 infoPtr
->bTrackActive
= TRUE
;
2123 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2128 TOOLTIPS_TrackHide (hwnd
, infoPtr
);
2130 infoPtr
->bTrackActive
= FALSE
;
2131 infoPtr
->nTrackTool
= -1;
2133 TRACE("deactivated!\n");
2141 TOOLTIPS_TrackPosition (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2143 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2145 infoPtr
->xTrackPos
= (INT
)LOWORD(lParam
);
2146 infoPtr
->yTrackPos
= (INT
)HIWORD(lParam
);
2148 if (infoPtr
->bTrackActive
) {
2150 infoPtr
->xTrackPos
, infoPtr
->yTrackPos
);
2152 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2160 TOOLTIPS_Update (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2162 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2164 if (infoPtr
->nCurrentTool
!= -1)
2165 UpdateWindow (hwnd
);
2172 TOOLTIPS_UpdateTipTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2174 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2175 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2176 TTTOOL_INFO
*toolPtr
;
2179 if (lpToolInfo
== NULL
)
2181 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2184 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2185 if (nTool
== -1) return 0;
2187 TRACE("tool %d\n", nTool
);
2189 toolPtr
= &infoPtr
->tools
[nTool
];
2191 /* copy tool text */
2192 toolPtr
->hinst
= lpToolInfo
->hinst
;
2194 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)){
2195 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
2197 else if (lpToolInfo
->lpszText
) {
2198 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
)
2199 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2201 if ( (toolPtr
->lpszText
) &&
2202 !IS_INTRESOURCE(toolPtr
->lpszText
) ) {
2203 if( toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
)
2204 Free (toolPtr
->lpszText
);
2205 toolPtr
->lpszText
= NULL
;
2207 if (lpToolInfo
->lpszText
) {
2208 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
,
2210 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
2211 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
2212 toolPtr
->lpszText
, len
);
2217 if(infoPtr
->nCurrentTool
== -1) return 0;
2219 if (infoPtr
->bActive
)
2220 TOOLTIPS_Show (hwnd
, infoPtr
, FALSE
);
2221 else if (infoPtr
->bTrackActive
)
2222 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2229 TOOLTIPS_UpdateTipTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2231 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2232 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
2233 TTTOOL_INFO
*toolPtr
;
2236 if (lpToolInfo
== NULL
)
2238 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
2241 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
2245 TRACE("tool %d\n", nTool
);
2247 toolPtr
= &infoPtr
->tools
[nTool
];
2249 /* copy tool text */
2250 toolPtr
->hinst
= lpToolInfo
->hinst
;
2252 if (IS_INTRESOURCE(lpToolInfo
->lpszText
)){
2253 toolPtr
->lpszText
= lpToolInfo
->lpszText
;
2255 else if (lpToolInfo
->lpszText
) {
2256 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
)
2257 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2259 if ( (toolPtr
->lpszText
) &&
2260 !IS_INTRESOURCE(toolPtr
->lpszText
) ) {
2261 if( toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
)
2262 Free (toolPtr
->lpszText
);
2263 toolPtr
->lpszText
= NULL
;
2265 if (lpToolInfo
->lpszText
) {
2266 INT len
= lstrlenW (lpToolInfo
->lpszText
);
2267 toolPtr
->lpszText
= Alloc ((len
+1)*sizeof(WCHAR
));
2268 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
2273 if(infoPtr
->nCurrentTool
== -1) return 0;
2275 if (infoPtr
->bActive
)
2276 TOOLTIPS_Show (hwnd
, infoPtr
, FALSE
);
2277 else if (infoPtr
->bTrackActive
)
2278 TOOLTIPS_Show (hwnd
, infoPtr
, TRUE
);
2285 TOOLTIPS_WindowFromPoint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2287 return (LRESULT
)WindowFromPoint (*((LPPOINT
)lParam
));
2293 TOOLTIPS_Create (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
2295 TOOLTIPS_INFO
*infoPtr
;
2297 /* allocate memory for info structure */
2298 infoPtr
= (TOOLTIPS_INFO
*)Alloc (sizeof(TOOLTIPS_INFO
));
2299 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
2301 /* initialize info structure */
2302 infoPtr
->bActive
= TRUE
;
2303 infoPtr
->bTrackActive
= FALSE
;
2305 infoPtr
->nMaxTipWidth
= -1;
2306 infoPtr
->nTool
= -1;
2307 infoPtr
->nCurrentTool
= -1;
2308 infoPtr
->nTrackTool
= -1;
2310 /* initialize colours and fonts */
2311 TOOLTIPS_InitSystemSettings(infoPtr
);
2313 TOOLTIPS_SetDelayTime(hwnd
, TTDT_AUTOMATIC
, 0L);
2315 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
2322 TOOLTIPS_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2324 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2325 TTTOOL_INFO
*toolPtr
;
2329 if (infoPtr
->tools
) {
2330 for (i
= 0; i
< infoPtr
->uNumTools
; i
++) {
2331 toolPtr
= &infoPtr
->tools
[i
];
2332 if (toolPtr
->lpszText
) {
2333 if ( (toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
) &&
2334 !IS_INTRESOURCE(toolPtr
->lpszText
) )
2336 Free (toolPtr
->lpszText
);
2337 toolPtr
->lpszText
= NULL
;
2341 /* remove subclassing */
2342 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
2343 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
2344 RemoveWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1);
2347 RemoveWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1);
2351 Free (infoPtr
->tools
);
2354 /* free title string */
2355 Free (infoPtr
->pszTitle
);
2356 /* free title icon if not a standard one */
2357 if (TOOLTIPS_GetTitleIconIndex(infoPtr
->hTitleIcon
) > TTI_ERROR
)
2358 DeleteObject(infoPtr
->hTitleIcon
);
2361 DeleteObject (infoPtr
->hFont
);
2362 DeleteObject (infoPtr
->hTitleFont
);
2364 /* free tool tips info data */
2366 SetWindowLongPtrW(hwnd
, 0, 0);
2372 TOOLTIPS_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2374 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2376 return (LRESULT
)infoPtr
->hFont
;
2381 TOOLTIPS_MouseMessage (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2383 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2385 TOOLTIPS_Hide (hwnd
, infoPtr
);
2392 TOOLTIPS_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2394 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
2395 DWORD dwExStyle
= GetWindowLongW (hwnd
, GWL_EXSTYLE
);
2397 dwStyle
&= ~(WS_CHILD
| /*WS_MAXIMIZE |*/ WS_BORDER
| WS_DLGFRAME
);
2398 dwStyle
|= (WS_POPUP
| WS_BORDER
| WS_CLIPSIBLINGS
);
2400 /* WS_BORDER only draws a border round the window rect, not the
2401 * window region, therefore it is useless to us in balloon mode */
2402 if (dwStyle
& TTS_BALLOON
) dwStyle
&= ~WS_BORDER
;
2404 SetWindowLongW (hwnd
, GWL_STYLE
, dwStyle
);
2406 dwExStyle
|= WS_EX_TOOLWINDOW
;
2407 SetWindowLongW (hwnd
, GWL_EXSTYLE
, dwExStyle
);
2414 TOOLTIPS_NCHitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2416 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2417 INT nTool
= (infoPtr
->bTrackActive
) ? infoPtr
->nTrackTool
: infoPtr
->nTool
;
2419 TRACE(" nTool=%d\n", nTool
);
2421 if ((nTool
> -1) && (nTool
< infoPtr
->uNumTools
)) {
2422 if (infoPtr
->tools
[nTool
].uFlags
& TTF_TRANSPARENT
) {
2423 TRACE("-- in transparent mode!\n");
2424 return HTTRANSPARENT
;
2428 return DefWindowProcW (hwnd
, WM_NCHITTEST
, wParam
, lParam
);
2433 TOOLTIPS_NotifyFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2435 FIXME ("hwnd=%p wParam=%lx lParam=%lx\n", hwnd
, wParam
, lParam
);
2442 TOOLTIPS_Paint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2447 hdc
= (wParam
== 0) ? BeginPaint (hwnd
, &ps
) : (HDC
)wParam
;
2448 TOOLTIPS_Refresh (hwnd
, hdc
);
2450 EndPaint (hwnd
, &ps
);
2456 TOOLTIPS_SetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2458 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2461 if(!GetObjectW((HFONT
)wParam
, sizeof(lf
), &lf
))
2464 DeleteObject (infoPtr
->hFont
);
2465 infoPtr
->hFont
= CreateFontIndirectW(&lf
);
2467 DeleteObject (infoPtr
->hTitleFont
);
2468 lf
.lfWeight
= FW_BOLD
;
2469 infoPtr
->hTitleFont
= CreateFontIndirectW(&lf
);
2471 if ((LOWORD(lParam
)) & (infoPtr
->nCurrentTool
!= -1)) {
2472 FIXME("full redraw needed!\n");
2478 /******************************************************************
2479 * TOOLTIPS_GetTextLength
2481 * This function is called when the tooltip receive a
2482 * WM_GETTEXTLENGTH message.
2486 * returns the length, in characters, of the tip text
2489 TOOLTIPS_GetTextLength(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2491 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2492 return strlenW(infoPtr
->szTipText
);
2495 /******************************************************************
2496 * TOOLTIPS_OnWMGetText
2498 * This function is called when the tooltip receive a
2499 * WM_GETTEXT message.
2500 * wParam : specifies the maximum number of characters to be copied
2501 * lParam : is the pointer to the buffer that will receive
2504 * returns the number of characters copied
2507 TOOLTIPS_OnWMGetText (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2509 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2511 LPWSTR pszText
= (LPWSTR
)lParam
;
2513 if(!infoPtr
->szTipText
|| !wParam
)
2516 res
= min(strlenW(infoPtr
->szTipText
)+1, wParam
);
2517 memcpy(pszText
, infoPtr
->szTipText
, res
*sizeof(WCHAR
));
2518 pszText
[res
-1] = '\0';
2523 TOOLTIPS_Timer (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2525 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2528 TRACE("timer %ld (%p) expired!\n", wParam
, hwnd
);
2532 KillTimer (hwnd
, ID_TIMERSHOW
);
2533 nOldTool
= infoPtr
->nTool
;
2534 if ((infoPtr
->nTool
= TOOLTIPS_CheckTool (hwnd
, TRUE
)) == nOldTool
)
2535 TOOLTIPS_Show (hwnd
, infoPtr
, FALSE
);
2539 TOOLTIPS_Hide (hwnd
, infoPtr
);
2543 nOldTool
= infoPtr
->nTool
;
2544 infoPtr
->nTool
= TOOLTIPS_CheckTool (hwnd
, FALSE
);
2545 TRACE("tool (%p) %d %d %d\n", hwnd
, nOldTool
,
2546 infoPtr
->nTool
, infoPtr
->nCurrentTool
);
2547 if (infoPtr
->nTool
!= nOldTool
) {
2548 if(infoPtr
->nTool
== -1) { /* Moved out of all tools */
2549 TOOLTIPS_Hide(hwnd
, infoPtr
);
2550 KillTimer(hwnd
, ID_TIMERLEAVE
);
2551 } else if (nOldTool
== -1) { /* Moved from outside */
2552 ERR("How did this happen?\n");
2553 } else { /* Moved from one to another */
2554 TOOLTIPS_Hide (hwnd
, infoPtr
);
2555 KillTimer(hwnd
, ID_TIMERLEAVE
);
2556 if(infoPtr
->bActive
) {
2557 SetTimer (hwnd
, ID_TIMERSHOW
, infoPtr
->nReshowTime
, 0);
2558 TRACE("timer 1 started!\n");
2565 ERR("Unknown timer id %ld\n", wParam
);
2573 TOOLTIPS_WinIniChange (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2575 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2577 TOOLTIPS_InitSystemSettings (infoPtr
);
2583 static LRESULT CALLBACK
2584 TOOLTIPS_SubclassProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
2590 case WM_LBUTTONDOWN
:
2592 case WM_MBUTTONDOWN
:
2594 case WM_RBUTTONDOWN
:
2598 msg
.wParam
= wParam
;
2599 msg
.lParam
= lParam
;
2600 TOOLTIPS_RelayEvent((HWND
)dwRef
, 0, (LPARAM
)&msg
);
2606 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
2610 static LRESULT CALLBACK
2611 TOOLTIPS_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2613 TRACE("hwnd=%p msg=%x wparam=%lx lParam=%lx\n", hwnd
, uMsg
, wParam
, lParam
);
2614 if (!TOOLTIPS_GetInfoPtr(hwnd
) && (uMsg
!= WM_CREATE
) && (uMsg
!= WM_NCCREATE
))
2615 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2619 return TOOLTIPS_Activate (hwnd
, wParam
, lParam
);
2622 return TOOLTIPS_AddToolA (hwnd
, wParam
, lParam
);
2625 return TOOLTIPS_AddToolW (hwnd
, wParam
, lParam
);
2628 return TOOLTIPS_DelToolA (hwnd
, wParam
, lParam
);
2631 return TOOLTIPS_DelToolW (hwnd
, wParam
, lParam
);
2633 case TTM_ENUMTOOLSA
:
2634 return TOOLTIPS_EnumToolsA (hwnd
, wParam
, lParam
);
2636 case TTM_ENUMTOOLSW
:
2637 return TOOLTIPS_EnumToolsW (hwnd
, wParam
, lParam
);
2639 case TTM_GETBUBBLESIZE
:
2640 return TOOLTIPS_GetBubbleSize (hwnd
, wParam
, lParam
);
2642 case TTM_GETCURRENTTOOLA
:
2643 return TOOLTIPS_GetCurrentToolA (hwnd
, wParam
, lParam
);
2645 case TTM_GETCURRENTTOOLW
:
2646 return TOOLTIPS_GetCurrentToolW (hwnd
, wParam
, lParam
);
2648 case TTM_GETDELAYTIME
:
2649 return TOOLTIPS_GetDelayTime (hwnd
, wParam
, lParam
);
2652 return TOOLTIPS_GetMargin (hwnd
, wParam
, lParam
);
2654 case TTM_GETMAXTIPWIDTH
:
2655 return TOOLTIPS_GetMaxTipWidth (hwnd
, wParam
, lParam
);
2658 return TOOLTIPS_GetTextA (hwnd
, wParam
, lParam
);
2661 return TOOLTIPS_GetTextW (hwnd
, wParam
, lParam
);
2663 case TTM_GETTIPBKCOLOR
:
2664 return TOOLTIPS_GetTipBkColor (hwnd
, wParam
, lParam
);
2666 case TTM_GETTIPTEXTCOLOR
:
2667 return TOOLTIPS_GetTipTextColor (hwnd
, wParam
, lParam
);
2669 case TTM_GETTOOLCOUNT
:
2670 return TOOLTIPS_GetToolCount (hwnd
, wParam
, lParam
);
2672 case TTM_GETTOOLINFOA
:
2673 return TOOLTIPS_GetToolInfoA (hwnd
, wParam
, lParam
);
2675 case TTM_GETTOOLINFOW
:
2676 return TOOLTIPS_GetToolInfoW (hwnd
, wParam
, lParam
);
2679 return TOOLTIPS_HitTestA (hwnd
, wParam
, lParam
);
2682 return TOOLTIPS_HitTestW (hwnd
, wParam
, lParam
);
2684 case TTM_NEWTOOLRECTA
:
2685 return TOOLTIPS_NewToolRectA (hwnd
, wParam
, lParam
);
2687 case TTM_NEWTOOLRECTW
:
2688 return TOOLTIPS_NewToolRectW (hwnd
, wParam
, lParam
);
2691 return TOOLTIPS_Pop (hwnd
, wParam
, lParam
);
2693 case TTM_RELAYEVENT
:
2694 return TOOLTIPS_RelayEvent (hwnd
, wParam
, lParam
);
2696 case TTM_SETDELAYTIME
:
2697 return TOOLTIPS_SetDelayTime (hwnd
, wParam
, lParam
);
2700 return TOOLTIPS_SetMargin (hwnd
, wParam
, lParam
);
2702 case TTM_SETMAXTIPWIDTH
:
2703 return TOOLTIPS_SetMaxTipWidth (hwnd
, wParam
, lParam
);
2705 case TTM_SETTIPBKCOLOR
:
2706 return TOOLTIPS_SetTipBkColor (hwnd
, wParam
, lParam
);
2708 case TTM_SETTIPTEXTCOLOR
:
2709 return TOOLTIPS_SetTipTextColor (hwnd
, wParam
, lParam
);
2712 return TOOLTIPS_SetTitleA (hwnd
, wParam
, lParam
);
2715 return TOOLTIPS_SetTitleW (hwnd
, wParam
, lParam
);
2717 case TTM_SETTOOLINFOA
:
2718 return TOOLTIPS_SetToolInfoA (hwnd
, wParam
, lParam
);
2720 case TTM_SETTOOLINFOW
:
2721 return TOOLTIPS_SetToolInfoW (hwnd
, wParam
, lParam
);
2723 case TTM_TRACKACTIVATE
:
2724 return TOOLTIPS_TrackActivate (hwnd
, wParam
, lParam
);
2726 case TTM_TRACKPOSITION
:
2727 return TOOLTIPS_TrackPosition (hwnd
, wParam
, lParam
);
2730 return TOOLTIPS_Update (hwnd
, wParam
, lParam
);
2732 case TTM_UPDATETIPTEXTA
:
2733 return TOOLTIPS_UpdateTipTextA (hwnd
, wParam
, lParam
);
2735 case TTM_UPDATETIPTEXTW
:
2736 return TOOLTIPS_UpdateTipTextW (hwnd
, wParam
, lParam
);
2738 case TTM_WINDOWFROMPOINT
:
2739 return TOOLTIPS_WindowFromPoint (hwnd
, wParam
, lParam
);
2743 return TOOLTIPS_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
2746 return TOOLTIPS_Destroy (hwnd
, wParam
, lParam
);
2749 /* we draw the background in WM_PAINT */
2753 return TOOLTIPS_GetFont (hwnd
, wParam
, lParam
);
2756 return TOOLTIPS_OnWMGetText (hwnd
, wParam
, lParam
);
2758 case WM_GETTEXTLENGTH
:
2759 return TOOLTIPS_GetTextLength (hwnd
, wParam
, lParam
);
2761 case WM_LBUTTONDOWN
:
2763 case WM_MBUTTONDOWN
:
2765 case WM_RBUTTONDOWN
:
2768 return TOOLTIPS_MouseMessage (hwnd
, uMsg
, wParam
, lParam
);
2771 return TOOLTIPS_NCCreate (hwnd
, wParam
, lParam
);
2774 return TOOLTIPS_NCHitTest (hwnd
, wParam
, lParam
);
2776 case WM_NOTIFYFORMAT
:
2777 return TOOLTIPS_NotifyFormat (hwnd
, wParam
, lParam
);
2779 case WM_PRINTCLIENT
:
2781 return TOOLTIPS_Paint (hwnd
, wParam
, lParam
);
2784 return TOOLTIPS_SetFont (hwnd
, wParam
, lParam
);
2787 return TOOLTIPS_Timer (hwnd
, wParam
, lParam
);
2789 case WM_WININICHANGE
:
2790 return TOOLTIPS_WinIniChange (hwnd
, wParam
, lParam
);
2793 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
2794 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
2795 uMsg
, wParam
, lParam
);
2796 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2802 TOOLTIPS_Register (void)
2806 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
2807 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
| CS_SAVEBITS
;
2808 wndClass
.lpfnWndProc
= TOOLTIPS_WindowProc
;
2809 wndClass
.cbClsExtra
= 0;
2810 wndClass
.cbWndExtra
= sizeof(TOOLTIPS_INFO
*);
2811 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
2812 wndClass
.hbrBackground
= 0;
2813 wndClass
.lpszClassName
= TOOLTIPS_CLASSW
;
2815 RegisterClassW (&wndClass
);
2817 hTooltipIcons
[TTI_NONE
] = NULL
;
2818 hTooltipIcons
[TTI_INFO
] = LoadImageW(COMCTL32_hModule
,
2819 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_INFO_SM
), IMAGE_ICON
, 0, 0, 0);
2820 hTooltipIcons
[TTI_WARNING
] = LoadImageW(COMCTL32_hModule
,
2821 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_WARN_SM
), IMAGE_ICON
, 0, 0, 0);
2822 hTooltipIcons
[TTI_ERROR
] = LoadImageW(COMCTL32_hModule
,
2823 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_ERROR_SM
), IMAGE_ICON
, 0, 0, 0);
2828 TOOLTIPS_Unregister (void)
2831 for (i
= TTI_INFO
; i
<= TTI_ERROR
; i
++)
2832 DestroyIcon(hTooltipIcons
[i
]);
2833 UnregisterClassW (TOOLTIPS_CLASSW
, NULL
);