Ignore:
Timestamp:
Apr 29, 2001, 12:30:59 PM (24 years ago)
Author:
sandervl
Message:

wine resync

File:
1 edited

Legend:

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

    r5416 r5630  
    1919
    2020/*
    21  * ComboBoxEx control v2 (mod4)
     21 * ComboBoxEx control v2 (mod5)
    2222 *
    2323 * Copyright 1998, 1999 Eric Kohl
     
    5959 *   5. The LBN_SELCHANGE is just for documentation purposes.
    6060 *
     61 *  mod 5
     62 *   1. Add support for CB_GETITEMDATA to a Comboex. Returns the LPARAM
     63 *      passed during insert of item.
     64 *   2. Remember selected item and don't issue CB_SETCURSEL unless needed.
     65 *   3. Add initial support for WM_NCCREATE to remove unwanted window styles
     66 *      (Currently just WS_VSCROLL and WS_HSCROLL, but probably should be
     67 *       more.)
     68 *   4. Improve some traces.
     69 *   5. Add support for CB_SETITEMDATA sets LPARAM value from item.
     70 *
    6171 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe),
    62  *  and IE 4.0.
     72 *  WinRAR, and IE 4.0.
    6373 *
    6474 */
     
    6979#include "debugtools.h"
    7080#include "wine/unicode.h"
    71 
    7281#ifdef __WIN32OS2__
    7382#include "ccbase.h"
     
    109118    WNDPROC      prevComboWndProc;   /* previous Combo WNDPROC value */
    110119    DWORD        dwExtStyle;
     120    INT          selected;         /* index of selected item */
    111121    DWORD        flags;            /* WINE internal flags */
    112122    HFONT        font;
     
    882892
    883893static LRESULT
     894COMBOEX_GetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam)
     895{
     896    INT index = wParam;
     897    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     898    CBE_ITEMDATA *item1, *item2;
     899    LRESULT lret = 0;
     900
     901    item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
     902                                             wParam, lParam);
     903    if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
     904        item2 = COMBOEX_FindItem (infoPtr, index);
     905        if (item2 != item1) {
     906            ERR("data structures damaged!\n");
     907            return CB_ERR;
     908        }
     909        if (item1->mask & CBEIF_LPARAM)
     910            lret = (LRESULT) item1->lParam;
     911        TRACE("returning 0x%08lx\n", lret);
     912        return lret;
     913    }
     914    lret = (LRESULT)item1;
     915    TRACE("non-valid result from combo, returning 0x%08lx\n", lret);
     916    return lret;
     917}
     918
     919
     920static LRESULT
    884921COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam)
    885922{
     
    896933    TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
    897934          debugstr_w(item->pszText) : "<null>");
     935    infoPtr->selected = index;
    898936
    899937    lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam);
    900938    COMBOEX_SetEditText (infoPtr, item);
    901939    return lret;
     940}
     941
     942
     943static LRESULT
     944COMBOEX_SetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam)
     945{
     946    INT index = wParam;
     947    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     948    CBE_ITEMDATA *item1, *item2;
     949
     950    item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
     951                                             wParam, lParam);
     952    if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
     953        item2 = COMBOEX_FindItem (infoPtr, index);
     954        if (item2 != item1) {
     955            ERR("data structures damaged!\n");
     956            return CB_ERR;
     957        }
     958        item1->mask |= CBEIF_LPARAM;
     959        item1->lParam = lParam;
     960        TRACE("setting lparam to 0x%08lx\n", lParam);
     961        return 0;
     962    }
     963    TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1);
     964    return (LRESULT)item1;
    902965}
    903966
     
    9681031    infoPtr->nb_items = 0;
    9691032    infoPtr->hwndSelf = hwnd;
     1033    infoPtr->selected = -1;
    9701034
    9711035    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
     
    9751039                        (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
    9761040
    977     TRACE("combo style=%08lx, additional style=%08lx\n", dwComboStyle,
     1041    GetWindowRect(hwnd, &wnrc1);
     1042    GetClientRect(hwnd, &clrc1);
     1043    TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
     1044          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     1045          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
     1046    TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle,
    9781047          WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    9791048          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
     
    10771146    GetClientRect(hwnd, &clrc1);
    10781147    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
    1079     TRACE("Ex wnd=(%d,%d)-(%d,%d) Ex clt=(%d,%d)-(%d,%d) Cb wnd=(%d,%d)-(%d,%d)\n",
     1148    TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) CB wnd=(%d,%d)-(%d,%d)\n",
    10801149          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    10811150          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     
    10861155
    10871156    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
    1088     TRACE("Ex wnd=(%d,%d)-(%d,%d)\n",
     1157    TRACE("CB window=(%d,%d)-(%d,%d)\n",
    10891158          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    10901159    SetWindowPos(hwnd, HWND_TOP,
     
    11181187    INT cursel, n, oldItem;
    11191188    NMCBEENDEDITA cbeend;
     1189    DWORD oldflags;
    11201190
    11211191    TRACE("for command %d\n", command);
     
    11711241            }
    11721242        }
    1173         if (infoPtr->flags & WCBE_ACTEDIT) {
     1243
     1244        /* Save flags for testing and reset them */
     1245        oldflags = infoPtr->flags;
     1246        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1247
     1248        if (oldflags & WCBE_ACTEDIT) {
    11741249            WideCharToMultiByte (CP_ACP, 0, item->pszText, -1,
    11751250                                 cbeend.szText, sizeof(cbeend.szText),
    11761251                                 NULL, NULL);
    1177             cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     1252            cbeend.fChanged = (oldflags & WCBE_EDITCHG);
    11781253            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    11791254                                                 CB_GETCURSEL, 0, 0);
    11801255            cbeend.iWhy = CBENF_DROPDOWN;
    11811256
    1182             infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    11831257            if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
    11841258                                (NMHDR *)&cbeend, FALSE)) {
     
    11881262            }
    11891263        }
    1190         SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
    1191         SetFocus(infoPtr->hwndCombo);
     1264
     1265        /* if selection has changed the set the new current selection */
     1266        cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1267        if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
     1268            infoPtr->selected = cursel;
     1269            SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
     1270            SetFocus(infoPtr->hwndCombo);
     1271        }
    11921272        return 0;
    11931273
     
    12101290            ERR("item %d not found. Problem!\n", oldItem);
    12111291            break;
    1212         } 
     1292        }
     1293        infoPtr->selected = oldItem;
    12131294        COMBOEX_SetEditText (infoPtr, item);
    12141295        return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     
    16191700
    16201701static LRESULT
     1702COMBOEX_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1703{
     1704    /* WARNING: The COMBOEX_INFO structure is not yet created */
     1705    DWORD oldstyle, newstyle;
     1706
     1707    oldstyle = (DWORD)GetWindowLongA (hwnd, GWL_STYLE);
     1708    newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
     1709    if (newstyle != oldstyle) {
     1710        TRACE("req style %08lx, reseting style %08lx\n",
     1711              oldstyle, newstyle);
     1712        SetWindowLongA (hwnd, GWL_STYLE, newstyle);
     1713    }
     1714    return 1;
     1715}
     1716
     1717
     1718static LRESULT
    16211719COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
    16221720{
     
    16561754            - (cbx_crect.right-cbx_crect.left);
    16571755
     1756    TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
     1757          wp->x, wp->y, wp->cx, wp->cy, wp->flags);
    16581758    TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
    16591759          cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     
    17711871                    break;
    17721872                }
    1773                  
     1873                infoPtr->selected = oldItem;             
    17741874                COMBOEX_SetEditText (infoPtr, item);
    17751875                RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     
    21102210{
    21112211    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
    2112     if (!COMBOEX_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
     2212
     2213    if (!COMBOEX_GetInfoPtr (hwnd)) {
     2214        if (uMsg == WM_CREATE)
     2215            return COMBOEX_Create (hwnd, wParam, lParam);
     2216        if (uMsg == WM_NCCREATE)
     2217            COMBOEX_NCCreate (hwnd, wParam, lParam);
    21132218        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2219    }
    21142220
    21152221    switch (uMsg)
     
    21672273/*   Combo messages we are not sure if we need to process or just forward */
    21682274        case CB_GETDROPPEDCONTROLRECT:
    2169         case CB_GETITEMDATA:
    21702275        case CB_GETITEMHEIGHT:
    21712276        case CB_GETLBTEXT:
     
    21752280        case CB_RESETCONTENT:
    21762281        case CB_SELECTSTRING:
    2177         case CB_SETITEMDATA:
    21782282        case WM_SETTEXT:
    21792283        case WM_GETTEXT:
    2180             FIXME("(0x%x 0x%x 0x%lx): possible missing fucntion\n",
     2284            FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
    21812285                  uMsg, wParam, lParam);
    21822286            return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     
    21962300                                            wParam, lParam);
    21972301
     2302        case CB_GETITEMDATA:
     2303            return COMBOEX_GetItemData (hwnd, wParam, lParam);
     2304
    21982305        case CB_SETCURSEL:
    21992306            return COMBOEX_SetCursel (hwnd, wParam, lParam);
     2307
     2308        case CB_SETITEMDATA:
     2309            return COMBOEX_SetItemData (hwnd, wParam, lParam);
    22002310
    22012311        case CB_SETITEMHEIGHT:
     
    22132323
    22142324/*   Window messages we need to process */
    2215         case WM_CREATE:
    2216             return COMBOEX_Create (hwnd, wParam, lParam);
    2217 
    22182325        case WM_DELETEITEM:
    22192326            return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
     
    22412348            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    22422349#else
    2243             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2350            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    22442351#endif
    22452352    }
Note: See TracChangeset for help on using the changeset viewer.