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

Last change on this file since 45 was 45, checked in by achimha, 26 years ago

* empty log message *

File size: 60.3 KB
Line 
1/*
2 * Tool tip control
3 *
4 * Copyright 1998 Eric Kohl
5 *
6 * TODO:
7 * - Unicode support.
8 * - Custom draw support.
9 *
10 * Testing:
11 * - Run tests using Waite Group Windows95 API Bible Volume 2.
12 * The second cdrom (chapter 3) contains executables activate.exe,
13 * curtool.exe, deltool.exe, enumtools.exe, getinfo.exe, getiptxt.exe,
14 * hittest.exe, needtext.exe, newrect.exe, updtext.exe and winfrpt.exe.
15 */
16
17#include <string.h>
18
19#include "winbase.h"
20#include "commctrl.h"
21#include "tooltips.h"
22
23
24#define ID_TIMERSHOW 1 /* show delay timer */
25#define ID_TIMERPOP 2 /* auto pop timer */
26#define ID_TIMERLEAVE 3 /* tool leave timer */
27
28
29extern LPSTR COMCTL32_aSubclass; /* global subclassing atom */
30
31/* property name of tooltip window handle */
32/*#define TT_SUBCLASS_PROP "CC32SubclassInfo" */
33
34#define TOOLTIPS_GetInfoPtr(hWindow) ((TOOLTIPS_INFO *)GetWindowLongA (hWindow, 0))
35
36
37LRESULT CALLBACK
38TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
39
40
41static VOID
42TOOLTIPS_Refresh (HWND hwnd, HDC hdc)
43{
44 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
45 RECT rc;
46 INT oldBkMode;
47 HFONT hOldFont;
48 HBRUSH hBrush;
49 UINT uFlags = DT_EXTERNALLEADING;
50
51 if (infoPtr->nMaxTipWidth > -1)
52 uFlags |= DT_WORDBREAK;
53 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)
54 uFlags |= DT_NOPREFIX;
55 GetClientRect (hwnd, &rc);
56
57 /* fill the background */
58 hBrush = CreateSolidBrush (infoPtr->clrBk);
59 FillRect (hdc, &rc, hBrush);
60 DeleteObject (hBrush);
61
62 /* calculate text rectangle */
63 rc.left += (2 + infoPtr->rcMargin.left);
64 rc.top += (2 + infoPtr->rcMargin.top);
65 rc.right -= (2 + infoPtr->rcMargin.right);
66 rc.bottom -= (2 + infoPtr->rcMargin.bottom);
67
68 /* draw text */
69 oldBkMode = SetBkMode (hdc, TRANSPARENT);
70 SetTextColor (hdc, infoPtr->clrText);
71 hOldFont = SelectObject (hdc, infoPtr->hFont);
72 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags);
73 SelectObject (hdc, hOldFont);
74 if (oldBkMode != TRANSPARENT)
75 SetBkMode (hdc, oldBkMode);
76}
77
78
79static VOID
80TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool)
81{
82 TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
83
84 if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) {
85 /* load a resource */
86// TRACE (tooltips, "load res string %x %x\n",
87// toolPtr->hinst, (int)toolPtr->lpszText);
88 LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText,
89 infoPtr->szTipText, INFOTIPSIZE);
90 }
91 else if (toolPtr->lpszText) {
92 if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) {
93 NMTTDISPINFOA ttnmdi;
94
95 /* fill NMHDR struct */
96 ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
97 ttnmdi.hdr.hwndFrom = hwnd;
98 ttnmdi.hdr.idFrom = toolPtr->uId;
99 ttnmdi.hdr.code = TTN_GETDISPINFOA;
100 ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
101 ttnmdi.uFlags = toolPtr->uFlags;
102 ttnmdi.lParam = toolPtr->lParam;
103
104// TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);
105 SendMessageA (toolPtr->hwnd, WM_NOTIFY,
106 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);
107
108 if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0)) {
109 LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.szText,
110 infoPtr->szTipText, INFOTIPSIZE);
111 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
112 toolPtr->hinst = ttnmdi.hinst;
113 toolPtr->lpszText = (LPWSTR)ttnmdi.szText;
114 }
115 }
116 else if (ttnmdi.szText[0]) {
117// lstrcpynAtoW (infoPtr->szTipText, ttnmdi.szText, 80);
118 strncpy(infoPtr->szTipText, ttnmdi.szText, 80);
119 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
120 INT len = lstrlenA (ttnmdi.szText);
121 toolPtr->hinst = 0;
122 toolPtr->lpszText = COMCTL32_Alloc ((len+1)* sizeof(WCHAR));
123// lstrcpyAtoW (toolPtr->lpszText, ttnmdi.szText);
124 strcpy(toolPtr->lpszText, ttnmdi.szText);
125 }
126 }
127 else if (ttnmdi.lpszText == 0) {
128 /* no text available */
129 infoPtr->szTipText[0] = L'\0';
130 }
131 else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) {
132// lstrcpynAtoW (infoPtr->szTipText, ttnmdi.lpszText, INFOTIPSIZE);
133 strncpy(infoPtr->szTipText, ttnmdi.lpszText, INFOTIPSIZE);
134 if (ttnmdi.uFlags & TTF_DI_SETITEM) {
135 INT len = lstrlenA (ttnmdi.lpszText);
136 toolPtr->hinst = 0;
137 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
138// lstrcpyAtoW (toolPtr->lpszText, ttnmdi.lpszText);
139 strcpy(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 strcpy(toolPtr->lpszText, lpToolInfo->lpszText);
619 }
620 }
621
622 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
623 toolPtr->lParam = lpToolInfo->lParam;
624
625 /* install subclassing hook */
626 if (toolPtr->uFlags & TTF_SUBCLASS) {
627 if (toolPtr->uFlags & TTF_IDISHWND) {
628 LPTT_SUBCLASS_INFO lpttsi =
629 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
630 if (lpttsi == NULL) {
631 lpttsi =
632 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
633 lpttsi->wpOrigProc =
634 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
635 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
636 lpttsi->hwndToolTip = hwnd;
637 lpttsi->uRefCount++;
638 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
639 (HANDLE)lpttsi);
640 }
641// else
642// WARN (tooltips, "A window tool must only be listed once!\n");
643 }
644 else {
645 LPTT_SUBCLASS_INFO lpttsi =
646 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
647 if (lpttsi == NULL) {
648 lpttsi =
649 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
650 lpttsi->wpOrigProc =
651 (WNDPROC)SetWindowLongA (toolPtr->hwnd,
652 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
653 lpttsi->hwndToolTip = hwnd;
654 lpttsi->uRefCount++;
655 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
656 }
657 else
658 lpttsi->uRefCount++;
659 }
660// TRACE (tooltips, "subclassing installed!\n");
661 }
662
663 return TRUE;
664}
665
666
667static LRESULT
668TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
669{
670 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
671 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
672 TTTOOL_INFO *toolPtr;
673
674 if (lpToolInfo == NULL)
675 return FALSE;
676 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
677 return FALSE;
678
679// TRACE (tooltips, "add tool (%x) %x %d%s!\n",
680// hwnd, lpToolInfo->hwnd, lpToolInfo->uId,
681// (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");
682
683 if (infoPtr->uNumTools == 0) {
684 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));
685 toolPtr = infoPtr->tools;
686 }
687 else {
688 TTTOOL_INFO *oldTools = infoPtr->tools;
689 infoPtr->tools =
690 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));
691 memcpy (infoPtr->tools, oldTools,
692 infoPtr->uNumTools * sizeof(TTTOOL_INFO));
693 COMCTL32_Free (oldTools);
694 toolPtr = &infoPtr->tools[infoPtr->uNumTools];
695 }
696
697 infoPtr->uNumTools++;
698
699 /* copy tool data */
700 toolPtr->uFlags = lpToolInfo->uFlags;
701 toolPtr->hwnd = lpToolInfo->hwnd;
702 toolPtr->uId = lpToolInfo->uId;
703 toolPtr->rect = lpToolInfo->rect;
704 toolPtr->hinst = lpToolInfo->hinst;
705
706 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
707// TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);
708 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
709 }
710 else if (lpToolInfo->lpszText) {
711 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
712// TRACE (tooltips, "add CALLBACK!\n");
713 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
714 }
715 else {
716 INT len = lstrlenW (lpToolInfo->lpszText);
717// TRACE (tooltips, "add text \"%s\"!\n",
718// debugstr_w(lpToolInfo->lpszText));
719 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
720 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
721 }
722 }
723
724 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
725 toolPtr->lParam = lpToolInfo->lParam;
726
727 /* install subclassing hook */
728 if (toolPtr->uFlags & TTF_SUBCLASS) {
729 if (toolPtr->uFlags & TTF_IDISHWND) {
730 LPTT_SUBCLASS_INFO lpttsi =
731 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
732 if (lpttsi == NULL) {
733 lpttsi =
734 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
735 lpttsi->wpOrigProc =
736 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,
737 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
738 lpttsi->hwndToolTip = hwnd;
739 lpttsi->uRefCount++;
740 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,
741 (HANDLE)lpttsi);
742 }
743// else
744// WARN (tooltips, "A window tool must only be listed once!\n");
745 }
746 else {
747 LPTT_SUBCLASS_INFO lpttsi =
748 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
749 if (lpttsi == NULL) {
750 lpttsi =
751 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));
752 lpttsi->wpOrigProc =
753 (WNDPROC)SetWindowLongA (toolPtr->hwnd,
754 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);
755 lpttsi->hwndToolTip = hwnd;
756 lpttsi->uRefCount++;
757 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);
758 }
759 else
760 lpttsi->uRefCount++;
761 }
762// TRACE (tooltips, "subclassing installed!\n");
763 }
764
765 return TRUE;
766}
767
768
769static LRESULT
770TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
771{
772 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
773 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
774 TTTOOL_INFO *toolPtr;
775 INT nTool;
776
777 if (lpToolInfo == NULL)
778 return 0;
779 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
780 return 0;
781 if (infoPtr->uNumTools == 0)
782 return 0;
783
784 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
785 if (nTool == -1) return 0;
786
787// TRACE (tooltips, "tool %d\n", nTool);
788
789 /* delete text string */
790 toolPtr = &infoPtr->tools[nTool];
791 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
792 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
793 COMCTL32_Free (toolPtr->lpszText);
794 }
795
796 /* remove subclassing */
797 if (toolPtr->uFlags & TTF_SUBCLASS) {
798 if (toolPtr->uFlags & TTF_IDISHWND) {
799 LPTT_SUBCLASS_INFO lpttsi =
800 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
801 if (lpttsi) {
802 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
803 (LONG)lpttsi->wpOrigProc);
804 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
805 COMCTL32_Free (&lpttsi);
806 }
807// else
808// ERR (tooltips, "Invalid data handle!\n");
809 }
810 else {
811 LPTT_SUBCLASS_INFO lpttsi =
812 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
813 if (lpttsi) {
814 if (lpttsi->uRefCount == 1) {
815 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
816 (LONG)lpttsi->wpOrigProc);
817 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
818 COMCTL32_Free (&lpttsi);
819 }
820 else
821 lpttsi->uRefCount--;
822 }
823// else
824// ERR (tooltips, "Invalid data handle!\n");
825 }
826 }
827
828 /* delete tool from tool list */
829 if (infoPtr->uNumTools == 1) {
830 COMCTL32_Free (infoPtr->tools);
831 infoPtr->tools = NULL;
832 }
833 else {
834 TTTOOL_INFO *oldTools = infoPtr->tools;
835 infoPtr->tools =
836 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
837
838 if (nTool > 0)
839 memcpy (&infoPtr->tools[0], &oldTools[0],
840 nTool * sizeof(TTTOOL_INFO));
841
842 if (nTool < infoPtr->uNumTools - 1)
843 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
844 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
845
846 COMCTL32_Free (oldTools);
847 }
848
849 infoPtr->uNumTools--;
850
851 return 0;
852}
853
854
855static LRESULT
856TOOLTIPS_DelToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
857{
858 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
859 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
860 TTTOOL_INFO *toolPtr;
861 INT nTool;
862
863 if (lpToolInfo == NULL)
864 return 0;
865 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
866 return 0;
867 if (infoPtr->uNumTools == 0)
868 return 0;
869
870 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
871 if (nTool == -1) return 0;
872
873// TRACE (tooltips, "tool %d\n", nTool);
874
875 /* delete text string */
876 toolPtr = &infoPtr->tools[nTool];
877 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
878 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
879 COMCTL32_Free (toolPtr->lpszText);
880 }
881
882 /* remove subclassing */
883 if (toolPtr->uFlags & TTF_SUBCLASS) {
884 if (toolPtr->uFlags & TTF_IDISHWND) {
885 LPTT_SUBCLASS_INFO lpttsi =
886 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
887 if (lpttsi) {
888 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
889 (LONG)lpttsi->wpOrigProc);
890 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
891 COMCTL32_Free (&lpttsi);
892 }
893// else
894// ERR (tooltips, "Invalid data handle!\n");
895 }
896 else {
897 LPTT_SUBCLASS_INFO lpttsi =
898 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
899 if (lpttsi) {
900 if (lpttsi->uRefCount == 1) {
901 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
902 (LONG)lpttsi->wpOrigProc);
903 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
904 COMCTL32_Free (&lpttsi);
905 }
906 else
907 lpttsi->uRefCount--;
908 }
909// else
910// ERR (tooltips, "Invalid data handle!\n");
911 }
912 }
913
914 /* delete tool from tool list */
915 if (infoPtr->uNumTools == 1) {
916 COMCTL32_Free (infoPtr->tools);
917 infoPtr->tools = NULL;
918 }
919 else {
920 TTTOOL_INFO *oldTools = infoPtr->tools;
921 infoPtr->tools =
922 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
923
924 if (nTool > 0)
925 memcpy (&infoPtr->tools[0], &oldTools[0],
926 nTool * sizeof(TTTOOL_INFO));
927
928 if (nTool < infoPtr->uNumTools - 1)
929 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
930 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
931
932 COMCTL32_Free (oldTools);
933 }
934
935 infoPtr->uNumTools--;
936
937 return 0;
938}
939
940
941static LRESULT
942TOOLTIPS_EnumToolsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
943{
944 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
945 UINT uIndex = (UINT)wParam;
946 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
947 TTTOOL_INFO *toolPtr;
948
949 if (lpToolInfo == NULL)
950 return FALSE;
951 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
952 return FALSE;
953 if (uIndex >= infoPtr->uNumTools)
954 return FALSE;
955
956// TRACE (tooltips, "index=%u\n", uIndex);
957
958 toolPtr = &infoPtr->tools[uIndex];
959
960 /* copy tool data */
961 lpToolInfo->uFlags = toolPtr->uFlags;
962 lpToolInfo->hwnd = toolPtr->hwnd;
963 lpToolInfo->uId = toolPtr->uId;
964 lpToolInfo->rect = toolPtr->rect;
965 lpToolInfo->hinst = toolPtr->hinst;
966/* lpToolInfo->lpszText = toolPtr->lpszText; */
967 lpToolInfo->lpszText = NULL; /* FIXME */
968
969 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
970 lpToolInfo->lParam = toolPtr->lParam;
971
972 return TRUE;
973}
974
975
976static LRESULT
977TOOLTIPS_EnumToolsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
978{
979 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
980 UINT uIndex = (UINT)wParam;
981 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
982 TTTOOL_INFO *toolPtr;
983
984 if (lpToolInfo == NULL)
985 return FALSE;
986 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
987 return FALSE;
988 if (uIndex >= infoPtr->uNumTools)
989 return FALSE;
990
991// TRACE (tooltips, "index=%u\n", uIndex);
992
993 toolPtr = &infoPtr->tools[uIndex];
994
995 /* copy tool data */
996 lpToolInfo->uFlags = toolPtr->uFlags;
997 lpToolInfo->hwnd = toolPtr->hwnd;
998 lpToolInfo->uId = toolPtr->uId;
999 lpToolInfo->rect = toolPtr->rect;
1000 lpToolInfo->hinst = toolPtr->hinst;
1001/* lpToolInfo->lpszText = toolPtr->lpszText; */
1002 lpToolInfo->lpszText = NULL; /* FIXME */
1003
1004 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1005 lpToolInfo->lParam = toolPtr->lParam;
1006
1007 return TRUE;
1008}
1009
1010
1011static LRESULT
1012TOOLTIPS_GetCurrentToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1013{
1014 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1015 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1016 TTTOOL_INFO *toolPtr;
1017
1018 if (lpToolInfo == NULL)
1019 return FALSE;
1020 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1021 return FALSE;
1022
1023 if (lpToolInfo) {
1024 if (infoPtr->nCurrentTool > -1) {
1025 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1026
1027 /* copy tool data */
1028 lpToolInfo->uFlags = toolPtr->uFlags;
1029 lpToolInfo->rect = toolPtr->rect;
1030 lpToolInfo->hinst = toolPtr->hinst;
1031/* lpToolInfo->lpszText = toolPtr->lpszText; */
1032 lpToolInfo->lpszText = NULL; /* FIXME */
1033
1034 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1035 lpToolInfo->lParam = toolPtr->lParam;
1036
1037 return TRUE;
1038 }
1039 else
1040 return FALSE;
1041 }
1042 else
1043 return (infoPtr->nCurrentTool != -1);
1044
1045 return FALSE;
1046}
1047
1048
1049static LRESULT
1050TOOLTIPS_GetCurrentToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1051{
1052 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1053 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1054 TTTOOL_INFO *toolPtr;
1055
1056 if (lpToolInfo == NULL)
1057 return FALSE;
1058 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1059 return FALSE;
1060
1061 if (lpToolInfo) {
1062 if (infoPtr->nCurrentTool > -1) {
1063 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
1064
1065 /* copy tool data */
1066 lpToolInfo->uFlags = toolPtr->uFlags;
1067 lpToolInfo->rect = toolPtr->rect;
1068 lpToolInfo->hinst = toolPtr->hinst;
1069/* lpToolInfo->lpszText = toolPtr->lpszText; */
1070 lpToolInfo->lpszText = NULL; /* FIXME */
1071
1072 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1073 lpToolInfo->lParam = toolPtr->lParam;
1074
1075 return TRUE;
1076 }
1077 else
1078 return FALSE;
1079 }
1080 else
1081 return (infoPtr->nCurrentTool != -1);
1082
1083 return FALSE;
1084}
1085
1086
1087static LRESULT
1088TOOLTIPS_GetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
1089{
1090 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1091
1092 switch (wParam) {
1093 case TTDT_AUTOMATIC:
1094 return infoPtr->nAutomaticTime;
1095
1096 case TTDT_RESHOW:
1097 return infoPtr->nReshowTime;
1098
1099 case TTDT_AUTOPOP:
1100 return infoPtr->nAutoPopTime;
1101
1102 case TTDT_INITIAL:
1103 return infoPtr->nInitialTime;
1104 }
1105
1106 return 0;
1107}
1108
1109
1110static LRESULT
1111TOOLTIPS_GetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1112{
1113 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1114 LPRECT lpRect = (LPRECT)lParam;
1115
1116 lpRect->left = infoPtr->rcMargin.left;
1117 lpRect->right = infoPtr->rcMargin.right;
1118 lpRect->bottom = infoPtr->rcMargin.bottom;
1119 lpRect->top = infoPtr->rcMargin.top;
1120
1121 return 0;
1122}
1123
1124
1125static LRESULT
1126TOOLTIPS_GetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1127{
1128 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1129
1130 return infoPtr->nMaxTipWidth;
1131}
1132
1133
1134static LRESULT
1135TOOLTIPS_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1136{
1137 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1138 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1139 INT nTool;
1140
1141 if (lpToolInfo == NULL)
1142 return 0;
1143 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1144 return 0;
1145
1146 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1147 if (nTool == -1) return 0;
1148
1149// lstrcpyWtoA (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
1150 strcpy(lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
1151
1152 return 0;
1153}
1154
1155
1156static LRESULT
1157TOOLTIPS_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1158{
1159 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1160 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1161 INT nTool;
1162
1163 if (lpToolInfo == NULL)
1164 return 0;
1165 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1166 return 0;
1167
1168 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1169 if (nTool == -1) return 0;
1170
1171 lstrcpyW (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
1172
1173 return 0;
1174}
1175
1176
1177static LRESULT
1178TOOLTIPS_GetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1179{
1180 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1181 return infoPtr->clrBk;
1182}
1183
1184
1185static LRESULT
1186TOOLTIPS_GetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1187{
1188 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1189 return infoPtr->clrText;
1190}
1191
1192
1193static LRESULT
1194TOOLTIPS_GetToolCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1195{
1196 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1197 return infoPtr->uNumTools;
1198}
1199
1200
1201static LRESULT
1202TOOLTIPS_GetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1203{
1204 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1205 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1206 TTTOOL_INFO *toolPtr;
1207 INT nTool;
1208
1209 if (lpToolInfo == NULL)
1210 return FALSE;
1211 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1212 return FALSE;
1213 if (infoPtr->uNumTools == 0)
1214 return FALSE;
1215
1216 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1217 if (nTool == -1)
1218 return FALSE;
1219
1220// TRACE (tooltips, "tool %d\n", nTool);
1221
1222 toolPtr = &infoPtr->tools[nTool];
1223
1224 /* copy tool data */
1225 lpToolInfo->uFlags = toolPtr->uFlags;
1226 lpToolInfo->rect = toolPtr->rect;
1227 lpToolInfo->hinst = toolPtr->hinst;
1228/* lpToolInfo->lpszText = toolPtr->lpszText; */
1229 lpToolInfo->lpszText = NULL; /* FIXME */
1230
1231 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1232 lpToolInfo->lParam = toolPtr->lParam;
1233
1234 return TRUE;
1235}
1236
1237
1238static LRESULT
1239TOOLTIPS_GetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1240{
1241 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1242 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1243 TTTOOL_INFO *toolPtr;
1244 INT nTool;
1245
1246 if (lpToolInfo == NULL)
1247 return FALSE;
1248 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1249 return FALSE;
1250 if (infoPtr->uNumTools == 0)
1251 return FALSE;
1252
1253 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1254 if (nTool == -1)
1255 return FALSE;
1256
1257// TRACE (tooltips, "tool %d\n", nTool);
1258
1259 toolPtr = &infoPtr->tools[nTool];
1260
1261 /* copy tool data */
1262 lpToolInfo->uFlags = toolPtr->uFlags;
1263 lpToolInfo->rect = toolPtr->rect;
1264 lpToolInfo->hinst = toolPtr->hinst;
1265/* lpToolInfo->lpszText = toolPtr->lpszText; */
1266 lpToolInfo->lpszText = NULL; /* FIXME */
1267
1268 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1269 lpToolInfo->lParam = toolPtr->lParam;
1270
1271 return TRUE;
1272}
1273
1274
1275static LRESULT
1276TOOLTIPS_HitTestA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1277{
1278 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1279 LPTTHITTESTINFOA lptthit = (LPTTHITTESTINFOA)lParam;
1280 TTTOOL_INFO *toolPtr;
1281 INT nTool;
1282
1283 if (lptthit == 0)
1284 return FALSE;
1285
1286 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1287 if (nTool == -1)
1288 return FALSE;
1289
1290// TRACE (tooltips, "tool %d!\n", nTool);
1291
1292 /* copy tool data */
1293 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) {
1294 toolPtr = &infoPtr->tools[nTool];
1295
1296 lptthit->ti.uFlags = toolPtr->uFlags;
1297 lptthit->ti.hwnd = toolPtr->hwnd;
1298 lptthit->ti.uId = toolPtr->uId;
1299 lptthit->ti.rect = toolPtr->rect;
1300 lptthit->ti.hinst = toolPtr->hinst;
1301/* lptthit->ti.lpszText = toolPtr->lpszText; */
1302 lptthit->ti.lpszText = NULL; /* FIXME */
1303 lptthit->ti.lParam = toolPtr->lParam;
1304 }
1305
1306 return TRUE;
1307}
1308
1309
1310static LRESULT
1311TOOLTIPS_HitTestW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1312{
1313 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1314 LPTTHITTESTINFOW lptthit = (LPTTHITTESTINFOW)lParam;
1315 TTTOOL_INFO *toolPtr;
1316 INT nTool;
1317
1318 if (lptthit == 0)
1319 return FALSE;
1320
1321 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
1322 if (nTool == -1)
1323 return FALSE;
1324
1325// TRACE (tooltips, "tool %d!\n", nTool);
1326
1327 /* copy tool data */
1328 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) {
1329 toolPtr = &infoPtr->tools[nTool];
1330
1331 lptthit->ti.uFlags = toolPtr->uFlags;
1332 lptthit->ti.hwnd = toolPtr->hwnd;
1333 lptthit->ti.uId = toolPtr->uId;
1334 lptthit->ti.rect = toolPtr->rect;
1335 lptthit->ti.hinst = toolPtr->hinst;
1336/* lptthit->ti.lpszText = toolPtr->lpszText; */
1337 lptthit->ti.lpszText = NULL; /* FIXME */
1338 lptthit->ti.lParam = toolPtr->lParam;
1339 }
1340
1341 return TRUE;
1342}
1343
1344
1345static LRESULT
1346TOOLTIPS_NewToolRectA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1347{
1348 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1349 LPTTTOOLINFOA lpti = (LPTTTOOLINFOA)lParam;
1350 INT nTool;
1351
1352 if (lpti == NULL)
1353 return 0;
1354 if (lpti->cbSize < TTTOOLINFO_V1_SIZEA)
1355 return FALSE;
1356
1357 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti);
1358 if (nTool == -1) return 0;
1359
1360 infoPtr->tools[nTool].rect = lpti->rect;
1361
1362 return 0;
1363}
1364
1365
1366static LRESULT
1367TOOLTIPS_NewToolRectW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1368{
1369 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1370 LPTTTOOLINFOW lpti = (LPTTTOOLINFOW)lParam;
1371 INT nTool;
1372
1373 if (lpti == NULL)
1374 return 0;
1375 if (lpti->cbSize < TTTOOLINFO_V1_SIZEW)
1376 return FALSE;
1377
1378 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti);
1379 if (nTool == -1) return 0;
1380
1381 infoPtr->tools[nTool].rect = lpti->rect;
1382
1383 return 0;
1384}
1385
1386
1387static LRESULT
1388TOOLTIPS_Pop (HWND hwnd, WPARAM wParam, LPARAM lParam)
1389{
1390 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1391
1392 TOOLTIPS_Hide (hwnd, infoPtr);
1393
1394 return 0;
1395}
1396
1397
1398static LRESULT
1399TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1400{
1401 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1402 LPMSG lpMsg = (LPMSG)lParam;
1403 POINT pt;
1404
1405 if (lParam == 0) {
1406// ERR (tooltips, "lpMsg == NULL!\n");
1407 return 0;
1408 }
1409
1410 switch (lpMsg->message) {
1411 case WM_LBUTTONDOWN:
1412 case WM_LBUTTONUP:
1413 case WM_MBUTTONDOWN:
1414 case WM_MBUTTONUP:
1415 case WM_RBUTTONDOWN:
1416 case WM_RBUTTONUP:
1417 pt = lpMsg->pt;
1418 ScreenToClient (lpMsg->hwnd, &pt);
1419 infoPtr->nOldTool = infoPtr->nTool;
1420 infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
1421// TRACE (tooltips, "tool (%x) %d %d\n",
1422// hwnd, infoPtr->nOldTool, infoPtr->nTool);
1423 TOOLTIPS_Hide (hwnd, infoPtr);
1424 break;
1425
1426 case WM_MOUSEMOVE:
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// TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n",
1434// hwnd, pt.x, pt.y);
1435 if ((infoPtr->bActive) && (infoPtr->nTool != infoPtr->nOldTool)) {
1436 if (infoPtr->nOldTool == -1) {
1437 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
1438// TRACE (tooltips, "timer 1 started!\n");
1439 }
1440 else {
1441 TOOLTIPS_Hide (hwnd, infoPtr);
1442 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
1443// TRACE (tooltips, "timer 2 started!\n");
1444 }
1445 }
1446 if (infoPtr->nCurrentTool != -1) {
1447 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
1448// TRACE (tooltips, "timer 3 started!\n");
1449 }
1450 break;
1451 }
1452
1453 return 0;
1454}
1455
1456
1457static LRESULT
1458TOOLTIPS_SetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
1459{
1460 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1461 INT nTime = (INT)LOWORD(lParam);
1462
1463 switch (wParam) {
1464 case TTDT_AUTOMATIC:
1465 if (nTime == 0) {
1466 infoPtr->nAutomaticTime = 500;
1467 infoPtr->nReshowTime = 100;
1468 infoPtr->nAutoPopTime = 5000;
1469 infoPtr->nInitialTime = 500;
1470 }
1471 else {
1472 infoPtr->nAutomaticTime = nTime;
1473 infoPtr->nReshowTime = nTime / 5;
1474 infoPtr->nAutoPopTime = nTime * 10;
1475 infoPtr->nInitialTime = nTime;
1476 }
1477 break;
1478
1479 case TTDT_RESHOW:
1480 infoPtr->nReshowTime = nTime;
1481 break;
1482
1483 case TTDT_AUTOPOP:
1484 infoPtr->nAutoPopTime = nTime;
1485 break;
1486
1487 case TTDT_INITIAL:
1488 infoPtr->nInitialTime = nTime;
1489 break;
1490 }
1491
1492 return 0;
1493}
1494
1495
1496static LRESULT
1497TOOLTIPS_SetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
1498{
1499 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1500 LPRECT lpRect = (LPRECT)lParam;
1501
1502 infoPtr->rcMargin.left = lpRect->left;
1503 infoPtr->rcMargin.right = lpRect->right;
1504 infoPtr->rcMargin.bottom = lpRect->bottom;
1505 infoPtr->rcMargin.top = lpRect->top;
1506
1507 return 0;
1508}
1509
1510
1511static LRESULT
1512TOOLTIPS_SetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1513{
1514 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1515 INT nTemp = infoPtr->nMaxTipWidth;
1516
1517 infoPtr->nMaxTipWidth = (INT)lParam;
1518
1519 return nTemp;
1520}
1521
1522
1523static LRESULT
1524TOOLTIPS_SetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1525{
1526 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1527
1528 infoPtr->clrBk = (COLORREF)wParam;
1529
1530 return 0;
1531}
1532
1533
1534static LRESULT
1535TOOLTIPS_SetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1536{
1537 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1538
1539 infoPtr->clrText = (COLORREF)wParam;
1540
1541 return 0;
1542}
1543
1544
1545static LRESULT
1546TOOLTIPS_SetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1547{
1548 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1549 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1550 TTTOOL_INFO *toolPtr;
1551 INT nTool;
1552
1553 if (lpToolInfo == NULL)
1554 return 0;
1555 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1556 return 0;
1557
1558 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1559 if (nTool == -1) return 0;
1560
1561// TRACE (tooltips, "tool %d\n", nTool);
1562
1563 toolPtr = &infoPtr->tools[nTool];
1564
1565 /* copy tool data */
1566 toolPtr->uFlags = lpToolInfo->uFlags;
1567 toolPtr->hwnd = lpToolInfo->hwnd;
1568 toolPtr->uId = lpToolInfo->uId;
1569 toolPtr->rect = lpToolInfo->rect;
1570 toolPtr->hinst = lpToolInfo->hinst;
1571
1572 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
1573// TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
1574 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1575 }
1576 else if (lpToolInfo->lpszText) {
1577 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
1578 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1579 else {
1580 if (toolPtr->lpszText) {
1581 COMCTL32_Free (toolPtr->lpszText);
1582 toolPtr->lpszText = NULL;
1583 }
1584 if (lpToolInfo->lpszText) {
1585 INT len = lstrlenA (lpToolInfo->lpszText);
1586 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1587// lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
1588 strcpy(toolPtr->lpszText, lpToolInfo->lpszText);
1589 }
1590 }
1591 }
1592
1593 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
1594 toolPtr->lParam = lpToolInfo->lParam;
1595
1596 return 0;
1597}
1598
1599
1600static LRESULT
1601TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1602{
1603 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1604 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1605 TTTOOL_INFO *toolPtr;
1606 INT nTool;
1607
1608 if (lpToolInfo == NULL)
1609 return 0;
1610 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1611 return 0;
1612
1613 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1614 if (nTool == -1) return 0;
1615
1616// TRACE (tooltips, "tool %d\n", nTool);
1617
1618 toolPtr = &infoPtr->tools[nTool];
1619
1620 /* copy tool data */
1621 toolPtr->uFlags = lpToolInfo->uFlags;
1622 toolPtr->hwnd = lpToolInfo->hwnd;
1623 toolPtr->uId = lpToolInfo->uId;
1624 toolPtr->rect = lpToolInfo->rect;
1625 toolPtr->hinst = lpToolInfo->hinst;
1626
1627 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {
1628// TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText);
1629 toolPtr->lpszText = lpToolInfo->lpszText;
1630 }
1631 else if (lpToolInfo->lpszText) {
1632 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
1633 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1634 else {
1635 if (toolPtr->lpszText) {
1636 COMCTL32_Free (toolPtr->lpszText);
1637 toolPtr->lpszText = NULL;
1638 }
1639 if (lpToolInfo->lpszText) {
1640 INT len = lstrlenW (lpToolInfo->lpszText);
1641 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1642 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
1643 }
1644 }
1645 }
1646
1647 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
1648 toolPtr->lParam = lpToolInfo->lParam;
1649
1650 return 0;
1651}
1652
1653
1654static LRESULT
1655TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1656{
1657 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1658 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1659
1660 if (lpToolInfo == NULL)
1661 return 0;
1662 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1663 return FALSE;
1664
1665 if ((BOOL)wParam) {
1666 /* activate */
1667 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1668 if (infoPtr->nTrackTool != -1) {
1669// TRACE (tooltips, "activated!\n");
1670 infoPtr->bTrackActive = TRUE;
1671 TOOLTIPS_TrackShow (hwnd, infoPtr);
1672 }
1673 }
1674 else {
1675 /* deactivate */
1676 TOOLTIPS_TrackHide (hwnd, infoPtr);
1677
1678 infoPtr->bTrackActive = FALSE;
1679 infoPtr->nTrackTool = -1;
1680
1681// TRACE (tooltips, "deactivated!\n");
1682 }
1683
1684 return 0;
1685}
1686
1687
1688static LRESULT
1689TOOLTIPS_TrackPosition (HWND hwnd, WPARAM wParam, LPARAM lParam)
1690{
1691 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1692
1693 infoPtr->xTrackPos = (INT)LOWORD(lParam);
1694 infoPtr->yTrackPos = (INT)HIWORD(lParam);
1695
1696 if (infoPtr->bTrackActive) {
1697// TRACE (tooltips, "[%d %d]\n",
1698// infoPtr->xTrackPos, infoPtr->yTrackPos);
1699
1700 TOOLTIPS_TrackShow (hwnd, infoPtr);
1701 }
1702
1703 return 0;
1704}
1705
1706
1707static LRESULT
1708TOOLTIPS_Update (HWND hwnd, WPARAM wParam, LPARAM lParam)
1709{
1710 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1711
1712 if (infoPtr->nCurrentTool != -1)
1713 UpdateWindow (hwnd);
1714
1715 return 0;
1716}
1717
1718
1719static LRESULT
1720TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1721{
1722 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1723 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
1724 TTTOOL_INFO *toolPtr;
1725 INT nTool;
1726
1727 if (lpToolInfo == NULL)
1728 return 0;
1729 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
1730 return FALSE;
1731
1732 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
1733 if (nTool == -1) return 0;
1734
1735// TRACE (tooltips, "tool %d\n", nTool);
1736
1737 toolPtr = &infoPtr->tools[nTool];
1738
1739 /* copy tool text */
1740 toolPtr->hinst = lpToolInfo->hinst;
1741
1742 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
1743 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
1744 }
1745 else if (lpToolInfo->lpszText) {
1746 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
1747 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1748 else {
1749 if (toolPtr->lpszText) {
1750 COMCTL32_Free (toolPtr->lpszText);
1751 toolPtr->lpszText = NULL;
1752 }
1753 if (lpToolInfo->lpszText) {
1754 INT len = lstrlenA (lpToolInfo->lpszText);
1755 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1756// lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
1757 strcpy(toolPtr->lpszText, lpToolInfo->lpszText);
1758 }
1759 }
1760 }
1761
1762 /* force repaint */
1763 if (infoPtr->bActive)
1764 TOOLTIPS_Show (hwnd, infoPtr);
1765 else if (infoPtr->bTrackActive)
1766 TOOLTIPS_TrackShow (hwnd, infoPtr);
1767
1768 return 0;
1769}
1770
1771
1772static LRESULT
1773TOOLTIPS_UpdateTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1774{
1775 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1776 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
1777 TTTOOL_INFO *toolPtr;
1778 INT nTool;
1779
1780 if (lpToolInfo == NULL)
1781 return 0;
1782 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
1783 return FALSE;
1784
1785 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
1786 if (nTool == -1)
1787 return 0;
1788
1789// TRACE (tooltips, "tool %d\n", nTool);
1790
1791 toolPtr = &infoPtr->tools[nTool];
1792
1793 /* copy tool text */
1794 toolPtr->hinst = lpToolInfo->hinst;
1795
1796 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
1797 toolPtr->lpszText = lpToolInfo->lpszText;
1798 }
1799 else if (lpToolInfo->lpszText) {
1800 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
1801 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
1802 else {
1803 if (toolPtr->lpszText) {
1804 COMCTL32_Free (toolPtr->lpszText);
1805 toolPtr->lpszText = NULL;
1806 }
1807 if (lpToolInfo->lpszText) {
1808 INT len = lstrlenW (lpToolInfo->lpszText);
1809 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
1810 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
1811 }
1812 }
1813 }
1814
1815 /* force repaint */
1816 if (infoPtr->bActive)
1817 TOOLTIPS_Show (hwnd, infoPtr);
1818 else if (infoPtr->bTrackActive)
1819 TOOLTIPS_TrackShow (hwnd, infoPtr);
1820
1821 return 0;
1822}
1823
1824
1825static LRESULT
1826TOOLTIPS_WindowFromPoint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1827{
1828 return WindowFromPoint (*((LPPOINT)lParam));
1829}
1830
1831
1832
1833static LRESULT
1834TOOLTIPS_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1835{
1836 TOOLTIPS_INFO *infoPtr;
1837 NONCLIENTMETRICSA nclm;
1838 INT nResult;
1839
1840 /* allocate memory for info structure */
1841 infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc (sizeof(TOOLTIPS_INFO));
1842 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1843
1844 /* initialize info structure */
1845 infoPtr->bActive = TRUE;
1846 infoPtr->bTrackActive = FALSE;
1847 infoPtr->clrBk = GetSysColor (COLOR_INFOBK);
1848 infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);
1849
1850 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
1851 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
1852 infoPtr->hFont = CreateFontIndirectA (&nclm.lfStatusFont);
1853
1854 infoPtr->nMaxTipWidth = -1;
1855 infoPtr->nTool = -1;
1856 infoPtr->nOldTool = -1;
1857 infoPtr->nCurrentTool = -1;
1858 infoPtr->nTrackTool = -1;
1859
1860 infoPtr->nAutomaticTime = 500;
1861 infoPtr->nReshowTime = 100;
1862 infoPtr->nAutoPopTime = 5000;
1863 infoPtr->nInitialTime = 500;
1864
1865 nResult = (INT) SendMessageA (GetParent (hwnd), WM_NOTIFYFORMAT,
1866 (WPARAM)hwnd, (LPARAM)NF_QUERY);
1867// if (nResult == NFR_ANSI)
1868// TRACE (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
1869// else if (nResult == NFR_UNICODE)
1870// FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n");
1871// else
1872// FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n");
1873
1874 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
1875
1876 return 0;
1877}
1878
1879
1880static LRESULT
1881TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1882{
1883 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1884 TTTOOL_INFO *toolPtr;
1885 INT i;
1886
1887 /* free tools */
1888 if (infoPtr->tools) {
1889 for (i = 0; i < infoPtr->uNumTools; i++) {
1890 toolPtr = &infoPtr->tools[i];
1891 if ((toolPtr->hinst) && (toolPtr->lpszText)) {
1892 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
1893 COMCTL32_Free (toolPtr->lpszText);
1894 }
1895
1896 /* remove subclassing */
1897 if (toolPtr->uFlags & TTF_SUBCLASS) {
1898 LPTT_SUBCLASS_INFO lpttsi;
1899
1900 if (toolPtr->uFlags & TTF_IDISHWND)
1901 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
1902 else
1903 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
1904
1905 if (lpttsi) {
1906 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
1907 (LONG)lpttsi->wpOrigProc);
1908 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
1909 COMCTL32_Free (&lpttsi);
1910 }
1911 }
1912 }
1913 COMCTL32_Free (infoPtr->tools);
1914 }
1915
1916 /* delete font */
1917 DeleteObject (infoPtr->hFont);
1918
1919 /* free tool tips info data */
1920 COMCTL32_Free (infoPtr);
1921
1922 return 0;
1923}
1924
1925
1926static LRESULT
1927TOOLTIPS_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
1928{
1929 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1930 RECT rect;
1931 HBRUSH hBrush;
1932
1933 hBrush = CreateSolidBrush (infoPtr->clrBk);
1934 GetClientRect (hwnd, &rect);
1935 FillRect ((HDC)wParam, &rect, hBrush);
1936 DeleteObject (hBrush);
1937
1938 return FALSE;
1939}
1940
1941
1942static LRESULT
1943TOOLTIPS_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1944{
1945 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1946
1947 return infoPtr->hFont;
1948}
1949
1950
1951static LRESULT
1952TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1953{
1954 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1955
1956 TOOLTIPS_Hide (hwnd, infoPtr);
1957
1958 return 0;
1959}
1960
1961
1962static LRESULT
1963TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1964{
1965 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1966
1967 dwStyle &= 0x0000FFFF;
1968 dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS);
1969 SetWindowLongA (hwnd, GWL_STYLE, dwStyle);
1970
1971 return TRUE;
1972}
1973
1974
1975static LRESULT
1976TOOLTIPS_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
1977{
1978 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
1979 INT nTool = (infoPtr->bTrackActive) ? infoPtr->nTrackTool : infoPtr->nTool;
1980
1981// TRACE (tooltips, " nTool=%d\n", nTool);
1982
1983 if ((nTool > -1) && (nTool < infoPtr->uNumTools)) {
1984 if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) {
1985// TRACE (tooltips, "-- in transparent mode!\n");
1986 return HTTRANSPARENT;
1987 }
1988 }
1989
1990 return DefWindowProcA (hwnd, WM_NCHITTEST, wParam, lParam);
1991}
1992
1993
1994static LRESULT
1995TOOLTIPS_Paint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1996{
1997 HDC hdc;
1998 PAINTSTRUCT ps;
1999
2000 hdc = (wParam == 0) ? BeginPaint (hwnd, &ps) : (HDC)wParam;
2001 TOOLTIPS_Refresh (hwnd, hdc);
2002 if (!wParam)
2003 EndPaint (hwnd, &ps);
2004 return 0;
2005}
2006
2007
2008static LRESULT
2009TOOLTIPS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2010{
2011 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2012
2013 infoPtr->hFont = (HFONT)wParam;
2014
2015 if ((LOWORD(lParam)) & (infoPtr->nCurrentTool != -1)) {
2016// FIXME (tooltips, "full redraw needed!\n");
2017 }
2018
2019 return 0;
2020}
2021/******************************************************************
2022 * TOOLTIPS_OnWMGetTextLength
2023 *
2024 * This function is called when the tooltip receive a
2025 * WM_GETTEXTLENGTH message.
2026 * wParam : not used
2027 * lParam : not used
2028 *
2029 * returns the length, in characters, of the tip text
2030 ******************************************************************/
2031static LRESULT
2032TOOLTIPS_OnWMGetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam)
2033{
2034 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2035 return lstrlenW(infoPtr->szTipText);
2036}
2037/******************************************************************
2038 * TOOLTIPS_OnWMGetText
2039 *
2040 * This function is called when the tooltip receive a
2041 * WM_GETTEXT message.
2042 * wParam : specifies the maximum number of characters to be copied
2043 * lParam : is the pointer to the buffer that will receive
2044 * the tip text
2045 *
2046 * returns the number of characters copied
2047 ******************************************************************/
2048static LRESULT
2049TOOLTIPS_OnWMGetText (HWND hwnd, WPARAM wParam, LPARAM lParam)
2050{
2051 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2052 INT length;
2053
2054 if(!infoPtr || !(infoPtr->szTipText))
2055 return 0;
2056
2057 length = lstrlenW(infoPtr->szTipText);
2058 /* When wParam is smaller than the lenght of the tip text
2059 copy wParam characters of the tip text and return wParam */
2060 if(wParam < length)
2061 {
2062// lstrcpynWtoA((LPSTR)lParam, infoPtr->szTipText,(UINT)wParam);
2063 strncpy((LPSTR)lParam, infoPtr->szTipText,(UINT)wParam);
2064 return wParam;
2065 }
2066// lstrcpyWtoA((LPSTR)lParam, infoPtr->szTipText);
2067 strcpy((LPSTR)lParam, infoPtr->szTipText);
2068 return length;
2069
2070}
2071
2072static LRESULT
2073TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam)
2074{
2075 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2076
2077// TRACE (tooltips, "timer %d (%x) expired!\n", wParam, hwnd);
2078
2079 switch (wParam)
2080 {
2081 case ID_TIMERSHOW:
2082 KillTimer (hwnd, ID_TIMERSHOW);
2083 if (TOOLTIPS_CheckTool (hwnd, TRUE) == infoPtr->nTool)
2084 TOOLTIPS_Show (hwnd, infoPtr);
2085 break;
2086
2087 case ID_TIMERPOP:
2088 TOOLTIPS_Hide (hwnd, infoPtr);
2089 break;
2090
2091 case ID_TIMERLEAVE:
2092 KillTimer (hwnd, ID_TIMERLEAVE);
2093 if (TOOLTIPS_CheckTool (hwnd, FALSE) == -1) {
2094 infoPtr->nTool = -1;
2095 infoPtr->nOldTool = -1;
2096 TOOLTIPS_Hide (hwnd, infoPtr);
2097 }
2098 break;
2099 }
2100 return 0;
2101}
2102
2103
2104static LRESULT
2105TOOLTIPS_WinIniChange (HWND hwnd, WPARAM wParam, LPARAM lParam)
2106{
2107 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
2108 NONCLIENTMETRICSA nclm;
2109
2110 infoPtr->clrBk = GetSysColor (COLOR_INFOBK);
2111 infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);
2112
2113 DeleteObject (infoPtr->hFont);
2114 nclm.cbSize = sizeof(NONCLIENTMETRICSA);
2115 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
2116 infoPtr->hFont = CreateFontIndirectA (&nclm.lfStatusFont);
2117
2118 return 0;
2119}
2120
2121
2122LRESULT CALLBACK
2123TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2124{
2125 LPTT_SUBCLASS_INFO lpttsi =
2126 (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass);
2127 TOOLTIPS_INFO *infoPtr;
2128 UINT nTool;
2129
2130 switch (uMsg) {
2131 case WM_LBUTTONDOWN:
2132 case WM_LBUTTONUP:
2133 case WM_MBUTTONDOWN:
2134 case WM_MBUTTONUP:
2135 case WM_RBUTTONDOWN:
2136 case WM_RBUTTONUP:
2137 infoPtr = TOOLTIPS_GetInfoPtr(lpttsi->hwndToolTip);
2138 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
2139
2140// TRACE (tooltips, "subclassed mouse message %04x\n", uMsg);
2141 infoPtr->nOldTool = infoPtr->nTool;
2142 infoPtr->nTool = nTool;
2143 TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
2144 break;
2145
2146 case WM_MOUSEMOVE:
2147 infoPtr = TOOLTIPS_GetInfoPtr (lpttsi->hwndToolTip);
2148 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd);
2149
2150// TRACE (tooltips, "subclassed WM_MOUSEMOVE\n");
2151 infoPtr->nOldTool = infoPtr->nTool;
2152 infoPtr->nTool = nTool;
2153
2154 if ((infoPtr->bActive) &&
2155 (infoPtr->nTool != infoPtr->nOldTool)) {
2156 if (infoPtr->nOldTool == -1) {
2157 SetTimer (hwnd, ID_TIMERSHOW,
2158 infoPtr->nInitialTime, 0);
2159// TRACE (tooltips, "timer 1 started!\n");
2160 }
2161 else {
2162 TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr);
2163 SetTimer (hwnd, ID_TIMERSHOW,
2164 infoPtr->nReshowTime, 0);
2165// TRACE (tooltips, "timer 2 started!\n");
2166 }
2167 }
2168 if (infoPtr->nCurrentTool != -1) {
2169 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0);
2170// TRACE (tooltips, "timer 3 started!\n");
2171 }
2172 break;
2173 }
2174
2175 return CallWindowProcA (lpttsi->wpOrigProc, hwnd, uMsg, wParam, lParam);
2176}
2177
2178
2179LRESULT CALLBACK
2180TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2181{
2182 switch (uMsg)
2183 {
2184 case TTM_ACTIVATE:
2185 return TOOLTIPS_Activate (hwnd, wParam, lParam);
2186
2187 case TTM_ADDTOOLA:
2188 return TOOLTIPS_AddToolA (hwnd, wParam, lParam);
2189
2190 case TTM_ADDTOOLW:
2191 return TOOLTIPS_AddToolW (hwnd, wParam, lParam);
2192
2193 case TTM_DELTOOLA:
2194 return TOOLTIPS_DelToolA (hwnd, wParam, lParam);
2195
2196 case TTM_DELTOOLW:
2197 return TOOLTIPS_DelToolW (hwnd, wParam, lParam);
2198
2199 case TTM_ENUMTOOLSA:
2200 return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam);
2201
2202 case TTM_ENUMTOOLSW:
2203 return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam);
2204
2205 case TTM_GETCURRENTTOOLA:
2206 return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam);
2207
2208 case TTM_GETCURRENTTOOLW:
2209 return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam);
2210
2211 case TTM_GETDELAYTIME:
2212 return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam);
2213
2214 case TTM_GETMARGIN:
2215 return TOOLTIPS_GetMargin (hwnd, wParam, lParam);
2216
2217 case TTM_GETMAXTIPWIDTH:
2218 return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam);
2219
2220 case TTM_GETTEXTA:
2221 return TOOLTIPS_GetTextA (hwnd, wParam, lParam);
2222
2223 case TTM_GETTEXTW:
2224 return TOOLTIPS_GetTextW (hwnd, wParam, lParam);
2225
2226 case TTM_GETTIPBKCOLOR:
2227 return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam);
2228
2229 case TTM_GETTIPTEXTCOLOR:
2230 return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam);
2231
2232 case TTM_GETTOOLCOUNT:
2233 return TOOLTIPS_GetToolCount (hwnd, wParam, lParam);
2234
2235 case TTM_GETTOOLINFOA:
2236 return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam);
2237
2238 case TTM_GETTOOLINFOW:
2239 return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam);
2240
2241 case TTM_HITTESTA:
2242 return TOOLTIPS_HitTestA (hwnd, wParam, lParam);
2243
2244 case TTM_HITTESTW:
2245 return TOOLTIPS_HitTestW (hwnd, wParam, lParam);
2246
2247 case TTM_NEWTOOLRECTA:
2248 return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam);
2249
2250 case TTM_NEWTOOLRECTW:
2251 return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam);
2252
2253 case TTM_POP:
2254 return TOOLTIPS_Pop (hwnd, wParam, lParam);
2255
2256 case TTM_RELAYEVENT:
2257 return TOOLTIPS_RelayEvent (hwnd, wParam, lParam);
2258
2259 case TTM_SETDELAYTIME:
2260 return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam);
2261
2262 case TTM_SETMARGIN:
2263 return TOOLTIPS_SetMargin (hwnd, wParam, lParam);
2264
2265 case TTM_SETMAXTIPWIDTH:
2266 return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam);
2267
2268 case TTM_SETTIPBKCOLOR:
2269 return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam);
2270
2271 case TTM_SETTIPTEXTCOLOR:
2272 return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam);
2273
2274 case TTM_SETTOOLINFOA:
2275 return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam);
2276
2277 case TTM_SETTOOLINFOW:
2278 return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam);
2279
2280 case TTM_TRACKACTIVATE:
2281 return TOOLTIPS_TrackActivate (hwnd, wParam, lParam);
2282
2283 case TTM_TRACKPOSITION:
2284 return TOOLTIPS_TrackPosition (hwnd, wParam, lParam);
2285
2286 case TTM_UPDATE:
2287 return TOOLTIPS_Update (hwnd, wParam, lParam);
2288
2289 case TTM_UPDATETIPTEXTA:
2290 return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam);
2291
2292 case TTM_UPDATETIPTEXTW:
2293 return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam);
2294
2295 case TTM_WINDOWFROMPOINT:
2296 return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam);
2297
2298
2299 case WM_CREATE:
2300 return TOOLTIPS_Create (hwnd, wParam, lParam);
2301
2302 case WM_DESTROY:
2303 return TOOLTIPS_Destroy (hwnd, wParam, lParam);
2304
2305 case WM_ERASEBKGND:
2306 return TOOLTIPS_EraseBackground (hwnd, wParam, lParam);
2307
2308 case WM_GETFONT:
2309 return TOOLTIPS_GetFont (hwnd, wParam, lParam);
2310
2311 case WM_GETTEXT:
2312 return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam);
2313
2314 case WM_GETTEXTLENGTH:
2315 return TOOLTIPS_OnWMGetTextLength (hwnd, wParam, lParam);
2316
2317
2318 case WM_LBUTTONDOWN:
2319 case WM_LBUTTONUP:
2320 case WM_MBUTTONDOWN:
2321 case WM_MBUTTONUP:
2322 case WM_RBUTTONDOWN:
2323 case WM_RBUTTONUP:
2324 case WM_MOUSEMOVE:
2325 return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam);
2326
2327 case WM_NCCREATE:
2328 return TOOLTIPS_NCCreate (hwnd, wParam, lParam);
2329
2330 case WM_NCHITTEST:
2331 return TOOLTIPS_NCHitTest (hwnd, wParam, lParam);
2332
2333/* case WM_NOTIFYFORMAT: */
2334/* return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); */
2335
2336 case WM_PAINT:
2337 return TOOLTIPS_Paint (hwnd, wParam, lParam);
2338
2339 case WM_SETFONT:
2340 return TOOLTIPS_SetFont (hwnd, wParam, lParam);
2341
2342 case WM_TIMER:
2343 return TOOLTIPS_Timer (hwnd, wParam, lParam);
2344
2345 case WM_WININICHANGE:
2346 return TOOLTIPS_WinIniChange (hwnd, wParam, lParam);
2347
2348 default:
2349 if (uMsg >= WM_USER)
2350// ERR (tooltips, "unknown msg %04x wp=%08x lp=%08lx\n",
2351// uMsg, wParam, lParam);
2352 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2353 }
2354 return 0;
2355}
2356
2357
2358VOID
2359TOOLTIPS_Register (VOID)
2360{
2361 WNDCLASSA wndClass;
2362
2363 if (GlobalFindAtomA (TOOLTIPS_CLASSA)) return;
2364
2365 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2366 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS;
2367 wndClass.lpfnWndProc = (WNDPROC)TOOLTIPS_WindowProc;
2368 wndClass.cbClsExtra = 0;
2369 wndClass.cbWndExtra = sizeof(TOOLTIPS_INFO *);
2370 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
2371 wndClass.hbrBackground = 0;
2372 wndClass.lpszClassName = TOOLTIPS_CLASSA;
2373
2374 RegisterClassA (&wndClass);
2375}
2376
2377
2378VOID
2379TOOLTIPS_Unregister (VOID)
2380{
2381 if (GlobalFindAtomA (TOOLTIPS_CLASSA))
2382 UnregisterClassA (TOOLTIPS_CLASSA, (HINSTANCE)NULL);
2383}
2384
Note: See TracBrowser for help on using the repository browser.