Ignore:
Timestamp:
Oct 29, 2002, 1:19:36 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

File:
1 edited

Legend:

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

    r8382 r9370  
    2020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2121 *
    22  * FIXME:
    23  *  1. Implement following extended styles:
    24  *           CBES_EX_PATHWORDBREAKPROC
    25  *           CBES_EX_NOSIZELIMIT
    26  *           CBES_EX_CASESENSITIVE
    27  *  2. Notify CBEN_DRAGBEGIN is not implemented.
    28  *
     22 * NOTE
     23 *
     24 * This code was audited for completeness against the documented features
     25 * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
     26 *
     27 * Unless otherwise noted, we belive this code to be complete, as per
     28 * the specification mentioned above.
     29 * If you discover missing features, or bugs, please note them below.
     30 *
    2931 */
    3032
     
    7476
    7577/* internal flags in the COMBOEX_INFO structure */
    76 #define  WCBE_ACTEDIT           0x00000001     /* Edit active i.e.
     78#define  WCBE_ACTEDIT           0x00000001  /* Edit active i.e.
    7779                                             * CBEN_BEGINEDIT issued
    7880                                             * but CBEN_ENDEDIT{A|W}
    7981                                             * not yet issued. */
    80 #define  WCBE_EDITCHG           0x00000002     /* Edit issued EN_CHANGE */
     82#define  WCBE_EDITCHG           0x00000002  /* Edit issued EN_CHANGE */
    8183#define  WCBE_EDITHASCHANGED    (WCBE_ACTEDIT | WCBE_EDITCHG)
    82 #define  WCBE_EDITFOCUSED       0x00000004     /* Edit control has focus */
    83 
     84#define  WCBE_EDITFOCUSED       0x00000004  /* Edit control has focus */
     85#define  WCBE_MOUSECAPTURED     0x00000008  /* Combo has captured mouse */
     86#define  WCBE_MOUSEDRAGGED      0x00000010  /* User has dragged in combo */
    8487
    8588#define ID_CB_EDIT              1001
     
    8891/*
    8992 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
    90  * the ComboEx version of the Combo Window Proc so that when the 
    91  * WM_DRAWITEM message is then passed to ComboEx, we know that this 
     93 * the ComboEx version of the Combo Window Proc so that when the
     94 * WM_DRAWITEM message is then passed to ComboEx, we know that this
    9295 * particular WM_DRAWITEM message is for listbox only items. Any messasges
    9396 * without this flag is then for the Edit control field.
    9497 *
    95  * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that 
     98 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
    9699 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
    97100 */
     
    121124static LRESULT WINAPI
    122125COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
     126static int CALLBACK
     127COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code);
    123128static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr);
     129
     130#ifdef __WIN32OS2__
     131#undef inline
     132#define inline
     133
     134typedef INT (* WINAPI cmp_func_t)(LPCWSTR, LPCWSTR);
     135#else
     136typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR);
     137#endif
    124138
    125139inline static BOOL is_textW(LPCWSTR str)
     
    164178inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index)
    165179{
    166     return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA, 
     180    return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA,
    167181                                         (WPARAM)index, 0);
    168182}
    169183
     184inline static cmp_func_t get_cmp_func(COMBOEX_INFO *infoPtr)
     185{
     186    return infoPtr->dwExtStyle & CBES_EX_CASESENSITIVE ? lstrcmpW : lstrcmpiW;
     187}
    170188
    171189static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
     
    207225        else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA;
    208226        else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA;
    209        
     227
    210228        ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr);
    211229
    212230        if (astr && hdr->ceItem.pszText == (LPWSTR)astr)
    213231            hdr->ceItem.pszText = wstr;
    214        
     232
    215233        if (astr) COMCTL32_Free(astr);
    216        
     234
    217235        return ret;
    218236    }
     
    228246    } else {
    229247        NMCBEENDEDITA neea;
    230        
     248
    231249        memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR));
    232250        neea.fChanged = neew->fChanged;
     
    240258
    241259
     260static void COMBOEX_NotifyDragBegin(COMBOEX_INFO *infoPtr, LPCWSTR wstr)
     261{
     262    /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
     263    if (infoPtr->NtfUnicode) {
     264        NMCBEDRAGBEGINW ndbw;
     265
     266        ndbw.iItemid = -1;
     267        lstrcpynW(ndbw.szText, wstr, CBEMAXSTRLEN);
     268        COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINW, &ndbw.hdr);
     269    } else {
     270        NMCBEDRAGBEGINA ndba;
     271
     272        ndba.iItemid = -1;
     273        WideCharToMultiByte (CP_ACP, 0, wstr, -1, ndba.szText, CBEMAXSTRLEN, 0, 0);
     274
     275        COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINA, &ndba.hdr);
     276    }
     277}
     278
     279
    242280static void COMBOEX_FreeText (CBE_ITEMDATA *item)
    243281{
     
    254292    LPWSTR text, buf;
    255293    INT len;
    256    
    257     if (item->pszText != LPSTR_TEXTCALLBACKW) 
     294
     295    if (item->pszText != LPSTR_TEXTCALLBACKW)
    258296        return item->pszText;
    259    
     297
    260298    ZeroMemory(&nmce, sizeof(nmce));
    261299    nmce.ceItem.mask = CBEIF_TEXT;
     
    277315    } else
    278316        text = nmce.ceItem.pszText;
    279    
     317
    280318    if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
    281319        item->pszText = text;
     
    290328
    291329    mydc = GetDC (0); /* why the entire screen???? */
    292     nfont = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     330    nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    293331    ofont = (HFONT) SelectObject (mydc, nfont);
    294332    GetTextExtentPointA (mydc, "A", 1, size);
    295333    SelectObject (mydc, ofont);
    296334    ReleaseDC (0, mydc);
    297     TRACE("selected font hwnd=%08x, height=%ld\n", nfont, size->cy);
     335    TRACE("selected font hwnd=%p, height=%ld\n", nfont, size->cy);
    298336}
    299337
     
    376414    }
    377415    SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy);
    378     if (infoPtr->hwndCombo)
     416    if (infoPtr->hwndCombo) {
    379417        SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
    380418                      (WPARAM) 0, (LPARAM) cy);
     419        if ( !(infoPtr->flags & CBES_EX_NOSIZELIMIT)) {
     420            RECT comboRect;
     421            if (GetWindowRect(infoPtr->hwndCombo, &comboRect)) {
     422                RECT ourRect;
     423                if (GetWindowRect(infoPtr->hwndSelf, &ourRect)) {
     424                    if (comboRect.bottom > ourRect.bottom) {
     425                        POINT pt = { ourRect.left, ourRect.top };
     426                        if (ScreenToClient(infoPtr->hwndSelf, &pt))
     427                            MoveWindow( infoPtr->hwndSelf, pt.x, pt.y, ourRect.right - ourRect.left,
     428                                        comboRect.bottom - comboRect.top, FALSE);
     429                    }
     430                }
     431            }
     432        }
     433    }
    381434}
    382435
     
    396449}
    397450
    398  
     451
    399452static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
    400453{
     
    424477static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr)
    425478{
    426     return infoPtr->hwndEdit;
    427 }
    428  
     479    return infoPtr->hwndEdit ? TRUE : FALSE;
     480}
     481
    429482
    430483/* ***  CBEM_xxx message support  *** */
     
    481534
    482535    if (is_textW(tmpcit.pszText) && cit->pszText)
    483         WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 
     536        WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
    484537                             cit->pszText, cit->cchTextMax, NULL, NULL);
    485538    else if (cit->pszText) cit->pszText[0] = 0;
     
    520573    /* get zero-filled space and chain it in */
    521574    if(!(item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof(*item)))) return -1;
    522    
     575
    523576    /* locate position to insert new item in */
    524577    if (index == infoPtr->nb_items) {
     
    576629    if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
    577630
    578     SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 
     631    SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
    579632                  (WPARAM)cit->iItem, (LPARAM)item);
    580633
     
    602655        citW.pszText = wstr;
    603656    }
    604     ret = COMBOEX_InsertItemW(infoPtr, &citW);;
    605    
     657    ret = COMBOEX_InsertItemW(infoPtr, &citW);
     658
    606659    if (wstr) COMCTL32_Free(wstr);
    607    
     660
    608661    return ret;
    609662}
    610663
    611664
    612 static DWORD 
     665static DWORD
    613666COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style)
    614667{
     
    618671
    619672    dwTemp = infoPtr->dwExtStyle;
    620 
    621     if (style &  (CBES_EX_PATHWORDBREAKPROC |
    622                   CBES_EX_NOSIZELIMIT |
    623                   CBES_EX_CASESENSITIVE))
    624         FIXME("Extended style not implemented %08lx\n", style);
    625673
    626674    if (mask)
     
    628676    else
    629677        infoPtr->dwExtStyle = style;
     678
     679    /* see if we need to change the word break proc on the edit */
     680    if ((infoPtr->dwExtStyle ^ dwTemp) & CBES_EX_PATHWORDBREAKPROC) {
     681        SendMessageW(infoPtr->hwndEdit, EM_SETWORDBREAKPROC, 0,
     682                     (infoPtr->dwExtStyle & CBES_EX_PATHWORDBREAKPROC) ?
     683                         (LPARAM)COMBOEX_PathWordBreakProc : 0);
     684    }
    630685
    631686    /* test if the control's appearance has changed */
     
    676731    if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
    677732
    678     /* add/change stuff to the internal item structure */ 
     733    /* add/change stuff to the internal item structure */
    679734    item->mask |= cit->mask;
    680735    if (cit->mask & CBEIF_TEXT) {
     
    726781        citW.pszText = wstr;
    727782    }
    728     ret = COMBOEX_SetItemW(infoPtr, &citW);;
     783    ret = COMBOEX_SetItemW(infoPtr, &citW);
    729784
    730785    if (wstr) COMCTL32_Free(wstr);
     
    749804
    750805static INT
    751 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCSTR str)
    752 {
    753     INT i, count;
    754     CBE_ITEMDATA *item;
    755     LPWSTR desired = NULL;
    756 
    757     i = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    758     if (i > 0) {
    759         desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
    760         if (!desired) return CB_ERR;
    761         MultiByteToWideChar (CP_ACP, 0, str, -1, desired, i);
    762     }
    763 
    764     count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
     806COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCWSTR str)
     807{
     808    INT i;
     809    cmp_func_t cmptext = get_cmp_func(infoPtr);
     810    INT count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
    765811
    766812    /* now search from after starting loc and wrapping back to start */
    767813    for(i=start+1; i<count; i++) {
    768         item = get_item_data(infoPtr, i);
    769         if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) {
    770             COMCTL32_Free (desired);
    771             return i;
    772         }
     814        CBE_ITEMDATA *item = get_item_data(infoPtr, i);
     815        if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
    773816    }
    774817    for(i=0; i<=start; i++) {
    775         item = get_item_data(infoPtr, i);
    776         if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) {
    777             COMCTL32_Free (desired);
    778             return i;
    779         }
    780     }
    781     COMCTL32_Free(desired);
     818        CBE_ITEMDATA *item = get_item_data(infoPtr, i);
     819        if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
     820    }
    782821    return CB_ERR;
    783822}
     
    857896    GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
    858897    GetClientRect (infoPtr->hwndSelf, &cbx_crect);
    859     /* the height of comboex as height of the combo + comboex border */ 
     898    /* the height of comboex as height of the combo + comboex border */
    860899    height = cb_wrect.bottom-cb_wrect.top
    861900             + cbx_wrect.bottom-cbx_wrect.top
     
    884923    WCHAR NIL[] = { 0 };
    885924    COMBOEX_INFO *infoPtr;
    886     DWORD dwComboStyle;
    887925    LOGFONTW mylogfont;
    888926    RECT wnrc1, clrc1, cmbwrc;
     
    895933    /* initialize info structure */
    896934    /* note that infoPtr is allocated zero-filled */
    897    
     935
    898936    infoPtr->hwndSelf = hwnd;
    899937    infoPtr->selected = -1;
     
    901939    infoPtr->unicode = IsWindowUnicode (hwnd);
    902940
    903     i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     941    i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
    904942    if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
    905943        WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
     
    911949
    912950    /* create combo box */
    913     dwComboStyle = GetWindowLongW (hwnd, GWL_STYLE) &
    914                         (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
    915 
    916951    GetWindowRect(hwnd, &wnrc1);
    917952    GetClientRect(hwnd, &clrc1);
     
    919954          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    920955          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
    921     TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle,
    922           WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    923           CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
    924           WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
    925956
    926957    /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
     
    934965                         /* following line added to match native */
    935966                         WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    936                          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | 
     967                         CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
    937968                         /* was base and is necessary */
    938                          WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
     969                         WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED |
     970                         GetWindowLongW (hwnd, GWL_STYLE),
    939971                         cs->y, cs->x, cs->cx, cs->cy, hwnd,
    940972                         (HMENU) GetWindowLongW (hwnd, GWL_ID),
    941                          GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
    942 
    943     /* 
     973                         (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
     974
     975    /*
    944976     * native does the following at this point according to trace:
    945977     *  GetWindowThreadProcessId(hwndCombo,0)
     
    950982
    951983    /*
    952      * Setup a property to hold the pointer to the COMBOBOXEX 
     984     * Setup a property to hold the pointer to the COMBOBOXEX
    953985     * data structure.
    954986     */
    955987    SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd);
    956     infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo, 
     988    infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo,
    957989                                GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
    958     infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     990    infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    959991
    960992
     
    967999                    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
    9681000                    0, 0, 0, 0,  /* will set later */
    969                     infoPtr->hwndCombo, 
     1001                    infoPtr->hwndCombo,
    9701002                    (HMENU) GetWindowLongW (hwnd, GWL_ID),
    971                     GetWindowLongW (hwnd, GWL_HINSTANCE),
    972                     NULL);
     1003                    (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
    9731004
    9741005        /* native does the following at this point according to trace:
     
    9801011
    9811012        /*
    982          * Setup a property to hold the pointer to the COMBOBOXEX 
     1013         * Setup a property to hold the pointer to the COMBOBOXEX
    9831014         * data structure.
    9841015         */
    9851016        SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd);
    986         infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit, 
     1017        infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit,
    9871018                                 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
    988         infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     1019        infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    9891020    }
    9901021
     
    9941025     */
    9951026    if (!infoPtr->font) {
    996         SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), 
     1027        SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
    9971028                               &mylogfont, 0);
    9981029        infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont);
     
    10151046          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
    10161047          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    1017     SetWindowPos(infoPtr->hwndCombo, HWND_TOP, 
     1048    SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
    10181049                 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
    10191050                 SWP_NOACTIVATE | SWP_NOREDRAW);
     
    10221053    TRACE("CB window=(%d,%d)-(%d,%d)\n",
    10231054          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    1024     SetWindowPos(hwnd, HWND_TOP, 
     1055    SetWindowPos(hwnd, HWND_TOP,
    10251056                 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
    10261057                 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
     
    10291060
    10301061    /*
    1031      * Create an item structure to represent the data in the 
     1062     * Create an item structure to represent the data in the
    10321063     * EDIT control. It is allocated zero-filled.
    10331064     */
     
    10611092        ShowWindow (infoPtr->hwndEdit, SW_HIDE);
    10621093        return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    1063        
     1094
    10641095    case CBN_CLOSEUP:
    10651096        SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    10661097        /*
    1067          * from native trace of first dropdown after typing in URL in IE4 
     1098         * from native trace of first dropdown after typing in URL in IE4
    10681099         *  CB_GETCURSEL(Combo)
    10691100         *  GetWindowText(Edit)
     
    10751106         *  CB_SETCURSEL(COMBOEX, n)
    10761107         *  SetFocus(Combo)
    1077          * the rest is supposition 
     1108         * the rest is supposition
    10781109         */
    10791110        ShowWindow (infoPtr->hwndEdit, SW_SHOW);
     
    10821113        cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    10831114        if (cursel == -1) {
     1115            cmp_func_t cmptext = get_cmp_func(infoPtr);
    10841116            /* find match from edit against those in Combobox */
    10851117            GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
     
    10881120                item = get_item_data(infoPtr, cursel);
    10891121                if ((INT)item == CB_ERR) break;
    1090                 if (!lstrcmpiW(COMBOEX_GetText(infoPtr, item), wintext)) break;
     1122                if (!cmptext(COMBOEX_GetText(infoPtr, item), wintext)) break;
    10911123            }
    10921124            if ((cursel == n) || ((INT)item == CB_ERR)) {
     
    11551187
    11561188    case CBN_SELENDOK:
    1157         /* 
     1189        /*
    11581190         * We have to change the handle since we are the control
    11591191         * issuing the message. IE4 depends on this.
     
    11891221
    11901222    default:
    1191         /* 
     1223        /*
    11921224         * We have to change the handle since we are the control
    11931225         * issuing the message. IE4 depends on this.
     
    12101242    INT i;
    12111243
    1212     TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
     1244    TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%p, data=%08lx\n",
    12131245          dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
    12141246
     
    12641296    if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
    12651297
    1266     TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", 
     1298    TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
    12671299          dis->CtlType, dis->CtlID);
    1268     TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", 
     1300    TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
    12691301          dis->itemID, dis->itemAction, dis->itemState);
    1270     TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
    1271           dis->hwndItem, dis->hDC, dis->rcItem.left, 
    1272           dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, 
     1302    TRACE("hWnd=%p hDC=%p (%d,%d)-(%d,%d) itemData=0x%08lx\n",
     1303          dis->hwndItem, dis->hDC, dis->rcItem.left,
     1304          dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
    12731305          dis->itemData);
    12741306
     
    12861318    if (dis->itemID == 0xffffffff) {
    12871319        if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
    1288              ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) { 
     1320             ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
    12891321
    12901322            TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
     
    12921324                  dis->rcItem.right, dis->rcItem.bottom);
    12931325        }
    1294         else if ((dis->CtlType == ODT_COMBOBOX) && 
     1326        else if ((dis->CtlType == ODT_COMBOBOX) &&
    12951327                 (dis->itemAction == ODA_DRAWENTIRE)) {
    12961328            /* draw of edit control data */
     
    13341366                if (item->pszText)
    13351367                    GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1);
    1336            
    1337                TRACE("edit control hwndEdit=%0x, text len=%d str=%s\n",
     1368
     1369               TRACE("edit control hwndEdit=%p, text len=%d str=%s\n",
    13381370                     infoPtr->hwndEdit, len, debugstr_txt(item->pszText));
    13391371            }
     
    13821414        /* drawing combo/edit entry */
    13831415        if (IsWindowVisible(infoPtr->hwndEdit)) {
    1384             /* if we have an edit control, the slave the 
    1385              * selection state to the Edit focus state 
     1416            /* if we have an edit control, the slave the
     1417             * selection state to the Edit focus state
    13861418             */
    13871419            if (infoPtr->flags & WCBE_EDITFOCUSED) {
     
    13911423            }
    13921424        } else {
    1393             /* if we don't have an edit control, use 
     1425            /* if we don't have an edit control, use
    13941426             * the requested state.
    13951427             */
     
    14151447    len = strlenW (str);
    14161448    GetTextExtentPoint32W (dis->hDC, str, len, &txtsize);
    1417    
     1449
    14181450    if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) {
    14191451        int overlay = item->iOverlay;
    1420        
     1452
    14211453        if (drawimage == I_IMAGECALLBACK) {
    14221454            NMCOMBOBOXEXW nmce;
     
    14421474            overlay = nmce.ceItem.iOverlay;
    14431475        }
    1444    
    1445         if (drawimage >= 0 && 
     1476
     1477        if (drawimage >= 0 &&
    14461478            !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) {
    14471479            if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1);
    1448             ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top, 
     1480            ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top,
    14491481                            drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0));
    14501482        }
     
    14731505        }
    14741506    }
    1475    
     1507
    14761508    if (dis->itemAction & ODA_FOCUS) {
    14771509        rect.left = xbase + xioff - 1;
     
    15091541    }
    15101542
    1511     if (infoPtr->defaultFont) 
     1543    if (infoPtr->defaultFont)
    15121544        DeleteObject (infoPtr->defaultFont);
    15131545
     
    15291561    mis->itemHeight = mysize.cy + CBE_EXTRA;
    15301562
    1531     TRACE("adjusted height hwnd=%08x, height=%d\n",
     1563    TRACE("adjusted height hwnd=%p, height=%d\n",
    15321564          infoPtr->hwndSelf, mis->itemHeight);
    15331565
     
    15561588    if (lParam == NF_REQUERY) {
    15571589        INT i = SendMessageW(GetParent (infoPtr->hwndSelf),
    1558                          WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     1590                         WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
    15591591        infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    15601592    }
     
    15651597static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height)
    15661598{
    1567     TRACE("(width=%d, height=%d)\n", width, height); 
     1599    TRACE("(width=%d, height=%d)\n", width, height);
    15681600
    15691601    MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE);
     
    15861618    /* width is winpos value + border width of comboex */
    15871619    width = wp->cx
    1588             + (cbx_wrect.right-cbx_wrect.left) 
    1589             - (cbx_crect.right-cbx_crect.left); 
     1620            + (cbx_wrect.right-cbx_wrect.left)
     1621            - (cbx_crect.right-cbx_crect.left);
    15901622
    15911623    TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
     
    16181650}
    16191651
     1652static inline int is_delimiter(WCHAR c)
     1653{
     1654    switch(c) {
     1655        case '/':
     1656        case '\\':
     1657        case '.':
     1658            return TRUE;
     1659    }
     1660    return FALSE;
     1661}
     1662
     1663static int CALLBACK
     1664COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code)
     1665{
     1666    if (code == WB_ISDELIMITER) {
     1667        return is_delimiter(lpch[ichCurrent]);
     1668    } else {
     1669        int dir = (code == WB_LEFT) ? -1 : 1;
     1670        for(; 0 <= ichCurrent && ichCurrent < cch; ichCurrent += dir)
     1671            if (is_delimiter(lpch[ichCurrent])) return ichCurrent;
     1672    }
     1673    return ichCurrent;
     1674}
    16201675
    16211676static LRESULT WINAPI
     
    16311686    LRESULT lret;
    16321687
    1633     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     1688    TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
    16341689          hwnd, uMsg, wParam, lParam, infoPtr);
    16351690
     
    16431698            if (wParam == VK_RETURN) return 0;
    16441699            /* all other characters pass into the real Edit */
    1645             return CallWindowProcW (infoPtr->prevEditWndProc, 
     1700            return CallWindowProcW (infoPtr->prevEditWndProc,
    16461701                                   hwnd, uMsg, wParam, lParam);
    16471702
    16481703        case WM_ERASEBKGND:
    16491704            /*
    1650              * The following was determined by traces of the native 
     1705             * The following was determined by traces of the native
    16511706             */
    16521707            hDC = (HDC) wParam;
     
    16571712            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    16581713            SetBkColor (hDC, obkc);
    1659             return CallWindowProcW (infoPtr->prevEditWndProc, 
     1714            return CallWindowProcW (infoPtr->prevEditWndProc,
    16601715                                   hwnd, uMsg, wParam, lParam);
    16611716
     
    16721727                 *   CB_GETCURSEL to Combo rets -1              x
    16731728                 *   WM_NOTIFY to COMBOEX parent (rebar)        x
    1674                  *     (CBEN_ENDEDIT{A|W} 
     1729                 *     (CBEN_ENDEDIT{A|W}
    16751730                 *      fChanged = FALSE                        x
    16761731                 *      inewSelection = -1                      x
     
    17011756                    break;
    17021757                }
    1703                 infoPtr->selected = oldItem;             
     1758                infoPtr->selected = oldItem;
    17041759                COMBOEX_SetEditText (infoPtr, item);
    1705                 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | 
     1760                RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
    17061761                              RDW_INVALIDATE);
    17071762                break;
     
    17131768                 *   CB_GETCURSEL to Combo  rets -1             x
    17141769                 *   CB_GETCOUNT to Combo  rets 0
    1715                  *   if >0 loop 
     1770                 *   if >0 loop
    17161771                 *       CB_GETITEMDATA to match
    1717                  * *** above 3 lines simulated by FindItem      x 
     1772                 * *** above 3 lines simulated by FindItem      x
    17181773                 *   WM_NOTIFY to COMBOEX parent (rebar)        x
    17191774                 *     (CBEN_ENDEDIT{A|W}                       x
     
    17381793
    17391794                if (selected != -1) {
     1795                    cmp_func_t cmptext = get_cmp_func(infoPtr);
    17401796                    item = COMBOEX_FindItem (infoPtr, selected);
    17411797                    TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
     
    17431799                    TRACE("handling VK_RETURN, edittext=%s\n",
    17441800                          debugstr_w(edit_text));
    1745                     if (lstrcmpiW (COMBOEX_GetText(infoPtr, item), edit_text)) {
     1801                    if (cmptext (COMBOEX_GetText(infoPtr, item), edit_text)) {
    17461802                        /* strings not equal -- indicate edit has changed */
    17471803                        selected = -1;
     
    17501806
    17511807                cbeend.iNewSelection = selected;
    1752                 cbeend.fChanged = TRUE; 
     1808                cbeend.fChanged = TRUE;
    17531809                cbeend.iWhy = CBENF_RETURN;
    17541810                if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     
    17561812                    TRACE("Notify requested abort of change\n");
    17571813                    COMBOEX_SetEditText (infoPtr, infoPtr->edit);
    1758                     RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | 
     1814                    RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
    17591815                                  RDW_INVALIDATE);
    17601816                    return 0;
     
    17631819                if (oldItem != -1) {
    17641820                    /* if something is selected, then deselect it */
    1765                     SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, 
     1821                    SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
    17661822                                  (WPARAM)-1, 0);
    17671823                }
     
    17871843        case WM_SETFOCUS:
    17881844            /* remember the focus to set state of icon */
    1789             lret = CallWindowProcW (infoPtr->prevEditWndProc, 
     1845            lret = CallWindowProcW (infoPtr->prevEditWndProc,
    17901846                                   hwnd, uMsg, wParam, lParam);
    17911847            infoPtr->flags |= WCBE_EDITFOCUSED;
     
    17931849
    17941850        case WM_KILLFOCUS:
    1795             /* 
     1851            /*
    17961852             * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
    17971853             */
     
    18111867
    18121868        default:
    1813             return CallWindowProcW (infoPtr->prevEditWndProc, 
     1869            return CallWindowProcW (infoPtr->prevEditWndProc,
    18141870                                   hwnd, uMsg, wParam, lParam);
    18151871    }
     
    18291885    HWND focusedhwnd;
    18301886    RECT rect;
     1887    POINT pt;
    18311888    WCHAR edit_text[260];
    18321889
    1833     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     1890    TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
    18341891          hwnd, uMsg, wParam, lParam, infoPtr);
    18351892
     
    18381895    switch (uMsg)
    18391896    {
    1840 
    1841     case CB_FINDSTRINGEXACT:
    1842             return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam);
    18431897
    18441898    case WM_DRAWITEM:
     
    18491903             */
    18501904            ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
    1851             return CallWindowProcW (infoPtr->prevComboWndProc, 
     1905            return CallWindowProcW (infoPtr->prevComboWndProc,
    18521906                                   hwnd, uMsg, wParam, lParam);
    18531907
    18541908    case WM_ERASEBKGND:
    18551909            /*
    1856              * The following was determined by traces of the native 
     1910             * The following was determined by traces of the native
    18571911             */
    18581912            hDC = (HDC) wParam;
     
    18631917            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    18641918            SetBkColor (hDC, obkc);
    1865             return CallWindowProcW (infoPtr->prevComboWndProc, 
     1919            return CallWindowProcW (infoPtr->prevComboWndProc,
    18661920                                   hwnd, uMsg, wParam, lParam);
    18671921
     
    18781932            nmmse.dwHitInfo = lParam;
    18791933            COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
    1880             return CallWindowProcW (infoPtr->prevComboWndProc, 
     1934            return CallWindowProcW (infoPtr->prevComboWndProc,
    18811935                                   hwnd, uMsg, wParam, lParam);
     1936
     1937    case WM_LBUTTONDOWN:
     1938            GetClientRect (hwnd, &rect);
     1939            rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf,
     1940                                                  CB_GETITEMHEIGHT, -1, 0);
     1941            rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
     1942            POINTSTOPOINT(pt, MAKEPOINTS(lParam));
     1943            if (PtInRect(&rect, pt))
     1944                return CallWindowProcW (infoPtr->prevComboWndProc,
     1945                                        hwnd, uMsg, wParam, lParam);
     1946            infoPtr->flags |= WCBE_MOUSECAPTURED;
     1947            SetCapture(hwnd);
     1948            break;
     1949
     1950    case WM_LBUTTONUP:
     1951            if (!(infoPtr->flags & WCBE_MOUSECAPTURED))
     1952                return CallWindowProcW (infoPtr->prevComboWndProc,
     1953                                        hwnd, uMsg, wParam, lParam);
     1954            ReleaseCapture();
     1955            infoPtr->flags &= ~WCBE_MOUSECAPTURED;
     1956            if (infoPtr->flags & WCBE_MOUSEDRAGGED) {
     1957                infoPtr->flags &= ~WCBE_MOUSEDRAGGED;
     1958            } else {
     1959                SendMessageW(hwnd, CB_SHOWDROPDOWN, TRUE, 0);
     1960            }
     1961            break;
     1962
     1963    case WM_MOUSEMOVE:
     1964            if ( (infoPtr->flags & WCBE_MOUSECAPTURED) &&
     1965                !(infoPtr->flags & WCBE_MOUSEDRAGGED)) {
     1966                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     1967                COMBOEX_NotifyDragBegin(infoPtr, edit_text);
     1968                infoPtr->flags |= WCBE_MOUSEDRAGGED;
     1969            }
     1970            return CallWindowProcW (infoPtr->prevComboWndProc,
     1971                                    hwnd, uMsg, wParam, lParam);
    18821972
    18831973    case WM_COMMAND:
     
    19182008                if (focusedhwnd)
    19192009                    SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
    1920                                   (WPARAM)focusedhwnd, 0); 
     2010                                  (WPARAM)focusedhwnd, 0);
    19212011                return 0;
    19222012
    19232013            case EN_SETFOCUS: {
    1924                 /* 
     2014                /*
    19252015                 * For EN_SETFOCUS this issues the same calls and messages
    19262016                 *  as the native seems to do.
     
    19482038
    19492039            case EN_CHANGE: {
    1950                 /* 
     2040                /*
    19512041                 * For EN_CHANGE this issues the same calls and messages
    19522042                 *  as the native seems to do.
     
    19542044                WCHAR edit_text[260];
    19552045                LPCWSTR lastwrk;
    1956                 INT selected;
    1957                 CBE_ITEMDATA *item;
    1958 
    1959                 selected = SendMessageW (infoPtr->hwndCombo,
    1960                                          CB_GETCURSEL, 0, 0);
     2046                cmp_func_t cmptext = get_cmp_func(infoPtr);
     2047
     2048                INT selected = SendMessageW (infoPtr->hwndCombo,
     2049                                             CB_GETCURSEL, 0, 0);
    19612050
    19622051                /* lstrlenA( lastworkingURL ) */
     
    19672056                }
    19682057                else {
    1969                     item = COMBOEX_FindItem (infoPtr, selected);
     2058                    CBE_ITEMDATA *item = COMBOEX_FindItem (infoPtr, selected);
    19702059                    lastwrk = COMBOEX_GetText(infoPtr, item);
    19712060                }
     
    19762065                      debugstr_w(edit_text));
    19772066
    1978                 /* lstrcmpiW is between lastworkingURL and GetWindowText */
    1979                 if (lstrcmpiW (lastwrk, edit_text)) {
     2067                /* cmptext is between lastworkingURL and GetWindowText */
     2068                if (cmptext (lastwrk, edit_text)) {
    19802069                    /* strings not equal -- indicate edit has changed */
    19812070                    infoPtr->flags |= WCBE_EDITCHG;
     
    19842073                               MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
    19852074                                          CBN_EDITCHANGE),
    1986                                infoPtr->hwndSelf);
     2075                               (LPARAM)infoPtr->hwndSelf);
    19872076                return 0;
    19882077                }
     
    20242113            }/* fall through */
    20252114    default:
    2026             return CallWindowProcW (infoPtr->prevComboWndProc, 
     2115            return CallWindowProcW (infoPtr->prevComboWndProc,
    20272116                                   hwnd, uMsg, wParam, lParam);
    20282117    }
     
    20362125    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    20372126
    2038     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
     2127    TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
    20392128
    20402129    if (!infoPtr) {
     
    20522141
    20532142        case CBEM_GETCOMBOCONTROL:
    2054             return infoPtr->hwndCombo;
     2143            return (LRESULT)infoPtr->hwndCombo;
    20552144
    20562145        case CBEM_GETEDITCONTROL:
    2057             return infoPtr->hwndEdit;
     2146            return (LRESULT)infoPtr->hwndEdit;
    20582147
    20592148        case CBEM_GETEXTENDEDSTYLE:
     
    20992188        /*case CBEM_SETWINDOWTHEME:
    21002189            FIXME("CBEM_SETWINDOWTHEME: stub\n");*/
     2190
     2191        case WM_SETTEXT:
     2192        case WM_GETTEXT:
     2193            return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam);
    21012194
    21022195/*   Combo messages we are not sure if we need to process or just forward */
     
    21092202        case CB_RESETCONTENT:
    21102203        case CB_SELECTSTRING:
    2111         case WM_SETTEXT:
    2112         case WM_GETTEXT:
    2113             FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
    2114                   uMsg, wParam, lParam);
    21152204
    21162205/*   Combo messages OK to just forward to the regular COMBO */
    2117         case CB_GETCOUNT:       
     2206        case CB_GETCOUNT:
    21182207        case CB_GETCURSEL:
    21192208        case CB_GETDROPPEDSTATE:
     
    21252214/*   Combo messages we need to process specially */
    21262215        case CB_FINDSTRINGEXACT:
    2127             return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam);
     2216            return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCWSTR)lParam);
    21282217
    21292218        case CB_GETITEMDATA:
     
    21752264
    21762265        default:
    2177             if (uMsg >= WM_USER)
     2266            if ((uMsg >= WM_USER) && (uMsg < WM_APP))
    21782267                ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam);
    21792268            return DefWindowProcW (hwnd, uMsg, wParam, lParam);
     
    21952284    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    21962285    wndClass.lpszClassName = WC_COMBOBOXEXW;
    2197  
     2286
    21982287    RegisterClassW (&wndClass);
    21992288}
     
    22042293    UnregisterClassW (WC_COMBOBOXEXW, (HINSTANCE)NULL);
    22052294}
    2206 
Note: See TracChangeset for help on using the changeset viewer.