Changeset 6644 for trunk/src/comctl32/toolbar.c
- Timestamp:
- Sep 5, 2001, 2:05:03 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/toolbar.c
r6380 r6644 1 /* $Id: toolbar.c,v 1.29 2001-09-05 12:05:03 bird Exp $ */ 1 2 /* 2 3 * Toolbar control … … 62 63 INT nRow; 63 64 RECT rect; 64 } TBUTTON_INFO; 65 } TBUTTON_INFO; 65 66 66 67 #ifdef __WIN32OS2__ … … 131 132 #define TOP_BORDER 2 132 133 #define BOTTOM_BORDER 2 133 #define DDARROW_WIDTH 11 134 #define DDARROW_WIDTH 11 134 135 135 136 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0)) … … 147 148 else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) 148 149 lpText = infoPtr->strings[btnPtr->iString]; 149 150 150 151 return lpText; 151 152 } 152 153 153 static BOOL 154 static BOOL 154 155 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index) 155 156 { … … 195 196 * Draw the text string for this button. 196 197 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef 197 * 198 * is non-zero, so we can simply check himlDef to see if we have 198 199 * an image list 199 200 */ 200 201 static void 201 202 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 202 203 HDC hdc, INT nState, DWORD dwStyle) 203 204 { 204 205 RECT rcText = btnPtr->rect; … … 219 220 if (lpText) { 220 221 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 222 InflateRect (&rcText, -3, -3); 223 224 if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 225 if ((dwStyle & TBSTYLE_LIST) && 226 ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) && 227 (btnPtr->iBitmap != I_IMAGENONE)) { 228 rcText.left += infoPtr->nBitmapWidth; 229 } 230 else { 231 rcText.top += infoPtr->nBitmapHeight; 232 } 233 } 234 235 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED)) 236 OffsetRect (&rcText, 1, 1); 237 238 hOldFont = SelectObject (hdc, infoPtr->hFont); 239 nOldBkMode = SetBkMode (hdc, TRANSPARENT); 240 if (!(nState & TBSTATE_ENABLED)) { 241 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT)); 242 OffsetRect (&rcText, 1, 1); 243 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 244 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 245 OffsetRect (&rcText, -1, -1); 246 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 247 } 248 else if (nState & TBSTATE_INDETERMINATE) { 249 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 250 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 251 } 252 else { 253 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); 254 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 255 } 256 257 SetTextColor (hdc, clrOld); 258 SelectObject (hdc, hOldFont); 259 if (nOldBkMode != TRANSPARENT) 260 SetBkMode (hdc, nOldBkMode); 260 261 } 261 262 } … … 275 276 static void 276 277 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 277 278 HDC hdc, INT x, INT y) 278 279 { 279 280 /* FIXME: this function is a hack since it uses image list 280 281 internals directly */ 281 282 282 283 HIMAGELIST himl = infoPtr->himlDef; … … 286 287 287 288 if (!himl) 288 289 return; 289 290 290 291 /* create new dc's */ … … 301 302 SetTextColor (hdcImageList, RGB(0, 0, 0)); 302 303 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 303 304 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY); 304 305 305 306 /* draw the new mask */ 306 307 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT)); 307 308 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy, 308 309 hdcMask, 0, 0, 0xB8074A); 309 310 310 311 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW)); 311 312 BitBlt (hdc, x, y, himl->cx, himl->cy, 312 313 hdcMask, 0, 0, 0xB8074A); 313 314 314 315 DeleteObject (hbmMask); … … 324 325 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 325 326 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && 326 327 (btnPtr->fsStyle & TBSTYLE_DROPDOWN); 327 328 RECT rc, rcArrow, rcBitmap; 328 329 329 330 if (btnPtr->fsState & TBSTATE_HIDDEN) 330 331 return; 331 332 332 333 rc = btnPtr->rect; … … 338 339 if (hasDropDownArrow) 339 340 { 340 341 if (dwStyle & TBSTYLE_FLAT) 341 342 rc.right = max(rc.left, rc.right - DDARROW_WIDTH); 342 343 else 343 344 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2); 344 rcArrow.left = rc.right; 345 rcArrow.left = rc.right; 345 346 } 346 347 … … 363 364 /* when drawing the vertical bar... */ 364 365 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) 365 366 366 TOOLBAR_DrawFlatSeparator (&rc, hdc); 367 return; 367 368 } 368 369 369 370 /* disabled */ 370 371 if (!(btnPtr->fsState & TBSTATE_ENABLED)) { 371 372 373 374 372 if (!(dwStyle & TBSTYLE_FLAT)) 373 { 374 DrawEdge (hdc, &rc, EDGE_RAISED, 375 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 375 376 if (hasDropDownArrow) 376 377 DrawEdge (hdc, &rcArrow, EDGE_RAISED, 377 378 379 378 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 379 } 380 380 381 if (hasDropDownArrow) 381 382 383 384 385 386 if (infoPtr->himlDis && 382 { 383 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT); 384 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW); 385 } 386 387 if (infoPtr->himlDis && 387 388 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 388 389 390 391 392 393 394 389 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 390 rcBitmap.left, rcBitmap.top, ILD_NORMAL); 391 else 392 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top); 393 394 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 395 return; 395 396 } 396 397 397 398 /* pressed TBSTYLE_BUTTON */ 398 399 if (btnPtr->fsState & TBSTATE_PRESSED) { 399 400 401 400 if (dwStyle & TBSTYLE_FLAT) 401 { 402 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST); 402 403 if (hasDropDownArrow) 403 404 405 406 407 404 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST); 405 } 406 else 407 { 408 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 408 409 if (hasDropDownArrow) 409 410 410 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 411 } 411 412 412 413 if (hasDropDownArrow) 413 414 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME); 414 415 415 416 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 416 417 418 419 420 417 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 418 rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL); 419 420 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 421 return; 421 422 } 422 423 423 424 /* checked TBSTYLE_CHECK */ 424 425 if ((btnPtr->fsStyle & TBSTYLE_CHECK) && 425 426 427 428 429 430 431 432 433 434 426 (btnPtr->fsState & TBSTATE_CHECKED)) { 427 if (dwStyle & TBSTYLE_FLAT) 428 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, 429 BF_RECT | BF_MIDDLE | BF_ADJUST); 430 else 431 DrawEdge (hdc, &rc, EDGE_SUNKEN, 432 BF_RECT | BF_MIDDLE | BF_ADJUST); 433 434 TOOLBAR_DrawPattern (hdc, &rc); 435 435 436 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 436 437 438 439 440 } 441 442 /* indeterminate */ 437 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 438 rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL); 439 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 440 return; 441 } 442 443 /* indeterminate */ 443 444 if (btnPtr->fsState & TBSTATE_INDETERMINATE) { 444 445 446 447 448 449 450 445 DrawEdge (hdc, &rc, EDGE_RAISED, 446 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 447 448 TOOLBAR_DrawPattern (hdc, &rc); 449 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top); 450 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 451 return; 451 452 } 452 453 … … 454 455 if (dwStyle & TBSTYLE_FLAT) 455 456 { 456 457 458 457 if (btnPtr->bHot) 458 { 459 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); 459 460 if (hasDropDownArrow) 460 461 461 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); 462 } 462 463 else 463 464 { 464 465 FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); 465 466 if (hasDropDownArrow) 466 467 FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE)); 467 468 } 468 469 469 470 if (hasDropDownArrow) 470 471 472 471 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME); 472 473 if (btnPtr->bHot && infoPtr->himlHot && 473 474 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 474 475 476 477 478 475 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc, 476 rcBitmap.left, rcBitmap.top, ILD_NORMAL); 477 else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 478 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 479 rcBitmap.left, rcBitmap.top, ILD_NORMAL); 479 480 } 480 481 else 481 482 { 482 483 483 DrawEdge (hdc, &rc, EDGE_RAISED, 484 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 484 485 485 486 if (hasDropDownArrow) 486 487 488 489 490 487 { 488 DrawEdge (hdc, &rcArrow, EDGE_RAISED, 489 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 490 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME); 491 } 491 492 492 493 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 493 494 494 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 495 rcBitmap.left, rcBitmap.top, ILD_NORMAL); 495 496 } 496 497 … … 537 538 if (!(btnPtr->fsState & TBSTATE_HIDDEN) && 538 539 (btnPtr->iString > -1) && 539 (btnPtr->iString < infoPtr->nNumStrings)) 540 (btnPtr->iString < infoPtr->nNumStrings)) 540 541 { 541 542 LPWSTR lpText = infoPtr->strings[btnPtr->iString]; … … 577 578 578 579 /*********************************************************************** 579 * 580 * TOOLBAR_WrapToolbar 580 581 * 581 * This function walks through the buttons and seperators in the 582 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 583 * wrapping should occur based on the width of the toolbar window. 584 * It does *not* calculate button placement itself. That task 585 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 586 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 582 * This function walks through the buttons and seperators in the 583 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 584 * wrapping should occur based on the width of the toolbar window. 585 * It does *not* calculate button placement itself. That task 586 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 587 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 587 588 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items. 588 */ 589 */ 589 590 590 591 static void … … 597 598 BOOL bWrap, bButtonWrap; 598 599 599 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */600 /* 601 /* to perform their own layout on the toolbar.*/600 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */ 601 /* no layout is necessary. Applications may use this style */ 602 /* to perform their own layout on the toolbar. */ 602 603 if( !(dwStyle & TBSTYLE_WRAPABLE) ) 603 604 return; 604 605 605 606 btnPtr = infoPtr->buttons; … … 616 617 for (i = 0; i < infoPtr->nNumButtons; i++ ) 617 618 { 618 619 620 621 622 623 624 625 626 627 628 cx = (btnPtr[i].iBitmap > 0) ? 629 630 631 632 633 /* Two or more adjacent separators form a separator group. */ 634 635 /* next row if the previous wrapping is on a button.*/636 637 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 638 639 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 640 641 642 643 644 645 646 647 648 649 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 650 > infoPtr->nWidth ) 651 652 653 654 /* If the current button is a separator and not hidden, */ 655 /*go to the next until it reaches a non separator. */656 /*Wrap the last separator if it is before a button. */657 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 658 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 /* If the current button is not a separator, find the last */ 677 /* separator and wrap it.*/678 679 680 681 682 683 bFound = TRUE; 684 i = j; 685 686 687 bButtonWrap = FALSE; 688 689 690 691 692 /* If no separator available for wrapping, wrap one of*/693 /* non-hidden previous button.*/694 695 696 for ( j = i - 1; 697 698 699 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 700 701 702 bFound = TRUE; 703 i = j; 704 705 706 707 708 709 710 711 712 if (!bFound) 713 714 715 716 717 718 719 720 721 } 722 723 724 619 bWrap = FALSE; 620 btnPtr[i].fsState &= ~TBSTATE_WRAP; 621 622 if (btnPtr[i].fsState & TBSTATE_HIDDEN) 623 continue; 624 625 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 626 /* it is the actual width of the separator. This is used for */ 627 /* custom controls in toolbars. */ 628 if (btnPtr[i].fsStyle & TBSTYLE_SEP) 629 cx = (btnPtr[i].iBitmap > 0) ? 630 btnPtr[i].iBitmap : SEPARATOR_WIDTH; 631 else 632 cx = infoPtr->nButtonWidth; 633 634 /* Two or more adjacent separators form a separator group. */ 635 /* The first separator in a group should be wrapped to the */ 636 /* next row if the previous wrapping is on a button. */ 637 if( bButtonWrap && 638 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 639 (i + 1 < infoPtr->nNumButtons ) && 640 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 641 { 642 btnPtr[i].fsState |= TBSTATE_WRAP; 643 x = infoPtr->nIndent; 644 i++; 645 bButtonWrap = FALSE; 646 continue; 647 } 648 649 /* The layout makes sure the bitmap is visible, but not the button. */ 650 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 651 > infoPtr->nWidth ) 652 { 653 BOOL bFound = FALSE; 654 655 /* If the current button is a separator and not hidden, */ 656 /* go to the next until it reaches a non separator. */ 657 /* Wrap the last separator if it is before a button. */ 658 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 659 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 660 i < infoPtr->nNumButtons ) 661 { 662 i++; 663 bFound = TRUE; 664 } 665 666 if( bFound && i < infoPtr->nNumButtons ) 667 { 668 i--; 669 btnPtr[i].fsState |= TBSTATE_WRAP; 670 x = infoPtr->nIndent; 671 bButtonWrap = FALSE; 672 continue; 673 } 674 else if ( i >= infoPtr->nNumButtons) 675 break; 676 677 /* If the current button is not a separator, find the last */ 678 /* separator and wrap it. */ 679 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 680 { 681 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) && 682 !(btnPtr[j].fsState & TBSTATE_HIDDEN)) 683 { 684 bFound = TRUE; 685 i = j; 686 x = infoPtr->nIndent; 687 btnPtr[j].fsState |= TBSTATE_WRAP; 688 bButtonWrap = FALSE; 689 break; 690 } 691 } 692 693 /* If no separator available for wrapping, wrap one of */ 694 /* non-hidden previous button. */ 695 if (!bFound) 696 { 697 for ( j = i - 1; 698 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 699 { 700 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 701 continue; 702 703 bFound = TRUE; 704 i = j; 705 x = infoPtr->nIndent; 706 btnPtr[j].fsState |= TBSTATE_WRAP; 707 bButtonWrap = TRUE; 708 break; 709 } 710 } 711 712 /* If all above failed, wrap the current button. */ 713 if (!bFound) 714 { 715 btnPtr[i].fsState |= TBSTATE_WRAP; 716 bFound = TRUE; 717 x = infoPtr->nIndent; 718 if (btnPtr[i].fsState & TBSTYLE_SEP ) 719 bButtonWrap = FALSE; 720 else 721 bButtonWrap = TRUE; 722 } 723 } 724 else 725 x += cx; 725 726 } 726 727 } … … 728 729 729 730 /*********************************************************************** 730 * 731 * TOOLBAR_CalcToolbar 731 732 * 732 * This function calculates button and separator placement. It first 733 * calculates the button sizes, gets the toolbar window width and then 734 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 733 * This function calculates button and separator placement. It first 734 * calculates the button sizes, gets the toolbar window width and then 735 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 735 736 * on. It assigns a new location to each item and sends this location to 736 * the tooltip window if appropriate. Finally, it updates the rcBound 737 * rect and calculates the new required toolbar window height. 738 */ 737 * the tooltip window if appropriate. Finally, it updates the rcBound 738 * rect and calculates the new required toolbar window height. 739 */ 739 740 740 741 static void … … 755 756 if (dwStyle & TBSTYLE_LIST) 756 757 { 757 758 758 infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6; 759 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6; 759 760 } 760 761 else { 761 762 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++) 762 763 { 763 764 764 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap)) 765 usesBitmaps = TRUE; 765 766 } 766 767 … … 768 769 { 769 770 if (usesBitmaps) 770 771 infoPtr->nButtonHeight = sizeString.cy + 771 772 infoPtr->nBitmapHeight + 6; 772 else 773 else 773 774 infoPtr->nButtonHeight = sizeString.cy + 6; 774 775 } 775 776 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) 776 777 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; 777 778 778 779 if (sizeString.cx > infoPtr->nBitmapWidth) 779 780 infoPtr->nButtonWidth = sizeString.cx + 6; 780 781 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6) 781 782 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6; 782 783 } 783 784 … … 793 794 794 795 /* 795 * We will set the height below, and we set the width on entry 796 * so we do not reset them here.. 796 * We will set the height below, and we set the width on entry 797 * so we do not reset them here.. 797 798 */ 798 799 #if 0 … … 829 830 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ ) 830 831 { 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE) 832 bWrap = FALSE; 833 if (btnPtr->fsState & TBSTATE_HIDDEN) 834 { 835 SetRectEmpty (&btnPtr->rect); 836 continue; 837 } 838 839 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 840 /* it is the actual width of the separator. This is used for */ 841 /* custom controls in toolbars. */ 842 if (btnPtr->fsStyle & TBSTYLE_SEP) 843 cx = (btnPtr->iBitmap > 0) ? 844 btnPtr->iBitmap : SEPARATOR_WIDTH; 845 else 846 { 847 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE) 847 848 { 848 849 SIZE sz; … … 851 852 } 852 853 else 853 854 855 856 cx += DDARROW_WIDTH; 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 874 875 876 877 878 879 880 881 882 883 884 885 886 /* btnPtr->nRow is zero based. The space between the rows is*/887 /* also considered as a row.*/888 889 890 891 892 893 else 894 { 895 896 897 /* custom controls in toolbars.*/898 y += cy + ( (btnPtr->iBitmap > 0 ) ? 899 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 900 901 /* nSepRows is used to calculate the extra height follwoing */ 902 /* the last row.*/903 904 905 906 907 908 909 854 cx = infoPtr->nButtonWidth; 855 856 if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN)) 857 cx += DDARROW_WIDTH; 858 } 859 cy = infoPtr->nHeight; 860 861 if (btnPtr->fsState & TBSTATE_WRAP ) 862 bWrap = TRUE; 863 864 SetRect (&btnPtr->rect, x, y, x + cx, y + cy); 865 866 if (infoPtr->rcBound.left > x) 867 infoPtr->rcBound.left = x; 868 if (infoPtr->rcBound.right < x + cx) 869 infoPtr->rcBound.right = x + cx; 870 if (infoPtr->rcBound.bottom < y + cy) 871 infoPtr->rcBound.bottom = y + cy; 872 873 /* Set the toolTip only for non-hidden, non-separator button */ 874 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 875 { 876 TTTOOLINFOA ti; 877 878 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 879 ti.cbSize = sizeof(TTTOOLINFOA); 880 ti.hwnd = hwnd; 881 ti.uId = btnPtr->idCommand; 882 ti.rect = btnPtr->rect; 883 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA, 884 0, (LPARAM)&ti); 885 } 886 887 /* btnPtr->nRow is zero based. The space between the rows is */ 888 /* also considered as a row. */ 889 btnPtr->nRow = nRows + nSepRows; 890 if( bWrap ) 891 { 892 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) ) 893 y += cy; 894 else 895 { 896 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 897 /* it is the actual width of the separator. This is used for */ 898 /* custom controls in toolbars. */ 899 y += cy + ( (btnPtr->iBitmap > 0 ) ? 900 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 901 902 /* nSepRows is used to calculate the extra height follwoing */ 903 /* the last row. */ 904 nSepRows++; 905 } 906 x = infoPtr->nIndent; 907 nRows++; 908 } 909 else 910 x += cx; 910 911 } 911 912 … … 913 914 infoPtr->nRows = nRows + nSepRows + 1; 914 915 915 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following 916 /* the last row. 917 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 918 919 nSepRows * (infoPtr->nBitmapHeight + 1) + 920 BOTTOM_BORDER; 916 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */ 917 /* the last row. */ 918 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 919 nSepRows * (SEPARATOR_WIDTH * 2 / 3) + 920 nSepRows * (infoPtr->nBitmapHeight + 1) + 921 BOTTOM_BORDER; 921 922 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth); 922 923 } … … 929 930 TBUTTON_INFO *btnPtr; 930 931 INT i; 931 932 932 933 btnPtr = infoPtr->buttons; 933 934 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 935 if (btnPtr->fsState & TBSTATE_HIDDEN) 936 continue; 937 938 if (btnPtr->fsStyle & TBSTYLE_SEP) { 939 if (PtInRect (&btnPtr->rect, *lpPt)) { 940 TRACE(" ON SEPARATOR %d!\n", i); 941 return -i; 942 } 943 } 944 else { 945 if (PtInRect (&btnPtr->rect, *lpPt)) { 946 TRACE(" ON BUTTON %d!\n", i); 947 return i; 948 } 949 } 949 950 } 950 951 … … 962 963 btnPtr = infoPtr->buttons; 963 964 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 964 965 966 967 965 if (btnPtr->idCommand == idCommand) { 966 TRACE("command=%d index=%d\n", idCommand, i); 967 return i; 968 } 968 969 } 969 970 TRACE("no index found for command=%d\n", idCommand); … … 979 980 980 981 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons)) 981 982 return -1; 982 983 983 984 /* check index button */ 984 985 btnPtr = &infoPtr->buttons[nIndex]; 985 986 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 986 987 987 if (btnPtr->fsState & TBSTATE_CHECKED) 988 return nIndex; 988 989 } 989 990 … … 991 992 nRunIndex = nIndex - 1; 992 993 while (nRunIndex >= 0) { 993 994 995 996 997 998 999 1000 994 btnPtr = &infoPtr->buttons[nRunIndex]; 995 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 996 if (btnPtr->fsState & TBSTATE_CHECKED) 997 return nRunIndex; 998 } 999 else 1000 break; 1001 nRunIndex--; 1001 1002 } 1002 1003 … … 1004 1005 nRunIndex = nIndex + 1; 1005 1006 while (nRunIndex < infoPtr->nNumButtons) { 1006 btnPtr = &infoPtr->buttons[nRunIndex]; 1007 1008 1009 1010 1011 1012 1013 1007 btnPtr = &infoPtr->buttons[nRunIndex]; 1008 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 1009 if (btnPtr->fsState & TBSTATE_CHECKED) 1010 return nRunIndex; 1011 } 1012 else 1013 break; 1014 nRunIndex++; 1014 1015 } 1015 1016 … … 1020 1021 static VOID 1021 1022 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, 1022 1023 WPARAM wParam, LPARAM lParam) 1023 1024 { 1024 1025 MSG msg; … … 1049 1050 switch (uMsg) 1050 1051 { 1051 case WM_INITDIALOG: 1052 custInfo = (PCUSTDLG_INFO)lParam; 1053 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo); 1054 1055 if (custInfo) 1056 { 1057 char Buffer[256]; 1058 int i = 0; 1059 int index; 1060 1061 /* send TBN_QUERYINSERT notification */ 1062 nmtb.hdr.hwndFrom = hwnd; 1063 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1064 nmtb.hdr.code = TBN_QUERYINSERT; 1065 nmtb.iItem = custInfo->tbInfo->nNumButtons; 1066 1067 if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1068 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1069 return FALSE; 1070 1071 /* add items to 'toolbar buttons' list and check if removable */ 1072 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++) 1073 { 1074 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1075 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1076 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1077 btnInfo->bVirtual = FALSE; 1078 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1079 1080 /* send TBN_QUERYDELETE notification */ 1081 nmtb.hdr.hwndFrom = hwnd; 1082 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1083 nmtb.hdr.code = TBN_QUERYDELETE; 1084 nmtb.iItem = i; 1085 1086 btnInfo->bRemovable = SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1087 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 1088 1089 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0); 1090 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1091 } 1092 1093 /* insert separator button into 'available buttons' list */ 1094 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1095 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1096 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1097 btnInfo->bVirtual = FALSE; 1098 btnInfo->bRemovable = TRUE; 1099 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1100 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo); 1101 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1102 1103 /* insert all buttons into dsa */ 1104 for (i = 0;; i++) 1105 { 1106 /* send TBN_GETBUTTONINFO notification */ 1107 nmtb.hdr.hwndFrom = hwnd; 1108 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1109 nmtb.hdr.code = TBN_GETBUTTONINFOA; 1110 nmtb.iItem = i; 1111 nmtb.pszText = Buffer; 1112 nmtb.cchText = 256; 1113 1114 if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1115 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1116 break; 1117 1118 TRACE("style: %x\n", nmtb.tbButton.fsStyle); 1119 1120 /* insert button into the apropriate list */ 1121 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand); 1122 if (index == -1) 1123 { 1124 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1125 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON)); 1126 btnInfo->bVirtual = FALSE; 1127 btnInfo->bRemovable = TRUE; 1128 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP)) 1129 strcpy (btnInfo->text, nmtb.pszText); 1130 1131 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0); 1132 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1133 } 1134 else 1135 { 1136 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1137 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON)); 1138 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP)) 1139 strcpy (btnInfo->text, nmtb.pszText); 1140 1141 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1142 } 1143 } 1144 1145 /* select first item in the 'available' list */ 1146 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0); 1147 1148 /* append 'virtual' separator button to the 'toolbar buttons' list */ 1149 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1150 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1151 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1152 btnInfo->bVirtual = TRUE; 1153 btnInfo->bRemovable = FALSE; 1154 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1155 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo); 1156 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1157 1158 /* select last item in the 'toolbar' list */ 1159 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0); 1160 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0); 1161 1162 /* set focus and disable buttons */ 1163 PostMessageA (hwnd, WM_USER, 0, 0); 1164 } 1165 return TRUE; 1166 1167 case WM_USER: 1168 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1169 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1170 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE); 1171 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX)); 1172 return TRUE; 1173 1174 case WM_CLOSE: 1175 EndDialog(hwnd, FALSE); 1176 return TRUE; 1177 1178 case WM_COMMAND: 1179 switch (LOWORD(wParam)) 1180 { 1181 case IDC_TOOLBARBTN_LBOX: 1182 if (HIWORD(wParam) == LBN_SELCHANGE) 1183 { 1184 PCUSTOMBUTTON btnInfo; 1185 NMTOOLBARA nmtb; 1186 int count; 1187 int index; 1188 1189 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1190 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1191 1192 /* send TBN_QUERYINSERT notification */ 1193 nmtb.hdr.hwndFrom = hwnd; 1194 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1195 nmtb.hdr.code = TBN_QUERYINSERT; 1196 nmtb.iItem = index; 1197 1198 SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1199 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 1200 1201 /* get list box item */ 1202 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1203 1204 if (index == (count - 1)) 1205 { 1206 /* last item (virtual separator) */ 1207 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1208 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1209 } 1210 else if (index == (count - 2)) 1211 { 1212 /* second last item (last non-virtual item) */ 1213 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1214 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1215 } 1216 else if (index == 0) 1217 { 1218 /* first item */ 1219 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1220 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1221 } 1222 else 1223 { 1224 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1225 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1226 } 1227 1228 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable); 1229 } 1230 break; 1231 1232 case IDC_MOVEUP_BTN: 1233 { 1234 PCUSTOMBUTTON btnInfo; 1235 int index; 1236 int count; 1237 1238 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1239 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1240 TRACE("Move up: index %d\n", index); 1241 1242 /* send TBN_QUERYINSERT notification */ 1243 nmtb.hdr.hwndFrom = hwnd; 1244 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1245 nmtb.hdr.code = TBN_QUERYINSERT; 1246 nmtb.iItem = index; 1247 1248 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1249 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1250 { 1251 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1252 1253 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1254 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0); 1255 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo); 1256 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0); 1257 1258 if (index <= 1) 1259 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1260 else if (index >= (count - 3)) 1261 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1262 1263 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1264 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn)); 1265 } 1266 } 1267 break; 1268 1269 case IDC_MOVEDN_BTN: /* move down */ 1270 { 1271 PCUSTOMBUTTON btnInfo; 1272 int index; 1273 int count; 1274 1275 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1276 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1277 TRACE("Move up: index %d\n", index); 1278 1279 /* send TBN_QUERYINSERT notification */ 1280 nmtb.hdr.hwndFrom = hwnd; 1281 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1282 nmtb.hdr.code = TBN_QUERYINSERT; 1283 nmtb.iItem = index; 1284 1285 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1286 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1287 { 1288 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1289 1290 /* move button down */ 1291 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1292 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0); 1293 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo); 1294 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0); 1295 1296 if (index == 0) 1297 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1298 else if (index >= (count - 3)) 1299 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1300 1301 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1302 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn)); 1303 } 1304 } 1305 break; 1306 1307 case IDC_REMOVE_BTN: /* remove button */ 1308 { 1309 PCUSTOMBUTTON btnInfo; 1310 int index; 1311 1312 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1313 TRACE("Remove: index %d\n", index); 1314 1315 /* send TBN_QUERYDELETE notification */ 1316 nmtb.hdr.hwndFrom = hwnd; 1317 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1318 nmtb.hdr.code = TBN_QUERYDELETE; 1319 nmtb.iItem = index; 1320 1321 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1322 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1323 { 1324 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1325 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1326 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0); 1327 1328 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1329 1330 /* insert into 'available button' list */ 1331 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP)) 1332 { 1333 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0); 1334 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1335 } 1336 else 1337 COMCTL32_Free (btnInfo); 1338 } 1339 } 1340 break; 1341 1342 case IDOK: /* Add button */ 1343 { 1344 int index; 1345 int count; 1346 1347 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0); 1348 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0); 1349 TRACE("Add: index %d\n", index); 1350 1351 /* send TBN_QUERYINSERT notification */ 1352 nmtb.hdr.hwndFrom = hwnd; 1353 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1354 nmtb.hdr.code = TBN_QUERYINSERT; 1355 nmtb.iItem = index; 1356 1357 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1358 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1359 { 1360 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0); 1361 1362 if (index != 0) 1363 { 1364 /* remove from 'available buttons' list */ 1365 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0); 1366 if (index == count-1) 1367 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0); 1368 else 1369 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0); 1370 } 1371 else 1372 { 1373 PCUSTOMBUTTON btnNew; 1374 1375 /* duplicate 'separator' button */ 1376 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON)); 1377 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON)); 1378 btnInfo = btnNew; 1379 } 1380 1381 /* insert into 'toolbar button' list */ 1382 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1383 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0); 1384 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1385 1386 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn)); 1387 } 1388 } 1389 break; 1390 1391 case IDCANCEL: 1392 EndDialog(hwnd, FALSE); 1393 break; 1394 } 1395 return TRUE; 1396 1397 case WM_DESTROY: 1398 { 1399 int count; 1400 int i; 1401 1402 /* delete items from 'toolbar buttons' listbox*/ 1403 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1404 for (i = 0; i < count; i++) 1405 { 1406 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0); 1407 COMCTL32_Free(btnInfo); 1408 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0); 1409 } 1410 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0); 1411 1412 1413 /* delete items from 'available buttons' listbox*/ 1414 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0); 1415 for (i = 0; i < count; i++) 1416 { 1417 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0); 1418 COMCTL32_Free(btnInfo); 1419 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0); 1420 } 1421 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0); 1052 case WM_INITDIALOG: 1053 custInfo = (PCUSTDLG_INFO)lParam; 1054 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo); 1055 1056 if (custInfo) 1057 { 1058 char Buffer[256]; 1059 int i = 0; 1060 int index; 1061 1062 /* send TBN_QUERYINSERT notification */ 1063 nmtb.hdr.hwndFrom = hwnd; 1064 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1065 nmtb.hdr.code = TBN_QUERYINSERT; 1066 nmtb.iItem = custInfo->tbInfo->nNumButtons; 1067 1068 if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1069 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1070 return FALSE; 1071 1072 /* add items to 'toolbar buttons' list and check if removable */ 1073 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++) 1074 { 1075 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1076 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1077 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1078 btnInfo->bVirtual = FALSE; 1079 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1080 1081 /* send TBN_QUERYDELETE notification */ 1082 nmtb.hdr.hwndFrom = hwnd; 1083 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1084 nmtb.hdr.code = TBN_QUERYDELETE; 1085 nmtb.iItem = i; 1086 1087 btnInfo->bRemovable = SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1088 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 1089 1090 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0); 1091 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1092 } 1093 1094 /* insert separator button into 'available buttons' list */ 1095 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1096 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1097 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1098 btnInfo->bVirtual = FALSE; 1099 btnInfo->bRemovable = TRUE; 1100 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1101 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo); 1102 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1103 1104 /* insert all buttons into dsa */ 1105 for (i = 0;; i++) 1106 { 1107 /* send TBN_GETBUTTONINFO notification */ 1108 nmtb.hdr.hwndFrom = hwnd; 1109 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1110 nmtb.hdr.code = TBN_GETBUTTONINFOA; 1111 nmtb.iItem = i; 1112 nmtb.pszText = Buffer; 1113 nmtb.cchText = 256; 1114 1115 if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1116 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1117 break; 1118 1119 TRACE("style: %x\n", nmtb.tbButton.fsStyle); 1120 1121 /* insert button into the apropriate list */ 1122 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand); 1123 if (index == -1) 1124 { 1125 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1126 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON)); 1127 btnInfo->bVirtual = FALSE; 1128 btnInfo->bRemovable = TRUE; 1129 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP)) 1130 strcpy (btnInfo->text, nmtb.pszText); 1131 1132 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0); 1133 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1422 1134 } 1423 return TRUE; 1424 1425 case WM_DRAWITEM: 1426 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1427 { 1428 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 1429 RECT rcButton; 1430 RECT rcText; 1431 HPEN hOldPen; 1432 HBRUSH hOldBrush; 1433 COLORREF oldText = 0; 1434 COLORREF oldBk = 0; 1435 1436 /* get item data */ 1437 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0); 1438 if (btnInfo == NULL) 1439 { 1440 FIXME("btnInfo invalid!\n"); 1441 return TRUE; 1442 } 1443 1444 /* set colors and select objects */ 1445 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1446 if (btnInfo->bVirtual) 1447 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT)); 1448 else 1449 oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT)); 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, 1455 lpdis->rcItem.right, lpdis->rcItem.bottom); 1456 1457 /* calculate button and text rectangles */ 1458 CopyRect (&rcButton, &lpdis->rcItem); 1459 InflateRect (&rcButton, -1, -1); 1460 CopyRect (&rcText, &rcButton); 1461 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6; 1462 rcText.left = rcButton.right + 2; 1463 1464 /* draw focus rectangle */ 1465 if (lpdis->itemState & ODS_FOCUS) 1466 DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1467 1468 /* draw button */ 1469 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); 1470 1471 /* draw image and text */ 1472 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0) 1473 ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC, 1474 rcButton.left+3, rcButton.top+3, ILD_NORMAL); 1475 DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText, 1476 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1477 1478 /* delete objects and reset colors */ 1479 SelectObject (lpdis->hDC, hOldBrush); 1480 SelectObject (lpdis->hDC, hOldPen); 1481 SetBkColor (lpdis->hDC, oldBk); 1482 SetTextColor (lpdis->hDC, oldText); 1483 1484 return TRUE; 1485 } 1486 return FALSE; 1487 1488 case WM_MEASUREITEM: 1489 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1490 { 1491 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 1492 1493 if (custInfo && custInfo->tbInfo) 1494 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8; 1495 else 1496 lpmis->itemHeight = 15 + 8; /* default height */ 1497 1498 return TRUE; 1499 } 1500 return FALSE; 1501 1502 default: 1503 return FALSE; 1135 else 1136 { 1137 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1138 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON)); 1139 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP)) 1140 strcpy (btnInfo->text, nmtb.pszText); 1141 1142 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1143 } 1144 } 1145 1146 /* select first item in the 'available' list */ 1147 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0); 1148 1149 /* append 'virtual' separator button to the 'toolbar buttons' list */ 1150 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1151 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1152 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1153 btnInfo->bVirtual = TRUE; 1154 btnInfo->bRemovable = FALSE; 1155 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1156 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo); 1157 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1158 1159 /* select last item in the 'toolbar' list */ 1160 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0); 1161 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0); 1162 1163 /* set focus and disable buttons */ 1164 PostMessageA (hwnd, WM_USER, 0, 0); 1165 } 1166 return TRUE; 1167 1168 case WM_USER: 1169 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1170 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1171 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE); 1172 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX)); 1173 return TRUE; 1174 1175 case WM_CLOSE: 1176 EndDialog(hwnd, FALSE); 1177 return TRUE; 1178 1179 case WM_COMMAND: 1180 switch (LOWORD(wParam)) 1181 { 1182 case IDC_TOOLBARBTN_LBOX: 1183 if (HIWORD(wParam) == LBN_SELCHANGE) 1184 { 1185 PCUSTOMBUTTON btnInfo; 1186 NMTOOLBARA nmtb; 1187 int count; 1188 int index; 1189 1190 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1191 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1192 1193 /* send TBN_QUERYINSERT notification */ 1194 nmtb.hdr.hwndFrom = hwnd; 1195 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1196 nmtb.hdr.code = TBN_QUERYINSERT; 1197 nmtb.iItem = index; 1198 1199 SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1200 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 1201 1202 /* get list box item */ 1203 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1204 1205 if (index == (count - 1)) 1206 { 1207 /* last item (virtual separator) */ 1208 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1209 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1210 } 1211 else if (index == (count - 2)) 1212 { 1213 /* second last item (last non-virtual item) */ 1214 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1215 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1216 } 1217 else if (index == 0) 1218 { 1219 /* first item */ 1220 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1221 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1222 } 1223 else 1224 { 1225 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1226 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1227 } 1228 1229 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable); 1230 } 1231 break; 1232 1233 case IDC_MOVEUP_BTN: 1234 { 1235 PCUSTOMBUTTON btnInfo; 1236 int index; 1237 int count; 1238 1239 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1240 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1241 TRACE("Move up: index %d\n", index); 1242 1243 /* send TBN_QUERYINSERT notification */ 1244 nmtb.hdr.hwndFrom = hwnd; 1245 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1246 nmtb.hdr.code = TBN_QUERYINSERT; 1247 nmtb.iItem = index; 1248 1249 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1250 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1251 { 1252 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1253 1254 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1255 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0); 1256 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo); 1257 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0); 1258 1259 if (index <= 1) 1260 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1261 else if (index >= (count - 3)) 1262 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1263 1264 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1265 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn)); 1266 } 1267 } 1268 break; 1269 1270 case IDC_MOVEDN_BTN: /* move down */ 1271 { 1272 PCUSTOMBUTTON btnInfo; 1273 int index; 1274 int count; 1275 1276 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1277 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1278 TRACE("Move up: index %d\n", index); 1279 1280 /* send TBN_QUERYINSERT notification */ 1281 nmtb.hdr.hwndFrom = hwnd; 1282 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1283 nmtb.hdr.code = TBN_QUERYINSERT; 1284 nmtb.iItem = index; 1285 1286 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1287 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1288 { 1289 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1290 1291 /* move button down */ 1292 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1293 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0); 1294 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo); 1295 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0); 1296 1297 if (index == 0) 1298 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1299 else if (index >= (count - 3)) 1300 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1301 1302 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1303 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn)); 1304 } 1305 } 1306 break; 1307 1308 case IDC_REMOVE_BTN: /* remove button */ 1309 { 1310 PCUSTOMBUTTON btnInfo; 1311 int index; 1312 1313 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1314 TRACE("Remove: index %d\n", index); 1315 1316 /* send TBN_QUERYDELETE notification */ 1317 nmtb.hdr.hwndFrom = hwnd; 1318 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1319 nmtb.hdr.code = TBN_QUERYDELETE; 1320 nmtb.iItem = index; 1321 1322 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1323 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1324 { 1325 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1326 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1327 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0); 1328 1329 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1330 1331 /* insert into 'available button' list */ 1332 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP)) 1333 { 1334 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0); 1335 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1336 } 1337 else 1338 COMCTL32_Free (btnInfo); 1339 } 1340 } 1341 break; 1342 1343 case IDOK: /* Add button */ 1344 { 1345 int index; 1346 int count; 1347 1348 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0); 1349 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0); 1350 TRACE("Add: index %d\n", index); 1351 1352 /* send TBN_QUERYINSERT notification */ 1353 nmtb.hdr.hwndFrom = hwnd; 1354 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1355 nmtb.hdr.code = TBN_QUERYINSERT; 1356 nmtb.iItem = index; 1357 1358 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1359 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1360 { 1361 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0); 1362 1363 if (index != 0) 1364 { 1365 /* remove from 'available buttons' list */ 1366 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0); 1367 if (index == count-1) 1368 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0); 1369 else 1370 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0); 1371 } 1372 else 1373 { 1374 PCUSTOMBUTTON btnNew; 1375 1376 /* duplicate 'separator' button */ 1377 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON)); 1378 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON)); 1379 btnInfo = btnNew; 1380 } 1381 1382 /* insert into 'toolbar button' list */ 1383 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1384 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0); 1385 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1386 1387 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn)); 1388 } 1389 } 1390 break; 1391 1392 case IDCANCEL: 1393 EndDialog(hwnd, FALSE); 1394 break; 1395 } 1396 return TRUE; 1397 1398 case WM_DESTROY: 1399 { 1400 int count; 1401 int i; 1402 1403 /* delete items from 'toolbar buttons' listbox*/ 1404 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1405 for (i = 0; i < count; i++) 1406 { 1407 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0); 1408 COMCTL32_Free(btnInfo); 1409 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0); 1410 } 1411 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0); 1412 1413 1414 /* delete items from 'available buttons' listbox*/ 1415 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0); 1416 for (i = 0; i < count; i++) 1417 { 1418 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0); 1419 COMCTL32_Free(btnInfo); 1420 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0); 1421 } 1422 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0); 1423 } 1424 return TRUE; 1425 1426 case WM_DRAWITEM: 1427 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1428 { 1429 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 1430 RECT rcButton; 1431 RECT rcText; 1432 HPEN hOldPen; 1433 HBRUSH hOldBrush; 1434 COLORREF oldText = 0; 1435 COLORREF oldBk = 0; 1436 1437 /* get item data */ 1438 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0); 1439 if (btnInfo == NULL) 1440 { 1441 FIXME("btnInfo invalid!\n"); 1442 return TRUE; 1443 } 1444 1445 /* set colors and select objects */ 1446 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1447 if (btnInfo->bVirtual) 1448 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT)); 1449 else 1450 oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT)); 1451 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1452 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1453 1454 /* fill background rectangle */ 1455 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, 1456 lpdis->rcItem.right, lpdis->rcItem.bottom); 1457 1458 /* calculate button and text rectangles */ 1459 CopyRect (&rcButton, &lpdis->rcItem); 1460 InflateRect (&rcButton, -1, -1); 1461 CopyRect (&rcText, &rcButton); 1462 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6; 1463 rcText.left = rcButton.right + 2; 1464 1465 /* draw focus rectangle */ 1466 if (lpdis->itemState & ODS_FOCUS) 1467 DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1468 1469 /* draw button */ 1470 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); 1471 1472 /* draw image and text */ 1473 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0) 1474 ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC, 1475 rcButton.left+3, rcButton.top+3, ILD_NORMAL); 1476 DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText, 1477 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1478 1479 /* delete objects and reset colors */ 1480 SelectObject (lpdis->hDC, hOldBrush); 1481 SelectObject (lpdis->hDC, hOldPen); 1482 SetBkColor (lpdis->hDC, oldBk); 1483 SetTextColor (lpdis->hDC, oldText); 1484 1485 return TRUE; 1486 } 1487 return FALSE; 1488 1489 case WM_MEASUREITEM: 1490 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1491 { 1492 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 1493 1494 if (custInfo && custInfo->tbInfo) 1495 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8; 1496 else 1497 lpmis->itemHeight = 15 + 8; /* default height */ 1498 1499 return TRUE; 1500 } 1501 return FALSE; 1502 1503 default: 1504 return FALSE; 1504 1505 } 1505 1506 } … … 1520 1521 TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam); 1521 1522 if (!lpAddBmp) 1522 1523 return -1; 1523 1524 1524 1525 if (lpAddBmp->hInst == HINST_COMMCTRL) 1525 1526 { 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 if (lpAddBmp->nID & 1) 1539 1540 1541 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap 1542 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this 1527 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR) 1528 nButtons = 15; 1529 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR) 1530 nButtons = 13; 1531 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR) 1532 nButtons = 5; 1533 else 1534 return -1; 1535 1536 TRACE ("adding %d internal bitmaps!\n", nButtons); 1537 1538 /* Windows resize all the buttons to the size of a newly added standard image */ 1539 if (lpAddBmp->nID & 1) 1540 { 1541 /* large icons */ 1542 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap 1543 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this 1543 1544 */ 1544 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1545 MAKELPARAM((WORD)24, (WORD)24)); 1546 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1547 MAKELPARAM((WORD)31, (WORD)30)); 1548 } 1549 else 1550 { 1551 /* small icons */ 1552 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1553 MAKELPARAM((WORD)16, (WORD)16)); 1554 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1555 MAKELPARAM((WORD)22, (WORD)22)); 1556 } 1557 1558 TOOLBAR_CalcToolbar (hwnd); 1545 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1546 MAKELPARAM((WORD)24, (WORD)24)); 1547 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1548 MAKELPARAM((WORD)31, (WORD)30)); 1559 1549 } 1560 1550 else 1561 1551 { 1562 nButtons = (INT)wParam; 1563 if (nButtons <= 0) 1564 return -1; 1565 1566 TRACE ("adding %d bitmaps!\n", nButtons); 1567 } 1568 1552 /* small icons */ 1553 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1554 MAKELPARAM((WORD)16, (WORD)16)); 1555 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1556 MAKELPARAM((WORD)22, (WORD)22)); 1557 } 1558 1559 TOOLBAR_CalcToolbar (hwnd); 1560 } 1561 else 1562 { 1563 nButtons = (INT)wParam; 1564 if (nButtons <= 0) 1565 return -1; 1566 1567 TRACE ("adding %d bitmaps!\n", nButtons); 1568 } 1569 1569 1570 if (!(infoPtr->himlDef)) { 1570 1571 1572 1573 1574 1575 1576 1571 /* create new default image list */ 1572 TRACE ("creating default image list!\n"); 1573 1574 infoPtr->himlDef = 1575 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, 1576 ILC_COLOR | ILC_MASK, nButtons, 2); 1577 infoPtr->himlInt = infoPtr->himlDef; 1577 1578 } 1578 1579 … … 1582 1583 if (lpAddBmp->hInst == (HINSTANCE)0) 1583 1584 { 1584 nIndex = 1585 1586 1585 nIndex = 1586 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID, 1587 CLR_DEFAULT); 1587 1588 } 1588 1589 else if (lpAddBmp->hInst == HINST_COMMCTRL) 1589 1590 { 1590 1591 1592 { 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1591 /* Add system bitmaps */ 1592 switch (lpAddBmp->nID) 1593 { 1594 case IDB_STD_SMALL_COLOR: 1595 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1596 MAKEINTRESOURCEA(IDB_STD_SMALL)); 1597 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1598 hbmLoad, CLR_DEFAULT); 1599 DeleteObject (hbmLoad); 1600 break; 1601 1602 case IDB_STD_LARGE_COLOR: 1603 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1604 MAKEINTRESOURCEA(IDB_STD_LARGE)); 1605 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1606 hbmLoad, CLR_DEFAULT); 1607 DeleteObject (hbmLoad); 1608 break; 1609 1610 case IDB_VIEW_SMALL_COLOR: 1611 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1612 MAKEINTRESOURCEA(IDB_VIEW_SMALL)); 1613 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1614 hbmLoad, CLR_DEFAULT); 1615 DeleteObject (hbmLoad); 1616 break; 1617 1618 case IDB_VIEW_LARGE_COLOR: 1619 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1620 MAKEINTRESOURCEA(IDB_VIEW_LARGE)); 1621 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1622 hbmLoad, CLR_DEFAULT); 1623 DeleteObject (hbmLoad); 1624 break; 1625 1626 case IDB_HIST_SMALL_COLOR: 1627 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1628 MAKEINTRESOURCEA(IDB_HIST_SMALL)); 1629 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1630 hbmLoad, CLR_DEFAULT); 1631 DeleteObject (hbmLoad); 1632 break; 1633 1634 case IDB_HIST_LARGE_COLOR: 1635 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1636 MAKEINTRESOURCEA(IDB_HIST_LARGE)); 1637 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1638 hbmLoad, CLR_DEFAULT); 1639 DeleteObject (hbmLoad); 1640 break; 1641 1642 default: 1643 nIndex = ImageList_GetImageCount (infoPtr->himlDef); 1644 ERR ("invalid imagelist!\n"); 1645 break; 1646 } 1646 1647 } 1647 1648 else 1648 1649 { 1649 1650 1651 1650 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1651 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT); 1652 DeleteObject (hbmLoad); 1652 1653 } 1653 1654 … … 1659 1660 { 1660 1661 WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n", 1661 1662 1663 1664 1662 infoPtr->nNumBitmaps, nCount, imagecount - nCount, 1663 infoPtr->nNumBitmaps+nButtons,imagecount); 1664 1665 infoPtr->nNumBitmaps = imagecount; 1665 1666 } 1666 1667 else … … 1688 1689 1689 1690 if (infoPtr->nNumButtons == 0) { 1690 1691 1691 infoPtr->buttons = 1692 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1692 1693 } 1693 1694 else { 1694 1695 1696 1697 1698 1695 TBUTTON_INFO *oldButtons = infoPtr->buttons; 1696 infoPtr->buttons = 1697 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1698 memcpy (&infoPtr->buttons[0], &oldButtons[0], 1699 nOldButtons * sizeof(TBUTTON_INFO)); 1699 1700 COMCTL32_Free (oldButtons); 1700 1701 } … … 1704 1705 /* insert new button data */ 1705 1706 for (nCount = 0; nCount < nAddButtons; nCount++) { 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1707 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 1708 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 1709 btnPtr->idCommand = lpTbb[nCount].idCommand; 1710 btnPtr->fsState = lpTbb[nCount].fsState; 1711 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 1712 btnPtr->dwData = lpTbb[nCount].dwData; 1713 btnPtr->iString = lpTbb[nCount].iString; 1714 btnPtr->bHot = FALSE; 1715 1716 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 1717 TTTOOLINFOA ti; 1718 1719 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 1720 ti.cbSize = sizeof (TTTOOLINFOA); 1721 ti.hwnd = hwnd; 1722 ti.uId = btnPtr->idCommand; 1723 ti.hinst = 0; 1724 ti.lpszText = LPSTR_TEXTCALLBACKA; 1725 1726 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 1727 0, (LPARAM)&ti); 1728 } 1728 1729 } 1729 1730 … … 1750 1751 1751 1752 if (infoPtr->nNumButtons == 0) { 1752 1753 1753 infoPtr->buttons = 1754 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1754 1755 } 1755 1756 else { 1756 1757 1758 1759 1760 1757 TBUTTON_INFO *oldButtons = infoPtr->buttons; 1758 infoPtr->buttons = 1759 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1760 memcpy (&infoPtr->buttons[0], &oldButtons[0], 1761 nOldButtons * sizeof(TBUTTON_INFO)); 1761 1762 COMCTL32_Free (oldButtons); 1762 1763 } … … 1766 1767 /* insert new button data */ 1767 1768 for (nCount = 0; nCount < nAddButtons; nCount++) { 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1769 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 1770 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 1771 btnPtr->idCommand = lpTbb[nCount].idCommand; 1772 btnPtr->fsState = lpTbb[nCount].fsState; 1773 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 1774 btnPtr->dwData = lpTbb[nCount].dwData; 1775 btnPtr->iString = lpTbb[nCount].iString; 1776 btnPtr->bHot = FALSE; 1777 1778 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 1779 TTTOOLINFOW ti; 1780 1781 ZeroMemory (&ti, sizeof(TTTOOLINFOW)); 1782 ti.cbSize = sizeof (TTTOOLINFOW); 1783 ti.hwnd = hwnd; 1784 ti.uId = btnPtr->idCommand; 1785 ti.hinst = 0; 1786 ti.lpszText = LPSTR_TEXTCALLBACKW; 1787 1788 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 1789 0, (LPARAM)&ti); 1790 } 1790 1791 } 1791 1792 … … 1805 1806 1806 1807 if ((wParam) && (HIWORD(lParam) == 0)) { 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1808 char szString[256]; 1809 INT len, lenW; 1810 TRACE("adding string from resource!\n"); 1811 1812 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam, 1813 szString, 256); 1814 1815 TRACE("len=%d \"%s\"\n", len, szString); 1816 nIndex = infoPtr->nNumStrings; 1817 if (infoPtr->nNumStrings == 0) { 1818 infoPtr->strings = 1819 COMCTL32_Alloc (sizeof(LPWSTR)); 1820 } 1821 else { 1822 LPWSTR *oldStrings = infoPtr->strings; 1823 infoPtr->strings = 1824 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1825 memcpy (&infoPtr->strings[0], &oldStrings[0], 1826 sizeof(LPWSTR) * infoPtr->nNumStrings); 1827 COMCTL32_Free (oldStrings); 1828 } 1828 1829 1829 1830 lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 ); … … 1831 1832 MultiByteToWideChar( CP_ACP, 0, szString, -1, 1832 1833 infoPtr->strings[infoPtr->nNumStrings], lenW ); 1833 1834 infoPtr->nNumStrings++; 1834 1835 } 1835 1836 else { 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1837 LPSTR p = (LPSTR)lParam; 1838 INT len, lenW; 1839 1840 if (p == NULL) 1841 return -1; 1842 TRACE("adding string(s) from array!\n"); 1843 1844 nIndex = infoPtr->nNumStrings; 1845 while (*p) { 1846 len = strlen (p); 1847 TRACE("len=%d \"%s\"\n", len, p); 1848 1849 if (infoPtr->nNumStrings == 0) { 1850 infoPtr->strings = 1851 COMCTL32_Alloc (sizeof(LPWSTR)); 1852 } 1853 else { 1854 LPWSTR *oldStrings = infoPtr->strings; 1855 infoPtr->strings = 1856 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1857 memcpy (&infoPtr->strings[0], &oldStrings[0], 1858 sizeof(LPWSTR) * infoPtr->nNumStrings); 1859 COMCTL32_Free (oldStrings); 1860 } 1860 1861 1861 1862 lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 ); … … 1863 1864 MultiByteToWideChar( CP_ACP, 0, p, -1, 1864 1865 infoPtr->strings[infoPtr->nNumStrings], lenW ); 1865 1866 1867 1868 1866 infoPtr->nNumStrings++; 1867 1868 p += (len+1); 1869 } 1869 1870 } 1870 1871 … … 1881 1882 1882 1883 if ((wParam) && (HIWORD(lParam) == 0)) { 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1884 WCHAR szString[MAX_RESOURCE_STRING_LENGTH]; 1885 INT len; 1886 TRACE("adding string from resource!\n"); 1887 1888 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam, 1889 szString, MAX_RESOURCE_STRING_LENGTH); 1890 1891 TRACE("len=%d %s\n", len, debugstr_w(szString)); 1892 TRACE("First char: 0x%x\n", *szString); 1893 if (szString[0] == L'|') 1894 { 1895 PWSTR p = szString + 1; 1896 1897 nIndex = infoPtr->nNumStrings; 1898 while (*p != L'|') { 1899 1900 if (infoPtr->nNumStrings == 0) { 1901 infoPtr->strings = 1902 COMCTL32_Alloc (sizeof(LPWSTR)); 1903 } 1904 else { 1905 LPWSTR *oldStrings = infoPtr->strings; 1906 infoPtr->strings = 1907 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1908 memcpy (&infoPtr->strings[0], &oldStrings[0], 1909 sizeof(LPWSTR) * infoPtr->nNumStrings); 1910 COMCTL32_Free (oldStrings); 1911 } 1912 1913 len = COMCTL32_StrChrW (p, L'|') - p; 1914 TRACE("len=%d %s\n", len, debugstr_w(p)); 1915 infoPtr->strings[infoPtr->nNumStrings] = 1916 COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1917 lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len); 1918 infoPtr->nNumStrings++; 1919 1920 p += (len+1); 1921 } 1922 } 1923 else 1924 { 1924 1925 nIndex = infoPtr->nNumStrings; 1925 1926 if (infoPtr->nNumStrings == 0) { … … 1943 1944 } 1944 1945 else { 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1946 LPWSTR p = (LPWSTR)lParam; 1947 INT len; 1948 1949 if (p == NULL) 1950 return -1; 1951 TRACE("adding string(s) from array!\n"); 1952 nIndex = infoPtr->nNumStrings; 1953 while (*p) { 1954 len = strlenW (p); 1955 1956 TRACE("len=%d %s\n", len, debugstr_w(p)); 1957 if (infoPtr->nNumStrings == 0) { 1958 infoPtr->strings = 1959 COMCTL32_Alloc (sizeof(LPWSTR)); 1960 } 1961 else { 1962 LPWSTR *oldStrings = infoPtr->strings; 1963 infoPtr->strings = 1964 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1965 memcpy (&infoPtr->strings[0], &oldStrings[0], 1966 sizeof(LPWSTR) * infoPtr->nNumStrings); 1967 COMCTL32_Free (oldStrings); 1968 } 1969 1970 infoPtr->strings[infoPtr->nNumStrings] = 1971 COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1972 strcpyW (infoPtr->strings[infoPtr->nNumStrings], p); 1973 infoPtr->nNumStrings++; 1974 1975 p += (len+1); 1976 } 1976 1977 } 1977 1978 … … 2004 2005 2005 2006 if (dwStyle & CCS_NORESIZE) { 2006 2007 2008 2007 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 2008 cx = 0; 2009 cy = 0; 2009 2010 } 2010 2011 else { 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2012 infoPtr->nWidth = parent_rect.right - parent_rect.left; 2013 TOOLBAR_CalcToolbar (hwnd); 2014 InvalidateRect( hwnd, NULL, TRUE ); 2015 cy = infoPtr->nHeight; 2016 cx = infoPtr->nWidth; 2017 2018 if (dwStyle & CCS_NOMOVEY) { 2019 GetWindowRect(hwnd, &window_rect); 2020 ScreenToClient(parent, (LPPOINT)&window_rect.left); 2021 y = window_rect.top; 2022 } 2022 2023 } 2023 2024 2024 2025 if (dwStyle & CCS_NOPARENTALIGN) 2025 2026 uPosFlags |= SWP_NOMOVE; 2026 2027 2027 2028 if (!(dwStyle & CCS_NODIVIDER)) 2028 2029 cy += GetSystemMetrics(SM_CYEDGE); 2029 2030 2030 2031 if (dwStyle & WS_BORDER) … … 2061 2062 2062 2063 if (infoPtr == NULL) { 2063 2064 2065 2064 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam); 2065 ERR("infoPtr == NULL!\n"); 2066 return 0; 2066 2067 } 2067 2068 … … 2081 2082 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2082 2083 if (nIndex == -1) 2083 2084 return FALSE; 2084 2085 2085 2086 btnPtr = &infoPtr->buttons[nIndex]; … … 2105 2106 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2106 2107 if (nIndex == -1) 2107 2108 return FALSE; 2108 2109 2109 2110 btnPtr = &infoPtr->buttons[nIndex]; 2110 2111 2111 2112 if (!(btnPtr->fsStyle & TBSTYLE_CHECK)) 2112 2113 return FALSE; 2113 2114 2114 2115 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE; 2115 2116 2116 2117 if (LOWORD(lParam) == FALSE) 2117 2118 btnPtr->fsState &= ~TBSTATE_CHECKED; 2118 2119 else { 2119 2120 nOldIndex = 2121 2122 2123 2124 2125 2126 2127 2120 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 2121 nOldIndex = 2122 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex); 2123 if (nOldIndex == nIndex) 2124 return 0; 2125 if (nOldIndex != -1) 2126 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 2127 } 2128 btnPtr->fsState |= TBSTATE_CHECKED; 2128 2129 } 2129 2130 2130 2131 if( bChecked != LOWORD(lParam) ) 2131 2132 { 2132 2133 if (nOldIndex != -1) 2133 2134 { 2134 2135 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, … … 2171 2172 2172 2173 SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY, 2173 2174 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 2174 2175 2175 2176 if (!(hRes = FindResourceA (COMCTL32_hModule, 2176 2177 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE), 2177 2178 RT_DIALOGA))) 2178 2179 return FALSE; 2179 2180 2180 2181 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes))) 2181 2182 return FALSE; 2182 2183 2183 2184 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE), … … 2190 2191 nmhdr.code = TBN_ENDADJUST; 2191 2192 SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY, 2192 2193 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 2193 2194 2194 2195 return ret; … … 2203 2204 2204 2205 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2205 2206 2207 if ((infoPtr->hwndToolTip) && 2208 2209 2210 2211 2212 2213 2214 2215 2216 2206 return FALSE; 2207 2208 if ((infoPtr->hwndToolTip) && 2209 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) { 2210 TTTOOLINFOA ti; 2211 2212 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2213 ti.cbSize = sizeof (TTTOOLINFOA); 2214 ti.hwnd = hwnd; 2215 ti.uId = infoPtr->buttons[nIndex].idCommand; 2216 2217 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti); 2217 2218 } 2218 2219 2219 2220 if (infoPtr->nNumButtons == 1) { 2220 2221 2222 2223 2221 TRACE(" simple delete!\n"); 2222 COMCTL32_Free (infoPtr->buttons); 2223 infoPtr->buttons = NULL; 2224 infoPtr->nNumButtons = 0; 2224 2225 } 2225 2226 else { 2226 2227 TBUTTON_INFO *oldButtons = infoPtr->buttons; 2227 2228 TRACE("complex delete! [nIndex=%d]\n", nIndex); 2228 2229 2229 2230 2230 infoPtr->nNumButtons--; 2231 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 2231 2232 if (nIndex > 0) { 2232 2233 memcpy (&infoPtr->buttons[0], &oldButtons[0], … … 2239 2240 } 2240 2241 2241 2242 COMCTL32_Free (oldButtons); 2242 2243 } 2243 2244 … … 2260 2261 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2261 2262 if (nIndex == -1) 2262 2263 return FALSE; 2263 2264 2264 2265 btnPtr = &infoPtr->buttons[nIndex]; … … 2268 2269 /* update the toolbar button state */ 2269 2270 if(LOWORD(lParam) == FALSE) { 2270 2271 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED); 2271 2272 } else { 2272 2273 btnPtr->fsState |= TBSTATE_ENABLED; 2273 2274 } 2274 2275 … … 2301 2302 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2302 2303 if (nIndex == -1) 2303 2304 return -1; 2304 2305 2305 2306 return infoPtr->buttons[nIndex].iBitmap; … … 2323 2324 2324 2325 if (infoPtr == NULL) 2325 2326 return FALSE; 2326 2327 2327 2328 if (lpTbb == NULL) 2328 2329 return FALSE; 2329 2330 2330 2331 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2331 2332 return FALSE; 2332 2333 2333 2334 btnPtr = &infoPtr->buttons[nIndex]; … … 2352 2353 2353 2354 if (infoPtr == NULL) 2354 2355 return -1; 2355 2356 if (lpTbInfo == NULL) 2356 2357 return -1; 2357 2358 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA)) 2358 2359 return -1; 2359 2360 2360 2361 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2361 2362 if (nIndex == -1) 2362 2363 return -1; 2363 2364 2364 2365 btnPtr = &infoPtr->buttons[nIndex]; 2365 2366 2366 2367 if (lpTbInfo->dwMask & TBIF_COMMAND) 2367 2368 lpTbInfo->idCommand = btnPtr->idCommand; 2368 2369 if (lpTbInfo->dwMask & TBIF_IMAGE) 2369 2370 lpTbInfo->iImage = btnPtr->iBitmap; 2370 2371 if (lpTbInfo->dwMask & TBIF_LPARAM) 2371 2372 lpTbInfo->lParam = btnPtr->dwData; 2372 2373 if (lpTbInfo->dwMask & TBIF_SIZE) 2373 2374 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 2374 2375 if (lpTbInfo->dwMask & TBIF_STATE) 2375 2376 lpTbInfo->fsState = btnPtr->fsState; 2376 2377 if (lpTbInfo->dwMask & TBIF_STYLE) 2377 2378 lpTbInfo->fsStyle = btnPtr->fsStyle; 2378 2379 if (lpTbInfo->dwMask & TBIF_TEXT) { 2379 2380 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) 2380 { 2381 { 2381 2382 if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1, 2382 2383 lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL )) … … 2398 2399 2399 2400 if (infoPtr == NULL) 2400 2401 return -1; 2401 2402 if (lpTbInfo == NULL) 2402 2403 return -1; 2403 2404 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW)) 2404 2405 return -1; 2405 2406 2406 2407 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2407 2408 if (nIndex == -1) 2408 2409 return -1; 2409 2410 2410 2411 btnPtr = &infoPtr->buttons[nIndex]; 2411 2412 2412 2413 if (lpTbInfo->dwMask & TBIF_COMMAND) 2413 2414 lpTbInfo->idCommand = btnPtr->idCommand; 2414 2415 if (lpTbInfo->dwMask & TBIF_IMAGE) 2415 2416 lpTbInfo->iImage = btnPtr->iBitmap; 2416 2417 if (lpTbInfo->dwMask & TBIF_LPARAM) 2417 2418 lpTbInfo->lParam = btnPtr->dwData; 2418 2419 if (lpTbInfo->dwMask & TBIF_SIZE) 2419 2420 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 2420 2421 if (lpTbInfo->dwMask & TBIF_STATE) 2421 2422 lpTbInfo->fsState = btnPtr->fsState; 2422 2423 if (lpTbInfo->dwMask & TBIF_STYLE) 2423 2424 lpTbInfo->fsStyle = btnPtr->fsStyle; 2424 2425 if (lpTbInfo->dwMask & TBIF_TEXT) { 2425 2426 2427 2428 2426 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings)) 2427 lstrcpynW (lpTbInfo->pszText, 2428 (LPWSTR)infoPtr->strings[btnPtr->iString], 2429 lpTbInfo->cchText); 2429 2430 } 2430 2431 … … 2439 2440 2440 2441 return MAKELONG((WORD)infoPtr->nButtonWidth, 2441 2442 (WORD)infoPtr->nButtonHeight); 2442 2443 } 2443 2444 … … 2451 2452 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2452 2453 if (nIndex == -1) 2453 2454 return -1; 2454 2455 2455 2456 nStringIndex = infoPtr->buttons[nIndex].iString; … … 2458 2459 2459 2460 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 2460 2461 return -1; 2461 2462 2462 2463 if (lParam == 0) 2463 2464 return -1; 2464 2465 2465 2466 return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1, … … 2476 2477 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2477 2478 if (nIndex == -1) 2478 2479 return -1; 2479 2480 2480 2481 nStringIndex = infoPtr->buttons[nIndex].iString; … … 2483 2484 2484 2485 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 2485 2486 return -1; 2486 2487 2487 2488 if (lParam == 0) 2488 2489 return -1; 2489 2490 2490 2491 strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]); … … 2530 2531 2531 2532 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)) 2532 2533 return -1; 2533 2534 2534 2535 if (infoPtr->nHotItem < 0) 2535 2536 return -1; 2536 2537 2537 2538 return (LRESULT)infoPtr->nHotItem; … … 2561 2562 2562 2563 if (infoPtr == NULL) 2563 2564 return FALSE; 2564 2565 nIndex = (INT)wParam; 2565 2566 btnPtr = &infoPtr->buttons[nIndex]; 2566 2567 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2567 2568 return FALSE; 2568 2569 lpRect = (LPRECT)lParam; 2569 2570 if (lpRect == NULL) 2570 2571 return FALSE; 2571 2572 if (btnPtr->fsState & TBSTATE_HIDDEN) 2572 2573 2573 return FALSE; 2574 2574 2575 lpRect->left = btnPtr->rect.left; 2575 2576 lpRect->right = btnPtr->rect.right; … … 2588 2589 2589 2590 if (lpSize == NULL) 2590 2591 return FALSE; 2591 2592 2592 2593 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left; … … 2594 2595 2595 2596 TRACE("maximum size %d x %d\n", 2596 2597 2597 infoPtr->rcBound.right - infoPtr->rcBound.left, 2598 infoPtr->rcBound.bottom - infoPtr->rcBound.top); 2598 2599 2599 2600 return TRUE; … … 2614 2615 2615 2616 if (infoPtr == NULL) 2616 2617 return FALSE; 2617 2618 nIndex = (INT)wParam; 2618 2619 btnPtr = &infoPtr->buttons[nIndex]; 2619 2620 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2620 2621 return FALSE; 2621 2622 lpRect = (LPRECT)lParam; 2622 2623 if (lpRect == NULL) 2623 2624 2624 return FALSE; 2625 2625 2626 lpRect->left = btnPtr->rect.left; 2626 2627 lpRect->right = btnPtr->rect.right; … … 2638 2639 2639 2640 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE) 2640 2641 return infoPtr->nRows; 2641 2642 else 2642 2643 return 1; 2643 2644 } 2644 2645 … … 2652 2653 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2653 2654 if (nIndex == -1) 2654 2655 return -1; 2655 2656 2656 2657 return infoPtr->buttons[nIndex].fsState; … … 2666 2667 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2667 2668 if (nIndex == -1) 2668 2669 return -1; 2669 2670 2670 2671 return infoPtr->buttons[nIndex].fsStyle; … … 2678 2679 2679 2680 if (infoPtr == NULL) 2680 2681 return 0; 2681 2682 2682 2683 return infoPtr->nMaxTextRows; … … 2690 2691 2691 2692 if (infoPtr == NULL) 2692 2693 return 0; 2693 2694 return infoPtr->hwndToolTip; 2694 2695 } … … 2700 2701 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2701 2702 2702 TRACE("%s hwnd=0x%x stub!\n", 2703 2703 TRACE("%s hwnd=0x%x stub!\n", 2704 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd); 2704 2705 2705 2706 return infoPtr->bUnicode; … … 2726 2727 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2727 2728 if (nIndex == -1) 2728 2729 return FALSE; 2729 2730 2730 2731 btnPtr = &infoPtr->buttons[nIndex]; 2731 2732 if (LOWORD(lParam) == FALSE) 2732 2733 btnPtr->fsState &= ~TBSTATE_HIDDEN; 2733 2734 else 2734 2735 btnPtr->fsState |= TBSTATE_HIDDEN; 2735 2736 2736 2737 TOOLBAR_CalcToolbar (hwnd); … … 2758 2759 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2759 2760 if (nIndex == -1) 2760 2761 return FALSE; 2761 2762 2762 2763 btnPtr = &infoPtr->buttons[nIndex]; 2763 2764 if (LOWORD(lParam) == FALSE) 2764 2765 btnPtr->fsState &= ~TBSTATE_INDETERMINATE; 2765 2766 else 2766 2767 btnPtr->fsState |= TBSTATE_INDETERMINATE; 2767 2768 2768 2769 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr)); … … 2781 2782 2782 2783 if (lpTbb == NULL) 2783 2784 return FALSE; 2784 2785 2785 2786 if (nIndex == -1) { 2786 2787 /* EPP: this seems to be an undocumented call (from my IE4) 2787 2788 2789 2790 2791 2792 2793 int 2794 LPSTR 2788 * I assume in that case that: 2789 * - lpTbb->iString is a string pointer (not a string index in strings[] table 2790 * - index of insertion is at the end of existing buttons 2791 * I only see this happen with nIndex == -1, but it could have a special 2792 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion). 2793 */ 2794 int len; 2795 LPSTR ptr; 2795 2796 2796 2797 /* FIXME: iString == -1 is undocumented */ … … 2814 2815 TRACE("inserting button index=%d\n", nIndex); 2815 2816 if (nIndex > infoPtr->nNumButtons) { 2816 2817 2817 nIndex = infoPtr->nNumButtons; 2818 TRACE("adjust index=%d\n", nIndex); 2818 2819 } 2819 2820 … … 2823 2824 /* pre insert copy */ 2824 2825 if (nIndex > 0) { 2825 2826 2826 memcpy (&infoPtr->buttons[0], &oldButtons[0], 2827 nIndex * sizeof(TBUTTON_INFO)); 2827 2828 } 2828 2829 … … 2836 2837 2837 2838 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2839 TTTOOLINFOA ti; 2840 2841 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2842 ti.cbSize = sizeof (TTTOOLINFOA); 2843 ti.hwnd = hwnd; 2844 ti.uId = lpTbb->idCommand; 2845 ti.hinst = 0; 2846 ti.lpszText = LPSTR_TEXTCALLBACKA; 2847 2848 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 2849 0, (LPARAM)&ti); 2849 2850 } 2850 2851 2851 2852 /* post insert copy */ 2852 2853 if (nIndex < infoPtr->nNumButtons - 1) { 2853 2854 2854 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 2855 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 2855 2856 } 2856 2857 … … 2874 2875 2875 2876 if (lpTbb == NULL) 2876 2877 return FALSE; 2877 2878 if (nIndex < 0) 2878 2879 return FALSE; 2879 2880 2880 2881 TRACE("inserting button index=%d\n", nIndex); 2881 2882 if (nIndex > infoPtr->nNumButtons) { 2882 2883 2883 nIndex = infoPtr->nNumButtons; 2884 TRACE("adjust index=%d\n", nIndex); 2884 2885 } 2885 2886 … … 2889 2890 /* pre insert copy */ 2890 2891 if (nIndex > 0) { 2891 2892 2892 memcpy (&infoPtr->buttons[0], &oldButtons[0], 2893 nIndex * sizeof(TBUTTON_INFO)); 2893 2894 } 2894 2895 … … 2902 2903 2903 2904 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2905 TTTOOLINFOW ti; 2906 2907 ZeroMemory (&ti, sizeof(TTTOOLINFOW)); 2908 ti.cbSize = sizeof (TTTOOLINFOW); 2909 ti.hwnd = hwnd; 2910 ti.uId = lpTbb->idCommand; 2911 ti.hinst = 0; 2912 ti.lpszText = LPSTR_TEXTCALLBACKW; 2913 2914 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 2915 0, (LPARAM)&ti); 2915 2916 } 2916 2917 2917 2918 /* post insert copy */ 2918 2919 if (nIndex < infoPtr->nNumButtons - 1) { 2919 2920 2920 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 2921 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 2921 2922 } 2922 2923 … … 2940 2941 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2941 2942 if (nIndex == -1) 2942 2943 return FALSE; 2943 2944 2944 2945 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED); … … 2954 2955 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2955 2956 if (nIndex == -1) 2956 2957 return FALSE; 2957 2958 2958 2959 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED); … … 2968 2969 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2969 2970 if (nIndex == -1) 2970 2971 return TRUE; 2971 2972 2972 2973 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN); … … 2982 2983 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2983 2984 if (nIndex == -1) 2984 2985 return FALSE; 2985 2986 2986 2987 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED); … … 2996 2997 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2997 2998 if (nIndex == -1) 2998 2999 return FALSE; 2999 3000 3000 3001 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE); … … 3010 3011 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3011 3012 if (nIndex == -1) 3012 3013 return FALSE; 3013 3014 3014 3015 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED); … … 3031 3032 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3032 3033 if (nIndex == -1) 3033 3034 return FALSE; 3034 3035 3035 3036 btnPtr = &infoPtr->buttons[nIndex]; 3036 3037 if (LOWORD(lParam) == FALSE) 3037 3038 btnPtr->fsState &= ~TBSTATE_PRESSED; 3038 3039 else 3039 3040 btnPtr->fsState |= TBSTATE_PRESSED; 3040 3041 3041 3042 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr)); … … 3058 3059 3059 3060 if ((BOOL)wParam) { 3060 3061 3062 3061 /* save toolbar information */ 3062 FIXME("save to \"%s\" \"%s\"\n", 3063 lpSave->pszSubKey, lpSave->pszValueName); 3063 3064 3064 3065 3065 3066 } 3066 3067 else { 3067 3068 3069 3070 3068 /* restore toolbar information */ 3069 3070 FIXME("restore from \"%s\" \"%s\"\n", 3071 lpSave->pszSubKey, lpSave->pszValueName); 3071 3072 3072 3073 … … 3086 3087 3087 3088 if (lpSave == NULL) 3088 3089 return 0; 3089 3090 3090 3091 if ((BOOL)wParam) { 3091 3092 3093 3092 /* save toolbar information */ 3093 FIXME("save to \"%s\" \"%s\"\n", 3094 lpSave->pszSubKey, lpSave->pszValueName); 3094 3095 3095 3096 3096 3097 } 3097 3098 else { 3098 3099 3100 3101 3099 /* restore toolbar information */ 3100 3101 FIXME("restore from \"%s\" \"%s\"\n", 3102 lpSave->pszSubKey, lpSave->pszValueName); 3102 3103 3103 3104 … … 3127 3128 3128 3129 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 3129 3130 return FALSE; 3130 3131 3131 3132 if (infoPtr->nNumButtons > 0) … … 3157 3158 3158 3159 if (lptbbi == NULL) 3159 3160 return FALSE; 3160 3161 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA)) 3161 3162 3162 return FALSE; 3163 3163 3164 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3164 3165 if (nIndex == -1) 3165 3166 return FALSE; 3166 3167 3167 3168 btnPtr = &infoPtr->buttons[nIndex]; 3168 3169 if (lptbbi->dwMask & TBIF_COMMAND) 3169 3170 btnPtr->idCommand = lptbbi->idCommand; 3170 3171 if (lptbbi->dwMask & TBIF_IMAGE) 3171 3172 btnPtr->iBitmap = lptbbi->iImage; 3172 3173 if (lptbbi->dwMask & TBIF_LPARAM) 3173 3174 btnPtr->dwData = lptbbi->lParam; 3174 3175 /* if (lptbbi->dwMask & TBIF_SIZE) */ 3175 /* 3176 /* btnPtr->cx = lptbbi->cx; */ 3176 3177 if (lptbbi->dwMask & TBIF_STATE) 3177 3178 btnPtr->fsState = lptbbi->fsState; 3178 3179 if (lptbbi->dwMask & TBIF_STYLE) 3179 3180 btnPtr->fsStyle = lptbbi->fsStyle; 3180 3181 3181 3182 if (lptbbi->dwMask & TBIF_TEXT) { 3182 if ((btnPtr->iString >= 0) || 3183 3184 3183 if ((btnPtr->iString >= 0) || 3184 (btnPtr->iString < infoPtr->nNumStrings)) { 3185 TRACE("Ooooooch\n"); 3185 3186 #if 0 3186 3187 3188 3187 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 3188 INT len = lstrlenA (lptbbi->pszText); 3189 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1)); 3189 3190 #endif 3190 3191 3191 3192 /* 3193 3192 /* this is the ultimate sollution */ 3193 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 3194 } 3194 3195 } 3195 3196 … … 3207 3208 3208 3209 if (lptbbi == NULL) 3209 3210 return FALSE; 3210 3211 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW)) 3211 3212 return FALSE; 3212 3213 3213 3214 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3214 3215 if (nIndex == -1) 3215 3216 return FALSE; 3216 3217 3217 3218 btnPtr = &infoPtr->buttons[nIndex]; 3218 3219 if (lptbbi->dwMask & TBIF_COMMAND) 3219 3220 btnPtr->idCommand = lptbbi->idCommand; 3220 3221 if (lptbbi->dwMask & TBIF_IMAGE) 3221 3222 btnPtr->iBitmap = lptbbi->iImage; 3222 3223 if (lptbbi->dwMask & TBIF_LPARAM) 3223 3224 btnPtr->dwData = lptbbi->lParam; 3224 3225 /* if (lptbbi->dwMask & TBIF_SIZE) */ 3225 /* 3226 /* btnPtr->cx = lptbbi->cx; */ 3226 3227 if (lptbbi->dwMask & TBIF_STATE) 3227 3228 btnPtr->fsState = lptbbi->fsState; 3228 3229 if (lptbbi->dwMask & TBIF_STYLE) 3229 3230 btnPtr->fsStyle = lptbbi->fsStyle; 3230 3231 3231 3232 if (lptbbi->dwMask & TBIF_TEXT) { 3232 3233 3233 if ((btnPtr->iString >= 0) || 3234 (btnPtr->iString < infoPtr->nNumStrings)) { 3234 3235 #if 0 3235 3236 3237 3236 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 3237 INT len = lstrlenW (lptbbi->pszText); 3238 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1)); 3238 3239 #endif 3239 3240 3240 3241 /* 3242 3241 /* this is the ultimate solution */ 3242 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 3243 } 3243 3244 } 3244 3245 … … 3255 3256 { 3256 3257 ERR("invalid parameter\n"); 3257 3258 return FALSE; 3258 3259 } 3259 3260 3260 3261 /* The documentation claims you can only change the button size before 3261 * any button has been added. But this is wrong. 3262 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding 3262 * any button has been added. But this is wrong. 3263 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding 3263 3264 * it to the toolbar, and it checks that the return value is nonzero - mjm 3264 3265 * Further testing shows that we must actually perform the change too. … … 3276 3277 3277 3278 if (infoPtr == NULL) { 3278 3279 3279 TRACE("Toolbar not initialized yet?????\n"); 3280 return FALSE; 3280 3281 } 3281 3282 3282 3283 /* if setting to current values, ignore */ 3283 3284 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) && 3284 3285 3286 3287 return TRUE; 3285 (infoPtr->cxMax == (INT)HIWORD(lParam))) { 3286 TRACE("matches current width, min=%d, max=%d, no recalc\n", 3287 infoPtr->cxMin, infoPtr->cxMax); 3288 return TRUE; 3288 3289 } 3289 3290 … … 3294 3295 /* if both values are 0 then we are done */ 3295 3296 if (lParam == 0) { 3296 TRACE("setting both min and max to 0, norecalc\n"); 3297 3297 TRACE("setting both min and max to 0, norecalc\n"); 3298 return TRUE; 3298 3299 } 3299 3300 … … 3301 3302 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT 3302 3303 which doesn't actually draw - GA). */ 3303 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 3304 3304 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 3305 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax); 3305 3306 3306 3307 TOOLBAR_CalcToolbar (hwnd); … … 3319 3320 3320 3321 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 3321 3322 return FALSE; 3322 3323 3323 3324 infoPtr->buttons[nIndex].idCommand = (INT)lParam; … … 3325 3326 if (infoPtr->hwndToolTip) { 3326 3327 3327 3328 FIXME("change tool tip!\n"); 3328 3329 3329 3330 } … … 3348 3349 /* FIXME: redraw ? */ 3349 3350 3350 return (LRESULT)himlTemp; 3351 return (LRESULT)himlTemp; 3351 3352 } 3352 3353 … … 3360 3361 dwTemp = infoPtr->dwDTFlags; 3361 3362 infoPtr->dwDTFlags = 3362 3363 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam; 3363 3364 3364 3365 return (LRESULT)dwTemp; … … 3375 3376 infoPtr->dwExStyle = (DWORD)lParam; 3376 3377 3377 return (LRESULT)dwTemp; 3378 return (LRESULT)dwTemp; 3378 3379 } 3379 3380 … … 3390 3391 /* FIXME: redraw ? */ 3391 3392 3392 return (LRESULT)himlTemp; 3393 return (LRESULT)himlTemp; 3393 3394 } 3394 3395 … … 3407 3408 { 3408 3409 3409 3410 infoPtr->nHotItem = (INT)wParam; 3410 3411 if ((INT)wParam >=0) 3411 3412 { 3412 3413 btnPtr = &infoPtr->buttons[(INT)wParam]; 3413 3414 btnPtr->bHot = TRUE; 3414 3415 InvalidateRect (hwnd, &btnPtr->rect, 3415 3416 TOOLBAR_HasText(infoPtr, btnPtr)); 3416 3417 } … … 3419 3420 btnPtr = &infoPtr->buttons[nOldHotItem]; 3420 3421 btnPtr->bHot = FALSE; 3421 3422 InvalidateRect (hwnd, &btnPtr->rect, 3422 3423 TOOLBAR_HasText(infoPtr, btnPtr)); 3423 3424 } … … 3425 3426 3426 3427 if (nOldHotItem < 0) 3427 3428 return -1; 3428 3429 3429 3430 return (LRESULT)nOldHotItem; … … 3443 3444 /* FIXME: redraw ? */ 3444 3445 3445 return (LRESULT)himlTemp; 3446 return (LRESULT)himlTemp; 3446 3447 } 3447 3448 … … 3490 3491 3491 3492 if (infoPtr == NULL) 3492 3493 return FALSE; 3493 3494 3494 3495 infoPtr->nMaxTextRows = (INT)wParam; … … 3510 3511 3511 3512 if (infoPtr == NULL) 3512 3513 return 0; 3513 3514 hwndOldNotify = infoPtr->hwndNotify; 3514 3515 infoPtr->hwndNotify = (HWND)wParam; … … 3527 3528 3528 3529 if (LOWORD(wParam) > 1) { 3529 3530 FIXME("multiple rows not supported!\n"); 3530 3531 } 3531 3532 … … 3543 3544 /* return bounding rectangle */ 3544 3545 if (lprc) { 3545 3546 3547 3548 3546 lprc->left = infoPtr->rcBound.left; 3547 lprc->right = infoPtr->rcBound.right; 3548 lprc->top = infoPtr->rcBound.top; 3549 lprc->bottom = infoPtr->rcBound.bottom; 3549 3550 } 3550 3551 … … 3562 3563 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3563 3564 if (nIndex == -1) 3564 3565 return FALSE; 3565 3566 3566 3567 btnPtr = &infoPtr->buttons[nIndex]; … … 3587 3588 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3588 3589 if (nIndex == -1) 3589 3590 return FALSE; 3590 3591 3591 3592 btnPtr = &infoPtr->buttons[nIndex]; … … 3599 3600 3600 3601 if (infoPtr->hwndToolTip) { 3601 3602 FIXME("change tool tip!\n"); 3602 3603 } 3603 3604 } … … 3613 3614 3614 3615 if (infoPtr == NULL) 3615 3616 return 0; 3616 3617 infoPtr->hwndToolTip = (HWND)wParam; 3617 3618 return 0; … … 3625 3626 BOOL bTemp; 3626 3627 3627 TRACE("%s hwnd=0x%04x stub!\n", 3628 3628 TRACE("%s hwnd=0x%04x stub!\n", 3629 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd); 3629 3630 3630 3631 bTemp = infoPtr->bUnicode; … … 3683 3684 3684 3685 if (dwStyle & TBSTYLE_TOOLTIPS) { 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3686 /* Create tooltip control */ 3687 infoPtr->hwndToolTip = 3688 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 3689 CW_USEDEFAULT, CW_USEDEFAULT, 3690 CW_USEDEFAULT, CW_USEDEFAULT, 3691 hwnd, 0, 0, 0); 3692 3693 /* Send NM_TOOLTIPSCREATED notification */ 3694 if (infoPtr->hwndToolTip) { 3695 NMTOOLTIPSCREATED nmttc; 3696 3697 nmttc.hdr.hwndFrom = hwnd; 3698 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3699 nmttc.hdr.code = NM_TOOLTIPSCREATED; 3700 nmttc.hwndToolTips = infoPtr->hwndToolTip; 3701 3702 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 3703 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc); 3704 } 3704 3705 } 3705 3706 … … 3717 3718 /* delete tooltip control */ 3718 3719 if (infoPtr->hwndToolTip) 3719 3720 DestroyWindow (infoPtr->hwndToolTip); 3720 3721 3721 3722 /* delete button data */ 3722 3723 if (infoPtr->buttons) 3723 3724 COMCTL32_Free (infoPtr->buttons); 3724 3725 3725 3726 /* delete strings */ 3726 3727 if (infoPtr->strings) { 3727 3728 3729 3730 3731 3732 3728 INT i; 3729 for (i = 0; i < infoPtr->nNumStrings; i++) 3730 if (infoPtr->strings[i]) 3731 COMCTL32_Free (infoPtr->strings[i]); 3732 3733 COMCTL32_Free (infoPtr->strings); 3733 3734 } 3734 3735 3735 3736 /* destroy internal image list */ 3736 3737 if (infoPtr->himlInt) 3737 3738 ImageList_Destroy (infoPtr->himlInt); 3738 3739 3739 3740 /* delete default font */ 3740 3741 if (infoPtr->hFont) 3741 3742 DeleteObject (infoPtr->hFont); 3742 3743 3743 3744 /* free toolbar info data */ … … 3755 3756 3756 3757 if (infoPtr->bTransparent) 3757 3758 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam); 3758 3759 3759 3760 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam); … … 3783 3784 3784 3785 if (nHit >= 0) { 3785 3786 3787 3788 3789 3790 3791 3792 3786 btnPtr = &infoPtr->buttons[nHit]; 3787 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 3788 return 0; 3789 SetCapture (hwnd); 3790 infoPtr->bCaptured = TRUE; 3791 infoPtr->nButtonDown = nHit; 3792 3793 btnPtr->fsState |= TBSTATE_PRESSED; 3793 3794 3794 3795 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, … … 3796 3797 } 3797 3798 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE) 3798 3799 TOOLBAR_Customize (hwnd); 3799 3800 3800 3801 return 0; … … 3811 3812 3812 3813 if (infoPtr->hwndToolTip) 3813 3814 3814 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 3815 WM_LBUTTONDOWN, wParam, lParam); 3815 3816 3816 3817 pt.x = (INT)LOWORD(lParam); … … 3819 3820 3820 3821 if (nHit >= 0) { 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3822 RECT arrowRect; 3823 btnPtr = &infoPtr->buttons[nHit]; 3824 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 3825 return 0; 3826 3827 infoPtr->nOldHit = nHit; 3828 3829 CopyRect(&arrowRect, &btnPtr->rect); 3830 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH); 3831 3832 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */ 3833 if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) && 3834 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) || 3835 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle)))) 3836 { 3837 NMTOOLBARA nmtb; 3838 /* 3839 * this time we must force a Redraw, so the btn is 3840 * painted down before CaptureChanged repaints it up 3841 */ 3842 RedrawWindow(hwnd,&btnPtr->rect,0, 3843 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW); 3844 3845 nmtb.hdr.hwndFrom = hwnd; 3846 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3847 nmtb.hdr.code = TBN_DROPDOWN; 3848 nmtb.iItem = btnPtr->idCommand; 3849 3850 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 3851 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 3852 } 3853 else 3854 { 3855 SetCapture (hwnd); 3856 infoPtr->bCaptured = TRUE; 3857 infoPtr->nButtonDown = nHit; 3858 3859 btnPtr->fsState |= TBSTATE_PRESSED; 3860 btnPtr->bHot = FALSE; 3861 3862 InvalidateRect(hwnd, &btnPtr->rect, 3863 TOOLBAR_HasText(infoPtr, btnPtr)); 3864 } 3864 3865 } 3865 3866 … … 3878 3879 3879 3880 if (infoPtr->hwndToolTip) 3880 3881 3881 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 3882 WM_LBUTTONUP, wParam, lParam); 3882 3883 3883 3884 pt.x = (INT)LOWORD(lParam); … … 3891 3892 3892 3893 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) { 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 if ((nOldIndex != infoPtr->nButtonDown) && 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3894 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 3895 btnPtr->fsState &= ~TBSTATE_PRESSED; 3896 3897 if (nHit == infoPtr->nButtonDown) { 3898 if (btnPtr->fsStyle & TBSTYLE_CHECK) { 3899 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 3900 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, 3901 infoPtr->nButtonDown); 3902 if (nOldIndex == infoPtr->nButtonDown) 3903 bSendMessage = FALSE; 3904 if ((nOldIndex != infoPtr->nButtonDown) && 3905 (nOldIndex != -1)) 3906 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 3907 btnPtr->fsState |= TBSTATE_CHECKED; 3908 } 3909 else { 3910 if (btnPtr->fsState & TBSTATE_CHECKED) 3911 btnPtr->fsState &= ~TBSTATE_CHECKED; 3912 else 3913 btnPtr->fsState |= TBSTATE_CHECKED; 3914 } 3915 } 3916 } 3917 else 3918 bSendMessage = FALSE; 3919 3920 if (nOldIndex != -1) 3920 3921 { 3921 3922 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, … … 3923 3924 } 3924 3925 3925 3926 3927 3928 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged) 3929 3930 3931 3932 3933 3934 3926 /* 3927 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg, 3928 * that resets bCaptured and btn TBSTATE_PRESSED flags, 3929 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged) 3930 */ 3931 ReleaseCapture (); 3932 3933 if (bSendMessage) 3934 SendMessageA (GetParent(hwnd), WM_COMMAND, 3935 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 3935 3936 } 3936 3937 … … 3949 3950 { 3950 3951 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 3951 3952 btnPtr->fsState &= ~TBSTATE_PRESSED; 3952 3953 3953 3954 infoPtr->nButtonDown = -1; … … 3975 3976 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED)) 3976 3977 { 3977 3978 hotBtnPtr->bHot = FALSE; 3978 3979 3979 3980 InvalidateRect (hwnd, &hotBtnPtr->rect, TOOLBAR_HasText(infoPtr, … … 4019 4020 if(!(trackinfo.dwFlags & TME_LEAVE)) { 4020 4021 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 4021 4022 4022 4023 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ 4023 4024 /* and can properly deactivate the hot toolbar button */ … … 4026 4027 4027 4028 if (infoPtr->hwndToolTip) 4028 4029 4029 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 4030 WM_MOUSEMOVE, wParam, lParam); 4030 4031 4031 4032 pt.x = (INT)LOWORD(lParam); … … 4036 4037 if (infoPtr->nOldHit != nHit) 4037 4038 { 4038 4039 4040 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem && 4041 4042 4043 4044 4045 4046 4039 /* Remove the effect of an old hot button if the button was enabled and was 4040 drawn with the hot button effect */ 4041 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem && 4042 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED)) 4043 { 4044 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 4045 oldBtnPtr->bHot = FALSE; 4046 4047 InvalidateRect (hwnd, &oldBtnPtr->rect, 4047 4048 TOOLBAR_HasText(infoPtr, oldBtnPtr)); 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 /* only enabled buttons show hot effect */ 4049 } 4050 4051 /* It's not a separator or in nowhere. It's a hot button. */ 4052 if (nHit >= 0) 4053 { 4054 btnPtr = &infoPtr->buttons[nHit]; 4055 btnPtr->bHot = TRUE; 4056 4057 infoPtr->nHotItem = nHit; 4058 4059 /* only enabled buttons show hot effect */ 4059 4060 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED) 4060 4061 { … … 4063 4064 } 4064 4065 4065 4066 } 4066 4067 4067 4068 if (infoPtr->bCaptured) { 4068 4069 4070 4069 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 4070 if (infoPtr->nOldHit == infoPtr->nButtonDown) { 4071 btnPtr->fsState &= ~TBSTATE_PRESSED; 4071 4072 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 4072 4073 4074 4073 } 4074 else if (nHit == infoPtr->nButtonDown) { 4075 btnPtr->fsState |= TBSTATE_PRESSED; 4075 4076 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 4076 4077 4078 4077 } 4078 } 4079 infoPtr->nOldHit = nHit; 4079 4080 } 4080 4081 return 0; … … 4086 4087 { 4087 4088 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */ 4088 4089 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam); 4089 4090 /* else */ 4090 /* 4091 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */ 4091 4092 } 4092 4093 … … 4096 4097 { 4097 4098 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER)) 4098 4099 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE); 4099 4100 4100 4101 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam); … … 4117 4118 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) { 4118 4119 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE); 4119 4120 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst); 4120 4121 } 4121 4122 … … 4132 4133 4133 4134 if (dwStyle & WS_MINIMIZE) 4134 4135 return 0; /* Nothing to do */ 4135 4136 4136 4137 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam); 4137 4138 4138 4139 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW))) 4139 4140 return 0; 4140 4141 4141 4142 if (!(dwStyle & CCS_NODIVIDER)) 4142 4143 { 4143 4144 4145 4146 4147 4144 GetWindowRect (hwnd, &rcWindow); 4145 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top); 4146 if( dwStyle & WS_BORDER ) 4147 OffsetRect (&rcWindow, 1, 1); 4148 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP); 4148 4149 } 4149 4150 … … 4163 4164 4164 4165 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) { 4165 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,wParam, lParam);4166 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam); 4166 4167 4167 4168 #if 0 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4169 if (lpnmh->code == TTN_GETDISPINFOA) { 4170 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam; 4171 4172 FIXME("retrieving ASCII string\n"); 4173 4174 } 4175 else if (lpnmh->code == TTN_GETDISPINFOW) { 4176 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam; 4177 4178 FIXME("retrieving UNICODE string\n"); 4179 4180 } 4180 4181 #endif 4181 4182 } … … 4193 4194 4194 4195 /* fill ps.rcPaint with a default rect */ 4195 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 4196 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 4196 4197 4197 4198 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam; 4198 4199 4199 4200 TRACE("psrect=(%d,%d)-(%d,%d)\n", 4200 4201 4201 ps.rcPaint.left, ps.rcPaint.top, 4202 ps.rcPaint.right, ps.rcPaint.bottom); 4202 4203 4203 4204 TOOLBAR_Refresh (hwnd, hdc, &ps); … … 4223 4224 /* Resize deadlock check */ 4224 4225 if (infoPtr->bAutoSize) { 4225 4226 4226 infoPtr->bAutoSize = FALSE; 4227 return 0; 4227 4228 } 4228 4229 … … 4239 4240 4240 4241 if (flags == SIZE_RESTORED) { 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4242 /* width and height don't apply */ 4243 parent = GetParent (hwnd); 4244 GetClientRect(parent, &parent_rect); 4245 x = parent_rect.left; 4246 y = parent_rect.top; 4247 4248 if (dwStyle & CCS_NORESIZE) { 4249 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 4250 4251 /* 4251 4252 * this sets the working width of the toolbar, and 4252 4253 * Calc Toolbar will not adjust it, only the height 4253 4254 */ 4254 infoPtr->nWidth = parent_rect.right - parent_rect.left; 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4255 infoPtr->nWidth = parent_rect.right - parent_rect.left; 4256 cy = infoPtr->nHeight; 4257 cx = infoPtr->nWidth; 4258 TOOLBAR_CalcToolbar (hwnd); 4259 infoPtr->nWidth = cx; 4260 infoPtr->nHeight = cy; 4261 } 4262 else { 4263 infoPtr->nWidth = parent_rect.right - parent_rect.left; 4264 TOOLBAR_CalcToolbar (hwnd); 4265 cy = infoPtr->nHeight; 4266 cx = infoPtr->nWidth; 4267 4268 if (dwStyle & CCS_NOMOVEY) { 4269 GetWindowRect(hwnd, &window_rect); 4270 ScreenToClient(parent, (LPPOINT)&window_rect.left); 4271 y = window_rect.top; 4272 } 4273 } 4274 4275 if (dwStyle & CCS_NOPARENTALIGN) { 4276 uPosFlags |= SWP_NOMOVE; 4277 cy = infoPtr->nHeight; 4278 cx = infoPtr->nWidth; 4279 } 4280 4281 if (!(dwStyle & CCS_NODIVIDER)) 4282 cy += GetSystemMetrics(SM_CYEDGE); 4283 4284 if (dwStyle & WS_BORDER) 4285 { 4286 x = y = 1; 4287 cy += GetSystemMetrics(SM_CYEDGE); 4288 cx += GetSystemMetrics(SM_CYEDGE); 4289 } 4290 4291 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y, 4292 cx, cy, uPosFlags | SWP_NOZORDER); 4292 4293 } 4293 4294 return 0; … … 4301 4302 4302 4303 if (nType == GWL_STYLE) { 4303 4304 4305 4306 4307 4308 4304 if (lpStyle->styleNew & TBSTYLE_LIST) { 4305 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE; 4306 } 4307 else { 4308 infoPtr->dwDTFlags = DT_CENTER; 4309 } 4309 4310 } 4310 4311 … … 4322 4323 { 4323 4324 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE)) 4324 4325 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 4325 4326 4326 4327 switch (uMsg) 4327 4328 { 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 /* case TB_GETCOLORSCHEME:*/ /* 4.71 */4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 /* case TB_GETINSERTMARK:*/ /* 4.71 */4415 /* case TB_GETINSERTMARKCOLOR:*/ /* 4.71 */4416 4417 4418 4419 4420 4421 4422 4423 /* case TB_GETOBJECT:*/ /* 4.71 */4424 /* case TB_GETPADDING:*/ /* 4.71 */4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 /* case TB_INSERTMARKHITTEST:*/ /* 4.71 */4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 case TB_LOADIMAGES:/* 4.70 */4486 4487 4488 4489 /* case TB_MAPACCELERATORA:*/ /* 4.71 */4490 /* case TB_MAPACCELERATORW:*/ /* 4.71 */4491 /* case TB_MARKBUTTON:*/ /* 4.71 */4492 /* case TB_MOVEBUTTON:*/ /* 4.71 */4493 4494 4495 4496 4497 /* 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 /* case TB_SETCOLORSCHEME:*/ /* 4.71 */4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 /* case TB_SETINSERTMARK:*/ /* 4.71 */4550 4551 4552 4553 4554 4555 4556 4557 /* case TB_SETPADDING:*/ /* 4.71 */4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 /* 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 /* 4596 /* 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 return TOOLBAR_MouseLeave (hwnd, wParam, lParam); 4612 4613 4614 return TOOLBAR_CaptureChanged(hwnd); 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 /* 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 /* 4643 4644 /* 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4329 case TB_ADDBITMAP: 4330 return TOOLBAR_AddBitmap (hwnd, wParam, lParam); 4331 4332 case TB_ADDBUTTONSA: 4333 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam); 4334 4335 case TB_ADDBUTTONSW: 4336 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam); 4337 4338 case TB_ADDSTRINGA: 4339 return TOOLBAR_AddStringA (hwnd, wParam, lParam); 4340 4341 case TB_ADDSTRINGW: 4342 return TOOLBAR_AddStringW (hwnd, wParam, lParam); 4343 4344 case TB_AUTOSIZE: 4345 return TOOLBAR_AutoSize (hwnd); 4346 4347 case TB_BUTTONCOUNT: 4348 return TOOLBAR_ButtonCount (hwnd, wParam, lParam); 4349 4350 case TB_BUTTONSTRUCTSIZE: 4351 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam); 4352 4353 case TB_CHANGEBITMAP: 4354 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam); 4355 4356 case TB_CHECKBUTTON: 4357 return TOOLBAR_CheckButton (hwnd, wParam, lParam); 4358 4359 case TB_COMMANDTOINDEX: 4360 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam); 4361 4362 case TB_CUSTOMIZE: 4363 return TOOLBAR_Customize (hwnd); 4364 4365 case TB_DELETEBUTTON: 4366 return TOOLBAR_DeleteButton (hwnd, wParam, lParam); 4367 4368 case TB_ENABLEBUTTON: 4369 return TOOLBAR_EnableButton (hwnd, wParam, lParam); 4370 4371 case TB_GETANCHORHIGHLIGHT: 4372 return TOOLBAR_GetAnchorHighlight (hwnd); 4373 4374 case TB_GETBITMAP: 4375 return TOOLBAR_GetBitmap (hwnd, wParam, lParam); 4376 4377 case TB_GETBITMAPFLAGS: 4378 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam); 4379 4380 case TB_GETBUTTON: 4381 return TOOLBAR_GetButton (hwnd, wParam, lParam); 4382 4383 case TB_GETBUTTONINFOA: 4384 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam); 4385 4386 case TB_GETBUTTONINFOW: 4387 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam); 4388 4389 case TB_GETBUTTONSIZE: 4390 return TOOLBAR_GetButtonSize (hwnd); 4391 4392 case TB_GETBUTTONTEXTA: 4393 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam); 4394 4395 case TB_GETBUTTONTEXTW: 4396 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam); 4397 4398 /* case TB_GETCOLORSCHEME: */ /* 4.71 */ 4399 4400 case TB_GETDISABLEDIMAGELIST: 4401 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam); 4402 4403 case TB_GETEXTENDEDSTYLE: 4404 return TOOLBAR_GetExtendedStyle (hwnd); 4405 4406 case TB_GETHOTIMAGELIST: 4407 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam); 4408 4409 case TB_GETHOTITEM: 4410 return TOOLBAR_GetHotItem (hwnd); 4411 4412 case TB_GETIMAGELIST: 4413 return TOOLBAR_GetImageList (hwnd, wParam, lParam); 4414 4415 /* case TB_GETINSERTMARK: */ /* 4.71 */ 4416 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */ 4417 4418 case TB_GETITEMRECT: 4419 return TOOLBAR_GetItemRect (hwnd, wParam, lParam); 4420 4421 case TB_GETMAXSIZE: 4422 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam); 4423 4424 /* case TB_GETOBJECT: */ /* 4.71 */ 4425 /* case TB_GETPADDING: */ /* 4.71 */ 4426 4427 case TB_GETRECT: 4428 return TOOLBAR_GetRect (hwnd, wParam, lParam); 4429 4430 case TB_GETROWS: 4431 return TOOLBAR_GetRows (hwnd, wParam, lParam); 4432 4433 case TB_GETSTATE: 4434 return TOOLBAR_GetState (hwnd, wParam, lParam); 4435 4436 case TB_GETSTYLE: 4437 return TOOLBAR_GetStyle (hwnd, wParam, lParam); 4438 4439 case TB_GETTEXTROWS: 4440 return TOOLBAR_GetTextRows (hwnd, wParam, lParam); 4441 4442 case TB_GETTOOLTIPS: 4443 return TOOLBAR_GetToolTips (hwnd, wParam, lParam); 4444 4445 case TB_GETUNICODEFORMAT: 4446 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam); 4447 4448 case CCM_GETVERSION: 4449 return TOOLBAR_GetVersion (hwnd); 4450 4451 case TB_HIDEBUTTON: 4452 return TOOLBAR_HideButton (hwnd, wParam, lParam); 4453 4454 case TB_HITTEST: 4455 return TOOLBAR_HitTest (hwnd, wParam, lParam); 4456 4457 case TB_INDETERMINATE: 4458 return TOOLBAR_Indeterminate (hwnd, wParam, lParam); 4459 4460 case TB_INSERTBUTTONA: 4461 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam); 4462 4463 case TB_INSERTBUTTONW: 4464 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam); 4465 4466 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */ 4467 4468 case TB_ISBUTTONCHECKED: 4469 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam); 4470 4471 case TB_ISBUTTONENABLED: 4472 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam); 4473 4474 case TB_ISBUTTONHIDDEN: 4475 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam); 4476 4477 case TB_ISBUTTONHIGHLIGHTED: 4478 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam); 4479 4480 case TB_ISBUTTONINDETERMINATE: 4481 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam); 4482 4483 case TB_ISBUTTONPRESSED: 4484 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam); 4485 4486 case TB_LOADIMAGES: /* 4.70 */ 4487 FIXME("missing standard imagelists\n"); 4488 return 0; 4489 4490 /* case TB_MAPACCELERATORA: */ /* 4.71 */ 4491 /* case TB_MAPACCELERATORW: */ /* 4.71 */ 4492 /* case TB_MARKBUTTON: */ /* 4.71 */ 4493 /* case TB_MOVEBUTTON: */ /* 4.71 */ 4494 4495 case TB_PRESSBUTTON: 4496 return TOOLBAR_PressButton (hwnd, wParam, lParam); 4497 4498 /* case TB_REPLACEBITMAP: */ 4499 4500 case TB_SAVERESTOREA: 4501 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam); 4502 4503 case TB_SAVERESTOREW: 4504 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam); 4505 4506 case TB_SETANCHORHIGHLIGHT: 4507 return TOOLBAR_SetAnchorHighlight (hwnd, wParam); 4508 4509 case TB_SETBITMAPSIZE: 4510 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam); 4511 4512 case TB_SETBUTTONINFOA: 4513 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam); 4514 4515 case TB_SETBUTTONINFOW: 4516 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam); 4517 4518 case TB_SETBUTTONSIZE: 4519 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam); 4520 4521 case TB_SETBUTTONWIDTH: 4522 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam); 4523 4524 case TB_SETCMDID: 4525 return TOOLBAR_SetCmdId (hwnd, wParam, lParam); 4526 4527 /* case TB_SETCOLORSCHEME: */ /* 4.71 */ 4528 4529 case TB_SETDISABLEDIMAGELIST: 4530 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam); 4531 4532 case TB_SETDRAWTEXTFLAGS: 4533 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam); 4534 4535 case TB_SETEXTENDEDSTYLE: 4536 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam); 4537 4538 case TB_SETHOTIMAGELIST: 4539 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam); 4540 4541 case TB_SETHOTITEM: 4542 return TOOLBAR_SetHotItem (hwnd, wParam); 4543 4544 case TB_SETIMAGELIST: 4545 return TOOLBAR_SetImageList (hwnd, wParam, lParam); 4546 4547 case TB_SETINDENT: 4548 return TOOLBAR_SetIndent (hwnd, wParam, lParam); 4549 4550 /* case TB_SETINSERTMARK: */ /* 4.71 */ 4551 4552 case TB_SETINSERTMARKCOLOR: 4553 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam); 4554 4555 case TB_SETMAXTEXTROWS: 4556 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam); 4557 4558 /* case TB_SETPADDING: */ /* 4.71 */ 4559 4560 case TB_SETPARENT: 4561 return TOOLBAR_SetParent (hwnd, wParam, lParam); 4562 4563 case TB_SETROWS: 4564 return TOOLBAR_SetRows (hwnd, wParam, lParam); 4565 4566 case TB_SETSTATE: 4567 return TOOLBAR_SetState (hwnd, wParam, lParam); 4568 4569 case TB_SETSTYLE: 4570 return TOOLBAR_SetStyle (hwnd, wParam, lParam); 4571 4572 case TB_SETTOOLTIPS: 4573 return TOOLBAR_SetToolTips (hwnd, wParam, lParam); 4574 4575 case TB_SETUNICODEFORMAT: 4576 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam); 4577 4578 case CCM_SETVERSION: 4579 return TOOLBAR_SetVersion (hwnd, (INT)wParam); 4580 4581 4582 /* case WM_CHAR: */ 4583 4584 case WM_CREATE: 4585 return TOOLBAR_Create (hwnd, wParam, lParam); 4586 4587 case WM_DESTROY: 4588 return TOOLBAR_Destroy (hwnd, wParam, lParam); 4589 4590 case WM_ERASEBKGND: 4591 return TOOLBAR_EraseBackground (hwnd, wParam, lParam); 4592 4593 case WM_GETFONT: 4594 return TOOLBAR_GetFont (hwnd, wParam, lParam); 4595 4596 /* case WM_KEYDOWN: */ 4597 /* case WM_KILLFOCUS: */ 4598 4599 case WM_LBUTTONDBLCLK: 4600 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam); 4601 4602 case WM_LBUTTONDOWN: 4603 return TOOLBAR_LButtonDown (hwnd, wParam, lParam); 4604 4605 case WM_LBUTTONUP: 4606 return TOOLBAR_LButtonUp (hwnd, wParam, lParam); 4607 4608 case WM_MOUSEMOVE: 4609 return TOOLBAR_MouseMove (hwnd, wParam, lParam); 4610 4611 case WM_MOUSELEAVE: 4612 return TOOLBAR_MouseLeave (hwnd, wParam, lParam); 4613 4614 case WM_CAPTURECHANGED: 4615 return TOOLBAR_CaptureChanged(hwnd); 4616 4617 case WM_NCACTIVATE: 4618 return TOOLBAR_NCActivate (hwnd, wParam, lParam); 4619 4620 case WM_NCCALCSIZE: 4621 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam); 4622 4623 case WM_NCCREATE: 4624 return TOOLBAR_NCCreate (hwnd, wParam, lParam); 4625 4626 case WM_NCPAINT: 4627 return TOOLBAR_NCPaint (hwnd, wParam, lParam); 4628 4629 case WM_NOTIFY: 4630 return TOOLBAR_Notify (hwnd, wParam, lParam); 4631 4632 /* case WM_NOTIFYFORMAT: */ 4633 4634 case WM_PAINT: 4635 return TOOLBAR_Paint (hwnd, wParam); 4636 4637 case WM_SIZE: 4638 return TOOLBAR_Size (hwnd, wParam, lParam); 4639 4640 case WM_STYLECHANGED: 4641 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam); 4642 4643 /* case WM_SYSCOLORCHANGE: */ 4644 4645 /* case WM_WININICHANGE: */ 4646 4647 case WM_CHARTOITEM: 4648 case WM_COMMAND: 4649 case WM_DRAWITEM: 4650 case WM_MEASUREITEM: 4651 case WM_VKEYTOITEM: 4652 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); 4653 4654 default: 4655 if (uMsg >= WM_USER) 4656 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 4657 uMsg, wParam, lParam); 4658 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 4658 4659 } 4659 4660 return 0; … … 4674 4675 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 4675 4676 wndClass.lpszClassName = TOOLBARCLASSNAMEA; 4676 4677 4677 4678 RegisterClassA (&wndClass); 4678 4679 }
Note:
See TracChangeset
for help on using the changeset viewer.