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

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

comctl32 wine conversion bugs fixed
trackbar: TRACKBAR_Draw prototype

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