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