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

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

merged latest WINE 990923 changes

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