4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 2004 Robert Shearman
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * This code was audited for completeness against the documented features
22 * of Comctl32.dll version 6.0 on Sep. 08, 2004, by Robert Shearman.
24 * Unless otherwise noted, we believe this code to be complete, as per
25 * the specification mentioned above.
26 * If you discover missing features or bugs please note them below.
29 * - Custom draw support.
43 * - Run tests using Waite Group Windows95 API Bible Volume 2.
44 * The second cdrom (chapter 3) contains executables activate.exe,
45 * curtool.exe, deltool.exe, enumtools.exe, getinfo.exe, getiptxt.exe,
46 * hittest.exe, needtext.exe, newrect.exe, updtext.exe and winfrpt.exe.
50 * One important point to remember is that tools don't necessarily get
51 * a WM_MOUSEMOVE once the cursor leaves the tool, an example is when
52 * a tool sets TTF_IDISHWND (i.e. an entire window is a tool) because
53 * here WM_MOUSEMOVEs only get sent when the cursor is inside the
54 * client area. Therefore the only reliable way to know that the
55 * cursor has left a tool is to keep a timer running and check the
56 * position every time it expires. This is the role of timer
60 * On entering a tool (detected in a relayed WM_MOUSEMOVE) we start
61 * ID_TIMERSHOW, if this times out and we're still in the tool we show
62 * the tip. On showing a tip we start both ID_TIMERPOP and
63 * ID_TIMERLEAVE. On hiding a tooltip we kill ID_TIMERPOP.
64 * ID_TIMERPOP is restarted on every relayed WM_MOUSEMOVE. If
65 * ID_TIMERPOP expires the tool is hidden and ID_TIMERPOP is killed.
66 * ID_TIMERLEAVE remains running - this is important as we need to
67 * determine when the cursor leaves the tool.
69 * When ID_TIMERLEAVE expires or on a relayed WM_MOUSEMOVE if we're
70 * still in the tool do nothing (apart from restart ID_TIMERPOP if
71 * this is a WM_MOUSEMOVE) (ID_TIMERLEAVE remains running). If we've
72 * left the tool and entered another one then hide the tip and start
73 * ID_TIMERSHOW with time ReshowTime and kill ID_TIMERLEAVE. If we're
74 * outside all tools hide the tip and kill ID_TIMERLEAVE. On Relayed
75 * mouse button messages hide the tip but leave ID_TIMERLEAVE running,
76 * this again will let us keep track of when the cursor leaves the
80 * infoPtr->nTool is the tool the mouse was on on the last relayed MM
81 * or timer expiry or -1 if the mouse was not on a tool.
83 * infoPtr->nCurrentTool is the tool for which the tip is currently
84 * displaying text for or -1 if the tip is not shown. Actually this
85 * will only ever be infoPtr-nTool or -1, so it could be changed to a
97 #include "wine/unicode.h"
101 #include "commctrl.h"
102 #include "comctl32.h"
103 #include "wine/debug.h"
105 WINE_DEFAULT_DEBUG_CHANNEL(tooltips
);
107 static HICON hTooltipIcons
[TTI_ERROR
+1];
124 WCHAR szTipText
[INFOTIPSIZE
];
135 INT nTool
; /* tool that mouse was on on last relayed mouse move */
149 #define ID_TIMERSHOW 1 /* show delay timer */
150 #define ID_TIMERPOP 2 /* auto pop timer */
151 #define ID_TIMERLEAVE 3 /* tool leave timer */
154 #define TOOLTIPS_GetInfoPtr(hWindow) ((TOOLTIPS_INFO *)GetWindowLongPtrW (hWindow, 0))
156 /* offsets from window edge to start of text */
157 #define NORMAL_TEXT_MARGIN 2
158 #define BALLOON_TEXT_MARGIN (NORMAL_TEXT_MARGIN+8)
159 /* value used for CreateRoundRectRgn that specifies how much
160 * each corner is curved */
161 #define BALLOON_ROUNDEDNESS 20
162 #define BALLOON_STEMHEIGHT 13
163 #define BALLOON_STEMWIDTH 10
164 #define BALLOON_STEMINDENT 20
166 #define BALLOON_ICON_TITLE_SPACING 8 /* horizontal spacing between icon and title */
167 #define BALLOON_TITLE_TEXT_SPACING 8 /* vertical spacing between icon/title and main text */
168 #define ICON_HEIGHT 16
169 #define ICON_WIDTH 16
171 static LRESULT CALLBACK
172 TOOLTIPS_SubclassProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uId
, DWORD_PTR dwRef
);
175 inline static UINT_PTR
176 TOOLTIPS_GetTitleIconIndex(HICON hIcon
)
179 for (i
= 0; i
<= TTI_ERROR
; i
++)
180 if (hTooltipIcons
[i
] == hIcon
)
182 return (UINT_PTR
)hIcon
;
186 TOOLTIPS_InitSystemSettings (TOOLTIPS_INFO
*infoPtr
)
188 NONCLIENTMETRICSW nclm
;
190 infoPtr
->clrBk
= GetSysColor (COLOR_INFOBK
);
191 infoPtr
->clrText
= GetSysColor (COLOR_INFOTEXT
);
193 DeleteObject (infoPtr
->hFont
);
194 nclm
.cbSize
= sizeof(nclm
);
195 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, sizeof(nclm
), &nclm
, 0);
196 infoPtr
->hFont
= CreateFontIndirectW (&nclm
.lfStatusFont
);
198 DeleteObject (infoPtr
->hTitleFont
);
199 nclm
.lfStatusFont
.lfWeight
= FW_BOLD
;
200 infoPtr
->hTitleFont
= CreateFontIndirectW (&nclm
.lfStatusFont
);
204 TOOLTIPS_Refresh (HWND hwnd
, HDC hdc
)
206 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr(hwnd
);
211 UINT uFlags
= DT_EXTERNALLEADING
;
213 DWORD dwStyle
= GetWindowLongW(hwnd
, GWL_STYLE
);
215 if (infoPtr
->nMaxTipWidth
> -1)
216 uFlags
|= DT_WORDBREAK
;
217 if (GetWindowLongA (hwnd
, GWL_STYLE
) & TTS_NOPREFIX
)
218 uFlags
|= DT_NOPREFIX
;
219 GetClientRect (hwnd
, &rc
);
221 hBrush
= CreateSolidBrush(infoPtr
->clrBk
);
223 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
224 SetTextColor (hdc
, infoPtr
->clrText
);
226 if (dwStyle
& TTS_BALLOON
)
228 /* create a region to store result into */
229 hRgn
= CreateRectRgn(0, 0, 0, 0);
231 GetWindowRgn(hwnd
, hRgn
);
233 /* fill the background */
234 FillRgn(hdc
, hRgn
, hBrush
);
235 DeleteObject(hBrush
);
240 /* fill the background */
241 FillRect(hdc
, &rc
, hBrush
);
242 DeleteObject(hBrush
);
246 if ((dwStyle
& TTS_BALLOON
) || infoPtr
->pszTitle
)
248 /* calculate text rectangle */
249 rc
.left
+= (BALLOON_TEXT_MARGIN
+ infoPtr
->rcMargin
.left
);
250 rc
.top
+= (BALLOON_TEXT_MARGIN
+ infoPtr
->rcMargin
.top
);
251 rc
.right
-= (BALLOON_TEXT_MARGIN
+ infoPtr
->rcMargin
.right
);
252 rc
.bottom
-= (BALLOON_TEXT_MARGIN
+ infoPtr
->rcMargin
.bottom
);
253 if(infoPtr
->bToolBelow
) rc
.top
+= BALLOON_STEMHEIGHT
;
255 if (infoPtr
->pszTitle
)
257 RECT rcTitle
= {rc
.left
, rc
.top
, rc
.right
, rc
.bottom
};
262 icon_present
= infoPtr
->hTitleIcon
&&
263 DrawIconEx(hdc
, rc
.left
, rc
.top
, infoPtr
->hTitleIcon
,
264 ICON_WIDTH
, ICON_HEIGHT
, 0, NULL
, DI_NORMAL
);
266 rcTitle
.left
+= ICON_WIDTH
+ BALLOON_ICON_TITLE_SPACING
;
268 rcTitle
.bottom
= rc
.top
+ ICON_HEIGHT
;
270 /* draw title text */
271 hOldFont
= SelectObject (hdc
, infoPtr
->hTitleFont
);
272 height
= DrawTextW(hdc
, infoPtr
->pszTitle
, -1, &rcTitle
, DT_BOTTOM
| DT_SINGLELINE
| DT_NOPREFIX
);
273 SelectObject (hdc
, hOldFont
);
274 rc
.top
+= height
+ BALLOON_TITLE_TEXT_SPACING
;
279 /* calculate text rectangle */
280 rc
.left
+= (NORMAL_TEXT_MARGIN
+ infoPtr
->rcMargin
.left
);
281 rc
.top
+= (NORMAL_TEXT_MARGIN
+ infoPtr
->rcMargin
.top
);
282 rc
.right
-= (NORMAL_TEXT_MARGIN
+ infoPtr
->rcMargin
.right
);
283 rc
.bottom
-= (NORMAL_TEXT_MARGIN
+ infoPtr
->rcMargin
.bottom
);
287 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
288 DrawTextW (hdc
, infoPtr
->szTipText
, -1, &rc
, uFlags
);
289 /* be polite and reset the things we changed in the dc */
290 SelectObject (hdc
, hOldFont
);
291 SetBkMode (hdc
, oldBkMode
);
293 if (dwStyle
& TTS_BALLOON
)
295 /* frame region because default window proc doesn't do it */
296 INT width
= GetSystemMetrics(SM_CXDLGFRAME
) - GetSystemMetrics(SM_CXEDGE
);
297 INT height
= GetSystemMetrics(SM_CYDLGFRAME
) - GetSystemMetrics(SM_CYEDGE
);
299 hBrush
= GetSysColorBrush(COLOR_WINDOWFRAME
);
300 FrameRgn(hdc
, hRgn
, hBrush
, width
, height
);
307 static void TOOLTIPS_GetDispInfoA(HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, TTTOOL_INFO
*toolPtr
)
309 NMTTDISPINFOA ttnmdi
;
311 /* fill NMHDR struct */
312 ZeroMemory (&ttnmdi
, sizeof(NMTTDISPINFOA
));
313 ttnmdi
.hdr
.hwndFrom
= hwnd
;
314 ttnmdi
.hdr
.idFrom
= toolPtr
->uId
;
315 ttnmdi
.hdr
.code
= TTN_GETDISPINFOA
;
316 ttnmdi
.lpszText
= (LPSTR
)&ttnmdi
.szText
;
317 ttnmdi
.uFlags
= toolPtr
->uFlags
;
318 ttnmdi
.lParam
= toolPtr
->lParam
;
320 TRACE("hdr.idFrom = %x\n", ttnmdi
.hdr
.idFrom
);
321 SendMessageW(toolPtr
->hwnd
, WM_NOTIFY
,
322 (WPARAM
)toolPtr
->uId
, (LPARAM
)&ttnmdi
);
324 if (HIWORD((UINT
)ttnmdi
.lpszText
) == 0) {
325 LoadStringW(ttnmdi
.hinst
, (UINT
)ttnmdi
.lpszText
,
326 infoPtr
->szTipText
, INFOTIPSIZE
);
327 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
328 toolPtr
->hinst
= ttnmdi
.hinst
;
329 toolPtr
->lpszText
= (LPWSTR
)ttnmdi
.lpszText
;
332 else if (ttnmdi
.lpszText
== 0) {
333 /* no text available */
334 infoPtr
->szTipText
[0] = '\0';
336 else if (ttnmdi
.lpszText
!= LPSTR_TEXTCALLBACKA
) {
337 INT max_len
= (ttnmdi
.lpszText
== &ttnmdi
.szText
[0]) ?
338 sizeof(ttnmdi
.szText
)/sizeof(ttnmdi
.szText
[0]) : -1;
339 MultiByteToWideChar(CP_ACP
, 0, ttnmdi
.lpszText
, max_len
,
340 infoPtr
->szTipText
, INFOTIPSIZE
);
341 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
342 INT len
= MultiByteToWideChar(CP_ACP
, 0, ttnmdi
.lpszText
,
345 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
346 MultiByteToWideChar(CP_ACP
, 0, ttnmdi
.lpszText
, -1,
347 toolPtr
->lpszText
, len
);
351 ERR("recursive text callback!\n");
352 infoPtr
->szTipText
[0] = '\0';
356 static void TOOLTIPS_GetDispInfoW(HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, TTTOOL_INFO
*toolPtr
)
358 NMTTDISPINFOW ttnmdi
;
360 /* fill NMHDR struct */
361 ZeroMemory (&ttnmdi
, sizeof(NMTTDISPINFOW
));
362 ttnmdi
.hdr
.hwndFrom
= hwnd
;
363 ttnmdi
.hdr
.idFrom
= toolPtr
->uId
;
364 ttnmdi
.hdr
.code
= TTN_GETDISPINFOW
;
365 ttnmdi
.lpszText
= (LPWSTR
)&ttnmdi
.szText
;
366 ttnmdi
.uFlags
= toolPtr
->uFlags
;
367 ttnmdi
.lParam
= toolPtr
->lParam
;
369 TRACE("hdr.idFrom = %x\n", ttnmdi
.hdr
.idFrom
);
370 SendMessageW(toolPtr
->hwnd
, WM_NOTIFY
,
371 (WPARAM
)toolPtr
->uId
, (LPARAM
)&ttnmdi
);
373 if (HIWORD((UINT
)ttnmdi
.lpszText
) == 0) {
374 LoadStringW(ttnmdi
.hinst
, (UINT
)ttnmdi
.lpszText
,
375 infoPtr
->szTipText
, INFOTIPSIZE
);
376 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
377 toolPtr
->hinst
= ttnmdi
.hinst
;
378 toolPtr
->lpszText
= ttnmdi
.lpszText
;
381 else if (ttnmdi
.lpszText
== 0) {
382 /* no text available */
383 infoPtr
->szTipText
[0] = '\0';
385 else if (ttnmdi
.lpszText
!= LPSTR_TEXTCALLBACKW
) {
386 INT max_len
= (ttnmdi
.lpszText
== &ttnmdi
.szText
[0]) ?
387 sizeof(ttnmdi
.szText
)/sizeof(ttnmdi
.szText
[0]) : INFOTIPSIZE
-1;
388 strncpyW(infoPtr
->szTipText
, ttnmdi
.lpszText
, max_len
);
389 if (ttnmdi
.uFlags
& TTF_DI_SETITEM
) {
390 INT len
= max(strlenW(ttnmdi
.lpszText
), max_len
);
392 toolPtr
->lpszText
= Alloc ((len
+1) * sizeof(WCHAR
));
393 memcpy(toolPtr
->lpszText
, ttnmdi
.lpszText
, (len
+1) * sizeof(WCHAR
));
397 ERR("recursive text callback!\n");
398 infoPtr
->szTipText
[0] = '\0';
403 TOOLTIPS_GetTipText (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, INT nTool
)
405 TTTOOL_INFO
*toolPtr
= &infoPtr
->tools
[nTool
];
407 if (HIWORD((UINT
)toolPtr
->lpszText
) == 0 && toolPtr
->hinst
) {
408 /* load a resource */
409 TRACE("load res string %p %x\n",
410 toolPtr
->hinst
, (int)toolPtr
->lpszText
);
411 LoadStringW (toolPtr
->hinst
, (UINT
)toolPtr
->lpszText
,
412 infoPtr
->szTipText
, INFOTIPSIZE
);
414 else if (toolPtr
->lpszText
) {
415 if (toolPtr
->lpszText
== LPSTR_TEXTCALLBACKW
) {
416 if (toolPtr
->bNotifyUnicode
)
417 TOOLTIPS_GetDispInfoW(hwnd
, infoPtr
, toolPtr
);
419 TOOLTIPS_GetDispInfoA(hwnd
, infoPtr
, toolPtr
);
422 /* the item is a usual (unicode) text */
423 lstrcpynW (infoPtr
->szTipText
, toolPtr
->lpszText
, INFOTIPSIZE
);
427 /* no text available */
428 infoPtr
->szTipText
[0] = L
'\0';
431 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
436 TOOLTIPS_CalcTipSize (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, LPSIZE lpSize
)
440 DWORD style
= GetWindowLongW(hwnd
, GWL_STYLE
);
441 UINT uFlags
= DT_EXTERNALLEADING
| DT_CALCRECT
;
442 RECT rc
= {0, 0, 0, 0};
445 if (infoPtr
->nMaxTipWidth
> -1) {
446 rc
.right
= infoPtr
->nMaxTipWidth
;
447 uFlags
|= DT_WORDBREAK
;
449 if (style
& TTS_NOPREFIX
)
450 uFlags
|= DT_NOPREFIX
;
451 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
454 if (infoPtr
->pszTitle
)
456 RECT rcTitle
= {0, 0, 0, 0};
457 TRACE("title %s\n", debugstr_w(infoPtr
->pszTitle
));
458 if (infoPtr
->hTitleIcon
)
460 title
.cx
= ICON_WIDTH
;
461 title
.cy
= ICON_HEIGHT
;
463 if (title
.cx
!= 0) title
.cx
+= BALLOON_ICON_TITLE_SPACING
;
464 hOldFont
= SelectObject (hdc
, infoPtr
->hTitleFont
);
465 DrawTextW(hdc
, infoPtr
->pszTitle
, -1, &rcTitle
, DT_SINGLELINE
| DT_NOPREFIX
| DT_CALCRECT
);
466 SelectObject (hdc
, hOldFont
);
467 title
.cy
= max(title
.cy
, rcTitle
.bottom
- rcTitle
.top
) + BALLOON_TITLE_TEXT_SPACING
;
468 title
.cx
+= (rcTitle
.right
- rcTitle
.left
);
470 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
471 DrawTextW (hdc
, infoPtr
->szTipText
, -1, &rc
, uFlags
);
472 SelectObject (hdc
, hOldFont
);
473 ReleaseDC (hwnd
, hdc
);
475 if ((style
& TTS_BALLOON
) || infoPtr
->pszTitle
)
477 lpSize
->cx
= max(rc
.right
- rc
.left
, title
.cx
) + 2*BALLOON_TEXT_MARGIN
+
478 infoPtr
->rcMargin
.left
+ infoPtr
->rcMargin
.right
;
479 lpSize
->cy
= title
.cy
+ rc
.bottom
- rc
.top
+ 2*BALLOON_TEXT_MARGIN
+
480 infoPtr
->rcMargin
.bottom
+ infoPtr
->rcMargin
.top
+
485 lpSize
->cx
= rc
.right
- rc
.left
+ 2*NORMAL_TEXT_MARGIN
+
486 infoPtr
->rcMargin
.left
+ infoPtr
->rcMargin
.right
;
487 lpSize
->cy
= rc
.bottom
- rc
.top
+ 2*NORMAL_TEXT_MARGIN
+
488 infoPtr
->rcMargin
.bottom
+ infoPtr
->rcMargin
.top
;
494 TOOLTIPS_Show (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
496 TTTOOL_INFO
*toolPtr
;
501 DWORD style
= GetWindowLongW(hwnd
, GWL_STYLE
);
503 if (infoPtr
->nTool
== -1) {
504 TRACE("invalid tool (-1)!\n");
508 infoPtr
->nCurrentTool
= infoPtr
->nTool
;
510 TRACE("Show tooltip pre %d! (%p)\n", infoPtr
->nTool
, hwnd
);
512 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nCurrentTool
);
514 if (infoPtr
->szTipText
[0] == L
'\0') {
515 infoPtr
->nCurrentTool
= -1;
519 TRACE("Show tooltip %d!\n", infoPtr
->nCurrentTool
);
520 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
523 hdr
.idFrom
= toolPtr
->uId
;
525 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
526 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
528 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
530 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
531 TRACE("size %ld x %ld\n", size
.cx
, size
.cy
);
533 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
536 if (toolPtr
->uFlags
& TTF_IDISHWND
)
537 GetWindowRect ((HWND
)toolPtr
->uId
, &rc
);
540 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rc
, 2);
542 rect
.left
= (rc
.left
+ rc
.right
- size
.cx
) / 2;
543 if (style
& TTS_BALLOON
)
545 ptfx
= rc
.left
+ ((rc
.right
- rc
.left
) / 2);
546 if(rect
.top
- size
.cy
>= 0)
549 infoPtr
->bToolBelow
= FALSE
;
553 infoPtr
->bToolBelow
= TRUE
;
556 rect
.left
= max(0, rect
.left
- BALLOON_STEMINDENT
);
560 rect
.top
= rc
.bottom
+ 2;
561 infoPtr
->bToolBelow
= TRUE
;
565 GetCursorPos ((LPPOINT
)&rect
);
566 if (style
& TTS_BALLOON
)
569 if(rect
.top
- size
.cy
>= 0)
572 infoPtr
->bToolBelow
= FALSE
;
576 infoPtr
->bToolBelow
= TRUE
;
579 rect
.left
= max(0, rect
.left
- BALLOON_STEMINDENT
);
584 infoPtr
->bToolBelow
= TRUE
;
588 TRACE("pos %ld - %ld\n", rect
.left
, rect
.top
);
590 rect
.right
= rect
.left
+ size
.cx
;
591 rect
.bottom
= rect
.top
+ size
.cy
;
594 wndrect
.right
= GetSystemMetrics( SM_CXSCREEN
);
595 if( rect
.right
> wndrect
.right
) {
596 rect
.left
-= rect
.right
- wndrect
.right
+ 2;
597 rect
.right
= wndrect
.right
- 2;
599 wndrect
.bottom
= GetSystemMetrics( SM_CYSCREEN
);
600 if( rect
.bottom
> wndrect
.bottom
) {
603 if (toolPtr
->uFlags
& TTF_IDISHWND
)
604 GetWindowRect ((HWND
)toolPtr
->uId
, &rc
);
607 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rc
, 2);
609 rect
.bottom
= rc
.top
- 2;
610 rect
.top
= rect
.bottom
- size
.cy
;
613 AdjustWindowRectEx (&rect
, GetWindowLongA (hwnd
, GWL_STYLE
),
614 FALSE
, GetWindowLongA (hwnd
, GWL_EXSTYLE
));
616 if (style
& TTS_BALLOON
)
624 if(infoPtr
->bToolBelow
)
628 pts
[1].x
= max(BALLOON_STEMINDENT
, ptfx
- (BALLOON_STEMWIDTH
/ 2));
629 pts
[1].y
= BALLOON_STEMHEIGHT
;
630 pts
[2].x
= pts
[1].x
+ BALLOON_STEMWIDTH
;
632 if(pts
[2].x
> (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
)
634 pts
[2].x
= (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
;
635 pts
[1].x
= pts
[2].x
- BALLOON_STEMWIDTH
;
640 pts
[0].x
= max(BALLOON_STEMINDENT
, ptfx
- (BALLOON_STEMWIDTH
/ 2));
641 pts
[0].y
= (rect
.bottom
- rect
.top
) - BALLOON_STEMHEIGHT
;
642 pts
[1].x
= pts
[0].x
+ BALLOON_STEMWIDTH
;
645 pts
[2].y
= (rect
.bottom
- rect
.top
);
646 if(pts
[1].x
> (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
)
648 pts
[1].x
= (rect
.right
- rect
.left
) - BALLOON_STEMINDENT
;
649 pts
[0].x
= pts
[1].x
- BALLOON_STEMWIDTH
;
653 hrStem
= CreatePolygonRgn(pts
, sizeof(pts
) / sizeof(pts
[0]), ALTERNATE
);
655 hRgn
= CreateRoundRectRgn(0,
656 (infoPtr
->bToolBelow
? BALLOON_STEMHEIGHT
: 0),
657 rect
.right
- rect
.left
,
658 (infoPtr
->bToolBelow
? rect
.bottom
- rect
.top
: rect
.bottom
- rect
.top
- BALLOON_STEMHEIGHT
),
659 BALLOON_ROUNDEDNESS
, BALLOON_ROUNDEDNESS
);
661 CombineRgn(hRgn
, hRgn
, hrStem
, RGN_OR
);
662 DeleteObject(hrStem
);
664 SetWindowRgn(hwnd
, hRgn
, FALSE
);
665 /* we don't free the region handle as the system deletes it when
666 * it is no longer needed */
669 SetWindowPos (hwnd
, HWND_TOP
, rect
.left
, rect
.top
,
670 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
671 SWP_SHOWWINDOW
| SWP_NOACTIVATE
);
673 /* repaint the tooltip */
674 InvalidateRect(hwnd
, NULL
, TRUE
);
677 SetTimer (hwnd
, ID_TIMERPOP
, infoPtr
->nAutoPopTime
, 0);
678 TRACE("timer 2 started!\n");
679 SetTimer (hwnd
, ID_TIMERLEAVE
, infoPtr
->nReshowTime
, 0);
680 TRACE("timer 3 started!\n");
685 TOOLTIPS_Hide (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
687 TTTOOL_INFO
*toolPtr
;
690 TRACE("Hide tooltip %d! (%p)\n", infoPtr
->nCurrentTool
, hwnd
);
692 if (infoPtr
->nCurrentTool
== -1)
695 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
696 KillTimer (hwnd
, ID_TIMERPOP
);
699 hdr
.idFrom
= toolPtr
->uId
;
701 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
702 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
704 infoPtr
->nCurrentTool
= -1;
706 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0,
707 SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
712 TOOLTIPS_TrackShow (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
714 TTTOOL_INFO
*toolPtr
;
719 if (infoPtr
->nTrackTool
== -1) {
720 TRACE("invalid tracking tool (-1)!\n");
724 TRACE("show tracking tooltip pre %d!\n", infoPtr
->nTrackTool
);
726 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nTrackTool
);
728 if (infoPtr
->szTipText
[0] == L
'\0') {
729 infoPtr
->nTrackTool
= -1;
733 TRACE("show tracking tooltip %d!\n", infoPtr
->nTrackTool
);
734 toolPtr
= &infoPtr
->tools
[infoPtr
->nTrackTool
];
737 hdr
.idFrom
= toolPtr
->uId
;
739 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
740 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
742 TRACE("%s\n", debugstr_w(infoPtr
->szTipText
));
744 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
745 TRACE("size %ld x %ld\n", size
.cx
, size
.cy
);
747 if (toolPtr
->uFlags
& TTF_ABSOLUTE
) {
748 rect
.left
= infoPtr
->xTrackPos
;
749 rect
.top
= infoPtr
->yTrackPos
;
751 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
752 rect
.left
-= (size
.cx
/ 2);
753 rect
.top
-= (size
.cy
/ 2);
759 if (toolPtr
->uFlags
& TTF_IDISHWND
)
760 GetWindowRect ((HWND
)toolPtr
->uId
, &rcTool
);
762 rcTool
= toolPtr
->rect
;
763 MapWindowPoints (toolPtr
->hwnd
, NULL
, (LPPOINT
)&rcTool
, 2);
766 GetCursorPos ((LPPOINT
)&rect
);
769 if (toolPtr
->uFlags
& TTF_CENTERTIP
) {
770 rect
.left
-= (size
.cx
/ 2);
771 rect
.top
-= (size
.cy
/ 2);
774 /* smart placement */
775 if ((rect
.left
+ size
.cx
> rcTool
.left
) && (rect
.left
< rcTool
.right
) &&
776 (rect
.top
+ size
.cy
> rcTool
.top
) && (rect
.top
< rcTool
.bottom
))
777 rect
.left
= rcTool
.right
;
780 TRACE("pos %ld - %ld\n", rect
.left
, rect
.top
);
782 rect
.right
= rect
.left
+ size
.cx
;
783 rect
.bottom
= rect
.top
+ size
.cy
;
785 AdjustWindowRectEx (&rect
, GetWindowLongA (hwnd
, GWL_STYLE
),
786 FALSE
, GetWindowLongA (hwnd
, GWL_EXSTYLE
));
788 if (GetWindowLongW(hwnd
, GWL_STYLE
) & TTS_BALLOON
)
792 /* FIXME: need to add pointy bit using CreatePolyRgn & CombinRgn */
793 hRgn
= CreateRoundRectRgn(0, 0, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, BALLOON_ROUNDEDNESS
, BALLOON_ROUNDEDNESS
);
795 SetWindowRgn(hwnd
, hRgn
, FALSE
);
796 /* we don't free the region handle as the system deletes it when
797 * it is no longer needed */
800 SetWindowPos (hwnd
, HWND_TOP
, rect
.left
, rect
.top
,
801 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
802 SWP_SHOWWINDOW
| SWP_NOACTIVATE
);
804 InvalidateRect(hwnd
, NULL
, TRUE
);
810 TOOLTIPS_TrackHide (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
)
812 TTTOOL_INFO
*toolPtr
;
815 TRACE("hide tracking tooltip %d\n", infoPtr
->nTrackTool
);
817 if (infoPtr
->nTrackTool
== -1)
820 toolPtr
= &infoPtr
->tools
[infoPtr
->nTrackTool
];
823 hdr
.idFrom
= toolPtr
->uId
;
825 SendMessageW (toolPtr
->hwnd
, WM_NOTIFY
,
826 (WPARAM
)toolPtr
->uId
, (LPARAM
)&hdr
);
828 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0,
829 SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
834 TOOLTIPS_GetToolFromInfoA (TOOLTIPS_INFO
*infoPtr
, LPTTTOOLINFOA lpToolInfo
)
836 TTTOOL_INFO
*toolPtr
;
839 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
840 toolPtr
= &infoPtr
->tools
[nTool
];
842 if (!(toolPtr
->uFlags
& TTF_IDISHWND
) &&
843 (lpToolInfo
->hwnd
== toolPtr
->hwnd
) &&
844 (lpToolInfo
->uId
== toolPtr
->uId
))
848 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
849 toolPtr
= &infoPtr
->tools
[nTool
];
851 if ((toolPtr
->uFlags
& TTF_IDISHWND
) &&
852 (lpToolInfo
->uId
== toolPtr
->uId
))
861 TOOLTIPS_GetToolFromInfoW (TOOLTIPS_INFO
*infoPtr
, LPTTTOOLINFOW lpToolInfo
)
863 TTTOOL_INFO
*toolPtr
;
866 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
867 toolPtr
= &infoPtr
->tools
[nTool
];
869 if (!(toolPtr
->uFlags
& TTF_IDISHWND
) &&
870 (lpToolInfo
->hwnd
== toolPtr
->hwnd
) &&
871 (lpToolInfo
->uId
== toolPtr
->uId
))
875 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
876 toolPtr
= &infoPtr
->tools
[nTool
];
878 if ((toolPtr
->uFlags
& TTF_IDISHWND
) &&
879 (lpToolInfo
->uId
== toolPtr
->uId
))
888 TOOLTIPS_GetToolFromPoint (TOOLTIPS_INFO
*infoPtr
, HWND hwnd
, LPPOINT lpPt
)
890 TTTOOL_INFO
*toolPtr
;
893 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
894 toolPtr
= &infoPtr
->tools
[nTool
];
896 if (!(toolPtr
->uFlags
& TTF_IDISHWND
)) {
897 if (hwnd
!= toolPtr
->hwnd
)
899 if (!PtInRect (&toolPtr
->rect
, *lpPt
))
905 for (nTool
= 0; nTool
< infoPtr
->uNumTools
; nTool
++) {
906 toolPtr
= &infoPtr
->tools
[nTool
];
908 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
909 if ((HWND
)toolPtr
->uId
== hwnd
)
919 TOOLTIPS_IsWindowActive (HWND hwnd
)
921 HWND hwndActive
= GetActiveWindow ();
924 if (hwndActive
== hwnd
)
926 return IsChild (hwndActive
, hwnd
);
931 TOOLTIPS_CheckTool (HWND hwnd
, BOOL bShowTest
)
933 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
939 hwndTool
= (HWND
)SendMessageW (hwnd
, TTM_WINDOWFROMPOINT
, 0, (LPARAM
)&pt
);
943 ScreenToClient (hwndTool
, &pt
);
944 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, hwndTool
, &pt
);
948 if (!(GetWindowLongA (hwnd
, GWL_STYLE
) & TTS_ALWAYSTIP
) && bShowTest
) {
949 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd
, GW_OWNER
)))
953 TRACE("tool %d\n", nTool
);
960 TOOLTIPS_Activate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
962 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
964 infoPtr
->bActive
= (BOOL
)wParam
;
966 if (infoPtr
->bActive
)
967 TRACE("activate!\n");
969 if (!(infoPtr
->bActive
) && (infoPtr
->nCurrentTool
!= -1))
970 TOOLTIPS_Hide (hwnd
, infoPtr
);
977 TOOLTIPS_AddToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
979 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
980 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
981 TTTOOL_INFO
*toolPtr
;
984 if (lpToolInfo
== NULL
)
986 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
989 TRACE("add tool (%p) %p %d%s!\n",
990 hwnd
, lpToolInfo
->hwnd
, lpToolInfo
->uId
,
991 (lpToolInfo
->uFlags
& TTF_IDISHWND
) ? " TTF_IDISHWND" : "");
993 if (infoPtr
->uNumTools
== 0) {
994 infoPtr
->tools
= Alloc (sizeof(TTTOOL_INFO
));
995 toolPtr
= infoPtr
->tools
;
998 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1000 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
+ 1));
1001 memcpy (infoPtr
->tools
, oldTools
,
1002 infoPtr
->uNumTools
* sizeof(TTTOOL_INFO
));
1004 toolPtr
= &infoPtr
->tools
[infoPtr
->uNumTools
];
1007 infoPtr
->uNumTools
++;
1009 /* copy tool data */
1010 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
1011 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
1012 toolPtr
->uId
= lpToolInfo
->uId
;
1013 toolPtr
->rect
= lpToolInfo
->rect
;
1014 toolPtr
->hinst
= lpToolInfo
->hinst
;
1016 if (HIWORD(lpToolInfo
->lpszText
) == 0) {
1017 TRACE("add string id %x!\n", (int)lpToolInfo
->lpszText
);
1018 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
1020 else if (lpToolInfo
->lpszText
) {
1021 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
) {
1022 TRACE("add CALLBACK!\n");
1023 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
1026 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
1028 TRACE("add text \"%s\"!\n", lpToolInfo
->lpszText
);
1029 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
1030 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
1031 toolPtr
->lpszText
, len
);
1035 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1036 toolPtr
->lParam
= lpToolInfo
->lParam
;
1038 /* install subclassing hook */
1039 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1040 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1041 SetWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1,
1045 SetWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1,
1048 TRACE("subclassing installed!\n");
1051 nResult
= (INT
) SendMessageW (toolPtr
->hwnd
, WM_NOTIFYFORMAT
,
1052 (WPARAM
)hwnd
, (LPARAM
)NF_QUERY
);
1053 if (nResult
== NFR_ANSI
) {
1054 toolPtr
->bNotifyUnicode
= FALSE
;
1055 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1056 } else if (nResult
== NFR_UNICODE
) {
1057 toolPtr
->bNotifyUnicode
= TRUE
;
1058 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1060 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1068 TOOLTIPS_AddToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1070 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1071 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1072 TTTOOL_INFO
*toolPtr
;
1075 if (lpToolInfo
== NULL
)
1077 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1080 TRACE("add tool (%p) %p %d%s!\n",
1081 hwnd
, lpToolInfo
->hwnd
, lpToolInfo
->uId
,
1082 (lpToolInfo
->uFlags
& TTF_IDISHWND
) ? " TTF_IDISHWND" : "");
1084 if (infoPtr
->uNumTools
== 0) {
1085 infoPtr
->tools
= Alloc (sizeof(TTTOOL_INFO
));
1086 toolPtr
= infoPtr
->tools
;
1089 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1091 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
+ 1));
1092 memcpy (infoPtr
->tools
, oldTools
,
1093 infoPtr
->uNumTools
* sizeof(TTTOOL_INFO
));
1095 toolPtr
= &infoPtr
->tools
[infoPtr
->uNumTools
];
1098 infoPtr
->uNumTools
++;
1100 /* copy tool data */
1101 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
1102 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
1103 toolPtr
->uId
= lpToolInfo
->uId
;
1104 toolPtr
->rect
= lpToolInfo
->rect
;
1105 toolPtr
->hinst
= lpToolInfo
->hinst
;
1107 if (HIWORD(lpToolInfo
->lpszText
) == 0) {
1108 TRACE("add string id %x!\n", (int)lpToolInfo
->lpszText
);
1109 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
1111 else if (lpToolInfo
->lpszText
) {
1112 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
) {
1113 TRACE("add CALLBACK!\n");
1114 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
1117 INT len
= lstrlenW (lpToolInfo
->lpszText
);
1118 TRACE("add text %s!\n",
1119 debugstr_w(lpToolInfo
->lpszText
));
1120 toolPtr
->lpszText
= Alloc ((len
+ 1)*sizeof(WCHAR
));
1121 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
1125 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1126 toolPtr
->lParam
= lpToolInfo
->lParam
;
1128 /* install subclassing hook */
1129 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1130 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1131 SetWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1,
1135 SetWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1,
1138 TRACE("subclassing installed!\n");
1141 nResult
= (INT
) SendMessageW (toolPtr
->hwnd
, WM_NOTIFYFORMAT
,
1142 (WPARAM
)hwnd
, (LPARAM
)NF_QUERY
);
1143 if (nResult
== NFR_ANSI
) {
1144 toolPtr
->bNotifyUnicode
= FALSE
;
1145 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1146 } else if (nResult
== NFR_UNICODE
) {
1147 toolPtr
->bNotifyUnicode
= TRUE
;
1148 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1150 TRACE (" -- WM_NOTIFYFORMAT returns: error!\n");
1158 TOOLTIPS_DelToolCommon (HWND hwnd
, TOOLTIPS_INFO
*infoPtr
, INT nTool
)
1160 TTTOOL_INFO
*toolPtr
;
1162 TRACE("tool %d\n", nTool
);
1167 /* make sure the tooltip has disappeared before deleting it */
1168 TOOLTIPS_Hide(hwnd
, infoPtr
);
1170 /* delete text string */
1171 toolPtr
= &infoPtr
->tools
[nTool
];
1172 if (toolPtr
->lpszText
) {
1173 if ( (toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
) &&
1174 (HIWORD((INT
)toolPtr
->lpszText
) != 0) )
1175 Free (toolPtr
->lpszText
);
1178 /* remove subclassing */
1179 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
1180 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
1181 RemoveWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1);
1184 RemoveWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1);
1188 /* delete tool from tool list */
1189 if (infoPtr
->uNumTools
== 1) {
1190 Free (infoPtr
->tools
);
1191 infoPtr
->tools
= NULL
;
1194 TTTOOL_INFO
*oldTools
= infoPtr
->tools
;
1196 Alloc (sizeof(TTTOOL_INFO
) * (infoPtr
->uNumTools
- 1));
1199 memcpy (&infoPtr
->tools
[0], &oldTools
[0],
1200 nTool
* sizeof(TTTOOL_INFO
));
1202 if (nTool
< infoPtr
->uNumTools
- 1)
1203 memcpy (&infoPtr
->tools
[nTool
], &oldTools
[nTool
+ 1],
1204 (infoPtr
->uNumTools
- nTool
- 1) * sizeof(TTTOOL_INFO
));
1209 /* update any indices affected by delete */
1211 /* destroying tool that mouse was on on last relayed mouse move */
1212 if (infoPtr
->nTool
== nTool
)
1213 /* -1 means no current tool (0 means first tool) */
1214 infoPtr
->nTool
= -1;
1215 else if (infoPtr
->nTool
> nTool
)
1218 if (infoPtr
->nTrackTool
== nTool
)
1219 /* -1 means no current tool (0 means first tool) */
1220 infoPtr
->nTrackTool
= -1;
1221 else if (infoPtr
->nTrackTool
> nTool
)
1222 infoPtr
->nTrackTool
--;
1224 if (infoPtr
->nCurrentTool
== nTool
)
1225 /* -1 means no current tool (0 means first tool) */
1226 infoPtr
->nCurrentTool
= -1;
1227 else if (infoPtr
->nCurrentTool
> nTool
)
1228 infoPtr
->nCurrentTool
--;
1230 infoPtr
->uNumTools
--;
1234 TOOLTIPS_DelToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1236 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1237 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1240 if (lpToolInfo
== NULL
)
1242 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1244 if (infoPtr
->uNumTools
== 0)
1247 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1249 TOOLTIPS_DelToolCommon (hwnd
, infoPtr
, nTool
);
1256 TOOLTIPS_DelToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1258 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1259 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1262 if (lpToolInfo
== NULL
)
1264 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1266 if (infoPtr
->uNumTools
== 0)
1269 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1271 TOOLTIPS_DelToolCommon (hwnd
, infoPtr
, nTool
);
1278 TOOLTIPS_EnumToolsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1280 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1281 UINT uIndex
= (UINT
)wParam
;
1282 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1283 TTTOOL_INFO
*toolPtr
;
1285 if (lpToolInfo
== NULL
)
1287 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1289 if (uIndex
>= infoPtr
->uNumTools
)
1292 TRACE("index=%u\n", uIndex
);
1294 toolPtr
= &infoPtr
->tools
[uIndex
];
1296 /* copy tool data */
1297 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1298 lpToolInfo
->hwnd
= toolPtr
->hwnd
;
1299 lpToolInfo
->uId
= toolPtr
->uId
;
1300 lpToolInfo
->rect
= toolPtr
->rect
;
1301 lpToolInfo
->hinst
= toolPtr
->hinst
;
1302 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1303 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1305 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1306 lpToolInfo
->lParam
= toolPtr
->lParam
;
1313 TOOLTIPS_EnumToolsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1315 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1316 UINT uIndex
= (UINT
)wParam
;
1317 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1318 TTTOOL_INFO
*toolPtr
;
1320 if (lpToolInfo
== NULL
)
1322 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1324 if (uIndex
>= infoPtr
->uNumTools
)
1327 TRACE("index=%u\n", uIndex
);
1329 toolPtr
= &infoPtr
->tools
[uIndex
];
1331 /* copy tool data */
1332 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1333 lpToolInfo
->hwnd
= toolPtr
->hwnd
;
1334 lpToolInfo
->uId
= toolPtr
->uId
;
1335 lpToolInfo
->rect
= toolPtr
->rect
;
1336 lpToolInfo
->hinst
= toolPtr
->hinst
;
1337 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1338 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1340 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1341 lpToolInfo
->lParam
= toolPtr
->lParam
;
1347 TOOLTIPS_GetBubbleSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1349 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1350 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1354 if (lpToolInfo
== NULL
)
1356 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1359 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1360 if (nTool
== -1) return 0;
1362 TRACE("tool %d\n", nTool
);
1364 TOOLTIPS_CalcTipSize (hwnd
, infoPtr
, &size
);
1365 TRACE("size %ld x %ld\n", size
.cx
, size
.cy
);
1367 return MAKELRESULT(size
.cx
, size
.cy
);
1371 TOOLTIPS_GetCurrentToolA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1373 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1374 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1375 TTTOOL_INFO
*toolPtr
;
1377 if (lpToolInfo
== NULL
)
1379 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1383 if (infoPtr
->nCurrentTool
> -1) {
1384 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
1386 /* copy tool data */
1387 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1388 lpToolInfo
->rect
= toolPtr
->rect
;
1389 lpToolInfo
->hinst
= toolPtr
->hinst
;
1390 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1391 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1393 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1394 lpToolInfo
->lParam
= toolPtr
->lParam
;
1402 return (infoPtr
->nCurrentTool
!= -1);
1407 TOOLTIPS_GetCurrentToolW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1409 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1410 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1411 TTTOOL_INFO
*toolPtr
;
1413 if (lpToolInfo
== NULL
)
1415 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1419 if (infoPtr
->nCurrentTool
> -1) {
1420 toolPtr
= &infoPtr
->tools
[infoPtr
->nCurrentTool
];
1422 /* copy tool data */
1423 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1424 lpToolInfo
->rect
= toolPtr
->rect
;
1425 lpToolInfo
->hinst
= toolPtr
->hinst
;
1426 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1427 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1429 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1430 lpToolInfo
->lParam
= toolPtr
->lParam
;
1438 return (infoPtr
->nCurrentTool
!= -1);
1443 TOOLTIPS_GetDelayTime (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1445 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1449 return infoPtr
->nReshowTime
;
1452 return infoPtr
->nAutoPopTime
;
1455 case TTDT_AUTOMATIC
: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */
1456 return infoPtr
->nInitialTime
;
1459 WARN("Invalid wParam %x\n", wParam
);
1468 TOOLTIPS_GetMargin (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1470 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1471 LPRECT lpRect
= (LPRECT
)lParam
;
1473 lpRect
->left
= infoPtr
->rcMargin
.left
;
1474 lpRect
->right
= infoPtr
->rcMargin
.right
;
1475 lpRect
->bottom
= infoPtr
->rcMargin
.bottom
;
1476 lpRect
->top
= infoPtr
->rcMargin
.top
;
1482 inline static LRESULT
1483 TOOLTIPS_GetMaxTipWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1485 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1487 return infoPtr
->nMaxTipWidth
;
1492 TOOLTIPS_GetTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1494 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1495 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1498 if (lpToolInfo
== NULL
)
1500 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1503 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1504 if (nTool
== -1) return 0;
1506 /* NB this API is broken, there is no way for the app to determine
1507 what size buffer it requires nor a way to specify how long the
1508 one it supplies is. We'll assume it's upto INFOTIPSIZE */
1510 WideCharToMultiByte(CP_ACP
, 0, infoPtr
->tools
[nTool
].lpszText
, -1,
1511 lpToolInfo
->lpszText
, INFOTIPSIZE
, NULL
, NULL
);
1518 TOOLTIPS_GetTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1520 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1521 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1524 if (lpToolInfo
== NULL
)
1526 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1529 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1530 if (nTool
== -1) return 0;
1532 strcpyW (lpToolInfo
->lpszText
, infoPtr
->tools
[nTool
].lpszText
);
1538 inline static LRESULT
1539 TOOLTIPS_GetTipBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1541 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1542 return infoPtr
->clrBk
;
1546 inline static LRESULT
1547 TOOLTIPS_GetTipTextColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1549 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1550 return infoPtr
->clrText
;
1554 inline static LRESULT
1555 TOOLTIPS_GetToolCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1557 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1558 return infoPtr
->uNumTools
;
1563 TOOLTIPS_GetToolInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1565 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1566 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1567 TTTOOL_INFO
*toolPtr
;
1570 if (lpToolInfo
== NULL
)
1572 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1574 if (infoPtr
->uNumTools
== 0)
1577 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
1581 TRACE("tool %d\n", nTool
);
1583 toolPtr
= &infoPtr
->tools
[nTool
];
1585 /* copy tool data */
1586 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1587 lpToolInfo
->rect
= toolPtr
->rect
;
1588 lpToolInfo
->hinst
= toolPtr
->hinst
;
1589 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1590 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1592 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
1593 lpToolInfo
->lParam
= toolPtr
->lParam
;
1600 TOOLTIPS_GetToolInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1602 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1603 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
1604 TTTOOL_INFO
*toolPtr
;
1607 if (lpToolInfo
== NULL
)
1609 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1611 if (infoPtr
->uNumTools
== 0)
1614 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
1618 TRACE("tool %d\n", nTool
);
1620 toolPtr
= &infoPtr
->tools
[nTool
];
1622 /* copy tool data */
1623 lpToolInfo
->uFlags
= toolPtr
->uFlags
;
1624 lpToolInfo
->rect
= toolPtr
->rect
;
1625 lpToolInfo
->hinst
= toolPtr
->hinst
;
1626 /* lpToolInfo->lpszText = toolPtr->lpszText; */
1627 lpToolInfo
->lpszText
= NULL
; /* FIXME */
1629 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
1630 lpToolInfo
->lParam
= toolPtr
->lParam
;
1637 TOOLTIPS_HitTestA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1639 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1640 LPTTHITTESTINFOA lptthit
= (LPTTHITTESTINFOA
)lParam
;
1641 TTTOOL_INFO
*toolPtr
;
1647 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, lptthit
->hwnd
, &lptthit
->pt
);
1651 TRACE("tool %d!\n", nTool
);
1653 /* copy tool data */
1654 if (lptthit
->ti
.cbSize
>= sizeof(TTTOOLINFOA
)) {
1655 toolPtr
= &infoPtr
->tools
[nTool
];
1657 lptthit
->ti
.uFlags
= toolPtr
->uFlags
;
1658 lptthit
->ti
.hwnd
= toolPtr
->hwnd
;
1659 lptthit
->ti
.uId
= toolPtr
->uId
;
1660 lptthit
->ti
.rect
= toolPtr
->rect
;
1661 lptthit
->ti
.hinst
= toolPtr
->hinst
;
1662 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1663 lptthit
->ti
.lpszText
= NULL
; /* FIXME */
1664 lptthit
->ti
.lParam
= toolPtr
->lParam
;
1672 TOOLTIPS_HitTestW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1674 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1675 LPTTHITTESTINFOW lptthit
= (LPTTHITTESTINFOW
)lParam
;
1676 TTTOOL_INFO
*toolPtr
;
1682 nTool
= TOOLTIPS_GetToolFromPoint (infoPtr
, lptthit
->hwnd
, &lptthit
->pt
);
1686 TRACE("tool %d!\n", nTool
);
1688 /* copy tool data */
1689 if (lptthit
->ti
.cbSize
>= sizeof(TTTOOLINFOW
)) {
1690 toolPtr
= &infoPtr
->tools
[nTool
];
1692 lptthit
->ti
.uFlags
= toolPtr
->uFlags
;
1693 lptthit
->ti
.hwnd
= toolPtr
->hwnd
;
1694 lptthit
->ti
.uId
= toolPtr
->uId
;
1695 lptthit
->ti
.rect
= toolPtr
->rect
;
1696 lptthit
->ti
.hinst
= toolPtr
->hinst
;
1697 /* lptthit->ti.lpszText = toolPtr->lpszText; */
1698 lptthit
->ti
.lpszText
= NULL
; /* FIXME */
1699 lptthit
->ti
.lParam
= toolPtr
->lParam
;
1707 TOOLTIPS_NewToolRectA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1709 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1710 LPTTTOOLINFOA lpti
= (LPTTTOOLINFOA
)lParam
;
1715 if (lpti
->cbSize
< TTTOOLINFOA_V1_SIZE
)
1718 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpti
);
1720 TRACE("nTool = %d, rect = %s\n", nTool
, wine_dbgstr_rect(&lpti
->rect
));
1722 if (nTool
== -1) return 0;
1724 infoPtr
->tools
[nTool
].rect
= lpti
->rect
;
1731 TOOLTIPS_NewToolRectW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1733 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1734 LPTTTOOLINFOW lpti
= (LPTTTOOLINFOW
)lParam
;
1739 if (lpti
->cbSize
< TTTOOLINFOW_V1_SIZE
)
1742 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpti
);
1744 TRACE("nTool = %d, rect = %s\n", nTool
, wine_dbgstr_rect(&lpti
->rect
));
1746 if (nTool
== -1) return 0;
1748 infoPtr
->tools
[nTool
].rect
= lpti
->rect
;
1754 inline static LRESULT
1755 TOOLTIPS_Pop (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1757 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1758 TOOLTIPS_Hide (hwnd
, infoPtr
);
1765 TOOLTIPS_RelayEvent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1767 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1768 LPMSG lpMsg
= (LPMSG
)lParam
;
1773 ERR("lpMsg == NULL!\n");
1777 switch (lpMsg
->message
) {
1778 case WM_LBUTTONDOWN
:
1780 case WM_MBUTTONDOWN
:
1782 case WM_RBUTTONDOWN
:
1784 TOOLTIPS_Hide (hwnd
, infoPtr
);
1788 pt
.x
= LOWORD(lpMsg
->lParam
);
1789 pt
.y
= HIWORD(lpMsg
->lParam
);
1790 nOldTool
= infoPtr
->nTool
;
1791 infoPtr
->nTool
= TOOLTIPS_GetToolFromPoint(infoPtr
, lpMsg
->hwnd
,
1793 TRACE("tool (%p) %d %d %d\n", hwnd
, nOldTool
,
1794 infoPtr
->nTool
, infoPtr
->nCurrentTool
);
1795 TRACE("WM_MOUSEMOVE (%p %ld %ld)\n", hwnd
, pt
.x
, pt
.y
);
1797 if (infoPtr
->nTool
!= nOldTool
) {
1798 if(infoPtr
->nTool
== -1) { /* Moved out of all tools */
1799 TOOLTIPS_Hide(hwnd
, infoPtr
);
1800 KillTimer(hwnd
, ID_TIMERLEAVE
);
1801 } else if (nOldTool
== -1) { /* Moved from outside */
1802 if(infoPtr
->bActive
) {
1803 SetTimer(hwnd
, ID_TIMERSHOW
, infoPtr
->nInitialTime
, 0);
1804 TRACE("timer 1 started!\n");
1806 } else { /* Moved from one to another */
1807 TOOLTIPS_Hide (hwnd
, infoPtr
);
1808 KillTimer(hwnd
, ID_TIMERLEAVE
);
1809 if(infoPtr
->bActive
) {
1810 SetTimer (hwnd
, ID_TIMERSHOW
, infoPtr
->nReshowTime
, 0);
1811 TRACE("timer 1 started!\n");
1814 } else if(infoPtr
->nCurrentTool
!= -1) { /* restart autopop */
1815 KillTimer(hwnd
, ID_TIMERPOP
);
1816 SetTimer(hwnd
, ID_TIMERPOP
, infoPtr
->nAutoPopTime
, 0);
1817 TRACE("timer 2 restarted\n");
1818 } else if(infoPtr
->nTool
!= -1 && infoPtr
->bActive
) {
1819 /* previous show attempt didn't result in tooltip so try again */
1820 SetTimer(hwnd
, ID_TIMERSHOW
, infoPtr
->nInitialTime
, 0);
1821 TRACE("timer 1 started!\n");
1831 TOOLTIPS_SetDelayTime (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1833 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1834 INT nTime
= (INT
)LOWORD(lParam
);
1837 case TTDT_AUTOMATIC
:
1839 nTime
= GetDoubleClickTime();
1840 infoPtr
->nReshowTime
= nTime
/ 5;
1841 infoPtr
->nAutoPopTime
= nTime
* 10;
1842 infoPtr
->nInitialTime
= nTime
;
1847 nTime
= GetDoubleClickTime() / 5;
1848 infoPtr
->nReshowTime
= nTime
;
1853 nTime
= GetDoubleClickTime() * 10;
1854 infoPtr
->nAutoPopTime
= nTime
;
1859 nTime
= GetDoubleClickTime();
1860 infoPtr
->nInitialTime
= nTime
;
1864 WARN("Invalid wParam %x\n", wParam
);
1873 TOOLTIPS_SetMargin (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1875 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1876 LPRECT lpRect
= (LPRECT
)lParam
;
1878 infoPtr
->rcMargin
.left
= lpRect
->left
;
1879 infoPtr
->rcMargin
.right
= lpRect
->right
;
1880 infoPtr
->rcMargin
.bottom
= lpRect
->bottom
;
1881 infoPtr
->rcMargin
.top
= lpRect
->top
;
1887 inline static LRESULT
1888 TOOLTIPS_SetMaxTipWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1890 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1891 INT nTemp
= infoPtr
->nMaxTipWidth
;
1893 infoPtr
->nMaxTipWidth
= (INT
)lParam
;
1899 inline static LRESULT
1900 TOOLTIPS_SetTipBkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1902 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1904 infoPtr
->clrBk
= (COLORREF
)wParam
;
1910 inline static LRESULT
1911 TOOLTIPS_SetTipTextColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1913 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1915 infoPtr
->clrText
= (COLORREF
)wParam
;
1922 TOOLTIPS_SetTitleA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1924 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1925 LPCSTR pszTitle
= (LPCSTR
)lParam
;
1926 UINT_PTR uTitleIcon
= (UINT_PTR
)wParam
;
1929 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd
, debugstr_a(pszTitle
),
1932 Free(infoPtr
->pszTitle
);
1936 size
= sizeof(WCHAR
)*MultiByteToWideChar(CP_ACP
, 0, pszTitle
, -1, NULL
, 0);
1937 infoPtr
->pszTitle
= Alloc(size
);
1938 if (!infoPtr
->pszTitle
)
1940 MultiByteToWideChar(CP_ACP
, 0, pszTitle
, -1, infoPtr
->pszTitle
, size
/sizeof(WCHAR
));
1943 infoPtr
->pszTitle
= NULL
;
1945 if (uTitleIcon
<= TTI_ERROR
)
1946 infoPtr
->hTitleIcon
= hTooltipIcons
[uTitleIcon
];
1948 infoPtr
->hTitleIcon
= CopyIcon((HICON
)wParam
);
1955 TOOLTIPS_SetTitleW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1957 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1958 LPCWSTR pszTitle
= (LPCWSTR
)lParam
;
1959 UINT_PTR uTitleIcon
= (UINT_PTR
)wParam
;
1962 TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd
, debugstr_w(pszTitle
),
1965 Free(infoPtr
->pszTitle
);
1969 size
= (strlenW(pszTitle
)+1)*sizeof(WCHAR
);
1970 infoPtr
->pszTitle
= Alloc(size
);
1971 if (!infoPtr
->pszTitle
)
1973 memcpy(infoPtr
->pszTitle
, pszTitle
, size
);
1976 infoPtr
->pszTitle
= NULL
;
1978 if (uTitleIcon
<= TTI_ERROR
)
1979 infoPtr
->hTitleIcon
= hTooltipIcons
[uTitleIcon
];
1981 infoPtr
->hTitleIcon
= CopyIcon((HICON
)wParam
);
1983 TRACE("icon = %p\n", infoPtr
->hTitleIcon
);
1990 TOOLTIPS_SetToolInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
1992 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
1993 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
1994 TTTOOL_INFO
*toolPtr
;
1997 if (lpToolInfo
== NULL
)
1999 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2002 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2003 if (nTool
== -1) return 0;
2005 TRACE("tool %d\n", nTool
);
2007 toolPtr
= &infoPtr
->tools
[nTool
];
2009 /* copy tool data */
2010 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
2011 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
2012 toolPtr
->uId
= lpToolInfo
->uId
;
2013 toolPtr
->rect
= lpToolInfo
->rect
;
2014 toolPtr
->hinst
= lpToolInfo
->hinst
;
2016 if (HIWORD(lpToolInfo
->lpszText
) == 0) {
2017 TRACE("set string id %x!\n", (INT
)lpToolInfo
->lpszText
);
2018 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
2020 else if (lpToolInfo
->lpszText
) {
2021 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
)
2022 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2024 if ( (toolPtr
->lpszText
) &&
2025 (HIWORD((INT
)toolPtr
->lpszText
) != 0) ) {
2026 Free (toolPtr
->lpszText
);
2027 toolPtr
->lpszText
= NULL
;
2029 if (lpToolInfo
->lpszText
) {
2030 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
,
2032 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
2033 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
2034 toolPtr
->lpszText
, len
);
2039 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOA
))
2040 toolPtr
->lParam
= lpToolInfo
->lParam
;
2047 TOOLTIPS_SetToolInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2049 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2050 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
2051 TTTOOL_INFO
*toolPtr
;
2054 if (lpToolInfo
== NULL
)
2056 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
2059 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
2060 if (nTool
== -1) return 0;
2062 TRACE("tool %d\n", nTool
);
2064 toolPtr
= &infoPtr
->tools
[nTool
];
2066 /* copy tool data */
2067 toolPtr
->uFlags
= lpToolInfo
->uFlags
;
2068 toolPtr
->hwnd
= lpToolInfo
->hwnd
;
2069 toolPtr
->uId
= lpToolInfo
->uId
;
2070 toolPtr
->rect
= lpToolInfo
->rect
;
2071 toolPtr
->hinst
= lpToolInfo
->hinst
;
2073 if (HIWORD(lpToolInfo
->lpszText
) == 0) {
2074 TRACE("set string id %x!\n", (INT
)lpToolInfo
->lpszText
);
2075 toolPtr
->lpszText
= lpToolInfo
->lpszText
;
2078 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
)
2079 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2081 if ( (toolPtr
->lpszText
) &&
2082 (HIWORD((INT
)toolPtr
->lpszText
) != 0) ) {
2083 Free (toolPtr
->lpszText
);
2084 toolPtr
->lpszText
= NULL
;
2086 if (lpToolInfo
->lpszText
) {
2087 INT len
= lstrlenW (lpToolInfo
->lpszText
);
2088 toolPtr
->lpszText
= Alloc ((len
+1)*sizeof(WCHAR
));
2089 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
2094 if (lpToolInfo
->cbSize
>= sizeof(TTTOOLINFOW
))
2095 toolPtr
->lParam
= lpToolInfo
->lParam
;
2097 if (infoPtr
->nCurrentTool
== nTool
)
2099 TOOLTIPS_GetTipText (hwnd
, infoPtr
, infoPtr
->nCurrentTool
);
2101 if (infoPtr
->szTipText
[0] == 0)
2102 TOOLTIPS_Hide(hwnd
, infoPtr
);
2104 TOOLTIPS_Show (hwnd
, infoPtr
);
2112 TOOLTIPS_TrackActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2114 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2117 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2119 if (lpToolInfo
== NULL
)
2121 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2125 infoPtr
->nTrackTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2126 if (infoPtr
->nTrackTool
!= -1) {
2127 TRACE("activated!\n");
2128 infoPtr
->bTrackActive
= TRUE
;
2129 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2134 TOOLTIPS_TrackHide (hwnd
, infoPtr
);
2136 infoPtr
->bTrackActive
= FALSE
;
2137 infoPtr
->nTrackTool
= -1;
2139 TRACE("deactivated!\n");
2147 TOOLTIPS_TrackPosition (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2149 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2151 infoPtr
->xTrackPos
= (INT
)LOWORD(lParam
);
2152 infoPtr
->yTrackPos
= (INT
)HIWORD(lParam
);
2154 if (infoPtr
->bTrackActive
) {
2156 infoPtr
->xTrackPos
, infoPtr
->yTrackPos
);
2158 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2166 TOOLTIPS_Update (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2168 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2170 if (infoPtr
->nCurrentTool
!= -1)
2171 UpdateWindow (hwnd
);
2178 TOOLTIPS_UpdateTipTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2180 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2181 LPTTTOOLINFOA lpToolInfo
= (LPTTTOOLINFOA
)lParam
;
2182 TTTOOL_INFO
*toolPtr
;
2185 if (lpToolInfo
== NULL
)
2187 if (lpToolInfo
->cbSize
< TTTOOLINFOA_V1_SIZE
)
2190 nTool
= TOOLTIPS_GetToolFromInfoA (infoPtr
, lpToolInfo
);
2191 if (nTool
== -1) return 0;
2193 TRACE("tool %d\n", nTool
);
2195 toolPtr
= &infoPtr
->tools
[nTool
];
2197 /* copy tool text */
2198 toolPtr
->hinst
= lpToolInfo
->hinst
;
2200 if (HIWORD(lpToolInfo
->lpszText
) == 0){
2201 toolPtr
->lpszText
= (LPWSTR
)lpToolInfo
->lpszText
;
2203 else if (lpToolInfo
->lpszText
) {
2204 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKA
)
2205 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2207 if ( (toolPtr
->lpszText
) &&
2208 (HIWORD((INT
)toolPtr
->lpszText
) != 0) ) {
2209 Free (toolPtr
->lpszText
);
2210 toolPtr
->lpszText
= NULL
;
2212 if (lpToolInfo
->lpszText
) {
2213 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
,
2215 toolPtr
->lpszText
= Alloc (len
* sizeof(WCHAR
));
2216 MultiByteToWideChar(CP_ACP
, 0, lpToolInfo
->lpszText
, -1,
2217 toolPtr
->lpszText
, len
);
2222 if(infoPtr
->nCurrentTool
== -1) return 0;
2224 if (infoPtr
->bActive
)
2225 TOOLTIPS_Show (hwnd
, infoPtr
);
2226 else if (infoPtr
->bTrackActive
)
2227 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2234 TOOLTIPS_UpdateTipTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2236 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2237 LPTTTOOLINFOW lpToolInfo
= (LPTTTOOLINFOW
)lParam
;
2238 TTTOOL_INFO
*toolPtr
;
2241 if (lpToolInfo
== NULL
)
2243 if (lpToolInfo
->cbSize
< TTTOOLINFOW_V1_SIZE
)
2246 nTool
= TOOLTIPS_GetToolFromInfoW (infoPtr
, lpToolInfo
);
2250 TRACE("tool %d\n", nTool
);
2252 toolPtr
= &infoPtr
->tools
[nTool
];
2254 /* copy tool text */
2255 toolPtr
->hinst
= lpToolInfo
->hinst
;
2257 if (HIWORD(lpToolInfo
->lpszText
) == 0){
2258 toolPtr
->lpszText
= lpToolInfo
->lpszText
;
2260 else if (lpToolInfo
->lpszText
) {
2261 if (lpToolInfo
->lpszText
== LPSTR_TEXTCALLBACKW
)
2262 toolPtr
->lpszText
= LPSTR_TEXTCALLBACKW
;
2264 if ( (toolPtr
->lpszText
) &&
2265 (HIWORD((INT
)toolPtr
->lpszText
) != 0) ) {
2266 Free (toolPtr
->lpszText
);
2267 toolPtr
->lpszText
= NULL
;
2269 if (lpToolInfo
->lpszText
) {
2270 INT len
= lstrlenW (lpToolInfo
->lpszText
);
2271 toolPtr
->lpszText
= Alloc ((len
+1)*sizeof(WCHAR
));
2272 strcpyW (toolPtr
->lpszText
, lpToolInfo
->lpszText
);
2277 if(infoPtr
->nCurrentTool
== -1) return 0;
2279 if (infoPtr
->bActive
)
2280 TOOLTIPS_Show (hwnd
, infoPtr
);
2281 else if (infoPtr
->bTrackActive
)
2282 TOOLTIPS_TrackShow (hwnd
, infoPtr
);
2289 TOOLTIPS_WindowFromPoint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2291 return (LRESULT
)WindowFromPoint (*((LPPOINT
)lParam
));
2297 TOOLTIPS_Create (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
2299 TOOLTIPS_INFO
*infoPtr
;
2301 /* allocate memory for info structure */
2302 infoPtr
= (TOOLTIPS_INFO
*)Alloc (sizeof(TOOLTIPS_INFO
));
2303 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
2305 /* initialize info structure */
2306 infoPtr
->bActive
= TRUE
;
2307 infoPtr
->bTrackActive
= FALSE
;
2309 infoPtr
->nMaxTipWidth
= -1;
2310 infoPtr
->nTool
= -1;
2311 infoPtr
->nCurrentTool
= -1;
2312 infoPtr
->nTrackTool
= -1;
2314 /* initialize colours and fonts */
2315 TOOLTIPS_InitSystemSettings(infoPtr
);
2317 TOOLTIPS_SetDelayTime(hwnd
, TTDT_AUTOMATIC
, 0L);
2319 SetWindowPos (hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOZORDER
| SWP_HIDEWINDOW
| SWP_NOACTIVATE
);
2326 TOOLTIPS_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2328 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2329 TTTOOL_INFO
*toolPtr
;
2333 if (infoPtr
->tools
) {
2334 for (i
= 0; i
< infoPtr
->uNumTools
; i
++) {
2335 toolPtr
= &infoPtr
->tools
[i
];
2336 if (toolPtr
->lpszText
) {
2337 if ( (toolPtr
->lpszText
!= LPSTR_TEXTCALLBACKW
) &&
2338 (HIWORD((INT
)toolPtr
->lpszText
) != 0) )
2340 Free (toolPtr
->lpszText
);
2341 toolPtr
->lpszText
= NULL
;
2345 /* remove subclassing */
2346 if (toolPtr
->uFlags
& TTF_SUBCLASS
) {
2347 if (toolPtr
->uFlags
& TTF_IDISHWND
) {
2348 RemoveWindowSubclass((HWND
)toolPtr
->uId
, TOOLTIPS_SubclassProc
, 1);
2351 RemoveWindowSubclass(toolPtr
->hwnd
, TOOLTIPS_SubclassProc
, 1);
2355 Free (infoPtr
->tools
);
2358 /* free title string */
2359 Free (infoPtr
->pszTitle
);
2360 /* free title icon if not a standard one */
2361 if (TOOLTIPS_GetTitleIconIndex(infoPtr
->hTitleIcon
) > TTI_ERROR
)
2362 DeleteObject(infoPtr
->hTitleIcon
);
2365 DeleteObject (infoPtr
->hFont
);
2366 DeleteObject (infoPtr
->hTitleFont
);
2368 /* free tool tips info data */
2370 SetWindowLongPtrW(hwnd
, 0, 0);
2376 TOOLTIPS_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2378 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2380 return (LRESULT
)infoPtr
->hFont
;
2385 TOOLTIPS_MouseMessage (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2387 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2389 TOOLTIPS_Hide (hwnd
, infoPtr
);
2396 TOOLTIPS_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2398 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
2399 DWORD dwExStyle
= GetWindowLongA (hwnd
, GWL_EXSTYLE
);
2401 dwStyle
&= 0x0000FFFF;
2402 dwStyle
|= (WS_POPUP
| WS_BORDER
| WS_CLIPSIBLINGS
);
2404 /* WS_BORDER only draws a border round the window rect, not the
2405 * window region, therefore it is useless to us in balloon mode */
2406 if (dwStyle
& TTS_BALLOON
) dwStyle
&= ~WS_BORDER
;
2408 SetWindowLongA (hwnd
, GWL_STYLE
, dwStyle
);
2410 dwExStyle
|= WS_EX_TOOLWINDOW
;
2411 SetWindowLongA (hwnd
, GWL_EXSTYLE
, dwExStyle
);
2418 TOOLTIPS_NCHitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2420 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2421 INT nTool
= (infoPtr
->bTrackActive
) ? infoPtr
->nTrackTool
: infoPtr
->nTool
;
2423 TRACE(" nTool=%d\n", nTool
);
2425 if ((nTool
> -1) && (nTool
< infoPtr
->uNumTools
)) {
2426 if (infoPtr
->tools
[nTool
].uFlags
& TTF_TRANSPARENT
) {
2427 TRACE("-- in transparent mode!\n");
2428 return HTTRANSPARENT
;
2432 return DefWindowProcW (hwnd
, WM_NCHITTEST
, wParam
, lParam
);
2437 TOOLTIPS_NotifyFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2439 FIXME ("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2446 TOOLTIPS_Paint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2451 hdc
= (wParam
== 0) ? BeginPaint (hwnd
, &ps
) : (HDC
)wParam
;
2452 TOOLTIPS_Refresh (hwnd
, hdc
);
2454 EndPaint (hwnd
, &ps
);
2460 TOOLTIPS_SetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2462 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2465 if(!GetObjectW((HFONT
)wParam
, sizeof(lf
), &lf
))
2468 DeleteObject (infoPtr
->hFont
);
2469 infoPtr
->hFont
= CreateFontIndirectW(&lf
);
2471 DeleteObject (infoPtr
->hTitleFont
);
2472 lf
.lfWeight
= FW_BOLD
;
2473 infoPtr
->hTitleFont
= CreateFontIndirectW(&lf
);
2475 if ((LOWORD(lParam
)) & (infoPtr
->nCurrentTool
!= -1)) {
2476 FIXME("full redraw needed!\n");
2482 /******************************************************************
2483 * TOOLTIPS_GetTextLength
2485 * This function is called when the tooltip receive a
2486 * WM_GETTEXTLENGTH message.
2490 * returns the length, in characters, of the tip text
2493 TOOLTIPS_GetTextLength(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2495 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2496 return strlenW(infoPtr
->szTipText
);
2499 /******************************************************************
2500 * TOOLTIPS_OnWMGetText
2502 * This function is called when the tooltip receive a
2503 * WM_GETTEXT message.
2504 * wParam : specifies the maximum number of characters to be copied
2505 * lParam : is the pointer to the buffer that will receive
2508 * returns the number of characters copied
2511 TOOLTIPS_OnWMGetText (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2513 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2515 LPWSTR pszText
= (LPWSTR
)lParam
;
2517 if(!infoPtr
->szTipText
|| !wParam
)
2520 res
= min(strlenW(infoPtr
->szTipText
)+1, wParam
);
2521 memcpy(pszText
, infoPtr
->szTipText
, res
*sizeof(WCHAR
));
2522 pszText
[res
-1] = '\0';
2527 TOOLTIPS_Timer (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2529 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2532 TRACE("timer %d (%p) expired!\n", wParam
, hwnd
);
2536 KillTimer (hwnd
, ID_TIMERSHOW
);
2537 nOldTool
= infoPtr
->nTool
;
2538 if ((infoPtr
->nTool
= TOOLTIPS_CheckTool (hwnd
, TRUE
)) == nOldTool
)
2539 TOOLTIPS_Show (hwnd
, infoPtr
);
2543 TOOLTIPS_Hide (hwnd
, infoPtr
);
2547 nOldTool
= infoPtr
->nTool
;
2548 infoPtr
->nTool
= TOOLTIPS_CheckTool (hwnd
, FALSE
);
2549 TRACE("tool (%p) %d %d %d\n", hwnd
, nOldTool
,
2550 infoPtr
->nTool
, infoPtr
->nCurrentTool
);
2551 if (infoPtr
->nTool
!= nOldTool
) {
2552 if(infoPtr
->nTool
== -1) { /* Moved out of all tools */
2553 TOOLTIPS_Hide(hwnd
, infoPtr
);
2554 KillTimer(hwnd
, ID_TIMERLEAVE
);
2555 } else if (nOldTool
== -1) { /* Moved from outside */
2556 ERR("How did this happen?\n");
2557 } else { /* Moved from one to another */
2558 TOOLTIPS_Hide (hwnd
, infoPtr
);
2559 KillTimer(hwnd
, ID_TIMERLEAVE
);
2560 if(infoPtr
->bActive
) {
2561 SetTimer (hwnd
, ID_TIMERSHOW
, infoPtr
->nReshowTime
, 0);
2562 TRACE("timer 1 started!\n");
2569 ERR("Unknown timer id %d\n", wParam
);
2577 TOOLTIPS_WinIniChange (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2579 TOOLTIPS_INFO
*infoPtr
= TOOLTIPS_GetInfoPtr (hwnd
);
2581 TOOLTIPS_InitSystemSettings (infoPtr
);
2587 static LRESULT CALLBACK
2588 TOOLTIPS_SubclassProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uID
, DWORD_PTR dwRef
)
2594 case WM_LBUTTONDOWN
:
2596 case WM_MBUTTONDOWN
:
2598 case WM_RBUTTONDOWN
:
2602 msg
.wParam
= wParam
;
2603 msg
.lParam
= lParam
;
2604 TOOLTIPS_RelayEvent((HWND
)dwRef
, 0, (LPARAM
)&msg
);
2610 return DefSubclassProc(hwnd
, uMsg
, wParam
, lParam
);
2614 static LRESULT CALLBACK
2615 TOOLTIPS_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2617 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd
, uMsg
, wParam
, lParam
);
2618 if (!TOOLTIPS_GetInfoPtr(hwnd
) && (uMsg
!= WM_CREATE
) && (uMsg
!= WM_NCCREATE
))
2619 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2623 return TOOLTIPS_Activate (hwnd
, wParam
, lParam
);
2626 return TOOLTIPS_AddToolA (hwnd
, wParam
, lParam
);
2629 return TOOLTIPS_AddToolW (hwnd
, wParam
, lParam
);
2632 return TOOLTIPS_DelToolA (hwnd
, wParam
, lParam
);
2635 return TOOLTIPS_DelToolW (hwnd
, wParam
, lParam
);
2637 case TTM_ENUMTOOLSA
:
2638 return TOOLTIPS_EnumToolsA (hwnd
, wParam
, lParam
);
2640 case TTM_ENUMTOOLSW
:
2641 return TOOLTIPS_EnumToolsW (hwnd
, wParam
, lParam
);
2643 case TTM_GETBUBBLESIZE
:
2644 return TOOLTIPS_GetBubbleSize (hwnd
, wParam
, lParam
);
2646 case TTM_GETCURRENTTOOLA
:
2647 return TOOLTIPS_GetCurrentToolA (hwnd
, wParam
, lParam
);
2649 case TTM_GETCURRENTTOOLW
:
2650 return TOOLTIPS_GetCurrentToolW (hwnd
, wParam
, lParam
);
2652 case TTM_GETDELAYTIME
:
2653 return TOOLTIPS_GetDelayTime (hwnd
, wParam
, lParam
);
2656 return TOOLTIPS_GetMargin (hwnd
, wParam
, lParam
);
2658 case TTM_GETMAXTIPWIDTH
:
2659 return TOOLTIPS_GetMaxTipWidth (hwnd
, wParam
, lParam
);
2662 return TOOLTIPS_GetTextA (hwnd
, wParam
, lParam
);
2665 return TOOLTIPS_GetTextW (hwnd
, wParam
, lParam
);
2667 case TTM_GETTIPBKCOLOR
:
2668 return TOOLTIPS_GetTipBkColor (hwnd
, wParam
, lParam
);
2670 case TTM_GETTIPTEXTCOLOR
:
2671 return TOOLTIPS_GetTipTextColor (hwnd
, wParam
, lParam
);
2673 case TTM_GETTOOLCOUNT
:
2674 return TOOLTIPS_GetToolCount (hwnd
, wParam
, lParam
);
2676 case TTM_GETTOOLINFOA
:
2677 return TOOLTIPS_GetToolInfoA (hwnd
, wParam
, lParam
);
2679 case TTM_GETTOOLINFOW
:
2680 return TOOLTIPS_GetToolInfoW (hwnd
, wParam
, lParam
);
2683 return TOOLTIPS_HitTestA (hwnd
, wParam
, lParam
);
2686 return TOOLTIPS_HitTestW (hwnd
, wParam
, lParam
);
2688 case TTM_NEWTOOLRECTA
:
2689 return TOOLTIPS_NewToolRectA (hwnd
, wParam
, lParam
);
2691 case TTM_NEWTOOLRECTW
:
2692 return TOOLTIPS_NewToolRectW (hwnd
, wParam
, lParam
);
2695 return TOOLTIPS_Pop (hwnd
, wParam
, lParam
);
2697 case TTM_RELAYEVENT
:
2698 return TOOLTIPS_RelayEvent (hwnd
, wParam
, lParam
);
2700 case TTM_SETDELAYTIME
:
2701 return TOOLTIPS_SetDelayTime (hwnd
, wParam
, lParam
);
2704 return TOOLTIPS_SetMargin (hwnd
, wParam
, lParam
);
2706 case TTM_SETMAXTIPWIDTH
:
2707 return TOOLTIPS_SetMaxTipWidth (hwnd
, wParam
, lParam
);
2709 case TTM_SETTIPBKCOLOR
:
2710 return TOOLTIPS_SetTipBkColor (hwnd
, wParam
, lParam
);
2712 case TTM_SETTIPTEXTCOLOR
:
2713 return TOOLTIPS_SetTipTextColor (hwnd
, wParam
, lParam
);
2716 return TOOLTIPS_SetTitleA (hwnd
, wParam
, lParam
);
2719 return TOOLTIPS_SetTitleW (hwnd
, wParam
, lParam
);
2721 case TTM_SETTOOLINFOA
:
2722 return TOOLTIPS_SetToolInfoA (hwnd
, wParam
, lParam
);
2724 case TTM_SETTOOLINFOW
:
2725 return TOOLTIPS_SetToolInfoW (hwnd
, wParam
, lParam
);
2727 case TTM_TRACKACTIVATE
:
2728 return TOOLTIPS_TrackActivate (hwnd
, wParam
, lParam
);
2730 case TTM_TRACKPOSITION
:
2731 return TOOLTIPS_TrackPosition (hwnd
, wParam
, lParam
);
2734 return TOOLTIPS_Update (hwnd
, wParam
, lParam
);
2736 case TTM_UPDATETIPTEXTA
:
2737 return TOOLTIPS_UpdateTipTextA (hwnd
, wParam
, lParam
);
2739 case TTM_UPDATETIPTEXTW
:
2740 return TOOLTIPS_UpdateTipTextW (hwnd
, wParam
, lParam
);
2742 case TTM_WINDOWFROMPOINT
:
2743 return TOOLTIPS_WindowFromPoint (hwnd
, wParam
, lParam
);
2747 return TOOLTIPS_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
2750 return TOOLTIPS_Destroy (hwnd
, wParam
, lParam
);
2753 /* we draw the background in WM_PAINT */
2757 return TOOLTIPS_GetFont (hwnd
, wParam
, lParam
);
2760 return TOOLTIPS_OnWMGetText (hwnd
, wParam
, lParam
);
2762 case WM_GETTEXTLENGTH
:
2763 return TOOLTIPS_GetTextLength (hwnd
, wParam
, lParam
);
2765 case WM_LBUTTONDOWN
:
2767 case WM_MBUTTONDOWN
:
2769 case WM_RBUTTONDOWN
:
2772 return TOOLTIPS_MouseMessage (hwnd
, uMsg
, wParam
, lParam
);
2775 return TOOLTIPS_NCCreate (hwnd
, wParam
, lParam
);
2778 return TOOLTIPS_NCHitTest (hwnd
, wParam
, lParam
);
2780 case WM_NOTIFYFORMAT
:
2781 return TOOLTIPS_NotifyFormat (hwnd
, wParam
, lParam
);
2784 return TOOLTIPS_Paint (hwnd
, wParam
, lParam
);
2787 return TOOLTIPS_SetFont (hwnd
, wParam
, lParam
);
2790 return TOOLTIPS_Timer (hwnd
, wParam
, lParam
);
2792 case WM_WININICHANGE
:
2793 return TOOLTIPS_WinIniChange (hwnd
, wParam
, lParam
);
2796 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
2797 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2798 uMsg
, wParam
, lParam
);
2799 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
2805 TOOLTIPS_Register (void)
2809 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
2810 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
| CS_SAVEBITS
;
2811 wndClass
.lpfnWndProc
= TOOLTIPS_WindowProc
;
2812 wndClass
.cbClsExtra
= 0;
2813 wndClass
.cbWndExtra
= sizeof(TOOLTIPS_INFO
*);
2814 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
2815 wndClass
.hbrBackground
= 0;
2816 wndClass
.lpszClassName
= TOOLTIPS_CLASSW
;
2818 RegisterClassW (&wndClass
);
2820 hTooltipIcons
[TTI_NONE
] = NULL
;
2821 hTooltipIcons
[TTI_INFO
] = LoadImageW(COMCTL32_hModule
,
2822 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_INFO_SM
), IMAGE_ICON
, 0, 0, 0);
2823 hTooltipIcons
[TTI_WARNING
] = LoadImageW(COMCTL32_hModule
,
2824 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_WARN_SM
), IMAGE_ICON
, 0, 0, 0);
2825 hTooltipIcons
[TTI_ERROR
] = LoadImageW(COMCTL32_hModule
,
2826 (LPCWSTR
)MAKEINTRESOURCE(IDI_TT_ERROR_SM
), IMAGE_ICON
, 0, 0, 0);
2831 TOOLTIPS_Unregister (void)
2834 for (i
= TTI_INFO
; i
<= TTI_ERROR
; i
++)
2835 DestroyIcon(hTooltipIcons
[i
]);
2836 UnregisterClassW (TOOLTIPS_CLASSW
, NULL
);