- Timestamp:
- Aug 6, 2000, 10:31:01 PM (25 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/toolbar.cpp
r3962 r3963 1 /* $Id: toolbar.cpp,v 1. 8 2000-08-06 14:40:17sandervl Exp $ */1 /* $Id: toolbar.cpp,v 1.9 2000-08-06 20:28:28 sandervl Exp $ */ 2 2 /* 3 3 * Toolbar control … … 10 10 * - A little bug in TOOLBAR_DrawMasked() 11 11 * - Button wrapping (under construction). 12 * - Messages .13 * - Notifications (under construction).12 * - Messages (under construction). 13 * - Notifications. 14 14 * - Fix TB_SETROWS. 15 15 * - Tooltip support (almost complete). 16 * - Unicode supp port (under construction).16 * - Unicode support (under construction). 17 17 * - Fix TOOLBAR_SetButtonInfo32A/W. 18 * - Customize dialog (under construction). 19 * - TBSTYLE_AUTOSIZE for toolbar and buttons. 20 * - I_IMAGECALLBACK support. 18 * - Drag & drop of buttons 21 19 * 22 20 * Testing: … … 31 29 32 30 /* 33 - (WINE 20000608 level) 31 - Corel 20000513 level 32 - (WINE 991212 level) 34 33 */ 35 36 34 37 35 #include <string.h> … … 48 46 #define BOTTOM_BORDER 2 49 47 50 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0)) 51 52 static BOOL 53 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index) 54 { 55 if ((index>=0) && (index < infoPtr->nNumBitmaps)) 56 return TRUE; 57 else 58 return FALSE; 59 } 48 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO*)getInfoPtr(hwnd)) 60 49 61 50 … … 76 65 } 77 66 78 /* 79 * Draw the text string for this button. 80 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef 81 * is non-zero, so we can simply check himlDef to see if we have 82 * an image list 83 */ 67 84 68 static void 85 69 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 86 70 HDC hdc, INT nState, DWORD dwStyle) 87 71 { 88 72 RECT rcText = btnPtr->rect; … … 90 74 INT nOldBkMode; 91 75 COLORREF clrOld; 92 LPWSTR lpText = NULL;93 HIMAGELIST himl = infoPtr->himlDef;94 95 // TRACE ("iString: %x\n", btnPtr->iString);96 97 /* get a pointer to the text */98 if (btnPtr->iString == -1)99 dprintf(("TOOLBAR_DrawString: Undocumented Index -1\n"));100 else if (HIWORD(btnPtr->iString) != 0)101 lpText = (LPWSTR)btnPtr->iString;102 else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))103 lpText = infoPtr->strings[btnPtr->iString];104 105 // TRACE ("lpText: \"%s\"\n", debugstr_w(lpText));106 76 107 77 /* draw text */ 108 if (lpText) { 109 110 InflateRect (&rcText, -3, -3); 111 112 if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 113 if ((dwStyle & TBSTYLE_LIST) && 114 ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) && 115 (btnPtr->iBitmap != I_IMAGENONE)) { 116 rcText.left += infoPtr->nBitmapWidth; 117 } 118 else { 119 rcText.top += infoPtr->nBitmapHeight; 120 } 121 } 122 123 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED)) 124 OffsetRect (&rcText, 1, 1); 125 126 hOldFont = SelectObject (hdc, infoPtr->hFont); 127 nOldBkMode = SetBkMode (hdc, TRANSPARENT); 128 if (!(nState & TBSTATE_ENABLED)) { 129 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT)); 130 OffsetRect (&rcText, 1, 1); 131 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 132 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 133 OffsetRect (&rcText, -1, -1); 134 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 135 } 136 else if (nState & TBSTATE_INDETERMINATE) { 137 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 138 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 139 } 140 else { 141 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); 142 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 143 } 144 145 SetTextColor (hdc, clrOld); 146 SelectObject (hdc, hOldFont); 147 if (nOldBkMode != TRANSPARENT) 148 SetBkMode (hdc, nOldBkMode); 78 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) { 79 InflateRect (&rcText, -3, -3); 80 if (dwStyle & TBSTYLE_LIST) { 81 rcText.left += infoPtr->nBitmapWidth; 82 } 83 else { 84 rcText.top += infoPtr->nBitmapHeight; 85 } 86 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED)) 87 OffsetRect (&rcText, 1, 1); 88 89 hOldFont = SelectObject (hdc, infoPtr->hFont); 90 nOldBkMode = SetBkMode (hdc, TRANSPARENT); 91 if (!(nState & TBSTATE_ENABLED)) { 92 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT)); 93 OffsetRect (&rcText, 1, 1); 94 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, 95 &rcText, infoPtr->dwDTFlags); 96 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 97 OffsetRect (&rcText, -1, -1); 98 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, 99 &rcText, infoPtr->dwDTFlags); 100 } 101 else if (nState & TBSTATE_INDETERMINATE) { 102 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 103 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, 104 &rcText, infoPtr->dwDTFlags); 105 } 106 else { 107 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); 108 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, 109 &rcText, infoPtr->dwDTFlags); 110 } 111 112 SetTextColor (hdc, clrOld); 113 SelectObject (hdc, hOldFont); 114 if (nOldBkMode != TRANSPARENT) 115 SetBkMode (hdc, nOldBkMode); 149 116 } 150 117 } … … 164 131 static void 165 132 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 166 133 HDC hdc, INT x, INT y) 167 134 { 168 135 /* FIXME: this function is a hack since it uses image list 169 136 internals directly */ 170 137 171 138 HIMAGELIST himl = infoPtr->himlDef; … … 175 142 176 143 if (!himl) 177 144 return; 178 145 179 146 /* create new dc's */ … … 190 157 SetTextColor (hdcImageList, RGB(0, 0, 0)); 191 158 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 192 159 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY); 193 160 194 161 #if 0 … … 197 164 SetBkColor (hdcImageList, RGB(0, 0, 0)); 198 165 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 199 166 hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT); 200 167 #endif 201 168 … … 203 170 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT)); 204 171 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy, 205 172 hdcMask, 0, 0, 0xB8074A); 206 173 207 174 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW)); 208 175 BitBlt (hdc, x, y, himl->cx, himl->cy, 209 176 hdcMask, 0, 0, 0xB8074A); 210 177 211 178 DeleteObject (hbmMask); … … 222 189 RECT rc; 223 190 224 if (btnPtr->fsState & TBSTATE_HIDDEN) 225 return; 191 if (btnPtr->fsState & TBSTATE_HIDDEN) return; 226 192 227 193 rc = btnPtr->rect; 228 194 229 // TRACE("iBitmap: %d\n", btnPtr->iBitmap);230 231 195 /* separator */ 232 if (btnPtr->fsStyle & TBSTYLE_SEP) { 233 /* with the FLAT style, iBitmap is the width and has already */ 234 /* been taken into consideration in calculating the width */ 235 /* so now we need to draw the vertical separator */ 236 /* empirical tests show that iBitmap can/will be non-zero */ 237 /* when drawing the vertical bar... */ 238 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) 239 TOOLBAR_DrawFlatSeparator (&rc, hdc); 240 return; 196 if (btnPtr->fsStyle & TBSTYLE_SEP) 197 { 198 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0)) 199 TOOLBAR_DrawFlatSeparator (&rc, hdc); 200 return; 241 201 } 242 202 243 203 /* disabled */ 244 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {245 if (!(dwStyle & TBSTYLE_FLAT)) 246 DrawEdge (hdc, &rc, EDGE_RAISED, 247 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 248 249 if (infoPtr->himlDis && 250 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))251 252 253 254 255 256 257 204 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 205 { 206 if (!(dwStyle & TBSTYLE_FLAT)) 207 DrawEdge (hdc, &rc, EDGE_RAISED, 208 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 209 210 if (infoPtr->himlDis) 211 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 212 rc.left+1, rc.top+1, ILD_NORMAL); 213 else 214 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 215 216 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 217 return; 258 218 } 259 219 260 220 /* pressed TBSTYLE_BUTTON */ 261 if (btnPtr->fsState & TBSTATE_PRESSED) {262 if (dwStyle & TBSTYLE_FLAT) 263 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST); 264 else 265 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 266 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))267 268 269 270 271 } 272 273 /* checked TBSTYLE_CHECK 221 if (btnPtr->fsState & TBSTATE_PRESSED) 222 { 223 if (dwStyle & TBSTYLE_FLAT) 224 DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST); 225 else 226 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 227 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 228 rc.left+2, rc.top+2, ILD_NORMAL); 229 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 230 return; 231 } 232 233 /* checked TBSTYLE_CHECK*/ 274 234 if ((btnPtr->fsStyle & TBSTYLE_CHECK) && 275 276 277 278 279 280 281 282 283 284 285 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))286 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 287 rc.left+2, rc.top+2, ILD_NORMAL); 288 289 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);290 return; 291 } 292 293 /* indeterminate */294 if (btnPtr->fsState & TBSTATE_INDETERMINATE){295 296 297 298 299 300 301 235 (btnPtr->fsState & TBSTATE_CHECKED)) { 236 if (dwStyle & TBSTYLE_FLAT) 237 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, 238 BF_RECT | BF_MIDDLE | BF_ADJUST); 239 else 240 DrawEdge (hdc, &rc, EDGE_SUNKEN, 241 BF_RECT | BF_MIDDLE | BF_ADJUST); 242 243 TOOLBAR_DrawPattern (hdc, &rc); 244 245 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 246 rc.left+2, rc.top+2, ILD_NORMAL); 247 248 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 249 return; 250 } 251 252 /* indeterminate */ 253 if (btnPtr->fsState & TBSTATE_INDETERMINATE) 254 { 255 DrawEdge (hdc, &rc, EDGE_RAISED, 256 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 257 258 TOOLBAR_DrawPattern (hdc, &rc); 259 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 260 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 261 return; 302 262 } 303 263 … … 305 265 if (dwStyle & TBSTYLE_FLAT) 306 266 { 307 if (btnPtr->bHot) 308 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); 309 if (btnPtr->bHot && infoPtr->himlHot && 310 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 311 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc, 312 rc.left +2, rc.top +2, ILD_NORMAL); 313 else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 314 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 315 rc.left +2, rc.top +2, ILD_NORMAL); 316 } 317 else 267 if(btnPtr->bHot) 268 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); 269 270 if(btnPtr->bHot && infoPtr->himlHot) 271 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc, 272 rc.left +2, rc.top +2, ILD_NORMAL); 273 else 274 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 275 rc.left +2, rc.top +2, ILD_NORMAL); 276 } else 318 277 { 319 DrawEdge (hdc, &rc, EDGE_RAISED, 320 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 321 322 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 323 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 324 rc.left+1, rc.top+1, ILD_NORMAL); 278 DrawEdge (hdc, &rc, EDGE_RAISED, 279 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 280 281 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 282 rc.left+1, rc.top+1, ILD_NORMAL); 325 283 } 326 284 … … 330 288 331 289 static void 332 TOOLBAR_Refresh (HWND hwnd, HDC hdc , PAINTSTRUCT* ps)290 TOOLBAR_Refresh (HWND hwnd, HDC hdc) 333 291 { 334 292 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 335 293 TBUTTON_INFO *btnPtr; 336 294 INT i; 337 RECT rcTemp; 338 339 /* redraw necessary buttons */ 295 296 /* draw buttons */ 340 297 btnPtr = infoPtr->buttons; 341 298 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 342 { 343 if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect))) 344 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 345 } 346 } 299 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 300 } 301 347 302 348 303 static void 349 TOOLBAR_ MeasureString(HWND hwnd, INT index, LPSIZE lpSize)304 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize) 350 305 { 351 306 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 352 307 TBUTTON_INFO *btnPtr; 308 INT i; 353 309 HDC hdc; 354 310 HFONT hOldFont; 311 SIZE sz; 355 312 356 313 lpSize->cx = 0; … … 359 316 hOldFont = SelectObject (hdc, infoPtr->hFont); 360 317 361 btnPtr = &infoPtr->buttons[index]; 362 363 if (!(btnPtr->fsState & TBSTATE_HIDDEN) && 364 (btnPtr->iString > -1) && 365 (btnPtr->iString < infoPtr->nNumStrings)) 366 { 367 LPWSTR lpText = infoPtr->strings[btnPtr->iString]; 368 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), lpSize); 318 btnPtr = infoPtr->buttons; 319 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 320 if (!(btnPtr->fsState & TBSTATE_HIDDEN) && 321 (btnPtr->iString > -1) && 322 (btnPtr->iString < infoPtr->nNumStrings)) { 323 LPWSTR lpText = infoPtr->strings[btnPtr->iString]; 324 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz); 325 if (sz.cx > lpSize->cx) 326 lpSize->cx = sz.cx; 327 if (sz.cy > lpSize->cy) 328 lpSize->cy = sz.cy; 329 } 369 330 } 370 331 … … 372 333 ReleaseDC (0, hdc); 373 334 374 // TRACE("string size %d x %d!\n", lpSize->cx, lpSize->cy); 375 } 376 377 static void 378 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize) 379 { 380 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 381 TBUTTON_INFO *btnPtr; 382 INT i; 383 SIZE sz; 384 385 386 lpSize->cx = 0; 387 lpSize->cy = 0; 388 389 btnPtr = infoPtr->buttons; 390 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 391 TOOLBAR_MeasureString(hwnd,i,&sz); 392 if (sz.cx > lpSize->cx) 393 lpSize->cx = sz.cx; 394 if (sz.cy > lpSize->cy) 395 lpSize->cy = sz.cy; 396 } 397 398 // TRACE("string size %d x %d!\n", lpSize->cx, lpSize->cy); 335 // TRACE (toolbar, "string size %d x %d!\n", lpSize->cx, lpSize->cy); 399 336 } 400 337 401 338 /*********************************************************************** 402 * 339 * TOOLBAR_WrapToolbar 403 340 * 404 * This function walks through the buttons and seperators in the 405 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 406 * wrapping should occur based on the width of the toolbar window. 407 * It does *not* calculate button placement itself. That task 408 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 409 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 341 * This function walks through the buttons and seperators in the 342 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 343 * wrapping should occur based on the width of the toolbar window. 344 * It does *not* calculate button placement itself. That task 345 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 346 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 410 347 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items. 411 */ 348 */ 412 349 413 350 static void … … 420 357 BOOL bWrap, bButtonWrap; 421 358 422 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */423 /* 424 /* to perform their own layout on the toolbar.*/359 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */ 360 /* no layout is necessary. Applications may use this style */ 361 /* to perform their own layout on the toolbar. */ 425 362 if( !(dwStyle & TBSTYLE_WRAPABLE) ) 426 363 return; 427 364 428 365 btnPtr = infoPtr->buttons; 429 366 x = infoPtr->nIndent; 430 367 431 /* this can get the parents width, to know how far we can extend432 * this toolbar. We cannot use its height, as there may be multiple433 * toolbars in a rebar control434 */435 368 GetClientRect( GetParent(hwnd), &rc ); 436 369 infoPtr->nWidth = rc.right - rc.left; … … 439 372 for (i = 0; i < infoPtr->nNumButtons; i++ ) 440 373 { 441 442 443 444 445 446 447 448 449 450 451 cx = (btnPtr[i].iBitmap > 0) ? 452 453 454 455 456 /* Two or more adjacent separators form a separator group. */ 457 458 /* next row if the previous wrapping is on a button.*/459 460 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 461 462 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 463 464 465 466 467 468 469 470 471 472 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 473 > infoPtr->nWidth ) 474 475 476 477 /* If the current button is a separator and not hidden, */ 478 /*go to the next until it reaches a non separator. */479 /*Wrap the last separator if it is before a button. */480 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 481 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 /* If the current button is not a separator, find the last */ 500 /* separator and wrap it.*/501 502 503 504 505 506 bFound = TRUE; 507 i = j; 508 509 510 bButtonWrap = FALSE; 511 512 513 514 515 /* If no separator available for wrapping, wrap one of*/516 /* non-hidden previous button.*/517 518 519 for ( j = i - 1; 520 521 522 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 523 524 525 bFound = TRUE; 526 i = j; 527 528 529 530 531 532 533 534 535 if (!bFound) 536 537 538 539 540 541 542 543 544 } 545 546 547 548 } 549 } 550 374 bWrap = FALSE; 375 btnPtr[i].fsState &= ~TBSTATE_WRAP; 376 377 if (btnPtr[i].fsState & TBSTATE_HIDDEN) 378 continue; 379 380 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 381 /* it is the actual width of the separator. This is used for */ 382 /* custom controls in toolbars. */ 383 if (btnPtr[i].fsStyle & TBSTYLE_SEP) 384 cx = (btnPtr[i].iBitmap > 0) ? 385 btnPtr[i].iBitmap : SEPARATOR_WIDTH; 386 else 387 cx = infoPtr->nButtonWidth; 388 389 /* Two or more adjacent separators form a separator group. */ 390 /* The first separator in a group should be wrapped to the */ 391 /* next row if the previous wrapping is on a button. */ 392 if( bButtonWrap && 393 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 394 (i + 1 < infoPtr->nNumButtons ) && 395 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 396 { 397 btnPtr[i].fsState |= TBSTATE_WRAP; 398 x = infoPtr->nIndent; 399 i++; 400 bButtonWrap = FALSE; 401 continue; 402 } 403 404 /* The layout makes sure the bitmap is visible, but not the button. */ 405 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 406 > infoPtr->nWidth ) 407 { 408 BOOL bFound = FALSE; 409 410 /* If the current button is a separator and not hidden, */ 411 /* go to the next until it reaches a non separator. */ 412 /* Wrap the last separator if it is before a button. */ 413 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 414 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 415 i < infoPtr->nNumButtons ) 416 { 417 i++; 418 bFound = TRUE; 419 } 420 421 if( bFound && i < infoPtr->nNumButtons ) 422 { 423 i--; 424 btnPtr[i].fsState |= TBSTATE_WRAP; 425 x = infoPtr->nIndent; 426 bButtonWrap = FALSE; 427 continue; 428 } 429 else if ( i >= infoPtr->nNumButtons) 430 break; 431 432 /* If the current button is not a separator, find the last */ 433 /* separator and wrap it. */ 434 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 435 { 436 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) && 437 !(btnPtr[j].fsState & TBSTATE_HIDDEN)) 438 { 439 bFound = TRUE; 440 i = j; 441 x = infoPtr->nIndent; 442 btnPtr[j].fsState |= TBSTATE_WRAP; 443 bButtonWrap = FALSE; 444 break; 445 } 446 } 447 448 /* If no separator available for wrapping, wrap one of */ 449 /* non-hidden previous button. */ 450 if (!bFound) 451 { 452 for ( j = i - 1; 453 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 454 { 455 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 456 continue; 457 458 bFound = TRUE; 459 i = j; 460 x = infoPtr->nIndent; 461 btnPtr[j].fsState |= TBSTATE_WRAP; 462 bButtonWrap = TRUE; 463 break; 464 } 465 } 466 467 /* If all above failed, wrap the current button. */ 468 if (!bFound) 469 { 470 btnPtr[i].fsState |= TBSTATE_WRAP; 471 bFound = TRUE; 472 x = infoPtr->nIndent; 473 if (btnPtr[i].fsState & TBSTYLE_SEP ) 474 bButtonWrap = FALSE; 475 else 476 bButtonWrap = TRUE; 477 } 478 } 479 else 480 x += cx; 481 } 482 } 483 551 484 /*********************************************************************** 552 * 485 * TOOLBAR_CalcToolbar 553 486 * 554 * This function calculates button and separator placement. It first 555 * calculates the button sizes, gets the toolbar window width and then 556 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 487 * This function calculates button and separator placement. It first 488 * calculates the button sizes, gets the toolbar window width and then 489 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 557 490 * on. It assigns a new location to each item and sends this location to 558 * the tooltip window if appropriate. Finally, it updates the rcBound 559 * rect and calculates the new required toolbar window height. 560 */ 491 * the tooltip window if appropriate. Finally, it updates the rcBound 492 * rect and calculates the new required toolbar window height. 493 */ 561 494 562 495 static void … … 564 497 { 565 498 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd); 566 DWORD dwStyle = GetWindowLongA 499 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); 567 500 TBUTTON_INFO *btnPtr; 568 501 INT i, nRows, nSepRows; 569 502 INT x, y, cx, cy; 570 503 SIZE sizeString; 504 RECT rc; 571 505 BOOL bWrap; 572 506 … … 574 508 575 509 if (dwStyle & TBSTYLE_LIST) { 576 577 510 infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6; 511 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6; 578 512 } 579 513 else { 580 BOOL usesBitmaps = FALSE; 581 INT i; 582 583 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++) 584 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap)) 585 usesBitmaps = TRUE; 586 587 if (sizeString.cy > 0) { 588 if (usesBitmaps) 589 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6; 590 else 591 infoPtr->nButtonHeight = sizeString.cy + 6; 592 } 593 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) 594 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; 595 596 if (sizeString.cx > infoPtr->nBitmapWidth) 597 infoPtr->nButtonWidth = sizeString.cx + 6; 598 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6) 599 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6; 600 } 601 602 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin ) 603 infoPtr->nButtonWidth = infoPtr->cxMin; 604 if ( infoPtr->cxMax >= 0 && infoPtr->nButtonWidth > infoPtr->cxMax ) 605 infoPtr->nButtonWidth = infoPtr->cxMax; 514 if (sizeString.cy > 0) 515 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6; 516 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) 517 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; 518 519 if (sizeString.cx > infoPtr->nBitmapWidth) 520 infoPtr->nButtonWidth = sizeString.cx + 6; 521 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6) 522 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6; 523 } 606 524 607 525 TOOLBAR_WrapToolbar( hwnd, dwStyle ); 608 526 609 527 x = infoPtr->nIndent; 610 y = (dwStyle & TBSTYLE_FLAT) ? 0 : TOP_BORDER; 611 612 /* 613 * We wills et the height below, and we set the width on entry 614 * so we do not reset them here.. 615 */ 616 #if 0 617 GetClientRect( hwnd, &rc ); 618 /* get initial values for toolbar */ 619 infoPtr->nWidth = rc.right - rc.left; 620 infoPtr->nHeight = rc.bottom - rc.top; 621 #endif 622 623 /* from above, minimum is a button, and possible text */ 528 y = (dwStyle & TBSTYLE_FLAT) ? 0: TOP_BORDER; 624 529 cx = infoPtr->nButtonWidth; 625 /* cannot use just ButtonHeight, we may have no buttons! */ 626 if (infoPtr->nNumButtons > 0) 627 infoPtr->nHeight = infoPtr->nButtonHeight; 628 cy = infoPtr->nHeight; 629 530 cy = infoPtr->nButtonHeight; 630 531 nRows = nSepRows = 0; 631 532 … … 636 537 637 538 btnPtr = infoPtr->buttons; 638 639 /* do not base height/width on parent, if the parent is a */ 640 /* rebar control it could have multiple rows of toolbars */ 641 /* GetClientRect( GetParent(hwnd), &rc ); */ 642 /* cx = rc.right - rc.left; */ 643 /* cy = rc.bottom - rc.top; */ 539 GetClientRect( GetParent(hwnd), &rc ); 540 infoPtr->nWidth = rc.right - rc.left; 644 541 645 542 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ ) 646 543 { 647 bWrap = FALSE; 648 if (btnPtr->fsState & TBSTATE_HIDDEN) 649 { 650 SetRectEmpty (&btnPtr->rect); 651 continue; 652 } 653 654 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 655 /* it is the actual width of the separator. This is used for */ 656 /* custom controls in toolbars. */ 657 if (btnPtr->fsStyle & TBSTYLE_SEP) 658 cx = (btnPtr->iBitmap > 0) ? 659 btnPtr->iBitmap : SEPARATOR_WIDTH; 660 else { 661 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE) 544 bWrap = FALSE; 545 if (btnPtr->fsState & TBSTATE_HIDDEN) 546 { 547 SetRectEmpty (&btnPtr->rect); 548 continue; 549 } 550 551 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 552 /* it is the actual width of the separator. This is used for */ 553 /* custom controls in toolbars. */ 554 if (btnPtr->fsStyle & TBSTYLE_SEP) 555 cx = (btnPtr->iBitmap > 0) ? 556 btnPtr->iBitmap : SEPARATOR_WIDTH; 557 else 558 cx = infoPtr->nButtonWidth; 559 560 if (btnPtr->fsState & TBSTATE_WRAP ) 561 bWrap = TRUE; 562 563 SetRect (&btnPtr->rect, x, y, x + cx, y + cy); 564 565 if (infoPtr->rcBound.left > x) 566 infoPtr->rcBound.left = x; 567 if (infoPtr->rcBound.right < x + cx) 568 infoPtr->rcBound.right = x + cx; 569 if (infoPtr->rcBound.bottom < y + cy) 570 infoPtr->rcBound.bottom = y + cy; 571 572 /* Set the toolTip only for non-hidden, non-separator button */ 573 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP)) 574 { 575 TTTOOLINFOA ti; 576 577 ZeroMemory (&ti,sizeof(TTTOOLINFOA)); 578 ti.cbSize = sizeof(TTTOOLINFOA); 579 ti.hwnd = hwnd; 580 ti.uId = btnPtr->idCommand; 581 ti.rect = btnPtr->rect; 582 SendMessageA(infoPtr->hwndToolTip,TTM_NEWTOOLRECTA,0,(LPARAM)&ti); 583 } 584 585 /* btnPtr->nRow is zero based. The space between the rows is */ 586 /* also considered as a row. */ 587 btnPtr->nRow = nRows + nSepRows; 588 if( bWrap ) 589 { 590 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) ) 591 y += cy; 592 else 662 593 { 663 SIZE sz; 664 TOOLBAR_MeasureString(hwnd,i,&sz); 665 cx = sz.cx + 6; 594 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 595 /* it is the actual width of the separator. This is used for */ 596 /* custom controls in toolbars. */ 597 y += cy + ( (btnPtr->iBitmap > 0 ) ? 598 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 599 600 /* nSepRows is used to calculate the extra height follwoing */ 601 /* the last row. */ 602 nSepRows++; 666 603 } 667 else 668 cx = infoPtr->nButtonWidth; 669 } 670 cy = infoPtr->nHeight; 671 672 if (btnPtr->fsState & TBSTATE_WRAP ) 673 bWrap = TRUE; 674 675 SetRect (&btnPtr->rect, x, y, x + cx, y + cy); 676 677 if (infoPtr->rcBound.left > x) 678 infoPtr->rcBound.left = x; 679 if (infoPtr->rcBound.right < x + cx) 680 infoPtr->rcBound.right = x + cx; 681 if (infoPtr->rcBound.bottom < y + cy) 682 infoPtr->rcBound.bottom = y + cy; 683 684 /* Set the toolTip only for non-hidden, non-separator button */ 685 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 686 { 687 TTTOOLINFOA ti; 688 689 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 690 ti.cbSize = sizeof(TTTOOLINFOA); 691 ti.hwnd = hwnd; 692 ti.uId = btnPtr->idCommand; 693 ti.rect = btnPtr->rect; 694 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA, 695 0, (LPARAM)&ti); 696 } 697 698 /* btnPtr->nRow is zero based. The space between the rows is */ 699 /* also considered as a row. */ 700 btnPtr->nRow = nRows + nSepRows; 701 if( bWrap ) 702 { 703 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) ) 704 y += cy; 705 else 706 { 707 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 708 /* it is the actual width of the separator. This is used for */ 709 /* custom controls in toolbars. */ 710 y += cy + ( (btnPtr->iBitmap > 0 ) ? 711 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 712 713 /* nSepRows is used to calculate the extra height follwoing */ 714 /* the last row. */ 715 nSepRows++; 716 } 717 x = infoPtr->nIndent; 718 nRows++; 719 } 720 else 721 x += cx; 604 x = infoPtr->nIndent; 605 nRows++; 606 } 607 else 608 x += cx; 722 609 } 723 610 … … 725 612 infoPtr->nRows = nRows + nSepRows + 1; 726 613 727 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following 728 /* the last row. 729 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 730 731 nSepRows * (infoPtr->nBitmapHeight + 1) + 732 BOTTOM_BORDER; 733 // TRACE("toolbar height %d\n", infoPtr->nHeight);614 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */ 615 /* the last row. */ 616 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 617 nSepRows * (SEPARATOR_WIDTH * 2 / 3) + 618 nSepRows * (infoPtr->nBitmapHeight + 1) + 619 BOTTOM_BORDER; 620 // TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight); 734 621 } 735 622 … … 741 628 TBUTTON_INFO *btnPtr; 742 629 INT i; 743 630 744 631 btnPtr = infoPtr->buttons; 745 632 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 746 747 748 749 750 751 // TRACE(" ON SEPARATOR %d!\n", i);752 753 754 755 756 757 // TRACE(" ON BUTTON %d!\n", i);758 759 760 761 } 762 763 // TRACE(" NOWHERE!\n");633 if (btnPtr->fsState & TBSTATE_HIDDEN) 634 continue; 635 636 if (btnPtr->fsStyle & TBSTYLE_SEP) { 637 if (PtInRect (&btnPtr->rect, *lpPt)) { 638 // TRACE (toolbar, " ON SEPARATOR %d!\n", i); 639 return -i; 640 } 641 } 642 else { 643 if (PtInRect (&btnPtr->rect, *lpPt)) { 644 // TRACE (toolbar, " ON BUTTON %d!\n", i); 645 return i; 646 } 647 } 648 } 649 650 // TRACE (toolbar, " NOWHERE!\n"); 764 651 return -1; 765 652 } … … 774 661 btnPtr = infoPtr->buttons; 775 662 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 776 777 // TRACE("command=%d index=%d\n", idCommand, i);778 779 780 } 781 // TRACE("no index found for command=%d\n", idCommand);663 if (btnPtr->idCommand == idCommand) { 664 // TRACE (toolbar, "command=%d index=%d\n", idCommand, i); 665 return i; 666 } 667 } 668 // TRACE (toolbar, "no index found for command=%d\n", idCommand); 782 669 return -1; 783 670 } … … 791 678 792 679 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons)) 793 680 return -1; 794 681 795 682 /* check index button */ 796 683 btnPtr = &infoPtr->buttons[nIndex]; 797 684 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 798 799 685 if (btnPtr->fsState & TBSTATE_CHECKED) 686 return nIndex; 800 687 } 801 688 … … 803 690 nRunIndex = nIndex - 1; 804 691 while (nRunIndex >= 0) { 805 806 807 808 809 810 811 812 692 btnPtr = &infoPtr->buttons[nRunIndex]; 693 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 694 if (btnPtr->fsState & TBSTATE_CHECKED) 695 return nRunIndex; 696 } 697 else 698 break; 699 nRunIndex--; 813 700 } 814 701 … … 816 703 nRunIndex = nIndex + 1; 817 704 while (nRunIndex < infoPtr->nNumButtons) { 818 btnPtr = &infoPtr->buttons[nRunIndex]; 819 820 821 822 823 824 825 705 btnPtr = &infoPtr->buttons[nRunIndex]; 706 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 707 if (btnPtr->fsState & TBSTATE_CHECKED) 708 return nRunIndex; 709 } 710 else 711 break; 712 nRunIndex++; 826 713 } 827 714 … … 832 719 static VOID 833 720 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, 834 721 WPARAM wParam, LPARAM lParam) 835 722 { 836 723 MSG msg; … … 840 727 msg.wParam = wParam; 841 728 msg.lParam = lParam; 842 msg.time = GetMessageTime (); 843 msg.pt.x = LOWORD(GetMessagePos ()); 844 msg.pt.y = HIWORD(GetMessagePos ()); 845 846 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg); 847 } 848 729 msg.time = GetMessageTime(); 730 msg.pt.x = LOWORD(GetMessagePos()); 731 msg.pt.y = HIWORD(GetMessagePos()); 732 733 SendMessageA(hwndTip,TTM_RELAYEVENT,0,(LPARAM)&msg); 734 } 735 736 static void TBCUSTOMIZE_GetToolName(TOOLBAR_INFO* infoPtr,TBUTTON_INFO* btnPtr,INT pos) 737 { 738 if (btnPtr->iString > -1 && btnPtr->iString < infoPtr->nNumStrings) 739 { 740 if (!btnPtr->pszName) btnPtr->pszName = (WCHAR*)COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 741 lstrcpynW(btnPtr->pszName,infoPtr->strings[btnPtr->iString],MAXTOOLNAME*sizeof(WCHAR)); 742 743 return; 744 } 745 746 if (btnPtr->fsStyle & TBSTYLE_SEP) 747 { 748 if (!btnPtr->pszName) btnPtr->pszName = (WCHAR*)COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 749 lstrcpyW(btnPtr->pszName,(WCHAR*)L"Separator"); 750 } else 751 { 752 TBNOTIFYW tbNotify; 753 BOOL unicode = isUnicodeNotify(&infoPtr->header); 754 755 tbNotify.iItem = pos; 756 tbNotify.tbButton.iBitmap = btnPtr->iBitmap; 757 tbNotify.tbButton.idCommand = btnPtr->idCommand; 758 tbNotify.tbButton.fsState = btnPtr->fsState; 759 tbNotify.tbButton.fsStyle = btnPtr->fsStyle; 760 tbNotify.tbButton.dwData = btnPtr->dwData; 761 tbNotify.tbButton.iString = btnPtr->iString; 762 763 tbNotify.cchText = MAXTOOLNAME; 764 if (unicode) 765 { 766 tbNotify.pszText = (WCHAR*)COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 767 tbNotify.pszText[0] = 0; 768 } else 769 { 770 tbNotify.pszText = (WCHAR*)COMCTL32_Alloc(MAXTOOLNAME*sizeof(CHAR)); 771 ((CHAR*)tbNotify.pszText)[0] = 0; 772 } 773 774 if (!sendNotify(infoPtr->hwndToolbar,unicode ? TBN_GETBUTTONINFOW:TBN_GETBUTTONINFOA,&tbNotify.hdr)) 775 { //CB: failed, try other methods 776 if (infoPtr->hwndToolTip) 777 { //try to get tool tip text 778 TTTOOLINFOW ti; 779 780 ZeroMemory (&ti,sizeof(ti)); 781 ti.cbSize = sizeof(ti); 782 ti.hwnd = infoPtr->hwndToolbar; 783 ti.uId = btnPtr->idCommand; 784 ti.hinst = 0; 785 ti.lpszText = (WCHAR*)COMCTL32_Alloc(INFOTIPSIZE*sizeof(WCHAR)); 786 ti.lpszText[0] = 0; 787 788 SendMessageW(infoPtr->hwndToolTip,TTM_GETTEXTW,0,(LPARAM)&ti); 789 if (unicode) 790 { 791 if (ti.lpszText[0] != 0) lstrcpynW(tbNotify.pszText,ti.lpszText,MAXTOOLNAME); 792 else lstrcpyW(tbNotify.pszText,(WCHAR*)L"Button"); 793 } else 794 { 795 if (ti.lpszText[0] != 0) lstrcpynWtoA((CHAR*)tbNotify.pszText,ti.lpszText,MAXTOOLNAME); 796 else lstrcpyWtoA((CHAR*)tbNotify.pszText,(WCHAR*)L"Button"); 797 } 798 799 COMCTL32_Free(ti.lpszText); 800 801 } else 802 { 803 if (unicode) 804 lstrcpyW(tbNotify.pszText,(WCHAR*)L"Button"); 805 else 806 lstrcpyA((CHAR*)tbNotify.pszText,"Button"); 807 } 808 } 809 810 if (!btnPtr->pszName) btnPtr->pszName = (WCHAR*)COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 811 if (unicode) 812 lstrcpyW(btnPtr->pszName,tbNotify.pszText); 813 else 814 lstrcpyAtoW(btnPtr->pszName,(CHAR*)tbNotify.pszText); 815 COMCTL32_Free(tbNotify.pszText); 816 } 817 } 818 819 static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd); 820 static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd); 821 822 static BOOL TBCUSTOMIZE_FillData(HWND hwnd,TOOLBAR_INFO* infoPtr) 823 { 824 TBUTTON_INFO* btnPtr; 825 INT i; 826 INT leftCount = 0; 827 INT rightCount = 0; 828 INT nItem; 829 830 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,WM_SETREDRAW,FALSE,0); 831 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,WM_SETREDRAW,FALSE,0); 832 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_RESETCONTENT,0,0); 833 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_RESETCONTENT,0,0); 834 835 /* insert 'virtual' separator button into 'available buttons' list */ 836 nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"Separator"); 837 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,0); 838 839 /* copy all buttons and append them to the listboxes */ 840 btnPtr = infoPtr->buttons; 841 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 842 { 843 TBNOTIFYW tbNotify; 844 845 tbNotify.iItem = i; 846 tbNotify.tbButton.iBitmap = btnPtr->iBitmap; 847 tbNotify.tbButton.idCommand = btnPtr->idCommand; 848 tbNotify.tbButton.fsState = btnPtr->fsState; 849 tbNotify.tbButton.fsStyle = btnPtr->fsStyle; 850 tbNotify.tbButton.dwData = btnPtr->dwData; 851 tbNotify.tbButton.iString = btnPtr->iString; 852 tbNotify.cchText = 0; 853 tbNotify.pszText = NULL; 854 855 // send TBN_QUERYINSERT notification 856 if (!sendNotify(infoPtr->hwndToolbar,TBN_QUERYINSERT,&tbNotify.hdr)) continue; 857 858 // send TBN_QUERYDELETE notification 859 btnPtr->bDelete = (BOOL)sendNotify(infoPtr->hwndToolbar,TBN_QUERYDELETE,&tbNotify.hdr); 860 861 //get tool name 862 863 TBCUSTOMIZE_GetToolName(infoPtr,btnPtr,i); 864 865 if (btnPtr->fsState & TBSTATE_HIDDEN) 866 { 867 nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 868 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,btnPtr->nCustomID); 869 leftCount++; 870 } else 871 { 872 nItem = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 873 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,nItem,btnPtr->nCustomID); 874 rightCount++; 875 } 876 } 877 878 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,0,0); 879 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,(rightCount > 0) ? 0:(WPARAM)-1,0); 880 881 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,WM_SETREDRAW,TRUE,0); 882 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,WM_SETREDRAW,TRUE,0); 883 InvalidateRect(GetDlgItem(hwnd,IDC_AVAILBTN_LBOX),NULL,TRUE); 884 InvalidateRect(GetDlgItem(hwnd,IDC_TOOLBARBTN_LBOX),NULL,TRUE); 885 886 if (leftCount == 0 && rightCount == 0) return FALSE; 887 888 TBCUSTOMIZE_AvailSelChange(hwnd); 889 TBCUSTOMIZE_VisSelChange(hwnd); 890 891 return TRUE; 892 } 893 894 static BOOL TBCUSTOMIZE_InitDialog(HWND hwnd,WPARAM wParam,LPARAM lParam) 895 { 896 TOOLBAR_INFO* infoPtr; 897 DWORD dwStyle; 898 899 infoPtr = (TOOLBAR_INFO*)lParam; 900 SetWindowLongA(hwnd,DWL_USER,(DWORD)infoPtr); 901 dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE); 902 903 if (infoPtr) 904 { 905 INT x,itemHeight; 906 907 //custom ID: 1-nNumButtons, 0 == new separator 908 for (x = 0;x < infoPtr->nNumButtons;x++) 909 { 910 infoPtr->buttons[x].nCustomID = x+1; 911 infoPtr->buttons[x].pszName = NULL; 912 } 913 infoPtr->nMaxCustomID = infoPtr->nNumButtons; 914 915 //save tools 916 infoPtr->nNumOldButtons = infoPtr->nNumButtons; 917 infoPtr->oldButtons = (TBUTTON_INFO*)COMCTL32_Alloc(infoPtr->nNumOldButtons*sizeof(TBUTTON_INFO)); 918 memcpy(&infoPtr->oldButtons[0],&infoPtr->buttons[0],infoPtr->nNumOldButtons*sizeof(TBUTTON_INFO)); 919 920 //set height 921 if (dwStyle & TBSTYLE_FLAT) 922 itemHeight = infoPtr->nBitmapHeight+4; 923 else 924 itemHeight = infoPtr->nBitmapHeight+8; 925 926 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMHEIGHT,0,itemHeight); 927 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMHEIGHT,0,itemHeight); 928 929 infoPtr->changed = FALSE; 930 931 if (!TBCUSTOMIZE_FillData(hwnd,infoPtr)) EndDialog(hwnd,FALSE); 932 } else EndDialog(hwnd,FALSE); 933 934 return TRUE; 935 } 936 937 static BOOL TBCUSTOMIZE_Close(HWND hwnd,WPARAM wParam,LPARAM lParam) 938 { 939 EndDialog(hwnd,FALSE); 940 941 return TRUE; 942 } 943 944 static VOID TBCUSTOMIZE_Reset(HWND hwnd) 945 { 946 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 947 INT x; 948 949 if (!infoPtr->changed) return; 950 951 //Send TBN_RESET 952 sendNotify(infoPtr->hwndToolbar,TBN_RESET); 953 954 for (x = 0;x < infoPtr->nNumOldButtons;x++) COMCTL32_Free(infoPtr->oldButtons[x].pszName); 955 956 //restore data 957 if (infoPtr->nNumButtons != infoPtr->nNumOldButtons) 958 { 959 COMCTL32_Free(infoPtr->buttons); 960 infoPtr->nNumButtons = infoPtr->nNumOldButtons; 961 infoPtr->buttons = (TBUTTON_INFO*)COMCTL32_Alloc(infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 962 } 963 memcpy(&infoPtr->buttons[0],&infoPtr->oldButtons[0],infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 964 965 if (!TBCUSTOMIZE_FillData(hwnd,infoPtr)) EndDialog(hwnd,FALSE); 966 967 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 968 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 969 970 infoPtr->changed = FALSE; 971 } 972 973 static TBUTTON_INFO* TBCUSTOMIZE_GetBtnPtr(TOOLBAR_INFO* infoPtr,INT customID) 974 { 975 INT x; 976 TBUTTON_INFO* btnPtr = infoPtr->buttons; 977 978 if (customID == 0) return NULL; 979 980 for (x = 0;x < infoPtr->nNumButtons;btnPtr++) 981 if (btnPtr->nCustomID == customID) return btnPtr; 982 983 return NULL; 984 } 985 986 static VOID TBCUSTOMIZE_AddTool(HWND hwnd) 987 { 988 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 989 LRESULT pos,count; 990 INT customID; 991 TBUTTON_INFO* btnPtr; 992 LRESULT rightSel,rightCount,rightPos; 993 994 pos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 995 if (pos == (LRESULT)-1) return; 996 997 count = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCOUNT,0,0); 998 999 customID = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,pos,0); 1000 if (customID == 0) btnPtr = NULL; else 1001 { 1002 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1003 if (btnPtr == NULL) return; 1004 1005 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_DELETESTRING,pos,0); 1006 } 1007 1008 rightSel = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1009 rightCount = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1010 1011 if (rightSel != (LRESULT)-1) 1012 rightPos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_INSERTSTRING,rightSel,(LPARAM)""); 1013 else 1014 rightPos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 1015 if (!btnPtr) 1016 { //new separator 1017 TBUTTON_INFO* newButtons; 1018 1019 newButtons = (TBUTTON_INFO*)COMCTL32_Alloc((infoPtr->nNumButtons+1)*sizeof(TBUTTON_INFO)); 1020 memcpy(&newButtons[0],&infoPtr->buttons[0],infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 1021 COMCTL32_Free(infoPtr->buttons); 1022 1023 infoPtr->buttons = newButtons; 1024 infoPtr->nNumButtons++; 1025 1026 btnPtr = &infoPtr->buttons[infoPtr->nNumButtons-1]; 1027 ZeroMemory(btnPtr,sizeof(TBUTTON_INFO)); 1028 btnPtr->fsStyle = TBSTYLE_SEP; 1029 btnPtr->bDelete = TRUE; 1030 1031 customID = ++infoPtr->nMaxCustomID; 1032 btnPtr->nCustomID = customID; 1033 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,rightPos,customID); 1034 } else 1035 { 1036 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,rightPos,customID); 1037 btnPtr->fsState &= ~TBSTATE_HIDDEN; 1038 } 1039 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,rightPos,0); 1040 TBCUSTOMIZE_VisSelChange(hwnd); 1041 1042 if (rightCount > 0) 1043 { //change order 1044 TBUTTON_INFO* btnPtr2; 1045 INT customID2,pos1,pos2; 1046 1047 pos1 = 0; 1048 while (infoPtr->buttons[pos1].nCustomID != customID) pos1++; 1049 if (rightPos < rightCount) 1050 { //insert before 1051 customID2 = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,rightPos+1,0); 1052 pos2 = 0; 1053 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1054 } else 1055 { //insert behind 1056 INT x; 1057 1058 customID2 = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,rightPos-1,0); 1059 pos2 = 0; 1060 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1061 //exchange to use first alogrithm 1062 x = pos1; 1063 pos1 = pos2; 1064 pos2 = x; 1065 } 1066 1067 if (pos1+1 != pos2) 1068 { 1069 TBUTTON_INFO temp; 1070 INT x; 1071 1072 memcpy(&temp,&infoPtr->buttons[pos1],sizeof(TBUTTON_INFO)); 1073 if (pos1 < pos2) 1074 { 1075 for (x = pos1;x < pos2;x++) 1076 memcpy(&infoPtr->buttons[x],&infoPtr->buttons[x+1],sizeof(TBUTTON_INFO)); 1077 memcpy(&infoPtr->buttons[pos2-1],&temp,sizeof(TBUTTON_INFO)); 1078 } else 1079 { 1080 for (x = pos1-1;x >= pos2;x--) 1081 memcpy(&infoPtr->buttons[x+1],&infoPtr->buttons[x],sizeof(TBUTTON_INFO)); 1082 memcpy(&infoPtr->buttons[pos2],&temp,sizeof(TBUTTON_INFO)); 1083 } 1084 } 1085 } 1086 1087 if (pos == count-1 && pos > 0) pos--; 1088 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,pos,0); 1089 TBCUSTOMIZE_AvailSelChange(hwnd); 1090 1091 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1092 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 1093 1094 infoPtr->changed = TRUE; 1095 } 1096 1097 static VOID TBCUSTOMIZE_RemoveTool(HWND hwnd) 1098 { 1099 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1100 LRESULT pos,count; 1101 INT customID; 1102 TBUTTON_INFO* btnPtr; 1103 1104 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1105 if (pos == (LRESULT)-1) return; 1106 1107 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1108 1109 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1110 if (customID == 0) return; //no allowed 1111 1112 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1113 if (btnPtr == NULL || !btnPtr->bDelete) return; 1114 1115 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_DELETESTRING,pos,0); 1116 1117 if (btnPtr->fsStyle & TBSTYLE_SEP) 1118 { //remove separator 1119 TBUTTON_INFO* newButtons; 1120 INT nIndex,x; 1121 1122 //find pos 1123 for (x = 0;x < infoPtr->nNumButtons;x++) if (&infoPtr->buttons[x] == btnPtr) 1124 { 1125 nIndex = x; 1126 break; 1127 } 1128 1129 infoPtr->nNumButtons--; 1130 newButtons = (TBUTTON_INFO*)COMCTL32_Alloc(infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 1131 1132 if (nIndex > 0) 1133 memcpy(&newButtons[0],&infoPtr->buttons[0],nIndex*sizeof(TBUTTON_INFO)); 1134 1135 if (nIndex < infoPtr->nNumButtons) 1136 memcpy (&newButtons[nIndex],&infoPtr->buttons[nIndex+1],(infoPtr->nNumButtons-nIndex)*sizeof(TBUTTON_INFO)); 1137 1138 COMCTL32_Free(infoPtr->buttons); 1139 infoPtr->buttons = newButtons; 1140 } else 1141 { 1142 LRESULT leftSel,leftCount,leftPos; 1143 1144 leftSel = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 1145 leftCount = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCOUNT,0,0); 1146 1147 if (leftSel == 0) 1148 if (leftCount > 1) leftSel++; else leftSel = -1; 1149 1150 if (leftSel != (LRESULT)-1) 1151 leftPos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_INSERTSTRING,leftSel,(LPARAM)""); 1152 else 1153 leftPos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 1154 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,leftPos,customID); 1155 1156 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,leftPos,0); 1157 TBCUSTOMIZE_AvailSelChange(hwnd); 1158 1159 btnPtr->fsState |= TBSTATE_HIDDEN; 1160 1161 if (leftCount > 1) 1162 { //change order 1163 TBUTTON_INFO* btnPtr2; 1164 INT customID2,pos1,pos2; 1165 1166 pos1 = 0; 1167 while (infoPtr->buttons[pos1].nCustomID != customID) pos1++; 1168 if (leftPos < leftCount) 1169 { //insert before 1170 customID2 = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,leftPos+1,0); 1171 pos2 = 0; 1172 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1173 } else 1174 { //insert behind 1175 INT x; 1176 1177 customID2 = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,leftPos-1,0); 1178 pos2 = 0; 1179 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1180 //exchange to use first alogrithm 1181 x = pos1; 1182 pos1 = pos2; 1183 pos2 = x; 1184 } 1185 1186 if (pos1+1 != pos2) 1187 { 1188 TBUTTON_INFO temp; 1189 INT x; 1190 1191 memcpy(&temp,&infoPtr->buttons[pos1],sizeof(TBUTTON_INFO)); 1192 if (pos1 < pos2) 1193 { 1194 for (x = pos1;x < pos2;x++) 1195 memcpy(&infoPtr->buttons[x],&infoPtr->buttons[x+1],sizeof(TBUTTON_INFO)); 1196 memcpy(&infoPtr->buttons[pos2-1],&temp,sizeof(TBUTTON_INFO)); 1197 } else 1198 { 1199 for (x = pos1-1;x >= pos2;x--) 1200 memcpy(&infoPtr->buttons[x+1],&infoPtr->buttons[x],sizeof(TBUTTON_INFO)); 1201 memcpy(&infoPtr->buttons[pos2],&temp,sizeof(TBUTTON_INFO)); 1202 } 1203 } 1204 } 1205 } 1206 1207 if (pos == count-1) pos--; 1208 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos,0); 1209 TBCUSTOMIZE_VisSelChange(hwnd); 1210 1211 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1212 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 1213 1214 infoPtr->changed = TRUE; 1215 } 1216 1217 static VOID TBCUSTOMIZE_Help(HWND hwnd) 1218 { 1219 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1220 1221 //Send TBN_CUSTHELP 1222 sendNotify(infoPtr->hwndToolbar,TBN_CUSTHELP); 1223 } 1224 1225 static VOID TBCUSTOMIZE_MoveToolUp(HWND hwnd) 1226 { 1227 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1228 LRESULT pos; 1229 TBUTTON_INFO button; 1230 INT customID; 1231 TBUTTON_INFO* btnPtr1,* btnPtr2; 1232 1233 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1234 if (pos == (LRESULT)-1 || pos == 0) return; 1235 1236 //update listbox 1237 1238 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1239 btnPtr1 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1240 if (btnPtr1 == NULL) return; 1241 1242 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos-1,0); 1243 btnPtr2 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1244 if (btnPtr2 == NULL) return; 1245 1246 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos,btnPtr2->nCustomID); 1247 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos-1,btnPtr1->nCustomID); 1248 1249 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos-1,0); 1250 TBCUSTOMIZE_VisSelChange(hwnd); 1251 1252 //update buttons 1253 memcpy(&button,btnPtr1,sizeof(TBUTTON_INFO)); 1254 memcpy(btnPtr1,btnPtr2,sizeof(TBUTTON_INFO)); 1255 memcpy(btnPtr2,&button,sizeof(TBUTTON_INFO)); 1256 1257 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1258 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 1259 1260 infoPtr->changed = TRUE; 1261 } 1262 1263 static VOID TBCUSTOMIZE_MoveToolDown(HWND hwnd) 1264 { 1265 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1266 LRESULT pos,count; 1267 TBUTTON_INFO button; 1268 INT customID; 1269 TBUTTON_INFO* btnPtr1,* btnPtr2; 1270 1271 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1272 if (pos == (LRESULT)-1) return; 1273 1274 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1275 if (pos == count-1) return; 1276 1277 //update listbox 1278 1279 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1280 btnPtr1 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1281 if (btnPtr1 == NULL) return; 1282 1283 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos+1,0); 1284 btnPtr2 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1285 if (btnPtr2 == NULL) return; 1286 1287 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos,btnPtr2->nCustomID); 1288 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos+1,btnPtr1->nCustomID); 1289 1290 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos+1,0); 1291 TBCUSTOMIZE_VisSelChange(hwnd); 1292 1293 //update buttons 1294 memcpy(&button,btnPtr1,sizeof(TBUTTON_INFO)); 1295 memcpy(btnPtr1,btnPtr2,sizeof(TBUTTON_INFO)); 1296 memcpy(btnPtr2,&button,sizeof(TBUTTON_INFO)); 1297 1298 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1299 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 1300 1301 infoPtr->changed = TRUE; 1302 } 1303 1304 static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd) 1305 { 1306 LRESULT pos; 1307 HWND hwndBtn; 1308 1309 pos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 1310 1311 hwndBtn = GetDlgItem(hwnd,IDOK); 1312 EnableWindow(hwndBtn,(pos == (LRESULT)-1) ? FALSE:TRUE); 1313 } 1314 1315 static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd) 1316 { 1317 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1318 LRESULT pos; 1319 1320 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1321 1322 if (pos == (LRESULT)-1) 1323 { 1324 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),FALSE); 1325 EnableWindow(GetDlgItem(hwnd,IDC_MOVEUP_BTN),FALSE); 1326 EnableWindow(GetDlgItem(hwnd,IDC_MOVEDN_BTN),FALSE); 1327 } else 1328 { 1329 INT customID; 1330 TBUTTON_INFO* btnPtr; 1331 LRESULT count; 1332 1333 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1334 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1335 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1336 1337 if (btnPtr) 1338 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),btnPtr->bDelete); 1339 else 1340 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),TRUE); 1341 EnableWindow(GetDlgItem(hwnd,IDC_MOVEUP_BTN),!(pos == 0)); 1342 EnableWindow(GetDlgItem(hwnd,IDC_MOVEDN_BTN),!(pos == count-1)); 1343 } 1344 } 1345 1346 static BOOL TBCUSTOMIZE_Command(HWND hwnd,WPARAM wParam,LPARAM lParam) 1347 { 1348 switch(LOWORD(wParam)) 1349 { 1350 case IDCANCEL: 1351 EndDialog(hwnd,FALSE); 1352 break; 1353 1354 case IDC_RESET_BTN: 1355 TBCUSTOMIZE_Reset(hwnd); 1356 break; 1357 1358 case IDOK: //== add tool 1359 TBCUSTOMIZE_AddTool(hwnd); 1360 break; 1361 1362 case IDC_REMOVE_BTN: 1363 TBCUSTOMIZE_RemoveTool(hwnd); 1364 break; 1365 1366 case IDC_HELP_BTN: 1367 TBCUSTOMIZE_Help(hwnd); 1368 break; 1369 1370 case IDC_MOVEUP_BTN: 1371 TBCUSTOMIZE_MoveToolUp(hwnd); 1372 break; 1373 1374 case IDC_MOVEDN_BTN: 1375 TBCUSTOMIZE_MoveToolDown(hwnd); 1376 break; 1377 1378 case IDC_AVAILBTN_LBOX: 1379 switch(HIWORD(wParam)) 1380 { 1381 case LBN_SELCHANGE: 1382 TBCUSTOMIZE_AvailSelChange(hwnd); 1383 break; 1384 case LBN_DBLCLK: 1385 TBCUSTOMIZE_AddTool(hwnd); 1386 break; 1387 } 1388 break; 1389 1390 case IDC_TOOLBARBTN_LBOX: 1391 switch(HIWORD(wParam)) 1392 { 1393 case LBN_SELCHANGE: 1394 TBCUSTOMIZE_VisSelChange(hwnd); 1395 break; 1396 case LBN_DBLCLK: 1397 TBCUSTOMIZE_RemoveTool(hwnd); 1398 break; 1399 } 1400 break; 1401 } 1402 1403 return TRUE; 1404 } 1405 1406 static BOOL TBCUSTOMIZE_Destroy(HWND hwnd,WPARAM wParam,LPARAM lParam) 1407 { 1408 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1409 INT x; 1410 1411 for (x = 0;x < infoPtr->nNumOldButtons;x++) 1412 COMCTL32_Free(infoPtr->oldButtons[x].pszName); 1413 COMCTL32_Free(infoPtr->oldButtons); 1414 infoPtr->oldButtons = NULL; 1415 infoPtr->nNumOldButtons = 0; 1416 1417 return TRUE; 1418 } 1419 1420 static BOOL TBCUSTOMIZE_DrawItem(HWND hwnd,WPARAM wParam,LPARAM lParam) 1421 { 1422 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1423 { 1424 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1425 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 1426 RECT rcButton; 1427 RECT rcText; 1428 HPEN hOldPen; 1429 HBRUSH hOldBrush; 1430 COLORREF oldText = 0; 1431 COLORREF oldBk = 0; 1432 INT customID; 1433 TBUTTON_INFO* btnPtr; 1434 DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE); 1435 1436 customID = SendDlgItemMessageA(hwnd,wParam,LB_GETITEMDATA,lpdis->itemID,0); 1437 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1438 1439 if (btnPtr != NULL && !btnPtr->bDelete) 1440 { 1441 if (lpdis->itemState & ODS_FOCUS) oldBk = SetBkColor(lpdis->hDC,GetSysColor(COLOR_HIGHLIGHT)); 1442 oldText = SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT)); 1443 } else if (lpdis->itemState & ODS_FOCUS) 1444 { 1445 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); 1446 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 1447 } 1448 1449 1450 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1451 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1452 1453 /* fill background rectangle */ 1454 Rectangle (lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,lpdis->rcItem.right,lpdis->rcItem.bottom); 1455 1456 /* calculate button and text rectangles */ 1457 CopyRect (&rcButton, &lpdis->rcItem); 1458 InflateRect (&rcButton, -1, -1); 1459 CopyRect (&rcText, &rcButton); 1460 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6; 1461 rcText.left = rcButton.right + 2; 1462 1463 /* draw focus rectangle */ 1464 if (lpdis->itemState & ODS_FOCUS) DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1465 1466 //draw tool 1467 if (btnPtr && !(btnPtr->fsStyle & TBSTYLE_SEP)) 1468 { 1469 //draw button 1470 if (dwStyle & TBSTYLE_FLAT) 1471 { 1472 ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC,rcButton.left+2,rcButton.top+2,ILD_NORMAL); 1473 } else 1474 { 1475 DrawEdge (lpdis->hDC,&rcButton,EDGE_RAISED,BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 1476 1477 ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC,rcButton.left+1,rcButton.top+1,ILD_NORMAL); 1478 } 1479 1480 } else 1481 { //draw separator 1482 if (!(dwStyle & TBSTYLE_FLAT)) 1483 DrawEdge (lpdis->hDC,&rcButton,EDGE_RAISED,BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 1484 1485 TOOLBAR_DrawFlatSeparator(&rcButton,lpdis->hDC); 1486 } 1487 1488 /* draw text */ 1489 if (!btnPtr || btnPtr->fsStyle & TBSTYLE_SEP) 1490 { //new separator 1491 DrawTextA(lpdis->hDC,"Separator",-1,&rcText,DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1492 } else if (btnPtr->pszName != NULL) 1493 { 1494 DrawTextW(lpdis->hDC,btnPtr->pszName,-1,&rcText,DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1495 } 1496 1497 if (lpdis->itemState & ODS_FOCUS) 1498 { 1499 SetBkColor (lpdis->hDC, oldBk); 1500 SetTextColor (lpdis->hDC, oldText); 1501 } 1502 1503 SelectObject (lpdis->hDC, hOldBrush); 1504 SelectObject (lpdis->hDC, hOldPen); 1505 1506 return TRUE; 1507 } 1508 1509 return FALSE; 1510 } 849 1511 850 1512 /*********************************************************************** … … 855 1517 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 856 1518 { 857 TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER); 858 static HDSA hDsa = NULL; 1519 TOOLBAR_INFO *infoPtr; 859 1520 860 1521 switch (uMsg) 861 1522 { 862 case WM_INITDIALOG: 863 infoPtr = (TOOLBAR_INFO *)lParam; 864 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr); 865 866 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5); 867 868 if (infoPtr) 869 { 870 TBUTTON_INFO *btnPtr; 871 INT i; 872 873 /* insert 'virtual' separator button into 'available buttons' list */ 874 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 875 876 /* copy all buttons and append them to the right listbox */ 877 btnPtr = infoPtr->buttons; 878 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 879 { 880 DSA_InsertItem (hDsa, i, btnPtr); 881 882 /* FIXME: hidden buttons appear in the 'toolbar buttons' list too */ 883 if (btnPtr->fsState & TBSTATE_HIDDEN) 884 { 885 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 886 } 887 else 888 { 889 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 890 } 891 } 892 893 /* append 'virtual' separator button to the 'toolbar buttons' list */ 894 /* TODO */ 895 } 896 return TRUE; 897 898 case WM_CLOSE: 899 EndDialog(hwnd, FALSE); 900 return TRUE; 901 902 case WM_COMMAND: 903 switch (LOWORD(wParam)) 904 { 905 case IDCANCEL: 906 EndDialog(hwnd, FALSE); 907 break; 908 } 909 return TRUE; 910 911 case WM_DESTROY: 912 if (hDsa) 913 DSA_Destroy (hDsa); 914 return TRUE; 915 916 case WM_DRAWITEM: 917 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 918 { 919 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 920 TBUTTON_INFO btnPtr; 921 RECT rcButton; 922 RECT rcText; 923 HPEN hOldPen; 924 HBRUSH hOldBrush; 925 COLORREF oldText = 0; 926 COLORREF oldBk = 0; 927 928 // FIXME("action: %x itemState: %x\n", 929 // lpdis->itemAction, lpdis->itemState); 930 931 DSA_GetItem (hDsa, 0 /*lpdis->itemID*/, &btnPtr); 932 933 if (lpdis->itemState & ODS_FOCUS) 934 { 935 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); 936 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 937 } 938 939 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 940 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 941 942 /* fill background rectangle */ 943 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, 944 lpdis->rcItem.right, lpdis->rcItem.bottom); 945 946 /* calculate button and text rectangles */ 947 CopyRect (&rcButton, &lpdis->rcItem); 948 InflateRect (&rcButton, -1, -1); 949 CopyRect (&rcText, &rcButton); 950 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6; 951 rcText.left = rcButton.right + 2; 952 953 /* draw focus rectangle */ 954 if (lpdis->itemState & ODS_FOCUS) 955 DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 956 957 /* draw button */ 958 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); 959 960 /* draw image and text */ 961 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0) 962 { 963 /* virtual separator in the 'available' list */ 964 DrawTextA (lpdis->hDC, "Separator", -1, &rcText, 965 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 966 } 967 else 968 { 969 /* real button */ 970 971 ImageList_Draw (infoPtr->himlDef, btnPtr.iBitmap, lpdis->hDC, 972 rcButton.left+1, rcButton.top+1, ILD_NORMAL); 973 974 DrawTextW (lpdis->hDC, infoPtr->strings[btnPtr.iString], -1, &rcText, 975 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 976 977 } 978 979 if (lpdis->itemState & ODS_FOCUS) 980 { 981 SetBkColor (lpdis->hDC, oldBk); 982 SetTextColor (lpdis->hDC, oldText); 983 } 984 985 SelectObject (lpdis->hDC, hOldBrush); 986 SelectObject (lpdis->hDC, hOldPen); 987 988 return TRUE; 989 } 990 return FALSE; 991 992 case WM_MEASUREITEM: 993 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 994 { 995 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 996 997 if (infoPtr) 998 lpmis->itemHeight = infoPtr->nBitmapHeight + 8; 999 else 1000 lpmis->itemHeight = 15 + 8; /* default height */ 1001 1002 return TRUE; 1003 } 1004 return FALSE; 1005 1006 default: 1007 return FALSE; 1008 } 1009 } 1010 1523 case WM_INITDIALOG: 1524 return TBCUSTOMIZE_InitDialog(hwnd,wParam,lParam); 1525 1526 case WM_CLOSE: 1527 return TBCUSTOMIZE_Close(hwnd,wParam,lParam); 1528 1529 case WM_COMMAND: 1530 return TBCUSTOMIZE_Command(hwnd,wParam,lParam); 1531 1532 case WM_DESTROY: 1533 return TBCUSTOMIZE_Destroy(hwnd,wParam,lParam); 1534 1535 case WM_DRAWITEM: 1536 return TBCUSTOMIZE_DrawItem(hwnd,wParam,lParam); 1537 1538 default: 1539 return FALSE; 1540 } 1541 } 1011 1542 1012 1543 /*********************************************************************** … … 1019 1550 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1020 1551 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam; 1021 INT nIndex = 0, nButtons, nCount;1552 INT nIndex = 0,nButtons; 1022 1553 HBITMAP hbmLoad; 1023 1554 1024 // TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);1025 1555 if (!lpAddBmp) 1026 1556 return -1; 1027 1557 1028 1558 if (lpAddBmp->hInst == HINST_COMMCTRL) 1029 1559 { 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 //TRACE ("adding %d internal bitmaps!\n", nButtons);1040 1041 /* Windows resize all the buttons to the size of a newly added standard image*/1042 if (lpAddBmp->nID & 1) 1043 1044 1045 1046 1047 1048 1049 } 1050 else 1051 1052 1053 1054 1055 1056 1057 1058 1059 1560 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR) 1561 nButtons = 15; 1562 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR) 1563 nButtons = 13; 1564 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR) 1565 nButtons = 5; 1566 else 1567 return -1; 1568 1569 // TRACE ("adding %d internal bitmaps!\n", nButtons); 1570 1571 /* Windows resize all the buttons to the size of a newly added standard Image*/ 1572 if (lpAddBmp->nID & 1) 1573 { 1574 /* large icons */ 1575 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1576 MAKELPARAM((WORD)26, (WORD)26)); 1577 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1578 MAKELPARAM((WORD)33, (WORD)33)); 1579 } 1580 else 1581 { 1582 /* small icons */ 1583 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1584 MAKELPARAM((WORD)16, (WORD)16)); 1585 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1586 MAKELPARAM((WORD)22, (WORD)22)); 1587 } 1588 1589 TOOLBAR_CalcToolbar (hwnd); 1060 1590 } 1061 1591 else 1062 1592 { 1063 1064 1065 1066 1067 //TRACE ("adding %d bitmaps!\n", nButtons);1068 } 1069 1593 nButtons = (INT)wParam; 1594 if (nButtons <= 0) 1595 return -1; 1596 1597 //TRACE ("adding %d bitmaps!\n", nButtons); 1598 } 1599 1070 1600 if (!(infoPtr->himlDef)) { 1071 /* create new default image list */ 1072 // TRACE ("creating default image list!\n"); 1073 1601 /* create new default image list */ 1602 //TRACE ("creating default image list!\n"); 1603 /* It seems that the image list created is 1 pixel taller than the bitmap height */ 1604 //CB: nope, it's otherwise 1074 1605 infoPtr->himlDef = 1075 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight ,1606 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight-1, 1076 1607 ILC_COLOR | ILC_MASK, nButtons, 2); 1077 infoPtr->himlInt = infoPtr->himlDef; 1078 } 1079 1080 nCount = ImageList_GetImageCount(infoPtr->himlDef); 1608 infoPtr->himlInt = infoPtr->himlDef; 1609 } 1081 1610 1082 1611 /* Add bitmaps to the default image list */ 1083 1612 if (lpAddBmp->hInst == (HINSTANCE)0) 1084 1613 { 1085 nIndex = 1086 1087 1614 nIndex = 1615 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID, 1616 CLR_DEFAULT); 1088 1617 } 1089 1618 else if (lpAddBmp->hInst == HINST_COMMCTRL) 1090 1619 { 1091 1092 1093 {1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 //ERR ("invalid imagelist!\n");1145 1146 1620 /* Add system bitmaps */ 1621 switch (lpAddBmp->nID) 1622 { 1623 case IDB_STD_SMALL_COLOR: 1624 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1625 MAKEINTRESOURCEA(IDB_STD_SMALL)); 1626 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1627 hbmLoad, CLR_DEFAULT); 1628 DeleteObject (hbmLoad); 1629 break; 1630 1631 case IDB_STD_LARGE_COLOR: 1632 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1633 MAKEINTRESOURCEA(IDB_STD_LARGE)); 1634 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1635 hbmLoad, CLR_DEFAULT); 1636 DeleteObject (hbmLoad); 1637 break; 1638 1639 case IDB_VIEW_SMALL_COLOR: 1640 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1641 MAKEINTRESOURCEA(IDB_VIEW_SMALL)); 1642 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1643 hbmLoad, CLR_DEFAULT); 1644 DeleteObject (hbmLoad); 1645 break; 1646 1647 case IDB_VIEW_LARGE_COLOR: 1648 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1649 MAKEINTRESOURCEA(IDB_VIEW_LARGE)); 1650 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1651 hbmLoad, CLR_DEFAULT); 1652 DeleteObject (hbmLoad); 1653 break; 1654 1655 case IDB_HIST_SMALL_COLOR: 1656 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1657 MAKEINTRESOURCEA(IDB_HIST_SMALL)); 1658 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1659 hbmLoad, CLR_DEFAULT); 1660 DeleteObject (hbmLoad); 1661 break; 1662 1663 case IDB_HIST_LARGE_COLOR: 1664 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1665 MAKEINTRESOURCEA(IDB_HIST_LARGE)); 1666 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1667 hbmLoad, CLR_DEFAULT); 1668 DeleteObject (hbmLoad); 1669 break; 1670 1671 default: 1672 nIndex = ImageList_GetImageCount (infoPtr->himlDef); 1673 //ERR ("invalid imagelist!\n"); 1674 break; 1675 } 1147 1676 } 1148 1677 else 1149 1678 { 1150 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1151 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT); 1152 DeleteObject (hbmLoad); 1153 } 1154 1155 if (nIndex != -1) 1156 { 1157 INT imagecount = ImageList_GetImageCount(infoPtr->himlDef); 1158 1159 if (infoPtr->nNumBitmaps + nButtons != imagecount) 1160 { 1161 dprintf(("TOOLBAR_AddBitmap: Desired images do not match recieved images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n", 1162 infoPtr->nNumBitmaps, nCount, imagecount - nCount, 1163 infoPtr->nNumBitmaps+nButtons,imagecount)); 1164 1165 infoPtr->nNumBitmaps = imagecount; 1166 } 1167 else 1168 infoPtr->nNumBitmaps += nButtons; 1169 } 1679 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1680 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT); 1681 DeleteObject (hbmLoad); 1682 } 1683 1684 infoPtr->nNumBitmaps += nButtons; 1170 1685 1171 1686 return nIndex; … … 1180 1695 INT nOldButtons, nNewButtons, nAddButtons, nCount; 1181 1696 1182 // TRACE("adding %d buttons!\n", wParam); 1697 // TRACE (toolbar, "adding %d buttons!\n", wParam); 1698 1699 nAddButtons = (UINT)wParam; 1700 nOldButtons = infoPtr->nNumButtons; 1701 nNewButtons = nOldButtons+nAddButtons; 1702 1703 if (infoPtr->nNumButtons == 0) 1704 { 1705 infoPtr->buttons = (TBUTTON_INFO*)COMCTL32_Alloc(sizeof(TBUTTON_INFO)*nNewButtons); 1706 } else 1707 { 1708 TBUTTON_INFO* oldButtons = infoPtr->buttons; 1709 1710 infoPtr->buttons = (TBUTTON_INFO*)COMCTL32_Alloc(sizeof(TBUTTON_INFO)*nNewButtons); 1711 memcpy(&infoPtr->buttons[0], &oldButtons[0],nOldButtons * sizeof(TBUTTON_INFO)); 1712 COMCTL32_Free(oldButtons); 1713 } 1714 1715 infoPtr->nNumButtons = nNewButtons; 1716 1717 /* insert new button data */ 1718 for (nCount = 0; nCount < nAddButtons; nCount++) 1719 { 1720 TBUTTON_INFO* btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 1721 1722 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 1723 btnPtr->idCommand = lpTbb[nCount].idCommand; 1724 btnPtr->fsState = lpTbb[nCount].fsState; 1725 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 1726 btnPtr->dwData = lpTbb[nCount].dwData; 1727 btnPtr->iString = lpTbb[nCount].iString; 1728 btnPtr->bHot = FALSE; 1729 btnPtr->bDelete = FALSE; //only used in customize 1730 btnPtr->pszName = NULL; 1731 1732 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) 1733 { 1734 TTTOOLINFOA ti; 1735 1736 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 1737 ti.cbSize = sizeof (TTTOOLINFOA); 1738 ti.hwnd = hwnd; 1739 ti.uId = btnPtr->idCommand; 1740 ti.hinst = 0; 1741 ti.lpszText = LPSTR_TEXTCALLBACKA; 1742 1743 SendMessageA (infoPtr->hwndToolTip,TTM_ADDTOOLA,0,(LPARAM)&ti); 1744 } 1745 } 1746 1747 TOOLBAR_CalcToolbar(hwnd); 1748 1749 InvalidateRect(hwnd,NULL,FALSE); 1750 1751 return TRUE; 1752 } 1753 1754 static LRESULT 1755 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam) 1756 { 1757 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1758 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam; 1759 INT nOldButtons, nNewButtons, nAddButtons, nCount; 1760 1761 // TRACE("adding %d buttons!\n", wParam); 1183 1762 1184 1763 nAddButtons = (UINT)wParam; … … 1187 1766 1188 1767 if (infoPtr->nNumButtons == 0) { 1189 infoPtr->buttons = 1190 (TBUTTON_INFO*)COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);1768 infoPtr->buttons = 1769 (TBUTTON_INFO*)COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1191 1770 } 1192 1771 else { 1193 1194 1195 (TBUTTON_INFO*)COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);1196 1197 1772 TBUTTON_INFO *oldButtons = infoPtr->buttons; 1773 infoPtr->buttons = 1774 (TBUTTON_INFO*)COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1775 memcpy (&infoPtr->buttons[0], &oldButtons[0], 1776 nOldButtons * sizeof(TBUTTON_INFO)); 1198 1777 COMCTL32_Free (oldButtons); 1199 1778 } … … 1203 1782 /* insert new button data */ 1204 1783 for (nCount = 0; nCount < nAddButtons; nCount++) { 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 TTTOOLINFOAti;1216 1217 ZeroMemory (&ti, sizeof(TTTOOLINFOA));1218 ti.cbSize = sizeof (TTTOOLINFOA);1219 1220 1221 1222 ti.lpszText = LPSTR_TEXTCALLBACKA;1223 1224 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,1225 1226 1784 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 1785 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 1786 btnPtr->idCommand = lpTbb[nCount].idCommand; 1787 btnPtr->fsState = lpTbb[nCount].fsState; 1788 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 1789 btnPtr->dwData = lpTbb[nCount].dwData; 1790 btnPtr->iString = lpTbb[nCount].iString; 1791 btnPtr->bHot = FALSE; 1792 1793 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 1794 TTTOOLINFOW ti; 1795 1796 ZeroMemory (&ti, sizeof(TTTOOLINFOW)); 1797 ti.cbSize = sizeof (TTTOOLINFOW); 1798 ti.hwnd = hwnd; 1799 ti.uId = btnPtr->idCommand; 1800 ti.hinst = 0; 1801 ti.lpszText = LPSTR_TEXTCALLBACKW; 1802 1803 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 1804 0, (LPARAM)&ti); 1805 } 1227 1806 } 1228 1807 … … 1236 1815 1237 1816 static LRESULT 1238 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam) 1239 { 1240 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1241 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam; 1242 INT nOldButtons, nNewButtons, nAddButtons, nCount; 1243 1244 // TRACE("adding %d buttons!\n", wParam); 1245 1246 nAddButtons = (UINT)wParam; 1247 nOldButtons = infoPtr->nNumButtons; 1248 nNewButtons = nOldButtons + nAddButtons; 1249 1250 if (infoPtr->nNumButtons == 0) { 1251 infoPtr->buttons = 1252 (TBUTTON_INFO*)COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1817 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1818 { 1819 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1820 INT nIndex; 1821 1822 if ((wParam) && (HIWORD(lParam) == 0)) { 1823 char szString[256]; 1824 INT len; 1825 // TRACE (toolbar, "adding string from resource!\n"); 1826 1827 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam, 1828 szString, 256); 1829 1830 // TRACE (toolbar, "len=%d \"%s\"\n", len, szString); 1831 nIndex = infoPtr->nNumStrings; 1832 if (infoPtr->nNumStrings == 0) { 1833 infoPtr->strings = 1834 (LPWSTR*)COMCTL32_Alloc (sizeof(LPWSTR)); 1835 } 1836 else { 1837 LPWSTR *oldStrings = infoPtr->strings; 1838 infoPtr->strings = 1839 (LPWSTR*)COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1840 memcpy (&infoPtr->strings[0], &oldStrings[0], 1841 sizeof(LPWSTR) * infoPtr->nNumStrings); 1842 COMCTL32_Free (oldStrings); 1843 } 1844 1845 infoPtr->strings[infoPtr->nNumStrings] = 1846 (WCHAR*)COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1847 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString); 1848 infoPtr->nNumStrings++; 1253 1849 } 1254 1850 else { 1255 TBUTTON_INFO *oldButtons = infoPtr->buttons; 1256 infoPtr->buttons = 1257 (TBUTTON_INFO*)COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1258 memcpy (&infoPtr->buttons[0], &oldButtons[0], 1259 nOldButtons * sizeof(TBUTTON_INFO)); 1260 COMCTL32_Free (oldButtons); 1261 } 1262 1263 infoPtr->nNumButtons = nNewButtons; 1264 1265 /* insert new button data */ 1266 for (nCount = 0; nCount < nAddButtons; nCount++) { 1267 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 1268 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 1269 btnPtr->idCommand = lpTbb[nCount].idCommand; 1270 btnPtr->fsState = lpTbb[nCount].fsState; 1271 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 1272 btnPtr->dwData = lpTbb[nCount].dwData; 1273 btnPtr->iString = lpTbb[nCount].iString; 1274 btnPtr->bHot = FALSE; 1275 1276 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 1277 TTTOOLINFOW ti; 1278 1279 ZeroMemory (&ti, sizeof(TTTOOLINFOW)); 1280 ti.cbSize = sizeof (TTTOOLINFOW); 1281 ti.hwnd = hwnd; 1282 ti.uId = btnPtr->idCommand; 1283 ti.hinst = 0; 1284 ti.lpszText = LPSTR_TEXTCALLBACKW; 1285 1286 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 1287 0, (LPARAM)&ti); 1288 } 1289 } 1290 1291 TOOLBAR_CalcToolbar (hwnd); 1292 1293 InvalidateRect(hwnd, NULL, FALSE); 1294 1295 return TRUE; 1296 } 1297 1298 1299 static LRESULT 1300 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1301 { 1302 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1303 INT nIndex; 1304 1305 if ((wParam) && (HIWORD(lParam) == 0)) { 1306 char szString[256]; 1307 INT len; 1308 // TRACE("adding string from resource!\n"); 1309 1310 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam, 1311 szString, 256); 1312 1313 // TRACE("len=%d \"%s\"\n", len, szString); 1314 nIndex = infoPtr->nNumStrings; 1315 if (infoPtr->nNumStrings == 0) { 1316 infoPtr->strings = 1317 (LPWSTR*) COMCTL32_Alloc (sizeof(LPWSTR)); 1318 } 1319 else { 1320 LPWSTR *oldStrings = infoPtr->strings; 1321 infoPtr->strings = 1322 (LPWSTR*) COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1323 memcpy (&infoPtr->strings[0], &oldStrings[0], 1324 sizeof(LPWSTR) * infoPtr->nNumStrings); 1325 COMCTL32_Free (oldStrings); 1326 } 1327 1328 infoPtr->strings[infoPtr->nNumStrings] = 1329 (WCHAR*)COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1330 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString); 1331 infoPtr->nNumStrings++; 1332 } 1333 else { 1334 LPSTR p = (LPSTR)lParam; 1335 INT len; 1336 1337 if (p == NULL) 1338 return -1; 1339 // TRACE("adding string(s) from array!\n"); 1340 1341 nIndex = infoPtr->nNumStrings; 1342 while (*p) { 1343 len = lstrlenA (p); 1344 // TRACE("len=%d \"%s\"\n", len, p); 1345 1346 if (infoPtr->nNumStrings == 0) { 1347 infoPtr->strings = 1348 (LPWSTR*) COMCTL32_Alloc (sizeof(LPWSTR)); 1349 } 1350 else { 1351 LPWSTR *oldStrings = infoPtr->strings; 1352 infoPtr->strings = 1353 (LPWSTR*) COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1354 memcpy (&infoPtr->strings[0], &oldStrings[0], 1355 sizeof(LPWSTR) * infoPtr->nNumStrings); 1356 COMCTL32_Free (oldStrings); 1357 } 1358 1359 infoPtr->strings[infoPtr->nNumStrings] = 1360 (WCHAR*)COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1361 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p); 1362 infoPtr->nNumStrings++; 1363 1364 p += (len+1); 1365 } 1366 } 1367 1368 return nIndex; 1369 } 1370 1371 1372 static LRESULT 1373 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) 1374 { 1375 #define MAX_RESOURCE_STRING_LENGTH 512 1376 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1377 INT nIndex; 1378 1379 if ((wParam) && (HIWORD(lParam) == 0)) { 1380 WCHAR szString[MAX_RESOURCE_STRING_LENGTH]; 1381 INT len; 1382 // TRACE("adding string from resource!\n"); 1383 1384 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam, 1385 szString, MAX_RESOURCE_STRING_LENGTH); 1386 1387 // TRACE("len=%d \"%s\"\n", len, debugstr_w(szString)); 1388 // TRACE("First char: 0x%x\n", *szString); 1389 if (szString[0] == L'|') 1390 { 1391 PWSTR p = szString + 1; 1392 1393 nIndex = infoPtr->nNumStrings; 1394 while (*p != L'|') { 1395 1396 if (infoPtr->nNumStrings == 0) { 1397 infoPtr->strings = 1398 (LPWSTR*)COMCTL32_Alloc (sizeof(LPWSTR)); 1399 } 1400 else { 1401 LPWSTR *oldStrings = infoPtr->strings; 1402 infoPtr->strings = 1403 (LPWSTR*)COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1404 memcpy (&infoPtr->strings[0], &oldStrings[0], 1405 sizeof(LPWSTR) * infoPtr->nNumStrings); 1406 COMCTL32_Free (oldStrings); 1407 } 1408 1409 len = COMCTL32_StrChrW (p, L'|') - p; 1410 // TRACE("len=%d \"%s\"\n", len, debugstr_w(p)); 1411 infoPtr->strings[infoPtr->nNumStrings] = 1412 (WCHAR *)COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1413 lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len); 1414 infoPtr->nNumStrings++; 1415 1416 p += (len+1); 1417 } 1418 } 1419 else 1420 { 1421 nIndex = infoPtr->nNumStrings; 1851 LPSTR p = (LPSTR)lParam; 1852 INT len; 1853 1854 if (p == NULL) 1855 return -1; 1856 // TRACE (toolbar, "adding string(s) from array!\n"); 1857 nIndex = infoPtr->nNumStrings; 1858 while (*p) { 1859 len = lstrlenA (p); 1860 // TRACE (toolbar, "len=%d \"%s\"\n", len, p); 1861 1422 1862 if (infoPtr->nNumStrings == 0) { 1423 1863 infoPtr->strings = … … 1435 1875 infoPtr->strings[infoPtr->nNumStrings] = 1436 1876 (WCHAR*)COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1437 lstrcpy W (infoPtr->strings[infoPtr->nNumStrings], szString);1877 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p); 1438 1878 infoPtr->nNumStrings++; 1439 } 1879 1880 p += (len+1); 1881 } 1882 } 1883 1884 return nIndex; 1885 } 1886 1887 1888 static LRESULT 1889 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) 1890 { 1891 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1892 INT nIndex; 1893 1894 if ((wParam) && (HIWORD(lParam) == 0)) { 1895 WCHAR szString[256]; 1896 INT len; 1897 // TRACE (toolbar, "adding string from resource!\n"); 1898 1899 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam, 1900 szString, 256); 1901 1902 // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString)); 1903 nIndex = infoPtr->nNumStrings; 1904 if (infoPtr->nNumStrings == 0) { 1905 infoPtr->strings = 1906 (LPWSTR*)COMCTL32_Alloc (sizeof(LPWSTR)); 1907 } 1908 else { 1909 LPWSTR *oldStrings = infoPtr->strings; 1910 infoPtr->strings = 1911 (LPWSTR*)COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1912 memcpy (&infoPtr->strings[0], &oldStrings[0], 1913 sizeof(LPWSTR) * infoPtr->nNumStrings); 1914 COMCTL32_Free (oldStrings); 1915 } 1916 1917 infoPtr->strings[infoPtr->nNumStrings] = 1918 (WCHAR*)COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1919 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString); 1920 infoPtr->nNumStrings++; 1440 1921 } 1441 1922 else { 1442 1443 1444 1445 1446 1447 // TRACE("adding string(s) from array!\n");1448 1449 1450 1451 1452 // TRACE("len=%d \"%s\"\n", len, debugstr_w(p)); 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1923 LPWSTR p = (LPWSTR)lParam; 1924 INT len; 1925 1926 if (p == NULL) 1927 return -1; 1928 // TRACE (toolbar, "adding string(s) from array!\n"); 1929 nIndex = infoPtr->nNumStrings; 1930 while (*p) { 1931 len = lstrlenW (p); 1932 // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p)); 1933 1934 if (infoPtr->nNumStrings == 0) { 1935 infoPtr->strings = 1936 (LPWSTR*)COMCTL32_Alloc (sizeof(LPWSTR)); 1937 } 1938 else { 1939 LPWSTR *oldStrings = infoPtr->strings; 1940 infoPtr->strings = 1941 (LPWSTR*)COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1942 memcpy (&infoPtr->strings[0], &oldStrings[0], 1943 sizeof(LPWSTR) * infoPtr->nNumStrings); 1944 COMCTL32_Free (oldStrings); 1945 } 1946 1947 infoPtr->strings[infoPtr->nNumStrings] = 1948 (WCHAR*)COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1949 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p); 1950 infoPtr->nNumStrings++; 1951 1952 p += (len+1); 1953 } 1473 1954 } 1474 1955 … … 1483 1964 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 1484 1965 RECT parent_rect; 1485 RECT window_rect;1486 1966 HWND parent; 1487 1967 INT x, y; 1488 1968 INT cx, cy; 1489 UINT uPosFlags = SWP_NOZORDER; 1490 1491 // TRACE("resize forced, style=%lx!\n", dwStyle); 1492 1969 UINT uPosFlags = 0; 1970 1971 //TRACE (toolbar, "resize forced!\n"); 1972 1973 x = y = 0; 1493 1974 parent = GetParent (hwnd); 1494 1975 GetClientRect(parent, &parent_rect); 1495 1976 1496 x = parent_rect.left;1497 y = parent_rect.top;1498 1499 1977 if (dwStyle & CCS_NORESIZE) { 1500 1501 1502 1978 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 1979 cx = 0; 1980 cy = 0; 1503 1981 } 1504 1982 else { 1505 infoPtr->nWidth = parent_rect.right - parent_rect.left; 1506 TOOLBAR_CalcToolbar (hwnd); 1507 InvalidateRect( hwnd, NULL, TRUE ); 1508 cy = infoPtr->nHeight; 1509 cx = infoPtr->nWidth; 1510 1511 if (dwStyle & CCS_NOMOVEY) { 1512 GetWindowRect(hwnd, &window_rect); 1513 ScreenToClient(parent, (LPPOINT)&window_rect.left); 1514 y = window_rect.top; 1515 } 1983 infoPtr->nWidth = parent_rect.right - parent_rect.left; 1984 TOOLBAR_CalcToolbar (hwnd); 1985 InvalidateRect( hwnd, NULL, TRUE ); 1986 cy = infoPtr->nHeight; 1987 cx = infoPtr->nWidth; 1516 1988 } 1517 1989 1518 1990 if (dwStyle & CCS_NOPARENTALIGN) 1519 1991 uPosFlags |= SWP_NOMOVE; 1520 1992 1521 1993 if (!(dwStyle & CCS_NODIVIDER)) 1522 1994 cy += GetSystemMetrics(SM_CYEDGE); 1523 1995 1524 1996 if (dwStyle & WS_BORDER) … … 1531 2003 infoPtr->bAutoSize = TRUE; 1532 2004 SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y, 1533 cx, cy, uPosFlags); 2005 cx, cy, uPosFlags); 2006 1534 2007 /* The following line makes sure that the infoPtr->bAutoSize is turned off after 1535 2008 * the setwindowpos calls */ … … 1555 2028 1556 2029 if (infoPtr == NULL) { 1557 // ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);1558 // ERR("infoPtr == NULL!\n");1559 2030 // ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam); 2031 // ERR (toolbar, "infoPtr == NULL!\n"); 2032 return 0; 1560 2033 } 1561 2034 … … 1571 2044 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1572 2045 TBUTTON_INFO *btnPtr; 2046 HDC hdc; 1573 2047 INT nIndex; 1574 2048 1575 2049 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1576 2050 if (nIndex == -1) 1577 2051 return FALSE; 1578 2052 1579 2053 btnPtr = &infoPtr->buttons[nIndex]; 1580 2054 btnPtr->iBitmap = LOWORD(lParam); 1581 2055 1582 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 2056 hdc = GetDC (hwnd); 2057 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2058 ReleaseDC (hwnd, hdc); 1583 2059 1584 2060 return TRUE; … … 1591 2067 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1592 2068 TBUTTON_INFO *btnPtr; 2069 HDC hdc; 1593 2070 INT nIndex; 1594 2071 INT nOldIndex = -1; … … 1597 2074 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1598 2075 if (nIndex == -1) 1599 2076 return FALSE; 1600 2077 1601 2078 btnPtr = &infoPtr->buttons[nIndex]; 1602 2079 1603 2080 if (!(btnPtr->fsStyle & TBSTYLE_CHECK)) 1604 2081 return FALSE; 1605 2082 1606 2083 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE; 1607 2084 1608 2085 if (LOWORD(lParam) == FALSE) 1609 2086 btnPtr->fsState &= ~TBSTATE_CHECKED; 1610 2087 else { 1611 1612 nOldIndex = 1613 1614 1615 1616 1617 1618 1619 2088 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 2089 nOldIndex = 2090 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex); 2091 if (nOldIndex == nIndex) 2092 return 0; 2093 if (nOldIndex != -1) 2094 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 2095 } 2096 btnPtr->fsState |= TBSTATE_CHECKED; 1620 2097 } 1621 2098 1622 2099 if( bChecked != LOWORD(lParam) ) 1623 2100 { 1624 if (nOldIndex != -1) 1625 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, TRUE); 1626 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 2101 hdc = GetDC (hwnd); 2102 if (nOldIndex != -1) 2103 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc); 2104 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2105 ReleaseDC (hwnd, hdc); 1627 2106 } 1628 2107 … … 1640 2119 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1641 2120 } 1642 1643 2121 1644 2122 static LRESULT … … 1649 2127 LPCVOID temp; 1650 2128 HRSRC hRes; 1651 NMHDR nmhdr; 2129 2130 if (infoPtr->nNumButtons == 0) return 0; 1652 2131 1653 2132 /* send TBN_BEGINADJUST notification */ 1654 nmhdr.hwndFrom = hwnd; 1655 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1656 nmhdr.code = TBN_BEGINADJUST; 1657 1658 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 1659 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 2133 sendNotify(hwnd,TBN_BEGINADJUST); 1660 2134 1661 2135 if (!(hRes = FindResourceA (COMCTL32_hModule, 1662 2136 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE), 1663 2137 RT_DIALOGA))) 1664 2138 return FALSE; 1665 2139 1666 2140 if(!(temp = (LPVOID)LoadResource (COMCTL32_hModule, hRes))) 1667 2141 return FALSE; 1668 2142 1669 2143 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE), … … 1674 2148 1675 2149 /* send TBN_ENDADJUST notification */ 1676 nmhdr.code = TBN_ENDADJUST; 1677 1678 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 1679 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 2150 sendNotify(hwnd,TBN_ENDADJUST); 1680 2151 1681 2152 return ret; … … 1690 2161 1691 2162 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 1692 return FALSE; 1693 1694 if ((infoPtr->hwndToolTip) && 1695 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) { 1696 TTTOOLINFOA ti; 1697 1698 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 1699 ti.cbSize = sizeof (TTTOOLINFOA); 1700 ti.hwnd = hwnd; 1701 ti.uId = infoPtr->buttons[nIndex].idCommand; 1702 1703 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti); 1704 } 1705 1706 if (infoPtr->nNumButtons == 1) { 1707 // TRACE(" simple delete!\n"); 1708 COMCTL32_Free (infoPtr->buttons); 1709 infoPtr->buttons = NULL; 1710 infoPtr->nNumButtons = 0; 1711 } 1712 else { 1713 TBUTTON_INFO *oldButtons = infoPtr->buttons; 1714 // TRACE("complex delete! [nIndex=%d]\n", nIndex); 1715 1716 infoPtr->nNumButtons--; 1717 infoPtr->buttons = (TBUTTON_INFO*)COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 2163 return FALSE; 2164 2165 if ((infoPtr->hwndToolTip) && 2166 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) { 2167 TTTOOLINFOA ti; 2168 2169 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2170 ti.cbSize = sizeof (TTTOOLINFOA); 2171 ti.hwnd = hwnd; 2172 ti.uId = infoPtr->buttons[nIndex].idCommand; 2173 2174 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti); 2175 } 2176 2177 COMCTL32_Free(infoPtr->buttons[nIndex].pszName); 2178 2179 if (infoPtr->nNumButtons == 1) 2180 { 2181 // TRACE (toolbar, " simple delete!\n"); 2182 COMCTL32_Free (infoPtr->buttons); 2183 infoPtr->buttons = NULL; 2184 infoPtr->nNumButtons = 0; 2185 } else 2186 { 2187 TBUTTON_INFO *oldButtons = infoPtr->buttons; 2188 // TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex); 2189 2190 infoPtr->nNumButtons--; 2191 infoPtr->buttons = (TBUTTON_INFO*)COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 1718 2192 if (nIndex > 0) { 1719 2193 memcpy (&infoPtr->buttons[0], &oldButtons[0], … … 1726 2200 } 1727 2201 1728 2202 COMCTL32_Free (oldButtons); 1729 2203 } 1730 2204 … … 1742 2216 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1743 2217 TBUTTON_INFO *btnPtr; 2218 HDC hdc; 1744 2219 INT nIndex; 1745 DWORD bState;2220 BOOL bEnabled = FALSE; 1746 2221 1747 2222 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1748 2223 if (nIndex == -1) 1749 2224 return FALSE; 1750 2225 1751 2226 btnPtr = &infoPtr->buttons[nIndex]; 1752 1753 bState = btnPtr->fsState & TBSTATE_ENABLED; 1754 1755 /* update the toolbar button state */1756 if(LOWORD(lParam) == FALSE) {1757 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);1758 } else { 1759 btnPtr->fsState |= TBSTATE_ENABLED; 1760 }1761 1762 /* redraw the button only if the state of the button changed */1763 if(bState != (btnPtr->fsState & TBSTATE_ENABLED))1764 InvalidateRect(hwnd, &btnPtr->rect, TRUE);2227 bEnabled = (btnPtr->fsState & TBSTATE_ENABLED )? TRUE : FALSE ; 2228 2229 if (LOWORD(lParam) == FALSE) 2230 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED); 2231 else 2232 btnPtr->fsState |= TBSTATE_ENABLED; 2233 2234 if( bEnabled != LOWORD(lParam) ) 2235 { 2236 hdc = GetDC (hwnd); 2237 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2238 ReleaseDC (hwnd, hdc); 2239 } 1765 2240 1766 2241 return TRUE; … … 1768 2243 1769 2244 1770 static inlineLRESULT2245 static LRESULT 1771 2246 TOOLBAR_GetAnchorHighlight (HWND hwnd) 1772 2247 { … … 1785 2260 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1786 2261 if (nIndex == -1) 1787 2262 return -1; 1788 2263 1789 2264 return infoPtr->buttons[nIndex].iBitmap; … … 1791 2266 1792 2267 1793 static inlineLRESULT2268 static LRESULT 1794 2269 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam) 1795 2270 { … … 1807 2282 1808 2283 if (infoPtr == NULL) 1809 2284 return FALSE; 1810 2285 1811 2286 if (lpTbb == NULL) 1812 2287 return FALSE; 1813 2288 1814 2289 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 1815 2290 return FALSE; 1816 2291 1817 2292 btnPtr = &infoPtr->buttons[nIndex]; … … 1836 2311 1837 2312 if (infoPtr == NULL) 1838 2313 return -1; 1839 2314 if (lpTbInfo == NULL) 1840 2315 return -1; 1841 2316 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA)) 1842 2317 return -1; 1843 2318 1844 2319 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1845 2320 if (nIndex == -1) 1846 2321 return -1; 1847 2322 1848 2323 btnPtr = &infoPtr->buttons[nIndex]; 1849 2324 1850 2325 if (lpTbInfo->dwMask & TBIF_COMMAND) 1851 2326 lpTbInfo->idCommand = btnPtr->idCommand; 1852 2327 if (lpTbInfo->dwMask & TBIF_IMAGE) 1853 2328 lpTbInfo->iImage = btnPtr->iBitmap; 1854 2329 if (lpTbInfo->dwMask & TBIF_LPARAM) 1855 2330 lpTbInfo->lParam = btnPtr->dwData; 1856 2331 if (lpTbInfo->dwMask & TBIF_SIZE) 1857 2332 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 1858 2333 if (lpTbInfo->dwMask & TBIF_STATE) 1859 2334 lpTbInfo->fsState = btnPtr->fsState; 1860 2335 if (lpTbInfo->dwMask & TBIF_STYLE) 1861 lpTbInfo->fsStyle = btnPtr->fsStyle; 1862 if (lpTbInfo->dwMask & TBIF_TEXT) { 1863 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) 1864 { 1865 lstrcpynWtoA (lpTbInfo->pszText, 1866 (LPWSTR)infoPtr->strings[btnPtr->iString], 1867 lpTbInfo->cchText); 1868 } 1869 else lpTbInfo->pszText[0]=0; 1870 } 2336 lpTbInfo->fsStyle = btnPtr->fsStyle; 2337 if (lpTbInfo->dwMask & TBIF_TEXT) { 2338 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings)) 2339 lstrcpynWtoA (lpTbInfo->pszText, 2340 infoPtr->strings[btnPtr->iString], 2341 lpTbInfo->cchText); 2342 } 2343 1871 2344 return nIndex; 1872 2345 } 1873 2346 1874 1875 static LRESULT 1876 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) 2347 static LRESULT TOOLBAR_GetButtonInfoW(HWND hwnd,WPARAM wParam,LPARAM lParam) 1877 2348 { 1878 2349 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); … … 1882 2353 1883 2354 if (infoPtr == NULL) 1884 2355 return -1; 1885 2356 if (lpTbInfo == NULL) 1886 2357 return -1; 1887 2358 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW)) 1888 2359 return -1; 1889 2360 1890 2361 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1891 2362 if (nIndex == -1) 1892 2363 return -1; 1893 2364 1894 2365 btnPtr = &infoPtr->buttons[nIndex]; 1895 2366 1896 2367 if (lpTbInfo->dwMask & TBIF_COMMAND) 1897 2368 lpTbInfo->idCommand = btnPtr->idCommand; 1898 2369 if (lpTbInfo->dwMask & TBIF_IMAGE) 1899 2370 lpTbInfo->iImage = btnPtr->iBitmap; 1900 2371 if (lpTbInfo->dwMask & TBIF_LPARAM) 1901 2372 lpTbInfo->lParam = btnPtr->dwData; 1902 2373 if (lpTbInfo->dwMask & TBIF_SIZE) 1903 2374 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 1904 2375 if (lpTbInfo->dwMask & TBIF_STATE) 1905 2376 lpTbInfo->fsState = btnPtr->fsState; 1906 2377 if (lpTbInfo->dwMask & TBIF_STYLE) 1907 2378 lpTbInfo->fsStyle = btnPtr->fsStyle; 1908 2379 if (lpTbInfo->dwMask & TBIF_TEXT) { 1909 1910 1911 (LPWSTR)infoPtr->strings[btnPtr->iString],1912 2380 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings)) 2381 lstrcpynW (lpTbInfo->pszText, 2382 infoPtr->strings[btnPtr->iString], 2383 lpTbInfo->cchText); 1913 2384 } 1914 2385 … … 1923 2394 1924 2395 return MAKELONG((WORD)infoPtr->nButtonWidth, 1925 2396 (WORD)infoPtr->nButtonHeight); 1926 2397 } 1927 2398 … … 1935 2406 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1936 2407 if (nIndex == -1) 1937 2408 return -1; 1938 2409 1939 2410 nStringIndex = infoPtr->buttons[nIndex].iString; 1940 2411 1941 // TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);2412 // TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex); 1942 2413 1943 2414 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 1944 return -1; 1945 1946 if (lParam == 0) 1947 return -1; 1948 1949 lstrcpyWtoA ((LPSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]); 1950 1951 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]); 1952 } 1953 1954 1955 static LRESULT 1956 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) 2415 return -1; 2416 2417 if (lParam == 0) return -1; 2418 2419 lstrcpyWtoA ((LPSTR)lParam, infoPtr->strings[nStringIndex]); 2420 2421 return lstrlenW (infoPtr->strings[nStringIndex]); 2422 } 2423 2424 static LRESULT TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) 1957 2425 { 1958 2426 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); … … 1961 2429 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1962 2430 if (nIndex == -1) 1963 2431 return -1; 1964 2432 1965 2433 nStringIndex = infoPtr->buttons[nIndex].iString; 1966 2434 1967 // TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);2435 // TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex); 1968 2436 1969 2437 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 1970 return -1; 1971 1972 if (lParam == 0) 1973 return -1; 1974 1975 lstrcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]); 1976 1977 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]); 1978 } 1979 1980 2438 return -1; 2439 2440 if (lParam == 0) return -1; 2441 2442 lstrcpyW ((LPWSTR)lParam, infoPtr->strings[nStringIndex]); 2443 2444 return lstrlenW (infoPtr->strings[nStringIndex]); 2445 } 2446 2447 /* << TOOLBAR_GetButtonText32W >> */ 1981 2448 /* << TOOLBAR_GetColorScheme >> */ 1982 2449 … … 1991 2458 1992 2459 1993 inlinestatic LRESULT2460 static LRESULT 1994 2461 TOOLBAR_GetExtendedStyle (HWND hwnd) 1995 2462 { … … 2015 2482 2016 2483 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)) 2017 2484 return -1; 2018 2485 2019 2486 if (infoPtr->nHotItem < 0) 2020 2487 return -1; 2021 2488 2022 2489 return (LRESULT)infoPtr->nHotItem; … … 2046 2513 2047 2514 if (infoPtr == NULL) 2048 2515 return FALSE; 2049 2516 nIndex = (INT)wParam; 2050 2517 btnPtr = &infoPtr->buttons[nIndex]; 2051 2518 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2052 2519 return FALSE; 2053 2520 lpRect = (LPRECT)lParam; 2054 2521 if (lpRect == NULL) 2055 2522 return FALSE; 2056 2523 if (btnPtr->fsState & TBSTATE_HIDDEN) 2057 2058 2524 return FALSE; 2525 2059 2526 TOOLBAR_CalcToolbar( hwnd ); 2060 2527 2061 2528 lpRect->left = btnPtr->rect.left; 2062 2529 lpRect->right = btnPtr->rect.right; … … 2075 2542 2076 2543 if (lpSize == NULL) 2077 2544 return FALSE; 2078 2545 2079 2546 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left; 2080 2547 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top; 2081 2548 2082 // TRACE("maximum size %d x %d\n",2083 //infoPtr->rcBound.right - infoPtr->rcBound.left,2084 //infoPtr->rcBound.bottom - infoPtr->rcBound.top);2549 // TRACE (toolbar, "maximum size %d x %d\n", 2550 // infoPtr->rcBound.right - infoPtr->rcBound.left, 2551 // infoPtr->rcBound.bottom - infoPtr->rcBound.top); 2085 2552 2086 2553 return TRUE; … … 2101 2568 2102 2569 if (infoPtr == NULL) 2103 2570 return FALSE; 2104 2571 nIndex = (INT)wParam; 2105 2572 btnPtr = &infoPtr->buttons[nIndex]; 2106 2573 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2107 2574 return FALSE; 2108 2575 lpRect = (LPRECT)lParam; 2109 2576 if (lpRect == NULL) 2110 2111 2577 return FALSE; 2578 2112 2579 lpRect->left = btnPtr->rect.left; 2113 2580 lpRect->right = btnPtr->rect.right; … … 2125 2592 2126 2593 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE) 2127 2594 return infoPtr->nRows; 2128 2595 else 2129 2596 return 1; 2130 2597 } 2131 2598 … … 2139 2606 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2140 2607 if (nIndex == -1) 2141 2608 return -1; 2142 2609 2143 2610 return infoPtr->buttons[nIndex].fsState; … … 2153 2620 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2154 2621 if (nIndex == -1) 2155 2622 return -1; 2156 2623 2157 2624 return infoPtr->buttons[nIndex].fsStyle; … … 2165 2632 2166 2633 if (infoPtr == NULL) 2167 2634 return 0; 2168 2635 2169 2636 return infoPtr->nMaxTextRows; … … 2176 2643 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2177 2644 2178 if (infoPtr == NULL) 2179 return 0; 2645 if (infoPtr == NULL) return 0; 2180 2646 return infoPtr->hwndToolTip; 2181 }2182 2183 2184 static LRESULT2185 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)2186 {2187 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);2188 2189 // TRACE("%s hwnd=0x%x stub!\n",2190 // infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);2191 2192 return infoPtr->bUnicode;2193 }2194 2195 2196 inline static LRESULT2197 TOOLBAR_GetVersion (HWND hwnd)2198 {2199 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);2200 return infoPtr->iVersion;2201 2647 } 2202 2648 … … 2211 2657 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2212 2658 if (nIndex == -1) 2213 2659 return FALSE; 2214 2660 2215 2661 btnPtr = &infoPtr->buttons[nIndex]; 2216 2662 if (LOWORD(lParam) == FALSE) 2217 2663 btnPtr->fsState &= ~TBSTATE_HIDDEN; 2218 2664 else 2219 2665 btnPtr->fsState |= TBSTATE_HIDDEN; 2220 2666 2221 2667 TOOLBAR_CalcToolbar (hwnd); … … 2227 2673 2228 2674 2229 inlinestatic LRESULT2675 static LRESULT 2230 2676 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam) 2231 2677 { … … 2239 2685 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2240 2686 TBUTTON_INFO *btnPtr; 2687 HDC hdc; 2241 2688 INT nIndex; 2242 2689 2243 2690 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2244 2691 if (nIndex == -1) 2245 2692 return FALSE; 2246 2693 2247 2694 btnPtr = &infoPtr->buttons[nIndex]; 2248 2695 if (LOWORD(lParam) == FALSE) 2249 2696 btnPtr->fsState &= ~TBSTATE_INDETERMINATE; 2250 2697 else 2251 btnPtr->fsState |= TBSTATE_INDETERMINATE; 2252 2253 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 2698 btnPtr->fsState |= TBSTATE_INDETERMINATE; 2699 2700 hdc = GetDC (hwnd); 2701 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2702 ReleaseDC (hwnd, hdc); 2254 2703 2255 2704 return TRUE; … … 2266 2715 2267 2716 if (lpTbb == NULL) 2268 2717 return FALSE; 2269 2718 2270 2719 if (nIndex == -1) { 2271 2720 /* EPP: this seems to be an undocumented call (from my IE4) 2272 * I assume in that case that: 2273 * - lpTbb->iString is a string pointer (not a string index in strings[] table 2274 * - index of insertion is at the end of existing buttons 2275 * I only see this happen with nIndex == -1, but it could have a special 2276 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion). 2277 */ 2278 int len; 2279 LPSTR ptr; 2280 2281 if(lpTbb->iString) { 2282 len = lstrlenA((char*)lpTbb->iString) + 2; 2283 ptr = (CHAR*)COMCTL32_Alloc(len); 2284 nIndex = infoPtr->nNumButtons; 2285 strcpy(ptr, (char*)lpTbb->iString); 2286 ptr[len - 1] = 0; /* ended by two '\0' */ 2287 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr); 2288 COMCTL32_Free(ptr); 2289 } 2290 else { 2291 // ERR("lpTbb->iString is NULL\n"); 2292 return FALSE; 2293 } 2721 * I assume in that case that: 2722 * - lpTbb->iString is a string pointer (not a string index in strings[] table 2723 * - index of insertion is at the end of existing buttons 2724 * I only see this happen with nIndex == -1, but it could have a special 2725 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion). 2726 */ 2727 int len = lstrlenA((char*)lpTbb->iString) + 2; 2728 LPSTR ptr = (LPSTR)COMCTL32_Alloc(len); 2729 2730 nIndex = infoPtr->nNumButtons; 2731 strcpy(ptr, (char*)lpTbb->iString); 2732 ptr[len - 1] = 0; /* ended by two '\0' */ 2733 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr); 2734 COMCTL32_Free(ptr); 2294 2735 2295 2736 } else if (nIndex < 0) 2296 2737 return FALSE; 2297 2738 2298 // TRACE("inserting button index=%d\n", nIndex); 2739 2740 // TRACE (toolbar, "inserting button index=%d\n", nIndex); 2299 2741 if (nIndex > infoPtr->nNumButtons) { 2300 2301 // TRACE("adjust index=%d\n", nIndex);2742 nIndex = infoPtr->nNumButtons; 2743 // TRACE (toolbar, "adjust index=%d\n", nIndex); 2302 2744 } 2303 2745 … … 2307 2749 /* pre insert copy */ 2308 2750 if (nIndex > 0) { 2309 2310 2751 memcpy (&infoPtr->buttons[0], &oldButtons[0], 2752 nIndex * sizeof(TBUTTON_INFO)); 2311 2753 } 2312 2754 … … 2320 2762 2321 2763 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2764 TTTOOLINFOA ti; 2765 2766 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2767 ti.cbSize = sizeof (TTTOOLINFOA); 2768 ti.hwnd = hwnd; 2769 ti.uId = lpTbb->idCommand; 2770 ti.hinst = 0; 2771 ti.lpszText = LPSTR_TEXTCALLBACKA; 2772 2773 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 2774 0, (LPARAM)&ti); 2333 2775 } 2334 2776 2335 2777 /* post insert copy */ 2336 2778 if (nIndex < infoPtr->nNumButtons - 1) { 2337 2338 2779 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 2780 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 2339 2781 } 2340 2782 … … 2348 2790 } 2349 2791 2350 2351 static LRESULT 2352 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam) 2353 { 2354 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2355 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam; 2356 INT nIndex = (INT)wParam; 2357 TBUTTON_INFO *oldButtons; 2358 2359 if (lpTbb == NULL) 2360 return FALSE; 2361 if (nIndex < 0) 2362 return FALSE; 2363 2364 // TRACE("inserting button index=%d\n", nIndex); 2365 if (nIndex > infoPtr->nNumButtons) { 2366 nIndex = infoPtr->nNumButtons; 2367 // TRACE("adjust index=%d\n", nIndex); 2368 } 2369 2370 oldButtons = infoPtr->buttons; 2371 infoPtr->nNumButtons++; 2372 infoPtr->buttons = (TBUTTON_INFO*)COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 2373 /* pre insert copy */ 2374 if (nIndex > 0) { 2375 memcpy (&infoPtr->buttons[0], &oldButtons[0], 2376 nIndex * sizeof(TBUTTON_INFO)); 2377 } 2378 2379 /* insert new button */ 2380 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap; 2381 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand; 2382 infoPtr->buttons[nIndex].fsState = lpTbb->fsState; 2383 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle; 2384 infoPtr->buttons[nIndex].dwData = lpTbb->dwData; 2385 infoPtr->buttons[nIndex].iString = lpTbb->iString; 2386 2387 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 2388 TTTOOLINFOW ti; 2389 2390 ZeroMemory (&ti, sizeof(TTTOOLINFOW)); 2391 ti.cbSize = sizeof (TTTOOLINFOW); 2392 ti.hwnd = hwnd; 2393 ti.uId = lpTbb->idCommand; 2394 ti.hinst = 0; 2395 ti.lpszText = LPSTR_TEXTCALLBACKW; 2396 2397 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 2398 0, (LPARAM)&ti); 2399 } 2400 2401 /* post insert copy */ 2402 if (nIndex < infoPtr->nNumButtons - 1) { 2403 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 2404 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 2405 } 2406 2407 COMCTL32_Free (oldButtons); 2408 2409 TOOLBAR_CalcToolbar (hwnd); 2410 2411 InvalidateRect (hwnd, NULL, FALSE); 2412 2413 return TRUE; 2414 } 2415 2792 static LRESULT TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam) 2793 { 2794 //CB: just call InsertButtonA, no Unicode used?!? 2795 2796 return TOOLBAR_InsertButtonA(hwnd,wParam,lParam); 2797 } 2416 2798 2417 2799 /* << TOOLBAR_InsertMarkHitTest >> */ … … 2426 2808 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2427 2809 if (nIndex == -1) 2428 2810 return FALSE; 2429 2811 2430 2812 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED); … … 2440 2822 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2441 2823 if (nIndex == -1) 2442 2824 return FALSE; 2443 2825 2444 2826 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED); … … 2454 2836 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2455 2837 if (nIndex == -1) 2456 2838 return FALSE; 2457 2839 2458 2840 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN); … … 2468 2850 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2469 2851 if (nIndex == -1) 2470 2852 return FALSE; 2471 2853 2472 2854 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED); … … 2482 2864 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2483 2865 if (nIndex == -1) 2484 2866 return FALSE; 2485 2867 2486 2868 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE); … … 2496 2878 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2497 2879 if (nIndex == -1) 2498 2880 return FALSE; 2499 2881 2500 2882 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED); … … 2513 2895 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2514 2896 TBUTTON_INFO *btnPtr; 2897 HDC hdc; 2515 2898 INT nIndex; 2516 2899 2517 2900 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2518 2901 if (nIndex == -1) 2519 2902 return FALSE; 2520 2903 2521 2904 btnPtr = &infoPtr->buttons[nIndex]; 2522 2905 if (LOWORD(lParam) == FALSE) 2523 2906 btnPtr->fsState &= ~TBSTATE_PRESSED; 2524 2907 else 2525 btnPtr->fsState |= TBSTATE_PRESSED; 2526 2527 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 2908 btnPtr->fsState |= TBSTATE_PRESSED; 2909 2910 hdc = GetDC (hwnd); 2911 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2912 ReleaseDC (hwnd, hdc); 2528 2913 2529 2914 return TRUE; … … 2544 2929 2545 2930 if ((BOOL)wParam) { 2546 2547 // FIXME("save to \"%s\" \"%s\"\n",2548 2931 /* save toolbar information */ 2932 // FIXME (toolbar, "save to \"%s\" \"%s\"\n", 2933 // lpSave->pszSubKey, lpSave->pszValueName); 2549 2934 2550 2935 2551 2936 } 2552 2937 else { 2553 2554 2555 // FIXME("restore from \"%s\" \"%s\"\n",2556 2938 /* restore toolbar information */ 2939 2940 // FIXME (toolbar, "restore from \"%s\" \"%s\"\n", 2941 // lpSave->pszSubKey, lpSave->pszValueName); 2557 2942 2558 2943 … … 2563 2948 } 2564 2949 2565 2566 static LRESULT 2567 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam) 2950 static LRESULT TOOLBAR_SaveRestoreW(HWND hwnd,WPARAM wParam,LPARAM lParam) 2568 2951 { 2569 2952 #if 0 … … 2571 2954 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam; 2572 2955 2573 if (lpSave == NULL) 2574 return 0; 2956 if (lpSave == NULL) return 0; 2575 2957 2576 2958 if ((BOOL)wParam) { 2577 2578 // FIXME("save to \"%s\" \"%s\"\n",2579 2959 /* save toolbar information */ 2960 // FIXME (toolbar, "save to \"%s\" \"%s\"\n", 2961 // lpSave->pszSubKey, lpSave->pszValueName); 2580 2962 2581 2963 2582 2964 } 2583 2965 else { 2584 2585 2586 // FIXME("restore from \"%s\" \"%s\"\n",2587 2966 /* restore toolbar information */ 2967 2968 // FIXME (toolbar, "restore from \"%s\" \"%s\"\n", 2969 // lpSave->pszSubKey, lpSave->pszValueName); 2588 2970 2589 2971 … … 2594 2976 } 2595 2977 2978 /* << TOOLBAR_SaveRestore32W >> */ 2596 2979 2597 2980 static LRESULT … … 2612 2995 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2613 2996 2614 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 2615 return FALSE; 2616 2617 // if (infoPtr->nNumButtons > 0) 2618 // WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n", 2619 // infoPtr->nNumButtons, 2620 // infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, 2621 // LOWORD(lParam), HIWORD(lParam)); 2997 if (((INT)LOWORD(lParam) <= 0) || ((INT)HIWORD(lParam) <= 0)) return FALSE; 2998 2999 /* Bitmap size can only be set before adding any button to the toolbar 3000 according to the documentation. */ 3001 if( infoPtr->nNumButtons != 0 ) 3002 return FALSE; 2622 3003 2623 3004 infoPtr->nBitmapWidth = (INT)LOWORD(lParam); 2624 3005 infoPtr->nBitmapHeight = (INT)HIWORD(lParam); 2625 2626 /* uses image list internals directly */2627 if (infoPtr->himlDef) {2628 infoPtr->himlDef->cx = infoPtr->nBitmapWidth;2629 infoPtr->himlDef->cy = infoPtr->nBitmapHeight;2630 }2631 3006 2632 3007 return TRUE; … … 2643 3018 2644 3019 if (lptbbi == NULL) 2645 3020 return FALSE; 2646 3021 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA)) 2647 2648 3022 return FALSE; 3023 2649 3024 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2650 3025 if (nIndex == -1) 2651 3026 return FALSE; 2652 3027 2653 3028 btnPtr = &infoPtr->buttons[nIndex]; 2654 3029 if (lptbbi->dwMask & TBIF_COMMAND) 2655 3030 btnPtr->idCommand = lptbbi->idCommand; 2656 3031 if (lptbbi->dwMask & TBIF_IMAGE) 2657 3032 btnPtr->iBitmap = lptbbi->iImage; 2658 3033 if (lptbbi->dwMask & TBIF_LPARAM) 2659 3034 btnPtr->dwData = lptbbi->lParam; 2660 3035 /* if (lptbbi->dwMask & TBIF_SIZE) */ 2661 /* 3036 /* btnPtr->cx = lptbbi->cx; */ 2662 3037 if (lptbbi->dwMask & TBIF_STATE) 2663 3038 btnPtr->fsState = lptbbi->fsState; 2664 3039 if (lptbbi->dwMask & TBIF_STYLE) 2665 3040 btnPtr->fsStyle = lptbbi->fsStyle; 2666 3041 2667 3042 if (lptbbi->dwMask & TBIF_TEXT) { 2668 if ((btnPtr->iString >= 0) || 2669 (btnPtr->iString < infoPtr->nNumStrings)) { 2670 // TRACE("Ooooooch\n"); 3043 if ((btnPtr->iString >= 0) || 3044 (btnPtr->iString < infoPtr->nNumStrings)) { 2671 3045 #if 0 2672 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 2673 2674 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));3046 CHAR **lpString = &infoPtr->strings[btnPtr->iString]; //wrong, it's Unicode!!! 3047 INT len = lstrlenA (lptbbi->pszText); 3048 *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1)); 2675 3049 #endif 2676 3050 2677 2678 /* 2679 3051 /* this is the ultimate sollution */ 3052 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 3053 } 2680 3054 } 2681 3055 … … 2683 3057 } 2684 3058 2685 2686 static LRESULT 2687 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) 3059 static LRESULT TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) 2688 3060 { 2689 3061 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); … … 2693 3065 2694 3066 if (lptbbi == NULL) 2695 3067 return FALSE; 2696 3068 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW)) 2697 3069 return FALSE; 2698 3070 2699 3071 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2700 3072 if (nIndex == -1) 2701 3073 return FALSE; 2702 3074 2703 3075 btnPtr = &infoPtr->buttons[nIndex]; 2704 3076 if (lptbbi->dwMask & TBIF_COMMAND) 2705 3077 btnPtr->idCommand = lptbbi->idCommand; 2706 3078 if (lptbbi->dwMask & TBIF_IMAGE) 2707 3079 btnPtr->iBitmap = lptbbi->iImage; 2708 3080 if (lptbbi->dwMask & TBIF_LPARAM) 2709 3081 btnPtr->dwData = lptbbi->lParam; 2710 3082 /* if (lptbbi->dwMask & TBIF_SIZE) */ 2711 /* 3083 /* btnPtr->cx = lptbbi->cx; */ 2712 3084 if (lptbbi->dwMask & TBIF_STATE) 2713 3085 btnPtr->fsState = lptbbi->fsState; 2714 3086 if (lptbbi->dwMask & TBIF_STYLE) 2715 3087 btnPtr->fsStyle = lptbbi->fsStyle; 2716 3088 2717 3089 if (lptbbi->dwMask & TBIF_TEXT) { 2718 2719 3090 if ((btnPtr->iString >= 0) || 3091 (btnPtr->iString < infoPtr->nNumStrings)) { 2720 3092 #if 0 2721 2722 2723 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));3093 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 3094 INT len = lstrlenW (lptbbi->pszText); 3095 *lpString = COMCTL32_ReAlloc (lpString, sizeof(wchar)*(len+1)); 2724 3096 #endif 2725 3097 2726 2727 /* Str_SetPtrA(&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */2728 3098 /* this is the ultimate sollution */ 3099 /* Str_SetPtrW (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 3100 } 2729 3101 } 2730 3102 … … 2732 3104 } 2733 3105 2734 2735 3106 static LRESULT 2736 3107 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 2738 3109 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2739 3110 2740 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 2741 { 2742 // ERR("invalid parameter\n"); 2743 return FALSE; 2744 } 3111 if (((INT)LOWORD(lParam) <= 0) || ((INT)HIWORD(lParam) <= 0)) return FALSE; 2745 3112 2746 3113 /* Button size can only be set before adding any button to the toolbar 2747 3114 according to the documentation. */ 2748 /* this appears to be wrong. WINZIP32.EXE (ver 8) calls this on2749 one of its buttons after adding it to the toolbar, and it2750 checks that the return value is nonzero - mjm */2751 3115 if( infoPtr->nNumButtons != 0 ) 2752 { 2753 // FIXME("Button size set after button in toolbar\n"); 2754 return TRUE; 2755 } 3116 return FALSE; 2756 3117 2757 3118 infoPtr->nButtonWidth = (INT)LOWORD(lParam); 2758 3119 infoPtr->nButtonHeight = (INT)HIWORD(lParam); 3120 2759 3121 return TRUE; 2760 3122 } … … 2767 3129 2768 3130 if (infoPtr == NULL) 2769 3131 return FALSE; 2770 3132 2771 3133 infoPtr->cxMin = (INT)LOWORD(lParam); … … 2783 3145 2784 3146 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2785 3147 return FALSE; 2786 3148 2787 3149 infoPtr->buttons[nIndex].idCommand = (INT)lParam; … … 2789 3151 if (infoPtr->hwndToolTip) { 2790 3152 2791 // FIXME("change tool tip!\n");3153 // FIXME (toolbar, "change tool tip!\n"); 2792 3154 2793 3155 } … … 2805 3167 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2806 3168 HIMAGELIST himlTemp; 2807 2808 3169 2809 3170 himlTemp = infoPtr->himlDis; … … 2812 3173 /* FIXME: redraw ? */ 2813 3174 2814 return (LRESULT)himlTemp; 3175 return (LRESULT)himlTemp; 2815 3176 } 2816 3177 … … 2824 3185 dwTemp = infoPtr->dwDTFlags; 2825 3186 infoPtr->dwDTFlags = 2826 3187 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam; 2827 3188 2828 3189 return (LRESULT)dwTemp; … … 2839 3200 infoPtr->dwExStyle = (DWORD)lParam; 2840 3201 2841 return (LRESULT)dwTemp; 3202 return (LRESULT)dwTemp; 2842 3203 } 2843 3204 … … 2854 3215 /* FIXME: redraw ? */ 2855 3216 2856 return (LRESULT)himlTemp; 3217 return (LRESULT)himlTemp; 2857 3218 } 2858 3219 … … 2866 3227 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 2867 3228 { 2868 2869 2870 3229 infoPtr->nHotItem = (INT)wParam; 3230 3231 /* FIXME: What else must be done ??? */ 2871 3232 2872 3233 } 2873 3234 2874 3235 if (nOldHotItem < 0) 2875 3236 return -1; 2876 3237 2877 3238 return (LRESULT)nOldHotItem; … … 2888 3249 infoPtr->himlDef = (HIMAGELIST)lParam; 2889 3250 2890 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);2891 3251 /* FIXME: redraw ? */ 2892 3252 2893 return (LRESULT)himlTemp; 3253 return (LRESULT)himlTemp; 2894 3254 } 2895 3255 … … 2932 3292 2933 3293 if (infoPtr == NULL) 2934 3294 return FALSE; 2935 3295 2936 3296 infoPtr->nMaxTextRows = (INT)wParam; … … 2950 3310 2951 3311 if (infoPtr == NULL) 2952 2953 hwndOldNotify = infoPtr->h wndNotify;2954 infoPtr->h wndNotify = (HWND)wParam;3312 return 0; 3313 hwndOldNotify = infoPtr->header.hwndNotify; 3314 infoPtr->header.hwndNotify = (HWND)wParam; 2955 3315 2956 3316 return hwndOldNotify; … … 2966 3326 if (LOWORD(wParam) > 1) { 2967 3327 2968 // FIXME("multiple rows not supported!\n");3328 // FIXME (toolbar, "multiple rows not supported!\n"); 2969 3329 2970 3330 } … … 2975 3335 /* return bounding rectangle */ 2976 3336 if (lprc) { 2977 2978 2979 2980 3337 lprc->left = infoPtr->rcBound.left; 3338 lprc->right = infoPtr->rcBound.right; 3339 lprc->top = infoPtr->rcBound.top; 3340 lprc->bottom = infoPtr->rcBound.bottom; 2981 3341 } 2982 3342 … … 2993 3353 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2994 3354 TBUTTON_INFO *btnPtr; 3355 HDC hdc; 2995 3356 INT nIndex; 2996 3357 2997 3358 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2998 3359 if (nIndex == -1) 2999 3360 return FALSE; 3000 3361 3001 3362 btnPtr = &infoPtr->buttons[nIndex]; 3002 3363 btnPtr->fsState = LOWORD(lParam); 3003 3364 3004 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 3365 hdc = GetDC (hwnd); 3366 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 3367 ReleaseDC (hwnd, hdc); 3005 3368 3006 3369 return TRUE; … … 3013 3376 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3014 3377 TBUTTON_INFO *btnPtr; 3378 HDC hdc; 3015 3379 INT nIndex; 3016 3380 3017 3381 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3018 3382 if (nIndex == -1) 3019 3383 return FALSE; 3020 3384 3021 3385 btnPtr = &infoPtr->buttons[nIndex]; 3022 3386 btnPtr->fsStyle = LOWORD(lParam); 3023 3387 3024 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 3388 hdc = GetDC (hwnd); 3389 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 3390 ReleaseDC (hwnd, hdc); 3025 3391 3026 3392 if (infoPtr->hwndToolTip) { 3027 // FIXME("change tool tip!\n"); 3393 3394 // FIXME (toolbar, "change tool tip!\n"); 3395 3028 3396 } 3029 3397 … … 3032 3400 3033 3401 3034 inlinestatic LRESULT3402 static LRESULT 3035 3403 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam) 3036 3404 { … … 3038 3406 3039 3407 if (infoPtr == NULL) 3040 3408 return 0; 3041 3409 infoPtr->hwndToolTip = (HWND)wParam; 3042 3410 return 0; 3043 3411 } 3044 3045 3046 static LRESULT3047 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)3048 {3049 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);3050 BOOL bTemp;3051 3052 // TRACE("%s hwnd=0x%04x stub!\n",3053 // ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);3054 3055 bTemp = infoPtr->bUnicode;3056 infoPtr->bUnicode = (BOOL)wParam;3057 3058 return bTemp;3059 }3060 3061 3062 static LRESULT3063 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)3064 {3065 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);3066 INT iOldVersion = infoPtr->iVersion;3067 3068 infoPtr->iVersion = iVersion;3069 3070 return iOldVersion;3071 }3072 3073 3412 3074 3413 static LRESULT … … 3090 3429 infoPtr->cxMin = -1; 3091 3430 infoPtr->cxMax = -1; 3092 infoPtr->nNumBitmaps = 0;3093 infoPtr->nNumStrings = 0;3094 3431 3095 3432 infoPtr->bCaptured = FALSE; 3096 infoPtr->bUnicode = IsWindowUnicode (hwnd);3097 3433 infoPtr->nButtonDown = -1; 3098 3434 infoPtr->nOldHit = -1; 3099 3435 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */ 3100 infoPtr->hwndNotify = GetParent (hwnd);3101 3436 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT); 3102 3437 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER; 3103 3438 infoPtr->bAnchor = FALSE; /* no anchor highlighting */ 3104 infoPtr->iVersion = 0; 3439 3440 infoPtr->hwndToolbar = hwnd; 3441 infoPtr->oldButtons = NULL; 3442 infoPtr->nNumOldButtons = 0; 3105 3443 3106 3444 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); 3107 3445 infoPtr->hFont = CreateFontIndirectA (&logFont); 3108 3446 3109 if (dwStyle & TBSTYLE_TOOLTIPS) { 3110 /* Create tooltip control */ 3111 infoPtr->hwndToolTip = 3112 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 3113 CW_USEDEFAULT, CW_USEDEFAULT, 3114 CW_USEDEFAULT, CW_USEDEFAULT, 3115 hwnd, 0, 0, 0); 3116 3117 /* Send NM_TOOLTIPSCREATED notification */ 3118 if (infoPtr->hwndToolTip) { 3119 NMTOOLTIPSCREATED nmttc; 3120 3121 nmttc.hdr.hwndFrom = hwnd; 3122 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3123 nmttc.hdr.code = NM_TOOLTIPSCREATED; 3124 nmttc.hwndToolTips = infoPtr->hwndToolTip; 3125 3126 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 3127 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc); 3128 } 3129 } 3447 /* Create tooltip control */ 3448 if (dwStyle & TBSTYLE_TOOLTIPS) 3449 infoPtr->hwndToolTip = createToolTip(hwnd,0,FALSE); 3130 3450 3131 3451 return 0; … … 3137 3457 { 3138 3458 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3139 3140 /* delete tooltip control */3141 if (infoPtr->hwndToolTip)3142 DestroyWindow (infoPtr->hwndToolTip);3143 3459 3144 3460 /* delete button data */ 3145 3461 if (infoPtr->buttons) 3146 COMCTL32_Free (infoPtr->buttons); 3462 { 3463 INT x; 3464 3465 //SvL: Check pointers 3466 for (x = 0;x < infoPtr->nNumButtons;x++) 3467 if(infoPtr->buttons[x].pszName) 3468 COMCTL32_Free(infoPtr->buttons[x].pszName); 3469 3470 COMCTL32_Free(infoPtr->buttons); 3471 } 3147 3472 3148 3473 /* delete strings */ 3149 3474 if (infoPtr->strings) { 3150 3151 3152 3153 3154 3155 3475 INT i; 3476 for (i = 0; i < infoPtr->nNumStrings; i++) 3477 if (infoPtr->strings[i]) 3478 COMCTL32_Free (infoPtr->strings[i]); 3479 3480 COMCTL32_Free (infoPtr->strings); 3156 3481 } 3157 3482 3158 3483 /* destroy internal image list */ 3159 3484 if (infoPtr->himlInt) 3160 3485 ImageList_Destroy (infoPtr->himlInt); 3161 3486 3162 3487 /* delete default font */ 3163 3488 if (infoPtr->hFont) 3164 3489 DeleteObject (infoPtr->hFont); 3165 3490 3166 3491 /* free toolbar info data */ 3167 COMCTL32_Free (infoPtr); 3168 SetWindowLongA (hwnd, 0, 0); 3492 doneControl(hwnd); 3169 3493 3170 3494 return 0; … … 3177 3501 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3178 3502 3179 if (infoPtr->bTransparent) 3180 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam); 3503 //SvL: Check ptr 3504 if (infoPtr && infoPtr->bTransparent) 3505 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam); 3181 3506 3182 3507 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam); 3183 3508 } 3184 3509 3185 3186 3510 static LRESULT 3187 3511 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 3191 3515 return infoPtr->hFont; 3192 3516 } 3193 3194 3517 3195 3518 static LRESULT … … 3200 3523 POINT pt; 3201 3524 INT nHit; 3525 HDC hdc; 3202 3526 3203 3527 pt.x = (INT)LOWORD(lParam); … … 3206 3530 3207 3531 if (nHit >= 0) { 3208 btnPtr = &infoPtr->buttons[nHit]; 3209 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 3210 return 0; 3211 SetCapture (hwnd); 3212 infoPtr->bCaptured = TRUE; 3213 infoPtr->nButtonDown = nHit; 3214 3215 btnPtr->fsState |= TBSTATE_PRESSED; 3216 3217 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 3532 btnPtr = &infoPtr->buttons[nHit]; 3533 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 3534 return 0; 3535 SetCapture (hwnd); 3536 infoPtr->bCaptured = TRUE; 3537 infoPtr->nButtonDown = nHit; 3538 3539 btnPtr->fsState |= TBSTATE_PRESSED; 3540 3541 hdc = GetDC (hwnd); 3542 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 3543 ReleaseDC (hwnd, hdc); 3218 3544 } 3219 3545 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE) 3220 3546 TOOLBAR_Customize (hwnd); 3221 3547 3222 3548 return 0; … … 3231 3557 POINT pt; 3232 3558 INT nHit; 3559 HDC hdc; 3233 3560 3234 3561 if (infoPtr->hwndToolTip) 3235 3236 3562 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 3563 WM_LBUTTONDOWN, wParam, lParam); 3237 3564 3238 3565 pt.x = (INT)LOWORD(lParam); … … 3241 3568 3242 3569 if (nHit >= 0) { 3243 btnPtr = &infoPtr->buttons[nHit]; 3244 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 3245 return 0; 3246 3247 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) 3248 { 3249 NMTOOLBARA nmtb; 3250 3251 nmtb.hdr.hwndFrom = hwnd; 3252 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3253 nmtb.hdr.code = TBN_DROPDOWN; 3254 nmtb.iItem = btnPtr->idCommand; 3255 3256 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 3257 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 3258 } 3259 3260 SetCapture (hwnd); 3261 infoPtr->bCaptured = TRUE; 3262 infoPtr->nButtonDown = nHit; 3263 infoPtr->nOldHit = nHit; 3264 3265 btnPtr->fsState |= TBSTATE_PRESSED; 3266 btnPtr->bHot = FALSE; 3267 3268 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 3570 btnPtr = &infoPtr->buttons[nHit]; 3571 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 3572 return 0; 3573 3574 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) 3575 { 3576 NMTOOLBARA nmtb; 3577 3578 nmtb.iItem = btnPtr->idCommand; 3579 3580 sendNotify(hwnd,TBN_DROPDOWN,&nmtb.hdr); 3581 } 3582 3583 SetCapture (hwnd); 3584 infoPtr->bCaptured = TRUE; 3585 infoPtr->nButtonDown = nHit; 3586 infoPtr->nOldHit = nHit; 3587 3588 btnPtr->fsState |= TBSTATE_PRESSED; 3589 3590 hdc = GetDC (hwnd); 3591 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 3592 ReleaseDC (hwnd, hdc); 3269 3593 } 3270 3594 3271 3595 return 0; 3272 3596 } 3597 3273 3598 3274 3599 static LRESULT … … 3280 3605 INT nHit; 3281 3606 INT nOldIndex = -1; 3607 HDC hdc; 3282 3608 BOOL bSendMessage = TRUE; 3283 3609 3284 3610 if (infoPtr->hwndToolTip) 3285 3286 3611 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 3612 WM_LBUTTONUP, wParam, lParam); 3287 3613 3288 3614 pt.x = (INT)LOWORD(lParam); … … 3290 3616 nHit = TOOLBAR_InternalHitTest (hwnd, &pt); 3291 3617 3292 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */3293 if(infoPtr->nHotItem >= 0)3294 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;3295 3296 3618 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) { 3297 infoPtr->bCaptured = FALSE; 3298 ReleaseCapture (); 3299 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 3300 btnPtr->fsState &= ~TBSTATE_PRESSED; 3301 3302 if (nHit == infoPtr->nButtonDown) { 3303 if (btnPtr->fsStyle & TBSTYLE_CHECK) { 3304 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 3305 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, 3306 infoPtr->nButtonDown); 3307 if (nOldIndex == infoPtr->nButtonDown) 3308 bSendMessage = FALSE; 3309 if ((nOldIndex != infoPtr->nButtonDown) && 3310 (nOldIndex != -1)) 3311 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 3312 btnPtr->fsState |= TBSTATE_CHECKED; 3313 } 3314 else { 3315 if (btnPtr->fsState & TBSTATE_CHECKED) 3316 btnPtr->fsState &= ~TBSTATE_CHECKED; 3317 else 3318 btnPtr->fsState |= TBSTATE_CHECKED; 3319 } 3320 } 3321 } 3322 else 3323 bSendMessage = FALSE; 3324 3325 if (nOldIndex != -1) 3326 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, TRUE); 3327 3328 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 3329 3330 if (bSendMessage) { 3331 SendMessageA (GetParent(hwnd), WM_COMMAND, 3332 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 3333 3334 // if ((GetWindowLongA(hwnd, GWL_STYLE) & TBSTYLE_DROPDOWN) || 3335 // (btnPtr->fsStyle & 0x08/* BTNS_DROPDOWN */)) { 3336 /* 3337 * This appears to be an error. Instead of checking the style of the 3338 * button in question wine was checking the style of the toolbar 3339 * itself. This caused a number of strange behaviors. In my 3340 * invistigation i think the whole dropdown thing is still fairly 3341 * broken. but this helps fix some of the problems. 3342 */ 3343 3344 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) { 3345 NMTOOLBARW nmtb; 3346 3347 nmtb.hdr.hwndFrom = hwnd; 3348 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3349 nmtb.hdr.code = TBN_DROPDOWN; 3350 nmtb.iItem = nHit; 3351 /* nmtb.tbButton not used with TBN_DROPDOWN */ 3352 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) { 3353 nmtb.pszText = infoPtr->strings[btnPtr->iString]; 3354 nmtb.cchText = lstrlenW(nmtb.pszText); 3355 } else { 3356 nmtb.pszText = NULL; 3357 nmtb.cchText = 0; 3358 } 3359 nmtb.rcButton = btnPtr->rect; 3360 3361 SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, 3362 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 3363 } 3364 } 3365 infoPtr->nButtonDown = -1; 3366 infoPtr->nOldHit = -1; 3619 infoPtr->bCaptured = FALSE; 3620 ReleaseCapture (); 3621 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 3622 btnPtr->fsState &= ~TBSTATE_PRESSED; 3623 3624 if (nHit == infoPtr->nButtonDown) { 3625 if (btnPtr->fsStyle & TBSTYLE_CHECK) { 3626 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 3627 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, 3628 infoPtr->nButtonDown); 3629 if (nOldIndex == infoPtr->nButtonDown) 3630 bSendMessage = FALSE; 3631 if ((nOldIndex != infoPtr->nButtonDown) && 3632 (nOldIndex != -1)) 3633 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 3634 btnPtr->fsState |= TBSTATE_CHECKED; 3635 } 3636 else { 3637 if (btnPtr->fsState & TBSTATE_CHECKED) 3638 btnPtr->fsState &= ~TBSTATE_CHECKED; 3639 else 3640 btnPtr->fsState |= TBSTATE_CHECKED; 3641 } 3642 } 3643 } 3644 else 3645 bSendMessage = FALSE; 3646 3647 hdc = GetDC (hwnd); 3648 if (nOldIndex != -1) 3649 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc); 3650 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 3651 ReleaseDC (hwnd, hdc); 3652 3653 if (bSendMessage) { 3654 SendMessageA (GetParent(hwnd), WM_COMMAND, 3655 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 3656 3657 if ((GetWindowLongA(hwnd, GWL_STYLE) & TBSTYLE_DROPDOWN) || 3658 (btnPtr->fsStyle & 0x08/* BTNS_DROPDOWN */)) { 3659 NMTOOLBARW nmtb; 3660 3661 nmtb.iItem = nHit; 3662 /* nmtb.tbButton not used with TBN_DROPDOWN */ 3663 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) { 3664 nmtb.pszText = infoPtr->strings[btnPtr->iString]; 3665 nmtb.cchText = lstrlenW(nmtb.pszText); 3666 } else { 3667 nmtb.pszText = NULL; 3668 nmtb.cchText = 0; 3669 } 3670 nmtb.rcButton = btnPtr->rect; 3671 3672 sendNotify(hwnd,TBN_DROPDOWN,&nmtb.hdr); 3673 } 3674 } 3675 3676 infoPtr->nButtonDown = -1; 3677 infoPtr->nOldHit = -1; 3367 3678 } 3368 3679 … … 3370 3681 } 3371 3682 3372 static LRESULT3373 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)3374 {3375 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);3376 TBUTTON_INFO *hotBtnPtr;3377 3378 if (infoPtr->nOldHit < 0)3379 return TRUE;3380 3381 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];3382 3383 /* Redraw the button if the last button we were over is the hot button and it3384 is enabled */3385 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))3386 {3387 hotBtnPtr->bHot = FALSE;3388 3389 InvalidateRect (hwnd, &hotBtnPtr->rect, TRUE);3390 }3391 3392 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */3393 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */3394 3395 return TRUE;3396 }3397 3683 3398 3684 static LRESULT … … 3403 3689 POINT pt; 3404 3690 INT nHit; 3405 TRACKMOUSEEVENT trackinfo; 3406 3407 /* fill in the TRACKMOUSEEVENT struct */ 3408 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT); 3409 trackinfo.dwFlags = TME_QUERY; 3410 trackinfo.hwndTrack = hwnd; 3411 trackinfo.dwHoverTime = HOVER_DEFAULT; 3412 3413 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */ 3414 _TrackMouseEvent(&trackinfo); 3415 3416 /* Make sure tracking is enabled so we recieve a WM_MOUSELEAVE message */ 3417 if(!(trackinfo.dwFlags & TME_LEAVE)) { 3418 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 3419 3420 /* call TRACKMOUSEEVENT so we recieve a WM_MOUSELEAVE message */ 3421 /* and can properly deactivate the hot toolbar button */ 3422 _TrackMouseEvent(&trackinfo); 3423 } 3691 HDC hdc; 3692 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 3424 3693 3425 3694 if (infoPtr->hwndToolTip) 3426 TOOLBAR_RelayEvent (infoPtr->hwndToolTip,hwnd,3427 WM_MOUSEMOVE, wParam,lParam);3695 TOOLBAR_RelayEvent (infoPtr->hwndToolTip,hwnd, 3696 WM_MOUSEMOVE,wParam,lParam); 3428 3697 3429 3698 pt.x = (INT)LOWORD(lParam); 3430 3699 pt.y = (INT)HIWORD(lParam); 3431 3700 3432 nHit = TOOLBAR_InternalHitTest (hwnd,&pt);3701 nHit = TOOLBAR_InternalHitTest(hwnd,&pt); 3433 3702 3434 3703 if (infoPtr->nOldHit != nHit) 3435 3704 { 3436 /* Remove the effect of an old hot button if the button was enabled and was 3437 drawn with the hot button effect */ 3438 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem && 3439 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED)) 3440 { 3441 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 3442 oldBtnPtr->bHot = FALSE; 3443 3444 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE); 3445 } 3446 3447 /* It's not a separator or in nowhere. It's a hot button. */ 3448 if (nHit >= 0) 3449 { 3450 btnPtr = &infoPtr->buttons[nHit]; 3451 btnPtr->bHot = TRUE; 3452 3453 infoPtr->nHotItem = nHit; 3454 3455 /* only enabled buttons show hot effect */ 3456 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED) 3457 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 3458 } 3459 3460 if (infoPtr->bCaptured) { 3461 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 3462 if (infoPtr->nOldHit == infoPtr->nButtonDown) { 3463 btnPtr->fsState &= ~TBSTATE_PRESSED; 3464 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 3465 } 3466 else if (nHit == infoPtr->nButtonDown) { 3467 btnPtr->fsState |= TBSTATE_PRESSED; 3468 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 3469 } 3470 } 3471 infoPtr->nOldHit = nHit; 3705 /* Remove the effect of an old hot button */ 3706 if(infoPtr->nOldHit == infoPtr->nHotItem) 3707 { 3708 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 3709 if (oldBtnPtr->bHot) //CB: dynamic buttons 3710 { 3711 oldBtnPtr->bHot = FALSE; 3712 3713 if (dwStyle & TBSTYLE_FLAT) InvalidateRect(hwnd,&oldBtnPtr->rect,TRUE); 3714 } 3715 } 3716 3717 /* It's not a separator or in nowhere. It's a hot button. */ 3718 if (nHit >= 0) 3719 { 3720 btnPtr = &infoPtr->buttons[nHit]; 3721 if (!btnPtr->bHot) 3722 { 3723 btnPtr->bHot = TRUE; 3724 3725 if (dwStyle & TBSTYLE_FLAT) 3726 { 3727 hdc = GetDC (hwnd); 3728 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 3729 ReleaseDC (hwnd, hdc); 3730 } 3731 3732 infoPtr->nHotItem = nHit; 3733 } 3734 } 3735 3736 if (infoPtr->bCaptured) 3737 { 3738 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 3739 if (infoPtr->nOldHit == infoPtr->nButtonDown) 3740 { 3741 btnPtr->fsState &= ~TBSTATE_PRESSED; 3742 3743 hdc = GetDC (hwnd); 3744 TOOLBAR_DrawButton(hwnd,btnPtr,hdc); 3745 ReleaseDC(hwnd,hdc); 3746 } else if (nHit == infoPtr->nButtonDown) 3747 { 3748 btnPtr->fsState |= TBSTATE_PRESSED; 3749 3750 hdc = GetDC(hwnd); 3751 TOOLBAR_DrawButton(hwnd,btnPtr,hdc); 3752 ReleaseDC(hwnd,hdc); 3753 } 3754 } 3755 infoPtr->nOldHit = nHit; 3472 3756 } 3473 3757 return 0; … … 3475 3759 3476 3760 3477 inlinestatic LRESULT3761 static LRESULT 3478 3762 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam) 3479 3763 { 3480 3764 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */ 3481 3765 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam); 3482 3766 /* else */ 3483 /* 3484 } 3485 3486 3487 inlinestatic LRESULT3767 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */ 3768 } 3769 3770 3771 static LRESULT 3488 3772 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam) 3489 3773 { 3490 3774 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER)) 3491 3775 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE); 3492 3776 3493 3777 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam); … … 3501 3785 3502 3786 /* allocate memory for info structure */ 3503 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO)); 3504 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); 3787 infoPtr = (TOOLBAR_INFO*)initControl(hwnd,sizeof(TOOLBAR_INFO)); 3505 3788 3506 3789 /* paranoid!! */ … … 3510 3793 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) { 3511 3794 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE); 3512 3795 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst); 3513 3796 } 3514 3797 … … 3525 3808 3526 3809 if (dwStyle & WS_MINIMIZE) 3527 3810 return 0; /* Nothing to do */ 3528 3811 3529 3812 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam); 3530 3813 3531 3814 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW))) 3532 3815 return 0; 3533 3816 3534 3817 if (!(dwStyle & CCS_NODIVIDER)) 3535 3818 { 3536 3537 3538 3539 3540 3819 GetWindowRect (hwnd, &rcWindow); 3820 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top); 3821 if( dwStyle & WS_BORDER ) 3822 OffsetRect (&rcWindow, 1, 1); 3823 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP); 3541 3824 } 3542 3825 … … 3547 3830 3548 3831 3549 inlinestatic LRESULT3832 static LRESULT 3550 3833 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam) 3551 3834 { … … 3553 3836 LPNMHDR lpnmh = (LPNMHDR)lParam; 3554 3837 3555 // TRACE("passing WM_NOTIFY!\n");3838 // TRACE (toolbar, "passing WM_NOTIFY!\n"); 3556 3839 3557 3840 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) { 3558 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,wParam, lParam);3841 SendMessageA (infoPtr->header.hwndNotify, WM_NOTIFY, wParam, lParam); 3559 3842 3560 3843 #if 0 3561 3562 3563 3564 // FIXME("retrieving ASCII string\n");3565 3566 3567 3568 3569 3570 // FIXME("retrieving UNICODE string\n");3571 3572 3844 if (lpnmh->code == TTN_GETDISPINFOA) { 3845 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam; 3846 3847 // FIXME (toolbar, "retrieving ASCII string\n"); 3848 3849 } 3850 else if (lpnmh->code == TTN_GETDISPINFOW) { 3851 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam; 3852 3853 // FIXME (toolbar, "retrieving UNICODE string\n"); 3854 3855 } 3573 3856 #endif 3574 3857 } … … 3581 3864 TOOLBAR_Paint (HWND hwnd, WPARAM wParam) 3582 3865 { 3583 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);3584 3866 HDC hdc; 3585 3867 PAINTSTRUCT ps; 3586 3868 3587 /* fill ps.rcPaint with a default rect */ 3588 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 3589 3590 TOOLBAR_CalcToolbar( hwnd ); 3591 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam; 3592 TOOLBAR_Refresh (hwnd, hdc, &ps); 3869 TOOLBAR_CalcToolbar(hwnd); 3870 hdc = wParam == 0 ? BeginPaint(hwnd,&ps) : (HDC)wParam; 3871 TOOLBAR_Refresh(hwnd,hdc); 3593 3872 if (!wParam) EndPaint (hwnd, &ps); 3594 3595 3873 return 0; 3596 3874 } … … 3603 3881 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 3604 3882 RECT parent_rect; 3605 RECT window_rect;3606 3883 HWND parent; 3607 INT x, y; 3608 INT cx, cy; 3884 INT x = 0,y = 0,cx,cy; 3609 3885 INT flags; 3610 3886 UINT uPosFlags = 0; … … 3612 3888 /* Resize deadlock check */ 3613 3889 if (infoPtr->bAutoSize) { 3614 3615 3890 infoPtr->bAutoSize = FALSE; 3891 return 0; 3616 3892 } 3617 3893 … … 3622 3898 */ 3623 3899 3624 // TRACE("sizing toolbar!\n");3900 //TRACE (toolbar, "sizing toolbar!\n"); 3625 3901 3626 3902 if (flags == SIZE_RESTORED) { 3627 /* width and height don't apply */ 3628 parent = GetParent (hwnd); 3629 GetClientRect(parent, &parent_rect); 3630 x = parent_rect.left; 3631 y = parent_rect.top; 3632 3633 if (dwStyle & CCS_NORESIZE) { 3634 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 3635 3636 /* 3637 * this sets the working width of the toolbar, and 3638 * Calc Toolbar will not adjust it, only the height 3639 */ 3640 infoPtr->nWidth = parent_rect.right - parent_rect.left; 3641 cy = infoPtr->nHeight; 3642 cx = infoPtr->nWidth; 3643 TOOLBAR_CalcToolbar (hwnd); 3644 infoPtr->nWidth = cx; 3645 infoPtr->nHeight = cy; 3646 } 3647 else { 3648 infoPtr->nWidth = parent_rect.right - parent_rect.left; 3649 TOOLBAR_CalcToolbar (hwnd); 3650 cy = infoPtr->nHeight; 3651 cx = infoPtr->nWidth; 3652 3653 if (dwStyle & CCS_NOMOVEY) { 3654 GetWindowRect(hwnd, &window_rect); 3655 ScreenToClient(parent, (LPPOINT)&window_rect.left); 3656 y = window_rect.top; 3657 } 3658 } 3659 3660 if (dwStyle & CCS_NOPARENTALIGN) { 3661 uPosFlags |= SWP_NOMOVE; 3662 cy = infoPtr->nHeight; 3663 cx = infoPtr->nWidth; 3664 } 3665 3666 if (!(dwStyle & CCS_NODIVIDER)) 3667 cy += GetSystemMetrics(SM_CYEDGE); 3668 3669 if (dwStyle & WS_BORDER) 3670 { 3671 x = y = 1; 3672 cy += GetSystemMetrics(SM_CYEDGE); 3673 cx += GetSystemMetrics(SM_CYEDGE); 3674 } 3675 3676 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y, 3677 cx, cy, uPosFlags | SWP_NOZORDER); 3903 /* width and height don't apply */ 3904 parent = GetParent (hwnd); 3905 GetClientRect(parent, &parent_rect); 3906 x = parent_rect.left; 3907 y = parent_rect.top; 3908 3909 if (dwStyle & CCS_NORESIZE) { 3910 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 3911 /* FIXME */ 3912 /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */ 3913 cy = infoPtr->nHeight; 3914 cx = infoPtr->nWidth; 3915 TOOLBAR_CalcToolbar (hwnd); 3916 infoPtr->nWidth = cx; 3917 infoPtr->nHeight = cy; 3918 } 3919 else { 3920 infoPtr->nWidth = parent_rect.right - parent_rect.left; 3921 TOOLBAR_CalcToolbar (hwnd); 3922 cy = infoPtr->nHeight; 3923 cx = infoPtr->nWidth; 3924 } 3925 3926 if (dwStyle & CCS_NOPARENTALIGN) { 3927 uPosFlags |= SWP_NOMOVE; 3928 cy = infoPtr->nHeight; 3929 cx = infoPtr->nWidth; 3930 } 3931 3932 if (!(dwStyle & CCS_NODIVIDER)) 3933 cy += GetSystemMetrics(SM_CYEDGE); 3934 3935 if (dwStyle & WS_BORDER) 3936 { 3937 x = y = 1; 3938 cy += GetSystemMetrics(SM_CYEDGE); 3939 cx += GetSystemMetrics(SM_CYEDGE); 3940 } 3941 3942 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y, 3943 cx, cy, uPosFlags | SWP_NOZORDER); 3678 3944 } 3679 3945 return 0; … … 3687 3953 3688 3954 if (nType == GWL_STYLE) { 3689 3690 3691 3692 3693 3694 3955 if (lpStyle->styleNew & TBSTYLE_LIST) { 3956 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE; 3957 } 3958 else { 3959 infoPtr->dwDTFlags = DT_CENTER; 3960 } 3695 3961 } 3696 3962 … … 3707 3973 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 3708 3974 { 3709 3710 switch (uMsg) 3975 switch (uMsg) 3711 3976 { 3712 3977 case WM_DESTROY: … … 3724 3989 switch (uMsg) 3725 3990 { 3726 case TB_ADDBITMAP: 3727 return TOOLBAR_AddBitmap (hwnd, wParam, lParam); 3728 3729 case TB_ADDBUTTONSA: 3730 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam); 3731 3732 case TB_ADDBUTTONSW: 3733 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam); 3734 3735 case TB_ADDSTRINGA: 3736 return TOOLBAR_AddStringA (hwnd, wParam, lParam); 3737 3738 case TB_ADDSTRINGW: 3739 return TOOLBAR_AddStringW (hwnd, wParam, lParam); 3740 3741 case TB_AUTOSIZE: 3742 return TOOLBAR_AutoSize (hwnd); 3743 3744 case TB_BUTTONCOUNT: 3745 return TOOLBAR_ButtonCount (hwnd, wParam, lParam); 3746 3747 case TB_BUTTONSTRUCTSIZE: 3748 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam); 3749 3750 case TB_CHANGEBITMAP: 3751 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam); 3752 3753 case TB_CHECKBUTTON: 3754 return TOOLBAR_CheckButton (hwnd, wParam, lParam); 3755 3756 case TB_COMMANDTOINDEX: 3757 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam); 3758 3759 case TB_CUSTOMIZE: 3760 return TOOLBAR_Customize (hwnd); 3761 3762 case TB_DELETEBUTTON: 3763 return TOOLBAR_DeleteButton (hwnd, wParam, lParam); 3764 3765 case TB_ENABLEBUTTON: 3766 return TOOLBAR_EnableButton (hwnd, wParam, lParam); 3767 3768 case TB_GETANCHORHIGHLIGHT: 3769 return TOOLBAR_GetAnchorHighlight (hwnd); 3770 3771 case TB_GETBITMAP: 3772 return TOOLBAR_GetBitmap (hwnd, wParam, lParam); 3773 3774 case TB_GETBITMAPFLAGS: 3775 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam); 3776 3777 case TB_GETBUTTON: 3778 return TOOLBAR_GetButton (hwnd, wParam, lParam); 3779 3780 case TB_GETBUTTONINFOA: 3781 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam); 3782 3783 case TB_GETBUTTONINFOW: 3784 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam); 3785 3786 case TB_GETBUTTONSIZE: 3787 return TOOLBAR_GetButtonSize (hwnd); 3788 3789 case TB_GETBUTTONTEXTA: 3790 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam); 3791 3792 case TB_GETBUTTONTEXTW: 3793 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam); 3794 3795 /* case TB_GETCOLORSCHEME: */ /* 4.71 */ 3796 3797 case TB_GETDISABLEDIMAGELIST: 3798 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam); 3799 3800 case TB_GETEXTENDEDSTYLE: 3801 return TOOLBAR_GetExtendedStyle (hwnd); 3802 3803 case TB_GETHOTIMAGELIST: 3804 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam); 3805 3806 case TB_GETHOTITEM: 3807 return TOOLBAR_GetHotItem (hwnd); 3808 3809 case TB_GETIMAGELIST: 3810 return TOOLBAR_GetImageList (hwnd, wParam, lParam); 3811 3812 /* case TB_GETINSERTMARK: */ /* 4.71 */ 3813 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */ 3814 3815 case TB_GETITEMRECT: 3816 return TOOLBAR_GetItemRect (hwnd, wParam, lParam); 3817 3818 case TB_GETMAXSIZE: 3819 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam); 3820 3821 /* case TB_GETOBJECT: */ /* 4.71 */ 3822 /* case TB_GETPADDING: */ /* 4.71 */ 3823 3824 case TB_GETRECT: 3825 return TOOLBAR_GetRect (hwnd, wParam, lParam); 3826 3827 case TB_GETROWS: 3828 return TOOLBAR_GetRows (hwnd, wParam, lParam); 3829 3830 case TB_GETSTATE: 3831 return TOOLBAR_GetState (hwnd, wParam, lParam); 3832 3833 case TB_GETSTYLE: 3834 return TOOLBAR_GetStyle (hwnd, wParam, lParam); 3835 3836 case TB_GETTEXTROWS: 3837 return TOOLBAR_GetTextRows (hwnd, wParam, lParam); 3838 3839 case TB_GETTOOLTIPS: 3840 return TOOLBAR_GetToolTips (hwnd, wParam, lParam); 3841 3842 case TB_GETUNICODEFORMAT: 3843 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam); 3844 3845 case CCM_GETVERSION: 3846 return TOOLBAR_GetVersion (hwnd); 3847 3848 case TB_HIDEBUTTON: 3849 return TOOLBAR_HideButton (hwnd, wParam, lParam); 3850 3851 case TB_HITTEST: 3852 return TOOLBAR_HitTest (hwnd, wParam, lParam); 3853 3854 case TB_INDETERMINATE: 3855 return TOOLBAR_Indeterminate (hwnd, wParam, lParam); 3856 3857 case TB_INSERTBUTTONA: 3858 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam); 3859 3860 case TB_INSERTBUTTONW: 3861 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam); 3862 3863 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */ 3864 3865 case TB_ISBUTTONCHECKED: 3866 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam); 3867 3868 case TB_ISBUTTONENABLED: 3869 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam); 3870 3871 case TB_ISBUTTONHIDDEN: 3872 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam); 3873 3874 case TB_ISBUTTONHIGHLIGHTED: 3875 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam); 3876 3877 case TB_ISBUTTONINDETERMINATE: 3878 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam); 3879 3880 case TB_ISBUTTONPRESSED: 3881 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam); 3882 3883 case TB_LOADIMAGES: /* 4.70 */ 3884 // FIXME("missing standard imagelists\n"); 3885 return 0; 3886 3887 /* case TB_MAPACCELERATORA: */ /* 4.71 */ 3888 /* case TB_MAPACCELERATORW: */ /* 4.71 */ 3889 /* case TB_MARKBUTTON: */ /* 4.71 */ 3890 /* case TB_MOVEBUTTON: */ /* 4.71 */ 3891 3892 case TB_PRESSBUTTON: 3893 return TOOLBAR_PressButton (hwnd, wParam, lParam); 3894 3895 /* case TB_REPLACEBITMAP: */ 3896 3897 case TB_SAVERESTOREA: 3898 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam); 3899 3900 case TB_SAVERESTOREW: 3901 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam); 3902 3903 case TB_SETANCHORHIGHLIGHT: 3904 return TOOLBAR_SetAnchorHighlight (hwnd, wParam); 3905 3906 case TB_SETBITMAPSIZE: 3907 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam); 3908 3909 case TB_SETBUTTONINFOA: 3910 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam); 3911 3912 case TB_SETBUTTONINFOW: 3913 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam); 3914 3915 case TB_SETBUTTONSIZE: 3916 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam); 3917 3918 case TB_SETBUTTONWIDTH: 3919 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam); 3920 3921 case TB_SETCMDID: 3922 return TOOLBAR_SetCmdId (hwnd, wParam, lParam); 3923 3924 /* case TB_SETCOLORSCHEME: */ /* 4.71 */ 3925 3926 case TB_SETDISABLEDIMAGELIST: 3927 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam); 3928 3929 case TB_SETDRAWTEXTFLAGS: 3930 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam); 3931 3932 case TB_SETEXTENDEDSTYLE: 3933 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam); 3934 3935 case TB_SETHOTIMAGELIST: 3936 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam); 3937 3938 case TB_SETHOTITEM: 3939 return TOOLBAR_SetHotItem (hwnd, wParam); 3940 3941 case TB_SETIMAGELIST: 3942 return TOOLBAR_SetImageList (hwnd, wParam, lParam); 3943 3944 case TB_SETINDENT: 3945 return TOOLBAR_SetIndent (hwnd, wParam, lParam); 3946 3947 /* case TB_SETINSERTMARK: */ /* 4.71 */ 3948 3949 case TB_SETINSERTMARKCOLOR: 3950 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam); 3951 3952 case TB_SETMAXTEXTROWS: 3953 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam); 3954 3955 /* case TB_SETPADDING: */ /* 4.71 */ 3956 3957 case TB_SETPARENT: 3958 return TOOLBAR_SetParent (hwnd, wParam, lParam); 3959 3960 case TB_SETROWS: 3961 return TOOLBAR_SetRows (hwnd, wParam, lParam); 3962 3963 case TB_SETSTATE: 3964 return TOOLBAR_SetState (hwnd, wParam, lParam); 3965 3966 case TB_SETSTYLE: 3967 return TOOLBAR_SetStyle (hwnd, wParam, lParam); 3968 3969 case TB_SETTOOLTIPS: 3970 return TOOLBAR_SetToolTips (hwnd, wParam, lParam); 3971 3972 case TB_SETUNICODEFORMAT: 3973 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam); 3974 3975 case CCM_SETVERSION: 3976 return TOOLBAR_SetVersion (hwnd, (INT)wParam); 3977 3978 3979 /* case WM_CHAR: */ 3980 3981 case WM_CREATE: 3982 return TOOLBAR_Create (hwnd, wParam, lParam); 3983 3984 case WM_ERASEBKGND: 3985 return TOOLBAR_EraseBackground (hwnd, wParam, lParam); 3986 3987 case WM_GETFONT: 3988 return TOOLBAR_GetFont (hwnd, wParam, lParam); 3989 3990 /* case WM_KEYDOWN: */ 3991 /* case WM_KILLFOCUS: */ 3992 3993 case WM_LBUTTONDBLCLK: 3994 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam); 3995 3996 case WM_LBUTTONDOWN: 3997 return TOOLBAR_LButtonDown (hwnd, wParam, lParam); 3998 3999 case WM_LBUTTONUP: 4000 return TOOLBAR_LButtonUp (hwnd, wParam, lParam); 4001 4002 case WM_MOUSEMOVE: 4003 return TOOLBAR_MouseMove (hwnd, wParam, lParam); 4004 4005 case WM_MOUSELEAVE: 4006 return TOOLBAR_MouseLeave (hwnd, wParam, lParam); 4007 4008 case WM_NCACTIVATE: 4009 return TOOLBAR_NCActivate (hwnd, wParam, lParam); 4010 4011 case WM_NCCALCSIZE: 4012 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam); 4013 4014 case WM_NCPAINT: 4015 return TOOLBAR_NCPaint (hwnd, wParam, lParam); 4016 4017 case WM_NOTIFY: 4018 return TOOLBAR_Notify (hwnd, wParam, lParam); 4019 4020 /* case WM_NOTIFYFORMAT: */ 4021 4022 case WM_PAINT: 4023 return TOOLBAR_Paint (hwnd, wParam); 4024 4025 case WM_SIZE: 4026 return TOOLBAR_Size (hwnd, wParam, lParam); 4027 4028 case WM_STYLECHANGED: 4029 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam); 4030 4031 /* case WM_SYSCOLORCHANGE: */ 4032 4033 /* case WM_WININICHANGE: */ 4034 4035 case WM_CHARTOITEM: 4036 case WM_COMMAND: 4037 case WM_DRAWITEM: 4038 case WM_MEASUREITEM: 4039 case WM_VKEYTOITEM: 4040 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); 3991 case TB_ADDBITMAP: 3992 return TOOLBAR_AddBitmap (hwnd, wParam, lParam); 3993 3994 case TB_ADDBUTTONSA: 3995 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam); 3996 3997 case TB_ADDBUTTONSW: 3998 return TOOLBAR_AddButtonsW(hwnd,wParam,lParam); 3999 4000 case TB_ADDSTRINGA: 4001 return TOOLBAR_AddStringA (hwnd, wParam, lParam); 4002 4003 case TB_ADDSTRINGW: 4004 return TOOLBAR_AddStringW (hwnd, wParam, lParam); 4005 4006 case TB_AUTOSIZE: 4007 return TOOLBAR_AutoSize (hwnd); 4008 4009 case TB_BUTTONCOUNT: 4010 return TOOLBAR_ButtonCount (hwnd, wParam, lParam); 4011 4012 case TB_BUTTONSTRUCTSIZE: 4013 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam); 4014 4015 case TB_CHANGEBITMAP: 4016 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam); 4017 4018 case TB_CHECKBUTTON: 4019 return TOOLBAR_CheckButton (hwnd, wParam, lParam); 4020 4021 case TB_COMMANDTOINDEX: 4022 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam); 4023 4024 case TB_CUSTOMIZE: 4025 return TOOLBAR_Customize (hwnd); 4026 4027 case TB_DELETEBUTTON: 4028 return TOOLBAR_DeleteButton (hwnd, wParam, lParam); 4029 4030 case TB_ENABLEBUTTON: 4031 return TOOLBAR_EnableButton (hwnd, wParam, lParam); 4032 4033 case TB_GETANCHORHIGHLIGHT: 4034 return TOOLBAR_GetAnchorHighlight (hwnd); 4035 4036 case TB_GETBITMAP: 4037 return TOOLBAR_GetBitmap (hwnd, wParam, lParam); 4038 4039 case TB_GETBITMAPFLAGS: 4040 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam); 4041 4042 case TB_GETBUTTON: 4043 return TOOLBAR_GetButton (hwnd, wParam, lParam); 4044 4045 case TB_GETBUTTONINFOA: 4046 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam); 4047 4048 case TB_GETBUTTONINFOW: /* 4.71 */ 4049 return TOOLBAR_GetButtonInfoW(hwnd,wParam,lParam); 4050 4051 case TB_GETBUTTONSIZE: 4052 return TOOLBAR_GetButtonSize (hwnd); 4053 4054 case TB_GETBUTTONTEXTA: 4055 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam); 4056 4057 case TB_GETBUTTONTEXTW: 4058 return TOOLBAR_GetButtonTextW(hwnd,wParam,lParam); 4059 4060 /* case TB_GETCOLORSCHEME: */ /* 4.71 */ 4061 4062 case TB_GETDISABLEDIMAGELIST: 4063 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam); 4064 4065 case TB_GETEXTENDEDSTYLE: 4066 return TOOLBAR_GetExtendedStyle (hwnd); 4067 4068 case TB_GETHOTIMAGELIST: 4069 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam); 4070 4071 case TB_GETHOTITEM: 4072 return TOOLBAR_GetHotItem (hwnd); 4073 4074 case TB_GETIMAGELIST: 4075 return TOOLBAR_GetImageList (hwnd, wParam, lParam); 4076 4077 /* case TB_GETINSERTMARK: */ /* 4.71 */ 4078 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */ 4079 4080 case TB_GETITEMRECT: 4081 return TOOLBAR_GetItemRect (hwnd, wParam, lParam); 4082 4083 case TB_GETMAXSIZE: 4084 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam); 4085 4086 /* case TB_GETOBJECT: */ /* 4.71 */ 4087 /* case TB_GETPADDING: */ /* 4.71 */ 4088 4089 case TB_GETRECT: 4090 return TOOLBAR_GetRect (hwnd, wParam, lParam); 4091 4092 case TB_GETROWS: 4093 return TOOLBAR_GetRows (hwnd, wParam, lParam); 4094 4095 case TB_GETSTATE: 4096 return TOOLBAR_GetState (hwnd, wParam, lParam); 4097 4098 case TB_GETSTYLE: 4099 return TOOLBAR_GetStyle (hwnd, wParam, lParam); 4100 4101 case TB_GETTEXTROWS: 4102 return TOOLBAR_GetTextRows (hwnd, wParam, lParam); 4103 4104 case TB_GETTOOLTIPS: 4105 return TOOLBAR_GetToolTips (hwnd, wParam, lParam); 4106 4107 case TB_HIDEBUTTON: 4108 return TOOLBAR_HideButton (hwnd, wParam, lParam); 4109 4110 case TB_HITTEST: 4111 return TOOLBAR_HitTest (hwnd, wParam, lParam); 4112 4113 case TB_INDETERMINATE: 4114 return TOOLBAR_Indeterminate (hwnd, wParam, lParam); 4115 4116 case TB_INSERTBUTTONA: 4117 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam); 4118 4119 case TB_INSERTBUTTONW: 4120 return TOOLBAR_InsertButtonW(hwnd,wParam,lParam); 4121 4122 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */ 4123 4124 case TB_ISBUTTONCHECKED: 4125 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam); 4126 4127 case TB_ISBUTTONENABLED: 4128 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam); 4129 4130 case TB_ISBUTTONHIDDEN: 4131 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam); 4132 4133 case TB_ISBUTTONHIGHLIGHTED: 4134 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam); 4135 4136 case TB_ISBUTTONINDETERMINATE: 4137 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam); 4138 4139 case TB_ISBUTTONPRESSED: 4140 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam); 4141 4142 case TB_LOADIMAGES: /* 4.70 */ 4143 // FIXME("missing standard imagelists\n"); 4144 return 0; 4145 /* case TB_MAPACCELERATORA: */ /* 4.71 */ 4146 /* case TB_MAPACCELERATORW: */ /* 4.71 */ 4147 /* case TB_MARKBUTTON: */ /* 4.71 */ 4148 /* case TB_MOVEBUTTON: */ /* 4.71 */ 4149 4150 case TB_PRESSBUTTON: 4151 return TOOLBAR_PressButton (hwnd, wParam, lParam); 4152 4153 /* case TB_REPLACEBITMAP: */ 4154 4155 case TB_SAVERESTOREA: 4156 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam); 4157 4158 case TB_SAVERESTOREW: 4159 return TOOLBAR_SaveRestoreW(hwnd,wParam,lParam); 4160 4161 case TB_SETANCHORHIGHLIGHT: 4162 return TOOLBAR_SetAnchorHighlight (hwnd, wParam); 4163 4164 case TB_SETBITMAPSIZE: 4165 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam); 4166 4167 case TB_SETBUTTONINFOA: 4168 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam); 4169 4170 case TB_SETBUTTONINFOW: /* 4.71 */ 4171 return TOOLBAR_SetButtonInfoW(hwnd,wParam,lParam); 4172 4173 case TB_SETBUTTONSIZE: 4174 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam); 4175 4176 case TB_SETBUTTONWIDTH: 4177 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam); 4178 4179 case TB_SETCMDID: 4180 return TOOLBAR_SetCmdId (hwnd, wParam, lParam); 4181 4182 /* case TB_SETCOLORSCHEME: */ /* 4.71 */ 4183 4184 case TB_SETDISABLEDIMAGELIST: 4185 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam); 4186 4187 case TB_SETDRAWTEXTFLAGS: 4188 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam); 4189 4190 case TB_SETEXTENDEDSTYLE: 4191 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam); 4192 4193 case TB_SETHOTIMAGELIST: 4194 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam); 4195 4196 case TB_SETHOTITEM: 4197 return TOOLBAR_SetHotItem (hwnd, wParam); 4198 4199 case TB_SETIMAGELIST: 4200 return TOOLBAR_SetImageList (hwnd, wParam, lParam); 4201 4202 case TB_SETINDENT: 4203 return TOOLBAR_SetIndent (hwnd, wParam, lParam); 4204 4205 /* case TB_SETINSERTMARK: */ /* 4.71 */ 4206 4207 case TB_SETINSERTMARKCOLOR: 4208 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam); 4209 4210 case TB_SETMAXTEXTROWS: 4211 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam); 4212 4213 /* case TB_SETPADDING: */ /* 4.71 */ 4214 4215 case TB_SETPARENT: 4216 return TOOLBAR_SetParent (hwnd, wParam, lParam); 4217 4218 case TB_SETROWS: 4219 return TOOLBAR_SetRows (hwnd, wParam, lParam); 4220 4221 case TB_SETSTATE: 4222 return TOOLBAR_SetState (hwnd, wParam, lParam); 4223 4224 case TB_SETSTYLE: 4225 return TOOLBAR_SetStyle (hwnd, wParam, lParam); 4226 4227 case TB_SETTOOLTIPS: 4228 return TOOLBAR_SetToolTips (hwnd, wParam, lParam); 4229 4230 /* case WM_CHAR: */ 4231 4232 case WM_CREATE: 4233 return TOOLBAR_Create (hwnd, wParam, lParam); 4234 4235 case WM_ERASEBKGND: 4236 return TOOLBAR_EraseBackground (hwnd, wParam, lParam); 4237 4238 case WM_GETFONT: 4239 return TOOLBAR_GetFont (hwnd, wParam, lParam); 4240 4241 /* case WM_KEYDOWN: */ 4242 /* case WM_KILLFOCUS: */ 4243 4244 case WM_LBUTTONDBLCLK: 4245 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam); 4246 4247 case WM_LBUTTONDOWN: 4248 return TOOLBAR_LButtonDown (hwnd, wParam, lParam); 4249 4250 case WM_LBUTTONUP: 4251 return TOOLBAR_LButtonUp (hwnd, wParam, lParam); 4252 4253 case WM_MOUSEMOVE: 4254 return TOOLBAR_MouseMove (hwnd, wParam, lParam); 4255 4256 case WM_NCACTIVATE: 4257 return TOOLBAR_NCActivate (hwnd, wParam, lParam); 4258 4259 case WM_NCCALCSIZE: 4260 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam); 4261 4262 case WM_NCPAINT: 4263 return TOOLBAR_NCPaint (hwnd, wParam, lParam); 4264 4265 case WM_NOTIFY: 4266 return TOOLBAR_Notify (hwnd, wParam, lParam); 4267 4268 case WM_PAINT: 4269 return TOOLBAR_Paint (hwnd, wParam); 4270 4271 case WM_SIZE: 4272 return TOOLBAR_Size (hwnd, wParam, lParam); 4273 4274 case WM_STYLECHANGED: 4275 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam); 4276 4277 /* case WM_SYSCOLORCHANGE: */ 4278 4279 /* case WM_WININICHANGE: */ 4280 4281 case WM_CHARTOITEM: 4282 case WM_COMMAND: 4283 case WM_DRAWITEM: 4284 case WM_MEASUREITEM: 4285 case WM_VKEYTOITEM: 4286 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); 4041 4287 4042 4288 default: … … 4051 4297 4052 4298 VOID 4053 TOOLBAR_Register ( void)4299 TOOLBAR_Register (VOID) 4054 4300 { 4055 4301 WNDCLASSA wndClass; … … 4063 4309 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 4064 4310 wndClass.lpszClassName = TOOLBARCLASSNAMEA; 4065 4311 4066 4312 RegisterClassA (&wndClass); 4067 4313 } … … 4069 4315 4070 4316 VOID 4071 TOOLBAR_Unregister ( void)4317 TOOLBAR_Unregister (VOID) 4072 4318 { 4073 4319 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL); -
trunk/src/comctl32/tooltips.cpp
r3962 r3963 1 /* $Id: tooltips.cpp,v 1. 9 2000-08-06 14:40:18sandervl Exp $ */1 /* $Id: tooltips.cpp,v 1.10 2000-08-06 20:28:29 sandervl Exp $ */ 2 2 /* 3 3 * Tool tip control … … 8 8 * 9 9 * TODO: 10 * - Unicode support (started).11 10 * - Custom draw support. 12 11 * … … 16 15 * curtool.exe, deltool.exe, enumtools.exe, getinfo.exe, getiptxt.exe, 17 16 * hittest.exe, needtext.exe, newrect.exe, updtext.exe and winfrpt.exe. 18 *19 * Timer logic.20 *21 * One important point to remember is that tools don't necessarily get22 * a WM_MOUSEMOVE once the cursor leaves the tool, an example is when23 * a tool sets TTF_IDISHWND (i.e. an entire window is a tool) because24 * here WM_MOUSEMOVEs only get sent when the cursor is inside the25 * client area. Therefore the only reliable way to know that the26 * cursor has left a tool is to keep a timer running and check the27 * position every time it expires. This is the role of timer28 * ID_TIMERLEAVE.29 *30 *31 * On entering a tool (detected in a relayed WM_MOUSEMOVE) we start32 * ID_TIMERSHOW, if this times out and we're still in the tool we show33 * the tip. On showing a tip we start both ID_TIMERPOP and34 * ID_TIMERLEAVE. On hiding a tooltip we kill ID_TIMERPOP.35 * ID_TIMERPOP is restarted on every relayed WM_MOUSEMOVE. If36 * ID_TIMERPOP expires the tool is hidden and ID_TIMERPOP is killed.37 * ID_TIMERLEAVE remains running - this is important as we need to38 * determine when the cursor leaves the tool.39 *40 * When ID_TIMERLEAVE expires or on a relayed WM_MOUSEMOVE if we're41 * still in the tool do nothing (apart from restart ID_TIMERPOP if42 * this is a WM_MOUSEMOVE) (ID_TIMERLEAVE remains running). If we've43 * left the tool and entered another one then hide the tip and start44 * ID_TIMERSHOW with time ReshowTime and kill ID_TIMERLEAVE. If we're45 * outside all tools hide the tip and kill ID_TIMERLEAVE. On Relayed46 * mouse button messages hide the tip but leave ID_TIMERLEAVE running,47 * this again will let us keep track of when the cursor leaves the48 * tool.49 *50 *51 * infoPtr->nTool is the tool the mouse was on on the last relayed MM52 * or timer expiry or -1 if the mouse was not on a tool.53 *54 * infoPtr->nCurrentTool is the tool for which the tip is currently55 * displaying text for or -1 if the tip is not shown. Actually this56 * will only ever be infoPtr-nTool or -1, so it could be changed to a57 * BOOL.58 *59 17 */ 60 18 61 19 /* 62 - (WINE 20000801 level) 20 - Corel WINE 20000513 level 21 - (WINE 20000130 level) 63 22 */ 64 23 65 24 #include <string.h> 66 25 67 #include "winnls.h"68 26 #include "winbase.h" 69 27 #include "commctrl.h" … … 76 34 #define ID_TIMERLEAVE 3 /* tool leave timer */ 77 35 78 #ifdef __WIN32OS2__79 #define FIXME80 #define TRACE81 #define WARN82 #define ERR83 #define debugstr_w84 #endif85 36 86 37 extern LPSTR COMCTL32_aSubclass; /* global subclassing atom */ … … 94 45 TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 95 46 96 static VOID 97 TOOLTIPS_Refresh(HWND hwnd, HDC hdc)47 48 static VOID TOOLTIPS_Draw (HWND hwnd, HDC hdc) 98 49 { 99 50 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd); … … 104 55 UINT uFlags = DT_EXTERNALLEADING; 105 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 106 212 if (infoPtr->nMaxTipWidth > -1) 107 uFlags |= DT_WORDBREAK; 108 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX) 109 uFlags |= DT_NOPREFIX; 110 GetClientRect (hwnd, &rc); 111 112 /* fill the background */ 113 hBrush = CreateSolidBrush (infoPtr->clrBk); 114 FillRect (hdc, &rc, hBrush); 115 DeleteObject (hBrush); 116 117 /* calculate text rectangle */ 118 rc.left += (2 + infoPtr->rcMargin.left); 119 rc.top += (2 + infoPtr->rcMargin.top); 120 rc.right -= (2 + infoPtr->rcMargin.right); 121 rc.bottom -= (2 + infoPtr->rcMargin.bottom); 122 123 /* draw text */ 124 oldBkMode = SetBkMode (hdc, TRANSPARENT); 125 SetTextColor (hdc, infoPtr->clrText); 126 hOldFont = SelectObject (hdc, infoPtr->hFont); 127 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags); 128 SelectObject (hdc, hOldFont); 129 if (oldBkMode != TRANSPARENT) 130 SetBkMode (hdc, oldBkMode); 131 } 132 133 134 static VOID 135 TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool) 136 { 137 TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool]; 138 139 if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) { 140 /* load a resource */ 141 TRACE("load res string %x %x\n", 142 toolPtr->hinst, (int)toolPtr->lpszText); 143 LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText, 144 infoPtr->szTipText, INFOTIPSIZE); 145 } 146 else if (toolPtr->lpszText) { 147 if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) { 148 NMTTDISPINFOA ttnmdi; 149 150 /* fill NMHDR struct */ 151 ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA)); 152 ttnmdi.hdr.hwndFrom = hwnd; 153 ttnmdi.hdr.idFrom = toolPtr->uId; 154 ttnmdi.hdr.code = TTN_GETDISPINFOA; 155 ttnmdi.lpszText = (LPSTR)&ttnmdi.szText; 156 ttnmdi.uFlags = toolPtr->uFlags; 157 ttnmdi.lParam = toolPtr->lParam; 158 159 TRACE("hdr.idFrom = %x\n", ttnmdi.hdr.idFrom); 160 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 161 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi); 162 163 if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.lpszText) == 0)) { 164 LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.lpszText, 165 infoPtr->szTipText, INFOTIPSIZE); 166 if (ttnmdi.uFlags & TTF_DI_SETITEM) { 167 toolPtr->hinst = ttnmdi.hinst; 168 toolPtr->lpszText = (LPWSTR)ttnmdi.lpszText; 169 } 170 } 171 else if (ttnmdi.szText[0]) { 172 MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText, 80, 173 infoPtr->szTipText, INFOTIPSIZE); 174 if (ttnmdi.uFlags & TTF_DI_SETITEM) { 175 INT len = MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText, 176 80, NULL, 0); 177 toolPtr->hinst = 0; 178 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR)); 179 MultiByteToWideChar(CP_ACP, 0, ttnmdi.szText, 80, 180 toolPtr->lpszText, len); 181 } 182 } 183 else if (ttnmdi.lpszText == 0) { 184 /* no text available */ 185 infoPtr->szTipText[0] = L'\0'; 186 } 187 else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) { 188 MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1, 189 infoPtr->szTipText, INFOTIPSIZE); 190 if (ttnmdi.uFlags & TTF_DI_SETITEM) { 191 INT len = MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, 192 -1, NULL, 0); 193 toolPtr->hinst = 0; 194 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR)); 195 MultiByteToWideChar(CP_ACP, 0, ttnmdi.lpszText, -1, 196 toolPtr->lpszText, len); 197 } 198 } 199 else { 200 ERR("recursive text callback!\n"); 201 infoPtr->szTipText[0] = '\0'; 202 } 203 } 204 else { 205 /* the item is a usual (unicode) text */ 206 lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE); 207 } 208 } 209 else { 210 /* no text available */ 211 infoPtr->szTipText[0] = L'\0'; 212 } 213 214 // TRACE("%s\n", debugstr_w(infoPtr->szTipText)); 215 } 216 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 } 217 308 218 309 static VOID … … 225 316 226 317 if (infoPtr->nMaxTipWidth > -1) { 227 228 318 rc.right = infoPtr->nMaxTipWidth; 319 uFlags |= DT_WORDBREAK; 229 320 } 230 321 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX) 231 232 TRACE("%s\n", debugstr_w(infoPtr->szTipText));322 uFlags |= DT_NOPREFIX; 323 //TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText)); 233 324 234 325 hdc = GetDC (hwnd); … … 238 329 ReleaseDC (hwnd, hdc); 239 330 240 lpSize->cx = rc.right - rc.left + 4 + 241 331 lpSize->cx = rc.right - rc.left + 4 + 332 infoPtr->rcMargin.left + infoPtr->rcMargin.right; 242 333 lpSize->cy = rc.bottom - rc.top + 4 + 243 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top; 244 } 245 334 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top; 335 } 246 336 247 337 static VOID … … 251 341 RECT rect, wndrect; 252 342 SIZE size; 343 HDC hdc; 253 344 NMHDR hdr; 254 345 255 346 if (infoPtr->nTool == -1) { 256 257 347 // TRACE("invalid tool (-1)!\n"); 348 return; 258 349 } 259 350 260 351 infoPtr->nCurrentTool = infoPtr->nTool; 261 352 262 TRACE("Show tooltip pre %d! (%04x)\n", infoPtr->nTool, hwnd);353 // TRACE("Show tooltip pre %d!\n", infoPtr->nTool); 263 354 264 355 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool); 265 356 266 357 if (infoPtr->szTipText[0] == L'\0') { 267 268 269 } 270 271 TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool);358 infoPtr->nCurrentTool = -1; 359 return; 360 } 361 362 // TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool); 272 363 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; 273 364 … … 276 367 hdr.code = TTN_SHOW; 277 368 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 278 279 280 TRACE("%s\n", debugstr_w(infoPtr->szTipText));369 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 370 371 // TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText)); 281 372 282 373 TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size); 283 TRACE("size %d - %d\n", size.cx, size.cy);374 // TRACE("size %d - %d\n", size.cx, size.cy); 284 375 285 376 if (toolPtr->uFlags & TTF_CENTERTIP) { 286 287 288 289 290 291 292 293 294 295 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; 296 387 } 297 388 else { 298 299 300 } 301 302 TRACE("pos %d - %d\n", rect.left, rect.top);389 GetCursorPos ((LPPOINT)&rect); 390 rect.top += 20; 391 } 392 393 // TRACE("pos %d - %d\n", rect.left, rect.top); 303 394 304 395 rect.right = rect.left + size.cx; … … 308 399 wndrect.right = GetSystemMetrics( SM_CXSCREEN ); 309 400 if( rect.right > wndrect.right ) { 310 311 401 rect.left -= rect.right - wndrect.right + 2; 402 rect.right = wndrect.right - 2; 312 403 } 313 404 wndrect.bottom = GetSystemMetrics( SM_CYSCREEN ); … … 315 406 RECT rc; 316 407 317 318 319 320 321 322 } 323 324 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; 325 416 } 326 417 327 418 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE), 328 419 FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE)); 329 420 330 421 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top, 331 332 422 rect.right - rect.left, rect.bottom - rect.top, 423 SWP_SHOWWINDOW | SWP_NOACTIVATE); 333 424 334 425 /* repaint the tooltip */ 335 InvalidateRect(hwnd, NULL, TRUE); 336 UpdateWindow(hwnd); 426 hdc = GetDC (hwnd); 427 TOOLTIPS_Draw(hwnd, hdc); 428 ReleaseDC (hwnd, hdc); 337 429 338 430 SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); 339 TRACE("timer 2 started!\n");340 SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0);341 TRACE("timer 3 started!\n");342 431 } 343 432 … … 349 438 NMHDR hdr; 350 439 351 TRACE("Hide tooltip %d! (%04x)\n", infoPtr->nCurrentTool, hwnd);352 353 440 if (infoPtr->nCurrentTool == -1) 354 441 return; 355 442 356 443 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; 444 //TRACE (tooltips, "Hide tooltip %d!\n", infoPtr->nCurrentTool); 357 445 KillTimer (hwnd, ID_TIMERPOP); 358 446 … … 361 449 hdr.code = TTN_POP; 362 450 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 363 451 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 364 452 365 453 infoPtr->nCurrentTool = -1; 366 454 367 455 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, 368 456 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); 369 457 } 370 458 … … 375 463 TTTOOL_INFO *toolPtr; 376 464 RECT rect; 377 SIZE size;465 HDC hdc; 378 466 NMHDR hdr; 379 467 380 if (infoPtr->nTrackTool == -1) { 381 TRACE("invalid tracking tool (-1)!\n"); 382 return; 383 } 384 385 TRACE("show tracking tooltip pre %d!\n", infoPtr->nTrackTool); 386 387 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nTrackTool); 388 389 if (infoPtr->szTipText[0] == L'\0') { 390 infoPtr->nTrackTool = -1; 391 return; 392 } 393 394 TRACE("show tracking tooltip %d!\n", infoPtr->nTrackTool); 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); 395 485 toolPtr = &infoPtr->tools[infoPtr->nTrackTool]; 396 486 … … 398 488 hdr.idFrom = toolPtr->uId; 399 489 hdr.code = TTN_SHOW; 400 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 401 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 402 403 TRACE("%s\n", debugstr_w(infoPtr->szTipText)); 404 405 TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size); 406 TRACE("size %d - %d\n", size.cx, size.cy); 407 408 if (toolPtr->uFlags & TTF_ABSOLUTE) { 409 rect.left = infoPtr->xTrackPos; 410 rect.top = infoPtr->yTrackPos; 411 412 if (toolPtr->uFlags & TTF_CENTERTIP) { 413 rect.left -= (size.cx / 2); 414 rect.top -= (size.cy / 2); 415 } 416 } 417 else { 418 RECT rcTool; 419 420 if (toolPtr->uFlags & TTF_IDISHWND) 421 GetWindowRect ((HWND)toolPtr->uId, &rcTool); 422 else { 423 rcTool = toolPtr->rect; 424 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rcTool, 2); 425 } 426 427 GetCursorPos ((LPPOINT)&rect); 428 rect.top += 20; 429 430 if (toolPtr->uFlags & TTF_CENTERTIP) { 431 rect.left -= (size.cx / 2); 432 rect.top -= (size.cy / 2); 433 } 434 435 /* smart placement */ 436 if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) && 437 (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom)) 438 rect.left = rcTool.right; 439 } 440 441 TRACE("pos %d - %d\n", rect.left, rect.top); 442 443 rect.right = rect.left + size.cx; 444 rect.bottom = rect.top + size.cy; 445 446 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE), 447 FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE)); 448 449 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top, 450 rect.right - rect.left, rect.bottom - rect.top, 451 SWP_SHOWWINDOW | SWP_NOACTIVATE ); 452 453 InvalidateRect(hwnd, NULL, TRUE); 454 UpdateWindow(hwnd); 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); 455 503 } 456 504 … … 463 511 464 512 if (infoPtr->nTrackTool == -1) 465 513 return; 466 514 467 515 toolPtr = &infoPtr->tools[infoPtr->nTrackTool]; 468 TRACE("hide tracking tooltip %d!\n", infoPtr->nTrackTool);516 // TRACE (tooltips, "hide tracking tooltip %d!\n", infoPtr->nTrackTool); 469 517 470 518 hdr.hwndFrom = hwnd; … … 472 520 hdr.code = TTN_POP; 473 521 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 474 522 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 475 523 476 524 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, 477 525 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); 478 526 } 479 527 … … 486 534 487 535 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 488 489 490 if (!(toolPtr->uFlags & TTF_IDISHWND) && 491 492 493 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; 494 542 } 495 543 496 544 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 497 498 499 500 501 545 toolPtr = &infoPtr->tools[nTool]; 546 547 if ((toolPtr->uFlags & TTF_IDISHWND) && 548 (lpToolInfo->uId == toolPtr->uId)) 549 return nTool; 502 550 } 503 551 … … 513 561 514 562 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 515 516 517 if (!(toolPtr->uFlags & TTF_IDISHWND) && 518 519 520 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; 521 569 } 522 570 523 571 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 524 525 526 527 528 572 toolPtr = &infoPtr->tools[nTool]; 573 574 if ((toolPtr->uFlags & TTF_IDISHWND) && 575 (lpToolInfo->uId == toolPtr->uId)) 576 return nTool; 529 577 } 530 578 … … 539 587 INT nTool; 540 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 541 596 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 542 543 544 545 546 547 548 549 550 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 } 551 606 } 552 607 553 608 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 554 555 556 557 558 559 609 toolPtr = &infoPtr->tools[nTool]; 610 611 if (toolPtr->uFlags & TTF_IDISHWND) { 612 if ((HWND)toolPtr->uId == hwnd) 613 return nTool; 614 } 560 615 } 561 616 562 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); 563 633 } 564 634 … … 569 639 HWND hwndActive = GetActiveWindow (); 570 640 if (!hwndActive) 571 641 return FALSE; 572 642 if (hwndActive == hwnd) 573 643 return TRUE; 574 644 return IsChild (hwndActive, hwnd); 575 645 } … … 587 657 hwndTool = SendMessageA (hwnd, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt); 588 658 if (hwndTool == 0) 589 659 return -1; 590 660 591 661 ScreenToClient (hwndTool, &pt); 592 662 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt); 593 663 if (nTool == -1) 594 664 return -1; 595 665 596 666 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) { 597 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER))) 598 return -1; 599 } 600 601 TRACE("tool %d\n", nTool); 667 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER))) 668 return -1; 669 } 602 670 603 671 return nTool; … … 608 676 TOOLTIPS_Activate (HWND hwnd, WPARAM wParam, LPARAM lParam) 609 677 { 610 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr 678 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd); 611 679 612 680 infoPtr->bActive = (BOOL)wParam; 613 681 614 if (infoPtr->bActive)615 TRACE("activate!\n");616 617 682 if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1)) 618 TOOLTIPS_Hide (hwnd, infoPtr); 619 620 return 0; 621 } 622 623 624 static LRESULT 625 TOOLTIPS_AddToolA (HWND hwnd, WPARAM wParam, LPARAM lParam) 626 { 627 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); 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); 628 767 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; 629 768 TTTOOL_INFO *toolPtr; 630 769 631 if (lpToolInfo == NULL) 632 return FALSE; 633 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 634 return FALSE; 635 636 TRACE("add tool (%x) %x %d%s!\n", 637 hwnd, lpToolInfo->hwnd, lpToolInfo->uId, 638 (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : ""); 639 640 if (infoPtr->uNumTools == 0) { 641 infoPtr->tools = (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO)); 642 toolPtr = infoPtr->tools; 643 } 644 else { 645 TTTOOL_INFO *oldTools = infoPtr->tools; 646 infoPtr->tools = 647 (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1)); 648 memcpy (infoPtr->tools, oldTools, 649 infoPtr->uNumTools * sizeof(TTTOOL_INFO)); 650 COMCTL32_Free (oldTools); 651 toolPtr = &infoPtr->tools[infoPtr->uNumTools]; 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 } 652 813 } 653 814 … … 661 822 toolPtr->hinst = lpToolInfo->hinst; 662 823 663 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {664 TRACE("add string id %x!\n", (int)lpToolInfo->lpszText); 665 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;666 }667 else if (lpToolInfo->lpszText) {668 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA){669 TRACE("add CALLBACK!\n"); 670 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 671 } 672 else { 673 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1, 674 NULL, 0); 675 TRACE("add text \"%s\"!\n",lpToolInfo->lpszText);676 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR));677 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1, 678 toolPtr->lpszText, len);679 680 } 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; 681 842 682 843 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 683 844 toolPtr->lParam = lpToolInfo->lParam; 684 845 685 846 /* install subclassing hook */ 686 if (toolPtr->uFlags & TTF_SUBCLASS) { 687 if (toolPtr->uFlags & TTF_IDISHWND) { 688 LPTT_SUBCLASS_INFO lpttsi = 689 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 690 if (lpttsi == NULL) { 691 lpttsi = 692 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO)); 693 lpttsi->wpOrigProc = 694 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId, 695 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 696 lpttsi->hwndToolTip = hwnd; 697 lpttsi->uRefCount++; 698 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass, 699 (HANDLE)lpttsi); 700 } 701 else 702 WARN("A window tool must only be listed once!\n"); 703 } 704 else { 705 LPTT_SUBCLASS_INFO lpttsi = 706 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 707 if (lpttsi == NULL) { 708 lpttsi = 709 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO)); 710 lpttsi->wpOrigProc = 711 (WNDPROC)SetWindowLongA (toolPtr->hwnd, 712 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 713 lpttsi->hwndToolTip = hwnd; 714 lpttsi->uRefCount++; 715 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi); 716 } 717 else 718 lpttsi->uRefCount++; 719 } 720 TRACE("subclassing installed!\n"); 721 } 847 TOOLTIPS_Subclass(hwnd,toolPtr); 722 848 723 849 return TRUE; … … 733 859 734 860 if (lpToolInfo == NULL) 735 861 return FALSE; 736 862 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 737 return FALSE; 738 739 TRACE("add tool (%x) %x %d%s!\n", 740 hwnd, lpToolInfo->hwnd, lpToolInfo->uId, 741 (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : ""); 742 743 if (infoPtr->uNumTools == 0) { 744 infoPtr->tools = (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO)); 745 toolPtr = infoPtr->tools; 746 } 747 else { 748 TTTOOL_INFO *oldTools = infoPtr->tools; 749 infoPtr->tools = 750 (TTTOOL_INFO*)COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1)); 751 memcpy (infoPtr->tools, oldTools, 752 infoPtr->uNumTools * sizeof(TTTOOL_INFO)); 753 COMCTL32_Free (oldTools); 754 toolPtr = &infoPtr->tools[infoPtr->uNumTools]; 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 } 755 905 } 756 906 … … 765 915 766 916 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) { 767 TRACE("add string id %x!\n", (int)lpToolInfo->lpszText);768 917 // TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText); 918 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 769 919 } 770 920 else if (lpToolInfo->lpszText) { 771 772 TRACE("add CALLBACK!\n");773 774 775 776 777 TRACE("add text %s!\n",778 779 toolPtr->lpszText =(WCHAR*)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));780 781 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 } 782 932 } 783 933 784 934 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 785 935 toolPtr->lParam = lpToolInfo->lParam; 786 936 787 937 /* install subclassing hook */ 788 if (toolPtr->uFlags & TTF_SUBCLASS) { 789 if (toolPtr->uFlags & TTF_IDISHWND) { 790 LPTT_SUBCLASS_INFO lpttsi = 791 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 792 if (lpttsi == NULL) { 793 lpttsi = 794 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO)); 795 lpttsi->wpOrigProc = 796 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId, 797 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 798 lpttsi->hwndToolTip = hwnd; 799 lpttsi->uRefCount++; 800 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass, 801 (HANDLE)lpttsi); 802 } 803 else 804 WARN("A window tool must only be listed once!\n"); 805 } 806 else { 807 LPTT_SUBCLASS_INFO lpttsi = 808 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 809 if (lpttsi == NULL) { 810 lpttsi = 811 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO)); 812 lpttsi->wpOrigProc = 813 (WNDPROC)SetWindowLongA (toolPtr->hwnd, 814 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 815 lpttsi->hwndToolTip = hwnd; 816 lpttsi->uRefCount++; 817 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi); 818 } 819 else 820 lpttsi->uRefCount++; 821 } 822 TRACE("subclassing installed!\n"); 823 } 938 TOOLTIPS_Subclass(hwnd,toolPtr); 824 939 825 940 return TRUE; … … 836 951 837 952 if (lpToolInfo == NULL) 838 953 return 0; 839 954 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 840 955 return 0; 841 956 if (infoPtr->uNumTools == 0) 842 957 return 0; 843 958 844 959 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 845 960 if (nTool == -1) return 0; 846 961 847 TRACE("tool %d\n", nTool);962 // TRACE (tooltips, "tool %d\n", nTool); 848 963 849 964 /* delete text string */ 850 toolPtr = &infoPtr->tools[nTool]; 965 toolPtr = &infoPtr->tools[nTool]; 851 966 if ((toolPtr->hinst) && (toolPtr->lpszText)) { 852 853 854 967 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) && 968 (HIWORD((INT)toolPtr->lpszText) != 0) ) 969 COMCTL32_Free (toolPtr->lpszText); 855 970 } 856 971 857 972 /* remove subclassing */ 858 if (toolPtr->uFlags & TTF_SUBCLASS) { 859 if (toolPtr->uFlags & TTF_IDISHWND) { 860 LPTT_SUBCLASS_INFO lpttsi = 861 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 862 if (lpttsi) { 863 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 864 (LONG)lpttsi->wpOrigProc); 865 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 866 COMCTL32_Free (&lpttsi); 867 } 868 else 869 ERR("Invalid data handle!\n"); 870 } 871 else { 872 LPTT_SUBCLASS_INFO lpttsi = 873 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 874 if (lpttsi) { 875 if (lpttsi->uRefCount == 1) { 876 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 877 (LONG)lpttsi->wpOrigProc); 878 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 879 COMCTL32_Free (&lpttsi); 880 } 881 else 882 lpttsi->uRefCount--; 883 } 884 else 885 ERR("Invalid data handle!\n"); 886 } 887 } 973 TOOLTIPS_Desubclass(toolPtr); 888 974 889 975 /* delete tool from tool list */ 890 976 if (infoPtr->uNumTools == 1) { 891 892 977 COMCTL32_Free (infoPtr->tools); 978 infoPtr->tools = NULL; 893 979 } 894 980 else { 895 896 897 898 899 900 901 902 903 904 905 906 907 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); 908 994 } 909 995 … … 923 1009 924 1010 if (lpToolInfo == NULL) 925 1011 return 0; 926 1012 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 927 1013 return 0; 928 1014 if (infoPtr->uNumTools == 0) 929 1015 return 0; 930 1016 931 1017 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); 932 1018 if (nTool == -1) return 0; 933 1019 934 TRACE("tool %d\n", nTool);1020 // TRACE (tooltips, "tool %d\n", nTool); 935 1021 936 1022 /* delete text string */ 937 toolPtr = &infoPtr->tools[nTool]; 1023 toolPtr = &infoPtr->tools[nTool]; 938 1024 if ((toolPtr->hinst) && (toolPtr->lpszText)) { 939 940 941 1025 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) && 1026 (HIWORD((INT)toolPtr->lpszText) != 0) ) 1027 COMCTL32_Free (toolPtr->lpszText); 942 1028 } 943 1029 944 1030 /* remove subclassing */ 945 if (toolPtr->uFlags & TTF_SUBCLASS) { 946 if (toolPtr->uFlags & TTF_IDISHWND) { 947 LPTT_SUBCLASS_INFO lpttsi = 948 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 949 if (lpttsi) { 950 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 951 (LONG)lpttsi->wpOrigProc); 952 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 953 COMCTL32_Free (&lpttsi); 954 } 955 else 956 ERR("Invalid data handle!\n"); 957 } 958 else { 959 LPTT_SUBCLASS_INFO lpttsi = 960 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 961 if (lpttsi) { 962 if (lpttsi->uRefCount == 1) { 963 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 964 (LONG)lpttsi->wpOrigProc); 965 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 966 COMCTL32_Free (&lpttsi); 967 } 968 else 969 lpttsi->uRefCount--; 970 } 971 else 972 ERR("Invalid data handle!\n"); 973 } 974 } 1031 TOOLTIPS_Desubclass(toolPtr); 975 1032 976 1033 /* delete tool from tool list */ 977 1034 if (infoPtr->uNumTools == 1) { 978 979 1035 COMCTL32_Free (infoPtr->tools); 1036 infoPtr->tools = NULL; 980 1037 } 981 1038 else { 982 983 984 985 986 987 988 989 990 991 992 993 994 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); 995 1052 } 996 1053 … … 1010 1067 1011 1068 if (lpToolInfo == NULL) 1012 1069 return FALSE; 1013 1070 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1014 1071 return FALSE; 1015 1072 if (uIndex >= infoPtr->uNumTools) 1016 1017 1018 TRACE("index=%u\n", uIndex);1073 return FALSE; 1074 1075 // TRACE (tooltips, "index=%u\n", uIndex); 1019 1076 1020 1077 toolPtr = &infoPtr->tools[uIndex]; … … 1030 1087 1031 1088 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 1032 1089 lpToolInfo->lParam = toolPtr->lParam; 1033 1090 1034 1091 return TRUE; … … 1045 1102 1046 1103 if (lpToolInfo == NULL) 1047 1104 return FALSE; 1048 1105 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1049 1106 return FALSE; 1050 1107 if (uIndex >= infoPtr->uNumTools) 1051 1052 1053 TRACE("index=%u\n", uIndex);1108 return FALSE; 1109 1110 // TRACE (tooltips, "index=%u\n", uIndex); 1054 1111 1055 1112 toolPtr = &infoPtr->tools[uIndex]; … … 1065 1122 1066 1123 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 1067 1124 lpToolInfo->lParam = toolPtr->lParam; 1068 1125 1069 1126 return TRUE; … … 1079 1136 1080 1137 if (lpToolInfo == NULL) 1081 1138 return FALSE; 1082 1139 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1083 1140 return FALSE; 1084 1141 1085 1142 if (lpToolInfo) { 1086 1087 1088 1089 1090 1091 1092 1093 /* 1094 1095 1096 1097 1098 1099 1100 1101 1102 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; 1103 1160 } 1104 1161 else 1105 1162 return (infoPtr->nCurrentTool != -1); 1106 1163 1107 1164 return FALSE; … … 1117 1174 1118 1175 if (lpToolInfo == NULL) 1119 1176 return FALSE; 1120 1177 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1121 1178 return FALSE; 1122 1179 1123 1180 if (lpToolInfo) { 1124 1125 1126 1127 1128 1129 1130 1131 /* 1132 1133 1134 1135 1136 1137 1138 1139 1140 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; 1141 1198 } 1142 1199 else 1143 1200 return (infoPtr->nCurrentTool != -1); 1144 1201 1145 1202 return FALSE; … … 1153 1210 1154 1211 switch (wParam) { 1155 case TTDT_RESHOW: 1156 return infoPtr->nReshowTime; 1157 1158 case TTDT_AUTOPOP: 1159 return infoPtr->nAutoPopTime; 1160 1161 case TTDT_INITIAL: 1162 case TTDT_AUTOMATIC: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */ 1163 return infoPtr->nInitialTime; 1164 1165 default: 1166 WARN("Invalid wParam %x\n", wParam); 1167 break; 1168 } 1169 1170 return -1; 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; 1171 1226 } 1172 1227 … … 1187 1242 1188 1243 1189 inlinestatic LRESULT1244 static LRESULT 1190 1245 TOOLTIPS_GetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam) 1191 1246 { … … 1204 1259 1205 1260 if (lpToolInfo == NULL) 1206 1261 return 0; 1207 1262 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1208 1263 return 0; 1209 1264 1210 1265 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 1211 1266 if (nTool == -1) return 0; 1212 1267 1213 /* NB this API is broken, there is no way for the app to determine 1214 what size buffer it requires nor a way to specify how long the 1215 one it supplies is. We'll assume it's upto INFOTIPSIZE */ 1216 1217 WideCharToMultiByte(CP_ACP, 0, infoPtr->tools[nTool].lpszText, -1, 1218 lpToolInfo->lpszText, INFOTIPSIZE, NULL, NULL); 1268 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); 1269 1270 lstrcpyWtoA(lpToolInfo->lpszText,infoPtr->szTipText); 1219 1271 1220 1272 return 0; … … 1230 1282 1231 1283 if (lpToolInfo == NULL) 1232 1284 return 0; 1233 1285 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1234 1286 return 0; 1235 1287 1236 1288 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); 1237 1289 if (nTool == -1) return 0; 1238 1290 1239 lstrcpyW (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText); 1240 1241 return 0; 1242 } 1243 1244 1245 inline static LRESULT 1291 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); 1292 1293 lstrcpyW(lpToolInfo->lpszText,infoPtr->szTipText); 1294 1295 return 0; 1296 } 1297 1298 1299 static LRESULT 1246 1300 TOOLTIPS_GetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 1247 1301 { … … 1251 1305 1252 1306 1253 inlinestatic LRESULT1307 static LRESULT 1254 1308 TOOLTIPS_GetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 1255 1309 { … … 1259 1313 1260 1314 1261 inlinestatic LRESULT1315 static LRESULT 1262 1316 TOOLTIPS_GetToolCount (HWND hwnd, WPARAM wParam, LPARAM lParam) 1263 1317 { … … 1276 1330 1277 1331 if (lpToolInfo == NULL) 1278 1332 return FALSE; 1279 1333 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1280 1334 return FALSE; 1281 1335 if (infoPtr->uNumTools == 0) 1282 1336 return FALSE; 1283 1337 1284 1338 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 1285 1339 if (nTool == -1) 1286 1287 1288 TRACE("tool %d\n", nTool);1340 return FALSE; 1341 1342 // TRACE (tooltips, "tool %d\n", nTool); 1289 1343 1290 1344 toolPtr = &infoPtr->tools[nTool]; … … 1298 1352 1299 1353 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 1300 1354 lpToolInfo->lParam = toolPtr->lParam; 1301 1355 1302 1356 return TRUE; … … 1313 1367 1314 1368 if (lpToolInfo == NULL) 1315 1369 return FALSE; 1316 1370 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1317 1371 return FALSE; 1318 1372 if (infoPtr->uNumTools == 0) 1319 1373 return FALSE; 1320 1374 1321 1375 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); 1322 1376 if (nTool == -1) 1323 1324 1325 TRACE("tool %d\n", nTool);1377 return FALSE; 1378 1379 // TRACE (tooltips, "tool %d\n", nTool); 1326 1380 1327 1381 toolPtr = &infoPtr->tools[nTool]; … … 1335 1389 1336 1390 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 1337 1391 lpToolInfo->lParam = toolPtr->lParam; 1338 1392 1339 1393 return TRUE; … … 1350 1404 1351 1405 if (lptthit == 0) 1352 1406 return FALSE; 1353 1407 1354 1408 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt); 1355 1409 if (nTool == -1) 1356 1357 1358 TRACE("tool %d!\n", nTool);1410 return FALSE; 1411 1412 // TRACE (tooltips, "tool %d!\n", nTool); 1359 1413 1360 1414 /* copy tool data */ 1361 1415 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) { 1362 1363 1364 1365 1366 1367 1368 1369 /* 1370 1371 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; 1372 1426 } 1373 1427 … … 1385 1439 1386 1440 if (lptthit == 0) 1387 1441 return FALSE; 1388 1442 1389 1443 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt); 1390 1444 if (nTool == -1) 1391 1392 1393 TRACE("tool %d!\n", nTool);1445 return FALSE; 1446 1447 // TRACE (tooltips, "tool %d!\n", nTool); 1394 1448 1395 1449 /* copy tool data */ 1396 1450 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) { 1397 1398 1399 1400 1401 1402 1403 1404 /* 1405 1406 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; 1407 1461 } 1408 1462 … … 1419 1473 1420 1474 if (lpti == NULL) 1421 1475 return 0; 1422 1476 if (lpti->cbSize < TTTOOLINFO_V1_SIZEA) 1423 1477 return FALSE; 1424 1478 1425 1479 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti); … … 1440 1494 1441 1495 if (lpti == NULL) 1442 1496 return 0; 1443 1497 if (lpti->cbSize < TTTOOLINFO_V1_SIZEW) 1444 1498 return FALSE; 1445 1499 1446 1500 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti); … … 1453 1507 1454 1508 1455 inlinestatic LRESULT1509 static LRESULT 1456 1510 TOOLTIPS_Pop (HWND hwnd, WPARAM wParam, LPARAM lParam) 1457 1511 { 1458 1512 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); 1513 1514 /* 1515 * Need to set nCurrentTool to nOldTool so we hide the tool. 1516 * nTool and nOldTool values change when the mouse leaves the window. 1517 * If using TTM_UPDATETIPTEXT we can end up with an nCurrentTool = -1 if the 1518 * text can't be found, thus the tooltip would never be hidden. 1519 */ 1520 if (infoPtr->nTool != infoPtr->nOldTool) 1521 infoPtr->nCurrentTool = infoPtr->nOldTool; 1522 1459 1523 TOOLTIPS_Hide (hwnd, infoPtr); 1460 1524 … … 1469 1533 LPMSG lpMsg = (LPMSG)lParam; 1470 1534 POINT pt; 1471 INT nOldTool; 1472 1473 if (lParam == 0) { 1474 ERR("lpMsg == NULL!\n"); 1475 return 0; 1476 } 1477 1478 switch (lpMsg->message) { 1479 case WM_LBUTTONDOWN: 1480 case WM_LBUTTONUP: 1481 case WM_MBUTTONDOWN: 1482 case WM_MBUTTONUP: 1483 case WM_RBUTTONDOWN: 1484 case WM_RBUTTONUP: 1485 pt.x = LOWORD(lParam); 1486 pt.y = HIWORD(lParam); 1487 infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt); 1488 TRACE("tool (%x) %d %d\n", 1489 hwnd, infoPtr->nTool, infoPtr->nCurrentTool); 1490 TOOLTIPS_Hide (hwnd, infoPtr); 1491 break; 1492 1493 case WM_MOUSEMOVE: 1494 pt.x = LOWORD(lpMsg->lParam); 1495 pt.y = HIWORD(lpMsg->lParam); 1496 nOldTool = infoPtr->nTool; 1497 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr, lpMsg->hwnd, 1498 &pt); 1499 TRACE("tool (%x) %d %d %d\n", hwnd, nOldTool, 1500 infoPtr->nTool, infoPtr->nCurrentTool); 1501 TRACE("WM_MOUSEMOVE (%04x %ld %ld)\n", hwnd, pt.x, pt.y); 1502 1503 if (infoPtr->nTool != nOldTool) { 1504 if(infoPtr->nTool == -1) { /* Moved out of all tools */ 1505 TOOLTIPS_Hide(hwnd, infoPtr); 1506 KillTimer(hwnd, ID_TIMERLEAVE); 1507 } else if (nOldTool == -1) { /* Moved from outside */ 1508 if(infoPtr->bActive) { 1509 SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0); 1510 TRACE("timer 1 started!\n"); 1511 } 1512 } else { /* Moved from one to another */ 1513 TOOLTIPS_Hide (hwnd, infoPtr); 1514 KillTimer(hwnd, ID_TIMERLEAVE); 1515 if(infoPtr->bActive) { 1516 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0); 1517 TRACE("timer 1 started!\n"); 1518 } 1519 } 1520 } else if(infoPtr->nCurrentTool != -1) { /* restart autopop */ 1521 KillTimer(hwnd, ID_TIMERPOP); 1522 SetTimer(hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); 1523 TRACE("timer 2 restarted\n"); 1524 } 1525 break; 1535 1536 if (lParam == 0) 1537 { 1538 // ERR (tooltips, "lpMsg == NULL!\n"); 1539 return 0; 1540 } 1541 1542 switch (lpMsg->message) 1543 { 1544 case WM_LBUTTONDOWN: 1545 case WM_LBUTTONUP: 1546 case WM_MBUTTONDOWN: 1547 case WM_MBUTTONUP: 1548 case WM_RBUTTONDOWN: 1549 case WM_RBUTTONUP: 1550 pt = lpMsg->pt; 1551 ScreenToClient(lpMsg->hwnd,&pt); 1552 infoPtr->nOldTool = infoPtr->nTool; 1553 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt); 1554 // TRACE (tooltips, "tool (%x) %d %d\n", 1555 // hwnd, infoPtr->nOldTool, infoPtr->nTool); 1556 TOOLTIPS_Hide (hwnd, infoPtr); 1557 break; 1558 1559 case WM_MOUSEMOVE: 1560 pt = lpMsg->pt; 1561 ScreenToClient(lpMsg->hwnd,&pt); 1562 infoPtr->nOldTool = infoPtr->nTool; 1563 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt); 1564 //TRACE (tooltips, "tool (%x) %d %d\n", 1565 // hwnd, infoPtr->nOldTool, infoPtr->nTool); 1566 //TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n", 1567 // hwnd, pt.x, pt.y); 1568 1569 if (infoPtr->bActive && (infoPtr->nTool != infoPtr->nOldTool)) 1570 { 1571 if (infoPtr->nOldTool == -1) 1572 { 1573 SetTimer(hwnd,ID_TIMERSHOW,infoPtr->nInitialTime,0); 1574 //TRACE (tooltips, "timer 1 started!\n"); 1575 } else 1576 { 1577 /* 1578 * Need to set nCurrentTool to nOldTool so we hide the tool. 1579 * nTool and nOldTool values change when the mouse leaves the window. 1580 * If using TTM_UPDATETIPTEXT we can end up with an nCurrentTool = -1 if the 1581 * text can't be found, thus the tooltip would never be hidden. 1582 */ 1583 if (infoPtr->nTool != infoPtr->nOldTool) 1584 infoPtr->nCurrentTool = infoPtr->nOldTool; 1585 1586 TOOLTIPS_Hide(hwnd,infoPtr); 1587 SetTimer (hwnd,ID_TIMERSHOW,infoPtr->nReshowTime,0); 1588 //TRACE (tooltips, "timer 2 started!\n"); 1589 } 1590 } 1591 if (infoPtr->nCurrentTool != -1) 1592 { 1593 SetTimer(hwnd,ID_TIMERLEAVE,100,0); 1594 //TRACE (tooltips, "timer 3 started!\n"); 1595 } 1596 break; 1526 1597 } 1527 1598 … … 1537 1608 1538 1609 switch (wParam) { 1539 case TTDT_AUTOMATIC: 1540 if (nTime <= 0) 1541 nTime = GetDoubleClickTime(); 1542 infoPtr->nReshowTime = nTime / 5; 1543 infoPtr->nAutoPopTime = nTime * 10; 1544 infoPtr->nInitialTime = nTime; 1545 break; 1546 1547 case TTDT_RESHOW: 1548 if(nTime < 0) 1549 nTime = GetDoubleClickTime() / 5; 1550 infoPtr->nReshowTime = nTime; 1551 break; 1552 1553 case TTDT_AUTOPOP: 1554 if(nTime < 0) 1555 nTime = GetDoubleClickTime() * 10; 1556 infoPtr->nAutoPopTime = nTime; 1557 break; 1558 1559 case TTDT_INITIAL: 1560 if(nTime < 0) 1561 nTime = GetDoubleClickTime(); 1562 infoPtr->nInitialTime = nTime; 1563 break; 1564 1565 default: 1566 WARN("Invalid wParam %x\n", wParam); 1567 break; 1610 case TTDT_AUTOMATIC: 1611 if (nTime == 0) { 1612 infoPtr->nAutomaticTime = 500; 1613 infoPtr->nReshowTime = 100; 1614 infoPtr->nAutoPopTime = 5000; 1615 infoPtr->nInitialTime = 500; 1616 } 1617 else { 1618 infoPtr->nAutomaticTime = nTime; 1619 infoPtr->nReshowTime = nTime / 5; 1620 infoPtr->nAutoPopTime = nTime * 10; 1621 infoPtr->nInitialTime = nTime; 1622 } 1623 break; 1624 1625 case TTDT_RESHOW: 1626 infoPtr->nReshowTime = nTime; 1627 break; 1628 1629 case TTDT_AUTOPOP: 1630 infoPtr->nAutoPopTime = nTime; 1631 break; 1632 1633 case TTDT_INITIAL: 1634 infoPtr->nInitialTime = nTime; 1635 break; 1568 1636 } 1569 1637 … … 1587 1655 1588 1656 1589 inlinestatic LRESULT1657 static LRESULT 1590 1658 TOOLTIPS_SetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam) 1591 1659 { … … 1599 1667 1600 1668 1601 inlinestatic LRESULT1669 static LRESULT 1602 1670 TOOLTIPS_SetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 1603 1671 { … … 1610 1678 1611 1679 1612 inlinestatic LRESULT1680 static LRESULT 1613 1681 TOOLTIPS_SetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 1614 1682 { … … 1630 1698 1631 1699 if (lpToolInfo == NULL) 1632 1700 return 0; 1633 1701 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1634 1702 return 0; 1635 1703 1636 1704 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 1637 1705 if (nTool == -1) return 0; 1638 1706 1639 TRACE("tool %d\n", nTool);1707 // TRACE (tooltips, "tool %d\n", nTool); 1640 1708 1641 1709 toolPtr = &infoPtr->tools[nTool]; … … 1649 1717 1650 1718 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) { 1651 TRACE("set string id %x!\n", (INT)lpToolInfo->lpszText);1652 1719 // TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText); 1720 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 1653 1721 } 1654 1722 else if (lpToolInfo->lpszText) { 1655 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) 1656 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1657 else { 1658 if ( (toolPtr->lpszText) && 1659 (HIWORD((INT)toolPtr->lpszText) != 0) ) { 1660 COMCTL32_Free (toolPtr->lpszText); 1661 toolPtr->lpszText = NULL; 1662 } 1663 if (lpToolInfo->lpszText) { 1664 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, 1665 -1, NULL, 0); 1666 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR)); 1667 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1, 1668 toolPtr->lpszText, len); 1669 } 1670 } 1723 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) 1724 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1725 else { 1726 if ( (toolPtr->lpszText) && 1727 (HIWORD((INT)toolPtr->lpszText) != 0) ) { 1728 COMCTL32_Free (toolPtr->lpszText); 1729 toolPtr->lpszText = NULL; 1730 } 1731 if (lpToolInfo->lpszText) { 1732 INT len = lstrlenA (lpToolInfo->lpszText); 1733 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1734 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText); 1735 } 1736 } 1671 1737 } 1672 1738 1673 1739 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 1674 1740 toolPtr->lParam = lpToolInfo->lParam; 1675 1741 1676 1742 return 0; … … 1687 1753 1688 1754 if (lpToolInfo == NULL) 1689 1755 return 0; 1690 1756 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1691 1757 return 0; 1692 1758 1693 1759 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); 1694 1760 if (nTool == -1) return 0; 1695 1761 1696 TRACE("tool %d\n", nTool);1762 // TRACE (tooltips, "tool %d\n", nTool); 1697 1763 1698 1764 toolPtr = &infoPtr->tools[nTool]; … … 1706 1772 1707 1773 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) { 1708 TRACE("set string id %x!\n", (INT)lpToolInfo->lpszText);1709 1774 // TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText); 1775 toolPtr->lpszText = lpToolInfo->lpszText; 1710 1776 } 1711 1777 else if (lpToolInfo->lpszText) { 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1778 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) 1779 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1780 else { 1781 if ( (toolPtr->lpszText) && 1782 (HIWORD((INT)toolPtr->lpszText) != 0) ) { 1783 COMCTL32_Free (toolPtr->lpszText); 1784 toolPtr->lpszText = NULL; 1785 } 1786 if (lpToolInfo->lpszText) { 1787 INT len = lstrlenW (lpToolInfo->lpszText); 1788 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1789 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText); 1790 } 1791 } 1726 1792 } 1727 1793 1728 1794 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 1729 1795 toolPtr->lParam = lpToolInfo->lParam; 1730 1796 1731 1797 return 0; … … 1739 1805 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; 1740 1806 1741 if (lpToolInfo == NULL) 1742 return 0;1743 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1744 return FALSE; 1745 1746 if ((BOOL)wParam) {1747 /* activate */ 1748 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 1749 if (infoPtr->nTrackTool != -1){1750 TRACE("activated!\n");1751 1752 TOOLTIPS_TrackShow (hwnd,infoPtr);1753 1754 } 1755 else{1756 1757 TOOLTIPS_TrackHide (hwnd,infoPtr);1758 1759 1760 1761 1762 TRACE("deactivated!\n");1807 if (lpToolInfo == NULL) return 0; 1808 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE; 1809 1810 if ((BOOL)wParam) 1811 { 1812 /* activate */ 1813 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA(infoPtr,lpToolInfo); 1814 if (infoPtr->nTrackTool != -1) 1815 { 1816 //TRACE (tooltips, "activated!\n"); 1817 infoPtr->bTrackActive = TRUE; 1818 TOOLTIPS_TrackShow(hwnd,infoPtr); 1819 } 1820 } else 1821 { 1822 /* deactivate */ 1823 TOOLTIPS_TrackHide(hwnd,infoPtr); 1824 1825 infoPtr->bTrackActive = FALSE; 1826 infoPtr->nTrackTool = -1; 1827 1828 //TRACE (tooltips, "deactivated!\n"); 1763 1829 } 1764 1830 … … 1775 1841 infoPtr->yTrackPos = (INT)HIWORD(lParam); 1776 1842 1777 if (infoPtr->bTrackActive) {1778 TRACE("[%d %d]\n", 1779 infoPtr->xTrackPos, infoPtr->yTrackPos); 1780 1781 TOOLTIPS_TrackShow (hwnd,infoPtr);1843 if (infoPtr->bTrackActive) 1844 { 1845 // TRACE (tooltips, "[%d %d]\n", 1846 // infoPtr->xTrackPos, infoPtr->yTrackPos); 1847 TOOLTIPS_TrackShow(hwnd,infoPtr); 1782 1848 } 1783 1849 … … 1792 1858 1793 1859 if (infoPtr->nCurrentTool != -1) 1794 UpdateWindow (hwnd); 1795 1796 return 0; 1797 } 1798 1799 1800 static LRESULT 1860 UpdateWindow (hwnd); 1861 1862 return 0; 1863 } 1864 1865 1801 1866 TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1802 1867 { … … 1807 1872 1808 1873 if (lpToolInfo == NULL) 1809 1874 return 0; 1810 1875 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1811 1876 return FALSE; 1812 1877 1813 1878 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 1814 1879 if (nTool == -1) return 0; 1815 1880 1816 TRACE("tool %d\n", nTool);1881 // TRACE("tool %d\n", nTool); 1817 1882 1818 1883 toolPtr = &infoPtr->tools[nTool]; … … 1822 1887 1823 1888 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){ 1824 1889 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 1825 1890 } 1826 1891 else if (lpToolInfo->lpszText) { 1827 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) 1828 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1829 else { 1830 if ( (toolPtr->lpszText) && 1831 (HIWORD((INT)toolPtr->lpszText) != 0) ) { 1832 COMCTL32_Free (toolPtr->lpszText); 1833 toolPtr->lpszText = NULL; 1834 } 1835 if (lpToolInfo->lpszText) { 1836 INT len = MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, 1837 -1, NULL, 0); 1838 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc (len * sizeof(WCHAR)); 1839 MultiByteToWideChar(CP_ACP, 0, lpToolInfo->lpszText, -1, 1840 toolPtr->lpszText, len); 1841 } 1842 } 1892 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) 1893 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1894 else { 1895 if ( (toolPtr->lpszText) && 1896 (HIWORD((INT)toolPtr->lpszText) != 0) ) { 1897 COMCTL32_Free (toolPtr->lpszText); 1898 toolPtr->lpszText = NULL; 1899 } 1900 if (lpToolInfo->lpszText) { 1901 INT len = lstrlenA (lpToolInfo->lpszText); 1902 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1903 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText); 1904 } 1905 } 1843 1906 } 1844 1907 1845 1908 /* force repaint */ 1846 1909 if (infoPtr->bActive) 1847 1910 TOOLTIPS_Show (hwnd, infoPtr); 1848 1911 else if (infoPtr->bTrackActive) 1849 1912 TOOLTIPS_TrackShow (hwnd, infoPtr); 1850 1913 1851 1914 return 0; … … 1862 1925 1863 1926 if (lpToolInfo == NULL) 1864 1927 return 0; 1865 1928 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1866 1929 return FALSE; 1867 1930 1868 1931 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); 1869 1932 if (nTool == -1) 1870 1871 1872 TRACE("tool %d\n", nTool);1933 return 0; 1934 1935 // TRACE("tool %d\n", nTool); 1873 1936 1874 1937 toolPtr = &infoPtr->tools[nTool]; … … 1878 1941 1879 1942 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){ 1880 1943 toolPtr->lpszText = lpToolInfo->lpszText; 1881 1944 } 1882 1945 else if (lpToolInfo->lpszText) { 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1946 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) 1947 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1948 else { 1949 if ( (toolPtr->lpszText) && 1950 (HIWORD((INT)toolPtr->lpszText) != 0) ) { 1951 COMCTL32_Free (toolPtr->lpszText); 1952 toolPtr->lpszText = NULL; 1953 } 1954 if (lpToolInfo->lpszText) { 1955 INT len = lstrlenW (lpToolInfo->lpszText); 1956 toolPtr->lpszText = (WCHAR*)COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1957 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText); 1958 } 1959 } 1897 1960 } 1898 1961 1899 1962 /* force repaint */ 1900 1963 if (infoPtr->bActive) 1901 1964 TOOLTIPS_Show (hwnd, infoPtr); 1902 1965 else if (infoPtr->bTrackActive) 1903 1966 TOOLTIPS_TrackShow (hwnd, infoPtr); 1904 1967 1905 1968 return 0; … … 1923 1986 1924 1987 /* allocate memory for info structure */ 1925 infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc (sizeof(TOOLTIPS_INFO)); 1926 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); 1988 infoPtr = (TOOLTIPS_INFO*)initControl(hwnd,sizeof(TOOLTIPS_INFO)); 1927 1989 1928 1990 /* initialize info structure */ 1991 infoPtr->szTipText[0] = '\0'; 1929 1992 infoPtr->bActive = TRUE; 1930 1993 infoPtr->bTrackActive = FALSE; 1931 infoPtr->clrBk = GetSysColor (COLOR_INFOBK); 1932 infoPtr->clrText = GetSysColor (COLOR_INFOTEXT); 1994 infoPtr->clrBk = GetSysColor(COLOR_INFOBK); 1995 infoPtr->clrText = GetSysColor(COLOR_INFOTEXT); 1996 infoPtr->xTrackPos = 0; 1997 infoPtr->yTrackPos = 0; 1933 1998 1934 1999 nclm.cbSize = sizeof(NONCLIENTMETRICSA); 1935 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm,0);1936 infoPtr->hFont = CreateFontIndirectA 2000 SystemParametersInfoA(SPI_GETNONCLIENTMETRICS,0,&nclm,0); 2001 infoPtr->hFont = CreateFontIndirectA(&nclm.lfStatusFont); 1937 2002 1938 2003 infoPtr->nMaxTipWidth = -1; 1939 2004 infoPtr->nTool = -1; 2005 infoPtr->nOldTool = -1; 1940 2006 infoPtr->nCurrentTool = -1; 1941 2007 infoPtr->nTrackTool = -1; 1942 2008 1943 TOOLTIPS_SetDelayTime(hwnd, TTDT_AUTOMATIC, 0L); 1944 1945 nResult = (INT) SendMessageA (GetParent (hwnd), WM_NOTIFYFORMAT, 1946 (WPARAM)hwnd, (LPARAM)NF_QUERY); 1947 if (nResult == NFR_ANSI) { 1948 infoPtr->bNotifyUnicode = FALSE; 1949 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_ANSI\n"); 1950 } 1951 else if (nResult == NFR_UNICODE) { 1952 infoPtr->bNotifyUnicode = TRUE; 1953 TRACE(" -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n"); 1954 } 1955 else { 1956 ERR (" -- WM_NOTIFYFORMAT returns: error!\n"); 1957 } 1958 1959 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); 2009 infoPtr->nAutomaticTime = 500; 2010 infoPtr->nReshowTime = 100; 2011 infoPtr->nAutoPopTime = 5000; 2012 infoPtr->nInitialTime = 500; 2013 2014 SetRectEmpty(&infoPtr->rcMargin); 2015 2016 SetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); 1960 2017 1961 2018 return 0; … … 1966 2023 TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) 1967 2024 { 1968 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr 2025 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd); 1969 2026 TTTOOL_INFO *toolPtr; 1970 2027 INT i; … … 1972 2029 /* free tools */ 1973 2030 if (infoPtr->tools) { 1974 1975 1976 1977 1978 (HIWORD((INT)toolPtr->lpszText) != 0) ) 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2031 for (i = 0; i < infoPtr->uNumTools; i++) { 2032 toolPtr = &infoPtr->tools[i]; 2033 if ((toolPtr->hinst) && (toolPtr->lpszText)) { 2034 if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) && 2035 (HIWORD((INT)toolPtr->lpszText) != 0) ) 2036 { 2037 COMCTL32_Free (toolPtr->lpszText); 2038 toolPtr->lpszText = NULL; 2039 } 2040 } 2041 2042 /* remove subclassing */ 2043 if (toolPtr->uFlags & TTF_SUBCLASS) { 2044 LPTT_SUBCLASS_INFO lpttsi; 2045 2046 if (toolPtr->uFlags & TTF_IDISHWND) 2047 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 2048 else 2049 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 2050 2051 if (lpttsi) { 2052 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 2053 (LONG)lpttsi->wpOrigProc); 2054 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 2055 COMCTL32_Free (&lpttsi); 2056 } 2057 } 2058 } 2059 COMCTL32_Free (infoPtr->tools); 2003 2060 } 2004 2061 … … 2007 2064 2008 2065 /* free tool tips info data */ 2009 COMCTL32_Free (infoPtr);2010 SetWindowLongA(hwnd, 0, 0); 2066 doneControl(hwnd); 2067 2011 2068 return 0; 2012 2069 } … … 2041 2098 TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 2042 2099 { 2043 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); 2044 2100 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); 2101 2102 if (infoPtr->nTrackTool > -1) 2103 { 2104 //CB: tocheck: tracking tool without TTF_TRANSPARENT style 2105 } else 2106 { 2045 2107 TOOLTIPS_Hide (hwnd, infoPtr); 2046 2047 return 0; 2108 } 2109 2110 return 0; 2048 2111 } 2049 2112 … … 2052 2115 TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) 2053 2116 { 2054 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 2117 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 2118 DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE); 2055 2119 2056 2120 dwStyle &= 0x0000FFFF; 2057 2121 dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS); 2058 SetWindowLongA (hwnd, GWL_STYLE, dwStyle); 2122 SetWindowLongA(hwnd,GWL_STYLE,dwStyle); 2123 2124 SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle | WS_EX_TOOLWINDOW); 2059 2125 2060 2126 return TRUE; … … 2068 2134 INT nTool = (infoPtr->bTrackActive) ? infoPtr->nTrackTool : infoPtr->nTool; 2069 2135 2070 TRACE(" nTool=%d\n", nTool);2136 // TRACE (tooltips, " nTool=%d\n", nTool); 2071 2137 2072 2138 if ((nTool > -1) && (nTool < infoPtr->uNumTools)) { 2073 2074 TRACE("-- in transparent mode!\n");2075 2076 2139 if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) { 2140 // TRACE (tooltips, "-- in transparent mode!\n"); 2141 return HTTRANSPARENT; 2142 } 2077 2143 } 2078 2144 2079 2145 return DefWindowProcA (hwnd, WM_NCHITTEST, wParam, lParam); 2080 2146 } 2081 2082 2083 static LRESULT2084 TOOLTIPS_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)2085 {2086 FIXME ("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);2087 2088 return 0;2089 }2090 2091 2147 2092 2148 static LRESULT … … 2097 2153 2098 2154 hdc = (wParam == 0) ? BeginPaint (hwnd, &ps) : (HDC)wParam; 2099 TOOLTIPS_ Refresh(hwnd, hdc);2155 TOOLTIPS_Draw(hwnd, hdc); 2100 2156 if (!wParam) 2101 2157 EndPaint (hwnd, &ps); 2102 2158 return 0; 2103 2159 } … … 2111 2167 infoPtr->hFont = (HFONT)wParam; 2112 2168 2113 if ((LOWORD(lParam)) && (infoPtr->nCurrentTool != -1)) { 2114 FIXME("full redraw needed!\n"); 2169 if ((LOWORD(lParam)) && (infoPtr->nCurrentTool != -1)) 2170 { 2171 /* force repaint */ 2172 if (infoPtr->bActive) TOOLTIPS_Show(hwnd,infoPtr); 2173 else if (infoPtr->bTrackActive) TOOLTIPS_TrackShow(hwnd,infoPtr); 2115 2174 } 2116 2175 … … 2127 2186 * returns the length, in characters, of the tip text 2128 2187 ******************************************************************/ 2188 2129 2189 static LRESULT 2130 2190 TOOLTIPS_OnWMGetTextLength(HWND hwnd, WPARAM wParam, LPARAM lParam) … … 2133 2193 return lstrlenW(infoPtr->szTipText); 2134 2194 } 2135 2136 2195 /****************************************************************** 2137 2196 * TOOLTIPS_OnWMGetText … … 2149 2208 { 2150 2209 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); 2210 INT length; 2151 2211 2152 2212 if(!infoPtr || !(infoPtr->szTipText)) 2153 2213 return 0; 2154 2214 2155 return WideCharToMultiByte(CP_ACP, 0, infoPtr->szTipText, -1, 2156 (LPSTR)lParam, wParam, NULL, NULL); 2215 length = lstrlenW(infoPtr->szTipText); 2216 /* When wParam is smaller than the lenght of the tip text 2217 copy wParam characters of the tip text and return wParam */ 2218 if(wParam < length) 2219 { 2220 lstrcpynWtoA((LPSTR)lParam,infoPtr->szTipText,(UINT)wParam);//includes 0 terminator 2221 return wParam; 2222 } 2223 lstrcpyWtoA((LPSTR)lParam,infoPtr->szTipText); 2224 return length; 2225 2157 2226 } 2158 2227 … … 2161 2230 { 2162 2231 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); 2163 INT nOldTool; 2164 2165 TRACE("timer %d (%x) expired!\n", wParam, hwnd); 2166 2167 switch (wParam) { 2168 case ID_TIMERSHOW: 2169 KillTimer (hwnd, ID_TIMERSHOW); 2170 nOldTool = infoPtr->nTool; 2171 if ((infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, TRUE)) == nOldTool) 2172 TOOLTIPS_Show (hwnd, infoPtr); 2173 break; 2174 2175 case ID_TIMERPOP: 2176 TOOLTIPS_Hide (hwnd, infoPtr); 2177 break; 2178 2179 case ID_TIMERLEAVE: 2180 nOldTool = infoPtr->nTool; 2181 infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, FALSE); 2182 TRACE("tool (%x) %d %d %d\n", hwnd, nOldTool, 2183 infoPtr->nTool, infoPtr->nCurrentTool); 2184 if (infoPtr->nTool != nOldTool) { 2185 if(infoPtr->nTool == -1) { /* Moved out of all tools */ 2186 TOOLTIPS_Hide(hwnd, infoPtr); 2187 KillTimer(hwnd, ID_TIMERLEAVE); 2188 } else if (nOldTool == -1) { /* Moved from outside */ 2189 ERR("How did this happen?\n"); 2190 } else { /* Moved from one to another */ 2191 TOOLTIPS_Hide (hwnd, infoPtr); 2192 KillTimer(hwnd, ID_TIMERLEAVE); 2193 if(infoPtr->bActive) { 2194 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0); 2195 TRACE("timer 1 started!\n"); 2196 } 2197 } 2198 } 2199 break; 2200 2201 default: 2202 ERR("Unknown timer id %d\n", wParam); 2203 break; 2204 } 2232 2233 // TRACE (tooltips, "timer %d (%x) expired!\n", wParam, hwnd); 2234 switch (wParam) 2235 { 2236 case ID_TIMERSHOW: 2237 KillTimer(hwnd,ID_TIMERSHOW); 2238 if (TOOLTIPS_CheckTool(hwnd,TRUE) == infoPtr->nTool) 2239 TOOLTIPS_Show(hwnd,infoPtr); 2240 break; 2241 2242 case ID_TIMERPOP: 2243 TOOLTIPS_Hide (hwnd, infoPtr); 2244 break; 2245 2246 case ID_TIMERLEAVE: 2247 KillTimer (hwnd,ID_TIMERLEAVE); 2248 if (TOOLTIPS_CheckTool(hwnd,FALSE) == -1) 2249 { 2250 infoPtr->nTool = -1; 2251 infoPtr->nOldTool = -1; 2252 TOOLTIPS_Hide(hwnd,infoPtr); 2253 } 2254 break; 2255 } 2256 2205 2257 return 0; 2206 2258 } … … 2224 2276 } 2225 2277 2278 LRESULT TOOLTIPS_MouseActivate(HWND hwnd,WPARAM wParam,LPARAM lParam) 2279 { 2280 return MA_NOACTIVATE; 2281 } 2226 2282 2227 2283 LRESULT CALLBACK … … 2229 2285 { 2230 2286 LPTT_SUBCLASS_INFO lpttsi = 2231 (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass); 2232 MSG msg; 2233 2234 switch(uMsg) { 2235 case WM_MOUSEMOVE: 2236 case WM_LBUTTONDOWN: 2237 case WM_LBUTTONUP: 2238 case WM_MBUTTONDOWN: 2239 case WM_MBUTTONUP: 2240 case WM_RBUTTONDOWN: 2241 case WM_RBUTTONUP: 2242 msg.hwnd = hwnd; 2243 msg.message = uMsg; 2244 msg.wParam = wParam; 2245 msg.lParam = lParam; 2246 TOOLTIPS_RelayEvent(lpttsi->hwndToolTip, 0, (LPARAM)&msg); 2247 break; 2248 2249 default: 2250 break; 2251 } 2287 (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass); 2288 TOOLTIPS_INFO *infoPtr; 2289 UINT nTool; 2290 2291 switch (uMsg) { 2292 case WM_LBUTTONDOWN: 2293 case WM_LBUTTONUP: 2294 case WM_MBUTTONDOWN: 2295 case WM_MBUTTONUP: 2296 case WM_RBUTTONDOWN: 2297 case WM_RBUTTONUP: 2298 infoPtr = TOOLTIPS_GetInfoPtr(lpttsi->hwndToolTip); 2299 if (!infoPtr) break; 2300 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd); 2301 2302 infoPtr->nOldTool = infoPtr->nTool; 2303 infoPtr->nTool = nTool; 2304 TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr); 2305 break; 2306 2307 case WM_MOUSEMOVE: 2308 infoPtr = TOOLTIPS_GetInfoPtr (lpttsi->hwndToolTip); 2309 if (!infoPtr) break; 2310 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd); 2311 2312 infoPtr->nOldTool = infoPtr->nTool; 2313 infoPtr->nTool = nTool; 2314 2315 if ((infoPtr->bActive) && 2316 (infoPtr->nTool != infoPtr->nOldTool)) { 2317 if (infoPtr->nOldTool == -1) { 2318 SetTimer (hwnd, ID_TIMERSHOW, 2319 infoPtr->nInitialTime, 0); 2320 //TRACE (tooltips, "timer 1 started!\n"); 2321 } 2322 else { 2323 TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr); 2324 SetTimer (hwnd, ID_TIMERSHOW, 2325 infoPtr->nReshowTime, 0); 2326 // TRACE (tooltips, "timer 2 started!\n"); 2327 } 2328 } 2329 if (infoPtr->nCurrentTool != -1) { 2330 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0); 2331 // TRACE (tooltips, "timer 3 started!\n"); 2332 } 2333 break; 2334 } 2335 2252 2336 return CallWindowProcA (lpttsi->wpOrigProc, hwnd, uMsg, wParam, lParam); 2253 2337 } … … 2257 2341 TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 2258 2342 { 2259 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);2260 if (!TOOLTIPS_GetInfoPtr(hwnd) && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE))2261 return DefWindowProcA (hwnd, uMsg, wParam, lParam);2262 2343 switch (uMsg) 2263 2344 { 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2345 case TTM_ACTIVATE: 2346 return TOOLTIPS_Activate (hwnd, wParam, lParam); 2347 2348 case TTM_ADDTOOLA: 2349 return TOOLTIPS_AddToolA (hwnd, wParam, lParam); 2350 2351 case TTM_ADDTOOLW: 2352 return TOOLTIPS_AddToolW (hwnd, wParam, lParam); 2353 2354 case TTM_DELTOOLA: 2355 return TOOLTIPS_DelToolA (hwnd, wParam, lParam); 2356 2357 case TTM_DELTOOLW: 2358 return TOOLTIPS_DelToolW (hwnd, wParam, lParam); 2359 2360 case TTM_ENUMTOOLSA: 2361 return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam); 2362 2363 case TTM_ENUMTOOLSW: 2364 return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam); 2365 2366 case TTM_GETCURRENTTOOLA: 2367 return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam); 2368 2369 case TTM_GETCURRENTTOOLW: 2370 return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam); 2371 2372 case TTM_GETDELAYTIME: 2373 return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam); 2374 2375 case TTM_GETMARGIN: 2376 return TOOLTIPS_GetMargin (hwnd, wParam, lParam); 2377 2378 case TTM_GETMAXTIPWIDTH: 2379 return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam); 2380 2381 case TTM_GETTEXTA: 2382 return TOOLTIPS_GetTextA (hwnd, wParam, lParam); 2383 2384 case TTM_GETTEXTW: 2385 return TOOLTIPS_GetTextW (hwnd, wParam, lParam); 2386 2387 case TTM_GETTIPBKCOLOR: 2388 return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam); 2389 2390 case TTM_GETTIPTEXTCOLOR: 2391 return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam); 2392 2393 case TTM_GETTOOLCOUNT: 2394 return TOOLTIPS_GetToolCount (hwnd, wParam, lParam); 2395 2396 case TTM_GETTOOLINFOA: 2397 return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam); 2398 2399 case TTM_GETTOOLINFOW: 2400 return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam); 2401 2402 case TTM_HITTESTA: 2403 return TOOLTIPS_HitTestA (hwnd, wParam, lParam); 2404 2405 case TTM_HITTESTW: 2406 return TOOLTIPS_HitTestW (hwnd, wParam, lParam); 2407 2408 case TTM_NEWTOOLRECTA: 2409 return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam); 2410 2411 case TTM_NEWTOOLRECTW: 2412 return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam); 2413 2414 case TTM_POP: 2415 return TOOLTIPS_Pop (hwnd, wParam, lParam); 2416 2417 case TTM_RELAYEVENT: 2418 return TOOLTIPS_RelayEvent (hwnd, wParam, lParam); 2419 2420 case TTM_SETDELAYTIME: 2421 return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam); 2422 2423 case TTM_SETMARGIN: 2424 return TOOLTIPS_SetMargin (hwnd, wParam, lParam); 2425 2426 case TTM_SETMAXTIPWIDTH: 2427 return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam); 2428 2429 case TTM_SETTIPBKCOLOR: 2430 return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam); 2431 2432 case TTM_SETTIPTEXTCOLOR: 2433 return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam); 2434 2435 case TTM_SETTOOLINFOA: 2436 return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam); 2437 2438 case TTM_SETTOOLINFOW: 2439 return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam); 2440 2441 case TTM_TRACKACTIVATE: 2442 return TOOLTIPS_TrackActivate (hwnd, wParam, lParam); 2443 2444 case TTM_TRACKPOSITION: 2445 return TOOLTIPS_TrackPosition (hwnd, wParam, lParam); 2446 2447 case TTM_UPDATE: 2448 return TOOLTIPS_Update (hwnd, wParam, lParam); 2449 2450 case TTM_UPDATETIPTEXTA: 2451 return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam); 2452 2453 case TTM_UPDATETIPTEXTW: 2454 return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam); 2455 2456 case TTM_WINDOWFROMPOINT: 2457 return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam); 2458 2459 2460 case WM_CREATE: 2461 return TOOLTIPS_Create (hwnd, wParam, lParam); 2462 2463 case WM_DESTROY: 2464 return TOOLTIPS_Destroy (hwnd, wParam, lParam); 2465 2466 case WM_ERASEBKGND: 2467 return TOOLTIPS_EraseBackground (hwnd, wParam, lParam); 2468 2469 case WM_GETFONT: 2470 return TOOLTIPS_GetFont (hwnd, wParam, lParam); 2390 2471 2391 2472 case WM_GETTEXT: 2392 2473 return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam); 2393 2474 2394 2475 case WM_GETTEXTLENGTH: 2395 2476 return TOOLTIPS_OnWMGetTextLength (hwnd, wParam, lParam); 2396 2397 2398 case WM_LBUTTONDOWN: 2399 case WM_LBUTTONUP: 2400 case WM_MBUTTONDOWN: 2401 case WM_MBUTTONUP: 2402 case WM_RBUTTONDOWN: 2403 case WM_RBUTTONUP: 2404 case WM_MOUSEMOVE: 2405 return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam); 2406 2407 case WM_NCCREATE: 2408 return TOOLTIPS_NCCreate (hwnd, wParam, lParam); 2409 2410 case WM_NCHITTEST: 2411 return TOOLTIPS_NCHitTest (hwnd, wParam, lParam); 2412 2413 case WM_NOTIFYFORMAT: 2414 return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); 2415 2416 case WM_PAINT: 2417 return TOOLTIPS_Paint (hwnd, wParam, lParam); 2418 2419 case WM_SETFONT: 2420 return TOOLTIPS_SetFont (hwnd, wParam, lParam); 2421 2422 case WM_TIMER: 2423 return TOOLTIPS_Timer (hwnd, wParam, lParam); 2424 2425 case WM_WININICHANGE: 2426 return TOOLTIPS_WinIniChange (hwnd, wParam, lParam); 2427 2428 default: 2429 if (uMsg >= WM_USER) 2430 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 2431 uMsg, wParam, lParam); 2432 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 2477 2478 2479 case WM_LBUTTONDOWN: 2480 case WM_LBUTTONUP: 2481 case WM_LBUTTONDBLCLK: 2482 case WM_MBUTTONDOWN: 2483 case WM_MBUTTONUP: 2484 case WM_MBUTTONDBLCLK: 2485 case WM_RBUTTONDOWN: 2486 case WM_RBUTTONUP: 2487 case WM_RBUTTONDBLCLK: 2488 case WM_MOUSEMOVE: 2489 return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam); 2490 2491 case WM_MOUSEACTIVATE: 2492 return TOOLTIPS_MouseActivate(hwnd,wParam,lParam); 2493 2494 case WM_NCCREATE: 2495 return TOOLTIPS_NCCreate (hwnd, wParam, lParam); 2496 2497 case WM_NCHITTEST: 2498 return TOOLTIPS_NCHitTest (hwnd, wParam, lParam); 2499 2500 case WM_PAINT: 2501 return TOOLTIPS_Paint (hwnd, wParam, lParam); 2502 2503 case WM_SETFONT: 2504 return TOOLTIPS_SetFont (hwnd, wParam, lParam); 2505 2506 case WM_TIMER: 2507 return TOOLTIPS_Timer (hwnd, wParam, lParam); 2508 2509 case WM_WININICHANGE: 2510 return TOOLTIPS_WinIniChange (hwnd, wParam, lParam); 2511 2512 default: 2513 // if (uMsg >= WM_USER) 2514 // ERR (tooltips, "unknown msg %04x wp=%08x lp=%08lx\n", 2515 // uMsg, wParam, lParam); 2516 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); 2433 2517 } 2434 2518 return 0; … … 2437 2521 2438 2522 VOID 2439 TOOLTIPS_Register ( void)2523 TOOLTIPS_Register (VOID) 2440 2524 { 2441 2525 WNDCLASSA wndClass; … … 2449 2533 wndClass.hbrBackground = 0; 2450 2534 wndClass.lpszClassName = TOOLTIPS_CLASSA; 2451 2535 2452 2536 RegisterClassA (&wndClass); 2453 2537 } … … 2455 2539 2456 2540 VOID 2457 TOOLTIPS_Unregister ( void)2541 TOOLTIPS_Unregister (VOID) 2458 2542 { 2459 2543 UnregisterClassA (TOOLTIPS_CLASSA, (HINSTANCE)NULL);
Note:
See TracChangeset
for help on using the changeset viewer.