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