source: trunk/src/comctl32/tooltips.c@ 2811

Last change on this file since 2811 was 2806, checked in by cbratschi, 26 years ago

treeview: finished soon

File size: 67.2 KB
Line 
1/* $Id: tooltips.c,v 1.21 2000-02-16 17:22:18 cbratschi Exp $ */
2/*
3 * Tool tip control
4 *
5 * Copyright 1998 Eric Kohl
6 * Copyright 1999 Achim Hasenmueller
7 * Copyright 1999 Christoph Bratschi
8 *
9 * TODO:
10 * - Custom draw support.
11 *
12 * Testing:
13 * - Run tests using Waite Group Windows95 API Bible Volume 2.
14 * The second cdrom (chapter 3) contains executables activate.exe,
15 * curtool.exe, deltool.exe, enumtools.exe, getinfo.exe, getiptxt.exe,
16 * hittest.exe, needtext.exe, newrect.exe, updtext.exe and winfrpt.exe.
17 */
18
19/* WINE 20000130 level */
20
21#include <string.h>
22
23#include "winbase.h"
24#include "commctrl.h"
25#include "tooltips.h"
26#include "comctl32.h"
27
28#define ID_TIMERSHOW 1 /* show delay timer */
29#define ID_TIMERPOP 2 /* auto pop timer */
30#define ID_TIMERLEAVE 3 /* tool leave timer */
31
32
33extern LPSTR COMCTL32_aSubclass; /* global subclassing atom */
34
35/* property name of tooltip window handle */
36/*#define TT_SUBCLASS_PROP "CC32SubclassInfo" */
37
38#define TOOLTIPS_GetInfoPtr(hWindow) ((TOOLTIPS_INFO *)GetWindowLongA (hWindow, 0))
39
40LRESULT CALLBACK
41TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
42
43
44static VOID
45TOOLTIPS_Refresh (HWND hwnd, HDC hdc)
46{
47 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
48 RECT rc;
49 INT oldBkMode;
50 HFONT hOldFont;
51 HBRUSH hBrush;
52 UINT uFlags = DT_EXTERNALLEADING;
53
54 if (infoPtr->nMaxTipWidth > -1) uFlags |= DT_WORDBREAK;
55 if (GetWindowLongA(hwnd,GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX;
56 GetClientRect(hwnd,&rc);
57
58 /* fill the background */
59 hBrush = CreateSolidBrush(infoPtr->clrBk);
60 FillRect(hdc,&rc,hBrush);
61 DeleteObject(hBrush);
62
63 /* calculate text rectangle */
64 rc.left += (2+infoPtr->rcMargin.left);
65 rc.top += (2+infoPtr->rcMargin.top);
66 rc.right -= (2+infoPtr->rcMargin.right);
67 rc.bottom -= (2+infoPtr->rcMargin.bottom);
68
69 /* draw text */
70 oldBkMode = SetBkMode(hdc,TRANSPARENT);
71 SetTextColor(hdc,infoPtr->clrText);
72 hOldFont = SelectObject(hdc,infoPtr->hFont);
73 DrawTextW(hdc,infoPtr->szTipText,-1,&rc,uFlags);
74 SelectObject(hdc,hOldFont);
75 if (oldBkMode != TRANSPARENT) SetBkMode(hdc,oldBkMode);
76}
77
78
79static VOID
80TOOLTIPS_GetTipText(HWND hwnd,TOOLTIPS_INFO *infoPtr,INT nTool)
81{
82 TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
83
84 if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0))
85 {
86 /* load a resource */
87
88 LoadStringW(toolPtr->hinst,(UINT)toolPtr->lpszText,infoPtr->szTipText,INFOTIPSIZE);
89 } else if (toolPtr->lpszText)
90 {
91 if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW)
92 {
93 NMTTDISPINFOA ttnmdi;
94
95 /* fill NMHDR struct */
96 ZeroMemory (&ttnmdi,sizeof(NMTTDISPINFOA));
97 ttnmdi.hdr.hwndFrom = hwnd;
98 ttnmdi.hdr.idFrom = toolPtr->uId;
99 ttnmdi.hdr.code = TTN_GETDISPINFOA;
100 ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
101 ttnmdi.uFlags = toolPtr->uFlags;
102 ttnmdi.lParam = toolPtr->lParam;
103 SendMessageA (toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&ttnmdi);
104
105 if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0))
106 {
107 LoadStringW (ttnmdi.hinst,(UINT)ttnmdi.szText,infoPtr->szTipText,INFOTIPSIZE);
108 if (ttnmdi.uFlags & TTF_DI_SETITEM)
109 {
110 toolPtr->hinst = ttnmdi.hinst;
111 toolPtr->lpszText = (LPWSTR)ttnmdi.szText;
112 }
113 } else if (ttnmdi.szText[0])
114 {
115 lstrcpynAtoW(infoPtr->szTipText,ttnmdi.szText,INFOTIPSIZE);
116 if (ttnmdi.uFlags & TTF_DI_SETITEM)
117 {
118 INT len = lstrlenA(ttnmdi.szText);
119 toolPtr->hinst = 0;
120 toolPtr->lpszText = COMCTL32_Alloc((len+1)* sizeof(WCHAR));
121 lstrcpyAtoW(toolPtr->lpszText,ttnmdi.szText);
122 }
123 } else if (ttnmdi.lpszText == 0)
124 {
125 /* no text available */
126 infoPtr->szTipText[0] = '\0';
127 } else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA)
128 {
129 lstrcpynAtoW(infoPtr->szTipText,ttnmdi.lpszText,INFOTIPSIZE);
130 if (ttnmdi.uFlags & TTF_DI_SETITEM)
131 {
132 INT len = lstrlenA(ttnmdi.lpszText);
133 toolPtr->hinst = 0;
134 toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
135 lstrcpyAtoW(toolPtr->lpszText,ttnmdi.lpszText);
136 }
137 } else
138 {
139 //ERR (tooltips, "recursive text callback!\n");
140 infoPtr->szTipText[0] = '\0';
141 }
142 } else
143 {
144 /* the item is a usual (unicode) text */
145 lstrcpynW(infoPtr->szTipText,toolPtr->lpszText,INFOTIPSIZE);
146 }
147 }
148 else
149 {
150 /* no text available */
151 infoPtr->szTipText[0] = '\0';
152 }
153
154// TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
155}
156
157static VOID
158TOOLTIPS_CalcTipRect (HWND hwnd,TOOLTIPS_INFO *infoPtr,TTTOOL_INFO *toolPtr,LPRECT lpRect)
159{
160 HDC hdc;
161 HFONT hOldFont;
162 UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT;
163 RECT rc = {0,0,0,0};
164 SIZE size;
165
166 if (infoPtr->nMaxTipWidth > -1)
167 {
168 rc.right = infoPtr->nMaxTipWidth;
169 uFlags |= DT_WORDBREAK;
170 }
171 if (GetWindowLongA(hwnd,GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX;
172// TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
173
174 hdc = GetDC(hwnd);
175 hOldFont = SelectObject(hdc,infoPtr->hFont);
176 DrawTextW(hdc,infoPtr->szTipText,-1,&rc,uFlags);
177 SelectObject(hdc,hOldFont);
178 ReleaseDC(hwnd,hdc);
179
180 size.cx = rc.right-rc.left+4+infoPtr->rcMargin.left+infoPtr->rcMargin.right;
181 size.cy = rc.bottom-rc.top+4+infoPtr->rcMargin.bottom+infoPtr->rcMargin.top;
182
183 //CB: optimize
184
185 if (toolPtr->uFlags & TTF_ABSOLUTE)
186 {
187 rc.left = infoPtr->xTrackPos;
188 rc.top = infoPtr->yTrackPos;
189
190 if (toolPtr->uFlags & TTF_CENTERTIP)
191 {
192 rc.left -= (size.cx/2);
193 rc.top -= (size.cy/2);
194 }
195 } else
196 {
197 RECT rcTool;
198
199 if (toolPtr->uFlags & TTF_IDISHWND)
200 {
201 GetWindowRect((HWND)toolPtr->uId,&rcTool); //screen coordinates
202 } else
203 {
204 rcTool = toolPtr->rect;
205 MapWindowPoints(toolPtr->hwnd,(HWND)0,(LPPOINT)&rcTool,2);
206 }
207
208 if (toolPtr->uFlags & TTF_CENTERTIP)
209 {
210 if (infoPtr->bTrackActive)
211 {
212 GetCursorPos((LPPOINT)&rc);
213 rc.top += 20;
214 rc.left -= (size.cx / 2);
215 rc.top -= (size.cy / 2);
216 } else
217 {
218 rc.left = (rcTool.left + rcTool.right-size.cx)/ 2;
219 rc.top = rcTool.bottom+2;
220 }
221
222 } else
223 {
224 GetCursorPos((LPPOINT)&rc);
225 rc.top += 20;
226 }
227
228 /* smart placement */
229 if (infoPtr->bTrackActive)
230 {
231 if ((rc.left + size.cx > rcTool.left) && (rc.left < rcTool.right) &&
232 (rc.top + size.cy > rcTool.top) && (rc.top < rcTool.bottom))
233 rc.left = rcTool.right;
234 }
235 }
236
237// TRACE (tooltips, "pos %d - %d\n", rect.left, rect.top);
238
239 rc.right = rc.left+size.cx;
240 rc.bottom = rc.top+size.cy;
241
242 AdjustWindowRectEx (&rc,GetWindowLongA(hwnd,GWL_STYLE),
243 FALSE,GetWindowLongA(hwnd,GWL_EXSTYLE));
244
245 *lpRect = rc;
246
247}
248
249static VOID
250TOOLTIPS_CalcTipSize (HWND hwnd, TOOLTIPS_INFO *infoPtr, LPSIZE lpSize)
251{
252 HDC hdc;
253 HFONT hOldFont;
254 UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT;
255 RECT rc = {0, 0, 0, 0};
256
257 if (infoPtr->nMaxTipWidth > -1) {
258 rc.right = infoPtr->nMaxTipWidth;
259 uFlags |= DT_WORDBREAK;
260 }
261 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
262 uFlags |= DT_NOPREFIX;
263// TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText));
264
265 hdc = GetDC (hwnd);
266 hOldFont = SelectObject (hdc, infoPtr->hFont);
267 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
268 SelectObject (hdc, hOldFont);
269 ReleaseDC (hwnd, hdc);
270
271 lpSize->cx = rc.right - rc.left + 4 +
272 infoPtr->rcMargin.left + infoPtr->rcMargin.right;
273 lpSize->cy = rc.bottom - rc.top + 4 +
274 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top;
275}
276
277static VOID
278TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr)
279{
280 TTTOOL_INFO *toolPtr;
281 RECT rect, wndrect;
282 SIZE size;
283 HDC hdc;
284 NMHDR hdr;
285
286 if (infoPtr->nTool == -1) {
287// TRACE("invalid tool (-1)!\n");
288 return;
289 }
290
291 infoPtr->nCurrentTool = infoPtr->nTool;
292
293// TRACE("Show tooltip pre %d!\n", infoPtr->nTool);
294
295 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool);
296
297 if (infoPtr->szTipText[0] == L'\0') {
298 infoPtr->nCurrentTool = -1;
299 return;
300 }
301
302// TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool);
303 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
304
305 hdr.hwndFrom = hwnd;
306 hdr.idFrom = toolPtr->uId;
307 hdr.code = TTN_SHOW;
308 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
309 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
310
311// TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText));
312
313 TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
314// TRACE("size %d - %d\n", size.cx, size.cy);
315
316 if (toolPtr->uFlags & TTF_CENTERTIP) {
317 RECT rc;
318
319 if (toolPtr->uFlags & TTF_IDISHWND)
320 GetWindowRect ((HWND)toolPtr->uId, &rc);
321 else {
322 rc = toolPtr->rect;
323 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
324 }
325 rect.left = (rc.left + rc.right - size.cx) / 2;
326 rect.top = rc.bottom + 2;
327 }
328 else {
329 GetCursorPos ((LPPOINT)&rect);
330 rect.top += 20;
331 }
332
333// TRACE("pos %d - %d\n", rect.left, rect.top);
334
335 rect.right = rect.left + size.cx;
336 rect.bottom = rect.top + size.cy;
337
338 /* check position */
339 wndrect.right = GetSystemMetrics( SM_CXSCREEN );
340 if( rect.right > wndrect.right ) {
341 rect.left -= rect.right - wndrect.right + 2;
342 rect.right = wndrect.right - 2;
343 }
344 wndrect.bottom = GetSystemMetrics( SM_CYSCREEN );
345 if( rect.bottom > wndrect.bottom ) {
346 RECT rc;
347
348 if (toolPtr->uFlags & TTF_IDISHWND)
349 GetWindowRect ((HWND)toolPtr->uId, &rc);
350 else {
351 rc = toolPtr->rect;
352 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
353 }
354 rect.bottom = rc.top - 2;
355 rect.top = rect.bottom - size.cy;
356 }
357
358 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE),
359 FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE));
360
361 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
362 rect.right - rect.left, rect.bottom - rect.top,
363 SWP_SHOWWINDOW | SWP_NOACTIVATE);
364
365 /* repaint the tooltip */
366 hdc = GetDC (hwnd);
367 TOOLTIPS_Refresh (hwnd, hdc);
368 ReleaseDC (hwnd, hdc);
369
370 SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
371}
372
373
374static VOID
375TOOLTIPS_Hide (HWND hwnd, TOOLTIPS_INFO *infoPtr)
376{
377 TTTOOL_INFO *toolPtr;
378 NMHDR hdr;
379
380 if (infoPtr->nCurrentTool == -1)
381 return;
382
383 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
384// TRACE (tooltips, "Hide tooltip %d!\n", infoPtr->nCurrentTool);
385 KillTimer (hwnd, ID_TIMERPOP);
386
387 hdr.hwndFrom = hwnd;
388 hdr.idFrom = toolPtr->uId;
389 hdr.code = TTN_POP;
390 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
391 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
392
393 infoPtr->nCurrentTool = -1;
394
395 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
396 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
397}
398
399
400static VOID
401TOOLTIPS_TrackShow (HWND hwnd, TOOLTIPS_INFO *infoPtr)
402{
403 TTTOOL_INFO *toolPtr;
404 RECT rect;
405 HDC hdc;
406 NMHDR hdr;
407
408 if (infoPtr->nTrackTool == -1)
409 {
410// TRACE (tooltips, "invalid tracking tool (-1)!\n");
411 return;
412 }
413
414// TRACE (tooltips, "show tracking tooltip pre %d!\n", infoPtr->nTrackTool);
415
416 TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nTrackTool);
417
418 if (infoPtr->szTipText[0] == '\0')
419 {
420 infoPtr->nTrackTool = -1;
421 return;
422 }
423
424// TRACE (tooltips, "show tracking tooltip %d!\n", infoPtr->nTrackTool);
425 toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
426
427 hdr.hwndFrom = hwnd;
428 hdr.idFrom = toolPtr->uId;
429 hdr.code = TTN_SHOW;
430 SendMessageA(toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&hdr);
431
432// TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
433
434 TOOLTIPS_CalcTipRect(hwnd,infoPtr,toolPtr,&rect);
435
436 SetWindowPos (hwnd,HWND_TOP,rect.left,rect.top,
437 rect.right-rect.left,rect.bottom-rect.top,
438 SWP_SHOWWINDOW | SWP_NOACTIVATE );
439
440 hdc = GetDC (hwnd);
441 TOOLTIPS_Refresh (hwnd, hdc);
442 ReleaseDC (hwnd, hdc);
443}
444
445
446static VOID
447TOOLTIPS_TrackHide (HWND hwnd, TOOLTIPS_INFO *infoPtr)
448{
449 TTTOOL_INFO *toolPtr;
450 NMHDR hdr;
451
452 if (infoPtr->nTrackTool == -1)
453 return;
454
455 toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
456// TRACE (tooltips, "hide tracking tooltip %d!\n", infoPtr->nTrackTool);
457
458 hdr.hwndFrom = hwnd;
459 hdr.idFrom = toolPtr->uId;
460 hdr.code = TTN_POP;
461 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
462 (WPARAM)toolPtr->uId, (LPARAM)&hdr);
463
464 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
465 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
466}
467
468
469static INT
470TOOLTIPS_GetToolFromInfoA (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOA lpToolInfo)
471{
472 TTTOOL_INFO *toolPtr;
473 INT nTool;
474
475 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
476 toolPtr = &infoPtr->tools[nTool];
477
478 if (!(toolPtr->uFlags & TTF_IDISHWND) &&
479 (lpToolInfo->hwnd == toolPtr->hwnd) &&
480 (lpToolInfo->uId == toolPtr->uId))
481 return nTool;
482 }
483
484 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
485 toolPtr = &infoPtr->tools[nTool];
486
487 if ((toolPtr->uFlags & TTF_IDISHWND) &&
488 (lpToolInfo->uId == toolPtr->uId))
489 return nTool;
490 }
491
492 return -1;
493}
494
495
496static INT
497TOOLTIPS_GetToolFromInfoW (TOOLTIPS_INFO *infoPtr, LPTTTOOLINFOW lpToolInfo)
498{
499 TTTOOL_INFO *toolPtr;
500 INT nTool;
501
502 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
503 toolPtr = &infoPtr->tools[nTool];
504
505 if (!(toolPtr->uFlags & TTF_IDISHWND) &&
506 (lpToolInfo->hwnd == toolPtr->hwnd) &&
507 (lpToolInfo->uId == toolPtr->uId))
508 return nTool;
509 }
510
511 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
512 toolPtr = &infoPtr->tools[nTool];
513
514 if ((toolPtr->uFlags & TTF_IDISHWND) &&
515 (lpToolInfo->uId == toolPtr->uId))
516 return nTool;
517 }
518
519 return -1;
520}
521
522
523static INT
524TOOLTIPS_GetToolFromPoint (TOOLTIPS_INFO *infoPtr, HWND hwnd, LPPOINT lpPt)
525{
526 TTTOOL_INFO *toolPtr;
527 INT nTool;
528
529 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
530 toolPtr = &infoPtr->tools[nTool];
531
532 if (!(toolPtr->uFlags & TTF_IDISHWND)) {
533 if (hwnd != toolPtr->hwnd)
534 continue;
535 if (!PtInRect (&toolPtr->rect, *lpPt))
536 continue;
537 return nTool;
538 }
539 }
540
541 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) {
542 toolPtr = &infoPtr->tools[nTool];
543
544 if (toolPtr->uFlags & TTF_IDISHWND) {
545 if ((HWND)toolPtr->uId == hwnd)
546 return nTool;
547 }
548 }
549
550 return -1;
551}
552
553
554static INT
555TOOLTIPS_GetToolFromMessage (TOOLTIPS_INFO *infoPtr, HWND hwndTool)
556{
557 DWORD dwPos;
558 POINT pt;
559
560 dwPos = GetMessagePos ();
561 pt.x = (INT)LOWORD(dwPos);
562 pt.y = (INT)HIWORD(dwPos);
563 ScreenToClient (hwndTool, &pt);
564
565 return TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
566}
567
568
569static BOOL
570TOOLTIPS_IsWindowActive (HWND hwnd)
571{
572 HWND hwndActive = GetActiveWindow ();
573 if (!hwndActive)
574 return FALSE;
575 if (hwndActive == hwnd)
576 return TRUE;
577 return IsChild (hwndActive, hwnd);
578}
579
580
581static INT
582TOOLTIPS_CheckTool (HWND hwnd, BOOL bShowTest)
583{
584 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
585 POINT pt;
586 HWND hwndTool;
587 INT nTool;
588
589 GetCursorPos (&pt);
590 hwndTool = SendMessageA (hwnd, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt);
591 if (hwndTool == 0)
592 return -1;
593
594 ScreenToClient (hwndTool, &pt);
595 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt);
596 if (nTool == -1)
597 return -1;
598
599 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) {
600 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER)))
601 return -1;
602 }
603
604// TRACE (tooltips, "tool %d\n", nTool);
605
606 return nTool;
607}
608
609
610static LRESULT
611TOOLTIPS_Activate (HWND hwnd, WPARAM wParam, LPARAM lParam)
612{
613 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
614
615 infoPtr->bActive = (BOOL)wParam;
616
617// if (infoPtr->bActive)
618// TRACE (tooltips, "activate!\n");
619
620 if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1))
621 TOOLTIPS_Hide (hwnd, infoPtr);
622
623 return 0;
624}
625
626
627static VOID TOOLTIPS_Subclass(HWND hwnd,TTTOOL_INFO *toolPtr)
628{
629 if (toolPtr->uFlags & TTF_SUBCLASS)
630 {
631 if (toolPtr->uFlags & TTF_IDISHWND)
632 {
633 LPTT_SUBCLASS_INFO lpttsi =
634 (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
635 if (lpttsi == NULL)
636 {
637 lpttsi = (LPTT_SUBCLASS_INFO)COMCTL32_Alloc(sizeof(TT_SUBCLASS_INFO));
638 lpttsi->wpOrigProc =
639 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
640 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
641 lpttsi->hwndToolTip = hwnd;
642 lpttsi->uRefCount++;
643 SetPropA ((HWND)toolPtr->uId,COMCTL32_aSubclass,(HANDLE)lpttsi);
644 }
645// else
646// WARN (tooltips, "A window tool must only be listed once!\n");
647 } else
648 {
649 LPTT_SUBCLASS_INFO lpttsi =
650 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
651 if (lpttsi == NULL)
652 {
653 lpttsi = (LPTT_SUBCLASS_INFO)COMCTL32_Alloc(sizeof(TT_SUBCLASS_INFO));
654 lpttsi->wpOrigProc =
655 (WNDPROC)SetWindowLongA (toolPtr->hwnd,
656 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
657 lpttsi->hwndToolTip = hwnd;
658 lpttsi->uRefCount++;
659 SetPropA(toolPtr->hwnd,COMCTL32_aSubclass,(HANDLE)lpttsi);
660 } else lpttsi->uRefCount++;
661 }
662// TRACE (tooltips, "subclassing installed!\n");
663 }
664}
665
666static VOID TOOLTIPS_Desubclass(TTTOOL_INFO *toolPtr)
667{
668 if (toolPtr->uFlags & TTF_SUBCLASS)
669 {
670 if (toolPtr->uFlags & TTF_IDISHWND)
671 {
672 LPTT_SUBCLASS_INFO lpttsi =
673 (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
674 if (lpttsi)
675 {
676 SetWindowLongA ((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc);
677 RemovePropA ((HWND)toolPtr->uId,COMCTL32_aSubclass);
678 COMCTL32_Free(&lpttsi);
679 }
680// else
681// ERR (tooltips, "Invalid data handle!\n");
682 } else
683 {
684 LPTT_SUBCLASS_INFO lpttsi =
685 (LPTT_SUBCLASS_INFO)GetPropA(toolPtr->hwnd,COMCTL32_aSubclass);
686 if (lpttsi)
687 {
688 if (lpttsi->uRefCount == 1)
689 {
690 SetWindowLongA((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc);
691 RemovePropA((HWND)toolPtr->uId,COMCTL32_aSubclass);
692 COMCTL32_Free(&lpttsi);
693 } else lpttsi->uRefCount--;
694 }
695// else
696// ERR (tooltips, "Invalid data handle!\n");
697 }
698 }
699}
700
701static LRESULT
702TOOLTIPS_AddToolA(HWND hwnd,WPARAM wParam,LPARAM lParam)
703{
704 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
705 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
706 TTTOOL_INFO *toolPtr;
707
708 if (lpToolInfo == NULL) return FALSE;
709 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
710
711// TRACE (tooltips, "add tool (%x) %x %d%s!\n",
712// hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
713// (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
714
715 if (infoPtr->uNumTools == 0)
716 {
717 infoPtr->tools = COMCTL32_Alloc(sizeof(TTTOOL_INFO));
718 toolPtr = infoPtr->tools;
719 } else
720 {
721 TTTOOL_INFO *oldTools = infoPtr->tools;
722 INT x;
723
724 toolPtr = NULL;
725
726 //check if toolinfo already exists
727 for (x = 0;x < infoPtr->uNumTools;x++)
728 {
729 if (lpToolInfo->hwnd == infoPtr->tools[x].hwnd && lpToolInfo->uId == infoPtr->tools[x].uId)
730 {
731 //return toolPtr
732 toolPtr = &infoPtr->tools[x];
733 //free allocated memory
734 TOOLTIPS_Desubclass(toolPtr);
735 if ((toolPtr->hinst) && (toolPtr->lpszText))
736 {
737 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText);
738 }
739
740 break;
741 }
742 }
743
744 if (toolPtr == NULL)
745 {
746 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1));
747 memcpy(infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO));
748 COMCTL32_Free(oldTools);
749 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
750 }
751 }
752
753 infoPtr->uNumTools++;
754
755 /* copy tool data */
756 toolPtr->uFlags = lpToolInfo->uFlags;
757 toolPtr->hwnd = lpToolInfo->hwnd;
758 toolPtr->uId = lpToolInfo->uId;
759 toolPtr->rect = lpToolInfo->rect;
760 toolPtr->hinst = lpToolInfo->hinst;
761
762 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0))
763 {
764// TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
765 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
766 } else if (lpToolInfo->lpszText)
767 {
768 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
769 {
770// TRACE (tooltips, "add CALLBACK!\n");
771 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
772 } else
773 {
774 INT len = lstrlenA (lpToolInfo->lpszText);
775// TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText);
776 toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
777 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
778 }
779 } else toolPtr->lpszText = NULL;
780
781 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
782 toolPtr->lParam = lpToolInfo->lParam;
783
784 /* install subclassing hook */
785 TOOLTIPS_Subclass(hwnd,toolPtr);
786
787 return TRUE;
788}
789
790
791static LRESULT
792TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
793{
794 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
795 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
796 TTTOOL_INFO *toolPtr;
797
798 if (lpToolInfo == NULL)
799 return FALSE;
800 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
801 return FALSE;
802
803// TRACE (tooltips, "add tool (%x) %x %d%s!\n",
804// hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
805// (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
806
807 if (infoPtr->uNumTools == 0)
808 {
809 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
810 toolPtr = infoPtr->tools;
811 } else
812 {
813 TTTOOL_INFO *oldTools = infoPtr->tools;
814 INT x;
815
816 toolPtr = NULL;
817
818 //check if toolinfo already exists
819 for (x = 0;x < infoPtr->uNumTools;x++)
820 {
821 if (lpToolInfo->hwnd == infoPtr->tools[x].hwnd && lpToolInfo->uId == infoPtr->tools[x].uId)
822 {
823 //return toolPtr
824 toolPtr = &infoPtr->tools[x];
825 //free allocated memory
826 TOOLTIPS_Desubclass(toolPtr);
827 if ((toolPtr->hinst) && (toolPtr->lpszText))
828 {
829 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText);
830 }
831
832 break;
833 }
834 }
835
836 if (toolPtr == NULL)
837 {
838 infoPtr->tools = COMCTL32_Alloc(sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1));
839 memcpy (infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO));
840 COMCTL32_Free(oldTools);
841 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
842 }
843 }
844
845 infoPtr->uNumTools++;
846
847 /* copy tool data */
848 toolPtr->uFlags = lpToolInfo->uFlags;
849 toolPtr->hwnd = lpToolInfo->hwnd;
850 toolPtr->uId = lpToolInfo->uId;
851 toolPtr->rect = lpToolInfo->rect;
852 toolPtr->hinst = lpToolInfo->hinst;
853
854 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
855// TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
856 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
857 }
858 else if (lpToolInfo->lpszText) {
859 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
860// TRACE (tooltips, "add CALLBACK!\n");
861 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
862 }
863 else {
864 INT len = lstrlenW (lpToolInfo->lpszText);
865// TRACE (tooltips, "add text \"%s\"!\n",
866// debugstr_w(lpToolInfo->lpszText));
867 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
868 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
869 }
870 }
871
872 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
873 toolPtr->lParam = lpToolInfo->lParam;
874
875 /* install subclassing hook */
876 TOOLTIPS_Subclass(hwnd,toolPtr);
877
878 return TRUE;
879}
880
881
882static LRESULT
883TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
884{
885 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
886 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
887 TTTOOL_INFO *toolPtr;
888 INT nTool;
889
890 if (lpToolInfo == NULL)
891 return 0;
892 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
893 return 0;
894 if (infoPtr->uNumTools == 0)
895 return 0;
896
897 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
898 if (nTool == -1) return 0;
899
900// TRACE (tooltips, "tool %d\n", nTool);
901
902 /* delete text string */
903 toolPtr = &infoPtr->tools[nTool];
904 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
905 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
906 (HIWORD((INT)toolPtr->lpszText) != 0) )
907 COMCTL32_Free (toolPtr->lpszText);
908 }
909
910 /* remove subclassing */
911 TOOLTIPS_Desubclass(toolPtr);
912
913 /* delete tool from tool list */
914 if (infoPtr->uNumTools == 1) {
915 COMCTL32_Free (infoPtr->tools);
916 infoPtr->tools = NULL;
917 }
918 else {
919 TTTOOL_INFO *oldTools = infoPtr->tools;
920 infoPtr->tools =
921 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
922
923 if (nTool > 0)
924 memcpy (&infoPtr->tools[0], &oldTools[0],
925 nTool * sizeof(TTTOOL_INFO));
926
927 if (nTool < infoPtr->uNumTools - 1)
928 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
929 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
930
931 COMCTL32_Free (oldTools);
932 }
933
934 infoPtr->uNumTools--;
935
936 return 0;
937}
938
939
940static LRESULT
941TOOLTIPS_DelToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
942{
943 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
944 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
945 TTTOOL_INFO *toolPtr;
946 INT nTool;
947
948 if (lpToolInfo == NULL)
949 return 0;
950 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
951 return 0;
952 if (infoPtr->uNumTools == 0)
953 return 0;
954
955 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
956 if (nTool == -1) return 0;
957
958// TRACE (tooltips, "tool %d\n", nTool);
959
960 /* delete text string */
961 toolPtr = &infoPtr->tools[nTool];
962 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
963 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
964 (HIWORD((INT)toolPtr->lpszText) != 0) )
965 COMCTL32_Free (toolPtr->lpszText);
966 }
967
968 /* remove subclassing */
969 TOOLTIPS_Desubclass(toolPtr);
970
971 /* delete tool from tool list */
972 if (infoPtr->uNumTools == 1) {
973 COMCTL32_Free (infoPtr->tools);
974 infoPtr->tools = NULL;
975 }
976 else {
977 TTTOOL_INFO *oldTools = infoPtr->tools;
978 infoPtr->tools =
979 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
980
981 if (nTool > 0)
982 memcpy (&infoPtr->tools[0], &oldTools[0],
983 nTool * sizeof(TTTOOL_INFO));
984
985 if (nTool < infoPtr->uNumTools - 1)
986 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
987 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
988
989 COMCTL32_Free (oldTools);
990 }
991
992 infoPtr->uNumTools--;
993
994 return 0;
995}
996
997
998static LRESULT
999TOOLTIPS_EnumToolsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1000{
1001 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1002 UINT uIndex = (UINT)wParam;
1003 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1004 TTTOOL_INFO *toolPtr;
1005
1006 if (lpToolInfo == NULL)
1007 return FALSE;
1008 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1009 return FALSE;
1010 if (uIndex >= infoPtr->uNumTools)
1011 return FALSE;
1012
1013// TRACE (tooltips, "index=%u\n", uIndex);
1014
1015 toolPtr = &infoPtr->tools[uIndex];
1016
1017 /* copy tool data */
1018 lpToolInfo->uFlags = toolPtr->uFlags;
1019 lpToolInfo->hwnd = toolPtr->hwnd;
1020 lpToolInfo->uId = toolPtr->uId;
1021 lpToolInfo->rect = toolPtr->rect;
1022 lpToolInfo->hinst = toolPtr->hinst;
1023/* lpToolInfo->lpszText = toolPtr->lpszText; */
1024 lpToolInfo->lpszText = NULL; /* FIXME */
1025
1026 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1027 lpToolInfo->lParam = toolPtr->lParam;
1028
1029 return TRUE;
1030}
1031
1032
1033static LRESULT
1034TOOLTIPS_EnumToolsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1035{
1036 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1037 UINT uIndex = (UINT)wParam;
1038 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1039 TTTOOL_INFO *toolPtr;
1040
1041 if (lpToolInfo == NULL)
1042 return FALSE;
1043 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1044 return FALSE;
1045 if (uIndex >= infoPtr->uNumTools)
1046 return FALSE;
1047
1048// TRACE (tooltips, "index=%u\n", uIndex);
1049
1050 toolPtr = &infoPtr->tools[uIndex];
1051
1052 /* copy tool data */
1053 lpToolInfo->uFlags = toolPtr->uFlags;
1054 lpToolInfo->hwnd = toolPtr->hwnd;
1055 lpToolInfo->uId = toolPtr->uId;
1056 lpToolInfo->rect = toolPtr->rect;
1057 lpToolInfo->hinst = toolPtr->hinst;
1058/* lpToolInfo->lpszText = toolPtr->lpszText; */
1059 lpToolInfo->lpszText = NULL; /* FIXME */
1060
1061 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1062 lpToolInfo->lParam = toolPtr->lParam;
1063
1064 return TRUE;
1065}
1066
1067
1068static LRESULT
1069TOOLTIPS_GetCurrentToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1070{
1071 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1072 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1073 TTTOOL_INFO *toolPtr;
1074
1075 if (lpToolInfo == NULL)
1076 return FALSE;
1077 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1078 return FALSE;
1079
1080 if (lpToolInfo) {
1081 if (infoPtr->nCurrentTool > -1) {
1082 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1083
1084 /* copy tool data */
1085 lpToolInfo->uFlags = toolPtr->uFlags;
1086 lpToolInfo->rect = toolPtr->rect;
1087 lpToolInfo->hinst = toolPtr->hinst;
1088/* lpToolInfo->lpszText = toolPtr->lpszText; */
1089 lpToolInfo->lpszText = NULL; /* FIXME */
1090
1091 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1092 lpToolInfo->lParam = toolPtr->lParam;
1093
1094 return TRUE;
1095 }
1096 else
1097 return FALSE;
1098 }
1099 else
1100 return (infoPtr->nCurrentTool != -1);
1101
1102 return FALSE;
1103}
1104
1105
1106static LRESULT
1107TOOLTIPS_GetCurrentToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1108{
1109 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1110 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1111 TTTOOL_INFO *toolPtr;
1112
1113 if (lpToolInfo == NULL)
1114 return FALSE;
1115 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1116 return FALSE;
1117
1118 if (lpToolInfo) {
1119 if (infoPtr->nCurrentTool > -1) {
1120 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1121
1122 /* copy tool data */
1123 lpToolInfo->uFlags = toolPtr->uFlags;
1124 lpToolInfo->rect = toolPtr->rect;
1125 lpToolInfo->hinst = toolPtr->hinst;
1126/* lpToolInfo->lpszText = toolPtr->lpszText; */
1127 lpToolInfo->lpszText = NULL; /* FIXME */
1128
1129 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1130 lpToolInfo->lParam = toolPtr->lParam;
1131
1132 return TRUE;
1133 }
1134 else
1135 return FALSE;
1136 }
1137 else
1138 return (infoPtr->nCurrentTool != -1);
1139
1140 return FALSE;
1141}
1142
1143
1144static LRESULT
1145TOOLTIPS_GetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
1146{
1147 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1148
1149 switch (wParam) {
1150 case TTDT_AUTOMATIC:
1151 return infoPtr->nAutomaticTime;
1152
1153 case TTDT_RESHOW:
1154 return infoPtr->nReshowTime;
1155
1156 case TTDT_AUTOPOP:
1157 return infoPtr->nAutoPopTime;
1158
1159 case TTDT_INITIAL:
1160 return infoPtr->nInitialTime;
1161 }
1162
1163 return 0;
1164}
1165
1166
1167static LRESULT
1168TOOLTIPS_GetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1169{
1170 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1171 LPRECT lpRect = (LPRECT)lParam;
1172
1173 lpRect->left = infoPtr->rcMargin.left;
1174 lpRect->right = infoPtr->rcMargin.right;
1175 lpRect->bottom = infoPtr->rcMargin.bottom;
1176 lpRect->top = infoPtr->rcMargin.top;
1177
1178 return 0;
1179}
1180
1181
1182static LRESULT
1183TOOLTIPS_GetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1184{
1185 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1186
1187 return infoPtr->nMaxTipWidth;
1188}
1189
1190
1191static LRESULT
1192TOOLTIPS_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1193{
1194 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1195 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1196 INT nTool;
1197
1198 if (lpToolInfo == NULL)
1199 return 0;
1200 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1201 return 0;
1202
1203 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1204 if (nTool == -1) return 0;
1205
1206 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); //CB: get text
1207
1208 lstrcpyWtoA(lpToolInfo->lpszText,infoPtr->szTipText);
1209
1210 return 0;
1211}
1212
1213
1214static LRESULT
1215TOOLTIPS_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1216{
1217 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1218 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1219 INT nTool;
1220
1221 if (lpToolInfo == NULL)
1222 return 0;
1223 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1224 return 0;
1225
1226 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1227 if (nTool == -1) return 0;
1228
1229 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); //CB: get text
1230
1231 lstrcpyW(lpToolInfo->lpszText,infoPtr->szTipText);
1232
1233 return 0;
1234}
1235
1236
1237static LRESULT
1238TOOLTIPS_GetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1239{
1240 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1241 return infoPtr->clrBk;
1242}
1243
1244
1245static LRESULT
1246TOOLTIPS_GetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1247{
1248 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1249 return infoPtr->clrText;
1250}
1251
1252
1253static LRESULT
1254TOOLTIPS_GetToolCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1255{
1256 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1257 return infoPtr->uNumTools;
1258}
1259
1260
1261static LRESULT
1262TOOLTIPS_GetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1263{
1264 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1265 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1266 TTTOOL_INFO *toolPtr;
1267 INT nTool;
1268
1269 if (lpToolInfo == NULL)
1270 return FALSE;
1271 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1272 return FALSE;
1273 if (infoPtr->uNumTools == 0)
1274 return FALSE;
1275
1276 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1277 if (nTool == -1)
1278 return FALSE;
1279
1280// TRACE (tooltips, "tool %d\n", nTool);
1281
1282 toolPtr = &infoPtr->tools[nTool];
1283
1284 /* copy tool data */
1285 lpToolInfo->uFlags = toolPtr->uFlags;
1286 lpToolInfo->rect = toolPtr->rect;
1287 lpToolInfo->hinst = toolPtr->hinst;
1288/* lpToolInfo->lpszText = toolPtr->lpszText; */
1289 lpToolInfo->lpszText = NULL; /* FIXME */
1290
1291 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1292 lpToolInfo->lParam = toolPtr->lParam;
1293
1294 return TRUE;
1295}
1296
1297
1298static LRESULT
1299TOOLTIPS_GetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1300{
1301 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1302 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1303 TTTOOL_INFO *toolPtr;
1304 INT nTool;
1305
1306 if (lpToolInfo == NULL)
1307 return FALSE;
1308 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1309 return FALSE;
1310 if (infoPtr->uNumTools == 0)
1311 return FALSE;
1312
1313 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1314 if (nTool == -1)
1315 return FALSE;
1316
1317// TRACE (tooltips, "tool %d\n", nTool);
1318
1319 toolPtr = &infoPtr->tools[nTool];
1320
1321 /* copy tool data */
1322 lpToolInfo->uFlags = toolPtr->uFlags;
1323 lpToolInfo->rect = toolPtr->rect;
1324 lpToolInfo->hinst = toolPtr->hinst;
1325/* lpToolInfo->lpszText = toolPtr->lpszText; */
1326 lpToolInfo->lpszText = NULL; /* FIXME */
1327
1328 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1329 lpToolInfo->lParam = toolPtr->lParam;
1330
1331 return TRUE;
1332}
1333
1334
1335static LRESULT
1336TOOLTIPS_HitTestA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1337{
1338 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1339 LPTTHITTESTINFOA lptthit = (LPTTHITTESTINFOA)lParam;
1340 TTTOOL_INFO *toolPtr;
1341 INT nTool;
1342
1343 if (lptthit == 0)
1344 return FALSE;
1345
1346 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1347 if (nTool == -1)
1348 return FALSE;
1349
1350// TRACE (tooltips, "tool %d!\n", nTool);
1351
1352 /* copy tool data */
1353 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) {
1354 toolPtr = &infoPtr->tools[nTool];
1355
1356 lptthit->ti.uFlags = toolPtr->uFlags;
1357 lptthit->ti.hwnd = toolPtr->hwnd;
1358 lptthit->ti.uId = toolPtr->uId;
1359 lptthit->ti.rect = toolPtr->rect;
1360 lptthit->ti.hinst = toolPtr->hinst;
1361/* lptthit->ti.lpszText = toolPtr->lpszText; */
1362 lptthit->ti.lpszText = NULL; /* FIXME */
1363 lptthit->ti.lParam = toolPtr->lParam;
1364 }
1365
1366 return TRUE;
1367}
1368
1369
1370static LRESULT
1371TOOLTIPS_HitTestW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1372{
1373 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1374 LPTTHITTESTINFOW lptthit = (LPTTHITTESTINFOW)lParam;
1375 TTTOOL_INFO *toolPtr;
1376 INT nTool;
1377
1378 if (lptthit == 0)
1379 return FALSE;
1380
1381 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1382 if (nTool == -1)
1383 return FALSE;
1384
1385// TRACE (tooltips, "tool %d!\n", nTool);
1386
1387 /* copy tool data */
1388 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) {
1389 toolPtr = &infoPtr->tools[nTool];
1390
1391 lptthit->ti.uFlags = toolPtr->uFlags;
1392 lptthit->ti.hwnd = toolPtr->hwnd;
1393 lptthit->ti.uId = toolPtr->uId;
1394 lptthit->ti.rect = toolPtr->rect;
1395 lptthit->ti.hinst = toolPtr->hinst;
1396/* lptthit->ti.lpszText = toolPtr->lpszText; */
1397 lptthit->ti.lpszText = NULL; /* FIXME */
1398 lptthit->ti.lParam = toolPtr->lParam;
1399 }
1400
1401 return TRUE;
1402}
1403
1404
1405static LRESULT
1406TOOLTIPS_NewToolRectA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1407{
1408 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1409 LPTTTOOLINFOA lpti = (LPTTTOOLINFOA)lParam;
1410 INT nTool;
1411
1412 if (lpti == NULL)
1413 return 0;
1414 if (lpti->cbSize < TTTOOLINFO_V1_SIZEA)
1415 return FALSE;
1416
1417 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti);
1418 if (nTool == -1) return 0;
1419
1420 infoPtr->tools[nTool].rect = lpti->rect;
1421
1422 return 0;
1423}
1424
1425
1426static LRESULT
1427TOOLTIPS_NewToolRectW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1428{
1429 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1430 LPTTTOOLINFOW lpti = (LPTTTOOLINFOW)lParam;
1431 INT nTool;
1432
1433 if (lpti == NULL)
1434 return 0;
1435 if (lpti->cbSize < TTTOOLINFO_V1_SIZEW)
1436 return FALSE;
1437
1438 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti);
1439 if (nTool == -1) return 0;
1440
1441 infoPtr->tools[nTool].rect = lpti->rect;
1442
1443 return 0;
1444}
1445
1446
1447static LRESULT
1448TOOLTIPS_Pop (HWND hwnd, WPARAM wParam, LPARAM lParam)
1449{
1450 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1451
1452 TOOLTIPS_Hide (hwnd, infoPtr);
1453
1454 return 0;
1455}
1456
1457
1458static LRESULT
1459TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1460{
1461 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1462 LPMSG lpMsg = (LPMSG)lParam;
1463 POINT pt;
1464
1465 if (lParam == 0)
1466 {
1467// ERR (tooltips, "lpMsg == NULL!\n");
1468 return 0;
1469 }
1470
1471 switch (lpMsg->message)
1472 {
1473 case WM_LBUTTONDOWN:
1474 case WM_LBUTTONUP:
1475 case WM_MBUTTONDOWN:
1476 case WM_MBUTTONUP:
1477 case WM_RBUTTONDOWN:
1478 case WM_RBUTTONUP:
1479 pt = lpMsg->pt;
1480 ScreenToClient(lpMsg->hwnd,&pt);
1481 infoPtr->nOldTool = infoPtr->nTool;
1482 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt);
1483// TRACE (tooltips, "tool (%x) %d %d\n",
1484// hwnd, infoPtr->nOldTool, infoPtr->nTool);
1485 TOOLTIPS_Hide (hwnd, infoPtr);
1486 break;
1487
1488 case WM_MOUSEMOVE:
1489 pt = lpMsg->pt;
1490 ScreenToClient(lpMsg->hwnd,&pt);
1491 infoPtr->nOldTool = infoPtr->nTool;
1492 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt);
1493// TRACE (tooltips, "tool (%x) %d %d\n",
1494// hwnd, infoPtr->nOldTool, infoPtr->nTool);
1495// TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n",
1496// hwnd, pt.x, pt.y);
1497
1498 if (infoPtr->bActive && (infoPtr->nTool != infoPtr->nOldTool))
1499 {
1500 if (infoPtr->nOldTool == -1)
1501 {
1502 SetTimer(hwnd,ID_TIMERSHOW,infoPtr->nInitialTime,0);
1503// TRACE (tooltips, "timer 1 started!\n");
1504 } else
1505 {
1506 TOOLTIPS_Hide(hwnd,infoPtr);
1507 SetTimer (hwnd,ID_TIMERSHOW,infoPtr->nReshowTime,0);
1508// TRACE (tooltips, "timer 2 started!\n");
1509 }
1510 }
1511 if (infoPtr->nCurrentTool != -1)
1512 {
1513 SetTimer(hwnd,ID_TIMERLEAVE,100,0);
1514// TRACE (tooltips, "timer 3 started!\n");
1515 }
1516 break;
1517 }
1518
1519 return 0;
1520}
1521
1522
1523static LRESULT
1524TOOLTIPS_SetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
1525{
1526 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1527 INT nTime = (INT)LOWORD(lParam);
1528
1529 switch (wParam) {
1530 case TTDT_AUTOMATIC:
1531 if (nTime == 0) {
1532 infoPtr->nAutomaticTime = 500;
1533 infoPtr->nReshowTime = 100;
1534 infoPtr->nAutoPopTime = 5000;
1535 infoPtr->nInitialTime = 500;
1536 }
1537 else {
1538 infoPtr->nAutomaticTime = nTime;
1539 infoPtr->nReshowTime = nTime / 5;
1540 infoPtr->nAutoPopTime = nTime * 10;
1541 infoPtr->nInitialTime = nTime;
1542 }
1543 break;
1544
1545 case TTDT_RESHOW:
1546 infoPtr->nReshowTime = nTime;
1547 break;
1548
1549 case TTDT_AUTOPOP:
1550 infoPtr->nAutoPopTime = nTime;
1551 break;
1552
1553 case TTDT_INITIAL:
1554 infoPtr->nInitialTime = nTime;
1555 break;
1556 }
1557
1558 return 0;
1559}
1560
1561
1562static LRESULT
1563TOOLTIPS_SetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1564{
1565 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1566 LPRECT lpRect = (LPRECT)lParam;
1567
1568 infoPtr->rcMargin.left = lpRect->left;
1569 infoPtr->rcMargin.right = lpRect->right;
1570 infoPtr->rcMargin.bottom = lpRect->bottom;
1571 infoPtr->rcMargin.top = lpRect->top;
1572
1573 return 0;
1574}
1575
1576
1577static LRESULT
1578TOOLTIPS_SetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1579{
1580 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1581 INT nTemp = infoPtr->nMaxTipWidth;
1582
1583 infoPtr->nMaxTipWidth = (INT)lParam;
1584
1585 return nTemp;
1586}
1587
1588
1589static LRESULT
1590TOOLTIPS_SetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1591{
1592 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1593
1594 infoPtr->clrBk = (COLORREF)wParam;
1595
1596 return 0;
1597}
1598
1599
1600static LRESULT
1601TOOLTIPS_SetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1602{
1603 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1604
1605 infoPtr->clrText = (COLORREF)wParam;
1606
1607 return 0;
1608}
1609
1610
1611static LRESULT
1612TOOLTIPS_SetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1613{
1614 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1615 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1616 TTTOOL_INFO *toolPtr;
1617 INT nTool;
1618
1619 if (lpToolInfo == NULL)
1620 return 0;
1621 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1622 return 0;
1623
1624 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1625 if (nTool == -1) return 0;
1626
1627// TRACE (tooltips, "tool %d\n", nTool);
1628
1629 toolPtr = &infoPtr->tools[nTool];
1630
1631 /* copy tool data */
1632 toolPtr->uFlags = lpToolInfo->uFlags;
1633 toolPtr->hwnd = lpToolInfo->hwnd;
1634 toolPtr->uId = lpToolInfo->uId;
1635 toolPtr->rect = lpToolInfo->rect;
1636 toolPtr->hinst = lpToolInfo->hinst;
1637
1638 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
1639// TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
1640 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1641 }
1642 else if (lpToolInfo->lpszText) {
1643 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
1644 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1645 else {
1646 if ( (toolPtr->lpszText) &&
1647 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
1648 COMCTL32_Free (toolPtr->lpszText);
1649 toolPtr->lpszText = NULL;
1650 }
1651 if (lpToolInfo->lpszText) {
1652 INT len = lstrlenA (lpToolInfo->lpszText);
1653 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1654 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
1655 }
1656 }
1657 }
1658
1659 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1660 toolPtr->lParam = lpToolInfo->lParam;
1661
1662 return 0;
1663}
1664
1665
1666static LRESULT
1667TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1668{
1669 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1670 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1671 TTTOOL_INFO *toolPtr;
1672 INT nTool;
1673
1674 if (lpToolInfo == NULL)
1675 return 0;
1676 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1677 return 0;
1678
1679 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1680 if (nTool == -1) return 0;
1681
1682// TRACE (tooltips, "tool %d\n", nTool);
1683
1684 toolPtr = &infoPtr->tools[nTool];
1685
1686 /* copy tool data */
1687 toolPtr->uFlags = lpToolInfo->uFlags;
1688 toolPtr->hwnd = lpToolInfo->hwnd;
1689 toolPtr->uId = lpToolInfo->uId;
1690 toolPtr->rect = lpToolInfo->rect;
1691 toolPtr->hinst = lpToolInfo->hinst;
1692
1693 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
1694// TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
1695 toolPtr->lpszText = lpToolInfo->lpszText;
1696 }
1697 else if (lpToolInfo->lpszText) {
1698 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
1699 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1700 else {
1701 if ( (toolPtr->lpszText) &&
1702 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
1703 COMCTL32_Free (toolPtr->lpszText);
1704 toolPtr->lpszText = NULL;
1705 }
1706 if (lpToolInfo->lpszText) {
1707 INT len = lstrlenW (lpToolInfo->lpszText);
1708 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1709 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
1710 }
1711 }
1712 }
1713
1714 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1715 toolPtr->lParam = lpToolInfo->lParam;
1716
1717 return 0;
1718}
1719
1720
1721static LRESULT
1722TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1723{
1724 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1725 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1726
1727 if (lpToolInfo == NULL) return 0;
1728 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
1729
1730 if ((BOOL)wParam)
1731 {
1732 /* activate */
1733 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA(infoPtr,lpToolInfo);
1734 if (infoPtr->nTrackTool != -1)
1735 {
1736// TRACE (tooltips, "activated!\n");
1737 infoPtr->bTrackActive = TRUE;
1738 TOOLTIPS_TrackShow(hwnd,infoPtr);
1739 }
1740 } else
1741 {
1742 /* deactivate */
1743 TOOLTIPS_TrackHide(hwnd,infoPtr);
1744
1745 infoPtr->bTrackActive = FALSE;
1746 infoPtr->nTrackTool = -1;
1747
1748// TRACE (tooltips, "deactivated!\n");
1749 }
1750
1751 return 0;
1752}
1753
1754
1755static LRESULT
1756TOOLTIPS_TrackPosition (HWND hwnd, WPARAM wParam, LPARAM lParam)
1757{
1758 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1759
1760 infoPtr->xTrackPos = (INT)LOWORD(lParam);
1761 infoPtr->yTrackPos = (INT)HIWORD(lParam);
1762
1763 if (infoPtr->bTrackActive)
1764 {
1765// TRACE (tooltips, "[%d %d]\n",
1766// infoPtr->xTrackPos, infoPtr->yTrackPos);
1767 TOOLTIPS_TrackShow(hwnd,infoPtr);
1768 }
1769
1770 return 0;
1771}
1772
1773
1774static LRESULT
1775TOOLTIPS_Update (HWND hwnd, WPARAM wParam, LPARAM lParam)
1776{
1777 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1778
1779 if (infoPtr->nCurrentTool != -1)
1780 UpdateWindow (hwnd);
1781
1782 return 0;
1783}
1784
1785
1786TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1787{
1788 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1789 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1790 TTTOOL_INFO *toolPtr;
1791 INT nTool;
1792
1793 if (lpToolInfo == NULL)
1794 return 0;
1795 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1796 return FALSE;
1797
1798 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1799 if (nTool == -1) return 0;
1800
1801// TRACE("tool %d\n", nTool);
1802
1803 toolPtr = &infoPtr->tools[nTool];
1804
1805 /* copy tool text */
1806 toolPtr->hinst = lpToolInfo->hinst;
1807
1808 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
1809 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1810 }
1811 else if (lpToolInfo->lpszText) {
1812 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
1813 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1814 else {
1815 if ( (toolPtr->lpszText) &&
1816 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
1817 COMCTL32_Free (toolPtr->lpszText);
1818 toolPtr->lpszText = NULL;
1819 }
1820 if (lpToolInfo->lpszText) {
1821 INT len = lstrlenA (lpToolInfo->lpszText);
1822 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1823 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
1824 }
1825 }
1826 }
1827
1828 /* force repaint */
1829 if (infoPtr->bActive)
1830 TOOLTIPS_Show (hwnd, infoPtr);
1831 else if (infoPtr->bTrackActive)
1832 TOOLTIPS_TrackShow (hwnd, infoPtr);
1833
1834 return 0;
1835}
1836
1837
1838static LRESULT
1839TOOLTIPS_UpdateTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1840{
1841 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1842 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1843 TTTOOL_INFO *toolPtr;
1844 INT nTool;
1845
1846 if (lpToolInfo == NULL)
1847 return 0;
1848 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1849 return FALSE;
1850
1851 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1852 if (nTool == -1)
1853 return 0;
1854
1855// TRACE("tool %d\n", nTool);
1856
1857 toolPtr = &infoPtr->tools[nTool];
1858
1859 /* copy tool text */
1860 toolPtr->hinst = lpToolInfo->hinst;
1861
1862 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
1863 toolPtr->lpszText = lpToolInfo->lpszText;
1864 }
1865 else if (lpToolInfo->lpszText) {
1866 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
1867 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1868 else {
1869 if ( (toolPtr->lpszText) &&
1870 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
1871 COMCTL32_Free (toolPtr->lpszText);
1872 toolPtr->lpszText = NULL;
1873 }
1874 if (lpToolInfo->lpszText) {
1875 INT len = lstrlenW (lpToolInfo->lpszText);
1876 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1877 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
1878 }
1879 }
1880 }
1881
1882 /* force repaint */
1883 if (infoPtr->bActive)
1884 TOOLTIPS_Show (hwnd, infoPtr);
1885 else if (infoPtr->bTrackActive)
1886 TOOLTIPS_TrackShow (hwnd, infoPtr);
1887
1888 return 0;
1889}
1890
1891
1892static LRESULT
1893TOOLTIPS_WindowFromPoint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1894{
1895 return WindowFromPoint (*((LPPOINT)lParam));
1896}
1897
1898
1899
1900static LRESULT
1901TOOLTIPS_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1902{
1903 TOOLTIPS_INFO *infoPtr;
1904 NONCLIENTMETRICSA nclm;
1905 INT nResult;
1906
1907 /* allocate memory for info structure */
1908 infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc(sizeof(TOOLTIPS_INFO));
1909 SetWindowLongA(hwnd,0,(DWORD)infoPtr);
1910
1911 /* initialize info structure */
1912 infoPtr->szTipText[0] = '\0';
1913 infoPtr->bActive = TRUE;
1914 infoPtr->bTrackActive = FALSE;
1915 infoPtr->clrBk = GetSysColor(COLOR_INFOBK);
1916 infoPtr->clrText = GetSysColor(COLOR_INFOTEXT);
1917 infoPtr->xTrackPos = 0;
1918 infoPtr->yTrackPos = 0;
1919
1920 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1921 SystemParametersInfoA(SPI_GETNONCLIENTMETRICS,0,&nclm,0);
1922 infoPtr->hFont = CreateFontIndirectA(&nclm.lfStatusFont);
1923
1924 infoPtr->nMaxTipWidth = -1;
1925 infoPtr->nTool = -1;
1926 infoPtr->nOldTool = -1;
1927 infoPtr->nCurrentTool = -1;
1928 infoPtr->nTrackTool = -1;
1929
1930 infoPtr->nAutomaticTime = 500;
1931 infoPtr->nReshowTime = 100;
1932 infoPtr->nAutoPopTime = 5000;
1933 infoPtr->nInitialTime = 500;
1934
1935 SetRectEmpty(&infoPtr->rcMargin);
1936
1937 nResult = (INT)SendMessageA(GetParent(hwnd),WM_NOTIFYFORMAT,(WPARAM)hwnd,(LPARAM)NF_QUERY);
1938// if (nResult == NFR_ANSI)
1939// TRACE (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1940// else if (nResult == NFR_UNICODE)
1941// FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1942// else
1943// FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n");
1944
1945 SetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
1946
1947 return 0;
1948}
1949
1950
1951static LRESULT
1952TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1953{
1954 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
1955 TTTOOL_INFO *toolPtr;
1956 INT i;
1957
1958 /* free tools */
1959 if (infoPtr->tools) {
1960 for (i = 0; i < infoPtr->uNumTools; i++) {
1961 toolPtr = &infoPtr->tools[i];
1962 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
1963 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
1964 (HIWORD((INT)toolPtr->lpszText) != 0) )
1965 {
1966 COMCTL32_Free (toolPtr->lpszText);
1967 toolPtr->lpszText = NULL;
1968 }
1969 }
1970
1971 /* remove subclassing */
1972 if (toolPtr->uFlags & TTF_SUBCLASS) {
1973 LPTT_SUBCLASS_INFO lpttsi;
1974
1975 if (toolPtr->uFlags & TTF_IDISHWND)
1976 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
1977 else
1978 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
1979
1980 if (lpttsi) {
1981 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
1982 (LONG)lpttsi->wpOrigProc);
1983 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
1984 COMCTL32_Free (&lpttsi);
1985 }
1986 }
1987 }
1988 COMCTL32_Free (infoPtr->tools);
1989 }
1990
1991 /* delete font */
1992 DeleteObject (infoPtr->hFont);
1993
1994 /* free tool tips info data */
1995 COMCTL32_Free(infoPtr);
1996
1997 return 0;
1998}
1999
2000
2001static LRESULT
2002TOOLTIPS_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2003{
2004 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2005 RECT rect;
2006 HBRUSH hBrush;
2007
2008 hBrush = CreateSolidBrush (infoPtr->clrBk);
2009 GetClientRect (hwnd, &rect);
2010 FillRect ((HDC)wParam, &rect, hBrush);
2011 DeleteObject (hBrush);
2012
2013 return FALSE;
2014}
2015
2016
2017static LRESULT
2018TOOLTIPS_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2019{
2020 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2021
2022 return infoPtr->hFont;
2023}
2024
2025
2026static LRESULT
2027TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2028{
2029 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2030
2031 TOOLTIPS_Hide (hwnd, infoPtr);
2032
2033 return 0;
2034}
2035
2036
2037static LRESULT
2038TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2039{
2040 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
2041 DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE);
2042
2043 dwStyle &= 0x0000FFFF;
2044 dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS);
2045 SetWindowLongA(hwnd,GWL_STYLE,dwStyle);
2046
2047 SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle | WS_EX_TOOLWINDOW);
2048
2049 return TRUE;
2050}
2051
2052
2053static LRESULT
2054TOOLTIPS_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
2055{
2056 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2057 INT nTool = (infoPtr->bTrackActive) ? infoPtr->nTrackTool : infoPtr->nTool;
2058
2059// TRACE (tooltips, " nTool=%d\n", nTool);
2060
2061 if ((nTool > -1) && (nTool < infoPtr->uNumTools)) {
2062 if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
2063// TRACE (tooltips, "-- in transparent mode!\n");
2064 return HTTRANSPARENT;
2065 }
2066 }
2067
2068 return DefWindowProcA (hwnd, WM_NCHITTEST, wParam, lParam);
2069}
2070
2071static LRESULT
2072TOOLTIPS_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2073{
2074// FIXME ("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
2075
2076 return 0;
2077}
2078
2079static LRESULT
2080TOOLTIPS_Paint (HWND hwnd, WPARAM wParam, LPARAM lParam)
2081{
2082 HDC hdc;
2083 PAINTSTRUCT ps;
2084
2085 hdc = (wParam == 0) ? BeginPaint (hwnd, &ps) : (HDC)wParam;
2086 TOOLTIPS_Refresh (hwnd, hdc);
2087 if (!wParam)
2088 EndPaint (hwnd, &ps);
2089 return 0;
2090}
2091
2092
2093static LRESULT
2094TOOLTIPS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2095{
2096 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2097
2098 infoPtr->hFont = (HFONT)wParam;
2099
2100 if ((LOWORD(lParam)) & (infoPtr->nCurrentTool != -1))
2101 {
2102 /* force repaint */
2103 if (infoPtr->bActive) TOOLTIPS_Show(hwnd,infoPtr);
2104 else if (infoPtr->bTrackActive) TOOLTIPS_TrackShow(hwnd,infoPtr);
2105 }
2106
2107 return 0;
2108}
2109/******************************************************************
2110 * TOOLTIPS_OnWMGetTextLength
2111 *
2112 * This function is called when the tooltip receive a
2113 * WM_GETTEXTLENGTH message.
2114 * wParam : not used
2115 * lParam : not used
2116 *
2117 * returns the length, in characters, of the tip text
2118 ******************************************************************/
2119
2120static LRESULT
2121TOOLTIPS_OnWMGetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam)
2122{
2123 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2124 return lstrlenW(infoPtr->szTipText);
2125}
2126/******************************************************************
2127 * TOOLTIPS_OnWMGetText
2128 *
2129 * This function is called when the tooltip receive a
2130 * WM_GETTEXT message.
2131 * wParam : specifies the maximum number of characters to be copied
2132 * lParam : is the pointer to the buffer that will receive
2133 * the tip text
2134 *
2135 * returns the number of characters copied
2136 ******************************************************************/
2137static LRESULT
2138TOOLTIPS_OnWMGetText (HWND hwnd, WPARAM wParam, LPARAM lParam)
2139{
2140 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2141 INT length;
2142
2143 if(!infoPtr || !(infoPtr->szTipText))
2144 return 0;
2145
2146 length = lstrlenW(infoPtr->szTipText);
2147 /* When wParam is smaller than the lenght of the tip text
2148 copy wParam characters of the tip text and return wParam */
2149 if(wParam < length)
2150 {
2151 lstrcpynWtoA((LPSTR)lParam,infoPtr->szTipText,(UINT)wParam);//includes 0 terminator
2152 return wParam;
2153 }
2154 lstrcpyWtoA((LPSTR)lParam,infoPtr->szTipText);
2155 return length;
2156
2157}
2158
2159static LRESULT
2160TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam)
2161{
2162 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2163
2164// TRACE (tooltips, "timer %d (%x) expired!\n", wParam, hwnd);
2165 switch (wParam)
2166 {
2167 case ID_TIMERSHOW:
2168 KillTimer(hwnd,ID_TIMERSHOW);
2169 if (TOOLTIPS_CheckTool(hwnd,TRUE) == infoPtr->nTool)
2170 TOOLTIPS_Show(hwnd,infoPtr);
2171 break;
2172
2173 case ID_TIMERPOP:
2174 TOOLTIPS_Hide (hwnd, infoPtr);
2175 break;
2176
2177 case ID_TIMERLEAVE:
2178 KillTimer (hwnd,ID_TIMERLEAVE);
2179 if (TOOLTIPS_CheckTool(hwnd,FALSE) == -1)
2180 {
2181 infoPtr->nTool = -1;
2182 infoPtr->nOldTool = -1;
2183 TOOLTIPS_Hide(hwnd,infoPtr);
2184 }
2185 break;
2186 }
2187
2188 return 0;
2189}
2190
2191
2192static LRESULT
2193TOOLTIPS_WinIniChange (HWND hwnd, WPARAM wParam, LPARAM lParam)
2194{
2195 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2196 NONCLIENTMETRICSA nclm;
2197
2198 infoPtr->clrBk = GetSysColor (COLOR_INFOBK);
2199 infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);
2200
2201 DeleteObject (infoPtr->hFont);
2202 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
2203 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
2204 infoPtr->hFont = CreateFontIndirectA (&nclm.lfStatusFont);
2205
2206 return 0;
2207}
2208
2209
2210LRESULT CALLBACK
2211TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2212{
2213 LPTT_SUBCLASS_INFO lpttsi =
2214 (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass);
2215 TOOLTIPS_INFO *infoPtr;
2216 UINT nTool;
2217
2218 switch (uMsg) {
2219 case WM_LBUTTONDOWN:
2220 case WM_LBUTTONUP:
2221 case WM_MBUTTONDOWN:
2222 case WM_MBUTTONUP:
2223 case WM_RBUTTONDOWN:
2224 case WM_RBUTTONUP:
2225 infoPtr = TOOLTIPS_GetInfoPtr(lpttsi->hwndToolTip);
2226 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
2227
2228// TRACE (tooltips, "subclassed mouse message %04x\n", uMsg);
2229 infoPtr->nOldTool = infoPtr->nTool;
2230 infoPtr->nTool = nTool;
2231 TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
2232 break;
2233
2234 case WM_MOUSEMOVE:
2235 infoPtr = TOOLTIPS_GetInfoPtr (lpttsi->hwndToolTip);
2236 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
2237
2238// TRACE (tooltips, "subclassed WM_MOUSEMOVE\n");
2239 infoPtr->nOldTool = infoPtr->nTool;
2240 infoPtr->nTool = nTool;
2241
2242 if ((infoPtr->bActive) &&
2243 (infoPtr->nTool != infoPtr->nOldTool)) {
2244 if (infoPtr->nOldTool == -1) {
2245 SetTimer (hwnd, ID_TIMERSHOW,
2246 infoPtr->nInitialTime, 0);
2247// TRACE (tooltips, "timer 1 started!\n");
2248 }
2249 else {
2250 TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
2251 SetTimer (hwnd, ID_TIMERSHOW,
2252 infoPtr->nReshowTime, 0);
2253// TRACE (tooltips, "timer 2 started!\n");
2254 }
2255 }
2256 if (infoPtr->nCurrentTool != -1) {
2257 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
2258// TRACE (tooltips, "timer 3 started!\n");
2259 }
2260 break;
2261 }
2262
2263 return CallWindowProcA (lpttsi->wpOrigProc, hwnd, uMsg, wParam, lParam);
2264}
2265
2266
2267static LRESULT CALLBACK
2268TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2269{
2270 switch (uMsg)
2271 {
2272 case TTM_ACTIVATE:
2273 return TOOLTIPS_Activate (hwnd, wParam, lParam);
2274
2275 case TTM_ADDTOOLA:
2276 return TOOLTIPS_AddToolA (hwnd, wParam, lParam);
2277
2278 case TTM_ADDTOOLW:
2279 return TOOLTIPS_AddToolW (hwnd, wParam, lParam);
2280
2281 case TTM_DELTOOLA:
2282 return TOOLTIPS_DelToolA (hwnd, wParam, lParam);
2283
2284 case TTM_DELTOOLW:
2285 return TOOLTIPS_DelToolW (hwnd, wParam, lParam);
2286
2287 case TTM_ENUMTOOLSA:
2288 return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam);
2289
2290 case TTM_ENUMTOOLSW:
2291 return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam);
2292
2293 case TTM_GETCURRENTTOOLA:
2294 return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam);
2295
2296 case TTM_GETCURRENTTOOLW:
2297 return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam);
2298
2299 case TTM_GETDELAYTIME:
2300 return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam);
2301
2302 case TTM_GETMARGIN:
2303 return TOOLTIPS_GetMargin (hwnd, wParam, lParam);
2304
2305 case TTM_GETMAXTIPWIDTH:
2306 return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam);
2307
2308 case TTM_GETTEXTA:
2309 return TOOLTIPS_GetTextA (hwnd, wParam, lParam);
2310
2311 case TTM_GETTEXTW:
2312 return TOOLTIPS_GetTextW (hwnd, wParam, lParam);
2313
2314 case TTM_GETTIPBKCOLOR:
2315 return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam);
2316
2317 case TTM_GETTIPTEXTCOLOR:
2318 return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam);
2319
2320 case TTM_GETTOOLCOUNT:
2321 return TOOLTIPS_GetToolCount (hwnd, wParam, lParam);
2322
2323 case TTM_GETTOOLINFOA:
2324 return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam);
2325
2326 case TTM_GETTOOLINFOW:
2327 return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam);
2328
2329 case TTM_HITTESTA:
2330 return TOOLTIPS_HitTestA (hwnd, wParam, lParam);
2331
2332 case TTM_HITTESTW:
2333 return TOOLTIPS_HitTestW (hwnd, wParam, lParam);
2334
2335 case TTM_NEWTOOLRECTA:
2336 return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam);
2337
2338 case TTM_NEWTOOLRECTW:
2339 return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam);
2340
2341 case TTM_POP:
2342 return TOOLTIPS_Pop (hwnd, wParam, lParam);
2343
2344 case TTM_RELAYEVENT:
2345 return TOOLTIPS_RelayEvent (hwnd, wParam, lParam);
2346
2347 case TTM_SETDELAYTIME:
2348 return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam);
2349
2350 case TTM_SETMARGIN:
2351 return TOOLTIPS_SetMargin (hwnd, wParam, lParam);
2352
2353 case TTM_SETMAXTIPWIDTH:
2354 return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam);
2355
2356 case TTM_SETTIPBKCOLOR:
2357 return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam);
2358
2359 case TTM_SETTIPTEXTCOLOR:
2360 return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam);
2361
2362 case TTM_SETTOOLINFOA:
2363 return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam);
2364
2365 case TTM_SETTOOLINFOW:
2366 return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam);
2367
2368 case TTM_TRACKACTIVATE:
2369 return TOOLTIPS_TrackActivate (hwnd, wParam, lParam);
2370
2371 case TTM_TRACKPOSITION:
2372 return TOOLTIPS_TrackPosition (hwnd, wParam, lParam);
2373
2374 case TTM_UPDATE:
2375 return TOOLTIPS_Update (hwnd, wParam, lParam);
2376
2377 case TTM_UPDATETIPTEXTA:
2378 return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam);
2379
2380 case TTM_UPDATETIPTEXTW:
2381 return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam);
2382
2383 case TTM_WINDOWFROMPOINT:
2384 return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam);
2385
2386
2387 case WM_CREATE:
2388 return TOOLTIPS_Create (hwnd, wParam, lParam);
2389
2390 case WM_DESTROY:
2391 return TOOLTIPS_Destroy (hwnd, wParam, lParam);
2392
2393 case WM_ERASEBKGND:
2394 return TOOLTIPS_EraseBackground (hwnd, wParam, lParam);
2395
2396 case WM_GETFONT:
2397 return TOOLTIPS_GetFont (hwnd, wParam, lParam);
2398
2399 case WM_GETTEXT:
2400 return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam);
2401
2402 case WM_GETTEXTLENGTH:
2403 return TOOLTIPS_OnWMGetTextLength (hwnd, wParam, lParam);
2404
2405
2406 case WM_LBUTTONDOWN:
2407 case WM_LBUTTONUP:
2408 case WM_MBUTTONDOWN:
2409 case WM_MBUTTONUP:
2410 case WM_RBUTTONDOWN:
2411 case WM_RBUTTONUP:
2412 case WM_MOUSEMOVE:
2413 return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
2414
2415 case WM_NCCREATE:
2416 return TOOLTIPS_NCCreate (hwnd, wParam, lParam);
2417
2418 case WM_NCHITTEST:
2419 return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
2420
2421 case WM_NOTIFYFORMAT:
2422 return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam);
2423
2424 case WM_PAINT:
2425 return TOOLTIPS_Paint (hwnd, wParam, lParam);
2426
2427 case WM_SETFONT:
2428 return TOOLTIPS_SetFont (hwnd, wParam, lParam);
2429
2430 case WM_TIMER:
2431 return TOOLTIPS_Timer (hwnd, wParam, lParam);
2432
2433 case WM_WININICHANGE:
2434 return TOOLTIPS_WinIniChange (hwnd, wParam, lParam);
2435
2436 default:
2437// if (uMsg >= WM_USER)
2438// ERR (tooltips, "unknown msg %04x wp=%08x lp=%08lx\n",
2439// uMsg, wParam, lParam);
2440 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2441 }
2442 return 0;
2443}
2444
2445
2446VOID
2447TOOLTIPS_Register (VOID)
2448{
2449 WNDCLASSA wndClass;
2450
2451//SvL: Don't check this now
2452// if (GlobalFindAtomA (TOOLTIPS_CLASSA)) return;
2453
2454 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2455 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
2456 wndClass.lpfnWndProc = (WNDPROC)TOOLTIPS_WindowProc;
2457 wndClass.cbClsExtra = 0;
2458 wndClass.cbWndExtra = sizeof(TOOLTIPS_INFO *);
2459 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
2460 wndClass.hbrBackground = 0;
2461 wndClass.lpszClassName = TOOLTIPS_CLASSA;
2462
2463 RegisterClassA (&wndClass);
2464}
2465
2466
2467VOID
2468TOOLTIPS_Unregister (VOID)
2469{
2470 if (GlobalFindAtomA (TOOLTIPS_CLASSA))
2471 UnregisterClassA (TOOLTIPS_CLASSA, (HINSTANCE)NULL);
2472}
2473
Note: See TracBrowser for help on using the repository browser.