Ignore:
Timestamp:
May 8, 2002, 1:26:30 PM (24 years ago)
Author:
sandervl
Message:

merge with latest Wine

File:
1 edited

Legend:

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

    r7815 r8382  
    11/*
    2  * TODO   <-------------
    3  *  1. The following extended styles need to be implemented, use will
    4  *     result in a FIXME:
    5  *           CBES_EX_NOEDITIMAGEINDENT
     2 * ComboBoxEx control
     3 *
     4 * Copyright 1998, 1999 Eric Kohl
     5 * Copyright 2000, 2001, 2002 Guy Albertelli <galberte@neo.lrun.com>
     6 * Copyright 2002 Dimitrie O. Paun
     7 *
     8 * This library is free software; you can redistribute it and/or
     9 * modify it under the terms of the GNU Lesser General Public
     10 * License as published by the Free Software Foundation; either
     11 * version 2.1 of the License, or (at your option) any later version.
     12 *
     13 * This library is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     16 * Lesser General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU Lesser General Public
     19 * License along with this library; if not, write to the Free Software
     20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     21 *
     22 * FIXME:
     23 *  1. Implement following extended styles:
    624 *           CBES_EX_PATHWORDBREAKPROC
    725 *           CBES_EX_NOSIZELIMIT
    826 *           CBES_EX_CASESENSITIVE
    9  *  2. None of the following callback items are implemented. Therefor
    10  *     no CBEN_GETDISPINFO notifies are issued. Use in either CBEM_INSERTITEM
    11  *     or CBEM_SETITEM will result in a FIXME:
    12  *           LPSTR_TEXTCALLBACK
    13  *           I_IMAGECALLBACK
    14  *           I_INDENTCALLBACK
    15  *  3. No use is made of the iOverlay image.
    16  *  4. Notify CBEN_DRAGBEGIN is not implemented.
    17  */
    18 
    19 
    20 /*
    21  * ComboBoxEx control v2 (mod6)
    22  *
    23  * Copyright 1998, 1999 Eric Kohl
    24  *
    25  * NOTES
    26  *   This is just a dummy control. An author is needed! Any volunteers?
    27  *   I will only improve this control once in a while.
    28  *     Eric <ekohl@abo.rhein-zeitung.de>
    29  *
    30 
    31  * Changes  Guy Albertelli <galberte@neo.lrun.com>
    32  * v1  Implemented messages: CB_SETITEMHEIGHT, WM_WINDOWPOSCHANGING,
    33  *      WM_DRAWITEM, and WM_MEASUREITEM. Fixed WM_CREATE. Fixed height
    34  *      of window rect reported fixing rebar control.
    35  * v2
    36  *   1. Rewrite of WM_Create for own created EDIT control. Also try to
    37  *      generate message sequence similar to native DLL.
    38  *   2. Handle case where CBEM_SETITEM is called to display data in EDIT
    39  *      Control.
    40  *   3. Add override for WNDPROC for the EDIT control (reqed for VK_RETURN).
    41  *   4. Dump input data for things using COMBOBOXEXITEM{A|W}.
    42  *   5. Handle positioning EDIT control based on whether icon present.
    43  *   6. Make InsertItemA use InsertItemW, and store all data in ..W form.
    44  *   7. Implement CBEM_DELETEITEM, CBEM_GETITEM{A|W}, CB_SETCURSEL,
    45  *      CBEM_{GET|SET}UNICODEFORMAT.
    46  *   8. Add override for WNDPROC for the COMBO control.
    47  *   9. Support extended style CBES_EX_NOEDITIMAGE and warn others are not
    48  *      supported.
    49  *  10. Implement CB_FINDSTRINGEXACT in both the Combo and ComboEx window
    50  *      procs to match the items. This eliminates dup entries in the listbox.
    51  *
    52  *  mod 4
    53  *   1. Implemented CBN_SELCHANGE, CBN_KILLFOCUS, and CBN_SELENDOK.
    54  *   2. Fix putting text in CBEN_ENDEDIT notifies for CBN_DROPDOWN case.
    55  *   3. Lock image selected status to focus state of edit control if
    56  *      edit control exists. Mimics native actions.
    57  *   4. Implemented WM_SETFOCUS in EditWndProc to track status of
    58  *      focus for 3 above.
    59  *   5. The LBN_SELCHANGE is just for documentation purposes.
    60  *
    61  *  mod 5
    62  *   1. Add support for CB_GETITEMDATA to a Comboex. Returns the LPARAM
    63  *      passed during insert of item.
    64  *   2. Remember selected item and don't issue CB_SETCURSEL unless needed.
    65  *   3. Add initial support for WM_NCCREATE to remove unwanted window styles
    66  *      (Currently just WS_VSCROLL and WS_HSCROLL, but probably should be
    67  *       more.)
    68  *   4. Improve some traces.
    69  *   5. Add support for CB_SETITEMDATA sets LPARAM value from item.
    70  *
    71  *  mod 6
    72  *   1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do
    73  *      WM_NOTIFY correctly based on results.
    74  *   2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM.
    75  *   3. Add routines to handle special cases of NMCBEENDEDIT and NMCOMBOXEX
    76  *      so translation to ANSI is done correctly.
    77  *   4. Fix some issues with COMBOEX_DrawItem.
    78  *
    79  * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe),
    80  *  WinRAR, and IE 4.0.
     27 *  2. Notify CBEN_DRAGBEGIN is not implemented.
    8128 *
    8229 */
     
    8532#include "winbase.h"
    8633#include "commctrl.h"
    87 #include "debugtools.h"
     34#include "wine/debug.h"
    8835#include "wine/unicode.h"
    8936
    90 DEFAULT_DEBUG_CHANNEL(comboex);
    91 /*
    92  * The following is necessary for the test done in COMBOEX_DrawItem
    93  * to determine whether to dump out the DRAWITEM structure or not.
    94  */
    95 DECLARE_DEBUG_CHANNEL(message);
     37WINE_DEFAULT_DEBUG_CHANNEL(comboex);
    9638
    9739/* Item structure */
     
    10143    UINT         mask;
    10244    LPWSTR       pszText;
     45    LPWSTR       pszTemp;
    10346    int          cchTextMax;
    10447    int          iImage;
     
    11760    HWND         hwndEdit;
    11861    WNDPROC      prevEditWndProc;  /* previous Edit WNDPROC value */
    119     WNDPROC      prevComboWndProc;   /* previous Combo WNDPROC value */
     62    WNDPROC      prevComboWndProc; /* previous Combo WNDPROC value */
    12063    DWORD        dwExtStyle;
    12164    INT          selected;         /* index of selected item */
    12265    DWORD        flags;            /* WINE internal flags */
    123     HFONT        hDefaultFont;
     66    HFONT        defaultFont;
    12467    HFONT        font;
    12568    INT          nb_items;         /* Number of items */
    126     BOOL         bUnicode;        /* TRUE if this window is Unicode   */
    127     BOOL         NtfUnicode;      /* TRUE if parent wants notify in Unicode */
     69    BOOL         unicode;          /* TRUE if this window is Unicode   */
     70    BOOL         NtfUnicode;       /* TRUE if parent wants notify in Unicode */
    12871    CBE_ITEMDATA *edit;            /* item data for edit item */
    12972    CBE_ITEMDATA *items;           /* Array of items */
     
    13174
    13275/* internal flags in the COMBOEX_INFO structure */
    133 #define  WCBE_ACTEDIT        0x00000001     /* Edit active i.e.
     76#define  WCBE_ACTEDIT           0x00000001     /* Edit active i.e.
    13477                                             * CBEN_BEGINEDIT issued
    13578                                             * but CBEN_ENDEDIT{A|W}
    13679                                             * not yet issued. */
    137 #define  WCBE_EDITCHG        0x00000002     /* Edit issued EN_CHANGE */
    138 #define  WCBE_EDITFOCUSED    0x00000004     /* Edit control has focus */
    139 
    140 
    141 #define ID_CB_EDIT    1001
     80#define  WCBE_EDITCHG           0x00000002     /* Edit issued EN_CHANGE */
     81#define  WCBE_EDITHASCHANGED    (WCBE_ACTEDIT | WCBE_EDITCHG)
     82#define  WCBE_EDITFOCUSED       0x00000004     /* Edit control has focus */
     83
     84
     85#define ID_CB_EDIT              1001
    14286
    14387
     
    15296 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
    15397 */
    154 #define ODS_COMBOEXLBOX  0x4000
     98#define ODS_COMBOEXLBOX         0x4000
    15599
    156100
    157101
    158102/* Height in pixels of control over the amount of the selected font */
    159 #define CBE_EXTRA     3
     103#define CBE_EXTRA               3
    160104
    161105/* Indent amount per MS documentation */
    162 #define CBE_INDENT    10
     106#define CBE_INDENT              10
    163107
    164108/* Offset in pixels from left side for start of image or text */
    165 #define CBE_STARTOFFSET   6
     109#define CBE_STARTOFFSET         6
    166110
    167111/* Offset between image and text */
    168 #define CBE_SEP   4
    169 
    170 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
     112#define CBE_SEP                 4
     113
     114#define COMBOEX_SUBCLASS_PROP   "CCComboEx32SubclassInfo"
     115#define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongW (hwnd, 0))
    171116
    172117
    173118/* Things common to the entire DLL */
    174 static ATOM ComboExInfo;
    175119static LRESULT WINAPI
    176120COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    177121static LRESULT WINAPI
    178122COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    179 
    180 static void
    181 COMBOEX_DumpItem (CBE_ITEMDATA *item)
    182 {
    183     if (TRACE_ON(comboex)){
    184       TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
    185             item, item->mask, item->pszText, item->cchTextMax,
    186             item->iImage);
    187       TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    188             item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
    189       if ((item->mask & CBEIF_TEXT) && item->pszText)
    190           TRACE("item %p - pszText=%s\n",
    191                 item, debugstr_w((const WCHAR *)item->pszText));
    192     }
    193 }
    194 
    195 
    196 static void
    197 COMBOEX_DumpInput (COMBOBOXEXITEMA *input, BOOL true_for_w)
    198 {
    199     if (TRACE_ON(comboex)){
    200       TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
    201             input->mask, input->iItem, input->pszText, input->cchTextMax,
    202             input->iImage);
    203       if ((input->mask & CBEIF_TEXT) && input->pszText) {
    204           if (true_for_w)
    205               TRACE("input - pszText=<%s>\n",
    206                     debugstr_w((const WCHAR *)input->pszText));
    207           else
    208               TRACE("input - pszText=<%s>\n",
    209                     debugstr_a((const char *)input->pszText));
    210       }
    211       TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    212             input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
    213     }
    214 }
    215 
    216 
    217 inline static LRESULT
    218 COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    219 {
    220     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    221 
    222     if (infoPtr->hwndCombo)   
    223         return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
    224 
    225     return 0;
    226 }
    227 
    228 
    229 static INT
    230 COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
    231 {
    232 
     123static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr);
     124
     125inline static BOOL is_textW(LPCWSTR str)
     126{
     127    return str && str != LPSTR_TEXTCALLBACKW;
     128}
     129
     130inline static BOOL is_textA(LPCSTR str)
     131{
     132    return str && str != LPSTR_TEXTCALLBACKA;
     133}
     134
     135inline static LPCSTR debugstr_txt(LPCWSTR str)
     136{
     137    if (str == LPSTR_TEXTCALLBACKW) return "(callback)";
     138    return debugstr_w(str);
     139}
     140
     141static void COMBOEX_DumpItem (CBE_ITEMDATA *item)
     142{
     143    TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
     144          item, item->mask, item->pszText, item->cchTextMax, item->iImage);
     145    TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
     146          item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
     147    if (item->mask & CBEIF_TEXT)
     148        TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText));
     149}
     150
     151
     152static void COMBOEX_DumpInput (COMBOBOXEXITEMW *input)
     153{
     154    TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
     155          input->mask, input->iItem, input->pszText, input->cchTextMax,
     156          input->iImage);
     157    if (input->mask & CBEIF_TEXT)
     158        TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText));
     159    TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
     160          input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
     161}
     162
     163
     164inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index)
     165{
     166    return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA,
     167                                         (WPARAM)index, 0);
     168}
     169
     170
     171static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
     172{
    233173    hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
    234174    hdr->hwndFrom = infoPtr->hwndSelf;
     
    246186COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr)
    247187{
    248 
    249188    /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
    250 
    251     hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
    252     hdr->hdr.hwndFrom = infoPtr->hwndSelf;
    253     hdr->hdr.code = code;
    254189    if (infoPtr->NtfUnicode)
    255         return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    256                              (LPARAM)hdr);
     190        return COMBOEX_Notify (infoPtr, code, &hdr->hdr);
    257191    else {
    258         LPWSTR str, ostr = NULL;
     192        LPWSTR wstr = hdr->ceItem.pszText;
     193        LPSTR astr = 0;
    259194        INT ret, len = 0;
    260195
    261         if (hdr->ceItem.mask & CBEIF_TEXT) {
    262             ostr = hdr->ceItem.pszText;
    263             str = ostr;
    264             if (!str) str = (LPWSTR)L"";
    265             len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL);
     196        if ((hdr->ceItem.mask & CBEIF_TEXT) && is_textW(wstr)) {
     197            len = WideCharToMultiByte (CP_ACP, 0, wstr, -1, 0, 0, NULL, NULL);
    266198            if (len > 0) {
    267                 hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
    268                 WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText,
    269                                      len, NULL, NULL);
     199                astr = (LPSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
     200                if (!astr) return 0;
     201                WideCharToMultiByte (CP_ACP, 0, wstr, -1, astr, len, 0, 0);
     202                hdr->ceItem.pszText = (LPWSTR)astr;
    270203            }
    271204        }
    272205
    273         ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    274                             (LPARAM)hdr);
    275         if (hdr->ceItem.mask & CBEIF_TEXT) {
    276             if (len > 0)
    277                 COMCTL32_Free (hdr->ceItem.pszText);
    278             hdr->ceItem.pszText = ostr;
    279         }
     206        if (code == CBEN_ENDEDITW) code = CBEN_ENDEDITA;
     207        else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA;
     208        else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA;
     209       
     210        ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr);
     211
     212        if (astr && hdr->ceItem.pszText == (LPWSTR)astr)
     213            hdr->ceItem.pszText = wstr;
     214       
     215        if (astr) COMCTL32_Free(astr);
     216       
    280217        return ret;
    281218    }
     
    283220
    284221
    285 static INT
    286 COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *hdr, LPWSTR itemText)
    287 {
    288 
     222static INT COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *neew, LPCWSTR wstr)
     223{
    289224    /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
    290 
    291     hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
    292     hdr->hdr.hwndFrom = infoPtr->hwndSelf;
    293     hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA;
    294     if (infoPtr->NtfUnicode)
    295         return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    296                              (LPARAM)hdr);
    297     else {
    298         NMCBEENDEDITA ansi;
    299 
    300         memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR));
    301         ansi.fChanged = hdr->fChanged;
    302         ansi.iNewSelection = hdr->iNewSelection;
    303         WideCharToMultiByte (CP_ACP, 0, itemText, -1,
    304                              (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL);
    305         ansi.iWhy = hdr->iWhy;
    306         return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    307                              (LPARAM)&ansi);
    308     }
    309 }
    310 
    311 
    312 static void
    313 COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
     225    if (infoPtr->NtfUnicode) {
     226        lstrcpynW(neew->szText, wstr, CBEMAXSTRLEN);
     227        return COMBOEX_Notify (infoPtr, CBEN_ENDEDITW, &neew->hdr);
     228    } else {
     229        NMCBEENDEDITA neea;
     230       
     231        memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR));
     232        neea.fChanged = neew->fChanged;
     233        neea.iNewSelection = neew->iNewSelection;
     234        WideCharToMultiByte (CP_ACP, 0, wstr, -1, neea.szText, CBEMAXSTRLEN, 0, 0);
     235        neea.iWhy = neew->iWhy;
     236
     237        return COMBOEX_Notify (infoPtr, CBEN_ENDEDITA, &neea.hdr);
     238    }
     239}
     240
     241
     242static void COMBOEX_FreeText (CBE_ITEMDATA *item)
     243{
     244    if (is_textW(item->pszText)) COMCTL32_Free(item->pszText);
     245    item->pszText = 0;
     246    if (item->pszTemp) COMCTL32_Free(item->pszTemp);
     247    item->pszTemp = 0;
     248}
     249
     250
     251static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
     252{
     253    NMCOMBOBOXEXW nmce;
     254    LPWSTR text, buf;
     255    INT len;
     256   
     257    if (item->pszText != LPSTR_TEXTCALLBACKW)
     258        return item->pszText;
     259   
     260    ZeroMemory(&nmce, sizeof(nmce));
     261    nmce.ceItem.mask = CBEIF_TEXT;
     262    COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
     263
     264    if (is_textW(nmce.ceItem.pszText)) {
     265        len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0);
     266        buf = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     267        if (buf)
     268            MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len);
     269        if (nmce.ceItem.mask & CBEIF_DI_SETITEM) {
     270            COMBOEX_FreeText(item);
     271            item->pszText = buf;
     272        } else {
     273            if (item->pszTemp) COMCTL32_Free(item->pszTemp);
     274            item->pszTemp = buf;
     275        }
     276        text = buf;
     277    } else
     278        text = nmce.ceItem.pszText;
     279   
     280    if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
     281        item->pszText = text;
     282    return text;
     283}
     284
     285
     286static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
    314287{
    315288    HFONT nfont, ofont;
     
    326299
    327300
    328 static void
    329 COMBOEX_CopyItem (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
     301static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
    330302{
    331303    if (cit->mask & CBEIF_TEXT) {
    332         cit->pszText        = item->pszText;
    333         cit->cchTextMax     = item->cchTextMax;
     304        /*
     305         * when given a text buffer actually use that buffer
     306         */
     307        if (cit->pszText) {
     308            if (is_textW(item->pszText))
     309                lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax);
     310            else
     311                cit->pszText[0] = 0;
     312        } else {
     313            cit->pszText        = item->pszText;
     314            cit->cchTextMax     = item->cchTextMax;
     315        }
    334316    }
    335317    if (cit->mask & CBEIF_IMAGE)
     
    343325    if (cit->mask & CBEIF_LPARAM)
    344326        cit->lParam         = item->lParam;
    345 
    346 }
    347 
    348 
    349 static void
    350 COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
     327}
     328
     329
     330static void COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
    351331{
    352332    SIZE mysize;
    353     IMAGEINFO iinfo;
    354     INT x, y, w, h, xoff = 0;
     333    INT x, y, w, h, xioff;
    355334    RECT rect;
    356335
    357336    if (!infoPtr->hwndEdit) return;
    358     iinfo.rcImage.left = iinfo.rcImage.right = 0;
    359     if (infoPtr->himl) {
     337
     338    if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
     339        IMAGEINFO iinfo;
     340        iinfo.rcImage.left = iinfo.rcImage.right = 0;
    360341        ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
    361         xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
    362     }
     342        xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
     343    }  else xioff = 0;
     344
    363345    GetClientRect (infoPtr->hwndCombo, &rect);
    364346    InflateRect (&rect, -2, -2);
     
    368350    COMBOEX_GetComboFontSize (infoPtr, &mysize);
    369351    TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy);
    370     x = xoff + CBE_STARTOFFSET + 1;
    371     y = CBE_EXTRA + 1;
     352    x = xioff + CBE_STARTOFFSET + 1;
    372353    w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
    373354    h = mysize.cy + 1;
     355    y = rect.bottom - h - 1;
    374356
    375357    TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n",
    376           rect.left, rect.top, rect.right, rect.bottom,
    377           x, y, x + w, y + h);
    378     SetWindowPos(infoPtr->hwndEdit, HWND_TOP,
    379                  x, y,
    380                  w, h,
     358          rect.left, rect.top, rect.right, rect.bottom, x, y, x + w, y + h);
     359    SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h,
    381360                 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
    382361}
    383362
    384363
    385 static void
    386 COMBOEX_ReSize (HWND hwnd, COMBOEX_INFO *infoPtr)
     364static void COMBOEX_ReSize (COMBOEX_INFO *infoPtr)
    387365{
    388366    SIZE mysize;
     
    397375        TRACE("upgraded height due to image:  height=%d\n", cy);
    398376    }
    399     SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
     377    SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy);
    400378    if (infoPtr->hwndCombo)
    401379        SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
     
    404382
    405383
    406 static void
    407 COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
     384static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
    408385{
    409386    if (!infoPtr->hwndEdit) return;
     
    413390    /*      EM_SETSEL32 (0,-1)      */
    414391    if (item->mask & CBEIF_TEXT) {
    415         SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
     392        SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item));
    416393        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
    417394        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     
    420397
    421398 
    422 static CBE_ITEMDATA *
    423 COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
     399static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
    424400{
    425401    CBE_ITEMDATA *item;
     
    439415    }
    440416    if (!item || (i != index)) {
    441         FIXME("COMBOBOXEX item structures broken. Please report!\n");
     417        ERR("COMBOBOXEX item structures broken. Please report!\n");
    442418        return 0;
    443419    }
     
    446422
    447423
    448 static void
    449 COMBOEX_WarnCallBack (CBE_ITEMDATA *item)
    450 {
    451     if (item->pszText == LPSTR_TEXTCALLBACKW)
    452         FIXME("Callback not implemented yet for pszText\n");
    453     if (item->iImage == I_IMAGECALLBACK)
    454         FIXME("Callback not implemented yet for iImage\n");
    455     if (item->iSelectedImage == I_IMAGECALLBACK)
    456         FIXME("Callback not implemented yet for iSelectedImage\n");
    457     if (item->iOverlay == I_IMAGECALLBACK)
    458         FIXME("Callback not implemented yet for iOverlay\n");
    459     if (item->iIndent == I_INDENTCALLBACK)
    460         FIXME("Callback not implemented yet for iIndent\n");
    461 }
    462 
     424static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr)
     425{
     426    return infoPtr->hwndEdit;
     427}
     428 
    463429
    464430/* ***  CBEM_xxx message support  *** */
    465431
    466432
    467 static LRESULT
    468 COMBOEX_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    469 {
    470     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    471     INT index = (INT) wParam;
     433static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT index)
     434{
    472435    CBE_ITEMDATA *item;
    473436
    474     TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     437    TRACE("(index=%d)\n", index);
    475438
    476439    /* if item number requested does not exist then return failure */
    477     if ((index > infoPtr->nb_items) || (index < 0)) {
    478         ERR("attempt to delete item that does not exist\n");
    479         return CB_ERR;
    480     }
    481 
    482     if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    483         ERR("attempt to delete item that was not found!\n");
    484         return CB_ERR;
    485     }
     440    if ((index > infoPtr->nb_items) || (index < 0)) return CB_ERR;
     441    if (!(item = COMBOEX_FindItem(infoPtr, index))) return CB_ERR;
    486442
    487443    /* doing this will result in WM_DELETEITEM being issued */
     
    492448
    493449
    494 inline static LRESULT
    495 COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
    496 {
    497     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    498 
    499     TRACE("\n");
    500 
    501     return (LRESULT)infoPtr->hwndCombo;
    502 }
    503 
    504 
    505 inline static LRESULT
    506 COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
    507 {
    508     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    509 
    510     if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    511         return 0;
    512 
    513     TRACE("-- 0x%x\n", infoPtr->hwndEdit);
    514 
    515     return (LRESULT)infoPtr->hwndEdit;
    516 }
    517 
    518 
    519 inline static LRESULT
    520 COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
    521 {
    522     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    523 
    524     TRACE("-- 0x%08lx\n", infoPtr->dwExtStyle);
    525 
    526     return (LRESULT)infoPtr->dwExtStyle;
    527 }
    528 
    529 
    530 inline static LRESULT
    531 COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    532 {
    533     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    534 
    535     TRACE("-- %p\n", infoPtr->himl);
    536 
    537     return (LRESULT)infoPtr->himl;
    538 }
    539 
    540 
    541 static LRESULT
    542 COMBOEX_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    543 {
    544     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    545     COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
    546     INT index;
     450static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
     451{
     452    INT index = cit->iItem;
    547453    CBE_ITEMDATA *item;
    548454
    549     TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
    550 
    551     /* get real index of item to insert */
    552     index = cit->iItem;
     455    TRACE("(...)\n");
    553456
    554457    /* if item number requested does not exist then return failure */
    555     if ((index > infoPtr->nb_items) || (index < -1)) {
    556         ERR("attempt to get item that does not exist\n");
    557         return 0;
    558     }
     458    if ((index > infoPtr->nb_items) || (index < -1)) return FALSE;
    559459
    560460    /* if the item is the edit control and there is no edit control, skip */
    561     if ((index == -1) &&
    562         ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
    563             return 0;
    564 
    565     if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    566         ERR("attempt to get item that was not found!\n");
    567         return 0;
    568     }
    569 
    570     COMBOEX_CopyItem (infoPtr, item, cit);
     461    if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
     462
     463    if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
     464
     465    COMBOEX_CopyItem (item, cit);
    571466
    572467    return TRUE;
     
    574469
    575470
    576 inline static LRESULT
    577 COMBOEX_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    578 {
    579     COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
     471static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
     472{
    580473    COMBOBOXEXITEMW tmpcit;
    581     INT len;
    582 
    583     TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     474
     475    TRACE("(...)\n");
    584476
    585477    tmpcit.mask = cit->mask;
    586478    tmpcit.iItem = cit->iItem;
    587     COMBOEX_GetItemW (hwnd, wParam, (LPARAM) &tmpcit);
    588 
    589     len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL);
    590     if (len > 0)
    591         WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
     479    tmpcit.pszText = 0;
     480    if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE;
     481
     482    if (is_textW(tmpcit.pszText) && cit->pszText)
     483        WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
    592484                             cit->pszText, cit->cchTextMax, NULL, NULL);
     485    else if (cit->pszText) cit->pszText[0] = 0;
     486    else cit->pszText = (LPSTR)tmpcit.pszText;
    593487
    594488    cit->iImage = tmpcit.iImage;
     
    602496
    603497
    604 inline static LRESULT
    605 COMBOEX_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
    606 {
    607     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    608 
    609     TRACE("%s hwnd=0x%x\n",
    610            infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    611 
    612     return infoPtr->bUnicode;
    613 }
    614 
    615 
    616 inline static LRESULT
    617 COMBOEX_HasEditChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
    618 {
    619     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    620 
    621     if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    622         return FALSE;
    623     if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) ==
    624         (WCBE_ACTEDIT | WCBE_EDITCHG))
    625         return TRUE;
    626     return FALSE;
    627 }
    628 
    629 
    630 static LRESULT
    631 COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    632 {
    633     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    634     COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
     498inline static BOOL COMBOEX_HasEditChanged (COMBOEX_INFO *infoPtr)
     499{
     500    return COMBOEX_HasEdit(infoPtr) &&
     501           (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED;
     502}
     503
     504
     505static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
     506{
    635507    INT index;
    636508    CBE_ITEMDATA *item;
     
    639511    TRACE("\n");
    640512
    641     COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
     513    if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
    642514
    643515    /* get real index of item to insert */
     
    646518    if (index > infoPtr->nb_items) index = infoPtr->nb_items;
    647519
    648     /* get space and chain it in */
    649     item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
    650     item->next = NULL;
    651     item->pszText = NULL;
    652 
     520    /* get zero-filled space and chain it in */
     521    if(!(item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof(*item)))) return -1;
     522   
    653523    /* locate position to insert new item in */
    654524    if (index == infoPtr->nb_items) {
     
    666536        }
    667537        if (!moving) {
    668             FIXME("COMBOBOXEX item structures broken. Please report!\n");
     538            ERR("COMBOBOXEX item structures broken. Please report!\n");
    669539            COMCTL32_Free(item);
    670540            return -1;
     
    675545
    676546    /* fill in our hidden item structure */
    677     item->mask           = cit->mask;
     547    item->mask = cit->mask;
    678548    if (item->mask & CBEIF_TEXT) {
    679         LPWSTR str;
    680         INT len;
    681 
    682         str = cit->pszText;
    683         if (!str) str = (LPWSTR) L"";
    684         len = strlenW (str);
     549        INT len = 0;
     550
     551        if (is_textW(cit->pszText)) len = strlenW (cit->pszText);
    685552        if (len > 0) {
    686553            item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    687             strcpyW (item->pszText, str);
    688         }
    689         else
    690             item->pszText = NULL;
    691         item->cchTextMax   = cit->cchTextMax;
     554            if (!item->pszText) {
     555                COMCTL32_Free(item);
     556                return -1;
     557            }
     558            strcpyW (item->pszText, cit->pszText);
     559        }
     560        else if (cit->pszText == LPSTR_TEXTCALLBACKW)
     561            item->pszText = LPSTR_TEXTCALLBACKW;
     562        item->cchTextMax = cit->cchTextMax;
    692563    }
    693564    if (item->mask & CBEIF_IMAGE)
    694       item->iImage        = cit->iImage;
     565        item->iImage = cit->iImage;
    695566    if (item->mask & CBEIF_SELECTEDIMAGE)
    696       item->iSelectedImage = cit->iSelectedImage;
     567        item->iSelectedImage = cit->iSelectedImage;
    697568    if (item->mask & CBEIF_OVERLAY)
    698       item->iOverlay      = cit->iOverlay;
     569        item->iOverlay = cit->iOverlay;
    699570    if (item->mask & CBEIF_INDENT)
    700       item->iIndent        = cit->iIndent;
     571        item->iIndent = cit->iIndent;
    701572    if (item->mask & CBEIF_LPARAM)
    702       item->lParam        = cit->lParam;
     573        item->lParam = cit->lParam;
    703574    infoPtr->nb_items++;
    704575
    705     COMBOEX_WarnCallBack (item);
    706 
    707     COMBOEX_DumpItem (item);
     576    if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
    708577
    709578    SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
    710579                  (WPARAM)cit->iItem, (LPARAM)item);
    711580
    712     COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
     581    memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
     582    COMBOEX_CopyItem (item, &nmcit.ceItem);
    713583    COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit);
    714584
     
    718588
    719589
    720 static LRESULT
    721 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    722 {
    723     COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
    724     COMBOBOXEXITEMW     citW;
    725     LRESULT             ret;
     590static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
     591{
     592    COMBOBOXEXITEMW citW;
     593    LPWSTR wstr = NULL;
     594    INT ret;
    726595
    727596    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    728     if (cit->mask & CBEIF_TEXT) {
    729         LPSTR str;
    730         INT len;
    731 
    732         str = cit->pszText;
    733         if (!str) str="";
    734         len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    735         if (len > 0) {
    736             citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    737             MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
    738         }
    739     }
    740     ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);;
    741 
    742     if (cit->mask & CBEIF_TEXT)
    743         COMCTL32_Free(citW.pszText);
     597    if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) {
     598        INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
     599        wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     600        if (!wstr) return -1;
     601        MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
     602        citW.pszText = wstr;
     603    }
     604    ret = COMBOEX_InsertItemW(infoPtr, &citW);;
     605   
     606    if (wstr) COMCTL32_Free(wstr);
     607   
    744608    return ret;
    745609}
    746610
    747611
    748 static LRESULT
    749 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
    750 {
    751     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     612static DWORD
     613COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style)
     614{
    752615    DWORD dwTemp;
    753616
    754     TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     617    TRACE("(mask=x%08lx, style=0x%08lx)\n", mask, style);
    755618
    756619    dwTemp = infoPtr->dwExtStyle;
    757620
    758     if (lParam & (CBES_EX_NOEDITIMAGEINDENT |
    759                   CBES_EX_PATHWORDBREAKPROC |
     621    if (style &  (CBES_EX_PATHWORDBREAKPROC |
    760622                  CBES_EX_NOSIZELIMIT |
    761623                  CBES_EX_CASESENSITIVE))
    762         FIXME("Extended style not implemented %08lx\n", lParam);
    763 
    764     if ((DWORD)wParam) {
    765         infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
    766     }
     624        FIXME("Extended style not implemented %08lx\n", style);
     625
     626    if (mask)
     627        infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style;
    767628    else
    768         infoPtr->dwExtStyle = (DWORD)lParam;
    769 
    770     /*
    771      * native does this for CBES_EX_NOEDITIMAGE state change
    772      */
    773     if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^
    774         (dwTemp & CBES_EX_NOEDITIMAGE)) {
     629        infoPtr->dwExtStyle = style;
     630
     631    /* test if the control's appearance has changed */
     632    mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT;
     633    if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) {
    775634        /* if state of EX_NOEDITIMAGE changes, invalidate all */
    776635        TRACE("EX_NOEDITIMAGE state changed to %ld\n",
    777             infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
    778         InvalidateRect (hwnd, NULL, TRUE);
     636              infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
     637        InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
    779638        COMBOEX_AdjustEditPos (infoPtr);
    780639        if (infoPtr->hwndEdit)
     
    782641    }
    783642
    784     return (LRESULT)dwTemp;
    785 }
    786 
    787 
    788 inline static LRESULT
    789 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    790 {
    791     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    792     HIMAGELIST himlTemp;
    793 
    794     TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
    795 
    796     himlTemp = infoPtr->himl;
    797     infoPtr->himl = (HIMAGELIST)lParam;
    798 
    799     COMBOEX_ReSize (hwnd, infoPtr);
     643    return dwTemp;
     644}
     645
     646
     647static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl)
     648{
     649    HIMAGELIST himlTemp = infoPtr->himl;
     650
     651    TRACE("(...)\n");
     652
     653    infoPtr->himl = himl;
     654
     655    COMBOEX_ReSize (infoPtr);
    800656    InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
    801657
    802658    /* reposition the Edit control based on whether icon exists */
    803659    COMBOEX_AdjustEditPos (infoPtr);
    804     return (LRESULT)himlTemp;
    805 }
    806 
    807 static LRESULT
    808 COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    809 {
    810     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    811     COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
    812     INT index;
     660    return himlTemp;
     661}
     662
     663static BOOL COMBOEX_SetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
     664{
     665    INT index = cit->iItem;
    813666    CBE_ITEMDATA *item;
    814667
    815     COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
    816 
    817     /* get real index of item to insert */
    818     index = cit->iItem;
     668    if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
    819669
    820670    /* if item number requested does not exist then return failure */
    821     if ((index > infoPtr->nb_items) || (index < -1)) {
    822         ERR("attempt to set item that does not exist yet!\n");
    823         return 0;
    824     }
     671    if ((index > infoPtr->nb_items) || (index < -1)) return FALSE;
    825672
    826673    /* if the item is the edit control and there is no edit control, skip */
    827     if ((index == -1) &&
    828         ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
    829             return 0;
    830 
    831     if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    832         ERR("attempt to set item that was not found!\n");
    833         return 0;
    834     }
     674    if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
     675
     676    if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
    835677
    836678    /* add/change stuff to the internal item structure */
    837679    item->mask |= cit->mask;
    838680    if (cit->mask & CBEIF_TEXT) {
    839         LPWSTR str;
    840         INT len;
    841         WCHAR emptystr[1] = {0};
    842 
    843         str = cit->pszText;
    844         if (!str) str=emptystr;
    845         len = strlenW(str);
     681        INT len = 0;
     682
     683        COMBOEX_FreeText(item);
     684        if (is_textW(cit->pszText)) len = strlenW(cit->pszText);
    846685        if (len > 0) {
    847686            item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    848             strcpyW(item->pszText,str);
    849         }
    850         item->cchTextMax   = cit->cchTextMax;
     687            if (!item->pszText) return FALSE;
     688            strcpyW(item->pszText, cit->pszText);
     689        } else if (cit->pszText == LPSTR_TEXTCALLBACKW)
     690            item->pszText = LPSTR_TEXTCALLBACKW;
     691        item->cchTextMax = cit->cchTextMax;
    851692    }
    852693    if (cit->mask & CBEIF_IMAGE)
    853       item->iImage        = cit->iImage;
     694        item->iImage = cit->iImage;
    854695    if (cit->mask & CBEIF_SELECTEDIMAGE)
    855       item->iSelectedImage = cit->iSelectedImage;
     696        item->iSelectedImage = cit->iSelectedImage;
    856697    if (cit->mask & CBEIF_OVERLAY)
    857       item->iOverlay      = cit->iOverlay;
     698        item->iOverlay = cit->iOverlay;
    858699    if (cit->mask & CBEIF_INDENT)
    859       item->iIndent        = cit->iIndent;
     700        item->iIndent = cit->iIndent;
    860701    if (cit->mask & CBEIF_LPARAM)
    861       cit->lParam         = cit->lParam;
    862 
    863     COMBOEX_WarnCallBack (item);
    864 
    865     COMBOEX_DumpItem (item);
     702        cit->lParam = cit->lParam;
     703
     704    if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
    866705
    867706    /* if original request was to update edit control, do some fast foot work */
     
    873712}
    874713
    875 static LRESULT
    876 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    877 {
    878     COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
    879     COMBOBOXEXITEMW     citW;
    880     LRESULT             ret;
    881 
    882     memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    883     if (cit->mask & CBEIF_TEXT) {
    884         LPSTR str;
    885         INT len;
    886 
    887         str = cit->pszText;
    888         if (!str) str="";
    889         len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    890         if (len > 0) {
    891             citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    892             MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
    893         }
    894     }
    895     ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
    896 
    897     if (cit->mask & CBEIF_TEXT)
    898         COMCTL32_Free(citW.pszText);
     714static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
     715{
     716    COMBOBOXEXITEMW citW;
     717    LPWSTR wstr = NULL;
     718    BOOL ret;
     719
     720    memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA));
     721    if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) {
     722        INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
     723        wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     724        if (!wstr) return FALSE;
     725        MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
     726        citW.pszText = wstr;
     727    }
     728    ret = COMBOEX_SetItemW(infoPtr, &citW);;
     729
     730    if (wstr) COMCTL32_Free(wstr);
     731
    899732    return ret;
    900733}
    901734
    902735
    903 inline static LRESULT
    904 COMBOEX_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
    905 {
    906     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    907     BOOL bTemp = infoPtr->bUnicode;
    908 
    909     TRACE("to %s hwnd=0x%04x, was %s\n",
    910           ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
    911           (bTemp) ? "TRUE" : "FALSE");
    912 
    913     infoPtr->bUnicode = (BOOL)wParam;
     736static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value)
     737{
     738    BOOL bTemp = infoPtr->unicode;
     739
     740    TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE");
     741
     742    infoPtr->unicode = value;
    914743
    915744    return bTemp;
     
    917746
    918747
    919 
    920748/* ***  CB_xxx message support  *** */
    921749
    922 
    923 static LRESULT
    924 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     750static INT
     751COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCSTR str)
    925752{
    926753    INT i, count;
    927754    CBE_ITEMDATA *item;
    928755    LPWSTR desired = NULL;
    929     INT start = (INT) wParam;
    930 
    931     i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
     756
     757    i = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    932758    if (i > 0) {
    933759        desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
    934         MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
    935     }
    936 
    937     count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0 , 0);
     760        if (!desired) return CB_ERR;
     761        MultiByteToWideChar (CP_ACP, 0, str, -1, desired, i);
     762    }
     763
     764    count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
    938765
    939766    /* now search from after starting loc and wrapping back to start */
    940767    for(i=start+1; i<count; i++) {
    941         item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    942                           CB_GETITEMDATA, (WPARAM)i, 0);
    943         TRACE("desired=%s, item=%s\n",
    944               debugstr_w(desired), debugstr_w(item->pszText));
    945         if (lstrcmpiW(item->pszText, desired) == 0) {
     768        item = get_item_data(infoPtr, i);
     769        if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) {
    946770            COMCTL32_Free (desired);
    947771            return i;
     
    949773    }
    950774    for(i=0; i<=start; i++) {
    951         item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    952                           CB_GETITEMDATA, (WPARAM)i, 0);
    953         TRACE("desired=%s, item=%s\n",
    954               debugstr_w(desired), debugstr_w(item->pszText));
    955         if (lstrcmpiW(item->pszText, desired) == 0) {
     775        item = get_item_data(infoPtr, i);
     776        if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) {
    956777            COMCTL32_Free (desired);
    957778            return i;
     
    963784
    964785
    965 static LRESULT
    966 COMBOEX_GetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam)
    967 {
    968     INT index = wParam;
    969     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     786static DWORD COMBOEX_GetItemData (COMBOEX_INFO *infoPtr, INT index)
     787{
    970788    CBE_ITEMDATA *item1, *item2;
    971     LRESULT lret = 0;
    972 
    973     item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
    974                                              wParam, lParam);
     789    DWORD ret = 0;
     790
     791    item1 = get_item_data(infoPtr, index);
    975792    if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
    976793        item2 = COMBOEX_FindItem (infoPtr, index);
     
    979796            return CB_ERR;
    980797        }
    981         if (item1->mask & CBEIF_LPARAM)
    982             lret = (LRESULT) item1->lParam;
    983         TRACE("returning 0x%08lx\n", lret);
    984         return lret;
    985     }
    986     lret = (LRESULT)item1;
    987     TRACE("non-valid result from combo, returning 0x%08lx\n", lret);
    988     return lret;
    989 }
    990 
    991 
    992 static LRESULT
    993 COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam)
    994 {
    995     INT index = wParam;
    996     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     798        if (item1->mask & CBEIF_LPARAM) ret = item1->lParam;
     799        TRACE("returning 0x%08lx\n", ret);
     800    } else {
     801        ret = (DWORD)item1;
     802        TRACE("non-valid result from combo, returning 0x%08lx\n", ret);
     803    }
     804    return ret;
     805}
     806
     807
     808static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT index)
     809{
    997810    CBE_ITEMDATA *item;
    998     LRESULT lret;
    999 
    1000     if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    1001         /* FIXME: need to clear selection */
    1002         return CB_ERR;
    1003     }
    1004 
    1005     TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
    1006           debugstr_w(item->pszText) : "<null>");
     811    INT sel;
     812
     813    if (!(item = COMBOEX_FindItem(infoPtr, index)))
     814        return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
     815
     816    TRACE("selecting item %d text=%s\n", index, debugstr_txt(item->pszText));
    1007817    infoPtr->selected = index;
    1008818
    1009     lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam);
     819    sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
    1010820    COMBOEX_SetEditText (infoPtr, item);
    1011     return lret;
    1012 }
    1013 
    1014 
    1015 static LRESULT
    1016 COMBOEX_SetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1017 {
    1018     INT index = wParam;
    1019     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     821    return sel;
     822}
     823
     824
     825static DWORD COMBOEX_SetItemData (COMBOEX_INFO *infoPtr, INT index, DWORD data)
     826{
    1020827    CBE_ITEMDATA *item1, *item2;
    1021828
    1022     item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
    1023                                              wParam, lParam);
     829    item1 = get_item_data(infoPtr, index);
    1024830    if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
    1025831        item2 = COMBOEX_FindItem (infoPtr, index);
     
    1029835        }
    1030836        item1->mask |= CBEIF_LPARAM;
    1031         item1->lParam = lParam;
    1032         TRACE("setting lparam to 0x%08lx\n", lParam);
     837        item1->lParam = data;
     838        TRACE("setting lparam to 0x%08lx\n", data);
    1033839        return 0;
    1034840    }
     
    1038844
    1039845
    1040 static LRESULT
    1041 COMBOEX_SetItemHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1042 {
    1043     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     846static INT COMBOEX_SetItemHeight (COMBOEX_INFO *infoPtr, INT index, UINT height)
     847{
    1044848    RECT cb_wrect, cbx_wrect, cbx_crect;
    1045     LRESULT ret = 0;
    1046     UINT height;
    1047849
    1048850    /* First, lets forward the message to the normal combo control
    1049851       just like Windows.     */
    1050     if (infoPtr->hwndCombo)   
    1051        SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
     852    if (infoPtr->hwndCombo)
     853       if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
     854                         index, height) == CB_ERR) return CB_ERR;
    1052855
    1053856    GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
    1054     GetWindowRect (hwnd, &cbx_wrect);
    1055     GetClientRect (hwnd, &cbx_crect);
     857    GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
     858    GetClientRect (infoPtr->hwndSelf, &cbx_crect);
    1056859    /* the height of comboex as height of the combo + comboex border */
    1057860    height = cb_wrect.bottom-cb_wrect.top
     
    1064867          cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
    1065868          cbx_wrect.right-cbx_wrect.left, height);
    1066     SetWindowPos (hwnd, HWND_TOP, 0, 0,
    1067                   cbx_wrect.right-cbx_wrect.left,
    1068                   height,
     869    SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0,
     870                  cbx_wrect.right-cbx_wrect.left, height,
    1069871                  SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    1070872
    1071     return ret;
     873    return 0;
    1072874}
    1073875
     
    1076878
    1077879
    1078 static LRESULT
    1079 COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1080 {
    1081     LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
     880static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs)
     881{
     882    WCHAR COMBOBOX[] = { 'C', 'o', 'm', 'b', 'o', 'B', 'o', 'x', 0 };
     883    WCHAR EDIT[] = { 'E', 'D', 'I', 'T', 0 };
     884    WCHAR NIL[] = { 0 };
    1082885    COMBOEX_INFO *infoPtr;
    1083886    DWORD dwComboStyle;
    1084     LOGFONTA mylogfont;
    1085     CBE_ITEMDATA *item;
     887    LOGFONTW mylogfont;
    1086888    RECT wnrc1, clrc1, cmbwrc;
    1087     LONG test;
    1088889    INT i;
    1089890
    1090891    /* allocate memory for info structure */
    1091892    infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
    1092     if (infoPtr == NULL) {
    1093         ERR("could not allocate info memory!\n");
    1094         return 0;
    1095     }
     893    if (!infoPtr) return -1;
    1096894
    1097895    /* initialize info structure */
    1098 
    1099     infoPtr->items    = NULL;
    1100     infoPtr->nb_items = 0;
     896    /* note that infoPtr is allocated zero-filled */
     897   
    1101898    infoPtr->hwndSelf = hwnd;
    1102899    infoPtr->selected = -1;
    1103900
    1104     infoPtr->bUnicode = IsWindowUnicode (hwnd);
    1105 
    1106     i = SendMessageA(GetParent (hwnd),
    1107                      WM_NOTIFYFORMAT, hwnd, NF_QUERY);
    1108     if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    1109         ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    1110             i);
     901    infoPtr->unicode = IsWindowUnicode (hwnd);
     902
     903    i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     904    if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
     905        WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
    1111906        i = NFR_ANSI;
    1112907    }
    1113     infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    1114 
    1115     SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
     908    infoPtr->NtfUnicode = (i == NFR_UNICODE);
     909
     910    SetWindowLongW (hwnd, 0, (DWORD)infoPtr);
    1116911
    1117912    /* create combo box */
    1118     dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
     913    dwComboStyle = GetWindowLongW (hwnd, GWL_STYLE) &
    1119914                        (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
    1120915
     
    1136931    /* (allow space for the icons).                                     */
    1137932
    1138     infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
     933    infoPtr->hwndCombo = CreateWindowW (COMBOBOX, NIL,
    1139934                         /* following line added to match native */
    1140935                         WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
     
    1143938                         WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
    1144939                         cs->y, cs->x, cs->cx, cs->cy, hwnd,
    1145                          (HMENU) GetWindowLongA (hwnd, GWL_ID),
    1146                          GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     940                         (HMENU) GetWindowLongW (hwnd, GWL_ID),
     941                         GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
    1147942
    1148943    /*
     
    1158953     * data structure.
    1159954     */
    1160     test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo);
    1161     if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
    1162         SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
    1163     }
    1164     infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo,
     955    SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd);
     956    infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo,
    1165957                                GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
    1166958    infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     
    1172964     */
    1173965    if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
    1174         infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
     966        infoPtr->hwndEdit = CreateWindowExW (0, EDIT, NIL,
    1175967                    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
    1176968                    0, 0, 0, 0,  /* will set later */
    1177969                    infoPtr->hwndCombo,
    1178                     (HMENU) GetWindowLongA (hwnd, GWL_ID),
    1179                     GetWindowLongA (hwnd, GWL_HINSTANCE),
     970                    (HMENU) GetWindowLongW (hwnd, GWL_ID),
     971                    GetWindowLongW (hwnd, GWL_HINSTANCE),
    1180972                    NULL);
    1181973
     
    1191983         * data structure.
    1192984         */
    1193         test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
    1194         if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
    1195             SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
    1196         }
    1197         infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
     985        SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd);
     986        infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit,
    1198987                                 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
    1199988        infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    1200     }
    1201     else {
    1202         infoPtr->hwndEdit = 0;
    1203         infoPtr->font = 0;
    1204989    }
    1205990
     
    1209994     */
    1210995    if (!infoPtr->font) {
    1211         SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
     996        SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
    1212997                               &mylogfont, 0);
    1213         infoPtr->font = infoPtr->hDefaultFont = CreateFontIndirectA (&mylogfont);
     998        infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont);
    1214999    }
    12151000    SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
     
    12191004    }
    12201005
    1221     COMBOEX_ReSize (hwnd, infoPtr);
     1006    COMBOEX_ReSize (infoPtr);
    12221007
    12231008    /* Above is fairly certain, below is much less certain. */
     
    12451030    /*
    12461031     * Create an item structure to represent the data in the
    1247      * EDIT control.
     1032     * EDIT control. It is allocated zero-filled.
    12481033     */
    1249     item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
    1250     item->next = NULL;
    1251     item->pszText = NULL;
    1252     item->mask = 0;
    1253     infoPtr->edit = item;
     1034    infoPtr->edit = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
     1035    if (!infoPtr->edit) {
     1036        COMBOEX_Destroy(infoPtr);
     1037        return -1;
     1038    }
    12541039
    12551040    return 0;
     
    12571042
    12581043
    1259 inline static LRESULT
    1260 COMBOEX_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1044static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    12611045{
    12621046    LRESULT lret;
    1263     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    12641047    INT command = HIWORD(wParam);
    12651048    CBE_ITEMDATA *item = 0;
     
    12681051    NMCBEENDEDITW cbeend;
    12691052    DWORD oldflags;
     1053    HWND parent = GetParent (infoPtr->hwndSelf);
    12701054
    12711055    TRACE("for command %d\n", command);
     
    12741058    {
    12751059    case CBN_DROPDOWN:
    1276         SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1277                              (LPARAM)hwnd);
     1060        SetFocus (infoPtr->hwndCombo);
     1061        ShowWindow (infoPtr->hwndEdit, SW_HIDE);
     1062        return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
     1063       
     1064    case CBN_CLOSEUP:
     1065        SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    12781066        /*
    12791067         * from native trace of first dropdown after typing in URL in IE4
     
    12891077         * the rest is supposition 
    12901078         */
     1079        ShowWindow (infoPtr->hwndEdit, SW_SHOW);
     1080        InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
     1081        InvalidateRect (infoPtr->hwndEdit, 0, TRUE);
    12911082        cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    12921083        if (cursel == -1) {
     
    12951086            n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
    12961087            for (cursel = 0; cursel < n; cursel++){
    1297                 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1298                                                      CB_GETITEMDATA,
    1299                                                      cursel, 0);
     1088                item = get_item_data(infoPtr, cursel);
    13001089                if ((INT)item == CB_ERR) break;
    1301                 if (lstrcmpiW(item->pszText, wintext) == 0) break;
     1090                if (!lstrcmpiW(COMBOEX_GetText(infoPtr, item), wintext)) break;
    13021091            }
    13031092            if ((cursel == n) || ((INT)item == CB_ERR)) {
     
    13101099        }
    13111100        else {
    1312             item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1313                                                  CB_GETITEMDATA,
    1314                                                  cursel, 0);
     1101            item = get_item_data(infoPtr, cursel);
    13151102            if ((INT)item == CB_ERR) {
    13161103                TRACE("failed to find match??? item=%p cursel=%d\n",
     
    13321119            cbeend.iWhy = CBENF_DROPDOWN;
    13331120
    1334             if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) {
    1335                 /* abort the change */
    1336                 TRACE("Notify requested abort of change\n");
    1337                 return 0;
    1338             }
     1121            if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0;
    13391122        }
    13401123
     
    13431126        if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
    13441127            infoPtr->selected = cursel;
    1345             SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
     1128            SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0);
    13461129            SetFocus(infoPtr->hwndCombo);
    13471130        }
     
    13691152        infoPtr->selected = oldItem;
    13701153        COMBOEX_SetEditText (infoPtr, item);
    1371         return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1372                              (LPARAM)hwnd);
     1154        return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    13731155
    13741156    case CBN_SELENDOK:
     
    13771159         * issuing the message. IE4 depends on this.
    13781160         */
    1379         return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1380                              (LPARAM)hwnd);
     1161        return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    13811162
    13821163    case CBN_KILLFOCUS:
     
    13921173         *  return 0
    13931174         */
    1394         SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1395                              (LPARAM)hwnd);
     1175        SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    13961176        if (infoPtr->flags & WCBE_ACTEDIT) {
    13971177            GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
     
    14021182
    14031183            infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    1404             if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) {
    1405                 /* abort the change */
    1406                 TRACE("Notify requested abort of change\n");
    1407                 return 0;
    1408             }
     1184            if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0;
    14091185        }
    14101186        /* possible CB_GETCURSEL */
     
    14121188        return 0;
    14131189
    1414     case CBN_CLOSEUP:
    14151190    default:
    14161191        /*
     
    14201195         * after passing the command to the parent of the ComboEx.
    14211196         */
    1422         lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1423                              (LPARAM)hwnd);
     1197        lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    14241198        if (infoPtr->hwndEdit)
    14251199            SetFocus(infoPtr->hwndEdit);
     
    14301204
    14311205
    1432 inline static LRESULT
    1433 COMBOEX_WM_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1434 {
    1435     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    1436     DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)lParam;
     1206static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis)
     1207{
    14371208    CBE_ITEMDATA *item, *olditem;
     1209    NMCOMBOBOXEXW nmcit;
    14381210    INT i;
    1439     NMCOMBOBOXEXW nmcit;
    14401211
    14411212    TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
     
    14601231        }
    14611232        if (!item->next || (i != dis->itemID)) {
    1462             FIXME("COMBOBOXEX item structures broken. Please report!\n");
     1233            ERR("COMBOBOXEX item structures broken. Please report!\n");
    14631234            return FALSE;
    14641235        }
     
    14681239    infoPtr->nb_items--;
    14691240
    1470     COMBOEX_CopyItem (infoPtr, olditem, &nmcit.ceItem);
     1241    memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
     1242    COMBOEX_CopyItem (olditem, &nmcit.ceItem);
    14711243    COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit);
    14721244
    1473     if (olditem->pszText)
    1474         COMCTL32_Free(olditem->pszText);
     1245    COMBOEX_FreeText(olditem);
    14751246    COMCTL32_Free(olditem);
    14761247
    14771248    return TRUE;
    1478 
    1479 }
    1480 
    1481 
    1482 inline static LRESULT
    1483 COMBOEX_DrawItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1484 {
    1485     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    1486     DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
     1249}
     1250
     1251
     1252static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT *dis)
     1253{
     1254    WCHAR nil[] = { 0 };
    14871255    CBE_ITEMDATA *item = 0;
    14881256    SIZE txtsize;
    14891257    RECT rect;
    1490     LPWSTR str;
    1491     int drawimage, drawstate;
     1258    LPCWSTR str = nil;
    14921259    UINT xbase, x, y;
    1493     UINT xioff = 0;               /* size and spacer of image if any */
    1494     IMAGEINFO iinfo;
    14951260    INT len;
    1496     COLORREF nbkc, ntxc;
     1261    COLORREF nbkc, ntxc, bkc, txc;
     1262    int drawimage, drawstate, xioff;
    14971263
    14981264    if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
    14991265
    1500     /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
    1501     if (!TRACE_ON(message)) {
    1502         TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
    1503               dis->CtlType, dis->CtlID);
    1504         TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
    1505               dis->itemID, dis->itemAction, dis->itemState);
    1506         TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
    1507               dis->hwndItem, dis->hDC, dis->rcItem.left,
    1508               dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
    1509               dis->itemData);
    1510     }
     1266    TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
     1267          dis->CtlType, dis->CtlID);
     1268    TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
     1269          dis->itemID, dis->itemAction, dis->itemState);
     1270    TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
     1271          dis->hwndItem, dis->hDC, dis->rcItem.left,
     1272          dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
     1273          dis->itemData);
    15111274
    15121275    /* MSDN says:                                                       */
     
    15361299            {
    15371300                RECT exrc, cbrc, edrc;
    1538                 GetWindowRect (hwnd, &exrc);
     1301                GetWindowRect (infoPtr->hwndSelf, &exrc);
    15391302                GetWindowRect (infoPtr->hwndCombo, &cbrc);
    15401303                edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
     
    15581321    /* If draw item is -1 (edit control) setup the item pointer */
    15591322    if (dis->itemID == 0xffffffff) {
    1560         CHAR str[260];
    1561         INT wlen, alen;
    1562 
    15631323        item = infoPtr->edit;
    15641324
    15651325        if (infoPtr->hwndEdit) {
     1326            INT len;
    15661327
    15671328            /* free previous text of edit item */
    1568             if (item->pszText) {
    1569                 COMCTL32_Free(item->pszText);
    1570                 item->pszText = 0;
    1571                 item->mask &= ~CBEIF_TEXT;
     1329            COMBOEX_FreeText(item);
     1330            item->mask &= ~CBEIF_TEXT;
     1331            if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) {
     1332                item->mask |= CBEIF_TEXT;
     1333                item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     1334                if (item->pszText)
     1335                    GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1);
     1336           
     1337               TRACE("edit control hwndEdit=%0x, text len=%d str=%s\n",
     1338                     infoPtr->hwndEdit, len, debugstr_txt(item->pszText));
    15721339            }
    1573             alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
    1574             TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
    1575                   infoPtr->hwndEdit, alen, str);
    1576             if (alen > 0) {
    1577                 item->mask |= CBEIF_TEXT;
    1578                 wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    1579                 if (wlen > 0) {
    1580                     item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
    1581                     MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
    1582                 }
    1583             }
    1584         }
    1585     }
     1340        }
     1341    }
     1342
    15861343
    15871344    /* if the item pointer is not set, then get the data and locate it */
    15881345    if (!item) {
    1589         item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1590                              CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
    1591         if (item == (CBE_ITEMDATA *)CB_ERR)
    1592             {
    1593                 FIXME("invalid item for id %d \n",dis->itemID);
    1594                 return 0;
     1346        item = get_item_data(infoPtr, dis->itemID);
     1347        if (item == (CBE_ITEMDATA *)CB_ERR) {
     1348            ERR("invalid item for id %d \n", dis->itemID);
     1349            return 0;
     1350        }
     1351    }
     1352
     1353    if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
     1354
     1355    xbase = CBE_STARTOFFSET;
     1356    if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) {
     1357        INT indent = item->iIndent;
     1358        if (indent == I_INDENTCALLBACK) {
     1359            NMCOMBOBOXEXW nmce;
     1360            ZeroMemory(&nmce, sizeof(nmce));
     1361            nmce.ceItem.mask = CBEIF_INDENT;
     1362            COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
     1363            if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
     1364                item->iIndent = nmce.ceItem.iIndent;
     1365            indent = nmce.ceItem.iIndent;
     1366        }
     1367        xbase += (indent * CBE_INDENT);
     1368    }
     1369
     1370    drawimage = -2;
     1371    drawstate = ILD_NORMAL;
     1372    if (item->mask & CBEIF_IMAGE)
     1373        drawimage = item->iImage;
     1374    if (dis->itemState & ODS_COMBOEXLBOX) {
     1375        /* drawing listbox entry */
     1376        if (dis->itemState & ODS_SELECTED) {
     1377            if (item->mask & CBEIF_SELECTEDIMAGE)
     1378                drawimage = item->iSelectedImage;
     1379            drawstate = ILD_SELECTED;
     1380        }
     1381    } else {
     1382        /* drawing combo/edit entry */
     1383        if (IsWindowVisible(infoPtr->hwndEdit)) {
     1384            /* if we have an edit control, the slave the
     1385             * selection state to the Edit focus state
     1386             */
     1387            if (infoPtr->flags & WCBE_EDITFOCUSED) {
     1388                if (item->mask & CBEIF_SELECTEDIMAGE)
     1389                    drawimage = item->iSelectedImage;
     1390                drawstate = ILD_SELECTED;
    15951391            }
    1596     }
    1597 
    1598     COMBOEX_DumpItem (item);
    1599 
    1600     xbase = CBE_STARTOFFSET;
    1601     if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX))
    1602         xbase += (item->iIndent * CBE_INDENT);
    1603     if (item->mask & CBEIF_IMAGE) {
    1604         ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
    1605         xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
    1606     }
    1607 
    1608     switch (dis->itemAction) {
    1609     case ODA_FOCUS:
    1610         if (dis->itemState & ODS_SELECTED /*1*/) {
    1611             if ((item->mask & CBEIF_TEXT) && item->pszText) {
    1612                 RECT rect2;
    1613 
    1614                 len = strlenW (item->pszText);
    1615                 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
    1616                 rect.left = xbase + xioff - 1;
    1617                 rect.right = rect.left + txtsize.cx + 2;
    1618                 rect.top = dis->rcItem.top;
    1619                 rect.bottom = dis->rcItem.bottom;
    1620                 GetClipBox (dis->hDC, &rect2);
    1621                 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
    1622                       dis->itemID, rect.left, rect.top,
    1623                       rect.right, rect.bottom);
    1624                 TRACE("                      clip=(%d,%d)-(%d,%d)\n",
    1625                       rect2.left, rect2.top,
    1626                       rect2.right, rect2.bottom);
    1627 
    1628                 DrawFocusRect(dis->hDC, &rect);
     1392        } else {
     1393            /* if we don't have an edit control, use
     1394             * the requested state.
     1395             */
     1396            if (dis->itemState & ODS_SELECTED) {
     1397                if (item->mask & CBEIF_SELECTEDIMAGE)
     1398                    drawimage = item->iSelectedImage;
     1399                drawstate = ILD_SELECTED;
    16291400            }
    1630             else {
    1631                 FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
    1632             }
    1633         }
    1634         else {
    1635             FIXME("ODA_FOCUS but not ODS_SELECTED\n");
    1636         }
    1637         break;
    1638     case ODA_SELECT:
    1639     case ODA_DRAWENTIRE:
    1640         drawimage = -1;
    1641         drawstate = ILD_NORMAL;
    1642         if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
    1643             if (item->mask & CBEIF_IMAGE)
    1644                 drawimage = item->iImage;
    1645             if (dis->itemState & ODS_COMBOEXLBOX) {
    1646                 /* drawing listbox entry */
    1647                 if (dis->itemState & ODS_SELECTED) {
    1648                     if (item->mask & CBEIF_SELECTEDIMAGE)
    1649                         drawimage = item->iSelectedImage;
    1650                     drawstate = ILD_SELECTED;
    1651                 }
    1652             }
    1653             else {
    1654                 /* drawing combo/edit entry */
    1655                 if (infoPtr->hwndEdit) {
    1656                     /* if we have an edit control, the slave the
    1657                      * selection state to the Edit focus state
    1658                      */
    1659                     if (infoPtr->flags & WCBE_EDITFOCUSED) {
    1660                         if (item->mask & CBEIF_SELECTEDIMAGE)
    1661                             drawimage = item->iSelectedImage;
    1662                         drawstate = ILD_SELECTED;
    1663                     }
    1664                 }
    1665                 else {
    1666                     /* if we don't have an edit control, use
    1667                      * the requested state.
    1668                      */
    1669                     if (dis->itemState & ODS_SELECTED) {
    1670                         if (item->mask & CBEIF_SELECTEDIMAGE)
    1671                             drawimage = item->iSelectedImage;
    1672                         drawstate = ILD_SELECTED;
    1673                     }
    1674                 }
    1675             }
    1676         }
    1677         if (drawimage != -1) {
    1678             TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
    1679             ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
    1680                             xbase, dis->rcItem.top, drawstate);
    1681         }
    1682 
    1683         /* setup pointer to text to be drawn */
    1684         if ((item->mask & CBEIF_TEXT) && item->pszText)
    1685             str = item->pszText;
    1686         else
    1687             str = (LPWSTR) L"";
     1401        }
     1402    }
     1403
     1404    if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
     1405        IMAGEINFO iinfo;
     1406        iinfo.rcImage.left = iinfo.rcImage.right = 0;
     1407        ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     1408        xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
     1409    }  else xioff = 0;
     1410
     1411    /* setup pointer to text to be drawn */
     1412    str = COMBOEX_GetText(infoPtr, item);
     1413    if (!str) str = nil;
     1414
     1415    len = strlenW (str);
     1416    GetTextExtentPoint32W (dis->hDC, str, len, &txtsize);
     1417   
     1418    if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) {
     1419        int overlay = item->iOverlay;
     1420       
     1421        if (drawimage == I_IMAGECALLBACK) {
     1422            NMCOMBOBOXEXW nmce;
     1423            ZeroMemory(&nmce, sizeof(nmce));
     1424            nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE;
     1425            COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
     1426            if (drawstate == ILD_NORMAL) {
     1427                if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage;
     1428                drawimage = nmce.ceItem.iImage;
     1429            } else if (drawstate == ILD_SELECTED) {
     1430                if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage;
     1431                drawimage =  nmce.ceItem.iSelectedImage;
     1432            } else ERR("Bad draw state = %d\n", drawstate);
     1433        }
     1434
     1435        if (overlay == I_IMAGECALLBACK) {
     1436            NMCOMBOBOXEXW nmce;
     1437            ZeroMemory(&nmce, sizeof(nmce));
     1438            nmce.ceItem.mask = CBEIF_OVERLAY;
     1439            COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
     1440            if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
     1441                item->iOverlay = nmce.ceItem.iOverlay;
     1442            overlay = nmce.ceItem.iOverlay;
     1443        }
     1444   
     1445        if (drawimage >= 0 &&
     1446            !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) {
     1447            if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1);
     1448            ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top,
     1449                            drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0));
     1450        }
    16881451
    16891452        /* now draw the text */
    1690         len = lstrlenW (str);
    1691         GetTextExtentPointW (dis->hDC, str, len, &txtsize);
    1692         nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    1693                             COLOR_HIGHLIGHT : COLOR_WINDOW);
    1694         SetBkColor (dis->hDC, nbkc);
    1695         ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    1696                             COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
    1697         SetTextColor (dis->hDC, ntxc);
    1698         x = xbase + xioff;
    1699         y = dis->rcItem.top +
    1700             (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
    1701         rect.left = x;
    1702         rect.right = x + txtsize.cx;
    1703         rect.top = dis->rcItem.top + 1;
    1704         rect.bottom = dis->rcItem.bottom - 1;
    1705         TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
    1706               dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    1707         ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
    1708                      &rect, str, len, 0);
    1709         if (dis->itemState & ODS_FOCUS) {
    1710             rect.top -= 1;
    1711             rect.bottom += 1;
    1712             rect.left -= 1;
    1713             rect.right += 1;
    1714             TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
    1715                   dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    1716             DrawFocusRect (dis->hDC, &rect);
    1717         }
    1718         break;
    1719     default:
    1720         FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
    1721               hwnd, wParam, lParam, dis->itemAction);
     1453        if (!IsWindowVisible (infoPtr->hwndEdit)) {
     1454            nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1455                                COLOR_HIGHLIGHT : COLOR_WINDOW);
     1456            bkc = SetBkColor (dis->hDC, nbkc);
     1457            ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1458                                COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
     1459            txc = SetTextColor (dis->hDC, ntxc);
     1460            x = xbase + xioff;
     1461            y = dis->rcItem.top +
     1462                (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
     1463            rect.left = x;
     1464            rect.right = x + txtsize.cx;
     1465            rect.top = dis->rcItem.top + 1;
     1466            rect.bottom = dis->rcItem.bottom - 1;
     1467            TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
     1468                  dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1469            ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
     1470                         &rect, str, len, 0);
     1471            SetBkColor (dis->hDC, bkc);
     1472            SetTextColor (dis->hDC, txc);
     1473        }
     1474    }
     1475   
     1476    if (dis->itemAction & ODA_FOCUS) {
     1477        rect.left = xbase + xioff - 1;
     1478        rect.right = rect.left + txtsize.cx + 2;
     1479        rect.top = dis->rcItem.top;
     1480        rect.bottom = dis->rcItem.bottom;
     1481        DrawFocusRect(dis->hDC, &rect);
    17221482    }
    17231483
     
    17261486
    17271487
    1728 static LRESULT
    1729 COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1730 {
    1731     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    1732 
     1488static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr)
     1489{
    17331490    if (infoPtr->hwndCombo)
    17341491        DestroyWindow (infoPtr->hwndCombo);
     
    17401497
    17411498    if (infoPtr->items) {
    1742         CBE_ITEMDATA *this, *next;
    1743 
    1744         this = infoPtr->items;
    1745         while (this) {
    1746             next = (CBE_ITEMDATA *)this->next;
    1747             if ((this->mask & CBEIF_TEXT) && this->pszText)
    1748                 COMCTL32_Free (this->pszText);
    1749             COMCTL32_Free (this);
    1750             this = next;
    1751         }
    1752     }
    1753 
    1754     if (infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
     1499        CBE_ITEMDATA *item, *next;
     1500
     1501        item = infoPtr->items;
     1502        while (item) {
     1503            next = (CBE_ITEMDATA *)item->next;
     1504            COMBOEX_FreeText (item);
     1505            COMCTL32_Free (item);
     1506            item = next;
     1507        }
     1508        infoPtr->items = 0;
     1509    }
     1510
     1511    if (infoPtr->defaultFont)
     1512        DeleteObject (infoPtr->defaultFont);
    17551513
    17561514    /* free comboex info data */
    17571515    COMCTL32_Free (infoPtr);
    1758     SetWindowLongA (hwnd, 0, 0);
     1516    SetWindowLongW (infoPtr->hwndSelf, 0, 0);
    17591517    return 0;
    17601518}
    17611519
    17621520
    1763 static LRESULT
    1764 COMBOEX_MeasureItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1765 {
    1766     /*COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);*/
    1767     MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
     1521static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis)
     1522{
     1523    SIZE mysize;
    17681524    HDC hdc;
    1769     SIZE mysize;
    17701525
    17711526    hdc = GetDC (0);
     
    17751530
    17761531    TRACE("adjusted height hwnd=%08x, height=%d\n",
    1777           hwnd, mis->itemHeight);
     1532          infoPtr->hwndSelf, mis->itemHeight);
    17781533
    17791534    return 0;
     
    17811536
    17821537
    1783 static LRESULT
    1784 COMBOEX_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1538static LRESULT COMBOEX_NCCreate (HWND hwnd)
    17851539{
    17861540    /* WARNING: The COMBOEX_INFO structure is not yet created */
    17871541    DWORD oldstyle, newstyle;
    17881542
    1789     oldstyle = (DWORD)GetWindowLongA (hwnd, GWL_STYLE);
     1543    oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE);
    17901544    newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
    17911545    if (newstyle != oldstyle) {
    17921546        TRACE("req style %08lx, reseting style %08lx\n",
    17931547              oldstyle, newstyle);
    1794         SetWindowLongA (hwnd, GWL_STYLE, newstyle);
     1548        SetWindowLongW (hwnd, GWL_STYLE, newstyle);
    17951549    }
    17961550    return 1;
     
    17981552
    17991553
    1800 static LRESULT
    1801 COMBOEX_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1802 {
    1803     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    1804     INT i;
    1805 
     1554static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam)
     1555{
    18061556    if (lParam == NF_REQUERY) {
    1807         i = SendMessageA(GetParent (hwnd),
     1557        INT i = SendMessageW(GetParent (infoPtr->hwndSelf),
    18081558                         WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
    1809         if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    1810             ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    1811                 i);
    1812             i = NFR_ANSI;
    1813         }
    18141559        infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    1815         return (LRESULT)i;
    1816     }
    1817     return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
    1818 }
    1819 
    1820 
    1821 static LRESULT
    1822 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1823 {
    1824     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    1825     RECT rect;
    1826 
    1827     GetWindowRect (hwnd, &rect);
    1828     TRACE("my rect (%d,%d)-(%d,%d)\n",
    1829           rect.left, rect.top, rect.right, rect.bottom);
    1830 
    1831     MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
    1832                   rect.bottom - rect.top, TRUE);
     1560    }
     1561    return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI;
     1562}
     1563
     1564
     1565static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height)
     1566{
     1567    TRACE("(width=%d, height=%d)\n", width, height);
     1568
     1569    MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE);
    18331570
    18341571    COMBOEX_AdjustEditPos (infoPtr);
     
    18381575
    18391576
    1840 static LRESULT
    1841 COMBOEX_WindowPosChanging (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1842 {
    1843     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     1577static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp)
     1578{
    18441579    RECT cbx_wrect, cbx_crect, cb_wrect;
    18451580    UINT width, height;
    1846     WINDOWPOS *wp = (WINDOWPOS *)lParam;
    1847 
    1848     GetWindowRect (hwnd, &cbx_wrect);
    1849     GetClientRect (hwnd, &cbx_crect);
     1581
     1582    GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
     1583    GetClientRect (infoPtr->hwndSelf, &cbx_crect);
    18501584    GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
    18511585
     
    18881622COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    18891623{
    1890     COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
     1624    HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP);
     1625    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
    18911626    NMCBEENDEDITW cbeend;
    18921627    WCHAR edit_text[260];
    1893     COLORREF nbkc, obkc;
     1628    COLORREF obkc;
    18941629    HDC hDC;
    18951630    RECT rect;
     
    19041639    {
    19051640
    1906     case WM_CHAR:
     1641        case WM_CHAR:
    19071642            /* handle (ignore) the return character */
    19081643            if (wParam == VK_RETURN) return 0;
    19091644            /* all other characters pass into the real Edit */
    1910             return CallWindowProcA (infoPtr->prevEditWndProc,
     1645            return CallWindowProcW (infoPtr->prevEditWndProc,
    19111646                                   hwnd, uMsg, wParam, lParam);
    19121647
    1913     case WM_ERASEBKGND:
     1648        case WM_ERASEBKGND:
    19141649            /*
    19151650             * The following was determined by traces of the native
    19161651             */
    19171652            hDC = (HDC) wParam;
    1918             nbkc = GetSysColor (COLOR_WINDOW);
    1919             obkc = SetBkColor (hDC, nbkc);
     1653            obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW));
    19201654            GetClientRect (hwnd, &rect);
    19211655            TRACE("erasing (%d,%d)-(%d,%d)\n",
     
    19231657            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    19241658            SetBkColor (hDC, obkc);
    1925             return CallWindowProcA (infoPtr->prevEditWndProc,
     1659            return CallWindowProcW (infoPtr->prevEditWndProc,
    19261660                                   hwnd, uMsg, wParam, lParam);
    19271661
    1928     case WM_KEYDOWN: {
    1929             INT oldItem, selected;
     1662        case WM_KEYDOWN: {
     1663            INT oldItem, selected, step = 1;
    19301664            CBE_ITEMDATA *item;
    19311665
     
    19601694                cbeend.iWhy = CBENF_ESCAPE;
    19611695
    1962                 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    1963                     /* abort the change */
    1964                     TRACE("Notify requested abort of change\n");
    1965                     return 0;
    1966                 }
    1967                 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     1696                if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
     1697                oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    19681698                InvalidateRect (infoPtr->hwndCombo, 0, 0);
    19691699                if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     
    20101740                    item = COMBOEX_FindItem (infoPtr, selected);
    20111741                    TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
    2012                           selected, debugstr_w(item->pszText));
     1742                          selected, debugstr_txt(item->pszText));
    20131743                    TRACE("handling VK_RETURN, edittext=%s\n",
    20141744                          debugstr_w(edit_text));
    2015                     if (lstrcmpiW (item->pszText, edit_text)) {
     1745                    if (lstrcmpiW (COMBOEX_GetText(infoPtr, item), edit_text)) {
    20161746                        /* strings not equal -- indicate edit has changed */
    20171747                        selected = -1;
     
    20401770                break;
    20411771
     1772            case VK_UP:
     1773                step = -1;
     1774            case VK_DOWN:
     1775                /* by default, step is 1 */
     1776                oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0);
     1777                if (oldItem >= 0 && oldItem + step >= 0)
     1778                    SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0);
     1779                return 0;
    20421780            default:
    2043                 return CallWindowProcA (infoPtr->prevEditWndProc,
     1781                return CallWindowProcW (infoPtr->prevEditWndProc,
    20441782                                       hwnd, uMsg, wParam, lParam);
    20451783            }
     
    20471785            }
    20481786
    2049     case WM_SETFOCUS:
     1787        case WM_SETFOCUS:
    20501788            /* remember the focus to set state of icon */
    2051             lret = CallWindowProcA (infoPtr->prevEditWndProc,
     1789            lret = CallWindowProcW (infoPtr->prevEditWndProc,
    20521790                                   hwnd, uMsg, wParam, lParam);
    20531791            infoPtr->flags |= WCBE_EDITFOCUSED;
    20541792            return lret;
    20551793
    2056     case WM_KILLFOCUS:
     1794        case WM_KILLFOCUS:
    20571795            /*
    20581796             * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
     
    20721810            /* fall through */
    20731811
    2074     default:
    2075             return CallWindowProcA (infoPtr->prevEditWndProc,
     1812        default:
     1813            return CallWindowProcW (infoPtr->prevEditWndProc,
    20761814                                   hwnd, uMsg, wParam, lParam);
    20771815    }
     
    20831821COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    20841822{
    2085     COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
     1823    HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP);
     1824    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
    20861825    NMCBEENDEDITW cbeend;
    20871826    NMMOUSE nmmse;
    2088     COLORREF nbkc, obkc;
     1827    COLORREF obkc;
    20891828    HDC hDC;
    20901829    HWND focusedhwnd;
     
    21011840
    21021841    case CB_FINDSTRINGEXACT:
    2103             return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
     1842            return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam);
    21041843
    21051844    case WM_DRAWITEM:
     
    21101849             */
    21111850            ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
    2112             return CallWindowProcA (infoPtr->prevComboWndProc,
     1851            return CallWindowProcW (infoPtr->prevComboWndProc,
    21131852                                   hwnd, uMsg, wParam, lParam);
    21141853
     
    21181857             */
    21191858            hDC = (HDC) wParam;
    2120             nbkc = GetSysColor (COLOR_WINDOW);
    2121             obkc = SetBkColor (hDC, nbkc);
     1859            obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW));
    21221860            GetClientRect (hwnd, &rect);
    21231861            TRACE("erasing (%d,%d)-(%d,%d)\n",
     
    21251863            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    21261864            SetBkColor (hDC, obkc);
    2127             return CallWindowProcA (infoPtr->prevComboWndProc,
     1865            return CallWindowProcW (infoPtr->prevComboWndProc,
    21281866                                   hwnd, uMsg, wParam, lParam);
    21291867
     
    21401878            nmmse.dwHitInfo = lParam;
    21411879            COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
    2142             return CallWindowProcA (infoPtr->prevComboWndProc,
     1880            return CallWindowProcW (infoPtr->prevComboWndProc,
    21431881                                   hwnd, uMsg, wParam, lParam);
    21441882
     
    21741912
    21751913                    infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    2176                     if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    2177                         /* abort the change */
    2178                         TRACE("Notify requested abort of change\n");
    2179                         return 0;
    2180                     }
     1914                    if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
    21811915                }
    21821916                /* possible CB_GETCURSEL */
     
    22191953                 */
    22201954                WCHAR edit_text[260];
    2221                 WCHAR *lastwrk;
    2222                 INT selected, cnt;
     1955                LPCWSTR lastwrk;
     1956                INT selected;
    22231957                CBE_ITEMDATA *item;
    22241958
     
    22311965                if (selected == -1) {
    22321966                    lastwrk = infoPtr->edit->pszText;
    2233                     cnt = lstrlenW (lastwrk);
    2234                     if (cnt >= 259) cnt = 259;
    22351967                }
    22361968                else {
    22371969                    item = COMBOEX_FindItem (infoPtr, selected);
    2238                     cnt = lstrlenW (item->pszText);
    2239                     lastwrk = item->pszText;
    2240                     if (cnt >= 259) cnt = 259;
     1970                    lastwrk = COMBOEX_GetText(infoPtr, item);
    22411971                }
    22421972
    22431973                TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
    2244                     selected, debugstr_w(lastwrk));
     1974                      selected, debugstr_w(lastwrk));
    22451975                TRACE("handling EN_CHANGE, edittext=%s\n",
    22461976                      debugstr_w(edit_text));
    22471977
    22481978                /* lstrcmpiW is between lastworkingURL and GetWindowText */
    2249 
    22501979                if (lstrcmpiW (lastwrk, edit_text)) {
    22511980                    /* strings not equal -- indicate edit has changed */
     
    22952024            }/* fall through */
    22962025    default:
    2297             return CallWindowProcA (infoPtr->prevComboWndProc,
     2026            return CallWindowProcW (infoPtr->prevComboWndProc,
    22982027                                   hwnd, uMsg, wParam, lParam);
    22992028    }
     
    23092038    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
    23102039
    2311     if (!COMBOEX_GetInfoPtr (hwnd)) {
     2040    if (!infoPtr) {
    23122041        if (uMsg == WM_CREATE)
    2313             return COMBOEX_Create (hwnd, wParam, lParam);
     2042            return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam);
    23142043        if (uMsg == WM_NCCREATE)
    2315             COMBOEX_NCCreate (hwnd, wParam, lParam);
    2316         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2044            COMBOEX_NCCreate (hwnd);
     2045        return DefWindowProcW (hwnd, uMsg, wParam, lParam);
    23172046    }
    23182047
    23192048    switch (uMsg)
    23202049    {
    2321         case CBEM_DELETEITEM:  /* maps to CB_DELETESTRING */
    2322             return COMBOEX_DeleteItem (hwnd, wParam, lParam);
     2050        case CBEM_DELETEITEM:
     2051            return COMBOEX_DeleteItem (infoPtr, wParam);
    23232052
    23242053        case CBEM_GETCOMBOCONTROL:
    2325             return COMBOEX_GetComboControl (hwnd, wParam, lParam);
     2054            return infoPtr->hwndCombo;
    23262055
    23272056        case CBEM_GETEDITCONTROL:
    2328             return COMBOEX_GetEditControl (hwnd, wParam, lParam);
     2057            return infoPtr->hwndEdit;
    23292058
    23302059        case CBEM_GETEXTENDEDSTYLE:
    2331             return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
     2060            return infoPtr->dwExtStyle;
    23322061
    23332062        case CBEM_GETIMAGELIST:
    2334             return COMBOEX_GetImageList (hwnd, wParam, lParam);
     2063            return (LRESULT)infoPtr->himl;
    23352064
    23362065        case CBEM_GETITEMA:
    2337             return COMBOEX_GetItemA (hwnd, wParam, lParam);
     2066            return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
    23382067
    23392068        case CBEM_GETITEMW:
    2340             return COMBOEX_GetItemW (hwnd, wParam, lParam);
     2069            return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
    23412070
    23422071        case CBEM_GETUNICODEFORMAT:
    2343             return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
     2072            return infoPtr->unicode;
    23442073
    23452074        case CBEM_HASEDITCHANGED:
    2346             return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
     2075            return COMBOEX_HasEditChanged (infoPtr);
    23472076
    23482077        case CBEM_INSERTITEMA:
    2349             return COMBOEX_InsertItemA (hwnd, wParam, lParam);
     2078            return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
    23502079
    23512080        case CBEM_INSERTITEMW:
    2352             return COMBOEX_InsertItemW (hwnd, wParam, lParam);
    2353 
    2354         case CBEM_SETEXSTYLE:   /* FIXME: obsoleted, should be the same as: */
     2081            return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
     2082
     2083        case CBEM_SETEXSTYLE:
    23552084        case CBEM_SETEXTENDEDSTYLE:
    2356             return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
     2085            return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam);
    23572086
    23582087        case CBEM_SETIMAGELIST:
    2359             return COMBOEX_SetImageList (hwnd, wParam, lParam);
     2088            return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam);
    23602089
    23612090        case CBEM_SETITEMA:
    2362             return COMBOEX_SetItemA (hwnd, wParam, lParam);
     2091            return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
    23632092
    23642093        case CBEM_SETITEMW:
    2365             return COMBOEX_SetItemW (hwnd, wParam, lParam);
     2094            return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
    23662095
    23672096        case CBEM_SETUNICODEFORMAT:
    2368             return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
    2369 
     2097            return COMBOEX_SetUnicodeFormat (infoPtr, wParam);
     2098
     2099        /*case CBEM_SETWINDOWTHEME:
     2100            FIXME("CBEM_SETWINDOWTHEME: stub\n");*/
    23702101
    23712102/*   Combo messages we are not sure if we need to process or just forward */
     
    23822113            FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
    23832114                  uMsg, wParam, lParam);
    2384             return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    23852115
    23862116/*   Combo messages OK to just forward to the regular COMBO */
     
    23912121        case CB_SETEXTENDEDUI:
    23922122        case CB_SHOWDROPDOWN:
    2393             return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     2123            return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam);
    23942124
    23952125/*   Combo messages we need to process specially */
    23962126        case CB_FINDSTRINGEXACT:
    2397             return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
    2398                                             wParam, lParam);
     2127            return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam);
    23992128
    24002129        case CB_GETITEMDATA:
    2401             return COMBOEX_GetItemData (hwnd, wParam, lParam);
     2130            return COMBOEX_GetItemData (infoPtr, (INT)wParam);
    24022131
    24032132        case CB_SETCURSEL:
    2404             return COMBOEX_SetCursel (hwnd, wParam, lParam);
     2133            return COMBOEX_SetCursel (infoPtr, (INT)wParam);
    24052134
    24062135        case CB_SETITEMDATA:
    2407             return COMBOEX_SetItemData (hwnd, wParam, lParam);
     2136            return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD)lParam);
    24082137
    24092138        case CB_SETITEMHEIGHT:
    2410             return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
     2139            return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam);
    24112140
    24122141
     
    24142143/*   Window messages passed to parent */
    24152144        case WM_COMMAND:
    2416             return COMBOEX_Command (hwnd, wParam, lParam);
     2145            return COMBOEX_Command (infoPtr, wParam, lParam);
    24172146
    24182147        case WM_NOTIFY:
    24192148            if (infoPtr->NtfUnicode)
    2420                 return SendMessageW (GetParent (hwnd),
    2421                                      uMsg, wParam, lParam);
     2149                return SendMessageW (GetParent (hwnd), uMsg, wParam, lParam);
    24222150            else
    2423                 return SendMessageA (GetParent (hwnd),
    2424                                      uMsg, wParam, lParam);
     2151                return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
    24252152
    24262153
    24272154/*   Window messages we need to process */
    24282155        case WM_DELETEITEM:
    2429             return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
     2156            return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam);
    24302157
    24312158        case WM_DRAWITEM:
    2432             return COMBOEX_DrawItem (hwnd, wParam, lParam);
     2159            return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam);
    24332160
    24342161        case WM_DESTROY:
    2435             return COMBOEX_Destroy (hwnd, wParam, lParam);
     2162            return COMBOEX_Destroy (infoPtr);
    24362163
    24372164        case WM_MEASUREITEM:
    2438             return COMBOEX_MeasureItem (hwnd, wParam, lParam);
     2165            return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam);
    24392166
    24402167        case WM_NOTIFYFORMAT:
    2441             return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
     2168            return COMBOEX_NotifyFormat (infoPtr, lParam);
    24422169
    24432170        case WM_SIZE:
    2444             return COMBOEX_Size (hwnd, wParam, lParam);
     2171            return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam));
    24452172
    24462173        case WM_WINDOWPOSCHANGING:
    2447             return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
     2174            return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam);
    24482175
    24492176        default:
    24502177            if (uMsg >= WM_USER)
    2451                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    2452                      uMsg, wParam, lParam);
    2453             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2178                ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam);
     2179            return DefWindowProcW (hwnd, uMsg, wParam, lParam);
    24542180    }
    24552181    return 0;
     
    24572183
    24582184
    2459 VOID
    2460 COMBOEX_Register (void)
    2461 {
    2462     WNDCLASSA wndClass;
    2463 
    2464     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
     2185void COMBOEX_Register (void)
     2186{
     2187    WNDCLASSW wndClass;
     2188
     2189    ZeroMemory (&wndClass, sizeof(WNDCLASSW));
    24652190    wndClass.style         = CS_GLOBALCLASS;
    24662191    wndClass.lpfnWndProc   = (WNDPROC)COMBOEX_WindowProc;
    24672192    wndClass.cbClsExtra    = 0;
    24682193    wndClass.cbWndExtra    = sizeof(COMBOEX_INFO *);
    2469     wndClass.hCursor       = LoadCursorA (0, IDC_ARROWA);
     2194    wndClass.hCursor       = LoadCursorW (0, IDC_ARROWW);
    24702195    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    2471     wndClass.lpszClassName = WC_COMBOBOXEXA;
     2196    wndClass.lpszClassName = WC_COMBOBOXEXW;
    24722197 
    2473     RegisterClassA (&wndClass);
    2474 
    2475     ComboExInfo = GlobalAddAtomA("CC32SubclassInfo");
    2476 }
    2477 
    2478 
    2479 VOID
    2480 COMBOEX_Unregister (void)
    2481 {
    2482     UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);
    2483 }
    2484 
     2198    RegisterClassW (&wndClass);
     2199}
     2200
     2201
     2202void COMBOEX_Unregister (void)
     2203{
     2204    UnregisterClassW (WC_COMBOBOXEXW, (HINSTANCE)NULL);
     2205}
     2206
Note: See TracChangeset for help on using the changeset viewer.