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

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

Updates for new DrawEdge and colors

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