Ignore:
Timestamp:
Sep 5, 2001, 2:05:03 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

File:
1 edited

Legend:

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

    r6380 r6644  
     1/* $Id: comboex.c,v 1.12 2001-09-05 12:04:56 bird Exp $ */
    12/*
    23 * TODO   <-------------
     
    45 *     result in a FIXME:
    56 *           CBES_EX_NOEDITIMAGEINDENT
    6  *           CBES_EX_PATHWORDBREAKPROC
    7  *           CBES_EX_NOSIZELIMIT
    8  *           CBES_EX_CASESENSITIVE
     7 *       CBES_EX_PATHWORDBREAKPROC
     8 *       CBES_EX_NOSIZELIMIT
     9 *       CBES_EX_CASESENSITIVE
    910 *  2. None of the following callback items are implemented. Therefor
    1011 *     no CBEN_GETDISPINFO notifies are issued. Use in either CBEM_INSERTITEM
     
    3738 *      generate message sequence similar to native DLL.
    3839 *   2. Handle case where CBEM_SETITEM is called to display data in EDIT
    39  *      Control. 
     40 *      Control.
    4041 *   3. Add override for WNDPROC for the EDIT control (reqed for VK_RETURN).
    4142 *   4. Dump input data for things using COMBOBOXEXITEM{A|W}.
     
    5556 *   3. Lock image selected status to focus state of edit control if
    5657 *      edit control exists. Mimics native actions.
    57  *   4. Implemented WM_SETFOCUS in EditWndProc to track status of 
     58 *   4. Implemented WM_SETFOCUS in EditWndProc to track status of
    5859 *      focus for 3 above.
    5960 *   5. The LBN_SELCHANGE is just for documentation purposes.
     
    7071 *
    7172 *  mod 6
    72  *   1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do 
     73 *   1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do
    7374 *      WM_NOTIFY correctly based on results.
    7475 *   2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM.
    7576 *   3. Add routines to handle special cases of NMCBEENDEDIT and NMCOMBOXEX
    76  *      so translation to ANSI is done correctly. 
     77 *      so translation to ANSI is done correctly.
    7778 *   4. Fix some issues with COMBOEX_DrawItem.
    7879 *
     
    150151/*
    151152 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
    152  * the ComboEx version of the Combo Window Proc so that when the 
    153  * WM_DRAWITEM message is then passed to ComboEx, we know that this 
     153 * the ComboEx version of the Combo Window Proc so that when the
     154 * WM_DRAWITEM message is then passed to ComboEx, we know that this
    154155 * particular WM_DRAWITEM message is for listbox only items. Any messasges
    155156 * without this flag is then for the Edit control field.
    156157 *
    157  * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that 
     158 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
    158159 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
    159160 */
     
    189190    if (TRACE_ON(comboex)){
    190191      TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
    191             item, item->mask, item->pszText, item->cchTextMax,
    192             item->iImage);
     192        item, item->mask, item->pszText, item->cchTextMax,
     193        item->iImage);
    193194      TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    194             item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
     195        item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
    195196      if ((item->mask & CBEIF_TEXT) && item->pszText)
    196           TRACE("item %p - pszText=%s\n",
    197                 item, debugstr_w((const WCHAR *)item->pszText));
     197      TRACE("item %p - pszText=%s\n",
     198        item, debugstr_w((const WCHAR *)item->pszText));
    198199    }
    199200}
     
    205206    if (TRACE_ON(comboex)){
    206207      TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
    207             input->mask, input->iItem, input->pszText, input->cchTextMax,
    208             input->iImage);
     208        input->mask, input->iItem, input->pszText, input->cchTextMax,
     209        input->iImage);
    209210      if ((input->mask & CBEIF_TEXT) && input->pszText) {
    210           if (true_for_w)
    211               TRACE("input - pszText=<%s>\n",
    212                     debugstr_w((const WCHAR *)input->pszText));
    213           else
    214               TRACE("input - pszText=<%s>\n",
    215                     debugstr_a((const char *)input->pszText));
     211      if (true_for_w)
     212          TRACE("input - pszText=<%s>\n",
     213            debugstr_w((const WCHAR *)input->pszText));
     214      else
     215          TRACE("input - pszText=<%s>\n",
     216            debugstr_a((const char *)input->pszText));
    216217      }
    217218      TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    218             input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
     219        input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
    219220    }
    220221}
     
    226227    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    227228
    228     if (infoPtr->hwndCombo)   
    229         return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
     229    if (infoPtr->hwndCombo)
     230    return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
    230231
    231232    return 0;
     
    241242    hdr->code = code;
    242243    if (infoPtr->NtfUnicode)
    243         return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    244                              (LPARAM)hdr);
     244    return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     245                 (LPARAM)hdr);
    245246    else
    246         return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    247                              (LPARAM)hdr);
     247    return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     248                 (LPARAM)hdr);
    248249}
    249250
     
    259260    hdr->hdr.code = code;
    260261    if (infoPtr->NtfUnicode)
    261         return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    262                              (LPARAM)hdr);
     262    return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     263                 (LPARAM)hdr);
    263264    else {
    264         LPWSTR str, ostr = NULL;
    265         INT ret, len = 0;
    266 
    267         if (hdr->ceItem.mask & CBEIF_TEXT) {
    268             ostr = hdr->ceItem.pszText;
    269             str = ostr;
    270             if (!str) str = (LPWSTR)L"";
    271             len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL);
    272             if (len > 0) {
    273                 hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
    274                 WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText,
    275                                      len, NULL, NULL);
    276             }
    277         }
    278 
    279         ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    280                             (LPARAM)hdr);
    281         if (hdr->ceItem.mask & CBEIF_TEXT) {
    282             if (len > 0)
    283                 COMCTL32_Free (hdr->ceItem.pszText);
    284             hdr->ceItem.pszText = ostr;
    285         }
    286         return ret;
     265    LPWSTR str, ostr = NULL;
     266    INT ret, len = 0;
     267
     268    if (hdr->ceItem.mask & CBEIF_TEXT) {
     269        ostr = hdr->ceItem.pszText;
     270        str = ostr;
     271        if (!str) str = (LPWSTR)L"";
     272        len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL);
     273        if (len > 0) {
     274        hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
     275        WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText,
     276                     len, NULL, NULL);
     277        }
     278    }
     279
     280    ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     281                (LPARAM)hdr);
     282    if (hdr->ceItem.mask & CBEIF_TEXT) {
     283        if (len > 0)
     284        COMCTL32_Free (hdr->ceItem.pszText);
     285        hdr->ceItem.pszText = ostr;
     286    }
     287    return ret;
    287288    }
    288289}
     
    299300    hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA;
    300301    if (infoPtr->NtfUnicode)
    301         return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    302                              (LPARAM)hdr);
     302    return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     303                 (LPARAM)hdr);
    303304    else {
    304         NMCBEENDEDITA ansi;
    305 
    306         memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR));
    307         ansi.fChanged = hdr->fChanged;
    308         ansi.iNewSelection = hdr->iNewSelection;
    309         WideCharToMultiByte (CP_ACP, 0, itemText, -1,
    310                              (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL);
    311         ansi.iWhy = hdr->iWhy;
    312         return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    313                              (LPARAM)&ansi);
     305    NMCBEENDEDITA ansi;
     306
     307    memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR));
     308    ansi.fChanged = hdr->fChanged;
     309    ansi.iNewSelection = hdr->iNewSelection;
     310    WideCharToMultiByte (CP_ACP, 0, itemText, -1,
     311                 (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL);
     312    ansi.iWhy = hdr->iWhy;
     313    return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     314                 (LPARAM)&ansi);
    314315    }
    315316}
     
    340341    }
    341342    if (cit->mask & CBEIF_IMAGE)
    342         cit->iImage         = item->iImage;
     343    cit->iImage         = item->iImage;
    343344    if (cit->mask & CBEIF_SELECTEDIMAGE)
    344         cit->iSelectedImage = item->iSelectedImage;
     345    cit->iSelectedImage = item->iSelectedImage;
    345346    if (cit->mask & CBEIF_OVERLAY)
    346         cit->iOverlay       = item->iOverlay;
     347    cit->iOverlay       = item->iOverlay;
    347348    if (cit->mask & CBEIF_INDENT)
    348         cit->iIndent        = item->iIndent;
     349    cit->iIndent        = item->iIndent;
    349350    if (cit->mask & CBEIF_LPARAM)
    350         cit->lParam         = item->lParam;
     351    cit->lParam         = item->lParam;
    351352
    352353}
     
    364365    iinfo.rcImage.left = iinfo.rcImage.right = 0;
    365366    if (infoPtr->himl) {
    366         ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
    367         xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
     367    ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     368    xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
    368369    }
    369370    GetClientRect (infoPtr->hwndCombo, &rect);
     
    380381
    381382    TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n",
    382           rect.left, rect.top, rect.right, rect.bottom,
    383           x, y, x + w, y + h);
     383      rect.left, rect.top, rect.right, rect.bottom,
     384      x, y, x + w, y + h);
    384385    SetWindowPos(infoPtr->hwndEdit, HWND_TOP,
    385                 x, y,
    386                 w, h,
    387                 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
     386        x, y,
     387        w, h,
     388        SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
    388389}
    389390
     
    399400    cy = mysize.cy + CBE_EXTRA;
    400401    if (infoPtr->himl) {
    401         ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
    402         cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
    403         TRACE("upgraded height due to image:  height=%d\n", cy);
     402    ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     403    cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
     404    TRACE("upgraded height due to image:  height=%d\n", cy);
    404405    }
    405406    SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
    406407    if (infoPtr->hwndCombo)
    407408        SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
    408                       (WPARAM) 0, (LPARAM) cy);
     409              (WPARAM) 0, (LPARAM) cy);
    409410}
    410411
     
    419420    /*      EM_SETSEL32 (0,-1)      */
    420421    if (item->mask & CBEIF_TEXT) {
    421         SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
    422         SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
    423         SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
    424     }
    425 }
    426 
    427  
     422    SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
     423    SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
     424    SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     425    }
     426}
     427
     428
    428429static CBE_ITEMDATA *
    429430COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
     
    433434
    434435    if ((index > infoPtr->nb_items) || (index < -1))
    435         return 0;
     436    return 0;
    436437    if (index == -1)
    437         return infoPtr->edit;
     438    return infoPtr->edit;
    438439    item = infoPtr->items;
    439440    i = infoPtr->nb_items - 1;
     
    441442    /* find the item in the list */
    442443    while (item && (i > index)) {
    443         item = (CBE_ITEMDATA *)item->next;
    444         i--;
     444    item = (CBE_ITEMDATA *)item->next;
     445    i--;
    445446    }
    446447    if (!item || (i != index)) {
    447         FIXME("COMBOBOXEX item structures broken. Please report!\n");
    448         return 0;
     448    FIXME("COMBOBOXEX item structures broken. Please report!\n");
     449    return 0;
    449450    }
    450451    return item;
     
    456457{
    457458    if (item->pszText == LPSTR_TEXTCALLBACKW)
    458         FIXME("Callback not implemented yet for pszText\n");
     459    FIXME("Callback not implemented yet for pszText\n");
    459460    if (item->iImage == I_IMAGECALLBACK)
    460         FIXME("Callback not implemented yet for iImage\n");
     461    FIXME("Callback not implemented yet for iImage\n");
    461462    if (item->iSelectedImage == I_IMAGECALLBACK)
    462         FIXME("Callback not implemented yet for iSelectedImage\n");
     463    FIXME("Callback not implemented yet for iSelectedImage\n");
    463464    if (item->iOverlay == I_IMAGECALLBACK)
    464         FIXME("Callback not implemented yet for iOverlay\n");
     465    FIXME("Callback not implemented yet for iOverlay\n");
    465466    if (item->iIndent == I_INDENTCALLBACK)
    466         FIXME("Callback not implemented yet for iIndent\n");
     467    FIXME("Callback not implemented yet for iIndent\n");
    467468}
    468469
     
    482483    /* if item number requested does not exist then return failure */
    483484    if ((index > infoPtr->nb_items) || (index < 0)) {
    484         ERR("attempt to delete item that does not exist\n");
    485         return CB_ERR;
     485    ERR("attempt to delete item that does not exist\n");
     486    return CB_ERR;
    486487    }
    487488
    488489    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    489         ERR("attempt to delete item that was not found!\n");
    490         return CB_ERR;
     490    ERR("attempt to delete item that was not found!\n");
     491    return CB_ERR;
    491492    }
    492493
     
    515516
    516517    if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    517         return 0;
     518    return 0;
    518519
    519520    TRACE("-- 0x%x\n", infoPtr->hwndEdit);
     
    560561    /* if item number requested does not exist then return failure */
    561562    if ((index > infoPtr->nb_items) || (index < -1)) {
    562         ERR("attempt to get item that does not exist\n");
    563         return 0;
     563    ERR("attempt to get item that does not exist\n");
     564    return 0;
    564565    }
    565566
    566567    /* if the item is the edit control and there is no edit control, skip */
    567     if ((index == -1) && 
     568    if ((index == -1) &&
    568569        ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
    569             return 0;
     570        return 0;
    570571
    571572    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    572         ERR("attempt to get item that was not found!\n");
    573         return 0;
     573    ERR("attempt to get item that was not found!\n");
     574    return 0;
    574575    }
    575576
     
    594595
    595596    len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL);
    596     if (len > 0) 
    597         WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
    598                              cit->pszText, cit->cchTextMax, NULL, NULL);
     597    if (len > 0)
     598    WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
     599                 cit->pszText, cit->cchTextMax, NULL, NULL);
    599600
    600601    cit->iImage = tmpcit.iImage;
     
    613614    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    614615
    615     TRACE("%s hwnd=0x%x\n", 
    616            infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
     616    TRACE("%s hwnd=0x%x\n",
     617       infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    617618
    618619    return infoPtr->bUnicode;
     
    626627
    627628    if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    628         return FALSE;
    629     if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) == 
    630         (WCBE_ACTEDIT | WCBE_EDITCHG))
    631         return TRUE;
     629    return FALSE;
     630    if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) ==
     631    (WCBE_ACTEDIT | WCBE_EDITCHG))
     632    return TRUE;
    632633    return FALSE;
    633634}
     
    661662        /* fast path for iItem = -1 */
    662663        item->next = infoPtr->items;
    663         infoPtr->items = item;
     664    infoPtr->items = item;
    664665    }
    665666    else {
    666667        INT i = infoPtr->nb_items-1;
    667         CBE_ITEMDATA *moving = infoPtr->items;
    668 
    669         while ((i > index) && moving) {
    670             moving = (CBE_ITEMDATA *)moving->next;
    671             i--;
    672         }
    673         if (!moving) {
    674             FIXME("COMBOBOXEX item structures broken. Please report!\n");
    675             COMCTL32_Free(item);
    676             return -1;
    677         }
    678         item->next = moving->next;
    679         moving->next = item;
     668    CBE_ITEMDATA *moving = infoPtr->items;
     669
     670    while ((i > index) && moving) {
     671        moving = (CBE_ITEMDATA *)moving->next;
     672        i--;
     673    }
     674    if (!moving) {
     675        FIXME("COMBOBOXEX item structures broken. Please report!\n");
     676        COMCTL32_Free(item);
     677        return -1;
     678    }
     679    item->next = moving->next;
     680    moving->next = item;
    680681    }
    681682
     
    684685    if (item->mask & CBEIF_TEXT) {
    685686        LPWSTR str;
    686         INT len;
     687    INT len;
    687688
    688689        str = cit->pszText;
    689690        if (!str) str = (LPWSTR) L"";
    690         len = strlenW (str);
    691         if (len > 0) {
    692             item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    693             strcpyW (item->pszText, str);
    694         }
    695         else
    696             item->pszText = NULL;
     691    len = strlenW (str);
     692    if (len > 0) {
     693        item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     694        strcpyW (item->pszText, str);
     695    }
     696    else
     697        item->pszText = NULL;
    697698        item->cchTextMax   = cit->cchTextMax;
    698699    }
     
    713714    COMBOEX_DumpItem (item);
    714715
    715     SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 
    716                   (WPARAM)cit->iItem, (LPARAM)item);
     716    SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
     717          (WPARAM)cit->iItem, (LPARAM)item);
    717718
    718719    COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
     
    727728COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    728729{
    729     COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
    730     COMBOBOXEXITEMW     citW;
    731     LRESULT             ret;
     730    COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
     731    COMBOBOXEXITEMW citW;
     732    LRESULT     ret;
    732733
    733734    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    734735    if (cit->mask & CBEIF_TEXT) {
    735736        LPSTR str;
    736         INT len;
     737    INT len;
    737738
    738739        str = cit->pszText;
    739740        if (!str) str="";
    740         len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    741         if (len > 0) {
    742             citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    743             MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
    744         }
     741    len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     742    if (len > 0) {
     743        citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     744        MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
     745    }
    745746    }
    746747    ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);;
    747748
    748749    if (cit->mask & CBEIF_TEXT)
    749         COMCTL32_Free(citW.pszText);
     750    COMCTL32_Free(citW.pszText);
    750751    return ret;
    751752}
     
    763764
    764765    if (lParam & (CBES_EX_NOEDITIMAGEINDENT |
    765                   CBES_EX_PATHWORDBREAKPROC |
    766                   CBES_EX_NOSIZELIMIT |
    767                   CBES_EX_CASESENSITIVE))
    768         FIXME("Extended style not implemented %08lx\n", lParam);
     766          CBES_EX_PATHWORDBREAKPROC |
     767          CBES_EX_NOSIZELIMIT |
     768          CBES_EX_CASESENSITIVE))
     769    FIXME("Extended style not implemented %08lx\n", lParam);
    769770
    770771    if ((DWORD)wParam) {
    771         infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
     772    infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
    772773    }
    773774    else
    774         infoPtr->dwExtStyle = (DWORD)lParam;
     775    infoPtr->dwExtStyle = (DWORD)lParam;
    775776
    776777    /*
     
    778779     */
    779780    if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^
    780         (dwTemp & CBES_EX_NOEDITIMAGE)) {
    781         /* if state of EX_NOEDITIMAGE changes, invalidate all */
    782         TRACE("EX_NOEDITIMAGE state changed to %ld\n",
    783             infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
    784         InvalidateRect (hwnd, NULL, TRUE);
    785         COMBOEX_AdjustEditPos (infoPtr);
    786         if (infoPtr->hwndEdit)
    787             InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
     781    (dwTemp & CBES_EX_NOEDITIMAGE)) {
     782    /* if state of EX_NOEDITIMAGE changes, invalidate all */
     783    TRACE("EX_NOEDITIMAGE state changed to %ld\n",
     784        infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
     785    InvalidateRect (hwnd, NULL, TRUE);
     786    COMBOEX_AdjustEditPos (infoPtr);
     787    if (infoPtr->hwndEdit)
     788        InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
    788789    }
    789790
     
    826827    /* if item number requested does not exist then return failure */
    827828    if ((index > infoPtr->nb_items) || (index < -1)) {
    828         ERR("attempt to set item that does not exist yet!\n");
    829         return 0;
     829    ERR("attempt to set item that does not exist yet!\n");
     830    return 0;
    830831    }
    831832
    832833    /* if the item is the edit control and there is no edit control, skip */
    833     if ((index == -1) && 
     834    if ((index == -1) &&
    834835        ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
    835             return 0;
     836        return 0;
    836837
    837838    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    838         ERR("attempt to set item that was not found!\n");
    839         return 0;
    840     }
    841 
    842     /* add/change stuff to the internal item structure */ 
     839    ERR("attempt to set item that was not found!\n");
     840    return 0;
     841    }
     842
     843    /* add/change stuff to the internal item structure */
    843844    item->mask |= cit->mask;
    844845    if (cit->mask & CBEIF_TEXT) {
    845846        LPWSTR str;
    846         INT len;
    847         WCHAR emptystr[1] = {0};
     847    INT len;
     848    WCHAR emptystr[1] = {0};
    848849
    849850        str = cit->pszText;
    850851        if (!str) str=emptystr;
    851         len = strlenW(str);
    852         if (len > 0) {
    853             item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    854             strcpyW(item->pszText,str);
    855         }
     852    len = strlenW(str);
     853    if (len > 0) {
     854        item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     855        strcpyW(item->pszText,str);
     856    }
    856857        item->cchTextMax   = cit->cchTextMax;
    857858    }
     
    873874    /* if original request was to update edit control, do some fast foot work */
    874875    if (cit->iItem == -1) {
    875         COMBOEX_SetEditText (infoPtr, item);
    876         RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
     876    COMBOEX_SetEditText (infoPtr, item);
     877    RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
    877878    }
    878879    return TRUE;
     
    882883COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    883884{
    884     COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
    885     COMBOBOXEXITEMW     citW;
    886     LRESULT             ret;
     885    COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
     886    COMBOBOXEXITEMW citW;
     887    LRESULT     ret;
    887888
    888889    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    889890    if (cit->mask & CBEIF_TEXT) {
    890891        LPSTR str;
    891         INT len;
     892    INT len;
    892893
    893894        str = cit->pszText;
    894895        if (!str) str="";
    895         len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    896         if (len > 0) {
    897             citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    898             MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
    899         }
     896    len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     897    if (len > 0) {
     898        citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     899        MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
     900    }
    900901    }
    901902    ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
    902903
    903904    if (cit->mask & CBEIF_TEXT)
    904         COMCTL32_Free(citW.pszText);
     905    COMCTL32_Free(citW.pszText);
    905906    return ret;
    906907}
     
    913914    BOOL bTemp = infoPtr->bUnicode;
    914915
    915     TRACE("to %s hwnd=0x%04x, was %s\n", 
    916           ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
    917           (bTemp) ? "TRUE" : "FALSE");
     916    TRACE("to %s hwnd=0x%04x, was %s\n",
     917      ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
     918      (bTemp) ? "TRUE" : "FALSE");
    918919
    919920    infoPtr->bUnicode = (BOOL)wParam;
     
    937938    i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
    938939    if (i > 0) {
    939         desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
    940         MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
     940    desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
     941    MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
    941942    }
    942943
     
    945946    /* now search from after starting loc and wrapping back to start */
    946947    for(i=start+1; i<count; i++) {
    947         item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    948                           CB_GETITEMDATA, (WPARAM)i, 0);
    949         TRACE("desired=%s, item=%s\n",
    950               debugstr_w(desired), debugstr_w(item->pszText));
    951         if (lstrcmpiW(item->pszText, desired) == 0) {
    952             COMCTL32_Free (desired);
    953             return i;
    954         }
     948    item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     949              CB_GETITEMDATA, (WPARAM)i, 0);
     950    TRACE("desired=%s, item=%s\n",
     951          debugstr_w(desired), debugstr_w(item->pszText));
     952    if (lstrcmpiW(item->pszText, desired) == 0) {
     953        COMCTL32_Free (desired);
     954        return i;
     955    }
    955956    }
    956957    for(i=0; i<=start; i++) {
    957         item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    958                           CB_GETITEMDATA, (WPARAM)i, 0);
    959         TRACE("desired=%s, item=%s\n",
    960               debugstr_w(desired), debugstr_w(item->pszText));
    961         if (lstrcmpiW(item->pszText, desired) == 0) {
    962             COMCTL32_Free (desired);
    963             return i;
    964         }
     958    item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     959              CB_GETITEMDATA, (WPARAM)i, 0);
     960    TRACE("desired=%s, item=%s\n",
     961          debugstr_w(desired), debugstr_w(item->pszText));
     962    if (lstrcmpiW(item->pszText, desired) == 0) {
     963        COMCTL32_Free (desired);
     964        return i;
     965    }
    965966    }
    966967    COMCTL32_Free(desired);
     
    977978    LRESULT lret = 0;
    978979
    979     item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 
    980                                              wParam, lParam);
     980    item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
     981                         wParam, lParam);
    981982    if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
    982         item2 = COMBOEX_FindItem (infoPtr, index);
    983         if (item2 != item1) {
    984             ERR("data structures damaged!\n");
    985             return CB_ERR;
    986         }
    987         if (item1->mask & CBEIF_LPARAM)
    988             lret = (LRESULT) item1->lParam;
    989         TRACE("returning 0x%08lx\n", lret);
    990         return lret;
     983    item2 = COMBOEX_FindItem (infoPtr, index);
     984    if (item2 != item1) {
     985        ERR("data structures damaged!\n");
     986        return CB_ERR;
     987    }
     988    if (item1->mask & CBEIF_LPARAM)
     989        lret = (LRESULT) item1->lParam;
     990    TRACE("returning 0x%08lx\n", lret);
     991    return lret;
    991992    }
    992993    lret = (LRESULT)item1;
     
    10051006
    10061007    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    1007         /* FIXME: need to clear selection */
    1008         return CB_ERR;
     1008    /* FIXME: need to clear selection */
     1009    return CB_ERR;
    10091010    }
    10101011
    10111012    TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
    1012           debugstr_w(item->pszText) : "<null>");
     1013      debugstr_w(item->pszText) : "<null>");
    10131014    infoPtr->selected = index;
    10141015
     
    10261027    CBE_ITEMDATA *item1, *item2;
    10271028
    1028     item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 
    1029                                              wParam, lParam);
     1029    item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
     1030                         wParam, lParam);
    10301031    if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
    1031         item2 = COMBOEX_FindItem (infoPtr, index);
    1032         if (item2 != item1) {
    1033             ERR("data structures damaged!\n");
    1034             return CB_ERR;
    1035         }
    1036         item1->mask |= CBEIF_LPARAM;
    1037         item1->lParam = lParam;
    1038         TRACE("setting lparam to 0x%08lx\n", lParam);
    1039         return 0;
     1032    item2 = COMBOEX_FindItem (infoPtr, index);
     1033    if (item2 != item1) {
     1034        ERR("data structures damaged!\n");
     1035        return CB_ERR;
     1036    }
     1037    item1->mask |= CBEIF_LPARAM;
     1038    item1->lParam = lParam;
     1039    TRACE("setting lparam to 0x%08lx\n", lParam);
     1040    return 0;
    10401041    }
    10411042    TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1);
     
    10541055    /* First, lets forward the message to the normal combo control
    10551056       just like Windows.     */
    1056     if (infoPtr->hwndCombo)   
     1057    if (infoPtr->hwndCombo)
    10571058       SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
    10581059
     
    10601061    GetWindowRect (hwnd, &cbx_wrect);
    10611062    GetClientRect (hwnd, &cbx_crect);
    1062     /* the height of comboex as height of the combo + comboex border */ 
     1063    /* the height of comboex as height of the combo + comboex border */
    10631064    height = cb_wrect.bottom-cb_wrect.top
    10641065             + cbx_wrect.bottom-cbx_wrect.top
    10651066             - (cbx_crect.bottom-cbx_crect.top);
    10661067    TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
    1067           cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
    1068           cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
     1068      cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     1069      cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
    10691070    TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
    1070           cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
    1071           cbx_wrect.right-cbx_wrect.left, height);
     1071      cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
     1072      cbx_wrect.right-cbx_wrect.left, height);
    10721073    SetWindowPos (hwnd, HWND_TOP, 0, 0,
    1073                   cbx_wrect.right-cbx_wrect.left,
    1074                   height,
    1075                   SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
     1074          cbx_wrect.right-cbx_wrect.left,
     1075          height,
     1076          SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    10761077
    10771078    return ret;
     
    11011102#endif
    11021103    if (infoPtr == NULL) {
    1103         ERR("could not allocate info memory!\n");
    1104         return 0;
     1104    ERR("could not allocate info memory!\n");
     1105    return 0;
    11051106    }
    11061107
     
    11151116
    11161117    i = SendMessageA(GetParent (hwnd),
    1117                      WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     1118             WM_NOTIFYFORMAT, hwnd, NF_QUERY);
    11181119    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    1119         ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    1120             i);
    1121         i = NFR_ANSI;
     1120    ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     1121        i);
     1122    i = NFR_ANSI;
    11221123    }
    11231124    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     
    11271128    /* create combo box */
    11281129    dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
    1129                         (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
     1130            (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
    11301131
    11311132    GetWindowRect(hwnd, &wnrc1);
    11321133    GetClientRect(hwnd, &clrc1);
    11331134    TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
    1134           wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    1135           clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
     1135      wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     1136      clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
    11361137    TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle,
    11371138          WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    11381139          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
    1139           WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
     1140      WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
    11401141
    11411142    /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
     
    11471148
    11481149    infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
    1149                         /* following line added to match native */
     1150            /* following line added to match native */
    11501151                         WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    1151                          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | 
    1152                         /* was base and is necessary */
    1153                         WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
    1154                         cs->y, cs->x, cs->cx, cs->cy, hwnd,
    1155                         (HMENU) GetWindowLongA (hwnd, GWL_ID),
    1156                         GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
    1157 
    1158     /* 
     1152                         CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
     1153            /* was base and is necessary */
     1154            WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
     1155            cs->y, cs->x, cs->cx, cs->cy, hwnd,
     1156            (HMENU) GetWindowLongA (hwnd, GWL_ID),
     1157            GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     1158
     1159    /*
    11591160     * native does the following at this point according to trace:
    11601161     *  GetWindowThreadProcessId(hwndCombo,0)
     
    11651166
    11661167    /*
    1167      * Setup a property to hold the pointer to the COMBOBOXEX 
     1168     * Setup a property to hold the pointer to the COMBOBOXEX
    11681169     * data structure.
    11691170     */
    11701171    test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo);
    11711172    if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
    1172         SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
    1173     }
    1174     infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo, 
    1175                                 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
     1173    SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
     1174    }
     1175    infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo,
     1176                            GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
    11761177    infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    11771178
     
    11821183     */
    11831184    if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
    1184         infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
    1185                     WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
    1186                     0, 0, 0, 0,  /* will set later */
    1187                     infoPtr->hwndCombo,
    1188                     (HMENU) GetWindowLongA (hwnd, GWL_ID),
    1189                     GetWindowLongA (hwnd, GWL_HINSTANCE),
    1190                     NULL);
    1191 
    1192         /* native does the following at this point according to trace:
    1193         *  GetWindowThreadProcessId(hwndEdit,0)
    1194         *  GetCurrentThreadId()
    1195         *  GetWindowThreadProcessId(hwndEdit, &???)
    1196         *  GetCurrentProcessId()
    1197         */
    1198 
    1199         /*
    1200          * Setup a property to hold the pointer to the COMBOBOXEX
    1201         * data structure.
    1202         */
    1203         test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
    1204         if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
    1205             SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
    1206         }
    1207         infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
    1208                                 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
    1209         infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     1185    infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
     1186            WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
     1187            0, 0, 0, 0,  /* will set later */
     1188            infoPtr->hwndCombo,
     1189            (HMENU) GetWindowLongA (hwnd, GWL_ID),
     1190            GetWindowLongA (hwnd, GWL_HINSTANCE),
     1191            NULL);
     1192
     1193    /* native does the following at this point according to trace:
     1194    *  GetWindowThreadProcessId(hwndEdit,0)
     1195    *  GetCurrentThreadId()
     1196    *  GetWindowThreadProcessId(hwndEdit, &???)
     1197    *  GetCurrentProcessId()
     1198    */
     1199
     1200    /*
     1201     * Setup a property to hold the pointer to the COMBOBOXEX
     1202    * data structure.
     1203    */
     1204    test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
     1205    if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
     1206        SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
     1207    }
     1208    infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
     1209                GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
     1210    infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    12101211    }
    12111212    else {
    1212         infoPtr->hwndEdit = 0;
    1213         infoPtr->font = 0;
     1213    infoPtr->hwndEdit = 0;
     1214    infoPtr->font = 0;
    12141215    }
    12151216
     
    12191220     */
    12201221    if (!infoPtr->font) {
    1221         SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
    1222                                &mylogfont, 0);
    1223         infoPtr->font = CreateFontIndirectA (&mylogfont);
     1222    SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
     1223                   &mylogfont, 0);
     1224    infoPtr->font = CreateFontIndirectA (&mylogfont);
    12241225    }
    12251226    SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
    12261227    if (infoPtr->hwndEdit) {
    1227         SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
    1228         SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
     1228    SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
     1229    SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
    12291230    }
    12301231
     
    12371238    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
    12381239    TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) CB wnd=(%d,%d)-(%d,%d)\n",
    1239           wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    1240           clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
    1241           cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    1242     SetWindowPos(infoPtr->hwndCombo, HWND_TOP, 
    1243                 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
    1244                 SWP_NOACTIVATE | SWP_NOREDRAW);
     1240      wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     1241      clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     1242      cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
     1243    SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
     1244        0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
     1245        SWP_NOACTIVATE | SWP_NOREDRAW);
    12451246
    12461247    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
    12471248    TRACE("CB window=(%d,%d)-(%d,%d)\n",
    1248           cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    1249     SetWindowPos(hwnd, HWND_TOP, 
    1250                 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
    1251                 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
     1249      cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
     1250    SetWindowPos(hwnd, HWND_TOP,
     1251        0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
     1252        SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    12521253
    12531254    COMBOEX_AdjustEditPos (infoPtr);
    12541255
    12551256    /*
    1256      * Create an item structure to represent the data in the 
     1257     * Create an item structure to represent the data in the
    12571258     * EDIT control.
    12581259     */
     
    12841285    {
    12851286    case CBN_DROPDOWN:
    1286         SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1287                              (LPARAM)hwnd);
    1288         /*
    1289          * from native trace of first dropdown after typing in URL in IE4
    1290         *  CB_GETCURSEL(Combo)
    1291         *  GetWindowText(Edit)
    1292         *  CB_GETCURSEL(Combo)
    1293         *  CB_GETCOUNT(Combo)
    1294         *  CB_GETITEMDATA(Combo, n)
    1295         *  WM_NOTIFY(parent, CBEN_ENDEDITA|W)
    1296         *  CB_GETCURSEL(Combo)
    1297         *  CB_SETCURSEL(COMBOEX, n)
    1298         *  SetFocus(Combo)
    1299          * the rest is supposition 
    1300         */
    1301         cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    1302         if (cursel == -1) {
    1303             /* find match from edit against those in Combobox */
    1304             GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
    1305             n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
    1306             for (cursel = 0; cursel < n; cursel++){
    1307                 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1308                                                      CB_GETITEMDATA,
    1309                                                      cursel, 0);
    1310                 if ((INT)item == CB_ERR) break;
    1311                 if (lstrcmpiW(item->pszText, wintext) == 0) break;
    1312             }
    1313             if ((cursel == n) || ((INT)item == CB_ERR)) {
    1314                 TRACE("failed to find match??? item=%p cursel=%d\n",
    1315                       item, cursel);
    1316                 if (infoPtr->hwndEdit)
    1317                     SetFocus(infoPtr->hwndEdit);
    1318                 return 0;
    1319             }
    1320         }
    1321         else {
    1322             item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1323                                                  CB_GETITEMDATA,
    1324                                                 cursel, 0);
    1325             if ((INT)item == CB_ERR) {
    1326                 TRACE("failed to find match??? item=%p cursel=%d\n",
    1327                       item, cursel);
    1328                 if (infoPtr->hwndEdit)
    1329                     SetFocus(infoPtr->hwndEdit);
    1330                 return 0;
    1331             }
    1332         }
    1333 
    1334         /* Save flags for testing and reset them */
    1335         oldflags = infoPtr->flags;
    1336         infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    1337 
    1338         if (oldflags & WCBE_ACTEDIT) {
    1339             cbeend.fChanged = (oldflags & WCBE_EDITCHG);
    1340             cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    1341                                                 CB_GETCURSEL, 0, 0);
    1342             cbeend.iWhy = CBENF_DROPDOWN;
    1343 
    1344             if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) {
    1345                 /* abort the change */
    1346                 TRACE("Notify requested abort of change\n");
    1347                 return 0;
    1348             }
    1349         }
    1350 
    1351         /* if selection has changed the set the new current selection */
    1352         cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    1353         if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
    1354             infoPtr->selected = cursel;
    1355             SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
    1356             SetFocus(infoPtr->hwndCombo);
    1357         }
    1358         return 0;
     1287    SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1288                 (LPARAM)hwnd);
     1289    /*
     1290     * from native trace of first dropdown after typing in URL in IE4
     1291    *  CB_GETCURSEL(Combo)
     1292    *  GetWindowText(Edit)
     1293    *  CB_GETCURSEL(Combo)
     1294    *  CB_GETCOUNT(Combo)
     1295    *  CB_GETITEMDATA(Combo, n)
     1296    *  WM_NOTIFY(parent, CBEN_ENDEDITA|W)
     1297    *  CB_GETCURSEL(Combo)
     1298    *  CB_SETCURSEL(COMBOEX, n)
     1299    *  SetFocus(Combo)
     1300     * the rest is supposition
     1301    */
     1302    cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1303    if (cursel == -1) {
     1304        /* find match from edit against those in Combobox */
     1305        GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
     1306        n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
     1307        for (cursel = 0; cursel < n; cursel++){
     1308        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1309                             CB_GETITEMDATA,
     1310                             cursel, 0);
     1311        if ((INT)item == CB_ERR) break;
     1312        if (lstrcmpiW(item->pszText, wintext) == 0) break;
     1313        }
     1314        if ((cursel == n) || ((INT)item == CB_ERR)) {
     1315        TRACE("failed to find match??? item=%p cursel=%d\n",
     1316              item, cursel);
     1317        if (infoPtr->hwndEdit)
     1318            SetFocus(infoPtr->hwndEdit);
     1319        return 0;
     1320        }
     1321    }
     1322    else {
     1323        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1324                         CB_GETITEMDATA,
     1325                        cursel, 0);
     1326        if ((INT)item == CB_ERR) {
     1327        TRACE("failed to find match??? item=%p cursel=%d\n",
     1328              item, cursel);
     1329        if (infoPtr->hwndEdit)
     1330            SetFocus(infoPtr->hwndEdit);
     1331        return 0;
     1332        }
     1333    }
     1334
     1335    /* Save flags for testing and reset them */
     1336    oldflags = infoPtr->flags;
     1337    infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1338
     1339    if (oldflags & WCBE_ACTEDIT) {
     1340        cbeend.fChanged = (oldflags & WCBE_EDITCHG);
     1341        cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1342                        CB_GETCURSEL, 0, 0);
     1343        cbeend.iWhy = CBENF_DROPDOWN;
     1344
     1345        if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) {
     1346        /* abort the change */
     1347        TRACE("Notify requested abort of change\n");
     1348        return 0;
     1349        }
     1350    }
     1351
     1352    /* if selection has changed the set the new current selection */
     1353    cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1354    if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
     1355        infoPtr->selected = cursel;
     1356        SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
     1357        SetFocus(infoPtr->hwndCombo);
     1358    }
     1359    return 0;
    13591360
    13601361    case CBN_SELCHANGE:
    1361         /*
    1362         * CB_GETCURSEL(Combo)
    1363         * CB_GETITEMDATA(Combo)   < simulated by COMBOEX_FindItem
    1364         * lstrlenA
    1365         * WM_SETTEXT(Edit)
    1366         * WM_GETTEXTLENGTH(Edit)
    1367         * WM_GETTEXT(Edit)
    1368         * EM_SETSEL(Edit, 0,0)
    1369         * WM_GETTEXTLENGTH(Edit)
    1370         * WM_GETTEXT(Edit)
    1371         * EM_SETSEL(Edit, 0,len)
    1372         * return WM_COMMAND to parent
    1373         */
    1374         oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    1375         if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
    1376             ERR("item %d not found. Problem!\n", oldItem);
    1377             break;
    1378         }
    1379         infoPtr->selected = oldItem;
    1380         COMBOEX_SetEditText (infoPtr, item);
    1381         return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1382                              (LPARAM)hwnd);
     1362    /*
     1363    * CB_GETCURSEL(Combo)
     1364    * CB_GETITEMDATA(Combo)   < simulated by COMBOEX_FindItem
     1365    * lstrlenA
     1366    * WM_SETTEXT(Edit)
     1367    * WM_GETTEXTLENGTH(Edit)
     1368    * WM_GETTEXT(Edit)
     1369    * EM_SETSEL(Edit, 0,0)
     1370    * WM_GETTEXTLENGTH(Edit)
     1371    * WM_GETTEXT(Edit)
     1372    * EM_SETSEL(Edit, 0,len)
     1373    * return WM_COMMAND to parent
     1374    */
     1375    oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1376    if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     1377        ERR("item %d not found. Problem!\n", oldItem);
     1378        break;
     1379    }
     1380    infoPtr->selected = oldItem;
     1381    COMBOEX_SetEditText (infoPtr, item);
     1382    return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1383                 (LPARAM)hwnd);
    13831384
    13841385    case CBN_SELENDOK:
    1385         /*
    1386         * We have to change the handle since we are the control
    1387         * issuing the message. IE4 depends on this.
    1388         */
    1389         return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1390                              (LPARAM)hwnd);
     1386    /*
     1387    * We have to change the handle since we are the control
     1388    * issuing the message. IE4 depends on this.
     1389    */
     1390    return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1391                 (LPARAM)hwnd);
    13911392
    13921393    case CBN_KILLFOCUS:
    1393         /*
    1394         * from native trace:
    1395         *
    1396         *  pass to parent
    1397         *  WM_GETTEXT(Edit, 104)
    1398         *  CB_GETCURSEL(Combo) rets -1
    1399         *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
    1400         *  CB_GETCURSEL(Combo)
    1401         *  InvalidateRect(Combo, 0, 0)
    1402         *  return 0
    1403         */
    1404         SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1405                              (LPARAM)hwnd);
    1406         if (infoPtr->flags & WCBE_ACTEDIT) {
    1407             GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
    1408             cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
    1409             cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    1410                                                 CB_GETCURSEL, 0, 0);
    1411             cbeend.iWhy = CBENF_KILLFOCUS;
    1412 
    1413             infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    1414             if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) {
    1415                 /* abort the change */
    1416                 TRACE("Notify requested abort of change\n");
    1417                 return 0;
    1418             }
    1419         }
    1420         /* possible CB_GETCURSEL */
    1421         InvalidateRect (infoPtr->hwndCombo, 0, 0);
    1422         return 0;
     1394    /*
     1395    * from native trace:
     1396    *
     1397    *  pass to parent
     1398    *  WM_GETTEXT(Edit, 104)
     1399    *  CB_GETCURSEL(Combo) rets -1
     1400    *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
     1401    *  CB_GETCURSEL(Combo)
     1402    *  InvalidateRect(Combo, 0, 0)
     1403    *  return 0
     1404    */
     1405    SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1406                 (LPARAM)hwnd);
     1407    if (infoPtr->flags & WCBE_ACTEDIT) {
     1408        GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
     1409        cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     1410        cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1411                        CB_GETCURSEL, 0, 0);
     1412        cbeend.iWhy = CBENF_KILLFOCUS;
     1413
     1414        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1415        if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) {
     1416        /* abort the change */
     1417        TRACE("Notify requested abort of change\n");
     1418        return 0;
     1419        }
     1420    }
     1421    /* possible CB_GETCURSEL */
     1422    InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1423    return 0;
    14231424
    14241425    case CBN_CLOSEUP:
    14251426    default:
    1426         /*
    1427         * We have to change the handle since we are the control
    1428         * issuing the message. IE4 depends on this.
    1429         * We also need to set the focus back to the Edit control
    1430         * after passing the command to the parent of the ComboEx.
    1431         */
    1432         lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1433                              (LPARAM)hwnd);
    1434         if (infoPtr->hwndEdit)
    1435             SetFocus(infoPtr->hwndEdit);
    1436         return lret;
     1427    /*
     1428    * We have to change the handle since we are the control
     1429    * issuing the message. IE4 depends on this.
     1430    * We also need to set the focus back to the Edit control
     1431    * after passing the command to the parent of the ComboEx.
     1432    */
     1433    lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1434                 (LPARAM)hwnd);
     1435    if (infoPtr->hwndEdit)
     1436        SetFocus(infoPtr->hwndEdit);
     1437    return lret;
    14371438    }
    14381439    return 0;
     
    14501451
    14511452    TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
    1452           dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
     1453      dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
    14531454
    14541455    if ((dis->itemID >= infoPtr->nb_items) || (dis->itemID < 0)) return FALSE;
     
    14581459
    14591460    if (i == dis->itemID) {
    1460         infoPtr->items = infoPtr->items->next;
     1461    infoPtr->items = infoPtr->items->next;
    14611462    }
    14621463    else {
    1463         item = olditem;
    1464         i--;
    1465 
    1466         /* find the prior item in the list */
    1467         while (item->next && (i > dis->itemID)) {
    1468             item = (CBE_ITEMDATA *)item->next;
    1469             i--;
    1470         }
    1471         if (!item->next || (i != dis->itemID)) {
    1472             FIXME("COMBOBOXEX item structures broken. Please report!\n");
    1473             return FALSE;
    1474         }
    1475         olditem = item->next;
    1476         item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
     1464    item = olditem;
     1465    i--;
     1466
     1467    /* find the prior item in the list */
     1468    while (item->next && (i > dis->itemID)) {
     1469        item = (CBE_ITEMDATA *)item->next;
     1470        i--;
     1471    }
     1472    if (!item->next || (i != dis->itemID)) {
     1473        FIXME("COMBOBOXEX item structures broken. Please report!\n");
     1474        return FALSE;
     1475    }
     1476    olditem = item->next;
     1477    item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
    14771478    }
    14781479    infoPtr->nb_items--;
     
    14821483
    14831484    if (olditem->pszText)
    1484         COMCTL32_Free(olditem->pszText);
     1485    COMCTL32_Free(olditem->pszText);
    14851486    COMCTL32_Free(olditem);
    14861487
     
    15101511    /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
    15111512    if (!TRACE_ON(message)) {
    1512         TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
    1513               dis->CtlType, dis->CtlID);
    1514         TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
    1515               dis->itemID, dis->itemAction, dis->itemState);
    1516         TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
    1517               dis->hwndItem, dis->hDC, dis->rcItem.left,
    1518               dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
    1519               dis->itemData);
     1513    TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
     1514          dis->CtlType, dis->CtlID);
     1515    TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
     1516          dis->itemID, dis->itemAction, dis->itemState);
     1517    TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
     1518          dis->hwndItem, dis->hDC, dis->rcItem.left,
     1519          dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
     1520          dis->itemData);
    15201521    }
    15211522
     
    15321533    /*      though the list box or combo box has the focus.             */
    15331534    if (dis->itemID == 0xffffffff) {
    1534         if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
    1535              ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
    1536 
    1537             TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
    1538                   dis->rcItem.left, dis->rcItem.top,
    1539                   dis->rcItem.right, dis->rcItem.bottom);
    1540         }
    1541         else if ((dis->CtlType == ODT_COMBOBOX) &&
    1542                 (dis->itemAction == ODA_DRAWENTIRE)) {
    1543             /* draw of edit control data */
    1544 
    1545             /* testing */
    1546             {
    1547                 RECT exrc, cbrc, edrc;
    1548                 GetWindowRect (hwnd, &exrc);
    1549                 GetWindowRect (infoPtr->hwndCombo, &cbrc);
    1550                 edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
    1551                 if (infoPtr->hwndEdit)
    1552                     GetWindowRect (infoPtr->hwndEdit, &edrc);
    1553                 TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
    1554                       exrc.left, exrc.top, exrc.right, exrc.bottom,
    1555                       cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
    1556                       edrc.left, edrc.top, edrc.right, edrc.bottom);
    1557             }
    1558         }
    1559         else {
    1560             ERR("NOT drawing item  -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
    1561                 dis->rcItem.left, dis->rcItem.top,
    1562                 dis->rcItem.right, dis->rcItem.bottom,
    1563                 dis->itemAction, dis->itemState);
    1564             return 0;
    1565         }
     1535    if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
     1536         ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
     1537
     1538        TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
     1539          dis->rcItem.left, dis->rcItem.top,
     1540          dis->rcItem.right, dis->rcItem.bottom);
     1541    }
     1542    else if ((dis->CtlType == ODT_COMBOBOX) &&
     1543        (dis->itemAction == ODA_DRAWENTIRE)) {
     1544        /* draw of edit control data */
     1545
     1546        /* testing */
     1547        {
     1548        RECT exrc, cbrc, edrc;
     1549        GetWindowRect (hwnd, &exrc);
     1550        GetWindowRect (infoPtr->hwndCombo, &cbrc);
     1551        edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
     1552        if (infoPtr->hwndEdit)
     1553            GetWindowRect (infoPtr->hwndEdit, &edrc);
     1554        TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
     1555              exrc.left, exrc.top, exrc.right, exrc.bottom,
     1556              cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
     1557              edrc.left, edrc.top, edrc.right, edrc.bottom);
     1558        }
     1559    }
     1560    else {
     1561        ERR("NOT drawing item  -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
     1562        dis->rcItem.left, dis->rcItem.top,
     1563        dis->rcItem.right, dis->rcItem.bottom,
     1564        dis->itemAction, dis->itemState);
     1565        return 0;
     1566    }
    15661567    }
    15671568
    15681569    /* If draw item is -1 (edit control) setup the item pointer */
    15691570    if (dis->itemID == 0xffffffff) {
    1570         CHAR str[260];
    1571         INT wlen, alen;
    1572 
    1573         item = infoPtr->edit;
    1574 
    1575         if (infoPtr->hwndEdit) {
    1576 
    1577             /* free previous text of edit item */
    1578             if (item->pszText) {
    1579                 COMCTL32_Free(item->pszText);
    1580                 item->pszText = 0;
    1581                 item->mask &= ~CBEIF_TEXT;
    1582             }
    1583             alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
    1584             TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
    1585                   infoPtr->hwndEdit, alen, str);
    1586             if (alen > 0) {
    1587                 item->mask |= CBEIF_TEXT;
    1588                 wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    1589                 if (wlen > 0) {
    1590                     item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
    1591                     MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
    1592                 }
    1593             }
    1594         }
     1571    CHAR str[260];
     1572    INT wlen, alen;
     1573
     1574    item = infoPtr->edit;
     1575
     1576    if (infoPtr->hwndEdit) {
     1577
     1578        /* free previous text of edit item */
     1579        if (item->pszText) {
     1580        COMCTL32_Free(item->pszText);
     1581        item->pszText = 0;
     1582        item->mask &= ~CBEIF_TEXT;
     1583        }
     1584        alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
     1585        TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
     1586          infoPtr->hwndEdit, alen, str);
     1587        if (alen > 0) {
     1588        item->mask |= CBEIF_TEXT;
     1589        wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     1590        if (wlen > 0) {
     1591            item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
     1592            MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
     1593        }
     1594        }
     1595    }
    15951596    }
    15961597
    15971598    /* if the item pointer is not set, then get the data and locate it */
    15981599    if (!item) {
    1599         item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1600                              CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
    1601         if (item == (CBE_ITEMDATA *)CB_ERR)
    1602             {
    1603                 FIXME("invalid item for id %d \n",dis->itemID);
    1604                 return 0;
    1605             }
     1600    item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1601                 CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
     1602    if (item == (CBE_ITEMDATA *)CB_ERR)
     1603        {
     1604        FIXME("invalid item for id %d \n",dis->itemID);
     1605        return 0;
     1606        }
    16061607    }
    16071608
     
    16121613        xbase += (item->iIndent * CBE_INDENT);
    16131614    if (item->mask & CBEIF_IMAGE) {
    1614         ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
    1615         xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
     1615    ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
     1616    xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
    16161617    }
    16171618
     
    16191620    case ODA_FOCUS:
    16201621        if (dis->itemState & ODS_SELECTED /*1*/) {
    1621             if ((item->mask & CBEIF_TEXT) && item->pszText) {
    1622                 RECT rect2;
    1623 
    1624                 len = strlenW (item->pszText);
    1625                 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
    1626                 rect.left = xbase + xioff - 1;
    1627                 rect.right = rect.left + txtsize.cx + 2;
    1628                 rect.top = dis->rcItem.top;
    1629                 rect.bottom = dis->rcItem.bottom;
    1630                 GetClipBox (dis->hDC, &rect2);
    1631                 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
    1632                       dis->itemID, rect.left, rect.top,
    1633                       rect.right, rect.bottom);
    1634                 TRACE("                      clip=(%d,%d)-(%d,%d)\n",
    1635                       rect2.left, rect2.top,
    1636                       rect2.right, rect2.bottom);
    1637 
    1638                 DrawFocusRect(dis->hDC, &rect);
    1639             }
    1640             else {
    1641                 FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
    1642             }
    1643         }
    1644         else {
    1645             FIXME("ODA_FOCUS but not ODS_SELECTED\n");
    1646         }
     1622        if ((item->mask & CBEIF_TEXT) && item->pszText) {
     1623        RECT rect2;
     1624
     1625            len = strlenW (item->pszText);
     1626        GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
     1627        rect.left = xbase + xioff - 1;
     1628        rect.right = rect.left + txtsize.cx + 2;
     1629        rect.top = dis->rcItem.top;
     1630        rect.bottom = dis->rcItem.bottom;
     1631        GetClipBox (dis->hDC, &rect2);
     1632        TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
     1633              dis->itemID, rect.left, rect.top,
     1634              rect.right, rect.bottom);
     1635        TRACE("                      clip=(%d,%d)-(%d,%d)\n",
     1636              rect2.left, rect2.top,
     1637              rect2.right, rect2.bottom);
     1638
     1639        DrawFocusRect(dis->hDC, &rect);
     1640        }
     1641        else {
     1642        FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
     1643        }
     1644    }
     1645    else {
     1646        FIXME("ODA_FOCUS but not ODS_SELECTED\n");
     1647    }
    16471648        break;
    16481649    case ODA_SELECT:
    16491650    case ODA_DRAWENTIRE:
    16501651        drawimage = -1;
    1651         drawstate = ILD_NORMAL;
    1652         if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
    1653             if (item->mask & CBEIF_IMAGE)
    1654                 drawimage = item->iImage;
    1655             if (dis->itemState & ODS_COMBOEXLBOX) {
    1656                 /* drawing listbox entry */
    1657                 if (dis->itemState & ODS_SELECTED) {
    1658                     if (item->mask & CBEIF_SELECTEDIMAGE)
    1659                         drawimage = item->iSelectedImage;
    1660                     drawstate = ILD_SELECTED;
    1661                 }
    1662             }
    1663             else {
    1664                 /* drawing combo/edit entry */
    1665                 if (infoPtr->hwndEdit) {
    1666                     /* if we have an edit control, the slave the
    1667                      * selection state to the Edit focus state 
    1668                      */
    1669                     if (infoPtr->flags & WCBE_EDITFOCUSED) {
    1670                         if (item->mask & CBEIF_SELECTEDIMAGE)
    1671                             drawimage = item->iSelectedImage;
    1672                         drawstate = ILD_SELECTED;
    1673                     }
    1674                 }
    1675                 else {
    1676                     /* if we don't have an edit control, use
    1677                      * the requested state.
    1678                      */
    1679                     if (dis->itemState & ODS_SELECTED) {
    1680                         if (item->mask & CBEIF_SELECTEDIMAGE)
    1681                             drawimage = item->iSelectedImage;
    1682                         drawstate = ILD_SELECTED;
    1683                     }
    1684                 }
    1685             }
    1686         }
    1687         if (drawimage != -1) {
    1688             TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
    1689             ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
    1690                             xbase, dis->rcItem.top, drawstate);
    1691         }
    1692 
    1693         /* setup pointer to text to be drawn */
    1694         if ((item->mask & CBEIF_TEXT) && item->pszText)
    1695             str = item->pszText;
    1696         else
    1697             str = (LPWSTR) L"";
    1698 
    1699         /* now draw the text */
    1700         len = lstrlenW (str);
    1701         GetTextExtentPointW (dis->hDC, str, len, &txtsize);
    1702         nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    1703                             COLOR_HIGHLIGHT : COLOR_WINDOW);
    1704         SetBkColor (dis->hDC, nbkc);
    1705         ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    1706                             COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
    1707         SetTextColor (dis->hDC, ntxc);
    1708         x = xbase + xioff;
    1709         y = dis->rcItem.top +
    1710             (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
    1711         rect.left = x;
    1712         rect.right = x + txtsize.cx;
    1713         rect.top = dis->rcItem.top + 1;
    1714         rect.bottom = dis->rcItem.bottom - 1;
    1715         TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
    1716               dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    1717         ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
    1718                      &rect, str, len, 0);
    1719         if (dis->itemState & ODS_FOCUS) {
    1720             rect.top -= 1;
    1721             rect.bottom += 1;
    1722             rect.left -= 1;
    1723             rect.right += 1;
    1724             TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
    1725                   dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    1726             DrawFocusRect (dis->hDC, &rect);
    1727         }
    1728         break;
     1652    drawstate = ILD_NORMAL;
     1653    if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
     1654        if (item->mask & CBEIF_IMAGE)
     1655        drawimage = item->iImage;
     1656        if (dis->itemState & ODS_COMBOEXLBOX) {
     1657        /* drawing listbox entry */
     1658        if (dis->itemState & ODS_SELECTED) {
     1659            if (item->mask & CBEIF_SELECTEDIMAGE)
     1660            drawimage = item->iSelectedImage;
     1661            drawstate = ILD_SELECTED;
     1662        }
     1663        }
     1664        else {
     1665        /* drawing combo/edit entry */
     1666        if (infoPtr->hwndEdit) {
     1667            /* if we have an edit control, the slave the
     1668                     * selection state to the Edit focus state
     1669             */
     1670            if (infoPtr->flags & WCBE_EDITFOCUSED) {
     1671            if (item->mask & CBEIF_SELECTEDIMAGE)
     1672                drawimage = item->iSelectedImage;
     1673            drawstate = ILD_SELECTED;
     1674            }
     1675        }
     1676        else {
     1677            /* if we don't have an edit control, use
     1678             * the requested state.
     1679             */
     1680            if (dis->itemState & ODS_SELECTED) {
     1681            if (item->mask & CBEIF_SELECTEDIMAGE)
     1682                drawimage = item->iSelectedImage;
     1683            drawstate = ILD_SELECTED;
     1684            }
     1685        }
     1686        }
     1687    }
     1688    if (drawimage != -1) {
     1689        TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
     1690        ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
     1691                xbase, dis->rcItem.top, drawstate);
     1692    }
     1693
     1694    /* setup pointer to text to be drawn */
     1695    if ((item->mask & CBEIF_TEXT) && item->pszText)
     1696        str = item->pszText;
     1697    else
     1698        str = (LPWSTR) L"";
     1699
     1700    /* now draw the text */
     1701    len = lstrlenW (str);
     1702    GetTextExtentPointW (dis->hDC, str, len, &txtsize);
     1703    nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1704                COLOR_HIGHLIGHT : COLOR_WINDOW);
     1705    SetBkColor (dis->hDC, nbkc);
     1706    ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1707                COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
     1708    SetTextColor (dis->hDC, ntxc);
     1709    x = xbase + xioff;
     1710    y = dis->rcItem.top +
     1711        (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
     1712    rect.left = x;
     1713    rect.right = x + txtsize.cx;
     1714    rect.top = dis->rcItem.top + 1;
     1715    rect.bottom = dis->rcItem.bottom - 1;
     1716    TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
     1717          dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1718    ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
     1719             &rect, str, len, 0);
     1720    if (dis->itemState & ODS_FOCUS) {
     1721        rect.top -= 1;
     1722        rect.bottom += 1;
     1723        rect.left -= 1;
     1724        rect.right += 1;
     1725        TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
     1726          dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1727        DrawFocusRect (dis->hDC, &rect);
     1728    }
     1729    break;
    17291730    default:
    1730         FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n", 
    1731               hwnd, wParam, lParam, dis->itemAction);
     1731        FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
     1732          hwnd, wParam, lParam, dis->itemAction);
    17321733    }
    17331734
     
    17421743
    17431744    if (infoPtr->hwndCombo)
    1744         DestroyWindow (infoPtr->hwndCombo);
     1745    DestroyWindow (infoPtr->hwndCombo);
    17451746
    17461747    if (infoPtr->edit) {
    1747         COMCTL32_Free (infoPtr->edit);
    1748         infoPtr->edit = 0;
     1748    COMCTL32_Free (infoPtr->edit);
     1749    infoPtr->edit = 0;
    17491750    }
    17501751
     
    17521753        CBE_ITEMDATA *this, *next;
    17531754
    1754         this = infoPtr->items;
    1755         while (this) {
    1756             next = (CBE_ITEMDATA *)this->next;
    1757             if ((this->mask & CBEIF_TEXT) && this->pszText)
    1758                 COMCTL32_Free (this->pszText);
    1759             COMCTL32_Free (this);
    1760             this = next;
    1761         }
     1755    this = infoPtr->items;
     1756    while (this) {
     1757        next = (CBE_ITEMDATA *)this->next;
     1758        if ((this->mask & CBEIF_TEXT) && this->pszText)
     1759            COMCTL32_Free (this->pszText);
     1760        COMCTL32_Free (this);
     1761        this = next;
     1762    }
    17621763    }
    17631764
     
    17851786
    17861787    TRACE("adjusted height hwnd=%08x, height=%d\n",
    1787           hwnd, mis->itemHeight);
     1788      hwnd, mis->itemHeight);
    17881789
    17891790    return 0;
     
    18001801    newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
    18011802    if (newstyle != oldstyle) {
    1802         TRACE("req style %08lx, reseting style %08lx\n",
    1803               oldstyle, newstyle);
    1804         SetWindowLongA (hwnd, GWL_STYLE, newstyle);
     1803    TRACE("req style %08lx, reseting style %08lx\n",
     1804          oldstyle, newstyle);
     1805    SetWindowLongA (hwnd, GWL_STYLE, newstyle);
    18051806    }
    18061807    return 1;
     
    18151816
    18161817    if (lParam == NF_REQUERY) {
    1817         i = SendMessageA(GetParent (hwnd),
    1818                         WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
    1819         if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    1820             ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    1821                 i);
    1822             i = NFR_ANSI;
    1823         }
    1824         infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    1825         return (LRESULT)i;
     1818    i = SendMessageA(GetParent (hwnd),
     1819            WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     1820    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     1821        ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     1822        i);
     1823        i = NFR_ANSI;
     1824    }
     1825    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     1826    return (LRESULT)i;
    18261827    }
    18271828    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
     
    18371838    GetWindowRect (hwnd, &rect);
    18381839    TRACE("my rect (%d,%d)-(%d,%d)\n",
    1839           rect.left, rect.top, rect.right, rect.bottom);
     1840      rect.left, rect.top, rect.right, rect.bottom);
    18401841
    18411842    MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
    1842                   rect.bottom - rect.top, TRUE);
     1843          rect.bottom - rect.top, TRUE);
    18431844
    18441845    COMBOEX_AdjustEditPos (infoPtr);
     
    18621863    /* width is winpos value + border width of comboex */
    18631864    width = wp->cx
    1864             + (cbx_wrect.right-cbx_wrect.left)
    1865             - (cbx_crect.right-cbx_crect.left); 
     1865        + (cbx_wrect.right-cbx_wrect.left)
     1866            - (cbx_crect.right-cbx_crect.left);
    18661867
    18671868    TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
    1868           wp->x, wp->y, wp->cx, wp->cy, wp->flags);
     1869      wp->x, wp->y, wp->cx, wp->cy, wp->flags);
    18691870    TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
    1870           cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
    1871           cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
     1871      cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     1872      cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
    18721873    TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
    1873           cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
    1874           width, cb_wrect.bottom-cb_wrect.top);
     1874      cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
     1875      width, cb_wrect.bottom-cb_wrect.top);
    18751876
    18761877    if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
    1877                              width,
    1878                              cb_wrect.bottom-cb_wrect.top,
    1879                              SWP_NOACTIVATE);
     1878                 width,
     1879                 cb_wrect.bottom-cb_wrect.top,
     1880                 SWP_NOACTIVATE);
    18801881
    18811882    GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
     
    18831884    /* height is combo window height plus border width of comboex */
    18841885    height =   (cb_wrect.bottom-cb_wrect.top)
    1885              + (cbx_wrect.bottom-cbx_wrect.top)
     1886         + (cbx_wrect.bottom-cbx_wrect.top)
    18861887             - (cbx_crect.bottom-cbx_crect.top);
    18871888    if (wp->cy < height) wp->cy = height;
    18881889    if (infoPtr->hwndEdit) {
    1889         COMBOEX_AdjustEditPos (infoPtr);
    1890         InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
     1890    COMBOEX_AdjustEditPos (infoPtr);
     1891    InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
    18911892    }
    18921893
     
    19061907    LRESULT lret;
    19071908
    1908     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 
    1909           hwnd, uMsg, wParam, lParam, infoPtr);
     1909    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     1910      hwnd, uMsg, wParam, lParam, infoPtr);
    19101911
    19111912    if (!infoPtr) return 0;
     
    19151916
    19161917    case WM_CHAR:
    1917             /* handle (ignore) the return character */
    1918             if (wParam == VK_RETURN) return 0;
    1919             /* all other characters pass into the real Edit */
    1920             return CallWindowProcA (infoPtr->prevEditWndProc,
    1921                                    hwnd, uMsg, wParam, lParam);
     1918        /* handle (ignore) the return character */
     1919        if (wParam == VK_RETURN) return 0;
     1920        /* all other characters pass into the real Edit */
     1921        return CallWindowProcA (infoPtr->prevEditWndProc,
     1922                   hwnd, uMsg, wParam, lParam);
    19221923
    19231924    case WM_ERASEBKGND:
    1924             /*
    1925              * The following was determined by traces of the native
    1926              */
     1925        /*
     1926         * The following was determined by traces of the native
     1927         */
    19271928            hDC = (HDC) wParam;
    1928             nbkc = GetSysColor (COLOR_WINDOW);
    1929             obkc = SetBkColor (hDC, nbkc);
     1929        nbkc = GetSysColor (COLOR_WINDOW);
     1930        obkc = SetBkColor (hDC, nbkc);
    19301931            GetClientRect (hwnd, &rect);
    1931             TRACE("erasing (%d,%d)-(%d,%d)\n",
    1932                   rect.left, rect.top, rect.right, rect.bottom);
    1933             ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
     1932        TRACE("erasing (%d,%d)-(%d,%d)\n",
     1933          rect.left, rect.top, rect.right, rect.bottom);
     1934        ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    19341935            SetBkColor (hDC, obkc);
    1935             return CallWindowProcA (infoPtr->prevEditWndProc,
    1936                                    hwnd, uMsg, wParam, lParam);
     1936        return CallWindowProcA (infoPtr->prevEditWndProc,
     1937                   hwnd, uMsg, wParam, lParam);
    19371938
    19381939    case WM_KEYDOWN: {
    1939             INT oldItem, selected;
    1940             CBE_ITEMDATA *item;
    1941 
    1942             switch ((INT)wParam)
    1943             {
    1944             case VK_ESCAPE:
    1945                 /* native version seems to do following for COMBOEX */
    1946                 /*
    1947                  *   GetWindowTextA(Edit,&?, 0x104)             x
    1948                  *   CB_GETCURSEL to Combo rets -1              x
    1949                  *   WM_NOTIFY to COMBOEX parent (rebar)        x
    1950                  *     (CBEN_ENDEDIT{A|W}
    1951                  *      fChanged = FALSE                        x
    1952                  *      inewSelection = -1                      x
    1953                  *      txt="www.hoho"                          x
    1954                  *      iWhy = 3                                x
    1955                  *   CB_GETCURSEL to Combo rets -1              x
    1956                  *   InvalidateRect(Combo, 0)                   x
    1957                  *   WM_SETTEXT to Edit                         x
    1958                  *   EM_SETSEL to Edit (0,0)                    x
    1959                  *   EM_SETSEL to Edit (0,-1)                   x
    1960                  *   RedrawWindow(Combo, 0, 0, 5)               x
    1961                  */
    1962                 TRACE("special code for VK_ESCAPE\n");
    1963 
    1964                 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    1965 
    1966                 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    1967                 cbeend.fChanged = FALSE;
    1968                 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    1969                                                      CB_GETCURSEL, 0, 0);
    1970                 cbeend.iWhy = CBENF_ESCAPE;
    1971 
    1972                 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    1973                     /* abort the change */
    1974                     TRACE("Notify requested abort of change\n");
    1975                     return 0;
    1976                 }
    1977                 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
    1978                 InvalidateRect (infoPtr->hwndCombo, 0, 0);
    1979                 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
    1980                     ERR("item %d not found. Problem!\n", oldItem);
    1981                     break;
    1982                 }
    1983                 infoPtr->selected = oldItem;             
    1984                 COMBOEX_SetEditText (infoPtr, item);
    1985                 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
    1986                               RDW_INVALIDATE);
    1987                 break;
    1988 
    1989             case VK_RETURN:
    1990                 /* native version seems to do following for COMBOEX */
    1991                 /*
    1992                  *   GetWindowTextA(Edit,&?, 0x104)             x
    1993                  *   CB_GETCURSEL to Combo  rets -1             x
    1994                  *   CB_GETCOUNT to Combo  rets 0
    1995                  *   if >0 loop
    1996                  *       CB_GETITEMDATA to match
    1997                  * *** above 3 lines simulated by FindItem      x 
    1998                  *   WM_NOTIFY to COMBOEX parent (rebar)        x
    1999                  *     (CBEN_ENDEDIT{A|W}                       x
    2000                  *        fChanged = TRUE (-1)                  x
    2001                  *        iNewSelection = -1 or selected        x
    2002                  *        txt=                                  x
    2003                  *        iWhy = 2 (CBENF_RETURN)               x
    2004                  *   CB_GETCURSEL to Combo  rets -1             x
    2005                  *   if -1 send CB_SETCURSEL to Combo -1        x
    2006                  *   InvalidateRect(Combo, 0, 0)                x
    2007                  *   SetFocus(Edit)                             x
    2008                  *   CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
    2009                  */
    2010 
    2011                 TRACE("special code for VK_RETURN\n");
    2012 
    2013                 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    2014 
    2015                 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    2016                 selected = SendMessageW (infoPtr->hwndCombo,
    2017                                          CB_GETCURSEL, 0, 0);
    2018 
    2019                 if (selected != -1) {
    2020                     item = COMBOEX_FindItem (infoPtr, selected);
    2021                     TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
    2022                           selected, debugstr_w(item->pszText));
    2023                     TRACE("handling VK_RETURN, edittext=%s\n",
    2024                           debugstr_w(edit_text));
    2025                     if (lstrcmpiW (item->pszText, edit_text)) {
    2026                         /* strings not equal -- indicate edit has changed */
    2027                         selected = -1;
    2028                     }
    2029                 }
    2030 
    2031                 cbeend.iNewSelection = selected;
    2032                 cbeend.fChanged = TRUE;
    2033                 cbeend.iWhy = CBENF_RETURN;
    2034                 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    2035                     /* abort the change, restore previous */
    2036                     TRACE("Notify requested abort of change\n");
    2037                     COMBOEX_SetEditText (infoPtr, infoPtr->edit);
    2038                     RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
    2039                                   RDW_INVALIDATE);
    2040                     return 0;
    2041                 }
    2042                 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
    2043                 if (oldItem != -1) {
    2044                     /* if something is selected, then deselect it */
    2045                     SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
    2046                                   (WPARAM)-1, 0);
    2047                 }
    2048                 InvalidateRect (infoPtr->hwndCombo, 0, 0);
    2049                 SetFocus(infoPtr->hwndEdit);
    2050                 break;
    2051 
    2052             default:
    2053                 return CallWindowProcA (infoPtr->prevEditWndProc,
    2054                                        hwnd, uMsg, wParam, lParam);
    2055             }
    2056             return 0;
     1940        INT oldItem, selected;
     1941        CBE_ITEMDATA *item;
     1942
     1943        switch ((INT)wParam)
     1944        {
     1945        case VK_ESCAPE:
     1946        /* native version seems to do following for COMBOEX */
     1947        /*
     1948         *   GetWindowTextA(Edit,&?, 0x104)             x
     1949         *   CB_GETCURSEL to Combo rets -1              x
     1950         *   WM_NOTIFY to COMBOEX parent (rebar)        x
     1951         *     (CBEN_ENDEDIT{A|W}
     1952         *      fChanged = FALSE                        x
     1953         *      inewSelection = -1                      x
     1954         *      txt="www.hoho"                          x
     1955         *      iWhy = 3                                x
     1956         *   CB_GETCURSEL to Combo rets -1              x
     1957         *   InvalidateRect(Combo, 0)                   x
     1958         *   WM_SETTEXT to Edit                         x
     1959         *   EM_SETSEL to Edit (0,0)                    x
     1960         *   EM_SETSEL to Edit (0,-1)                   x
     1961         *   RedrawWindow(Combo, 0, 0, 5)               x
     1962         */
     1963        TRACE("special code for VK_ESCAPE\n");
     1964
     1965        GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     1966
     1967        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1968        cbeend.fChanged = FALSE;
     1969        cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1970                             CB_GETCURSEL, 0, 0);
     1971        cbeend.iWhy = CBENF_ESCAPE;
     1972
     1973        if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     1974            /* abort the change */
     1975            TRACE("Notify requested abort of change\n");
     1976            return 0;
     1977        }
     1978        oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     1979        InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1980        if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     1981            ERR("item %d not found. Problem!\n", oldItem);
     1982            break;
     1983        }
     1984        infoPtr->selected = oldItem;
     1985        COMBOEX_SetEditText (infoPtr, item);
     1986        RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     1987                  RDW_INVALIDATE);
     1988        break;
     1989
     1990        case VK_RETURN:
     1991        /* native version seems to do following for COMBOEX */
     1992        /*
     1993         *   GetWindowTextA(Edit,&?, 0x104)             x
     1994         *   CB_GETCURSEL to Combo  rets -1             x
     1995         *   CB_GETCOUNT to Combo  rets 0
     1996         *   if >0 loop
     1997         *       CB_GETITEMDATA to match
     1998         * *** above 3 lines simulated by FindItem      x
     1999         *   WM_NOTIFY to COMBOEX parent (rebar)        x
     2000         *     (CBEN_ENDEDIT{A|W}                       x
     2001         *        fChanged = TRUE (-1)                  x
     2002         *        iNewSelection = -1 or selected        x
     2003         *        txt=                                  x
     2004         *        iWhy = 2 (CBENF_RETURN)               x
     2005         *   CB_GETCURSEL to Combo  rets -1             x
     2006         *   if -1 send CB_SETCURSEL to Combo -1        x
     2007         *   InvalidateRect(Combo, 0, 0)                x
     2008         *   SetFocus(Edit)                             x
     2009         *   CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
     2010         */
     2011
     2012        TRACE("special code for VK_RETURN\n");
     2013
     2014        GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2015
     2016        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2017        selected = SendMessageW (infoPtr->hwndCombo,
     2018                     CB_GETCURSEL, 0, 0);
     2019
     2020        if (selected != -1) {
     2021            item = COMBOEX_FindItem (infoPtr, selected);
     2022            TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
     2023              selected, debugstr_w(item->pszText));
     2024            TRACE("handling VK_RETURN, edittext=%s\n",
     2025              debugstr_w(edit_text));
     2026            if (lstrcmpiW (item->pszText, edit_text)) {
     2027            /* strings not equal -- indicate edit has changed */
     2028            selected = -1;
    20572029            }
     2030        }
     2031
     2032        cbeend.iNewSelection = selected;
     2033        cbeend.fChanged = TRUE;
     2034        cbeend.iWhy = CBENF_RETURN;
     2035        if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     2036            /* abort the change, restore previous */
     2037            TRACE("Notify requested abort of change\n");
     2038            COMBOEX_SetEditText (infoPtr, infoPtr->edit);
     2039            RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     2040                  RDW_INVALIDATE);
     2041            return 0;
     2042        }
     2043        oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     2044        if (oldItem != -1) {
     2045            /* if something is selected, then deselect it */
     2046            SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
     2047                  (WPARAM)-1, 0);
     2048        }
     2049        InvalidateRect (infoPtr->hwndCombo, 0, 0);
     2050        SetFocus(infoPtr->hwndEdit);
     2051        break;
     2052
     2053        default:
     2054        return CallWindowProcA (infoPtr->prevEditWndProc,
     2055                       hwnd, uMsg, wParam, lParam);
     2056        }
     2057        return 0;
     2058            }
    20582059
    20592060    case WM_SETFOCUS:
    2060             /* remember the focus to set state of icon */
    2061             lret = CallWindowProcA (infoPtr->prevEditWndProc,
    2062                                    hwnd, uMsg, wParam, lParam);
    2063             infoPtr->flags |= WCBE_EDITFOCUSED;
    2064             return lret;
     2061        /* remember the focus to set state of icon */
     2062        lret = CallWindowProcA (infoPtr->prevEditWndProc,
     2063                   hwnd, uMsg, wParam, lParam);
     2064        infoPtr->flags |= WCBE_EDITFOCUSED;
     2065        return lret;
    20652066
    20662067    case WM_KILLFOCUS:
    2067             /*
    2068              * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
    2069              */
    2070             infoPtr->flags &= ~WCBE_EDITFOCUSED;
    2071             if (infoPtr->flags & WCBE_ACTEDIT) {
    2072                 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    2073 
    2074                 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    2075                 cbeend.fChanged = FALSE;
    2076                 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    2077                                                      CB_GETCURSEL, 0, 0);
    2078                 cbeend.iWhy = CBENF_KILLFOCUS;
    2079 
    2080                 COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
    2081             }
    2082             /* fall through */
     2068        /*
     2069         * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
     2070         */
     2071        infoPtr->flags &= ~WCBE_EDITFOCUSED;
     2072        if (infoPtr->flags & WCBE_ACTEDIT) {
     2073        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2074
     2075        GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2076        cbeend.fChanged = FALSE;
     2077        cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     2078                             CB_GETCURSEL, 0, 0);
     2079        cbeend.iWhy = CBENF_KILLFOCUS;
     2080
     2081        COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
     2082        }
     2083        /* fall through */
    20832084
    20842085    default:
    2085             return CallWindowProcA (infoPtr->prevEditWndProc,
    2086                                    hwnd, uMsg, wParam, lParam);
     2086        return CallWindowProcA (infoPtr->prevEditWndProc,
     2087                   hwnd, uMsg, wParam, lParam);
    20872088    }
    20882089    return 0;
     
    21022103    WCHAR edit_text[260];
    21032104
    2104     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 
    2105           hwnd, uMsg, wParam, lParam, infoPtr);
     2105    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     2106      hwnd, uMsg, wParam, lParam, infoPtr);
    21062107
    21072108    if (!infoPtr) return 0;
     
    21112112
    21122113    case CB_FINDSTRINGEXACT:
    2113             return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
     2114        return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
    21142115
    21152116    case WM_DRAWITEM:
    2116             /*
    2117              * The only way this message should come is from the
    2118              * child Listbox issuing the message. Flag this so
    2119              * that ComboEx knows this is listbox.
    2120              */
    2121             ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
    2122             return CallWindowProcA (infoPtr->prevComboWndProc,
    2123                                    hwnd, uMsg, wParam, lParam);
     2117        /*
     2118         * The only way this message should come is from the
     2119         * child Listbox issuing the message. Flag this so
     2120         * that ComboEx knows this is listbox.
     2121         */
     2122        ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
     2123        return CallWindowProcA (infoPtr->prevComboWndProc,
     2124                   hwnd, uMsg, wParam, lParam);
    21242125
    21252126    case WM_ERASEBKGND:
    2126             /*
    2127              * The following was determined by traces of the native
    2128              */
     2127        /*
     2128         * The following was determined by traces of the native
     2129         */
    21292130            hDC = (HDC) wParam;
    2130             nbkc = GetSysColor (COLOR_WINDOW);
    2131             obkc = SetBkColor (hDC, nbkc);
     2131        nbkc = GetSysColor (COLOR_WINDOW);
     2132        obkc = SetBkColor (hDC, nbkc);
    21322133            GetClientRect (hwnd, &rect);
    2133             TRACE("erasing (%d,%d)-(%d,%d)\n",
    2134                   rect.left, rect.top, rect.right, rect.bottom);
    2135             ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
     2134        TRACE("erasing (%d,%d)-(%d,%d)\n",
     2135          rect.left, rect.top, rect.right, rect.bottom);
     2136        ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    21362137            SetBkColor (hDC, obkc);
    2137             return CallWindowProcA (infoPtr->prevComboWndProc,
    2138                                    hwnd, uMsg, wParam, lParam);
     2138        return CallWindowProcA (infoPtr->prevComboWndProc,
     2139                   hwnd, uMsg, wParam, lParam);
    21392140
    21402141    case WM_SETCURSOR:
    2141             /*
    2142              *  WM_NOTIFY to comboex parent (rebar)
    2143              *   with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
    2144              *  CallWindowProc (previous)
    2145              */
    2146             nmmse.dwItemSpec = 0;
    2147             nmmse.dwItemData = 0;
    2148             nmmse.pt.x = 0;
    2149             nmmse.pt.y = 0;
    2150             nmmse.dwHitInfo = lParam;
    2151             COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
    2152             return CallWindowProcA (infoPtr->prevComboWndProc,
    2153                                    hwnd, uMsg, wParam, lParam);
     2142        /*
     2143         *  WM_NOTIFY to comboex parent (rebar)
     2144         *   with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
     2145         *  CallWindowProc (previous)
     2146         */
     2147        nmmse.dwItemSpec = 0;
     2148        nmmse.dwItemData = 0;
     2149        nmmse.pt.x = 0;
     2150        nmmse.pt.y = 0;
     2151        nmmse.dwHitInfo = lParam;
     2152        COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
     2153        return CallWindowProcA (infoPtr->prevComboWndProc,
     2154                   hwnd, uMsg, wParam, lParam);
    21542155
    21552156    case WM_COMMAND:
    2156             switch (HIWORD(wParam)) {
    2157 
    2158             case EN_UPDATE:
    2159                 /* traces show that COMBOEX does not issue CBN_EDITUPDATE
    2160                 * on the EN_UPDATE
    2161                 */
    2162                 return 0;
    2163 
    2164             case EN_KILLFOCUS:
    2165                 /*
    2166                 * Native does:
    2167                 *
    2168                 *  GetFocus() retns AA
    2169                 *  GetWindowTextA(Edit)
    2170                 *  CB_GETCURSEL(Combo) (got -1)
    2171                 *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
    2172                 *  CB_GETCURSEL(Combo) (got -1)
    2173                 *  InvalidateRect(Combo, 0, 0)
    2174                 *  WM_KILLFOCUS(Combo, AA)
    2175                 *  return 0;
    2176                 */
    2177                 focusedhwnd = GetFocus();
    2178                 if (infoPtr->flags & WCBE_ACTEDIT) {
    2179                     GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    2180                     cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
    2181                     cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    2182                                                         CB_GETCURSEL, 0, 0);
    2183                     cbeend.iWhy = CBENF_KILLFOCUS;
    2184 
    2185                     infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    2186                     if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    2187                         /* abort the change */
    2188                         TRACE("Notify requested abort of change\n");
    2189                         return 0;
    2190                     }
    2191                 }
    2192                 /* possible CB_GETCURSEL */
    2193                 InvalidateRect (infoPtr->hwndCombo, 0, 0);
    2194                 if (focusedhwnd)
    2195                     SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
    2196                                   (WPARAM)focusedhwnd, 0);
    2197                 return 0;
    2198 
    2199             case EN_SETFOCUS: {
    2200                 /*
    2201                 * For EN_SETFOCUS this issues the same calls and messages
    2202                 *  as the native seems to do.
    2203                 *
    2204                 * for some cases however native does the following:
    2205                 *   (noticed after SetFocus during LBUTTONDOWN on
    2206                 *    on dropdown arrow)
    2207                 *  WM_GETTEXTLENGTH (Edit);
    2208                 *  WM_GETTEXT (Edit, len+1, str);
    2209                 *  EM_SETSEL (Edit, 0, 0);
    2210                 *  WM_GETTEXTLENGTH (Edit);
    2211                 *  WM_GETTEXT (Edit, len+1, str);
    2212                 *  EM_SETSEL (Edit, 0, len);
    2213                 *  WM_NOTIFY (parent, CBEN_BEGINEDIT)
    2214                 */
    2215                 NMHDR hdr;
    2216 
    2217                 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
    2218                 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
    2219                 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
    2220                 infoPtr->flags |= WCBE_ACTEDIT;
    2221                 infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
    2222                 return 0;
    2223                 }
    2224 
    2225             case EN_CHANGE: {
    2226                 /*
    2227                 * For EN_CHANGE this issues the same calls and messages
    2228                 *  as the native seems to do.
    2229                 */
    2230                 WCHAR edit_text[260];
    2231                 WCHAR *lastwrk;
    2232                 INT selected, cnt;
    2233                 CBE_ITEMDATA *item;
    2234 
    2235                 selected = SendMessageW (infoPtr->hwndCombo,
    2236                                         CB_GETCURSEL, 0, 0);
    2237 
    2238                 /* lstrlenA( lastworkingURL ) */
    2239 
    2240                 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    2241                 if (selected == -1) {
    2242                     lastwrk = infoPtr->edit->pszText;
    2243                     cnt = lstrlenW (lastwrk);
    2244                     if (cnt >= 259) cnt = 259;
    2245                 }
    2246                 else {
    2247                     item = COMBOEX_FindItem (infoPtr, selected);
    2248                     cnt = lstrlenW (item->pszText);
    2249                     lastwrk = item->pszText;
    2250                     if (cnt >= 259) cnt = 259;
    2251                 }
    2252 
    2253                 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
    2254                     selected, debugstr_w(lastwrk));
    2255                 TRACE("handling EN_CHANGE, edittext=%s\n",
    2256                       debugstr_w(edit_text));
    2257 
    2258                 /* lstrcmpiW is between lastworkingURL and GetWindowText */
    2259 
    2260                 if (lstrcmpiW (lastwrk, edit_text)) {
    2261                     /* strings not equal -- indicate edit has changed */
    2262                     infoPtr->flags |= WCBE_EDITCHG;
    2263                 }
    2264                 SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
    2265                                MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
    2266                                           CBN_EDITCHANGE),
    2267                                infoPtr->hwndSelf);
    2268                 return 0;
    2269                 }
    2270 
    2271             case LBN_SELCHANGE:
    2272                 /*
    2273                 * Therefore from traces there is no additional code here
    2274                 */
    2275 
    2276                 /*
    2277                 * Using native COMCTL32 gets the following:
    2278                 *  1 == SHDOCVW.DLL  issues call/message
    2279                 *  2 == COMCTL32.DLL  issues call/message
    2280                 *  3 == WINE  issues call/message
    2281                 *
    2282                 *
    2283                 * for LBN_SELCHANGE:
    2284                 *    1  CB_GETCURSEL(ComboEx)
    2285                 *    1  CB_GETDROPPEDSTATE(ComboEx)
    2286                 *    1  CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
    2287                 *    2  CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
    2288                 **   call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
    2289                 *    3  WM_COMMAND(ComboEx, CBN_SELENDOK)
    2290                 *      WM_USER+49(ComboLB, 1,0)  <=============!!!!!!!!!!!
    2291                 *    3  ShowWindow(ComboLB, SW_HIDE)
    2292                 *    3  RedrawWindow(Combo,  RDW_UPDATENOW)
    2293                 *    3  WM_COMMAND(ComboEX, CBN_CLOSEUP)
    2294                 **   end of CBRollUp
    2295                 *    3  WM_COMMAND(ComboEx, CBN_SELCHANGE)  (echo to parent)
    2296                 *    ?  LB_GETCURSEL              <==|
    2297                 *    ?  LB_GETTEXTLEN                |
    2298                 *    ?  LB_GETTEXT                   | Needs to be added to
    2299                 *    ?  WM_CTLCOLOREDIT(ComboEx)     | Combo processing
    2300                 *    ?  LB_GETITEMDATA               |
    2301                 *    ?  WM_DRAWITEM(ComboEx)      <==|
    2302                 */
    2303             default:
    2304                 break;
    2305             }/* fall through */
     2157        switch (HIWORD(wParam)) {
     2158
     2159        case EN_UPDATE:
     2160        /* traces show that COMBOEX does not issue CBN_EDITUPDATE
     2161        * on the EN_UPDATE
     2162        */
     2163        return 0;
     2164
     2165        case EN_KILLFOCUS:
     2166        /*
     2167        * Native does:
     2168        *
     2169        *  GetFocus() retns AA
     2170        *  GetWindowTextA(Edit)
     2171        *  CB_GETCURSEL(Combo) (got -1)
     2172        *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
     2173        *  CB_GETCURSEL(Combo) (got -1)
     2174        *  InvalidateRect(Combo, 0, 0)
     2175        *  WM_KILLFOCUS(Combo, AA)
     2176        *  return 0;
     2177        */
     2178        focusedhwnd = GetFocus();
     2179        if (infoPtr->flags & WCBE_ACTEDIT) {
     2180            GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2181            cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     2182            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     2183                            CB_GETCURSEL, 0, 0);
     2184            cbeend.iWhy = CBENF_KILLFOCUS;
     2185
     2186            infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2187            if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     2188            /* abort the change */
     2189            TRACE("Notify requested abort of change\n");
     2190            return 0;
     2191            }
     2192        }
     2193        /* possible CB_GETCURSEL */
     2194        InvalidateRect (infoPtr->hwndCombo, 0, 0);
     2195        if (focusedhwnd)
     2196            SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
     2197                  (WPARAM)focusedhwnd, 0);
     2198        return 0;
     2199
     2200        case EN_SETFOCUS: {
     2201        /*
     2202        * For EN_SETFOCUS this issues the same calls and messages
     2203        *  as the native seems to do.
     2204        *
     2205        * for some cases however native does the following:
     2206        *   (noticed after SetFocus during LBUTTONDOWN on
     2207        *    on dropdown arrow)
     2208        *  WM_GETTEXTLENGTH (Edit);
     2209        *  WM_GETTEXT (Edit, len+1, str);
     2210        *  EM_SETSEL (Edit, 0, 0);
     2211        *  WM_GETTEXTLENGTH (Edit);
     2212        *  WM_GETTEXT (Edit, len+1, str);
     2213        *  EM_SETSEL (Edit, 0, len);
     2214        *  WM_NOTIFY (parent, CBEN_BEGINEDIT)
     2215        */
     2216        NMHDR hdr;
     2217
     2218        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
     2219        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     2220        COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
     2221        infoPtr->flags |= WCBE_ACTEDIT;
     2222        infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
     2223        return 0;
     2224            }
     2225
     2226        case EN_CHANGE: {
     2227        /*
     2228        * For EN_CHANGE this issues the same calls and messages
     2229        *  as the native seems to do.
     2230        */
     2231        WCHAR edit_text[260];
     2232        WCHAR *lastwrk;
     2233        INT selected, cnt;
     2234        CBE_ITEMDATA *item;
     2235
     2236        selected = SendMessageW (infoPtr->hwndCombo,
     2237                    CB_GETCURSEL, 0, 0);
     2238
     2239        /* lstrlenA( lastworkingURL ) */
     2240
     2241        GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2242        if (selected == -1) {
     2243            lastwrk = infoPtr->edit->pszText;
     2244            cnt = lstrlenW (lastwrk);
     2245            if (cnt >= 259) cnt = 259;
     2246        }
     2247        else {
     2248            item = COMBOEX_FindItem (infoPtr, selected);
     2249            cnt = lstrlenW (item->pszText);
     2250            lastwrk = item->pszText;
     2251            if (cnt >= 259) cnt = 259;
     2252        }
     2253
     2254        TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
     2255            selected, debugstr_w(lastwrk));
     2256        TRACE("handling EN_CHANGE, edittext=%s\n",
     2257              debugstr_w(edit_text));
     2258
     2259        /* lstrcmpiW is between lastworkingURL and GetWindowText */
     2260
     2261        if (lstrcmpiW (lastwrk, edit_text)) {
     2262            /* strings not equal -- indicate edit has changed */
     2263            infoPtr->flags |= WCBE_EDITCHG;
     2264        }
     2265        SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
     2266                   MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
     2267                      CBN_EDITCHANGE),
     2268                   infoPtr->hwndSelf);
     2269        return 0;
     2270            }
     2271
     2272        case LBN_SELCHANGE:
     2273        /*
     2274        * Therefore from traces there is no additional code here
     2275        */
     2276
     2277        /*
     2278        * Using native COMCTL32 gets the following:
     2279        *  1 == SHDOCVW.DLL  issues call/message
     2280        *  2 == COMCTL32.DLL  issues call/message
     2281        *  3 == WINE  issues call/message
     2282        *
     2283        *
     2284        * for LBN_SELCHANGE:
     2285        *    1  CB_GETCURSEL(ComboEx)
     2286        *    1  CB_GETDROPPEDSTATE(ComboEx)
     2287        *    1  CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
     2288        *    2  CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
     2289        **   call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
     2290        *    3  WM_COMMAND(ComboEx, CBN_SELENDOK)
     2291        *      WM_USER+49(ComboLB, 1,0)  <=============!!!!!!!!!!!
     2292        *    3  ShowWindow(ComboLB, SW_HIDE)
     2293        *    3  RedrawWindow(Combo,  RDW_UPDATENOW)
     2294        *    3  WM_COMMAND(ComboEX, CBN_CLOSEUP)
     2295        **   end of CBRollUp
     2296        *    3  WM_COMMAND(ComboEx, CBN_SELCHANGE)  (echo to parent)
     2297        *    ?  LB_GETCURSEL              <==|
     2298        *    ?  LB_GETTEXTLEN                |
     2299        *    ?  LB_GETTEXT                   | Needs to be added to
     2300        *    ?  WM_CTLCOLOREDIT(ComboEx)     | Combo processing
     2301        *    ?  LB_GETITEMDATA               |
     2302        *    ?  WM_DRAWITEM(ComboEx)      <==|
     2303        */
     2304        default:
     2305        break;
     2306        }/* fall through */
    23062307    default:
    2307             return CallWindowProcA (infoPtr->prevComboWndProc,
    2308                                    hwnd, uMsg, wParam, lParam);
     2308        return CallWindowProcA (infoPtr->prevComboWndProc,
     2309                   hwnd, uMsg, wParam, lParam);
    23092310    }
    23102311    return 0;
     
    23202321
    23212322    if (!COMBOEX_GetInfoPtr (hwnd)) {
    2322         if (uMsg == WM_CREATE)
    2323             return COMBOEX_Create (hwnd, wParam, lParam);
    2324         if (uMsg == WM_NCCREATE)
    2325             COMBOEX_NCCreate (hwnd, wParam, lParam);
     2323    if (uMsg == WM_CREATE)
     2324        return COMBOEX_Create (hwnd, wParam, lParam);
     2325    if (uMsg == WM_NCCREATE)
     2326        COMBOEX_NCCreate (hwnd, wParam, lParam);
    23262327        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    23272328    }
     
    23302331    {
    23312332        case CBEM_DELETEITEM:  /* maps to CB_DELETESTRING */
    2332             return COMBOEX_DeleteItem (hwnd, wParam, lParam);
    2333 
    2334         case CBEM_GETCOMBOCONTROL:
    2335             return COMBOEX_GetComboControl (hwnd, wParam, lParam);
    2336 
    2337         case CBEM_GETEDITCONTROL:
    2338             return COMBOEX_GetEditControl (hwnd, wParam, lParam);
    2339 
    2340         case CBEM_GETEXTENDEDSTYLE:
    2341             return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
    2342 
    2343         case CBEM_GETIMAGELIST:
    2344             return COMBOEX_GetImageList (hwnd, wParam, lParam);
    2345 
    2346         case CBEM_GETITEMA:
    2347             return COMBOEX_GetItemA (hwnd, wParam, lParam);
    2348 
    2349         case CBEM_GETITEMW:
    2350             return COMBOEX_GetItemW (hwnd, wParam, lParam);
    2351 
    2352         case CBEM_GETUNICODEFORMAT:
    2353             return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
    2354 
    2355         case CBEM_HASEDITCHANGED:
    2356             return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
    2357 
    2358         case CBEM_INSERTITEMA:
    2359             return COMBOEX_InsertItemA (hwnd, wParam, lParam);
    2360 
    2361         case CBEM_INSERTITEMW:
    2362             return COMBOEX_InsertItemW (hwnd, wParam, lParam);
    2363 
    2364         case CBEM_SETEXSTYLE:   /* FIXME: obsoleted, should be the same as: */
    2365         case CBEM_SETEXTENDEDSTYLE:
    2366             return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
    2367 
    2368         case CBEM_SETIMAGELIST:
    2369             return COMBOEX_SetImageList (hwnd, wParam, lParam);
    2370 
    2371         case CBEM_SETITEMA:
    2372             return COMBOEX_SetItemA (hwnd, wParam, lParam);
    2373 
    2374         case CBEM_SETITEMW:
    2375             return COMBOEX_SetItemW (hwnd, wParam, lParam);
    2376 
    2377         case CBEM_SETUNICODEFORMAT:
    2378             return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
     2333        return COMBOEX_DeleteItem (hwnd, wParam, lParam);
     2334
     2335    case CBEM_GETCOMBOCONTROL:
     2336        return COMBOEX_GetComboControl (hwnd, wParam, lParam);
     2337
     2338    case CBEM_GETEDITCONTROL:
     2339        return COMBOEX_GetEditControl (hwnd, wParam, lParam);
     2340
     2341    case CBEM_GETEXTENDEDSTYLE:
     2342        return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
     2343
     2344    case CBEM_GETIMAGELIST:
     2345        return COMBOEX_GetImageList (hwnd, wParam, lParam);
     2346
     2347    case CBEM_GETITEMA:
     2348        return COMBOEX_GetItemA (hwnd, wParam, lParam);
     2349
     2350    case CBEM_GETITEMW:
     2351        return COMBOEX_GetItemW (hwnd, wParam, lParam);
     2352
     2353    case CBEM_GETUNICODEFORMAT:
     2354        return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
     2355
     2356    case CBEM_HASEDITCHANGED:
     2357        return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
     2358
     2359    case CBEM_INSERTITEMA:
     2360        return COMBOEX_InsertItemA (hwnd, wParam, lParam);
     2361
     2362    case CBEM_INSERTITEMW:
     2363        return COMBOEX_InsertItemW (hwnd, wParam, lParam);
     2364
     2365    case CBEM_SETEXSTYLE:   /* FIXME: obsoleted, should be the same as: */
     2366    case CBEM_SETEXTENDEDSTYLE:
     2367        return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
     2368
     2369    case CBEM_SETIMAGELIST:
     2370        return COMBOEX_SetImageList (hwnd, wParam, lParam);
     2371
     2372    case CBEM_SETITEMA:
     2373        return COMBOEX_SetItemA (hwnd, wParam, lParam);
     2374
     2375    case CBEM_SETITEMW:
     2376        return COMBOEX_SetItemW (hwnd, wParam, lParam);
     2377
     2378    case CBEM_SETUNICODEFORMAT:
     2379        return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
    23792380
    23802381
    23812382/*   Combo messages we are not sure if we need to process or just forward */
    2382         case CB_GETDROPPEDCONTROLRECT:
    2383         case CB_GETITEMHEIGHT:
    2384         case CB_GETLBTEXT:
    2385         case CB_GETLBTEXTLEN:
    2386         case CB_GETEXTENDEDUI:
    2387         case CB_LIMITTEXT:
    2388         case CB_RESETCONTENT:
    2389         case CB_SELECTSTRING:
    2390         case WM_SETTEXT:
    2391         case WM_GETTEXT:
    2392             FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
    2393                   uMsg, wParam, lParam);
    2394             return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     2383    case CB_GETDROPPEDCONTROLRECT:
     2384    case CB_GETITEMHEIGHT:
     2385    case CB_GETLBTEXT:
     2386    case CB_GETLBTEXTLEN:
     2387    case CB_GETEXTENDEDUI:
     2388    case CB_LIMITTEXT:
     2389    case CB_RESETCONTENT:
     2390    case CB_SELECTSTRING:
     2391    case WM_SETTEXT:
     2392    case WM_GETTEXT:
     2393        FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
     2394          uMsg, wParam, lParam);
     2395        return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    23952396
    23962397/*   Combo messages OK to just forward to the regular COMBO */
    2397         case CB_GETCOUNT:       
    2398         case CB_GETCURSEL:
    2399         case CB_GETDROPPEDSTATE:
     2398    case CB_GETCOUNT:
     2399    case CB_GETCURSEL:
     2400    case CB_GETDROPPEDSTATE:
    24002401        case CB_SETDROPPEDWIDTH:
    24012402        case CB_SETEXTENDEDUI:
    24022403        case CB_SHOWDROPDOWN:
    2403             return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     2404        return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    24042405
    24052406/*   Combo messages we need to process specially */
    24062407        case CB_FINDSTRINGEXACT:
    2407             return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
    2408                                             wParam, lParam);
    2409 
    2410         case CB_GETITEMDATA:
    2411             return COMBOEX_GetItemData (hwnd, wParam, lParam);
    2412 
    2413         case CB_SETCURSEL:
    2414             return COMBOEX_SetCursel (hwnd, wParam, lParam);
    2415 
    2416         case CB_SETITEMDATA:
    2417             return COMBOEX_SetItemData (hwnd, wParam, lParam);
    2418 
    2419         case CB_SETITEMHEIGHT:
    2420             return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
     2408        return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
     2409                        wParam, lParam);
     2410
     2411    case CB_GETITEMDATA:
     2412        return COMBOEX_GetItemData (hwnd, wParam, lParam);
     2413
     2414    case CB_SETCURSEL:
     2415        return COMBOEX_SetCursel (hwnd, wParam, lParam);
     2416
     2417    case CB_SETITEMDATA:
     2418        return COMBOEX_SetItemData (hwnd, wParam, lParam);
     2419
     2420    case CB_SETITEMHEIGHT:
     2421        return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
    24212422
    24222423
    24232424
    24242425/*   Window messages passed to parent */
    2425         case WM_COMMAND:
    2426             return COMBOEX_Command (hwnd, wParam, lParam);
    2427 
    2428         case WM_NOTIFY:
    2429             if (infoPtr->NtfUnicode)
    2430                 return SendMessageW (GetParent (hwnd),
    2431                                      uMsg, wParam, lParam);
    2432             else
    2433                 return SendMessageA (GetParent (hwnd),
    2434                                      uMsg, wParam, lParam);
     2426    case WM_COMMAND:
     2427        return COMBOEX_Command (hwnd, wParam, lParam);
     2428
     2429    case WM_NOTIFY:
     2430        if (infoPtr->NtfUnicode)
     2431        return SendMessageW (GetParent (hwnd),
     2432                     uMsg, wParam, lParam);
     2433        else
     2434        return SendMessageA (GetParent (hwnd),
     2435                     uMsg, wParam, lParam);
    24352436
    24362437
    24372438/*   Window messages we need to process */
    24382439        case WM_DELETEITEM:
    2439             return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
     2440        return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
    24402441
    24412442        case WM_DRAWITEM:
    24422443            return COMBOEX_DrawItem (hwnd, wParam, lParam);
    24432444
    2444         case WM_DESTROY:
    2445             return COMBOEX_Destroy (hwnd, wParam, lParam);
     2445    case WM_DESTROY:
     2446        return COMBOEX_Destroy (hwnd, wParam, lParam);
    24462447
    24472448        case WM_MEASUREITEM:
     
    24492450
    24502451        case WM_NOTIFYFORMAT:
    2451             return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
    2452 
    2453         case WM_SIZE:
    2454             return COMBOEX_Size (hwnd, wParam, lParam);
     2452        return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
     2453
     2454    case WM_SIZE:
     2455        return COMBOEX_Size (hwnd, wParam, lParam);
    24552456
    24562457        case WM_WINDOWPOSCHANGING:
    2457             return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
    2458 
    2459         default:
    2460             if (uMsg >= WM_USER)
    2461                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    2462                      uMsg, wParam, lParam);
     2458        return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
     2459
     2460    default:
     2461        if (uMsg >= WM_USER)
     2462        ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     2463             uMsg, wParam, lParam);
    24632464#ifdef __WIN32OS2__
    24642465            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    24652466#else
    2466             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2467        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    24672468#endif
    24682469    }
     
    24842485    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    24852486    wndClass.lpszClassName = WC_COMBOBOXEXA;
    2486  
     2487
    24872488    RegisterClassA (&wndClass);
    24882489
Note: See TracChangeset for help on using the changeset viewer.