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

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