Ignore:
Timestamp:
Dec 18, 1999, 9:57:01 PM (26 years ago)
Author:
achimha
Message:

WINE 991212 updates - treeview missing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/toolbar.c

    r1776 r2126  
    1 /* $Id: toolbar.c,v 1.18 1999-11-19 16:19:22 achimha Exp $ */
     1/* $Id: toolbar.c,v 1.19 1999-12-18 20:57:01 achimha Exp $ */
    22/*
    33 * Toolbar control
     
    1010 *   - A little bug in TOOLBAR_DrawMasked()
    1111 *   - Button wrapping (under construction).
    12  *   - Messages.
     12 *   - Messages (under construction).
    1313 *   - Notifications.
    1414 *   - Fix TB_SETROWS.
    1515 *   - Tooltip support (almost complete).
    16  *   - Fix TOOLBAR_SetButtonInfo32A.
     16 *   - Unicode support (under construction).
     17 *   - Fix TOOLBAR_SetButtonInfo32A/W.
    1718 *   - Drag & drop of buttons
    1819 *
     
    2728 */
    2829
    29 /* WINE 991114 level */
     30/* WINE 991212 level */
    3031
    3132/* CB: Odin32/WINE bugs
     
    6869static void
    6970TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    70                     HDC hdc, INT nState)
     71                    HDC hdc, INT nState, DWORD dwStyle)
    7172{
    7273    RECT   rcText = btnPtr->rect;
     
    7879    if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
    7980        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        }
    8187        if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
    8288            OffsetRect (&rcText, 1, 1);
     
    209215        TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
    210216
    211       TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
     217      TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    212218      return;
    213219    }
     
    216222    if (btnPtr->fsState & TBSTATE_PRESSED)
    217223    {
    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);
    219228      ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    220229                      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);
    222231      return;
    223232    }
     
    238247                        rc.left+2, rc.top+2, ILD_NORMAL);
    239248
    240         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
     249        TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    241250        return;
    242251    }
     
    250259      TOOLBAR_DrawPattern (hdc, &rc);
    251260      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);
    253262      return;
    254263    }
     
    258267    {
    259268      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);
    262270
    263271      if(btnPtr->bHot && infoPtr->himlHot)
     
    276284    }
    277285
    278     TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
     286    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    279287}
    280288
     
    342350
    343351static void
    344 TOOLBAR_WrapToolbar( HWND hwnd )
     352TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
    345353{
    346354    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    347355    TBUTTON_INFO *btnPtr;
    348     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    349356    INT x, cx, i, j;
    350357    RECT rc;
     
    491498{
    492499    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
     500    DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
    493501    TBUTTON_INFO *btnPtr;
    494502    INT i, nRows, nSepRows;
     
    500508    TOOLBAR_CalcStrings (hwnd, &sizeString);
    501509
    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 );
    513527
    514528    x  = infoPtr->nIndent;
    515     y  = TOP_BORDER;
     529    y  = (dwStyle & TBSTYLE_FLAT) ? 0: TOP_BORDER;
    516530    cx = infoPtr->nButtonWidth;
    517531    cy = infoPtr->nButtonHeight;
     
    15571571TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    15581572{
    1559     TOOLBAR_INFO *infoPtr;
     1573    TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER);
     1574    static HDSA hDsa = NULL;
    15601575
    15611576    switch (uMsg)
    15621577    {
    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;
    15831724    }
    15841725}
     
    17951936}
    17961937
    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 >> */
     1938static LRESULT
     1939TOOLBAR_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}
    18061998
    18071999
     
    19512143
    19522144static LRESULT
    1953 TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
     2145TOOLBAR_AutoSize (HWND hwnd)
    19542146{
    19552147    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     
    22182410
    22192411
    2220 /* << TOOLBAR_GetAnchorHighlight >> */
     2412static LRESULT
     2413TOOLBAR_GetAnchorHighlight (HWND hwnd)
     2414{
     2415    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     2416
     2417    return infoPtr->bAnchor;
     2418}
    22212419
    22222420
     
    23562554}
    23572555
    2358 /* << TOOLBAR_GetButtonInfo32W >> */
    2359 
    23602556
    23612557static LRESULT
     
    24472643
    24482644
    2449 /* << TOOLBAR_GetHotItem >> */
     2645static LRESULT
     2646TOOLBAR_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}
    24502658
    24512659
     
    26182826}
    26192827
     2828static LRESULT
     2829TOOLBAR_GetVersion (HWND hwnd)
     2830{
     2831    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     2832    return infoPtr->iVersion;
     2833}
    26202834
    26212835static LRESULT
     
    26872901    if (lpTbb == NULL)
    26882902        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
    26912924
    26922925//    TRACE (toolbar, "inserting button index=%d\n", nIndex);
     
    29303163
    29313164/* << TOOLBAR_SaveRestore32W >> */
    2932 /* << TOOLBAR_SetAnchorHighlight >> */
     3165
     3166static LRESULT
     3167TOOLBAR_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}
    29333176
    29343177
     
    31553398
    31563399
    3157 /* << TOOLBAR_SetHotItem >> */
     3400static LRESULT
     3401TOOLBAR_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}
    31583419
    31593420
     
    33453606}
    33463607
     3608static LRESULT
     3609TOOLBAR_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}
    33473618
    33483619static LRESULT
     
    33723643    infoPtr->hwndNotify = GetParent (hwnd);
    33733644    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;
    33753648
    33763649    infoPtr->hwndToolbar = hwnd;
     
    34463719    /* free toolbar info data */
    34473720    COMCTL32_Free (infoPtr);
     3721    SetWindowLongA(hwnd, 0, 0);
    34483722
    34493723    return 0;
     
    35263800        if (!(btnPtr->fsState & TBSTATE_ENABLED))
    35273801            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        }
    35283815
    35293816        SetCapture (hwnd);
     
    35973884        ReleaseDC (hwnd, hdc);
    35983885
    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        }
    36023912
    36033913        infoPtr->nButtonDown = -1;
     
    38674177
    38684178static LRESULT
    3869 TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
    3870 {
    3871     TOOLBAR_AutoSize (hwnd, wParam, lParam);
     4179TOOLBAR_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);
    38724193
    38734194    InvalidateRect(hwnd, NULL, FALSE);
     
    38814202ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    38824203{
     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
    38834218    switch (uMsg)
    38844219    {
     
    38984233            return TOOLBAR_AddStringW (hwnd, wParam, lParam);
    38994234
    3900         case TB_AUTOSIZE:
    3901             return TOOLBAR_AutoSize (hwnd, wParam, lParam);
     4235        case TB_AUTOSIZE:
     4236            return TOOLBAR_AutoSize (hwnd);
    39024237
    39034238        case TB_BUTTONCOUNT:
     
    39254260            return TOOLBAR_EnableButton (hwnd, wParam, lParam);
    39264261
    3927 /*      case TB_GETANCHORHIGHLIGHT:             */ /* 4.71 */
     4262        case TB_GETANCHORHIGHLIGHT:
     4263            return TOOLBAR_GetAnchorHighlight (hwnd);
    39284264
    39294265        case TB_GETBITMAP:
     
    39624298            return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
    39634299
    3964 /*      case TB_GETHOTITEM:                     */ /* 4.71 */
     4300        case TB_GETHOTITEM:
     4301            return TOOLBAR_GetHotItem (hwnd);
    39654302
    39664303        case TB_GETIMAGELIST:
     
    39994336        case TB_GETUNICODEFORMAT:
    40004337            return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
     4338
     4339        case CCM_GETVERSION:
     4340            return TOOLBAR_GetVersion (hwnd);
    40014341
    40024342        case TB_HIDEBUTTON:
     
    40544394            return TOOLBAR_SaveRestoreW(hwnd,wParam,lParam);
    40554395
    4056 /*      case TB_SETANCHORHIGHLIGHT:             */ /* 4.71 */
     4396        case TB_SETANCHORHIGHLIGHT:
     4397            return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
    40574398
    40584399        case TB_SETBITMAPSIZE:
     
    40884429            return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
    40894430
    4090 /*      case TB_SETHOTITEM:                     */ /* 4.71 */
     4431        case TB_SETHOTITEM:
     4432            return TOOLBAR_SetHotItem (hwnd, wParam);
    40914433
    40924434        case TB_SETIMAGELIST:
     
    41244466            return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
    41254467
     4468        case CCM_SETVERSION:
     4469            return TOOLBAR_SetVersion (hwnd, (INT)wParam);
    41264470
    41274471/*      case WM_CHAR: */
     
    41304474            return TOOLBAR_Create (hwnd, wParam, lParam);
    41314475
    4132         case WM_DESTROY:
    4133             return TOOLBAR_Destroy (hwnd, wParam, lParam);
    4134 
    41354476        case WM_ERASEBKGND:
    41364477            return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
     
    41604501            return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
    41614502
    4162         case WM_NCCREATE:
    4163             return TOOLBAR_NCCreate (hwnd, wParam, lParam);
    4164 
    41654503        case WM_NCPAINT:
    41664504            return TOOLBAR_NCPaint (hwnd, wParam, lParam);
     
    41774515            return TOOLBAR_Size (hwnd, wParam, lParam);
    41784516
    4179         case WM_STYLECHANGED:
    4180             return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
     4517        case WM_STYLECHANGED:
     4518            return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
    41814519
    41824520/*      case WM_SYSCOLORCHANGE: */
Note: See TracChangeset for help on using the changeset viewer.