Changeset 5416


Ignore:
Timestamp:
Mar 31, 2001, 3:25:59 PM (24 years ago)
Author:
sandervl
Message:

Resync with Wine + previous merge fixes

Location:
trunk/src/comctl32
Files:
2 added
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/comctl32/CCBase.h

    r4627 r5416  
    1 /* $Id: CCBase.h,v 1.11 2000-11-19 11:51:47 sandervl Exp $ */
     1/* $Id: CCBase.h,v 1.12 2001-03-31 13:25:25 sandervl Exp $ */
    22/*
    33 * COMCTL32 Base Functions and Macros for all Controls
     
    77#ifndef __CCBASE_H
    88#define __CCBASE_H
     9
     10#include <heapstring.h>
    911
    1012#define getInfoPtr(hwnd) ((COMCTL32_HEADER*)GetWindowLongA(hwnd,0))
     
    2022} COMCTL32_HEADER;
    2123
    22 PVOID initControl(HWND hwnd,DWORD dwSize);
    23 VOID doneControl(HWND hwnd);
    24 
    25 
    2624#ifdef __cplusplus
    2725extern "C" {
    2826#endif
     27
     28PVOID initControl(HWND hwnd,DWORD dwSize);
     29VOID doneControl(HWND hwnd);
    2930
    3031LRESULT defComCtl32ProcA(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam);
     
    6566INT lstrcmpAW(WCHAR *textA,BOOL textaunicode,WCHAR *textB,BOOL textbunicode);
    6667
     68
    6769//read note in CCBase.cpp!!
    6870INT lstrcmpniA(CHAR *textA,CHAR *textB,INT len);
    6971INT lstrcmpniAtoW(CHAR *textA,WCHAR* textB,INT len);
    70 INT lstrcmpniW(WCHAR *textA,WCHAR *textB,INT len);
     72////INT lstrcmpniW(WCHAR *textA,WCHAR *textB,INT len);
    7173INT lstrcmpniAW(WCHAR *textA,BOOL unicodeA,WCHAR *textB,BOOL unicodeB,INT len);
    7274
  • TabularUnified trunk/src/comctl32/animate.c

    r4627 r5416  
    3030typedef struct
    3131{
     32#ifdef __WIN32OS2__
     33    COMCTL32_HEADER header;
     34#endif
     35
    3236   /* pointer to msvideo functions. it's easier to put them here.
    3337    * to be correct, they should be defined on a per process basis, but
     
    819823
    820824    /* allocate memory for info structure */
     825#ifdef __WIN32OS2__
     826    infoPtr = (ANIMATE_INFO*)initControl(hWnd,sizeof(ANIMATE_INFO));
     827#else
    821828    infoPtr = (ANIMATE_INFO *)COMCTL32_Alloc(sizeof(ANIMATE_INFO));
     829#endif
    822830    if (!infoPtr) {
    823831        ERR("could not allocate info memory!\n");
  • TabularUnified trunk/src/comctl32/comboex.c

    r4627 r5416  
    11/*
    2  * ComboBoxEx control
     2 * TODO   <-------------
     3 *  1. The following extended styles need to be implemented, use will
     4 *     result in a FIXME:
     5 *           CBES_EX_NOEDITIMAGEINDENT
     6 *           CBES_EX_PATHWORDBREAKPROC
     7 *           CBES_EX_NOSIZELIMIT
     8 *           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 (mod4)
    322 *
    423 * Copyright 1998, 1999 Eric Kohl
     
    928 *     Eric <ekohl@abo.rhein-zeitung.de>
    1029 *
    11  * TODO:
    12  *   - All messages.
    13  *   - All notifications.
     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.
    1451 *
    15  * FIXME:
    16  *   - should include "combo.h"
    17 
    18  * Changes  Guy Albertelli <galberte@neo.lrun.com>
    19  *   1. Implemented message CB_SETITEMHEIGHT
    20  *   2. Implemented message WM_WINDOWPOSCHANGING
    21  *   3. Implemented message WM_MEASUREITEM
    22  *   4. Add code to WM_CREATE processing to set font of COMBOBOX and
    23  *      issue the CB_SETITEMHEIGHT to start the correct sizing process.
    24  * The above 4 changes allow the window rect for the comboboxex
    25  * to be set properly, which in turn allows the height of the
    26  * rebar control it *may* be imbeded in to be correct.
    27  *   5. Rewrite CBEM_INSERTITEMA to save the information.
    28  *   6. Implemented message WM_DRAWITEM. The code will handle images
    29  *      but not "overlays" yet.
    30  *   7. Fixed code in CBEM_SETIMAGELIST to resize control.
    31  *   8. Add debugging code.
     52 *  mod 4
     53 *   1. Implemented CBN_SELCHANGE, CBN_KILLFOCUS, and CBN_SELENDOK.
     54 *   2. Fix putting text in CBEN_ENDEDIT notifys 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.
    3260 *
    33  * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe)
     61 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe),
     62 *  and IE 4.0.
    3463 *
    3564 */
    3665
    37 #ifdef __WIN32OS2__
    38 #include <odin.h>
    3966#include <string.h>
    40 #define inline
    41 #endif
    42 
    4367#include "winbase.h"
    44 #include "wine/winestring.h"
    4568#include "commctrl.h"
    4669#include "debugtools.h"
    4770#include "wine/unicode.h"
    4871
     72#ifdef __WIN32OS2__
     73#include "ccbase.h"
     74#define inline
     75#endif
     76
    4977DEFAULT_DEBUG_CHANNEL(comboex);
     78/*
     79 * The following is necessary for the test done in COMBOEX_DrawItem
     80 * to determine whether to dump out the DRAWITEM structure or not.
     81 */
    5082DECLARE_DEBUG_CHANNEL(message);
    5183
     
    5385typedef struct
    5486{
    55     VOID *next;
    56     UINT mask;
    57     LPWSTR pszText;
    58     int cchTextMax;
    59     int iImage;
    60     int iSelectedImage;
    61     int iOverlay;
    62     int iIndent;
    63     LPARAM lParam;
     87    VOID         *next;
     88    UINT         mask;
     89    LPWSTR       pszText;
     90    int          cchTextMax;
     91    int          iImage;
     92    int          iSelectedImage;
     93    int          iOverlay;
     94    int          iIndent;
     95    LPARAM       lParam;
    6496} CBE_ITEMDATA;
    6597
     
    6799typedef struct
    68100{
     101#ifdef __WIN32OS2__
     102    COMCTL32_HEADER header;
     103#endif
    69104    HIMAGELIST   himl;
     105    HWND         hwndSelf;         /* my own hwnd */
    70106    HWND         hwndCombo;
     107    HWND         hwndEdit;
     108    WNDPROC      prevEditWndProc;  /* previous Edit WNDPROC value */
     109    WNDPROC      prevComboWndProc;   /* previous Combo WNDPROC value */
    71110    DWORD        dwExtStyle;
     111    DWORD        flags;            /* WINE internal flags */
    72112    HFONT        font;
    73113    INT          nb_items;         /* Number of items */
     114    BOOL         bUnicode;         /* ASCII (FALSE) or Unicode (TRUE)? */
     115    CBE_ITEMDATA *edit;            /* item data for edit item */
    74116    CBE_ITEMDATA *items;           /* Array of items */
    75117} COMBOEX_INFO;
    76118
     119/* internal flags in the COMBOEX_INFO structure */
     120#define  WCBE_ACTEDIT        0x00000001     /* Edit active i.e.
     121                                             * CBEN_BEGINEDIT issued
     122                                             * but CBEN_ENDEDIT{A|W}
     123                                             * not yet issued. */
     124#define  WCBE_EDITCHG        0x00000002     /* Edit issued EN_CHANGE */
     125#define  WCBE_EDITFOCUSED    0x00000004     /* Edit control has focus */
     126
     127
    77128#define ID_CB_EDIT    1001
     129
     130
     131/*
     132 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
     133 * the ComboEx version of the Combo Window Proc so that when the
     134 * WM_DRAWITEM message is then passed to ComboEx, we know that this
     135 * particular WM_DRAWITEM message is for listbox only items. Any messasges
     136 * without this flag is then for the Edit control field.
     137 *
     138 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
     139 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
     140 */
     141#define ODS_COMBOEXLBOX  0x4000
     142
     143
    78144
    79145/* Height in pixels of control over the amount of the selected font */
     
    89155#define CBE_SEP   4
    90156
    91 #define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
    92 
     157#define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
     158
     159
     160/* Things common to the entire DLL */
     161static ATOM ComboExInfo;
     162static LRESULT WINAPI
     163COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
     164static LRESULT WINAPI
     165COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    93166
    94167static void
     
    97170    if (TRACE_ON(comboex)){
    98171      TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
    99         item, item->mask, item->pszText, item->cchTextMax,
    100         item->iImage);
     172            item, item->mask, item->pszText, item->cchTextMax,
     173            item->iImage);
    101174      TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    102         item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
     175            item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
     176      if ((item->mask & CBEIF_TEXT) && item->pszText)
     177          TRACE("item %p - pszText=%s\n",
     178                item, debugstr_w((const WCHAR *)item->pszText));
     179    }
     180}
     181
     182
     183static void
     184COMBOEX_DumpInput (COMBOBOXEXITEMA *input, BOOL true_for_w)
     185{
     186    if (TRACE_ON(comboex)){
     187      TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
     188            input->mask, input->iItem, input->pszText, input->cchTextMax,
     189            input->iImage);
     190      if ((input->mask & CBEIF_TEXT) && input->pszText) {
     191          if (true_for_w)
     192              TRACE("input - pszText=<%s>\n",
     193                    debugstr_w((const WCHAR *)input->pszText));
     194          else
     195              TRACE("input - pszText=<%s>\n",
     196                    debugstr_a((const char *)input->pszText));
     197      }
     198      TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
     199            input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
    103200    }
    104201}
     
    110207    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    111208
    112     FIXME("(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam);
    113 
    114     if (infoPtr->hwndCombo)
    115     return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
     209    if (infoPtr->hwndCombo)   
     210        return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
    116211
    117212    return 0;
     213}
     214
     215
     216static INT
     217COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr, BOOL doW)
     218{
     219
     220    hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
     221    hdr->hwndFrom = infoPtr->hwndSelf;
     222    hdr->code = code;
     223    if (doW)
     224        return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     225                             (LPARAM)hdr);
     226    else
     227        return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     228                             (LPARAM)hdr);
     229}
     230
     231
     232static void
     233COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
     234{
     235    HFONT nfont, ofont;
     236    HDC mydc;
     237
     238    mydc = GetDC (0); /* why the entire screen???? */
     239    nfont = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     240    ofont = (HFONT) SelectObject (mydc, nfont);
     241    GetTextExtentPointA (mydc, "A", 1, size);
     242    SelectObject (mydc, ofont);
     243    ReleaseDC (0, mydc);
     244    TRACE("selected font hwnd=%08x, height=%ld\n", nfont, size->cy);
     245}
     246
     247
     248static void
     249COMBOEX_CopyItem (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
     250{
     251    if (cit->mask & CBEIF_TEXT) {
     252        cit->pszText        = item->pszText;
     253        cit->cchTextMax     = item->cchTextMax;
     254    }
     255    if (cit->mask & CBEIF_IMAGE)
     256        cit->iImage         = item->iImage;
     257    if (cit->mask & CBEIF_SELECTEDIMAGE)
     258        cit->iSelectedImage = item->iSelectedImage;
     259    if (cit->mask & CBEIF_OVERLAY)
     260        cit->iOverlay       = item->iOverlay;
     261    if (cit->mask & CBEIF_INDENT)
     262        cit->iIndent        = item->iIndent;
     263    if (cit->mask & CBEIF_LPARAM)
     264        cit->lParam         = item->lParam;
     265
     266}
     267
     268
     269static void
     270COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
     271{
     272    SIZE mysize;
     273    IMAGEINFO iinfo;
     274    INT x, y, w, h, xoff = 0;
     275    RECT rect;
     276
     277    if (!infoPtr->hwndEdit) return;
     278    iinfo.rcImage.left = iinfo.rcImage.right = 0;
     279    if (infoPtr->himl) {
     280        ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     281        xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
     282    }
     283    GetClientRect (infoPtr->hwndCombo, &rect);
     284    InflateRect (&rect, -2, -2);
     285    InvalidateRect (infoPtr->hwndCombo, &rect, TRUE);
     286
     287    /* reposition the Edit control based on whether icon exists */
     288    COMBOEX_GetComboFontSize (infoPtr, &mysize);
     289    TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy);
     290    x = xoff + CBE_STARTOFFSET + 1;
     291    y = CBE_EXTRA + 1;
     292    w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
     293    h = mysize.cy + 1;
     294
     295    TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n",
     296          rect.left, rect.top, rect.right, rect.bottom,
     297          x, y, x + w, y + h);
     298    SetWindowPos(infoPtr->hwndEdit, HWND_TOP,
     299                 x, y,
     300                 w, h,
     301                 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
    118302}
    119303
     
    122306COMBOEX_ReSize (HWND hwnd, COMBOEX_INFO *infoPtr)
    123307{
    124     HFONT nfont, ofont;
    125     HDC mydc;
    126308    SIZE mysize;
    127309    UINT cy;
    128310    IMAGEINFO iinfo;
    129311
    130     mydc = GetDC (0); /* why the entire screen???? */
    131     nfont = SendMessageA (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    132     ofont = (HFONT) SelectObject (mydc, nfont);
    133     GetTextExtentPointA (mydc, "A", 1, &mysize);
    134     SelectObject (mydc, ofont);
    135     ReleaseDC (0, mydc);
     312    COMBOEX_GetComboFontSize (infoPtr, &mysize);
    136313    cy = mysize.cy + CBE_EXTRA;
    137314    if (infoPtr->himl) {
    138     ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
    139     cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
    140     }
    141     TRACE("selected font hwnd=%08x, height=%d\n", nfont, cy);
    142     SendMessageA (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
     315        ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     316        cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
     317        TRACE("upgraded height due to image:  height=%d\n", cy);
     318    }
     319    SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
    143320    if (infoPtr->hwndCombo)
    144         SendMessageA (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
    145               (WPARAM) 0, (LPARAM) cy);
     321        SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
     322                      (WPARAM) 0, (LPARAM) cy);
     323}
     324
     325
     326static void
     327COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
     328{
     329    if (!infoPtr->hwndEdit) return;
     330    /* native issues the following messages to the {Edit} control */
     331    /*      WM_SETTEXT (0,addr)     */
     332    /*      EM_SETSEL32 (0,0)       */
     333    /*      EM_SETSEL32 (0,-1)      */
     334    if (item->mask & CBEIF_TEXT) {
     335        SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
     336        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
     337        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     338    }
     339}
     340
     341 
     342static CBE_ITEMDATA *
     343COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
     344{
     345    CBE_ITEMDATA *item;
     346    INT i;
     347
     348    if ((index > infoPtr->nb_items) || (index < -1))
     349        return 0;
     350    if (index == -1)
     351        return infoPtr->edit;
     352    item = infoPtr->items;
     353    i = infoPtr->nb_items - 1;
     354
     355    /* find the item in the list */
     356    while (item && (i > index)) {
     357        item = (CBE_ITEMDATA *)item->next;
     358        i--;
     359    }
     360    if (!item || (i != index)) {
     361        FIXME("COMBOBOXEX item structures broken. Please report!\n");
     362        return 0;
     363    }
     364    return item;
     365}
     366
     367
     368static void
     369COMBOEX_WarnCallBack (CBE_ITEMDATA *item)
     370{
     371    if (item->pszText == LPSTR_TEXTCALLBACKW)
     372        FIXME("Callback not implemented yet for pszText\n");
     373    if (item->iImage == I_IMAGECALLBACK)
     374        FIXME("Callback not implemented yet for iImage\n");
     375    if (item->iSelectedImage == I_IMAGECALLBACK)
     376        FIXME("Callback not implemented yet for iSelectedImage\n");
     377    if (item->iOverlay == I_IMAGECALLBACK)
     378        FIXME("Callback not implemented yet for iOverlay\n");
     379    if (item->iIndent == I_INDENTCALLBACK)
     380        FIXME("Callback not implemented yet for iIndent\n");
    146381}
    147382
     
    150385
    151386
    152 /* << COMBOEX_DeleteItem >> */
     387static LRESULT
     388COMBOEX_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
     389{
     390    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     391    INT index = (INT) wParam;
     392    CBE_ITEMDATA *item;
     393
     394    TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     395
     396    /* if item number requested does not exist then return failure */
     397    if ((index > infoPtr->nb_items) || (index < 0)) {
     398        ERR("attempt to delete item that does not exist\n");
     399        return CB_ERR;
     400    }
     401
     402    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
     403        ERR("attempt to delete item that was not found!\n");
     404        return CB_ERR;
     405    }
     406
     407    /* doing this will result in WM_DELETEITEM being issued */
     408    SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0);
     409
     410    return infoPtr->nb_items;
     411}
    153412
    154413
     
    170429
    171430    if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    172     return 0;
    173 
    174     TRACE("-- 0x%x\n", GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT));
    175 
    176     return (LRESULT)GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT);
     431        return 0;
     432
     433    TRACE("-- 0x%x\n", infoPtr->hwndEdit);
     434
     435    return (LRESULT)infoPtr->hwndEdit;
    177436}
    178437
     
    183442    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    184443
     444    TRACE("-- 0x%08lx\n", infoPtr->dwExtStyle);
     445
    185446    return (LRESULT)infoPtr->dwExtStyle;
    186447}
     
    192453    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    193454
    194     TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     455    TRACE("-- 0x%p\n", infoPtr->himl);
    195456
    196457    return (LRESULT)infoPtr->himl;
     
    198459
    199460
    200 /* << COMBOEX_GetItemA >> */
    201 
    202 /* << COMBOEX_GetItemW >> */
    203 
    204 /* << COMBOEX_GetUniCodeFormat >> */
    205 
    206 /* << COMBOEX_HasEditChanged >> */
    207 
    208 
    209461static LRESULT
    210 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
     462COMBOEX_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    211463{
    212464    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    213     COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
     465    COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
    214466    INT index;
    215467    CBE_ITEMDATA *item;
    216468
     469    TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     470
     471    /* get real index of item to insert */
     472    index = cit->iItem;
     473
     474    /* if item number requested does not exist then return failure */
     475    if ((index > infoPtr->nb_items) || (index < -1)) {
     476        ERR("attempt to get item that does not exist\n");
     477        return 0;
     478    }
     479
     480    /* if the item is the edit control and there is no edit control, skip */
     481    if ((index == -1) &&
     482        ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
     483            return 0;
     484
     485    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
     486        ERR("attempt to get item that was not found!\n");
     487        return 0;
     488    }
     489
     490    COMBOEX_CopyItem (infoPtr, item, cit);
     491
     492    return TRUE;
     493}
     494
     495
     496inline static LRESULT
     497COMBOEX_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
     498{
     499    COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
     500    COMBOBOXEXITEMW tmpcit;
     501    INT len;
     502
     503    TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     504
     505    tmpcit.mask = cit->mask;
     506    tmpcit.iItem = cit->iItem;
     507    COMBOEX_GetItemW (hwnd, wParam, (LPARAM) &tmpcit);
     508
     509    len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL);
     510    if (len > 0)
     511        WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
     512                             cit->pszText, cit->cchTextMax, NULL, NULL);
     513
     514    cit->iImage = tmpcit.iImage;
     515    cit->iSelectedImage = tmpcit.iSelectedImage;
     516    cit->iOverlay = tmpcit.iOverlay;
     517    cit->iIndent = tmpcit.iIndent;
     518    cit->lParam = tmpcit.lParam;
     519
     520    return TRUE;
     521}
     522
     523
     524inline static LRESULT
     525COMBOEX_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
     526{
     527    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     528
     529    TRACE("%s hwnd=0x%x stub!\n",
     530           infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
     531
     532    return infoPtr->bUnicode;
     533}
     534
     535
     536inline static LRESULT
     537COMBOEX_HasEditChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
     538{
     539    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     540
     541    if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
     542        return FALSE;
     543    if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) ==
     544        (WCBE_ACTEDIT | WCBE_EDITCHG))
     545        return TRUE;
     546    return FALSE;
     547}
     548
     549
     550static LRESULT
     551COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
     552{
     553    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     554    COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
     555    INT index;
     556    CBE_ITEMDATA *item;
     557    NMCOMBOBOXEXW nmcit;
     558
     559    TRACE("\n");
     560
     561    COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
    217562
    218563    /* get real index of item to insert */
     
    230575        /* fast path for iItem = -1 */
    231576        item->next = infoPtr->items;
    232     infoPtr->items = item;
     577        infoPtr->items = item;
    233578    }
    234579    else {
    235         int i = infoPtr->nb_items-1;
    236     CBE_ITEMDATA *moving = infoPtr->items;
    237 
    238     while (i > index && moving) {
    239         moving = (CBE_ITEMDATA *)moving->next;
    240     }
    241     if (!moving) {
    242         FIXME("COMBOBOXEX item structures broken. Please report!\n");
    243         COMCTL32_Free(item);
    244         return -1;
    245     }
    246     item->next = moving->next;
    247     moving->next = item;
     580        INT i = infoPtr->nb_items-1;
     581        CBE_ITEMDATA *moving = infoPtr->items;
     582
     583        while ((i > index) && moving) {
     584            moving = (CBE_ITEMDATA *)moving->next;
     585            i--;
     586        }
     587        if (!moving) {
     588            FIXME("COMBOBOXEX item structures broken. Please report!\n");
     589            COMCTL32_Free(item);
     590            return -1;
     591        }
     592        item->next = moving->next;
     593        moving->next = item;
    248594    }
    249595
     
    251597    item->mask           = cit->mask;
    252598    if (item->mask & CBEIF_TEXT) {
    253         LPSTR str;
    254     INT len;
     599        LPWSTR str;
     600        INT len;
    255601
    256602        str = cit->pszText;
    257         if (!str) str="";
    258     len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    259     if (len > 0) {
    260         item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    261         MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, len);
    262     }
     603        if (!str) str = (LPWSTR) L"";
     604        len = strlenW (str);
     605        if (len > 0) {
     606            item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     607            strcpyW (item->pszText, str);
     608        }
    263609        item->cchTextMax   = cit->cchTextMax;
    264610    }
     
    275621    infoPtr->nb_items++;
    276622
     623    COMBOEX_WarnCallBack (item);
     624
    277625    COMBOEX_DumpItem (item);
    278626
    279     SendMessageA (infoPtr->hwndCombo, CB_INSERTSTRING,
    280           (WPARAM)cit->iItem, (LPARAM)item);
     627    SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
     628                  (WPARAM)cit->iItem, (LPARAM)item);
     629
     630    COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
     631    COMBOEX_Notify (infoPtr, CBEN_INSERTITEM, (NMHDR *)&nmcit, TRUE);
    281632
    282633    return index;
     
    286637
    287638static LRESULT
    288 COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
     639COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
     640{
     641    COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
     642    COMBOBOXEXITEMW     citW;
     643    LRESULT             ret;
     644
     645    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
     646    if (cit->mask & CBEIF_TEXT) {
     647        LPSTR str;
     648        INT len;
     649
     650        str = cit->pszText;
     651        if (!str) str="";
     652        len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     653        if (len > 0) {
     654            citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     655            MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
     656        }
     657    }
     658    ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);;
     659
     660    if (cit->mask & CBEIF_TEXT)
     661        COMCTL32_Free(citW.pszText);
     662    return ret;
     663}
     664
     665
     666static LRESULT
     667COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
     668{
     669    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     670    DWORD dwTemp;
     671
     672    TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     673
     674    dwTemp = infoPtr->dwExtStyle;
     675
     676    if (lParam & (CBES_EX_NOEDITIMAGEINDENT |
     677                  CBES_EX_PATHWORDBREAKPROC |
     678                  CBES_EX_NOSIZELIMIT |
     679                  CBES_EX_CASESENSITIVE))
     680        FIXME("Extended style not implemented %08lx\n", lParam);
     681
     682    if ((DWORD)wParam) {
     683        infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
     684    }
     685    else
     686        infoPtr->dwExtStyle = (DWORD)lParam;
     687
     688    /*
     689     * native does this for CBES_EX_NOEDITIMAGE state change
     690     */
     691    if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^
     692        (dwTemp & CBES_EX_NOEDITIMAGE)) {
     693        /* if state of EX_NOEDITIMAGE changes, invalidate all */
     694        TRACE("EX_NOEDITIMAGE state changed to %ld\n",
     695            infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
     696        InvalidateRect (hwnd, NULL, TRUE);
     697        COMBOEX_AdjustEditPos (infoPtr);
     698        if (infoPtr->hwndEdit)
     699            InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
     700    }
     701
     702    return (LRESULT)dwTemp;
     703}
     704
     705
     706inline static LRESULT
     707COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
     708{
     709    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     710    HIMAGELIST himlTemp;
     711
     712    TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
     713
     714    himlTemp = infoPtr->himl;
     715    infoPtr->himl = (HIMAGELIST)lParam;
     716
     717    COMBOEX_ReSize (hwnd, infoPtr);
     718    InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
     719
     720    /* reposition the Edit control based on whether icon exists */
     721    COMBOEX_AdjustEditPos (infoPtr);
     722    return (LRESULT)himlTemp;
     723}
     724
     725static LRESULT
     726COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    289727{
    290728    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     
    293731    CBE_ITEMDATA *item;
    294732
     733    COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
     734
    295735    /* get real index of item to insert */
    296736    index = cit->iItem;
    297     if (index == -1) index = infoPtr->nb_items;
    298     if (index > infoPtr->nb_items) index = infoPtr->nb_items;
    299 
    300     /* get space and chain it in */
    301     item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
    302     item->next = NULL;
    303     item->pszText = NULL;
    304 
    305     /* locate position to insert new item in */
    306     if (index == infoPtr->nb_items) {
    307         /* fast path for iItem = -1 */
    308         item->next = infoPtr->items;
    309     infoPtr->items = item;
    310     }
    311     else {
    312         INT i = infoPtr->nb_items-1;
    313     CBE_ITEMDATA *moving = infoPtr->items;
    314 
    315     while ((i > index) && moving) {
    316         moving = (CBE_ITEMDATA *)moving->next;
    317         i--;
    318     }
    319     if (!moving) {
    320         FIXME("COMBOBOXEX item structures broken. Please report!\n");
    321         COMCTL32_Free(item);
    322         return -1;
    323     }
    324     item->next = moving->next;
    325     moving->next = item;
    326     }
    327 
    328     /* fill in our hidden item structure */
    329     item->mask           = cit->mask;
    330     if (item->mask & CBEIF_TEXT) {
    331         LPWSTR str;
    332     INT len;
    333 
    334         str = cit->pszText;
    335         if (!str) str = (LPWSTR) L"";
    336     len = strlenW (str);
    337     if (len > 0) {
    338         item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    339         strcpyW (item->pszText, str);
    340     }
    341         item->cchTextMax   = cit->cchTextMax;
    342     }
    343     if (item->mask & CBEIF_IMAGE)
    344       item->iImage         = cit->iImage;
    345     if (item->mask & CBEIF_SELECTEDIMAGE)
    346       item->iSelectedImage = cit->iSelectedImage;
    347     if (item->mask & CBEIF_OVERLAY)
    348       item->iOverlay       = cit->iOverlay;
    349     if (item->mask & CBEIF_INDENT)
    350       item->iIndent        = cit->iIndent;
    351     if (item->mask & CBEIF_LPARAM)
    352       item->lParam         = cit->lParam;
    353     infoPtr->nb_items++;
    354 
    355     COMBOEX_DumpItem (item);
    356 
    357     SendMessageA (infoPtr->hwndCombo, CB_INSERTSTRING,
    358           (WPARAM)cit->iItem, (LPARAM)item);
    359 
    360     return index;
    361 
    362 }
    363 
    364 
    365 static LRESULT
    366 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
    367 {
    368     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    369     DWORD dwTemp;
    370 
    371     TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
    372 
    373     dwTemp = infoPtr->dwExtStyle;
    374 
    375     if ((DWORD)wParam) {
    376     infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
    377     }
    378     else
    379     infoPtr->dwExtStyle = (DWORD)lParam;
    380 
    381     /* FIXME: repaint?? */
    382 
    383     return (LRESULT)dwTemp;
    384 }
    385 
    386 
    387 inline static LRESULT
    388 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
    389 {
    390     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    391     HIMAGELIST himlTemp;
    392 
    393     TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
    394 
    395     himlTemp = infoPtr->himl;
    396     infoPtr->himl = (HIMAGELIST)lParam;
    397 
    398     COMBOEX_ReSize (hwnd, infoPtr);
    399     InvalidateRect (hwnd, NULL, TRUE);
    400 
    401     return (LRESULT)himlTemp;
    402 }
    403 
    404 static LRESULT
    405 COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    406 {
    407     COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    408     COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
    409     INT index;
    410     INT i;
    411     CBE_ITEMDATA *item;
    412 
    413     /* get real index of item to insert */
    414     index = cit->iItem;
    415     if (index == -1) {
    416         FIXME("NYI setting data for item in edit control\n");
    417     return 0;
    418     }
    419737
    420738    /* if item number requested does not exist then return failure */
    421     if ((index > infoPtr->nb_items) || (index < 0)) return 0;
    422 
    423     /* find the item in the list */
    424     item = infoPtr->items;
    425     i = infoPtr->nb_items - 1;
    426     while (item && (i > index)) {
    427         item = (CBE_ITEMDATA *)item->next;
    428     i--;
    429     }
    430     if (!item || (i != index)) {
    431     FIXME("COMBOBOXEX item structures broken. Please report!\n");
    432     return 0;
    433     }
    434 
    435     /* add/change stuff to the internal item structure */
     739    if ((index > infoPtr->nb_items) || (index < -1)) {
     740        ERR("attempt to set item that does not exist yet!\n");
     741        return 0;
     742    }
     743
     744    /* if the item is the edit control and there is no edit control, skip */
     745    if ((index == -1) &&
     746        ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
     747            return 0;
     748
     749    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
     750        ERR("attempt to set item that was not found!\n");
     751        return 0;
     752    }
     753
     754    /* add/change stuff to the internal item structure */
    436755    item->mask |= cit->mask;
    437756    if (cit->mask & CBEIF_TEXT) {
    438757        LPWSTR str;
    439     INT len;
    440     WCHAR emptystr[1] = {0};
     758        INT len;
     759        WCHAR emptystr[1] = {0};
    441760
    442761        str = cit->pszText;
    443762        if (!str) str=emptystr;
    444     len = strlenW(str);
    445     if (len > 0) {
    446         item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    447         strcpyW(item->pszText,str);
    448     }
     763        len = strlenW(str);
     764        if (len > 0) {
     765            item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     766            strcpyW(item->pszText,str);
     767        }
    449768        item->cchTextMax   = cit->cchTextMax;
    450769    }
     
    460779      cit->lParam         = cit->lParam;
    461780
     781    COMBOEX_WarnCallBack (item);
     782
    462783    COMBOEX_DumpItem (item);
    463784
     785    /* if original request was to update edit control, do some fast foot work */
     786    if (cit->iItem == -1) {
     787        COMBOEX_SetEditText (infoPtr, item);
     788        RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
     789    }
    464790    return TRUE;
    465791}
     
    468794COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    469795{
    470     COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
    471     COMBOBOXEXITEMW citW;
    472     LRESULT     ret;
     796    COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
     797    COMBOBOXEXITEMW     citW;
     798    LRESULT             ret;
    473799
    474800    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    475801    if (cit->mask & CBEIF_TEXT) {
    476802        LPSTR str;
    477     INT len;
     803        INT len;
    478804
    479805        str = cit->pszText;
    480806        if (!str) str="";
    481     len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    482     if (len > 0) {
    483         citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    484         MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
    485     }
     807        len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     808        if (len > 0) {
     809            citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     810            MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
     811        }
    486812    }
    487813    ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
    488814
    489815    if (cit->mask & CBEIF_TEXT)
    490     COMCTL32_Free(citW.pszText);
     816        COMCTL32_Free(citW.pszText);
    491817    return ret;
    492818}
    493819
    494820
    495 /* << COMBOEX_SetUniCodeFormat >> */
     821inline static LRESULT
     822COMBOEX_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
     823{
     824    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     825    BOOL bTemp;
     826
     827    TRACE("%s hwnd=0x%04x stub!\n",
     828           ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
     829
     830    bTemp = infoPtr->bUnicode;
     831    infoPtr->bUnicode = (BOOL)wParam;
     832
     833    return bTemp;
     834}
     835
    496836
    497837
    498838/* ***  CB_xxx message support  *** */
     839
     840
     841static LRESULT
     842COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
     843{
     844    INT i, count;
     845    CBE_ITEMDATA *item;
     846    LPWSTR desired = NULL;
     847    INT start = (INT) wParam;
     848
     849    i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
     850    if (i > 0) {
     851        desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
     852        MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
     853    }
     854
     855    count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0 , 0);
     856
     857    /* now search from after starting loc and wrapping back to start */
     858    for(i=start+1; i<count; i++) {
     859        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     860                          CB_GETITEMDATA, (WPARAM)i, 0);
     861        TRACE("desired=%s, item=%s\n",
     862              debugstr_w(desired), debugstr_w(item->pszText));
     863        if (lstrcmpiW(item->pszText, desired) == 0) {
     864            COMCTL32_Free (desired);
     865            return i;
     866        }
     867    }
     868    for(i=0; i<=start; i++) {
     869        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     870                          CB_GETITEMDATA, (WPARAM)i, 0);
     871        TRACE("desired=%s, item=%s\n",
     872              debugstr_w(desired), debugstr_w(item->pszText));
     873        if (lstrcmpiW(item->pszText, desired) == 0) {
     874            COMCTL32_Free (desired);
     875            return i;
     876        }
     877    }
     878    COMCTL32_Free(desired);
     879    return CB_ERR;
     880}
     881
     882
     883static LRESULT
     884COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam)
     885{
     886    INT index = wParam;
     887    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     888    CBE_ITEMDATA *item;
     889    LRESULT lret;
     890
     891    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
     892        /* FIXME: need to clear selection */
     893        return CB_ERR;
     894    }
     895
     896    TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
     897          debugstr_w(item->pszText) : "<null>");
     898
     899    lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam);
     900    COMBOEX_SetEditText (infoPtr, item);
     901    return lret;
     902}
    499903
    500904
     
    509913    /* First, lets forward the message to the normal combo control
    510914       just like Windows.     */
    511     if (infoPtr->hwndCombo)
    512        SendMessageA (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
    513 
    514     /* *** new *** */
     915    if (infoPtr->hwndCombo)   
     916       SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
     917
    515918    GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
    516919    GetWindowRect (hwnd, &cbx_wrect);
    517920    GetClientRect (hwnd, &cbx_crect);
    518     /* the height of comboex as height of the combo + comboex border */
     921    /* the height of comboex as height of the combo + comboex border */ 
    519922    height = cb_wrect.bottom-cb_wrect.top
    520923             + cbx_wrect.bottom-cbx_wrect.top
    521924             - (cbx_crect.bottom-cbx_crect.top);
    522925    TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
    523       cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
    524       cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
     926          cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     927          cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
    525928    TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
    526       cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
    527       cbx_wrect.right-cbx_wrect.left, height);
     929          cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
     930          cbx_wrect.right-cbx_wrect.left, height);
    528931    SetWindowPos (hwnd, HWND_TOP, 0, 0,
    529           cbx_wrect.right-cbx_wrect.left,
    530           height,
    531           SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    532     /* *** end new *** */
     932                  cbx_wrect.right-cbx_wrect.left,
     933                  height,
     934                  SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    533935
    534936    return ret;
     
    546948    DWORD dwComboStyle;
    547949    LOGFONTA mylogfont;
     950    CBE_ITEMDATA *item;
     951    RECT wnrc1, clrc1, cmbwrc;
     952    LONG test;
    548953
    549954    /* allocate memory for info structure */
     955#ifdef __WIN32OS2__
     956    infoPtr = (COMBOEX_INFO*)initControl(hwnd,sizeof(COMBOEX_INFO));
     957#else
    550958    infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
     959#endif
    551960    if (infoPtr == NULL) {
    552     ERR("could not allocate info memory!\n");
    553     return 0;
    554     }
     961        ERR("could not allocate info memory!\n");
     962        return 0;
     963    }
     964
     965    /* initialize info structure */
     966
    555967    infoPtr->items    = NULL;
    556968    infoPtr->nb_items = 0;
     969    infoPtr->hwndSelf = hwnd;
    557970
    558971    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
    559 
    560 
    561     /* initialize info structure */
    562 
    563972
    564973    /* create combo box */
    565974    dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
    566             (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
     975                        (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
     976
     977    TRACE("combo style=%08lx, additional style=%08lx\n", dwComboStyle,
     978          WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
     979          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
     980          WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
     981
     982    /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
     983    /* specified. It then creates it's own version of the EDIT control  */
     984    /* and makes the ComboBox the parent. This is because a normal      */
     985    /* DROPDOWNLIST does not have a EDIT control, but we need one.      */
     986    /* We also need to place the edit control at the proper location    */
     987    /* (allow space for the icons).                                     */
    567988
    568989    infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
    569              /* following line added to match native */
    570                          WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | CBS_NOINTEGRALHEIGHT |
    571              /* was base and is necessary */
    572              WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
    573             cs->y, cs->x, cs->cx, cs->cy, hwnd, (HMENU)0,
    574             GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
    575 
    576     /* *** new *** */
    577     SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), &mylogfont, 0);
    578     infoPtr->font = CreateFontIndirectA (&mylogfont);
    579     SendMessageA (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
     990                         /* following line added to match native */
     991                         WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
     992                         CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
     993                         /* was base and is necessary */
     994                         WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
     995                         cs->y, cs->x, cs->cx, cs->cy, hwnd,
     996                         (HMENU) GetWindowLongA (hwnd, GWL_ID),
     997                         GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     998
     999    /*
     1000     * native does the following at this point according to trace:
     1001     *  GetWindowThreadProcessId(hwndCombo,0)
     1002     *  GetCurrentThreadId()
     1003     *  GetWindowThreadProcessId(hwndCombo, &???)
     1004     *  GetCurrentProcessId()
     1005     */
     1006
     1007    /*
     1008     * Setup a property to hold the pointer to the COMBOBOXEX
     1009     * data structure.
     1010     */
     1011    test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo);
     1012    if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
     1013        SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
     1014    }
     1015    infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo,
     1016                                GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
     1017    infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     1018
     1019
     1020    /*
     1021     * Now create our own EDIT control so we can position it.
     1022     * It is created only for CBS_DROPDOWN style
     1023     */
     1024    if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
     1025        infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
     1026                    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
     1027                    0, 0, 0, 0,  /* will set later */
     1028                    infoPtr->hwndCombo,
     1029                    (HMENU) GetWindowLongA (hwnd, GWL_ID),
     1030                    GetWindowLongA (hwnd, GWL_HINSTANCE),
     1031                    NULL);
     1032
     1033        /* native does the following at this point according to trace:
     1034         *  GetWindowThreadProcessId(hwndEdit,0)
     1035         *  GetCurrentThreadId()
     1036         *  GetWindowThreadProcessId(hwndEdit, &???)
     1037         *  GetCurrentProcessId()
     1038         */
     1039
     1040        /*
     1041         * Setup a property to hold the pointer to the COMBOBOXEX
     1042         * data structure.
     1043         */
     1044        test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
     1045        if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
     1046            SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
     1047        }
     1048        infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
     1049                                 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
     1050        infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     1051    }
     1052    else {
     1053        infoPtr->hwndEdit = 0;
     1054        infoPtr->font = 0;
     1055    }
     1056
     1057    /*
     1058     * Locate the default font if necessary and then set it in
     1059     * all associated controls
     1060     */
     1061    if (!infoPtr->font) {
     1062        SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
     1063                               &mylogfont, 0);
     1064        infoPtr->font = CreateFontIndirectA (&mylogfont);
     1065    }
     1066    SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
     1067    if (infoPtr->hwndEdit) {
     1068        SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
     1069        SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
     1070    }
     1071
    5801072    COMBOEX_ReSize (hwnd, infoPtr);
    581     /* *** end new *** */
     1073
     1074    /* Above is fairly certain, below is much less certain. */
     1075
     1076    GetWindowRect(hwnd, &wnrc1);
     1077    GetClientRect(hwnd, &clrc1);
     1078    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
     1079    TRACE("Ex wnd=(%d,%d)-(%d,%d) Ex clt=(%d,%d)-(%d,%d) Cb wnd=(%d,%d)-(%d,%d)\n",
     1080          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     1081          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     1082          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
     1083    SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
     1084                 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
     1085                 SWP_NOACTIVATE | SWP_NOREDRAW);
     1086
     1087    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
     1088    TRACE("Ex wnd=(%d,%d)-(%d,%d)\n",
     1089          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
     1090    SetWindowPos(hwnd, HWND_TOP,
     1091                 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
     1092                 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
     1093
     1094    COMBOEX_AdjustEditPos (infoPtr);
     1095
     1096    /*
     1097     * Create an item structure to represent the data in the
     1098     * EDIT control.
     1099     */
     1100    item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
     1101    item->next = NULL;
     1102    item->pszText = NULL;
     1103    item->mask = 0;
     1104    infoPtr->edit = item;
    5821105
    5831106    return 0;
     1107}
     1108
     1109
     1110inline static LRESULT
     1111COMBOEX_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1112{
     1113    LRESULT lret;
     1114    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     1115    INT command = HIWORD(wParam);
     1116    CBE_ITEMDATA *item = 0;
     1117    WCHAR wintext[520];
     1118    INT cursel, n, oldItem;
     1119    NMCBEENDEDITA cbeend;
     1120
     1121    TRACE("for command %d\n", command);
     1122
     1123    switch (command)
     1124    {
     1125    case CBN_DROPDOWN:
     1126        SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1127                             (LPARAM)hwnd);
     1128        /*
     1129         * from native trace of first dropdown after typing in URL in IE4
     1130         *  CB_GETCURSEL(Combo)
     1131         *  GetWindowText(Edit)
     1132         *  CB_GETCURSEL(Combo)
     1133         *  CB_GETCOUNT(Combo)
     1134         *  CB_GETITEMDATA(Combo, n)
     1135         *  WM_NOTIFY(parent, CBEN_ENDEDITA|W)
     1136         *  CB_GETCURSEL(Combo)
     1137         *  CB_SETCURSEL(COMBOEX, n)
     1138         *  SetFocus(Combo)
     1139         * the rest is supposition 
     1140         */
     1141        cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1142        if (cursel == -1) {
     1143            /* find match from edit against those in Combobox */
     1144            GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
     1145            n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
     1146            for (cursel = 0; cursel < n; cursel++){
     1147                item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1148                                                     CB_GETITEMDATA,
     1149                                                     cursel, 0);
     1150                if ((INT)item == CB_ERR) break;
     1151                if (lstrcmpiW(item->pszText, wintext) == 0) break;
     1152            }
     1153            if ((cursel == n) || ((INT)item == CB_ERR)) {
     1154                TRACE("failed to find match??? item=%p cursel=%d\n",
     1155                      item, cursel);
     1156                if (infoPtr->hwndEdit)
     1157                    SetFocus(infoPtr->hwndEdit);
     1158                return 0;
     1159            }
     1160        }
     1161        else {
     1162            item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1163                                                 CB_GETITEMDATA,
     1164                                                 cursel, 0);
     1165            if ((INT)item == CB_ERR) {
     1166                TRACE("failed to find match??? item=%p cursel=%d\n",
     1167                      item, cursel);
     1168                if (infoPtr->hwndEdit)
     1169                    SetFocus(infoPtr->hwndEdit);
     1170                return 0;
     1171            }
     1172        }
     1173        if (infoPtr->flags & WCBE_ACTEDIT) {
     1174            WideCharToMultiByte (CP_ACP, 0, item->pszText, -1,
     1175                                 cbeend.szText, sizeof(cbeend.szText),
     1176                                 NULL, NULL);
     1177            cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     1178            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1179                                                 CB_GETCURSEL, 0, 0);
     1180            cbeend.iWhy = CBENF_DROPDOWN;
     1181
     1182            infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1183            if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
     1184                                (NMHDR *)&cbeend, FALSE)) {
     1185                /* abort the change */
     1186                TRACE("Notify requested abort of change\n");
     1187                return 0;
     1188            }
     1189        }
     1190        SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
     1191        SetFocus(infoPtr->hwndCombo);
     1192        return 0;
     1193
     1194    case CBN_SELCHANGE:
     1195        /*
     1196         * CB_GETCURSEL(Combo)
     1197         * CB_GETITEMDATA(Combo)   < simulated by COMBOEX_FindItem
     1198         * lstrlenA
     1199         * WM_SETTEXT(Edit)
     1200         * WM_GETTEXTLENGTH(Edit)
     1201         * WM_GETTEXT(Edit)
     1202         * EM_SETSEL(Edit, 0,0)
     1203         * WM_GETTEXTLENGTH(Edit)
     1204         * WM_GETTEXT(Edit)
     1205         * EM_SETSEL(Edit, 0,len)
     1206         * return WM_COMMAND to parent
     1207         */
     1208        oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1209        if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     1210            ERR("item %d not found. Problem!\n", oldItem);
     1211            break;
     1212        } 
     1213        COMBOEX_SetEditText (infoPtr, item);
     1214        return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1215                             (LPARAM)hwnd);
     1216
     1217    case CBN_SELENDOK:
     1218        /*
     1219         * We have to change the handle since we are the control
     1220         * issuing the message. IE4 depends on this.
     1221         */
     1222        return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1223                             (LPARAM)hwnd);
     1224
     1225    case CBN_KILLFOCUS:
     1226        /*
     1227         * from native trace:
     1228         *
     1229         *  pass to parent
     1230         *  WM_GETTEXT(Edit, 104)
     1231         *  CB_GETCURSEL(Combo) rets -1
     1232         *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
     1233         *  CB_GETCURSEL(Combo)
     1234         *  InvalidateRect(Combo, 0, 0)
     1235         *  return 0
     1236         */
     1237        SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1238                             (LPARAM)hwnd);
     1239        if (infoPtr->flags & WCBE_ACTEDIT) {
     1240            GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
     1241            cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     1242            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1243                                                 CB_GETCURSEL, 0, 0);
     1244            cbeend.iWhy = CBENF_KILLFOCUS;
     1245
     1246            infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1247            if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
     1248                                (NMHDR *)&cbeend, FALSE)) {
     1249                /* abort the change */
     1250                TRACE("Notify requested abort of change\n");
     1251                return 0;
     1252            }
     1253        }
     1254        /* possible CB_GETCURSEL */
     1255        InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1256        return 0;
     1257
     1258    case CBN_CLOSEUP:
     1259    default:
     1260        /*
     1261         * We have to change the handle since we are the control
     1262         * issuing the message. IE4 depends on this.
     1263         * We also need to set the focus back to the Edit control
     1264         * after passing the command to the parent of the ComboEx.
     1265         */
     1266        lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1267                             (LPARAM)hwnd);
     1268        if (infoPtr->hwndEdit)
     1269            SetFocus(infoPtr->hwndEdit);
     1270        return lret;
     1271    }
     1272    return 0;
     1273}
     1274
     1275
     1276inline static LRESULT
     1277COMBOEX_WM_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1278{
     1279    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
     1280    DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)lParam;
     1281    CBE_ITEMDATA *item, *olditem;
     1282    INT i;
     1283    NMCOMBOBOXEXW nmcit;
     1284
     1285    TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
     1286          dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
     1287
     1288    if ((dis->itemID >= infoPtr->nb_items) || (dis->itemID < 0)) return FALSE;
     1289
     1290    olditem = infoPtr->items;
     1291    i = infoPtr->nb_items - 1;
     1292
     1293    if (i == dis->itemID) {
     1294        infoPtr->items = infoPtr->items->next;
     1295    }
     1296    else {
     1297        item = olditem;
     1298        i--;
     1299
     1300        /* find the prior item in the list */
     1301        while (item->next && (i > dis->itemID)) {
     1302            item = (CBE_ITEMDATA *)item->next;
     1303            i--;
     1304        }
     1305        if (!item->next || (i != dis->itemID)) {
     1306            FIXME("COMBOBOXEX item structures broken. Please report!\n");
     1307            return FALSE;
     1308        }
     1309        olditem = item->next;
     1310        item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
     1311    }
     1312    infoPtr->nb_items--;
     1313
     1314    COMBOEX_CopyItem (infoPtr, olditem, &nmcit.ceItem);
     1315    COMBOEX_Notify (infoPtr, CBEN_DELETEITEM, (NMHDR *)&nmcit, TRUE);
     1316
     1317    COMCTL32_Free(olditem);
     1318
     1319    return TRUE;
     1320
    5841321}
    5851322
     
    5901327    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    5911328    DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
    592     CBE_ITEMDATA *item;
     1329    CBE_ITEMDATA *item = 0;
    5931330    SIZE txtsize;
    594     COLORREF nbkc, ntxc;
    5951331    RECT rect;
    596     int drawimage;
    597     UINT x, xbase, y;
     1332    int drawimage, drawstate;
     1333    UINT xbase;
    5981334    UINT xioff = 0;               /* size and spacer of image if any */
    5991335    IMAGEINFO iinfo;
     
    6141350    /*      though the list box or combo box has the focus.             */
    6151351    if (dis->itemID == 0xffffffff) {
    616       if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
    617        ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
    618         TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
    619           dis->rcItem.left, dis->rcItem.top,
    620           dis->rcItem.right, dis->rcItem.bottom);
    621     DrawFocusRect(dis->hDC, &dis->rcItem);
    622     return 0;
    623       }
    624       else {
    625     TRACE("NOT drawing item  -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
    626           dis->rcItem.left, dis->rcItem.top,
    627           dis->rcItem.right, dis->rcItem.bottom,
    628           dis->itemAction, dis->itemState);
    629     return 0;
    630       }
    631     }
    632 
    633     item = (CBE_ITEMDATA *)SendMessageA (infoPtr->hwndCombo, CB_GETITEMDATA,
    634                      (WPARAM)dis->itemID, 0);
    635     if (item == (CBE_ITEMDATA *)CB_ERR)
    636     {
    637         FIXME("invalid item for id %d \n",dis->itemID);
    638         return 0;
    639     }
     1352        if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
     1353             ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
     1354
     1355            TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
     1356                  dis->rcItem.left, dis->rcItem.top,
     1357                  dis->rcItem.right, dis->rcItem.bottom);
     1358        }
     1359        else if ((dis->CtlType == ODT_COMBOBOX) &&
     1360                 (dis->itemAction == ODA_DRAWENTIRE)) {
     1361            /* draw of edit control data */
     1362
     1363            /* testing */
     1364            {
     1365                RECT exrc, cbrc, edrc;
     1366                GetWindowRect (hwnd, &exrc);
     1367                GetWindowRect (infoPtr->hwndCombo, &cbrc);
     1368                edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
     1369                if (infoPtr->hwndEdit)
     1370                    GetWindowRect (infoPtr->hwndEdit, &edrc);
     1371                TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
     1372                      exrc.left, exrc.top, exrc.right, exrc.bottom,
     1373                      cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
     1374                      edrc.left, edrc.top, edrc.right, edrc.bottom);
     1375            }
     1376        }
     1377        else {
     1378            ERR("NOT drawing item  -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
     1379                dis->rcItem.left, dis->rcItem.top,
     1380                dis->rcItem.right, dis->rcItem.bottom,
     1381                dis->itemAction, dis->itemState);
     1382            return 0;
     1383        }
     1384    }
     1385
     1386    /* If draw item is -1 (edit control) setup the item pointer */
     1387    if (dis->itemID == 0xffffffff) {
     1388        CHAR str[260];
     1389        INT wlen, alen;
     1390
     1391        if (!infoPtr->hwndEdit) {
     1392            ERR("request to draw edit item, but no edit control exists!\n");
     1393            return 0;
     1394        }
     1395
     1396        item = infoPtr->edit;
     1397        /* free previous text of edit item */
     1398        if (item->pszText) {
     1399            COMCTL32_Free(item->pszText);
     1400            item->pszText = 0;
     1401            item->mask &= ~CBEIF_TEXT;
     1402        }
     1403        alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
     1404        TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
     1405              infoPtr->hwndEdit, alen, str);
     1406        if (alen > 0) {
     1407            item->mask |= CBEIF_TEXT;
     1408            wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     1409            if (wlen > 0) {
     1410                item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
     1411                MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
     1412            }
     1413        }
     1414    }
     1415
     1416    /* if the item pointer is not set, then get the data and locate it */
     1417    if (!item) {
     1418        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1419                             CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
     1420        if (item == (CBE_ITEMDATA *)CB_ERR)
     1421            {
     1422                FIXME("invalid item for id %d \n",dis->itemID);
     1423                return 0;
     1424            }
     1425    }
     1426
     1427    /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
    6401428    if (!TRACE_ON(message)) {
    641     TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
    642           dis->CtlType, dis->CtlID);
    643     TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
    644           dis->itemID, dis->itemAction, dis->itemState);
    645     TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
    646           dis->hwndItem, dis->hDC, dis->rcItem.left,
    647           dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
    648           dis->itemData);
     1429        TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
     1430              dis->CtlType, dis->CtlID);
     1431        TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
     1432              dis->itemID, dis->itemAction, dis->itemState);
     1433        TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
     1434              dis->hwndItem, dis->hDC, dis->rcItem.left,
     1435              dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
     1436              dis->itemData);
    6491437    }
    6501438    COMBOEX_DumpItem (item);
    6511439
    6521440    xbase = CBE_STARTOFFSET;
    653     if (item->mask & CBEIF_INDENT)
     1441    if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX))
    6541442        xbase += (item->iIndent * CBE_INDENT);
    6551443    if (item->mask & CBEIF_IMAGE) {
    656     ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
    657     xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
     1444        ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
     1445        xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
    6581446    }
    6591447
     
    6611449    case ODA_FOCUS:
    6621450        if (dis->itemState & ODS_SELECTED /*1*/) {
    663         if ((item->mask & CBEIF_TEXT) && item->pszText) {
    664             len = strlenW (item->pszText);
    665         GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
    666         rect.left = xbase + xioff - 1;
    667             rect.top = dis->rcItem.top - 1 +
    668           (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
    669         rect.right = rect.left + txtsize.cx + 2;
    670         rect.bottom = rect.top + txtsize.cy + 2;
    671         TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
    672               dis->itemID, rect.left, rect.top,
    673               rect.right, rect.bottom);
    674         DrawFocusRect(dis->hDC, &rect);
    675         }
    676     }
     1451            if ((item->mask & CBEIF_TEXT) && item->pszText) {
     1452                RECT rect2;
     1453
     1454                len = strlenW (item->pszText);
     1455                GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
     1456                rect.left = xbase + xioff - 1;
     1457                rect.right = rect.left + txtsize.cx + 2;
     1458                rect.top = dis->rcItem.top;
     1459                rect.bottom = dis->rcItem.bottom;
     1460                GetClipBox (dis->hDC, &rect2);
     1461                TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
     1462                      dis->itemID, rect.left, rect.top,
     1463                      rect.right, rect.bottom);
     1464                TRACE("                      clip=(%d,%d)-(%d,%d)\n",
     1465                      rect2.left, rect2.top,
     1466                      rect2.right, rect2.bottom);
     1467
     1468                DrawFocusRect(dis->hDC, &rect);
     1469            }
     1470            else {
     1471                FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
     1472            }
     1473        }
     1474        else {
     1475            FIXME("ODA_FOCUS but not ODS_SELECTED\n");
     1476        }
    6771477        break;
    6781478    case ODA_SELECT:
    6791479    case ODA_DRAWENTIRE:
    6801480        drawimage = -1;
    681     if (item->mask & CBEIF_IMAGE) drawimage = item->iImage;
    682     if ((dis->itemState & ODS_SELECTED) &&
    683         (item->mask & CBEIF_SELECTEDIMAGE))
    684             drawimage = item->iSelectedImage;
    685     if (drawimage != -1) {
    686         ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
    687                 xbase, dis->rcItem.top,
    688                 (dis->itemState & ODS_SELECTED) ?
    689                 ILD_SELECTED : ILD_NORMAL);
    690     }
    691     if ((item->mask & CBEIF_TEXT) && item->pszText) {
    692         len = strlenW (item->pszText);
    693         GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
    694         nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    695                     COLOR_HIGHLIGHT : COLOR_WINDOW);
    696         SetBkColor (dis->hDC, nbkc);
    697         ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    698                     COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
    699         SetTextColor (dis->hDC, ntxc);
    700         x = xbase + xioff;
    701         y = dis->rcItem.top +
    702             (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
    703         rect.left = x;
    704         rect.right = x + txtsize.cx;
    705         rect.top = y;
    706         rect.bottom = y + txtsize.cy;
    707         TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
    708           dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    709         ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
    710              &rect, item->pszText, len, 0);
    711         if (dis->itemState & ODS_FOCUS) {
    712             rect.top -= 1;
    713         rect.bottom += 1;
    714         rect.left -= 1;
    715         rect.right += 2;
    716         TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
    717               dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    718         DrawFocusRect (dis->hDC, &rect);
    719         }
    720     }
    721     break;
     1481        drawstate = ILD_NORMAL;
     1482        if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
     1483            if (item->mask & CBEIF_IMAGE)
     1484                drawimage = item->iImage;
     1485            if (dis->itemState & ODS_COMBOEXLBOX) {
     1486                /* drawing listbox entry */
     1487                if (dis->itemState & ODS_SELECTED) {
     1488                    if (item->mask & CBEIF_SELECTEDIMAGE)
     1489                        drawimage = item->iSelectedImage;
     1490                    drawstate = ILD_SELECTED;
     1491                }
     1492            }
     1493            else {
     1494                /* drawing combo/edit entry */
     1495                if (infoPtr->hwndEdit) {
     1496                    /* if we have an edit control, the slave the
     1497                     * selection state to the Edit focus state
     1498                     */
     1499                    if (infoPtr->flags & WCBE_EDITFOCUSED) {
     1500                        if (item->mask & CBEIF_SELECTEDIMAGE)
     1501                            drawimage = item->iSelectedImage;
     1502                        drawstate = ILD_SELECTED;
     1503                    }
     1504                }
     1505                else {
     1506                    /* if we don't have an edit control, use
     1507                     * the requested state.
     1508                     */
     1509                    if (dis->itemState & ODS_SELECTED) {
     1510                        if (item->mask & CBEIF_SELECTEDIMAGE)
     1511                            drawimage = item->iSelectedImage;
     1512                        drawstate = ILD_SELECTED;
     1513                    }
     1514                }
     1515            }
     1516        }
     1517        if (drawimage != -1) {
     1518            TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
     1519            ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
     1520                            xbase, dis->rcItem.top, drawstate);
     1521        }
     1522        if ((item->mask & CBEIF_TEXT) && item->pszText) {
     1523            UINT x, y;
     1524            COLORREF nbkc, ntxc;
     1525
     1526            len = lstrlenW (item->pszText);
     1527            GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
     1528            nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1529                                COLOR_HIGHLIGHT : COLOR_WINDOW);
     1530            SetBkColor (dis->hDC, nbkc);
     1531            ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1532                                COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
     1533            SetTextColor (dis->hDC, ntxc);
     1534            x = xbase + xioff;
     1535            y = dis->rcItem.top +
     1536                (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
     1537            rect.left = x;
     1538            rect.right = x + txtsize.cx;
     1539            rect.top = dis->rcItem.top + 1;
     1540            rect.bottom = dis->rcItem.bottom - 1;
     1541            TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
     1542                  dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1543            ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
     1544                         &rect, item->pszText, len, 0);
     1545            if (dis->itemState & ODS_FOCUS) {
     1546                rect.top -= 1;
     1547                rect.bottom += 1;
     1548                rect.left -= 1;
     1549                rect.right += 1;
     1550                TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
     1551                      dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1552                DrawFocusRect (dis->hDC, &rect);
     1553            }
     1554        }
     1555        break;
    7221556    default:
    723         FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
    724           hwnd, wParam, lParam, dis->itemAction);
     1557        FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n", 
     1558              hwnd, wParam, lParam, dis->itemAction);
    7251559    }
    7261560
     
    7351569
    7361570    if (infoPtr->hwndCombo)
    737     DestroyWindow (infoPtr->hwndCombo);
     1571        DestroyWindow (infoPtr->hwndCombo);
     1572
     1573    if (infoPtr->edit) {
     1574        COMCTL32_Free (infoPtr->edit);
     1575        infoPtr->edit = 0;
     1576    }
    7381577
    7391578    if (infoPtr->items) {
    7401579        CBE_ITEMDATA *this, *next;
    7411580
    742     this = infoPtr->items;
    743     while (this) {
    744         next = (CBE_ITEMDATA *)this->next;
    745         if ((this->mask & CBEIF_TEXT) && this->pszText)
    746             COMCTL32_Free (this->pszText);
    747         COMCTL32_Free (this);
    748         this = next;
    749     }
     1581        this = infoPtr->items;
     1582        while (this) {
     1583            next = (CBE_ITEMDATA *)this->next;
     1584            if ((this->mask & CBEIF_TEXT) && this->pszText)
     1585                COMCTL32_Free (this->pszText);
     1586            COMCTL32_Free (this);
     1587            this = next;
     1588        }
    7501589    }
    7511590
     
    7731612
    7741613    TRACE("adjusted height hwnd=%08x, height=%d\n",
    775       hwnd, mis->itemHeight);
     1614          hwnd, mis->itemHeight);
    7761615
    7771616    return 0;
     
    7851624    RECT rect;
    7861625
    787     GetClientRect (hwnd, &rect);
     1626    GetWindowRect (hwnd, &rect);
     1627    TRACE("my rect (%d,%d)-(%d,%d)\n",
     1628          rect.left, rect.top, rect.right, rect.bottom);
    7881629
    7891630    MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
    790           rect.bottom - rect.top, TRUE);
     1631                  rect.bottom - rect.top, TRUE);
     1632
     1633    COMBOEX_AdjustEditPos (infoPtr);
    7911634
    7921635    return 0;
     
    8001643    LRESULT ret;
    8011644    RECT cbx_wrect, cbx_crect, cb_wrect;
    802     UINT width;
     1645    UINT width, height;
    8031646    WINDOWPOS *wp = (WINDOWPOS *)lParam;
    8041647
     
    8101653    /* width is winpos value + border width of comboex */
    8111654    width = wp->cx
    812             + cbx_wrect.right-cbx_wrect.left
    813             - (cbx_crect.right - cbx_crect.left);
     1655            + (cbx_wrect.right-cbx_wrect.left)
     1656            - (cbx_crect.right-cbx_crect.left);
    8141657
    8151658    TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
    816       cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
    817       cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
     1659          cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     1660          cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
    8181661    TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
    819       cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
    820       width, cb_wrect.bottom-cb_wrect.top);
    821 
    822     SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
    823           width,
    824           cb_wrect.bottom-cb_wrect.top,
    825           SWP_NOACTIVATE);
    826 
     1662          cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
     1663          width, cb_wrect.bottom-cb_wrect.top);
     1664
     1665    if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
     1666                             width,
     1667                             cb_wrect.bottom-cb_wrect.top,
     1668                             SWP_NOACTIVATE);
     1669
     1670    GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
     1671
     1672    /* height is combo window height plus border width of comboex */
     1673    height =   (cb_wrect.bottom-cb_wrect.top)
     1674             + (cbx_wrect.bottom-cbx_wrect.top)
     1675             - (cbx_crect.bottom-cbx_crect.top);
     1676    if (wp->cy < height) wp->cy = height;
     1677    if (infoPtr->hwndEdit) {
     1678        COMBOEX_AdjustEditPos (infoPtr);
     1679        InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
     1680    }
     1681
     1682    return 0;
     1683}
     1684
     1685
     1686static LRESULT WINAPI
     1687COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     1688{
     1689    COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
     1690    NMCBEENDEDITA cbeend;
     1691    COLORREF nbkc, obkc;
     1692    HDC hDC;
     1693    RECT rect;
     1694    LRESULT lret;
     1695
     1696    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     1697          hwnd, uMsg, wParam, lParam, infoPtr);
     1698
     1699    if (!infoPtr) return 0;
     1700
     1701    switch (uMsg)
     1702    {
     1703
     1704    case WM_CHAR:
     1705            /* handle (ignore) the return character */
     1706            if (wParam == VK_RETURN) return 0;
     1707            /* all other characters pass into the real Edit */
     1708            return CallWindowProcA (infoPtr->prevEditWndProc,
     1709                                   hwnd, uMsg, wParam, lParam);
     1710
     1711    case WM_ERASEBKGND:
     1712            /*
     1713             * The following was determined by traces of the native
     1714             */
     1715            hDC = (HDC) wParam;
     1716            nbkc = GetSysColor (COLOR_WINDOW);
     1717            obkc = SetBkColor (hDC, nbkc);
     1718            GetClientRect (hwnd, &rect);
     1719            TRACE("erasing (%d,%d)-(%d,%d)\n",
     1720                  rect.left, rect.top, rect.right, rect.bottom);
     1721            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
     1722            SetBkColor (hDC, obkc);
     1723            return CallWindowProcA (infoPtr->prevEditWndProc,
     1724                                   hwnd, uMsg, wParam, lParam);
     1725
     1726    case WM_KEYDOWN: {
     1727            INT oldItem, selected;
     1728            CBE_ITEMDATA *item;
     1729            WCHAR edit_text[260];
     1730
     1731            switch ((INT)wParam)
     1732            {
     1733            case VK_ESCAPE:
     1734                /* native version seems to do following for COMBOEX */
     1735                /*
     1736                 *   GetWindowTextA(Edit,&?, 0x104)             x
     1737                 *   CB_GETCURSEL to Combo rets -1              x
     1738                 *   WM_NOTIFY to COMBOEX parent (rebar)        x
     1739                 *     (CBEN_ENDEDIT{A|W}
     1740                 *      fChanged = FALSE                        x
     1741                 *      inewSelection = -1                      x
     1742                 *      txt="www.hoho"                          x
     1743                 *      iWhy = 3                                x
     1744                 *   CB_GETCURSEL to Combo rets -1              x
     1745                 *   InvalidateRect(Combo, 0)                   x
     1746                 *   WM_SETTEXT to Edit                         x
     1747                 *   EM_SETSEL to Edit (0,0)                    x
     1748                 *   EM_SETSEL to Edit (0,-1)                   x
     1749                 *   RedrawWindow(Combo, 0, 0, 5)               x
     1750                 */
     1751                TRACE("special code for VK_ESCAPE\n");
     1752
     1753                GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
     1754
     1755                infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1756                cbeend.fChanged = FALSE;
     1757                cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1758                                                     CB_GETCURSEL, 0, 0);
     1759                cbeend.iWhy = CBENF_ESCAPE;
     1760
     1761                if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
     1762                                    (NMHDR *)&cbeend, FALSE)) {
     1763                    /* abort the change */
     1764                    TRACE("Notify requested abort of change\n");
     1765                    return 0;
     1766                }
     1767                oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     1768                InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1769                if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     1770                    ERR("item %d not found. Problem!\n", oldItem);
     1771                    break;
     1772                }
     1773                 
     1774                COMBOEX_SetEditText (infoPtr, item);
     1775                RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     1776                              RDW_INVALIDATE);
     1777                break;
     1778
     1779            case VK_RETURN:
     1780                /* native version seems to do following for COMBOEX */
     1781                /*
     1782                 *   GetWindowTextA(Edit,&?, 0x104)             x
     1783                 *   CB_GETCURSEL to Combo  rets -1             x
     1784                 *   CB_GETCOUNT to Combo  rets 0
     1785                 *   if >0 loop
     1786                 *       CB_GETITEMDATA to match
     1787                 * *** above 3 lines simulated by FindItem      x 
     1788                 *   WM_NOTIFY to COMBOEX parent (rebar)        x
     1789                 *     (CBEN_ENDEDIT{A|W}                       x
     1790                 *        fChanged = TRUE (-1)                  x
     1791                 *        iNewSelection = -1 or selected        x
     1792                 *        txt=                                  x
     1793                 *        iWhy = 2 (CBENF_RETURN)               x
     1794                 *   CB_GETCURSEL to Combo  rets -1             x
     1795                 *   if -1 send CB_SETCURSEL to Combo -1        x
     1796                 *   InvalidateRect(Combo, 0, 0)                x
     1797                 *   SetFocus(Edit)                             x
     1798                 *   CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
     1799                 */
     1800
     1801                TRACE("special code for VK_RETURN\n");
     1802
     1803                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     1804
     1805                infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1806                selected = SendMessageW (infoPtr->hwndCombo,
     1807                                         CB_GETCURSEL, 0, 0);
     1808
     1809                if (selected != -1) {
     1810                    item = COMBOEX_FindItem (infoPtr, selected);
     1811                    TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
     1812                          selected, debugstr_w(item->pszText));
     1813                    TRACE("handling VK_RETURN, edittext=%s\n",
     1814                          debugstr_w(edit_text));
     1815                    if (lstrcmpiW (item->pszText, edit_text)) {
     1816                        /* strings not equal -- indicate edit has changed */
     1817                        selected = -1;
     1818                    }
     1819                }
     1820
     1821                cbeend.iNewSelection = selected;
     1822                cbeend.fChanged = TRUE;
     1823                cbeend.iWhy = CBENF_RETURN;
     1824                WideCharToMultiByte (CP_ACP, 0, edit_text, -1,
     1825                                     cbeend.szText, sizeof(cbeend.szText),
     1826                                     NULL, NULL);
     1827
     1828                if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
     1829                                    (NMHDR *)&cbeend, FALSE)) {
     1830                    /* abort the change, restore previous */
     1831                    TRACE("Notify requested abort of change\n");
     1832                    COMBOEX_SetEditText (infoPtr, infoPtr->edit);
     1833                    RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     1834                                  RDW_INVALIDATE);
     1835                    return 0;
     1836                }
     1837                oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     1838                if (oldItem != -1) {
     1839                    /* if something is selected, then deselect it */
     1840                    SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
     1841                                  (WPARAM)-1, 0);
     1842                }
     1843                InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1844                SetFocus(infoPtr->hwndEdit);
     1845                break;
     1846
     1847            default:
     1848                return CallWindowProcA (infoPtr->prevEditWndProc,
     1849                                       hwnd, uMsg, wParam, lParam);
     1850            }
     1851            return 0;
     1852            }
     1853
     1854    case WM_SETFOCUS:
     1855            /* remember the focus to set state of icon */
     1856            lret = CallWindowProcA (infoPtr->prevEditWndProc,
     1857                                   hwnd, uMsg, wParam, lParam);
     1858            infoPtr->flags |= WCBE_EDITFOCUSED;
     1859            return lret;
     1860
     1861    case WM_KILLFOCUS:
     1862            /*
     1863             * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
     1864             */
     1865            infoPtr->flags &= ~WCBE_EDITFOCUSED;
     1866            if (infoPtr->flags & WCBE_ACTEDIT) {
     1867                infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1868                cbeend.fChanged = FALSE;
     1869                cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1870                                                     CB_GETCURSEL, 0, 0);
     1871                cbeend.iWhy = CBENF_KILLFOCUS;
     1872
     1873                COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
     1874                                (NMHDR *)&cbeend, FALSE);
     1875            }
     1876            /* fall through */
     1877
     1878    default:
     1879            return CallWindowProcA (infoPtr->prevEditWndProc,
     1880                                   hwnd, uMsg, wParam, lParam);
     1881    }
     1882    return 0;
     1883}
     1884
     1885
     1886static LRESULT WINAPI
     1887COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     1888{
     1889    COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
     1890    NMCBEENDEDITA cbeend;
     1891    NMMOUSE nmmse;
     1892    COLORREF nbkc, obkc;
     1893    HDC hDC;
     1894    HWND focusedhwnd;
     1895    RECT rect;
     1896
     1897    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     1898          hwnd, uMsg, wParam, lParam, infoPtr);
     1899
     1900    if (!infoPtr) return 0;
     1901
     1902    switch (uMsg)
     1903    {
     1904
     1905    case CB_FINDSTRINGEXACT:
     1906            return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
     1907
     1908    case WM_DRAWITEM:
     1909            /*
     1910             * The only way this message should come is from the
     1911             * child Listbox issuing the message. Flag this so
     1912             * that ComboEx knows this is listbox.
     1913             */
     1914            ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
     1915            return CallWindowProcA (infoPtr->prevComboWndProc,
     1916                                   hwnd, uMsg, wParam, lParam);
     1917
     1918    case WM_ERASEBKGND:
     1919            /*
     1920             * The following was determined by traces of the native
     1921             */
     1922            hDC = (HDC) wParam;
     1923            nbkc = GetSysColor (COLOR_WINDOW);
     1924            obkc = SetBkColor (hDC, nbkc);
     1925            GetClientRect (hwnd, &rect);
     1926            TRACE("erasing (%d,%d)-(%d,%d)\n",
     1927                  rect.left, rect.top, rect.right, rect.bottom);
     1928            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
     1929            SetBkColor (hDC, obkc);
     1930            return CallWindowProcA (infoPtr->prevComboWndProc,
     1931                                   hwnd, uMsg, wParam, lParam);
     1932
     1933    case WM_SETCURSOR:
     1934            /*
     1935             *  WM_NOTIFY to comboex parent (rebar)
     1936             *   with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
     1937             *  CallWindowProc (previous)
     1938             */
     1939            nmmse.dwItemSpec = 0;
     1940            nmmse.dwItemData = 0;
     1941            nmmse.pt.x = 0;
     1942            nmmse.pt.y = 0;
     1943            nmmse.dwHitInfo = lParam;
     1944            COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse, FALSE);
     1945            return CallWindowProcA (infoPtr->prevComboWndProc,
     1946                                   hwnd, uMsg, wParam, lParam);
     1947
     1948    case WM_COMMAND:
     1949            switch (HIWORD(wParam)) {
     1950
     1951            case EN_UPDATE:
     1952                /* traces show that COMBOEX does not issue CBN_EDITUPDATE
     1953                 * on the EN_UPDATE
     1954                 */
     1955                return 0;
     1956
     1957            case EN_KILLFOCUS:
     1958                /*
     1959                 * Native does:
     1960                 *
     1961                 *  GetFocus() retns AA
     1962                 *  GetWindowTextA(Edit)
     1963                 *  CB_GETCURSEL(Combo) (got -1)
     1964                 *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
     1965                 *  CB_GETCURSEL(Combo) (got -1)
     1966                 *  InvalidateRect(Combo, 0, 0)
     1967                 *  WM_KILLFOCUS(Combo, AA)
     1968                 *  return 0;
     1969                 */
     1970                focusedhwnd = GetFocus();
     1971                if (infoPtr->flags & WCBE_ACTEDIT) {
     1972                    GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
     1973                    cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     1974                    cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1975                                                         CB_GETCURSEL, 0, 0);
     1976                    cbeend.iWhy = CBENF_KILLFOCUS;
     1977
     1978                    infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1979                    if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
     1980                                        (NMHDR *)&cbeend, FALSE)) {
     1981                        /* abort the change */
     1982                        TRACE("Notify requested abort of change\n");
     1983                        return 0;
     1984                    }
     1985                }
     1986                /* possible CB_GETCURSEL */
     1987                InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1988                if (focusedhwnd)
     1989                    SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
     1990                                  (WPARAM)focusedhwnd, 0);
     1991                return 0;
     1992
     1993            case EN_SETFOCUS: {
     1994                /*
     1995                 * For EN_SETFOCUS this issues the same calls and messages
     1996                 *  as the native seems to do.
     1997                 *
     1998                 * for some cases however native does the following:
     1999                 *   (noticed after SetFocus during LBUTTONDOWN on
     2000                 *    on dropdown arrow)
     2001                 *  WM_GETTEXTLENGTH (Edit);
     2002                 *  WM_GETTEXT (Edit, len+1, str);
     2003                 *  EM_SETSEL (Edit, 0, 0);
     2004                 *  WM_GETTEXTLENGTH (Edit);
     2005                 *  WM_GETTEXT (Edit, len+1, str);
     2006                 *  EM_SETSEL (Edit, 0, len);
     2007                 *  WM_NOTIFY (parent, CBEN_BEGINEDIT)
     2008                 */
     2009                NMHDR hdr;
     2010
     2011                SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
     2012                SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     2013                COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr, FALSE);
     2014                infoPtr->flags |= WCBE_ACTEDIT;
     2015                infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
     2016                return 0;
     2017                }
     2018
     2019            case EN_CHANGE: {
     2020                /*
     2021                 * For EN_CHANGE this issues the same calls and messages
     2022                 *  as the native seems to do.
     2023                 */
     2024                WCHAR edit_text[260];
     2025                WCHAR *lastwrk;
     2026                INT selected, cnt;
     2027                CBE_ITEMDATA *item;
     2028
     2029                selected = SendMessageW (infoPtr->hwndCombo,
     2030                                         CB_GETCURSEL, 0, 0);
     2031
     2032                /* lstrlenA( lastworkingURL ) */
     2033
     2034                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2035                if (selected == -1) {
     2036                    lastwrk = infoPtr->edit->pszText;
     2037                    cnt = lstrlenW (lastwrk);
     2038                    if (cnt >= 259) cnt = 259;
     2039                }
     2040                else {
     2041                    item = COMBOEX_FindItem (infoPtr, selected);
     2042                    cnt = lstrlenW (item->pszText);
     2043                    lastwrk = item->pszText;
     2044                    if (cnt >= 259) cnt = 259;
     2045                }
     2046
     2047                TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
     2048                    selected, debugstr_w(lastwrk));
     2049                TRACE("handling EN_CHANGE, edittext=%s\n",
     2050                      debugstr_w(edit_text));
     2051
     2052                /* lstrcmpiW is between lastworkingURL and GetWindowText */
     2053
     2054                if (lstrcmpiW (lastwrk, edit_text)) {
     2055                    /* strings not equal -- indicate edit has changed */
     2056                    infoPtr->flags |= WCBE_EDITCHG;
     2057                }
     2058                SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
     2059                               MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
     2060                                          CBN_EDITCHANGE),
     2061                               infoPtr->hwndSelf);
     2062                return 0;
     2063                }
     2064
     2065            case LBN_SELCHANGE:
     2066                /*
     2067                 * Therefore from traces there is no additional code here
     2068                 */
     2069
     2070                /*
     2071                 * Using native COMCTL32 gets the following:
     2072                 *  1 == SHDOCVW.DLL  issues call/message
     2073                 *  2 == COMCTL32.DLL  issues call/message
     2074                 *  3 == WINE  issues call/message
     2075                 *
     2076                 *
     2077                 * for LBN_SELCHANGE:
     2078                 *    1  CB_GETCURSEL(ComboEx)
     2079                 *    1  CB_GETDROPPEDSTATE(ComboEx)
     2080                 *    1  CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
     2081                 *    2  CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
     2082                 **   call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
     2083                 *    3  WM_COMMAND(ComboEx, CBN_SELENDOK)
     2084                 *      WM_USER+49(ComboLB, 1,0)  <=============!!!!!!!!!!!
     2085                 *    3  ShowWindow(ComboLB, SW_HIDE)
     2086                 *    3  RedrawWindow(Combo,  RDW_UPDATENOW)
     2087                 *    3  WM_COMMAND(ComboEX, CBN_CLOSEUP)
     2088                 **   end of CBRollUp
     2089                 *    3  WM_COMMAND(ComboEx, CBN_SELCHANGE)  (echo to parent)
     2090                 *    ?  LB_GETCURSEL              <==|
     2091                 *    ?  LB_GETTEXTLEN                |
     2092                 *    ?  LB_GETTEXT                   | Needs to be added to
     2093                 *    ?  WM_CTLCOLOREDIT(ComboEx)     | Combo processing
     2094                 *    ?  LB_GETITEMDATA               |
     2095                 *    ?  WM_DRAWITEM(ComboEx)      <==|
     2096                 */
     2097            default:
     2098                break;
     2099            }/* fall through */
     2100    default:
     2101            return CallWindowProcA (infoPtr->prevComboWndProc,
     2102                                   hwnd, uMsg, wParam, lParam);
     2103    }
    8272104    return 0;
    8282105}
     
    8382115    switch (uMsg)
    8392116    {
    840 /*  case CBEM_DELETEITEM: */
    841 
    842     case CBEM_GETCOMBOCONTROL:
    843         return COMBOEX_GetComboControl (hwnd, wParam, lParam);
    844 
    845     case CBEM_GETEDITCONTROL:
    846         return COMBOEX_GetEditControl (hwnd, wParam, lParam);
    847 
    848     case CBEM_GETEXTENDEDSTYLE:
    849         return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
    850 
    851     case CBEM_GETIMAGELIST:
    852         return COMBOEX_GetImageList (hwnd, wParam, lParam);
    853 
    854 /*  case CBEM_GETITEMA:
    855     case CBEM_GETITEMW:
    856     case CBEM_GETUNICODEFORMAT:
    857     case CBEM_HASEDITCHANGED:
    858 */
    859 
    860     case CBEM_INSERTITEMA:
    861         return COMBOEX_InsertItemA (hwnd, wParam, lParam);
    862 
    863     case CBEM_INSERTITEMW:
    864         return COMBOEX_InsertItemW (hwnd, wParam, lParam);
    865 
    866     case CBEM_SETEXSTYLE:   /* FIXME: obsoleted, should be the same as: */
    867     case CBEM_SETEXTENDEDSTYLE:
    868         return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
    869 
    870     case CBEM_SETIMAGELIST:
    871         return COMBOEX_SetImageList (hwnd, wParam, lParam);
    872 
    873     case CBEM_SETITEMA:
    874         return COMBOEX_SetItemA (hwnd, wParam, lParam);
    875 
    876     case CBEM_SETITEMW:
    877         return COMBOEX_SetItemW (hwnd, wParam, lParam);
    878 
    879 /*  case CBEM_SETUNICODEFORMAT:
    880 */
    881 
    882     case CB_DELETESTRING:
    883     case CB_FINDSTRINGEXACT:
    884     case CB_GETCOUNT:
    885     case CB_GETCURSEL:
    886     case CB_GETDROPPEDCONTROLRECT:
    887     case CB_GETDROPPEDSTATE:
    888     case CB_GETITEMDATA:
    889     case CB_GETITEMHEIGHT:
    890     case CB_GETLBTEXT:
    891     case CB_GETLBTEXTLEN:
    892     case CB_GETEXTENDEDUI:
    893     case CB_LIMITTEXT:
    894     case CB_RESETCONTENT:
    895     case CB_SELECTSTRING:
    896     case CB_SETCURSEL:
    897     case CB_SETDROPPEDWIDTH:
    898     case CB_SETEXTENDEDUI:
    899     case CB_SETITEMDATA:
    900     case CB_SHOWDROPDOWN:
    901     case WM_SETTEXT:
    902     case WM_GETTEXT:
    903         return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    904 
    905     case CB_SETITEMHEIGHT:
    906         return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
    907 
    908 
    909     case WM_CREATE:
    910         return COMBOEX_Create (hwnd, wParam, lParam);
     2117        case CBEM_DELETEITEM:  /* maps to CB_DELETESTRING */
     2118            return COMBOEX_DeleteItem (hwnd, wParam, lParam);
     2119
     2120        case CBEM_GETCOMBOCONTROL:
     2121            return COMBOEX_GetComboControl (hwnd, wParam, lParam);
     2122
     2123        case CBEM_GETEDITCONTROL:
     2124            return COMBOEX_GetEditControl (hwnd, wParam, lParam);
     2125
     2126        case CBEM_GETEXTENDEDSTYLE:
     2127            return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
     2128
     2129        case CBEM_GETIMAGELIST:
     2130            return COMBOEX_GetImageList (hwnd, wParam, lParam);
     2131
     2132        case CBEM_GETITEMA:
     2133            return COMBOEX_GetItemA (hwnd, wParam, lParam);
     2134
     2135        case CBEM_GETITEMW:
     2136            return COMBOEX_GetItemW (hwnd, wParam, lParam);
     2137
     2138        case CBEM_GETUNICODEFORMAT:
     2139            return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
     2140
     2141        case CBEM_HASEDITCHANGED:
     2142            return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
     2143
     2144        case CBEM_INSERTITEMA:
     2145            return COMBOEX_InsertItemA (hwnd, wParam, lParam);
     2146
     2147        case CBEM_INSERTITEMW:
     2148            return COMBOEX_InsertItemW (hwnd, wParam, lParam);
     2149
     2150        case CBEM_SETEXSTYLE:   /* FIXME: obsoleted, should be the same as: */
     2151        case CBEM_SETEXTENDEDSTYLE:
     2152            return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
     2153
     2154        case CBEM_SETIMAGELIST:
     2155            return COMBOEX_SetImageList (hwnd, wParam, lParam);
     2156
     2157        case CBEM_SETITEMA:
     2158            return COMBOEX_SetItemA (hwnd, wParam, lParam);
     2159
     2160        case CBEM_SETITEMW:
     2161            return COMBOEX_SetItemW (hwnd, wParam, lParam);
     2162
     2163        case CBEM_SETUNICODEFORMAT:
     2164            return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
     2165
     2166
     2167/*   Combo messages we are not sure if we need to process or just forward */
     2168        case CB_GETDROPPEDCONTROLRECT:
     2169        case CB_GETITEMDATA:
     2170        case CB_GETITEMHEIGHT:
     2171        case CB_GETLBTEXT:
     2172        case CB_GETLBTEXTLEN:
     2173        case CB_GETEXTENDEDUI:
     2174        case CB_LIMITTEXT:
     2175        case CB_RESETCONTENT:
     2176        case CB_SELECTSTRING:
     2177        case CB_SETITEMDATA:
     2178        case WM_SETTEXT:
     2179        case WM_GETTEXT:
     2180            FIXME("(0x%x 0x%x 0x%lx): possible missing fucntion\n",
     2181                  uMsg, wParam, lParam);
     2182            return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     2183
     2184/*   Combo messages OK to just forward to the regular COMBO */
     2185        case CB_GETCOUNT:       
     2186        case CB_GETCURSEL:
     2187        case CB_GETDROPPEDSTATE:
     2188        case CB_SETDROPPEDWIDTH:
     2189        case CB_SETEXTENDEDUI:
     2190        case CB_SHOWDROPDOWN:
     2191            return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     2192
     2193/*   Combo messages we need to process specially */
     2194        case CB_FINDSTRINGEXACT:
     2195            return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
     2196                                            wParam, lParam);
     2197
     2198        case CB_SETCURSEL:
     2199            return COMBOEX_SetCursel (hwnd, wParam, lParam);
     2200
     2201        case CB_SETITEMHEIGHT:
     2202            return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
     2203
     2204
     2205
     2206/*   Window messages passed to parent */
     2207        case WM_COMMAND:
     2208            return COMBOEX_Command (hwnd, wParam, lParam);
     2209
     2210        case WM_NOTIFY:
     2211            return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     2212
     2213
     2214/*   Window messages we need to process */
     2215        case WM_CREATE:
     2216            return COMBOEX_Create (hwnd, wParam, lParam);
     2217
     2218        case WM_DELETEITEM:
     2219            return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
    9112220
    9122221        case WM_DRAWITEM:
    9132222            return COMBOEX_DrawItem (hwnd, wParam, lParam);
    9142223
    915     case WM_DESTROY:
    916         return COMBOEX_Destroy (hwnd, wParam, lParam);
     2224        case WM_DESTROY:
     2225            return COMBOEX_Destroy (hwnd, wParam, lParam);
    9172226
    9182227        case WM_MEASUREITEM:
    9192228            return COMBOEX_MeasureItem (hwnd, wParam, lParam);
    9202229
    921     case WM_SIZE:
    922         return COMBOEX_Size (hwnd, wParam, lParam);
     2230        case WM_SIZE:
     2231            return COMBOEX_Size (hwnd, wParam, lParam);
    9232232
    9242233        case WM_WINDOWPOSCHANGING:
    925         return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
    926 
    927     default:
    928         if (uMsg >= WM_USER)
    929         ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    930              uMsg, wParam, lParam);
     2234            return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
     2235
     2236        default:
     2237            if (uMsg >= WM_USER)
     2238                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     2239                     uMsg, wParam, lParam);
    9312240#ifdef __WIN32OS2__
    9322241            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    9332242#else
    934         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2243            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    9352244#endif
    9362245    }
     
    9522261    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    9532262    wndClass.lpszClassName = WC_COMBOBOXEXA;
    954 
     2263 
    9552264    RegisterClassA (&wndClass);
     2265
     2266    ComboExInfo = GlobalAddAtomA("CC32SubclassInfo");
    9562267}
    9572268
  • TabularUnified trunk/src/comctl32/comctl32.def

    r4809 r5416  
    1 ; $Id: comctl32.def,v 1.20 2000-12-16 22:53:18 bird Exp $
     1; $Id: comctl32.def,v 1.21 2001-03-31 13:25:26 sandervl Exp $
    22LIBRARY COMCTL32 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - ComCtl32 - Common Controls Library'
     
    99  GetEffectiveClientRect       = _GetEffectiveClientRect@12          @4
    1010  DrawStatusTextA              = _DrawStatusTextA@16                 @5
    11   DrawStatusText               = _DrawStatusTextA@16                 @27
    12   DrawStatusTextW              = _DrawStatusTextW@16                 @28
    1311  CreateStatusWindowA          = _CreateStatusWindowA@16             @6
    14   CreateStatusWindow           = _CreateStatusWindowA@16             @21
    15   CreateStatusWindowW          = _CreateStatusWindowW@16             @22
     12  CreateToolbar                = _CreateToolbar@32                   @7
     13  CreateMappedBitmap           = _CreateMappedBitmap@20              @8
     14  DPA_LoadStream               = _DPA_LoadStream@16                  @9
     15  DPA_SaveStream               = _DPA_SaveStream@16                  @10
     16  DPA_Merge                    = _DPA_Merge@24                       @11
     17  CreatePropertySheetPage      = _CreatePropertySheetPageA@4         @12
     18  MakeDragList                 = _MakeDragList@4                     @13
     19  LBItemFromPt                 = _LBItemFromPt@16                    @14
     20  DrawInsert                   = _DrawInsert@12                      @15
    1621  CreateUpDownControl          = _CreateUpDownControl@48             @16
    1722  InitCommonControls           = _InitCommonControls@0               @17
    18   InitCommonControlsEx         = _InitCommonControlsEx@4             @81
    19   CreateToolbarEx              = _CreateToolbarEx@52                 @32
    20   CreateMappedBitmap           = _CreateMappedBitmap@20              @8
    21   CreateToolbar                = _CreateToolbar@32                   @7
    22   DllGetVersion                = _COMCTL32_DllGetVersion@4           @25
     23  CreatePropertySheetPageA     = _CreatePropertySheetPageA@4         @18
     24  CreatePropertySheetPageW     = _CreatePropertySheetPageW@4         @19
     25  CreateStatusWindow           = _CreateStatusWindowA@16             @20
     26  CreateStatusWindowW          = _CreateStatusWindowW@16             @21
     27  CreateToolbarEx              = _CreateToolbarEx@52                 @22
     28  DestroyPropertySheetPage     = _DestroyPropertySheetPage@4         @23
     29  DllGetVersion                = _COMCTL32_DllGetVersion@4           @24
     30  DllInstall                   = _COMCTL32_DllInstall@8              @25
     31  DrawStatusText               = _DrawStatusTextA@16                 @26
     32  DrawStatusTextW              = _DrawStatusTextW@16                 @27
     33
     34  FlatSB_EnableScrollBar       = _FlatSB_EnableScrollBar@12          @28
     35  FlatSB_GetScrollInfo         = _FlatSB_GetScrollInfo@12            @29
     36  FlatSB_GetScrollPos          = _FlatSB_GetScrollPos@8              @30
     37  FlatSB_GetScrollProp         = _FlatSB_GetScrollProp@12            @31
     38  FlatSB_GetScrollRange        = _FlatSB_GetScrollRange@16           @32
     39  FlatSB_SetScrollInfo         = _FlatSB_SetScrollInfo@16            @33
     40  FlatSB_SetScrollPos          = _FlatSB_SetScrollPos@16             @34
     41  FlatSB_SetScrollProp         = _FlatSB_SetScrollProp@16            @35
     42  FlatSB_SetScrollRange        = _FlatSB_SetScrollRange@20           @36
     43  FlatSB_ShowScrollBar         = _FlatSB_ShowScrollBar@12            @37
     44  GetMUILanguage               = _GetMUILanguage@0                   @38
    2345
    2446  ImageList_Add                = _ImageList_Add@12                   @39
     
    4062  ImageList_GetBkColor         = _ImageList_GetBkColor@4             @55
    4163  ImageList_GetDragImage       = _ImageList_GetDragImage@8           @56
    42   ImageList_GetIcon            = _ImageList_GetIcon@12               @57
    43   ImageList_GetIconSize        = _ImageList_GetIconSize@12           @58
    44   ImageList_GetImageCount      = _ImageList_GetImageCount@4          @59
    45   ImageList_GetImageInfo       = _ImageList_GetImageInfo@12          @60
    46   ImageList_GetImageRect       = _ImageList_GetImageRect@12          @61
    47   ImageList_LoadImageA         = _ImageList_LoadImageA@28            @62
     64  ;;stub ImageList_GetFlags                                          @57
     65  ImageList_GetIcon            = _ImageList_GetIcon@12               @58
     66  ImageList_GetIconSize        = _ImageList_GetIconSize@12           @59
     67  ImageList_GetImageCount      = _ImageList_GetImageCount@4          @60
     68  ImageList_GetImageInfo       = _ImageList_GetImageInfo@12          @61
     69  ImageList_GetImageRect       = _ImageList_GetImageRect@12          @62
    4870  ImageList_LoadImage          = _ImageList_LoadImageA@28            @63
    49   ImageList_LoadImageW         = _ImageList_LoadImageW@28            @64
    50   ImageList_Merge              = _ImageList_Merge@24                 @65
    51   ImageList_Read               = _ImageList_Read@4                   @66
     71  ImageList_LoadImageA         = _ImageList_LoadImageA@28            @64
     72  ImageList_LoadImageW         = _ImageList_LoadImageW@28            @65
     73  ImageList_Merge              = _ImageList_Merge@24                 @66
     74  ImageList_Read               = _ImageList_Read@4                   @67
     75  ImageList_Remove             = _ImageList_Remove@8                 @68
     76  ImageList_Replace            = _ImageList_Replace@16               @69
     77  ImageList_ReplaceIcon        = _ImageList_ReplaceIcon@12           @70
     78  Alloc                        = _COMCTL32_Alloc@4                   @71
     79  ReAlloc                      = _COMCTL32_ReAlloc@8                 @72
     80  Free                         = _COMCTL32_Free@4                    @73
     81  GetSize                      = _COMCTL32_GetSize@4                 @74
     82  ImageList_SetBkColor         = _ImageList_SetBkColor@8             @75
     83  ImageList_SetDragCursorImage = _ImageList_SetDragCursorImage@16    @76
     84  ImageList_SetFilter          = _ImageList_SetFilter@12             @77
     85  ;;stub ImageList_SetFlags                                          @78
     86  ImageList_SetIconSize        = _ImageList_SetIconSize@12           @79
     87  ImageList_SetImageCount      = _ImageList_SetImageCount@8          @80
     88  ImageList_SetOverlayImage    = _ImageList_SetOverlayImage@12       @81
     89  ImageList_Write              = _ImageList_Write@8                  @82
    5290
    53   ImageList_Remove             = _ImageList_Remove@8                 @67
    54   ImageList_Replace            = _ImageList_Replace@16               @68
    55   ImageList_ReplaceIcon        = _ImageList_ReplaceIcon@12           @69
    56   ImageList_SetBkColor         = _ImageList_SetBkColor@8             @70
    57   ImageList_SetDragCursorImage = _ImageList_SetDragCursorImage@16    @75
    58   ImageList_SetFilter          = _ImageList_SetFilter@12             @76
    59   ImageList_SetIconSize        = _ImageList_SetIconSize@12           @77
    60   ImageList_SetImageCount      = _ImageList_SetImageCount@8          @78
    61   ImageList_SetOverlayImage    = _ImageList_SetOverlayImage@12       @79
    62   ImageList_Write              = _ImageList_Write@8                  @80
     91  InitCommonControlsEx         = _InitCommonControlsEx@4             @83
     92  InitMUILanguage              = _InitMUILanguage@4                  @84
     93  InitializeFlatSB             = _InitializeFlatSB@4                 @85
     94  PropertySheet                = _PropertySheetA@4                   @86
     95  PropertySheetA               = _PropertySheetA@4                   @87
     96  PropertySheetW               = _PropertySheetW@4                   @88
     97  UninitializeFlatSB           = _UninitializeFlatSB@4               @89
     98  _TrackMouseEvent             = __TrackMouseEvent@4                 @90
    6399
    64   PropertySheetA               = _PropertySheetA@4                   @84
    65   PropertySheet                = _PropertySheetA@4                   @83
    66   PropertySheetW               = _PropertySheetW@4                   @85
    67   CreatePropertySheetPageA     = _CreatePropertySheetPageA@4         @19
    68   CreatePropertySheetPage      = _CreatePropertySheetPageA@4         @18
    69   CreatePropertySheetPageW     = _CreatePropertySheetPageW@4         @20
    70   DestroyPropertySheetPage     = _DestroyPropertySheetPage@4         @24
    71100
    72   MakeDragList                 = _MakeDragList@4                     @13
    73   DrawInsert                   = _DrawInsert@12                      @15
    74   LBItemFromPt                 = _LBItemFromPt@16                    @14
    75 
    76   _TrackMouseEvent             = __TrackMouseEvent@4                 @91
    77 
    78                         _COMCTL32_9@16             @9
    79                         _COMCTL32_10@16            @10
    80   DPA_Merge           = _DPA_Merge@24              @11
    81 
    82   COMCTL32_Alloc      = _COMCTL32_Alloc@4          @71
    83   COMCTL32_ReAlloc    = _COMCTL32_ReAlloc@8        @72
    84   COMCTL32_Free       = _COMCTL32_Free@4           @73
    85   COMCTL32_GetSize    = _COMCTL32_GetSize@4        @74
    86101
    87102  CreateMRUListA      = _CreateMRUListA@4          @151
     
    153168  comctl32_412        = _comctl32_412@12           @412
    154169  comctl32_413        = _comctl32_413@16           @413
    155   InitMUILanguage     = _InitMUILanguage@4         @414 ;should be 70
  • TabularUnified trunk/src/comctl32/comctl32.h

    r4641 r5416  
    1 /* $Id: comctl32.h,v 1.18 2000-11-20 04:06:04 bird Exp $ */
     1/* $Id: comctl32.h,v 1.19 2001-03-31 13:25:26 sandervl Exp $ */
    22/*
    33 * Win32 common controls implementation
     
    2222#include <win/commctrl.h>
    2323#include "unicode.h"
    24 #include "wineuni.h"
    2524
    2625#define _OS2WIN_H
     
    158157#define IDI_DRAGARROW                   150
    159158
     159#define COMCTL32_VERSION_MINOR 0
     160#define WINE_FILEVERSION 5, COMCTL32_VERSION_MINOR, 0, 0
     161#define WINE_FILEVERSIONSTR "5.00"
     162
     163#define UINT_PTR DWORD
     164
     165#ifdef __cplusplus
     166extern "C" {
     167#endif
     168
     169void ANIMATE_Register(void);
     170void ANIMATE_Unregister(void);
     171void COMBOEX_Register(void);
     172void COMBOEX_Unregister(void);
     173void DATETIME_Register(void);
     174void DATETIME_Unregister(void);
     175void FLATSB_Register(void);
     176void FLATSB_Unregister(void);
     177void HEADER_Register(void);
     178void HEADER_Unregister(void);
     179void HOTKEY_Register(void);
     180void HOTKEY_Unregister(void);
     181void IPADDRESS_Register(void);
     182void IPADDRESS_Unregister(void);
     183void LISTVIEW_Register(void);
     184void LISTVIEW_Unregister(void);
     185void MONTHCAL_Register(void);
     186void MONTHCAL_Unregister(void);
     187void NATIVEFONT_Register(void);
     188void NATIVEFONT_Unregister(void);
     189void PAGER_Register(void);
     190void PAGER_Unregister(void);
     191void PROGRESS_Register(void);
     192void PROGRESS_Unregister(void);
     193void REBAR_Register(void);
     194void REBAR_Unregister(void);
     195void STATUS_Register(void);
     196void STATUS_Unregister(void);
     197void TAB_Register(void);
     198void TAB_Unregister(void);
     199void TOOLBAR_Register(void);
     200void TOOLBAR_Unregister(void);
     201void TOOLTIPS_Register(void);
     202void TOOLTIPS_Unregister(void);
     203void TRACKBAR_Register(void);
     204void TRACKBAR_Unregister(void);
     205void TREEVIEW_Register(void);
     206void TREEVIEW_Unregister(void);
     207void UPDOWN_Register(void);
     208void UPDOWN_Unregister(void);
     209
     210#ifdef __cplusplus
     211}
     212#endif
     213
    160214#endif /* _H_COMCTL32 */
  • TabularUnified trunk/src/comctl32/comctl32undoc.cpp

    r3923 r5416  
    1 /* $Id: comctl32undoc.cpp,v 1.7 2000-08-02 15:10:23 bird Exp $ */
     1/* $Id: comctl32undoc.cpp,v 1.8 2001-03-31 13:25:26 sandervl Exp $ */
    22/*
    33 * Undocumented functions from COMCTL32.DLL
     
    25202520}
    25212521
    2522 /*************************************************************************
    2523  * InitMUILanguage [COMCTL32.70]
    2524  *
    2525  * FIXME: What's this supposed to do?  Apparently some i18n thing.
    2526  *
    2527  */
    2528 
    2529 BOOL WINAPI InitMUILanguage( LANGID uiLang)
    2530 {
    2531    dprintf(("COMCTL32: InitMUILanguage - empty stub!"));
    2532 
    2533    return TRUE;
    2534 }
    25352522
    25362523DWORD WINAPI COMCTL32_389(DWORD x1, DWORD x2)
     
    25592546
    25602547
    2561 /*****************************************************************************
    2562  * Name      :
    2563  * Purpose   :
    2564  * Parameters:
    2565  * Variables :
    2566  * Result    :
    2567  * Remark    : COMCTL32.9
    2568  *             Likely to have something to do with COM object.
    2569  * Status    : UNTESTED UNKNOWN STUB
    2570  *
    2571  * Author    : Patrick Haller [Sun, 2000/06/09 09:00]
    2572  *****************************************************************************/
    2573 
    2574 DWORD WINAPI COMCTL32_9(DWORD arg0,
    2575                         DWORD arg1,
    2576                         DWORD arg2,
    2577                         DWORD arg3)
    2578 {
    2579   dprintf(("COMCTL32: comctl32_9: %x %x %x %x not implemented!!",
    2580            arg0,
    2581            arg1,
    2582            arg2,
    2583            arg3));
    2584 
    2585   return 0;
    2586 }
    2587 
    2588 /*****************************************************************************
    2589  * Name      :
    2590  * Purpose   :
    2591  * Parameters:
    2592  * Variables :
    2593  * Result    :
    2594  * Remark    : COMCTL32.10
    2595  *             Likely to have something to do with COM object.
    2596  * Status    : UNTESTED UNKNOWN STUB
    2597  *
    2598  * Author    : Patrick Haller [Sun, 2000/06/09 09:00]
    2599  *****************************************************************************/
    2600 
    2601 DWORD WINAPI COMCTL32_10(DWORD arg0,
    2602                          DWORD arg1,
    2603                          DWORD arg2,
    2604                          DWORD arg3)
    2605 {
    2606   dprintf(("COMCTL32: comctl32_10: %x %x %x %x not implemented!!",
    2607            arg0,
    2608            arg1,
    2609            arg2,
    2610            arg3));
    2611 
    2612   return 0;
    2613 }
  • TabularUnified trunk/src/comctl32/datetime.c

    r4627 r5416  
    1919#include "winbase.h"
    2020#include "wingdi.h"
    21 #include "wine/winestring.h"
    2221#include "commctrl.h"
    2322#include "debugtools.h"
    2423
     24#ifdef __WIN32OS2__
     25#include "ccbase.h"
     26#define inline
     27#endif
     28
    2529DEFAULT_DEBUG_CHANNEL(datetime);
    2630
    2731typedef struct
    2832{
     33#ifdef __WIN32OS2__
     34        COMCTL32_HEADER header;
     35#endif
    2936        HWND hMonthCal;
    3037        HWND hUpdown;
     
    308315        LPSTR buf;
    309316        int retval;
    310         int len = lstrlenW ((LPWSTR) lParam)+1;
     317        int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL );
    311318
    312319        buf = (LPSTR) COMCTL32_Alloc (len);
    313         lstrcpyWtoA (buf, (LPWSTR) lParam);
     320        WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, buf, len, NULL, NULL );
    314321        retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf);
    315322        COMCTL32_Free (buf);
     
    11121119  /* allocate memory for info structure */
    11131120  TRACE("%04x %08lx\n",wParam,lParam);
     1121#ifdef __WIN32OS2__
     1122  infoPtr = (DATETIME_INFO*)initControl(hwnd,sizeof(DATETIME_INFO));
     1123#else
    11141124  infoPtr = (DATETIME_INFO *)COMCTL32_Alloc (sizeof(DATETIME_INFO));
     1125#endif
    11151126  if (infoPtr == NULL) {
    11161127    ERR("could not allocate info memory!\n");
     
    11661177    TRACE("\n");
    11671178    COMCTL32_Free (infoPtr);
     1179    SetWindowLongA( hwnd, 0, 0 );
    11681180    return 0;
    11691181}
     
    11731185DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    11741186{
     1187    if (!DATETIME_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
     1188        return DefWindowProcA( hwnd, uMsg, wParam, lParam );
     1189   
    11751190    switch (uMsg)
    11761191    {
     
    12521267                     uMsg, wParam, lParam);
    12531268#ifdef __WIN32OS2__
    1254             return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
     1269        return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    12551270#else
    12561271        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
  • TabularUnified trunk/src/comctl32/flatsb.c

    r4627 r5416  
    2121#include "debugtools.h"
    2222
     23#ifdef __WIN32OS2__
     24#include "ccbase.h"
     25#endif
     26
    2327DEFAULT_DEBUG_CHANNEL(commctrl);
    2428
    2529typedef struct
    2630{
     31#ifdef __WIN32OS2__
     32    COMCTL32_HEADER header;
     33#endif
    2734    DWORD dwDummy;  /* just to keep the compiler happy ;-) */
    2835} FLATSB_INFO, *LPFLATSB_INFO;
     
    180187{
    181188    TRACE("[%04x] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
     189#ifdef __WIN32OS2__
     190    initControl(hwnd,sizeof(FLATSB_INFO));
     191#endif
     192
    182193    return 0;
    183194}
     
    188199{
    189200    TRACE("[%04x] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
     201#ifdef __WIN32OS2__
     202    /* free pager info data */
     203    doneControl(hwnd);
     204#endif
    190205    return 0;
    191206}
  • TabularUnified trunk/src/comctl32/hotkey.cpp

    r2895 r5416  
    1 /* $Id: hotkey.cpp,v 1.2 2000-02-25 17:00:15 cbratschi Exp $ */
     1/* $Id: hotkey.cpp,v 1.3 2001-03-31 13:25:26 sandervl Exp $ */
    22/*
    33 * Hotkey control
     
    1616#include "hotkey.h"
    1717#include <string.h>
     18#include "comctl32.h"
    1819
    1920#define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO*)getInfoPtr(hwnd))
  • TabularUnified trunk/src/comctl32/initterm.cpp

    r5135 r5416  
    4343static HMODULE dllHandle = 0;
    4444
    45 void CDECL RegisterCOMCTL32WindowClasses(unsigned long hinstDLL);
    46 void CDECL UnregisterCOMCTL32WindowClasses(void);
     45BOOL WINAPI COMCTL32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
    4746
    4847//******************************************************************************
     
    5352   {
    5453   case DLL_PROCESS_ATTACH:
    55         /* register Win32 window classes implemented in this DLL */
    56         RegisterCOMCTL32WindowClasses(hinstDLL);
    57         return TRUE;
    58 
    5954   case DLL_THREAD_ATTACH:
    6055   case DLL_THREAD_DETACH:
    61         return TRUE;
     56        return COMCTL32_LibMain(hinstDLL, fdwReason, fImpLoad);
    6257
    6358   case DLL_PROCESS_DETACH:
    64         /* unregister Win32 window classes */
    65         UnregisterCOMCTL32WindowClasses();
     59   {
     60        BOOL ret = COMCTL32_LibMain(hinstDLL, fdwReason, fImpLoad);
    6661        ctordtorTerm();
    67         return TRUE;
     62        return ret;
     63   }
    6864   }
    6965   return FALSE;
  • TabularUnified trunk/src/comctl32/ipaddress.cpp

    r2895 r5416  
    1 /* $Id: ipaddress.cpp,v 1.2 2000-02-25 17:00:16 cbratschi Exp $ */
     1/* $Id: ipaddress.cpp,v 1.3 2001-03-31 13:25:26 sandervl Exp $ */
    22/*
    33 * IP Address control
     
    3333#include "ipaddress.h"
    3434//#include "heap.h"
    35 
     35#include "comctl32.h"
    3636
    3737#define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO*)getInfoPtr(hwnd))
  • TabularUnified trunk/src/comctl32/monthcal.c

    r4627 r5416  
    55 * Copyright 1999 Alex Priem (alexp@sci.kun.nl)
    66 * Copyright 1999 Chris Morgan <cmorgan@wpi.edu> and
    7  *        James Abbatiello <abbeyj@wpi.edu>
     7 *                James Abbatiello <abbeyj@wpi.edu>
    88 * Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
    99 *
     
    1313 *
    1414 *  FIXME: handle resources better (doesn't work now); also take care
    15            of internationalization.
     15           of internationalization. 
    1616 *  FIXME: keyboard handling.
    1717 */
     
    2626#include <stdio.h>
    2727#include <stdlib.h>
     28#include <string.h>
    2829
    2930#include "winbase.h"
     
    3132#include "wingdi.h"
    3233#include "winuser.h"
    33 #include "win.h"
    3434#include "winnls.h"
    3535#include "commctrl.h"
     
    3737#include "debugtools.h"
    3838
     39#ifdef __WIN32OS2__
     40#include "ccbase.h"
     41#endif
     42
    3943DEFAULT_DEBUG_CHANNEL(monthcal);
    4044
    41 #define MC_SEL_LBUTUP       1   /* Left button released */
    42 #define MC_SEL_LBUTDOWN     2   /* Left button pressed in calendar */
     45#define MC_SEL_LBUTUP       1   /* Left button released */
     46#define MC_SEL_LBUTDOWN     2   /* Left button pressed in calendar */
    4347#define MC_PREVPRESSED      4   /* Prev month button pressed */
    4448#define MC_NEXTPRESSED      8   /* Next month button pressed */
    45 #define MC_NEXTMONTHDELAY   350 /* when continuously pressing `next */
    46                                         /* month', wait 500 ms before going */
    47                                         /* to the next month */
    48 #define MC_NEXTMONTHTIMER   1           /* Timer ID's */
    49 #define MC_PREVMONTHTIMER   2
     49#define MC_NEXTMONTHDELAY   350 /* when continuously pressing `next */
     50                                                                                /* month', wait 500 ms before going */
     51                                                                                /* to the next month */
     52#define MC_NEXTMONTHTIMER   1                   /* Timer ID's */
     53#define MC_PREVMONTHTIMER   2                   
    5054
    5155typedef struct
    5256{
    53     COLORREF    bk;
    54     COLORREF    txt;
    55     COLORREF    titlebk;
    56     COLORREF    titletxt;
    57     COLORREF    monthbk;
    58     COLORREF    trailingtxt;
    59     HFONT   hFont;
    60     HFONT   hBoldFont;
    61     int     textHeight;
    62     int     textWidth;
    63     int     height_increment;
    64     int     width_increment;
    65     int     left_offset;
    66     int     top_offset;
    67     int     firstDayplace; /* place of the first day of the current month */
    68     int     delta;  /* scroll rate; # of months that the */
     57#ifdef __WIN32OS2__
     58    COMCTL32_HEADER header;
     59#endif
     60    COLORREF    bk;
     61    COLORREF    txt;
     62    COLORREF    titlebk;
     63    COLORREF    titletxt;
     64    COLORREF    monthbk;
     65    COLORREF    trailingtxt;
     66    HFONT       hFont;
     67    HFONT       hBoldFont;
     68    int         textHeight;
     69    int         textWidth;
     70    int         height_increment;
     71    int         width_increment;
     72    int         left_offset;
     73    int         top_offset;
     74    int         firstDayplace; /* place of the first day of the current month */
     75    int         delta;  /* scroll rate; # of months that the */
    6976                        /* control moves when user clicks a scroll button */
    70     int     visible;    /* # of months visible */
    71     int     firstDay;   /* Start month calendar with firstDay's day */
    72     int     monthRange;
     77    int         visible;        /* # of months visible */
     78    int         firstDay;       /* Start month calendar with firstDay's day */
     79    int         monthRange;
    7380    MONTHDAYSTATE *monthdayState;
    74     SYSTEMTIME  todaysDate;
    75     DWORD   currentMonth;
    76     DWORD   currentYear;
    77     int     status;     /* See MC_SEL flags */
    78     int     curSelDay;  /* current selected day */
    79     int     firstSelDay;    /* first selected day */
    80     int     maxSelCount;
    81     SYSTEMTIME  minSel;
    82     SYSTEMTIME  maxSel;
    83     DWORD   rangeValid;
    84     SYSTEMTIME  minDate;
    85     SYSTEMTIME  maxDate;
    86 
    87     RECT rcClient;  /* rect for whole client area */
    88     RECT rcDraw;    /* rect for drawable portion of client area */
    89     RECT title;     /* rect for the header above the calendar */
    90     RECT titlebtnnext;  /* the `next month' button in the header */
    91     RECT titlebtnprev;  /* the `prev month' button in the header */
    92     RECT titlemonth;    /* the `month name' txt in the header */
    93     RECT titleyear; /* the `year number' txt in the header */
    94     RECT wdays;     /* week days at top */
    95     RECT days;      /* calendar area */
    96     RECT weeknums;  /* week numbers at left side */
    97     RECT todayrect; /* `today: xx/xx/xx' text rect */
     81    SYSTEMTIME  todaysDate;
     82    DWORD       currentMonth;
     83    DWORD       currentYear;
     84    int         status;         /* See MC_SEL flags */
     85    int         curSelDay;      /* current selected day */
     86    int         firstSelDay;    /* first selected day */
     87    int         maxSelCount;
     88    SYSTEMTIME  minSel;
     89    SYSTEMTIME  maxSel;
     90    DWORD       rangeValid;
     91    SYSTEMTIME  minDate;
     92    SYSTEMTIME  maxDate;
     93               
     94    RECT rcClient;      /* rect for whole client area */
     95    RECT rcDraw;        /* rect for drawable portion of client area */
     96    RECT title;         /* rect for the header above the calendar */
     97    RECT titlebtnnext;  /* the `next month' button in the header */
     98    RECT titlebtnprev;  /* the `prev month' button in the header */     
     99    RECT titlemonth;    /* the `month name' txt in the header */
     100    RECT titleyear;     /* the `year number' txt in the header */
     101    RECT wdays;         /* week days at top */
     102    RECT days;          /* calendar area */
     103    RECT weeknums;      /* week numbers at left side */
     104    RECT todayrect;     /* `today: xx/xx/xx' text rect */
    98105    HWND hWndYearEdit;  /* Window Handle of edit box to handle years */
    99106    HWND hWndYearUpDown;/* Window Handle of updown box to handle years */
     
    134141
    135142/* make sure that time is valid */
    136 static int MONTHCAL_ValidateTime(SYSTEMTIME time)
     143static int MONTHCAL_ValidateTime(SYSTEMTIME time) 
    137144{
    138145  if(time.wMonth > 12) return FALSE;
    139146  if(time.wDayOfWeek > 6) return FALSE;
    140147  if(time.wDay > MONTHCAL_MonthLength(time.wMonth, time.wYear))
    141       return FALSE;
     148          return FALSE;
    142149  if(time.wHour > 23) return FALSE;
    143150  if(time.wMinute > 59) return FALSE;
     
    149156
    150157
    151 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to)
     158void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 
    152159{
    153160  to->wYear = from->wYear;
     
    162169
    163170
    164 /* Note:Depending on DST, this may be offset by a day.
     171/* Note:Depending on DST, this may be offset by a day. 
    165172   Need to find out if we're on a DST place & adjust the clock accordingly.
    166173   Above function assumes we have a valid data.
     
    175182  year-=(month < 3);
    176183
    177   return((year + year/4 - year/100 + year/400 +
     184  return((year + year/4 - year/100 + year/400 + 
    178185         DayOfWeekTable[month-1] + day - 1 ) % 7);
    179186}
     
    182189   and day in the calendar. day== 0 mean the last day of tha last month
    183190*/
    184 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y,
    185                    int *daypos,int *weekpos)
     191static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 
     192                                   int *daypos,int *weekpos)
    186193{
    187194  int retval, firstDay;
     
    195202  *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment;
    196203  *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment;
    197 
     204   
    198205  firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear)+6 - infoPtr->firstDay)%7;
    199206  retval = *daypos + (7 * *weekpos) - firstDay;
     
    204211/* sets x and y to be the position of the day */
    205212/* x == day, y == week where(0,0) == firstDay, 1st week */
    206 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month,
     213static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 
    207214                                 int *x, int *y)
    208215{
     
    220227    if(prevMonth==0)
    221228       prevMonth = 12;
    222 
     229   
    223230    *x = (MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay) % 7;
    224231    *y = 0;
     
    233240
    234241/* x: column(day), y: row(week) */
    235 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
     242static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 
    236243{
    237244  r->left = infoPtr->days.left + x * infoPtr->width_increment;
     
    245252/* day is the day value of the month(1 == 1st), month is the month */
    246253/* value(january == 1, december == 12) */
    247 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr,
     254static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 
    248255                                            int day, int month, RECT *r)
    249256{
     
    271278  x = day_rect.left;
    272279  y = day_rect.top;
    273 
     280       
    274281  points[0].x = x;
    275282  points[0].y = y - 1;
     
    280287  points[3].x = x + infoPtr->width_increment;
    281288  points[3].y = y + 0.5 * infoPtr->height_increment;
    282 
     289       
    283290  points[4].x = x + infoPtr->width_increment;
    284291  points[4].y = y + 0.9 * infoPtr->height_increment;
     
    287294  points[6].x = x + 0.5 * infoPtr->width_increment;
    288295  points[6].y = y + 0.9 * infoPtr->height_increment; /* bring the bottom up just
    289                 a hair to fit inside the day rectangle */
    290 
     296                                a hair to fit inside the day rectangle */
     297       
    291298  points[7].x = x + 0.2 * infoPtr->width_increment;
    292299  points[7].y = y + 0.8 * infoPtr->height_increment;
     
    302309  points[12].x = x + 0.4 * infoPtr->width_increment;
    303310  points[12].y = y + 0.2 * infoPtr->height_increment;
    304 
     311 
    305312  PolyBezier(hdc, points, 13);
    306313  DeleteObject(hRedPen);
     
    322329  sprintf(buf, "%d", day);
    323330
    324 /* No need to check styles: when selection is not valid, it is set to zero.
     331/* No need to check styles: when selection is not valid, it is set to zero. 
    325332 * 1<day<31, so evertyhing's OK.
    326333 */
     
    342349
    343350    /* FIXME: this may need to be changed now b/c of the other
    344     drawing changes 11/3/99 CMM */
     351        drawing changes 11/3/99 CMM */
    345352    r2.left   = r.left - 0.25 * infoPtr->textWidth;
    346353    r2.top    = r.top;
     
    383390
    384391/* CHECKME: For `todays date', do we need to check the locale?*/
    385 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
     392static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 
    386393{
    387394  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     
    418425  hbr = CreateSolidBrush (infoPtr->bk);
    419426  FillRect(hdc, rcClient, hbr);
    420   DeleteObject(hbr);
     427  DeleteObject(hbr);       
    421428
    422429  /* draw header */
     
    427434    DeleteObject(hbr);
    428435  }
    429 
     436       
    430437  /* if the previous button is pressed draw it depressed */
    431438  if(IntersectRect(&rcTemp, &(ps->rcPaint), prev))
    432   {
     439  { 
    433440    if((infoPtr->status & MC_PREVPRESSED))
    434441        DrawFrameControl(hdc, prev, DFC_SCROLL,
    435        DFCS_SCROLLLEFT | DFCS_PUSHED |
     442           DFCS_SCROLLLEFT | DFCS_PUSHED |
    436443          (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    437444    else /* if the previous button is pressed draw it depressed */
    438445      DrawFrameControl(hdc, prev, DFC_SCROLL,
    439        DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    440   }
    441 
    442   /* if next button is depressed draw it depressed */
     446           DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
     447  }
     448
     449  /* if next button is depressed draw it depressed */   
    443450  if(IntersectRect(&rcTemp, &(ps->rcPaint), next))
    444451  {
    445452    if((infoPtr->status & MC_NEXTPRESSED))
    446453      DrawFrameControl(hdc, next, DFC_SCROLL,
    447            DFCS_SCROLLRIGHT | DFCS_PUSHED |
     454           DFCS_SCROLLRIGHT | DFCS_PUSHED |
    448455           (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    449456    else /* if the next button is pressed draw it depressed */
     
    459466  titlemonth->left   = title->left;
    460467  titlemonth->right  = title->right;
    461 
     468 
    462469  GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1,
    463           buf1,sizeof(buf1));
     470                  buf1,sizeof(buf1));
    464471  sprintf(buf, "%s %ld", buf1, infoPtr->currentYear);
    465 
     472 
    466473  if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth))
    467474  {
    468     DrawTextA(hdc, buf, strlen(buf), titlemonth,
     475    DrawTextA(hdc, buf, strlen(buf), titlemonth, 
    469476                        DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    470477  }
     
    474481/* titlemonth left/right contained rect for whole titletxt('June  1999')
    475482  * MCM_HitTestInfo wants month & year rects, so prepare these now.
    476   *(no, we can't draw them separately; the whole text is centered)
     483  *(no, we can't draw them separately; the whole text is centered) 
    477484  */
    478485  GetTextExtentPoint32A(hdc, buf, strlen(buf), &size);
     
    482489  titlemonth->right = titlemonth->left + size.cx;
    483490  titleyear->left = titlemonth->right;
    484 
     491 
    485492  /* draw month area */
    486493  rcTemp.top=infoPtr->wdays.top;
     
    494501    DeleteObject(hbr);
    495502  }
    496 
     503       
    497504/* draw line under day abbreviatons */
    498505
    499506  MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL);
    500 
     507     
    501508  LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1);
    502 
     509 
    503510  prevMonth = infoPtr->currentMonth - 1;
    504511  if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */
     
    522529  for(j=0; j<7; j++) {
    523530    GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i +j)%7,
    524             buf,sizeof(buf));
     531                    buf,sizeof(buf));
    525532    DrawTextA(hdc, buf, strlen(buf), days,
    526533                         DT_CENTER | DT_VCENTER | DT_SINGLELINE );
     
    530537
    531538/* draw day numbers; first, the previous month */
    532 
     539 
    533540  firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
    534 
    535   day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  +
     541 
     542  day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  + 
    536543    (infoPtr->firstDay + 7  - firstDay)%7 + 1;
    537544  if (day > MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear))
     
    546553    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    547554    {
    548       MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0,
     555      MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 
    549556          infoPtr->monthdayState[m] & mask);
    550557    }
     
    570577    {
    571578
    572       MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0,
    573     infoPtr->monthdayState[m] & mask);
     579      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 
     580        infoPtr->monthdayState[m] & mask);
    574581
    575582      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    576583          (day==infoPtr->todaysDate.wDay) &&
    577       (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
     584          (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
    578585        if(!(dwStyle & MCS_NOTODAYCIRCLE))
    579       MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
     586          MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    580587      }
    581588    }
     
    588595  j = 1; /* move to the 2nd week of the current month */
    589596  i = 0; /* move back to sunday */
    590   while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {
     597  while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {     
    591598    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    592599    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     
    597604      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    598605          (day==infoPtr->todaysDate.wDay) &&
    599           (infoPtr->currentYear == infoPtr->todaysDate.wYear))
    600         if(!(dwStyle & MCS_NOTODAYCIRCLE))
    601       MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
     606          (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 
     607        if(!(dwStyle & MCS_NOTODAYCIRCLE)) 
     608          MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    602609    }
    603610    mask<<=1;
     
    620627    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    621628    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    622     {
     629    {   
    623630      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j,
    624         infoPtr->monthdayState[m] & mask);
     631                infoPtr->monthdayState[m] & mask);
    625632    }
    626633
    627634    mask<<=1;
    628635    day++;
    629     i++;
     636    i++;       
    630637    if(i==7) { /* past saturday, go to next week's sunday */
    631638      i = 0;
     
    643650    if(!(dwStyle & MCS_NOTODAYCIRCLE))  {
    644651      /*day is the number of days from nextmonth we put on the calendar */
    645       MONTHCAL_CircleDay(hdc, infoPtr,
    646              day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
    647             infoPtr->currentMonth);
     652      MONTHCAL_CircleDay(hdc, infoPtr, 
     653                         day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
     654                        infoPtr->currentMonth);
    648655      offset+=textWidth;
    649656    }
    650657    if (!LoadStringA(COMCTL32_hModule,IDM_TODAY,buf1,sizeof(buf1)))
    651658      {
    652     WARN("Can't load resource\n");
    653     strcpy(buf1,"Today:");
     659        WARN("Can't load resource\n");
     660        strcpy(buf1,"Today:");
    654661      }
    655662    MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6);
     
    667674  }
    668675
    669 /*eventually draw week numbers*/
     676/*eventually draw week numbers*/   
    670677  if(dwStyle & MCS_WEEKNUMBERS)  {
    671678    /* display weeknumbers*/
     
    675682       LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?):
    676683       The week containing Jan 1 is the first week of year
    677        LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany):
     684       LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany): 
    678685       First week of year must contain 4 days of the new year
    679686       LOCALE_IFIRSTWEEKOFYEAR == 1  (what contries?)
     
    681688    */
    682689    GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR,
    683              buf, sizeof(buf));
     690                     buf, sizeof(buf));
    684691    sscanf(buf, "%d", &weeknum);
    685692    switch (weeknum)
    686693      {
    687694      case 1: mindays = 6;
    688     break;
     695        break;
    689696      case 2: mindays = 3;
    690     break;
     697        break;
    691698      case 0:
    692699      default:
    693     mindays = 0;
     700        mindays = 0;
    694701      }
    695702    if (infoPtr->currentMonth < 2)
    696703      {
    697     /* calculate all those exceptions for january */
    698     weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
    699     if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays)
    700         weeknum =1;
    701     else
    702       {
    703         weeknum = 0;
    704         for(i=0; i<11; i++)
    705           weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1);
    706         weeknum +=startofprescal+ 7;
    707         weeknum /=7;
    708         weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear-1);
    709         if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
    710           weeknum++;
    711       }
     704        /* calculate all those exceptions for january */
     705        weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
     706        if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays)
     707            weeknum =1;
     708        else
     709          {
     710            weeknum = 0;
     711            for(i=0; i<11; i++)
     712              weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1);
     713            weeknum +=startofprescal+ 7;
     714            weeknum /=7;
     715            weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear-1);
     716            if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
     717              weeknum++;
     718          }
    712719      }
    713720    else
    714721      {
    715     weeknum = 0;
    716     for(i=0; i<prevMonth-1; i++)
    717       weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear);
    718     weeknum +=startofprescal+ 7;
    719     weeknum /=7;
    720     weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
    721     if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
    722       weeknum++;
     722        weeknum = 0;
     723        for(i=0; i<prevMonth-1; i++)
     724          weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear);
     725        weeknum +=startofprescal+ 7;
     726        weeknum /=7;
     727        weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
     728        if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
     729          weeknum++;
    723730      }
    724731    days->left = infoPtr->weeknums.left;
     
    728735    for(i=0; i<6; i++) {
    729736      if((i==0)&&(weeknum>50))
    730     {
    731       sprintf(buf, "%d", weeknum);
    732       weeknum=0;
    733     }
     737        {
     738          sprintf(buf, "%d", weeknum);
     739          weeknum=0;
     740        }
    734741      else if((i==5)&&(weeknum>47))
    735     {
    736       sprintf(buf, "%d", 1);
    737     }
     742        {
     743          sprintf(buf, "%d", 1);
     744        }
    738745      else
    739     sprintf(buf, "%d", weeknum + i);
     746        sprintf(buf, "%d", weeknum + i);
    740747      DrawTextA(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
    741748      days->top+=infoPtr->height_increment;
    742749      days->bottom+=infoPtr->height_increment;
    743750    }
    744 
     751                       
    745752    MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL);
    746753    LineTo(hdc,   infoPtr->weeknums.right, infoPtr->weeknums.bottom );
    747 
     754               
    748755  }
    749756  /* currentFont was font at entering Refresh */
    750757
    751758  SetBkColor(hdc, oldBkColor);
    752   SelectObject(hdc, currentFont);
     759  SelectObject(hdc, currentFont);     
    753760  SetTextColor(hdc, oldTextColor);
    754761}
    755762
    756763
    757 static LRESULT
     764static LRESULT 
    758765MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    759766{
     
    761768  LPRECT lpRect = (LPRECT) lParam;
    762769  TRACE("%x %lx\n", wParam, lParam);
    763 
     770       
    764771  /* validate parameters */
    765772
     
    774781
    775782
    776 static LRESULT
     783static LRESULT 
    777784MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    778785{
     
    800807
    801808
    802 static LRESULT
     809static LRESULT 
    803810MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    804811{
     
    840847
    841848
    842 static LRESULT
     849static LRESULT 
    843850MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    844851{
     
    846853
    847854  TRACE("%x %lx\n", wParam, lParam);
    848 
     855 
    849856  if(infoPtr->delta)
    850857    return infoPtr->delta;
     
    854861
    855862
    856 static LRESULT
     863static LRESULT 
    857864MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    858865{
     
    861868
    862869  TRACE("%x %lx\n", wParam, lParam);
    863 
     870       
    864871  infoPtr->delta = (int)wParam;
    865872  return prev;
     
    867874
    868875
    869 static LRESULT
     876static LRESULT 
    870877MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    871878{
    872879  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
    873 
     880       
    874881  return infoPtr->firstDay;
    875882}
     
    880887/* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */
    881888/* FIXME: we need more error checking here */
    882 static LRESULT
     889static LRESULT 
    883890MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    884891{
     
    896903    {
    897904      GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK,
    898              buf, sizeof(buf));
     905                     buf, sizeof(buf));
    899906      TRACE("%s %d\n", buf, strlen(buf));
    900907      if(sscanf(buf, "%d", &day) == 1)
    901     infoPtr->firstDay = day;
     908        infoPtr->firstDay = day;
    902909      else
    903     infoPtr->firstDay = 0;
     910        infoPtr->firstDay = 0;
    904911    }
    905912  return prev;
     
    909916/* FIXME: fill this in */
    910917static LRESULT
    911 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
     918MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 
    912919{
    913920  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
     
    930937
    931938/* FIXME: are validated times taken from current date/time or simply
    932  * copied?
     939 * copied? 
    933940 * FIXME:    check whether MCM_GETMONTHRANGE shows correct result after
    934941 *            adjusting range with MCM_SETRANGE
     
    943950
    944951  TRACE("%x %lx\n", wParam, lParam);
    945 
     952 
    946953  if(wParam & GDTR_MAX) {
    947954    if(MONTHCAL_ValidateTime(lprgSysTimeArray[1])){
     
    966973  infoPtr->monthRange = infoPtr->maxDate.wMonth - infoPtr->minDate.wMonth;
    967974
    968   if(infoPtr->monthRange!=prev) {
    969     COMCTL32_ReAlloc(infoPtr->monthdayState,
    970         infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     975  if(infoPtr->monthRange!=prev) { 
     976        COMCTL32_ReAlloc(infoPtr->monthdayState,
     977                infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    971978  }
    972979
     
    976983
    977984/* CHECKME: At the moment, we copy ranges anyway,regardless of
    978  * infoPtr->rangeValid; a invalid range is simply filled with zeros in
     985 * infoPtr->rangeValid; a invalid range is simply filled with zeros in 
    979986 * SetRange.  Is this the right behavior?
    980987*/
     
    10081015  if(iMonths!=infoPtr->monthRange) return 0;
    10091016
    1010   for(i=0; i<iMonths; i++)
     1017  for(i=0; i<iMonths; i++) 
    10111018    infoPtr->monthdayState[i] = dayStates[i];
    10121019  return 1;
    10131020}
    10141021
    1015 static LRESULT
     1022static LRESULT 
    10161023MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10171024{
     
    10291036/* FIXME: if the specified date is not visible, make it visible */
    10301037/* FIXME: redraw? */
    1031 static LRESULT
     1038static LRESULT 
    10321039MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10331040{
     
    10501057
    10511058
    1052 static LRESULT
     1059static LRESULT 
    10531060MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10541061{
     
    10601067
    10611068
    1062 static LRESULT
     1069static LRESULT 
    10631070MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10641071{
     
    10741081
    10751082
    1076 static LRESULT
     1083static LRESULT 
    10771084MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10781085{
     
    10931100    return TRUE;
    10941101  }
    1095 
     1102 
    10961103  return FALSE;
    10971104}
    10981105
    10991106
    1100 static LRESULT
     1107static LRESULT 
    11011108MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11021109{
     
    11171124    return TRUE;
    11181125  }
    1119 
     1126 
    11201127  return FALSE;
    11211128}
    11221129
    11231130
    1124 static LRESULT
     1131static LRESULT 
    11251132MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11261133{
     
    11381145
    11391146
    1140 static LRESULT
     1147static LRESULT 
    11411148MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11421149{
     
    11631170  DWORD retval;
    11641171  int day,wday,wnum;
    1165 
    1166 
     1172 
     1173 
    11671174  x = lpht->pt.x;
    11681175  y = lpht->pt.y;
    11691176  retval = MCHT_NOWHERE;
    1170 
    1171 
    1172   /* Comment in for debugging...
    1173   TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y,
    1174     infoPtr->wdays.left, infoPtr->wdays.right,
    1175     infoPtr->wdays.top, infoPtr->wdays.bottom,
    1176     infoPtr->days.left, infoPtr->days.right,
    1177     infoPtr->days.top, infoPtr->days.bottom,
    1178     infoPtr->todayrect.left, infoPtr->todayrect.right,
    1179     infoPtr->todayrect.top, infoPtr->todayrect.bottom,
    1180     infoPtr->weeknums.left, infoPtr->weeknums.right,
    1181     infoPtr->weeknums.top, infoPtr->weeknums.bottom);
     1177 
     1178
     1179  /* Comment in for debugging... 
     1180  TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y, 
     1181        infoPtr->wdays.left, infoPtr->wdays.right,
     1182        infoPtr->wdays.top, infoPtr->wdays.bottom,
     1183        infoPtr->days.left, infoPtr->days.right,
     1184        infoPtr->days.top, infoPtr->days.bottom,
     1185        infoPtr->todayrect.left, infoPtr->todayrect.right,
     1186        infoPtr->todayrect.top, infoPtr->todayrect.bottom,
     1187        infoPtr->weeknums.left, infoPtr->weeknums.right,
     1188        infoPtr->weeknums.top, infoPtr->weeknums.bottom);
    11821189  */
    11831190
    11841191  /* are we in the header? */
    1185 
     1192 
    11861193  if(PtInRect(&infoPtr->title, lpht->pt)) {
    11871194    if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) {
     
    12011208      goto done;
    12021209    }
    1203 
     1210   
    12041211    retval = MCHT_TITLE;
    12051212    goto done;
    12061213  }
    1207 
     1214 
    12081215  day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum);
    12091216  if(PtInRect(&infoPtr->wdays, lpht->pt)) {
     
    12111218    lpht->st.wYear  = infoPtr->currentYear;
    12121219    lpht->st.wMonth = (day < 1)? infoPtr->currentMonth -1 : infoPtr->currentMonth;
    1213     lpht->st.wDay   = (day < 1)?
     1220    lpht->st.wDay   = (day < 1)? 
    12141221      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : day;
    12151222    goto done;
    12161223  }
    1217   if(PtInRect(&infoPtr->weeknums, lpht->pt)) {
    1218     retval = MCHT_CALENDARWEEKNUM;
     1224  if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 
     1225    retval = MCHT_CALENDARWEEKNUM; 
    12191226    lpht->st.wYear  = infoPtr->currentYear;
    1220     lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 :
    1221       (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
     1227    lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 : 
     1228      (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 
    12221229      infoPtr->currentMonth +1 :infoPtr->currentMonth;
    1223     lpht->st.wDay   = (day < 1 ) ?
    1224       MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day :
    1225       (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
     1230    lpht->st.wDay   = (day < 1 ) ? 
     1231      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : 
     1232      (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 
    12261233      day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) : day;
    1227     goto done;
    1228   }
    1229   if(PtInRect(&infoPtr->days, lpht->pt))
     1234    goto done;                             
     1235  }
     1236  if(PtInRect(&infoPtr->days, lpht->pt)) 
    12301237    {
    12311238      lpht->st.wYear  = infoPtr->currentYear;
    1232       if ( day < 1)
    1233     {
    1234       retval = MCHT_CALENDARDATEPREV;
    1235       lpht->st.wMonth = infoPtr->currentMonth - 1;
    1236       if (lpht->st.wMonth <1)
    1237         {
    1238           lpht->st.wMonth = 12;
    1239           lpht->st.wYear--;
    1240         }
    1241       lpht->st.wDay   = MONTHCAL_MonthLength(lpht->st.wMonth,lpht->st.wYear) -day;
    1242     }
     1239      if ( day < 1) 
     1240        {
     1241          retval = MCHT_CALENDARDATEPREV;
     1242          lpht->st.wMonth = infoPtr->currentMonth - 1;
     1243          if (lpht->st.wMonth <1)
     1244            {
     1245              lpht->st.wMonth = 12;
     1246              lpht->st.wYear--;
     1247            }
     1248          lpht->st.wDay   = MONTHCAL_MonthLength(lpht->st.wMonth,lpht->st.wYear) -day;
     1249        }
    12431250      else if (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear))
    1244     {
    1245       retval = MCHT_CALENDARDATENEXT;
    1246       lpht->st.wMonth = infoPtr->currentMonth + 1;
    1247       if (lpht->st.wMonth <12)
    1248         {
    1249           lpht->st.wMonth = 1;
    1250           lpht->st.wYear++;
    1251         }
    1252       lpht->st.wDay   = day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) ;
    1253     }
     1251        {
     1252          retval = MCHT_CALENDARDATENEXT;
     1253          lpht->st.wMonth = infoPtr->currentMonth + 1;
     1254          if (lpht->st.wMonth <12)
     1255            {
     1256              lpht->st.wMonth = 1;
     1257              lpht->st.wYear++;
     1258            }
     1259          lpht->st.wDay   = day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) ;
     1260        }
    12541261      else {
    1255     retval = MCHT_CALENDARDATE;
    1256     lpht->st.wMonth = infoPtr->currentMonth;
    1257     lpht->st.wDay   = day;
     1262        retval = MCHT_CALENDARDATE;
     1263        lpht->st.wMonth = infoPtr->currentMonth;
     1264        lpht->st.wDay   = day;
    12581265      }
    12591266      goto done;
    12601267    }
    12611268  if(PtInRect(&infoPtr->todayrect, lpht->pt)) {
    1262     retval = MCHT_TODAYLINK;
     1269    retval = MCHT_TODAYLINK; 
    12631270    goto done;
    12641271  }
    1265 
    1266 
     1272 
     1273 
    12671274  /* Hit nothing special? What's left must be background :-) */
    1268 
    1269   retval = MCHT_CALENDARBK;
    1270  done:
     1275 
     1276  retval = MCHT_CALENDARBK;       
     1277 done: 
    12711278  lpht->uHit = retval;
    12721279  return retval;
     
    12931300    nmds.nmhdr.idFrom   = GetWindowLongA(hwnd, GWL_ID);
    12941301    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    1295     nmds.cDayState  = infoPtr->monthRange;
    1296     nmds.prgDayState    = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     1302    nmds.cDayState      = infoPtr->monthRange;
     1303    nmds.prgDayState    = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    12971304
    12981305    SendMessageA(GetParent(hwnd), WM_NOTIFY,
     
    13231330    nmds.nmhdr.idFrom   = GetWindowLongA(hwnd, GWL_ID);
    13241331    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    1325     nmds.cDayState  = infoPtr->monthRange;
    1326     nmds.prgDayState    = COMCTL32_Alloc
     1332    nmds.cDayState      = infoPtr->monthRange;
     1333    nmds.prgDayState    = COMCTL32_Alloc
    13271334                        (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    13281335
     
    13411348  POINT menupoint;
    13421349  char buf[32];
    1343 
     1350 
    13441351  hMenu = CreatePopupMenu();
    13451352  if (!LoadStringA(COMCTL32_hModule,IDM_GOTODAY,buf,sizeof(buf)))
     
    13531360  ClientToScreen(hwnd, &menupoint);
    13541361  if( TrackPopupMenu(hMenu,TPM_RIGHTBUTTON| TPM_NONOTIFY|TPM_RETURNCMD,
    1355              menupoint.x,menupoint.y,0,hwnd,NULL))
     1362                     menupoint.x,menupoint.y,0,hwnd,NULL))
    13561363    {
    13571364      infoPtr->currentMonth=infoPtr->todaysDate.wMonth;
    13581365      infoPtr->currentYear=infoPtr->todaysDate.wYear;
    13591366      InvalidateRect(hwnd, NULL, FALSE);
    1360     }
     1367    }   
    13611368  return 0;
    13621369}
     
    13741381  POINT menupoint;
    13751382  TRACE("%x %lx\n", wParam, lParam);
    1376 
     1383       
    13771384  if (infoPtr->hWndYearUpDown)
    13781385    {
    13791386      infoPtr->currentYear=SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)0);
    13801387      if(!DestroyWindow(infoPtr->hWndYearUpDown))
    1381     {
    1382       FIXME("Can't destroy Updown Control\n");
    1383     }
     1388        {
     1389          FIXME("Can't destroy Updown Control\n");
     1390        }
    13841391      else
    1385     infoPtr->hWndYearUpDown=0;
     1392        infoPtr->hWndYearUpDown=0;
    13861393      if(!DestroyWindow(infoPtr->hWndYearEdit))
    1387     {
    1388       FIXME("Can't destroy Updown Control\n");
    1389     }
     1394        {
     1395          FIXME("Can't destroy Updown Control\n");
     1396        }
    13901397      else
    1391     infoPtr->hWndYearEdit=0;
     1398        infoPtr->hWndYearEdit=0;
    13921399      InvalidateRect(hwnd, NULL, FALSE);
    13931400    }
    1394 
     1401 
    13951402  ht.pt.x = (INT)LOWORD(lParam);
    13961403  ht.pt.y = (INT)HIWORD(lParam);
     
    14071414    return TRUE;
    14081415  }
    1409   if(hit == MCHT_TITLEBTNPREV){
     1416  if(hit == MCHT_TITLEBTNPREV){ 
    14101417    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    14111418    infoPtr->status = MC_PREVPRESSED;
     
    14171424  if(hit == MCHT_TITLEMONTH) {
    14181425    hMenu = CreatePopupMenu();
    1419 
     1426   
    14201427    for (i=0; i<12;i++)
    14211428      {
    1422     GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,
    1423           buf,sizeof(buf));
    1424     AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
     1429        GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,
     1430                  buf,sizeof(buf));
     1431        AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
    14251432      }
    14261433    menupoint.x=infoPtr->titlemonth.right;
     
    14281435    ClientToScreen(hwnd, &menupoint);
    14291436    i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD,
    1430               menupoint.x,menupoint.y,0,hwnd,NULL);
     1437                      menupoint.x,menupoint.y,0,hwnd,NULL);
    14311438    if ((i>0) && (i<13))
    14321439      {
    1433     infoPtr->currentMonth=i;
    1434     InvalidateRect(hwnd, NULL, FALSE);
     1440        infoPtr->currentMonth=i;
     1441        InvalidateRect(hwnd, NULL, FALSE);
    14351442      }
    14361443  }
    14371444  if(hit == MCHT_TITLEYEAR) {
    14381445    infoPtr->hWndYearEdit=CreateWindowExA(0,
    1439             "EDIT",
    1440                0,
    1441             WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT,
    1442             infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,
    1443             infoPtr->titleyear.right-infoPtr->titleyear.left,
    1444             infoPtr->textHeight,
    1445             hwnd,
    1446              (HMENU)NULL,
    1447              (HINSTANCE)NULL,
    1448             NULL);
     1446                        "EDIT",
     1447                           0,
     1448                        WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT,
     1449                        infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,
     1450                        infoPtr->titleyear.right-infoPtr->titleyear.left,
     1451                        infoPtr->textHeight,
     1452                        hwnd,
     1453                         (HMENU)NULL,
     1454                         (HINSTANCE)NULL,
     1455                        NULL);
    14491456    infoPtr->hWndYearUpDown=CreateWindowExA(0,
    1450             UPDOWN_CLASSA,
    1451                0,
    1452             WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,
    1453             infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top,
    1454             20,
    1455             infoPtr->textHeight,
    1456             hwnd,
    1457              (HMENU)NULL,
    1458              (HINSTANCE)NULL,
    1459             NULL);
     1457                        UPDOWN_CLASSA,
     1458                           0,
     1459                        WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,
     1460                        infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top,
     1461                        20,
     1462                        infoPtr->textHeight,
     1463                        hwnd,
     1464                         (HMENU)NULL,
     1465                         (HINSTANCE)NULL,
     1466                        NULL);
    14601467    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753));
    14611468    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 );
    14621469    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)infoPtr->currentYear );
    14631470    return TRUE;
    1464 
     1471         
    14651472  }
    14661473  if(hit == MCHT_TODAYLINK) {
     
    14801487    MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    14811488    MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1482 
     1489       
    14831490    SendMessageA(GetParent(hwnd), WM_NOTIFY,
    14841491           (WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc);
     
    14861493    MONTHCAL_CopyTime(&ht.st, &selArray[0]);
    14871494    MONTHCAL_CopyTime(&ht.st, &selArray[1]);
    1488     MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray);
     1495    MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 
    14891496
    14901497    /* redraw both old and new days if the selected day changed */
     
    15391546    return TRUE;
    15401547  }
    1541   if(hit == MCHT_CALENDARDATEPREV){
     1548  if(hit == MCHT_CALENDARDATEPREV){ 
    15421549    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    15431550    InvalidateRect(hwnd, NULL, FALSE);
     
    15571564  MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    15581565  MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1559 
     1566       
    15601567  SendMessageA(GetParent(hwnd), WM_NOTIFY,
    15611568           (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
    1562 
     1569 
    15631570  /* redraw if necessary */
    15641571  if(redraw)
    15651572    InvalidateRect(hwnd, NULL, FALSE);
    1566 
     1573       
    15671574  return 0;
    15681575}
     
    15791586
    15801587  switch(wParam) {
    1581   case MC_NEXTMONTHTIMER:
     1588  case MC_NEXTMONTHTIMER: 
    15821589    redraw = TRUE;
    15831590    MONTHCAL_GoToNextMonth(hwnd, infoPtr);
     
    16111618  ht.pt.x = LOWORD(lParam);
    16121619  ht.pt.y = HIWORD(lParam);
    1613 
     1620       
    16141621  hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
    1615 
     1622 
    16161623  /* not on the calendar date numbers? bail out */
    16171624  TRACE("hit:%x\n",hit);
     
    16311638    if(infoPtr->firstSelDay==selArray[0].wDay) i=1;
    16321639    TRACE("oldRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1633     if(infoPtr->firstSelDay==selArray[1].wDay) {
     1640    if(infoPtr->firstSelDay==selArray[1].wDay) { 
    16341641      /* 1st time we get here: selArray[0]=selArray[1])  */
    16351642      /* if we're still at the first selected date, return */
     
    16371644      if(selday<infoPtr->firstSelDay) i = 0;
    16381645    }
    1639 
     1646                       
    16401647    if(abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) {
    16411648      if(selday>infoPtr->firstSelDay)
     
    16441651        selday = infoPtr->firstSelDay - infoPtr->maxSelCount;
    16451652    }
    1646 
     1653               
    16471654    if(selArray[i].wDay!=selday) {
    16481655      TRACE("newRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1649 
     1656                       
    16501657      selArray[i].wDay = selday;
    16511658
     
    17051712{
    17061713  TRACE("\n");
    1707 
     1714 
    17081715  InvalidateRect(hwnd, NULL, FALSE);
    17091716
     
    17621769
    17631770  /* recalculate the height and width increments and offsets */
    1764   /* FIXME: We use up all available width. This will inhibit having multiple
    1765      calendars in a row, like win doesn
     1771  /* FIXME: We use up all available width. This will inhibit having multiple 
     1772     calendars in a row, like win doesn 
    17661773  */
    17671774  if(dwStyle & MCS_WEEKNUMBERS)
     
    17691776  else
    17701777    xdiv=7.0;
    1771   infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv;
    1772   infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0;
     1778  infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv; 
     1779  infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0; 
    17731780  infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * xdiv);
    17741781  infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 10.0);
     
    17831790    rcDraw->bottom = rcDraw->top + 9 * infoPtr->textHeight + 5;
    17841791    }*/
    1785 
     1792   
    17861793  /* calculate title area */
    17871794  title->top    = rcClient->top;
     
    17981805  next->right  = title->right - 6;
    17991806  next->left   = next->right - (title->bottom - title->top);
    1800 
     1807 
    18011808  /* titlemonth->left and right change based upon the current month */
    18021809  /* and are recalculated in refresh as the current month may change */
     
    18041811  titlemonth->top    = titleyear->top    = title->top    + (infoPtr->height_increment)/2;
    18051812  titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2;
    1806 
     1813 
    18071814  /* setup the dimensions of the rectangle we draw the names of the */
    18081815  /* days of the week in */
    18091816  weeknumrect->left =infoPtr->left_offset;
    1810   if(dwStyle & MCS_WEEKNUMBERS)
     1817  if(dwStyle & MCS_WEEKNUMBERS) 
    18111818    weeknumrect->right=prev->right;
    18121819  else
     
    18161823  wdays->top    = title->bottom ;
    18171824  wdays->bottom = wdays->top + infoPtr->height_increment;
    1818 
     1825 
    18191826  days->top    = weeknumrect->top = wdays->bottom ;
    18201827  days->bottom = weeknumrect->bottom = days->top     + 6 * infoPtr->height_increment;
    1821 
     1828 
    18221829  todayrect->left   = rcClient->left;
    18231830  todayrect->right  = rcClient->right;
     
    18251832  todayrect->bottom = days->bottom + infoPtr->height_increment;
    18261833
    1827   /* uncomment for excessive debugging
     1834  /* uncomment for excessive debugging 
    18281835  TRACE("dx=%d dy=%d rcC[%d %d %d %d] t[%d %d %d %d] wd[%d %d %d %d] w[%d %d %d %d] t[%d %d %d %d]\n",
    1829     infoPtr->width_increment,infoPtr->height_increment,
    1830     rcClient->left, rcClient->right, rcClient->top, rcClient->bottom,
    1831         title->left,    title->right,    title->top,    title->bottom,
    1832         wdays->left,    wdays->right,    wdays->top,    wdays->bottom,
    1833          days->left,     days->right,     days->top,     days->bottom,
    1834     todayrect->left,todayrect->right,todayrect->top,todayrect->bottom);
     1836        infoPtr->width_increment,infoPtr->height_increment,
     1837        rcClient->left, rcClient->right, rcClient->top, rcClient->bottom,
     1838            title->left,    title->right,    title->top,    title->bottom,
     1839            wdays->left,    wdays->right,    wdays->top,    wdays->bottom,
     1840             days->left,     days->right,     days->top,     days->bottom,
     1841        todayrect->left,todayrect->right,todayrect->top,todayrect->bottom);
    18351842  */
    1836 
     1843 
    18371844  /* restore the originally selected font */
    1838   SelectObject(hdc, currentFont);
     1845  SelectObject(hdc, currentFont);     
    18391846
    18401847  ReleaseDC(hwnd, hdc);
     
    18581865{
    18591866  MONTHCAL_INFO *infoPtr;
    1860   LOGFONTA  logFont;
     1867  LOGFONTA      logFont;
    18611868
    18621869  /* allocate memory for info structure */
     1870#ifdef __WIN32OS2__
     1871  infoPtr =(MONTHCAL_INFO*)initControl(hwnd,sizeof(MONTHCAL_INFO));
     1872#else
    18631873  infoPtr =(MONTHCAL_INFO*)COMCTL32_Alloc(sizeof(MONTHCAL_INFO));
     1874#endif
    18641875  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    18651876
     
    18891900  infoPtr->maxSelCount  = 7;
    18901901  infoPtr->monthRange = 3;
    1891   infoPtr->monthdayState = COMCTL32_Alloc
     1902  infoPtr->monthdayState = COMCTL32_Alloc 
    18921903                         (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    18931904  infoPtr->titlebk     = GetSysColor(COLOR_ACTIVECAPTION);
     
    18961907  infoPtr->trailingtxt = GetSysColor(COLOR_GRAYTEXT);
    18971908  infoPtr->bk          = GetSysColor(COLOR_WINDOW);
    1898   infoPtr->txt         = GetSysColor(COLOR_WINDOWTEXT);
     1909  infoPtr->txt         = GetSysColor(COLOR_WINDOWTEXT);
    18991910
    19001911  /* call MONTHCAL_UpdateSize to set all of the dimensions */
     
    20512062  wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    20522063  wndClass.lpszClassName = MONTHCAL_CLASSA;
    2053 
     2064 
    20542065  RegisterClassA(&wndClass);
    20552066}
  • TabularUnified trunk/src/comctl32/nativefont.cpp

    r3182 r5416  
    1 /* $Id: nativefont.cpp,v 1.3 2000-03-21 17:30:43 cbratschi Exp $ */
     1/* $Id: nativefont.cpp,v 1.4 2001-03-31 13:25:26 sandervl Exp $ */
    22/*
    33 * Native Font control
     
    2121#include "ccbase.h"
    2222#include "nativefont.h"
     23#include "comctl32.h"
    2324
    2425#define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO*)getInfoPtr(hwnd))
  • TabularUnified trunk/src/comctl32/trackbar.cpp

    r3970 r5416  
    1 /* $Id: trackbar.cpp,v 1.5 2000-08-08 17:05:01 cbratschi Exp $ */
     1/* $Id: trackbar.cpp,v 1.6 2001-03-31 13:25:27 sandervl Exp $ */
    22/*
    33 * Trackbar control
     
    2020#include "ccbase.h"
    2121#include "trackbar.h"
     22#include "comctl32.h"
    2223#include <stdio.h>
    2324
  • TabularUnified trunk/src/comctl32/updown.cpp

    r3154 r5416  
    1 /* $Id: updown.cpp,v 1.2 2000-03-18 16:17:35 cbratschi Exp $ */
     1/* $Id: updown.cpp,v 1.3 2001-03-31 13:25:27 sandervl Exp $ */
    22/*
    33 * Updown control
     
    3939#include "ccbase.h"
    4040#include "updown.h"
     41#include "comctl32.h"
    4142
    4243/* Control configuration constants */
Note: See TracChangeset for help on using the changeset viewer.