Changeset 2126 for trunk/src/comctl32/toolbar.c
- Timestamp:
- Dec 18, 1999, 9:57:01 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/toolbar.c
r1776 r2126 1 /* $Id: toolbar.c,v 1.1 8 1999-11-19 16:19:22achimha Exp $ */1 /* $Id: toolbar.c,v 1.19 1999-12-18 20:57:01 achimha Exp $ */ 2 2 /* 3 3 * Toolbar control … … 10 10 * - A little bug in TOOLBAR_DrawMasked() 11 11 * - Button wrapping (under construction). 12 * - Messages .12 * - Messages (under construction). 13 13 * - Notifications. 14 14 * - Fix TB_SETROWS. 15 15 * - Tooltip support (almost complete). 16 * - Fix TOOLBAR_SetButtonInfo32A. 16 * - Unicode support (under construction). 17 * - Fix TOOLBAR_SetButtonInfo32A/W. 17 18 * - Drag & drop of buttons 18 19 * … … 27 28 */ 28 29 29 /* WINE 991 114level */30 /* WINE 991212 level */ 30 31 31 32 /* CB: Odin32/WINE bugs … … 68 69 static void 69 70 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 70 HDC hdc, INT nState )71 HDC hdc, INT nState, DWORD dwStyle) 71 72 { 72 73 RECT rcText = btnPtr->rect; … … 78 79 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) { 79 80 InflateRect (&rcText, -3, -3); 80 rcText.top += infoPtr->nBitmapHeight; 81 if (dwStyle & TBSTYLE_LIST) { 82 rcText.left += infoPtr->nBitmapWidth; 83 } 84 else { 85 rcText.top += infoPtr->nBitmapHeight; 86 } 81 87 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED)) 82 88 OffsetRect (&rcText, 1, 1); … … 209 215 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 210 216 211 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState );217 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 212 218 return; 213 219 } … … 216 222 if (btnPtr->fsState & TBSTATE_PRESSED) 217 223 { 218 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 224 if (dwStyle & TBSTYLE_FLAT) 225 DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST); 226 else 227 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 219 228 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 220 229 rc.left+2, rc.top+2, ILD_NORMAL); 221 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState );230 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 222 231 return; 223 232 } … … 238 247 rc.left+2, rc.top+2, ILD_NORMAL); 239 248 240 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState );249 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 241 250 return; 242 251 } … … 250 259 TOOLBAR_DrawPattern (hdc, &rc); 251 260 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 252 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState );261 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 253 262 return; 254 263 } … … 258 267 { 259 268 if(btnPtr->bHot) 260 DrawEdge (hdc, &rc, BDR_RAISEDINNER, 261 BF_RECT | BF_MIDDLE | BF_SOFT); 269 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); 262 270 263 271 if(btnPtr->bHot && infoPtr->himlHot) … … 276 284 } 277 285 278 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState );286 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 279 287 } 280 288 … … 342 350 343 351 static void 344 TOOLBAR_WrapToolbar( HWND hwnd )352 TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle ) 345 353 { 346 354 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 347 355 TBUTTON_INFO *btnPtr; 348 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);349 356 INT x, cx, i, j; 350 357 RECT rc; … … 491 498 { 492 499 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd); 500 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); 493 501 TBUTTON_INFO *btnPtr; 494 502 INT i, nRows, nSepRows; … … 500 508 TOOLBAR_CalcStrings (hwnd, &sizeString); 501 509 502 if (sizeString.cy > 0) 503 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6; 504 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) 505 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; 506 507 if (sizeString.cx > infoPtr->nBitmapWidth) 508 infoPtr->nButtonWidth = sizeString.cx + 6; 509 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6) 510 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6; 511 512 TOOLBAR_WrapToolbar( hwnd ); 510 if (dwStyle & TBSTYLE_LIST) { 511 infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6; 512 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6; 513 } 514 else { 515 if (sizeString.cy > 0) 516 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6; 517 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) 518 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; 519 520 if (sizeString.cx > infoPtr->nBitmapWidth) 521 infoPtr->nButtonWidth = sizeString.cx + 6; 522 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6) 523 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6; 524 } 525 526 TOOLBAR_WrapToolbar( hwnd, dwStyle ); 513 527 514 528 x = infoPtr->nIndent; 515 y = TOP_BORDER;529 y = (dwStyle & TBSTYLE_FLAT) ? 0: TOP_BORDER; 516 530 cx = infoPtr->nButtonWidth; 517 531 cy = infoPtr->nButtonHeight; … … 1557 1571 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 1558 1572 { 1559 TOOLBAR_INFO *infoPtr; 1573 TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER); 1574 static HDSA hDsa = NULL; 1560 1575 1561 1576 switch (uMsg) 1562 1577 { 1563 case WM_INITDIALOG: 1564 return TBCUSTOMIZE_InitDialog(hwnd,wParam,lParam); 1565 1566 case WM_CLOSE: 1567 return TBCUSTOMIZE_Close(hwnd,wParam,lParam); 1568 1569 case WM_COMMAND: 1570 return TBCUSTOMIZE_Command(hwnd,wParam,lParam); 1571 1572 case WM_DESTROY: 1573 return TBCUSTOMIZE_Destroy(hwnd,wParam,lParam); 1574 1575 case WM_DRAWITEM: 1576 return TBCUSTOMIZE_DrawItem(hwnd,wParam,lParam); 1577 1578 case WM_MEASUREITEM: 1579 return TBCUSTOMIZE_MeasureItem(hwnd,wParam,lParam); 1580 1581 default: 1582 return FALSE; 1578 case WM_INITDIALOG: 1579 infoPtr = (TOOLBAR_INFO *)lParam; 1580 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr); 1581 1582 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5); 1583 1584 if (infoPtr) 1585 { 1586 TBUTTON_INFO *btnPtr; 1587 INT i; 1588 1589 /* insert 'virtual' separator button into 'available buttons' list */ 1590 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 1591 1592 /* copy all buttons and append them to the right listbox */ 1593 btnPtr = infoPtr->buttons; 1594 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 1595 { 1596 DSA_InsertItem (hDsa, i, btnPtr); 1597 1598 /* FIXME: hidden buttons appear in the 'toolbar buttons' list too */ 1599 if (btnPtr->fsState & TBSTATE_HIDDEN) 1600 { 1601 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 1602 } 1603 else 1604 { 1605 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 1606 } 1607 } 1608 1609 /* append 'virtual' separator button to the 'toolbar buttons' list */ 1610 /* TODO */ 1611 } 1612 return TRUE; 1613 1614 case WM_CLOSE: 1615 EndDialog(hwnd, FALSE); 1616 return TRUE; 1617 1618 case WM_COMMAND: 1619 switch (LOWORD(wParam)) 1620 { 1621 case IDCANCEL: 1622 EndDialog(hwnd, FALSE); 1623 break; 1624 } 1625 return TRUE; 1626 1627 case WM_DESTROY: 1628 if (hDsa) 1629 DSA_Destroy (hDsa); 1630 return TRUE; 1631 1632 case WM_DRAWITEM: 1633 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1634 { 1635 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 1636 TBUTTON_INFO btnPtr; 1637 RECT rcButton; 1638 RECT rcText; 1639 HPEN hOldPen; 1640 HBRUSH hOldBrush; 1641 COLORREF oldText = 0; 1642 COLORREF oldBk = 0; 1643 1644 FIXME("action: %x itemState: %x\n", 1645 lpdis->itemAction, lpdis->itemState); 1646 1647 DSA_GetItem (hDsa, 0 /*lpdis->itemID*/, &btnPtr); 1648 1649 if (lpdis->itemState & ODS_FOCUS) 1650 { 1651 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); 1652 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 1653 } 1654 1655 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1656 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1657 1658 /* fill background rectangle */ 1659 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, 1660 lpdis->rcItem.right, lpdis->rcItem.bottom); 1661 1662 /* calculate button and text rectangles */ 1663 CopyRect (&rcButton, &lpdis->rcItem); 1664 InflateRect (&rcButton, -1, -1); 1665 CopyRect (&rcText, &rcButton); 1666 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6; 1667 rcText.left = rcButton.right + 2; 1668 1669 /* draw focus rectangle */ 1670 if (lpdis->itemState & ODS_FOCUS) 1671 DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1672 1673 /* draw button */ 1674 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); 1675 1676 /* draw image and text */ 1677 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0) 1678 { 1679 /* virtual separator in the 'available' list */ 1680 DrawTextA (lpdis->hDC, "Separator", -1, &rcText, 1681 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1682 } 1683 else 1684 { 1685 /* real button */ 1686 1687 ImageList_Draw (infoPtr->himlDef, btnPtr.iBitmap, lpdis->hDC, 1688 rcButton.left+1, rcButton.top+1, ILD_NORMAL); 1689 1690 DrawTextW (lpdis->hDC, infoPtr->strings[btnPtr.iString], -1, &rcText, 1691 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1692 1693 } 1694 1695 if (lpdis->itemState & ODS_FOCUS) 1696 { 1697 SetBkColor (lpdis->hDC, oldBk); 1698 SetTextColor (lpdis->hDC, oldText); 1699 } 1700 1701 SelectObject (lpdis->hDC, hOldBrush); 1702 SelectObject (lpdis->hDC, hOldPen); 1703 1704 return TRUE; 1705 } 1706 return FALSE; 1707 1708 case WM_MEASUREITEM: 1709 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1710 { 1711 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 1712 1713 if (infoPtr) 1714 lpmis->itemHeight = infoPtr->nBitmapHeight + 8; 1715 else 1716 lpmis->itemHeight = 16 + 8; /* default height */ 1717 1718 return TRUE; 1719 } 1720 return FALSE; 1721 1722 default: 1723 return FALSE; 1583 1724 } 1584 1725 } … … 1795 1936 } 1796 1937 1797 1798 static LRESULT TOOLBAR_AddButtonsW(HWND hwnd,WPARAM wParam,LPARAM lParam) 1799 { 1800 //CB: just call AddButtonsA, no Unicode used?!? 1801 1802 return TOOLBAR_AddButtonsA(hwnd,wParam,lParam); 1803 } 1804 1805 /* << TOOLBAR_AddButtons32W >> */ 1938 static LRESULT 1939 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam) 1940 { 1941 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1942 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam; 1943 INT nOldButtons, nNewButtons, nAddButtons, nCount; 1944 1945 TRACE("adding %d buttons!\n", wParam); 1946 1947 nAddButtons = (UINT)wParam; 1948 nOldButtons = infoPtr->nNumButtons; 1949 nNewButtons = nOldButtons + nAddButtons; 1950 1951 if (infoPtr->nNumButtons == 0) { 1952 infoPtr->buttons = 1953 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1954 } 1955 else { 1956 TBUTTON_INFO *oldButtons = infoPtr->buttons; 1957 infoPtr->buttons = 1958 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1959 memcpy (&infoPtr->buttons[0], &oldButtons[0], 1960 nOldButtons * sizeof(TBUTTON_INFO)); 1961 COMCTL32_Free (oldButtons); 1962 } 1963 1964 infoPtr->nNumButtons = nNewButtons; 1965 1966 /* insert new button data */ 1967 for (nCount = 0; nCount < nAddButtons; nCount++) { 1968 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 1969 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 1970 btnPtr->idCommand = lpTbb[nCount].idCommand; 1971 btnPtr->fsState = lpTbb[nCount].fsState; 1972 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 1973 btnPtr->dwData = lpTbb[nCount].dwData; 1974 btnPtr->iString = lpTbb[nCount].iString; 1975 btnPtr->bHot = FALSE; 1976 1977 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 1978 TTTOOLINFOW ti; 1979 1980 ZeroMemory (&ti, sizeof(TTTOOLINFOW)); 1981 ti.cbSize = sizeof (TTTOOLINFOW); 1982 ti.hwnd = hwnd; 1983 ti.uId = btnPtr->idCommand; 1984 ti.hinst = 0; 1985 ti.lpszText = LPSTR_TEXTCALLBACKW; 1986 1987 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 1988 0, (LPARAM)&ti); 1989 } 1990 } 1991 1992 TOOLBAR_CalcToolbar (hwnd); 1993 1994 InvalidateRect(hwnd, NULL, FALSE); 1995 1996 return TRUE; 1997 } 1806 1998 1807 1999 … … 1951 2143 1952 2144 static LRESULT 1953 TOOLBAR_AutoSize (HWND hwnd , WPARAM wParam, LPARAM lParam)2145 TOOLBAR_AutoSize (HWND hwnd) 1954 2146 { 1955 2147 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); … … 2218 2410 2219 2411 2220 /* << TOOLBAR_GetAnchorHighlight >> */ 2412 static LRESULT 2413 TOOLBAR_GetAnchorHighlight (HWND hwnd) 2414 { 2415 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2416 2417 return infoPtr->bAnchor; 2418 } 2221 2419 2222 2420 … … 2356 2554 } 2357 2555 2358 /* << TOOLBAR_GetButtonInfo32W >> */2359 2360 2556 2361 2557 static LRESULT … … 2447 2643 2448 2644 2449 /* << TOOLBAR_GetHotItem >> */ 2645 static LRESULT 2646 TOOLBAR_GetHotItem (HWND hwnd) 2647 { 2648 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2649 2650 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)) 2651 return -1; 2652 2653 if (infoPtr->nHotItem < 0) 2654 return -1; 2655 2656 return (LRESULT)infoPtr->nHotItem; 2657 } 2450 2658 2451 2659 … … 2618 2826 } 2619 2827 2828 static LRESULT 2829 TOOLBAR_GetVersion (HWND hwnd) 2830 { 2831 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2832 return infoPtr->iVersion; 2833 } 2620 2834 2621 2835 static LRESULT … … 2687 2901 if (lpTbb == NULL) 2688 2902 return FALSE; 2689 if (nIndex < 0) 2690 return FALSE; 2903 2904 if (nIndex == -1) { 2905 /* EPP: this seems to be an undocumented call (from my IE4) 2906 * I assume in that case that: 2907 * - lpTbb->iString is a string pointer (not a string index in strings[] table 2908 * - index of insertion is at the end of existing buttons 2909 * I only see this happen with nIndex == -1, but it could have a special 2910 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion). 2911 */ 2912 int len = lstrlenA((char*)lpTbb->iString) + 2; 2913 LPSTR ptr = COMCTL32_Alloc(len); 2914 2915 nIndex = infoPtr->nNumButtons; 2916 strcpy(ptr, (char*)lpTbb->iString); 2917 ptr[len - 1] = 0; /* ended by two '\0' */ 2918 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr); 2919 COMCTL32_Free(ptr); 2920 2921 } else if (nIndex < 0) 2922 return FALSE; 2923 2691 2924 2692 2925 // TRACE (toolbar, "inserting button index=%d\n", nIndex); … … 2930 3163 2931 3164 /* << TOOLBAR_SaveRestore32W >> */ 2932 /* << TOOLBAR_SetAnchorHighlight >> */ 3165 3166 static LRESULT 3167 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam) 3168 { 3169 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3170 BOOL bOldAnchor = infoPtr->bAnchor; 3171 3172 infoPtr->bAnchor = (BOOL)wParam; 3173 3174 return (LRESULT)bOldAnchor; 3175 } 2933 3176 2934 3177 … … 3155 3398 3156 3399 3157 /* << TOOLBAR_SetHotItem >> */ 3400 static LRESULT 3401 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam) 3402 { 3403 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd); 3404 INT nOldHotItem = infoPtr->nHotItem; 3405 3406 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 3407 { 3408 infoPtr->nHotItem = (INT)wParam; 3409 3410 /* FIXME: What else must be done ??? */ 3411 3412 } 3413 3414 if (nOldHotItem < 0) 3415 return -1; 3416 3417 return (LRESULT)nOldHotItem; 3418 } 3158 3419 3159 3420 … … 3345 3606 } 3346 3607 3608 static LRESULT 3609 TOOLBAR_SetVersion (HWND hwnd, INT iVersion) 3610 { 3611 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3612 INT iOldVersion = infoPtr->iVersion; 3613 3614 infoPtr->iVersion = iVersion; 3615 3616 return iOldVersion; 3617 } 3347 3618 3348 3619 static LRESULT … … 3372 3643 infoPtr->hwndNotify = GetParent (hwnd); 3373 3644 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT); 3374 infoPtr->dwDTFlags = DT_CENTER; 3645 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER; 3646 infoPtr->bAnchor = FALSE; /* no anchor highlighting */ 3647 infoPtr->iVersion = 0; 3375 3648 3376 3649 infoPtr->hwndToolbar = hwnd; … … 3446 3719 /* free toolbar info data */ 3447 3720 COMCTL32_Free (infoPtr); 3721 SetWindowLongA(hwnd, 0, 0); 3448 3722 3449 3723 return 0; … … 3526 3800 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 3527 3801 return 0; 3802 3803 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) 3804 { 3805 NMTOOLBARA nmtb; 3806 3807 nmtb.hdr.hwndFrom = hwnd; 3808 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3809 nmtb.hdr.code = TBN_DROPDOWN; 3810 nmtb.iItem = btnPtr->idCommand; 3811 3812 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 3813 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 3814 } 3528 3815 3529 3816 SetCapture (hwnd); … … 3597 3884 ReleaseDC (hwnd, hdc); 3598 3885 3599 if (bSendMessage) 3600 SendMessageA (infoPtr->hwndNotify, WM_COMMAND, 3601 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 3886 if (bSendMessage) { 3887 SendMessageA (GetParent(hwnd), WM_COMMAND, 3888 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 3889 3890 if ((GetWindowLongA(hwnd, GWL_STYLE) & TBSTYLE_DROPDOWN) || 3891 (btnPtr->fsStyle & 0x08/* BTNS_DROPDOWN */)) { 3892 NMTOOLBARW nmtb; 3893 3894 nmtb.hdr.hwndFrom = hwnd; 3895 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3896 nmtb.hdr.code = TBN_DROPDOWN; 3897 nmtb.iItem = nHit; 3898 /* nmtb.tbButton not used with TBN_DROPDOWN */ 3899 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) { 3900 nmtb.pszText = infoPtr->strings[btnPtr->iString]; 3901 nmtb.cchText = lstrlenW(nmtb.pszText); 3902 } else { 3903 nmtb.pszText = NULL; 3904 nmtb.cchText = 0; 3905 } 3906 nmtb.rcButton = btnPtr->rect; 3907 3908 SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, 3909 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 3910 } 3911 } 3602 3912 3603 3913 infoPtr->nButtonDown = -1; … … 3867 4177 3868 4178 static LRESULT 3869 TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam) 3870 { 3871 TOOLBAR_AutoSize (hwnd, wParam, lParam); 4179 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle) 4180 { 4181 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 4182 4183 if (nType == GWL_STYLE) { 4184 if (lpStyle->styleNew & TBSTYLE_LIST) { 4185 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE; 4186 } 4187 else { 4188 infoPtr->dwDTFlags = DT_CENTER; 4189 } 4190 } 4191 4192 TOOLBAR_AutoSize (hwnd); 3872 4193 3873 4194 InvalidateRect(hwnd, NULL, FALSE); … … 3881 4202 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 3882 4203 { 4204 switch (uMsg) 4205 { 4206 case WM_DESTROY: 4207 return TOOLBAR_Destroy (hwnd, wParam, lParam); 4208 4209 case WM_NCCREATE: 4210 return TOOLBAR_NCCreate (hwnd, wParam, lParam); 4211 } 4212 4213 if (!TOOLBAR_GetInfoPtr (hwnd)) 4214 { 4215 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 4216 } 4217 3883 4218 switch (uMsg) 3884 4219 { … … 3898 4233 return TOOLBAR_AddStringW (hwnd, wParam, lParam); 3899 4234 3900 3901 return TOOLBAR_AutoSize (hwnd, wParam, lParam);4235 case TB_AUTOSIZE: 4236 return TOOLBAR_AutoSize (hwnd); 3902 4237 3903 4238 case TB_BUTTONCOUNT: … … 3925 4260 return TOOLBAR_EnableButton (hwnd, wParam, lParam); 3926 4261 3927 /* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */ 4262 case TB_GETANCHORHIGHLIGHT: 4263 return TOOLBAR_GetAnchorHighlight (hwnd); 3928 4264 3929 4265 case TB_GETBITMAP: … … 3962 4298 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam); 3963 4299 3964 /* case TB_GETHOTITEM: */ /* 4.71 */ 4300 case TB_GETHOTITEM: 4301 return TOOLBAR_GetHotItem (hwnd); 3965 4302 3966 4303 case TB_GETIMAGELIST: … … 3999 4336 case TB_GETUNICODEFORMAT: 4000 4337 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam); 4338 4339 case CCM_GETVERSION: 4340 return TOOLBAR_GetVersion (hwnd); 4001 4341 4002 4342 case TB_HIDEBUTTON: … … 4054 4394 return TOOLBAR_SaveRestoreW(hwnd,wParam,lParam); 4055 4395 4056 /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */ 4396 case TB_SETANCHORHIGHLIGHT: 4397 return TOOLBAR_SetAnchorHighlight (hwnd, wParam); 4057 4398 4058 4399 case TB_SETBITMAPSIZE: … … 4088 4429 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam); 4089 4430 4090 /* case TB_SETHOTITEM: */ /* 4.71 */ 4431 case TB_SETHOTITEM: 4432 return TOOLBAR_SetHotItem (hwnd, wParam); 4091 4433 4092 4434 case TB_SETIMAGELIST: … … 4124 4466 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam); 4125 4467 4468 case CCM_SETVERSION: 4469 return TOOLBAR_SetVersion (hwnd, (INT)wParam); 4126 4470 4127 4471 /* case WM_CHAR: */ … … 4130 4474 return TOOLBAR_Create (hwnd, wParam, lParam); 4131 4475 4132 case WM_DESTROY:4133 return TOOLBAR_Destroy (hwnd, wParam, lParam);4134 4135 4476 case WM_ERASEBKGND: 4136 4477 return TOOLBAR_EraseBackground (hwnd, wParam, lParam); … … 4160 4501 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam); 4161 4502 4162 case WM_NCCREATE:4163 return TOOLBAR_NCCreate (hwnd, wParam, lParam);4164 4165 4503 case WM_NCPAINT: 4166 4504 return TOOLBAR_NCPaint (hwnd, wParam, lParam); … … 4177 4515 return TOOLBAR_Size (hwnd, wParam, lParam); 4178 4516 4179 4180 return TOOLBAR_StyleChanged (hwnd, wParam,lParam);4517 case WM_STYLECHANGED: 4518 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam); 4181 4519 4182 4520 /* case WM_SYSCOLORCHANGE: */
Note:
See TracChangeset
for help on using the changeset viewer.