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

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

Fixed Unicode<->Ascii issues partially

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