source: trunk/src/comctl32/tooltips.cpp@ 2875

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

C -> C++, WINE animate, treeview WM_VSCROLL fixed

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