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