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