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