OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [mwin/] [winlib/] [combobox.c] - Diff between revs 674 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 674 Rev 1765
/*--------------------------------------------------------------------------
/*--------------------------------------------------------------------------
**      ComboBox.c             Twin           From:  Twin/controls
**      ComboBox.c             Twin           From:  Twin/controls
**
**
**
**
**------------------------- < License Information > ------------------------
**------------------------- < License Information > ------------------------
**
**
**      This file was originally a part of Willows TWIN.  Willows
**      This file was originally a part of Willows TWIN.  Willows
**  TWIN was released under a Library GPL (LGPL).  This permits
**  TWIN was released under a Library GPL (LGPL).  This permits
**  redistribution of this source code, provided that the full
**  redistribution of this source code, provided that the full
**  TWIN license is in effect, and provided that all modifications
**  TWIN license is in effect, and provided that all modifications
**  to this source code are made publicly available.
**  to this source code are made publicly available.
**  Please refer to Willows software (www.willows.com) or
**  Please refer to Willows software (www.willows.com) or
**  LICENSE for full information.
**  LICENSE for full information.
**
**
**      Under Twine, this file is also protected by an LGPL.  Please
**      Under Twine, this file is also protected by an LGPL.  Please
**  see LICENSE for full details on this license.
**  see LICENSE for full details on this license.
**
**
**
**
**      Copyright 1997 Willows Software, Inc.
**      Copyright 1997 Willows Software, Inc.
**------------------------ < File Content Description > --------------------
**------------------------ < File Content Description > --------------------
**
**
**  Module:      controls/ComboBox.c
**  Module:      controls/ComboBox.c
**
**
**  Description:
**  Description:
**
**
**
**
**  Functions defined:
**  Functions defined:
**
**
**------------------------- < Revision Information > -----------------------
**------------------------- < Revision Information > -----------------------
**
**
**      Full Revision history at bottom of file
**      Full Revision history at bottom of file
**
**
**--------------------------------------------------------------------------*/
**--------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include "windows.h"
#include "windows.h"
#include "windowsx.h"
#include "windowsx.h"
 
 
#define WinMalloc(n)    malloc((n))
#define WinMalloc(n)    malloc((n))
#define WinFree(p)      free(p)
#define WinFree(p)      free(p)
 
 
#define GET_WM_COMMAND_ID(wp, lp)               LOWORD(wp)
#define GET_WM_COMMAND_ID(wp, lp)               LOWORD(wp)
#define GET_WM_COMMAND_HWND(wp, lp)             (HWND)(lp)
#define GET_WM_COMMAND_HWND(wp, lp)             (HWND)(lp)
#define GET_WM_COMMAND_CMD(wp, lp)              HIWORD(wp)
#define GET_WM_COMMAND_CMD(wp, lp)              HIWORD(wp)
#define GET_WM_COMMAND_MPS(id, hwnd, cmd)    \
#define GET_WM_COMMAND_MPS(id, hwnd, cmd)    \
        (WPARAM)MAKELONG(id, cmd), (LONG)(hwnd)
        (WPARAM)MAKELONG(id, cmd), (LONG)(hwnd)
#define LOSHORT(x)      (short int)LOWORD(x)
#define LOSHORT(x)      (short int)LOWORD(x)
#define Edit_SetSel(hwndCtl, ichStart, ichEnd)  ((void)SendMessage((hwndCtl), EM_SETSEL, (ichStart), (ichEnd)))
#define Edit_SetSel(hwndCtl, ichStart, ichEnd)  ((void)SendMessage((hwndCtl), EM_SETSEL, (ichStart), (ichEnd)))
 
 
 
 
typedef struct  {
typedef struct  {
    HFONT   hFont;          /* hFont used */
    HFONT   hFont;          /* hFont used */
    HWND    hWndParent;     /* parent window */
    HWND    hWndParent;     /* parent window */
    UINT    nID;            /* control ID */
    UINT    nID;            /* control ID */
    WORD    wStateFlags;    /* combobox state flags */
    WORD    wStateFlags;    /* combobox state flags */
    UINT    wStyle;         /* this is a copy of LOWORD(style) */
    UINT    wStyle;         /* this is a copy of LOWORD(style) */
    BOOL    bExtended;      /* extended UI flag */
    BOOL    bExtended;      /* extended UI flag */
    BOOL    bRedraw;        /* MiD - redraw flag, draw only if it's 1 */
    BOOL    bRedraw;        /* MiD - redraw flag, draw only if it's 1 */
    HWND    EditControl;    /* edit/static control hWnd */
    HWND    EditControl;    /* edit/static control hWnd */
    HWND    ListBoxControl; /* listbox control hWnd */
    HWND    ListBoxControl; /* listbox control hWnd */
    RECT    ButtonRect;     /* local button rect (client) */
    RECT    ButtonRect;     /* local button rect (client) */
    RECT    ListBoxRect;    /* listbox rect (screen) */
    RECT    ListBoxRect;    /* listbox rect (screen) */
    UINT    uHeight;        /* height of the normal state */
    UINT    uHeight;        /* height of the normal state */
    WNDPROC lpfnOldStatic;  /* previous static wndproc */
    WNDPROC lpfnOldStatic;  /* previous static wndproc */
    UINT    nListItems;     /* ecw */
    UINT    nListItems;     /* ecw */
} COMBOBOX;
} COMBOBOX;
 
 
#define CWD_LPCBDATA  0
#define CWD_LPCBDATA  0
#define CBC_EDITID    1
#define CBC_EDITID    1
 
 
#define CSF_CAPTUREACTIVE   0x0001
#define CSF_CAPTUREACTIVE   0x0001
#define CSF_LOCALBUTTONDOWN 0x0002
#define CSF_LOCALBUTTONDOWN 0x0002
#define CSF_BUTTONDOWN      0x0004
#define CSF_BUTTONDOWN      0x0004
#define CSF_LBOXBUTTONDOWN  0x0008
#define CSF_LBOXBUTTONDOWN  0x0008
#define CSF_FOCUS           0x0010 /* MiD */
#define CSF_FOCUS           0x0010 /* MiD */
#define CSF_HASDROPPED      0x0020 /* weav */
#define CSF_HASDROPPED      0x0020 /* weav */
 
 
#define SET_STATE(lp, wMask)   (lp->wStateFlags |= (wMask))
#define SET_STATE(lp, wMask)   (lp->wStateFlags |= (wMask))
#define CLEAR_STATE(lp, wMask) (lp->wStateFlags &= ~(wMask))
#define CLEAR_STATE(lp, wMask) (lp->wStateFlags &= ~(wMask))
#define IS_SET(lp, wMask)      (lp->wStateFlags & (wMask))
#define IS_SET(lp, wMask)      (lp->wStateFlags & (wMask))
 
 
#define BOWNERDRAW(l) ((l)->wStyle & (CBS_OWNERDRAWFIXED|CBS_OWNERDRAWVARIABLE))
#define BOWNERDRAW(l) ((l)->wStyle & (CBS_OWNERDRAWFIXED|CBS_OWNERDRAWVARIABLE))
 
 
/**********************************************
/**********************************************
    Styles:
    Styles:
 
 
    CBS_AUTOHSCROLL     passed to the edit control
    CBS_AUTOHSCROLL     passed to the edit control
    CBS_DISABLENOSCROLL passed to the listbox control
    CBS_DISABLENOSCROLL passed to the listbox control
    CBS_DROPDOWN
    CBS_DROPDOWN
    CBS_DROPDOWNLIST
    CBS_DROPDOWNLIST
    CBS_HASSTRINGS      passed to the listbox control
    CBS_HASSTRINGS      passed to the listbox control
    CBS_NOINTEGRALHEIGHT    passed to the listbox control
    CBS_NOINTEGRALHEIGHT    passed to the listbox control
    CBS_OEMCONVERT      passed to the edit control
    CBS_OEMCONVERT      passed to the edit control
    CBS_OWNERDRAWFIXED  passed to the listbox control
    CBS_OWNERDRAWFIXED  passed to the listbox control
    CBS_OWNERDRAWVARIABLE   passed to the listbox control
    CBS_OWNERDRAWVARIABLE   passed to the listbox control
    CBS_SIMPLE      TODO
    CBS_SIMPLE      TODO
    CBS_SORT        passed to the listbox control
    CBS_SORT        passed to the listbox control
 
 
    WS_VSCROLL      passed to the listbox control
    WS_VSCROLL      passed to the listbox control
 
 
*********************************************/
*********************************************/
 
 
/**********************************************
/**********************************************
    CBN_xxx messages to be added
    CBN_xxx messages to be added
 
 
    from mouse tracking...
    from mouse tracking...
    CBN_SELENDCANCEL    TODO
    CBN_SELENDCANCEL    TODO
    CBN_SELENDOK        TODO
    CBN_SELENDOK        TODO
 
 
*********************************************/
*********************************************/
 
 
/* imported stuff */
/* imported stuff */
#if 1
#if 1
void
void
Draw3DButtonRect(HDC hDC, HPEN hPenHigh, HPEN hPenShadow,
Draw3DButtonRect(HDC hDC, HPEN hPenHigh, HPEN hPenShadow,
                RECT rc, BOOL fClicked)
                RECT rc, BOOL fClicked)
{
{
    HPEN     hPenOld;
    HPEN     hPenOld;
    POINT    lpt[6];
    POINT    lpt[6];
 
 
    POINT    p3[3];
    POINT    p3[3];
    int      shrink=1;
    int      shrink=1;
 
 
    hPenOld = SelectObject(hDC, hPenShadow);
    hPenOld = SelectObject(hDC, hPenShadow);
    if (fClicked) {
    if (fClicked) {
        lpt[0].x = lpt[1].x = rc.left;
        lpt[0].x = lpt[1].x = rc.left;
        lpt[1].y = lpt[2].y = rc.top;
        lpt[1].y = lpt[2].y = rc.top;
        lpt[2].x = rc.right-1;
        lpt[2].x = rc.right-1;
        lpt[0].y = rc.bottom-1;
        lpt[0].y = rc.bottom-1;
        Polyline(hDC,lpt,3);
        Polyline(hDC,lpt,3);
    }
    }
    else {
    else {
        lpt[0].x = lpt[1].x = rc.right-1;
        lpt[0].x = lpt[1].x = rc.right-1;
        lpt[0].y = rc.top;
        lpt[0].y = rc.top;
        lpt[1].y = lpt[2].y = rc.bottom-1;
        lpt[1].y = lpt[2].y = rc.bottom-1;
        lpt[2].x = rc.left;
        lpt[2].x = rc.left;
        lpt[3].x = rc.left+1;
        lpt[3].x = rc.left+1;
        lpt[3].y = lpt[4].y = rc.bottom-2;
        lpt[3].y = lpt[4].y = rc.bottom-2;
        lpt[4].x = lpt[5].x = rc.right-2;
        lpt[4].x = lpt[5].x = rc.right-2;
        lpt[5].y = rc.top+1;
        lpt[5].y = rc.top+1;
        Polyline(hDC,lpt,6);
        Polyline(hDC,lpt,6);
 
 
        SelectObject(hDC, hPenHigh);
        SelectObject(hDC, hPenHigh);
        lpt[0].x = rc.right-1;
        lpt[0].x = rc.right-1;
        lpt[0].y = lpt[1].y = rc.top;
        lpt[0].y = lpt[1].y = rc.top;
        lpt[1].x = lpt[2].x = rc.left;
        lpt[1].x = lpt[2].x = rc.left;
        lpt[2].y = rc.bottom-1;
        lpt[2].y = rc.bottom-1;
        lpt[3].x = lpt[4].x = rc.left+1;
        lpt[3].x = lpt[4].x = rc.left+1;
        lpt[3].y = rc.bottom-2;
        lpt[3].y = rc.bottom-2;
        lpt[4].y = lpt[5].y = rc.top+1;
        lpt[4].y = lpt[5].y = rc.top+1;
        lpt[5].x = rc.right-2;
        lpt[5].x = rc.right-2;
        Polyline(hDC,lpt,6);
        Polyline(hDC,lpt,6);
    }
    }
 
 
    SelectObject(hDC,GetStockObject(BLACK_BRUSH));
    SelectObject(hDC,GetStockObject(BLACK_BRUSH));
    /* down */
    /* down */
    p3[0].x= rc.left + ((rc.right-rc.left)/2) - 1;
    p3[0].x= rc.left + ((rc.right-rc.left)/2) - 1;
    p3[0].y= rc.bottom - 4 - shrink;
    p3[0].y= rc.bottom - 4 - shrink;
    p3[1].x= rc.left + 2 + shrink - 1;
    p3[1].x= rc.left + 2 + shrink - 1;
    p3[1].y= rc.bottom-(rc.bottom-rc.top) + 2 + shrink;
    p3[1].y= rc.bottom-(rc.bottom-rc.top) + 2 + shrink;
    p3[2].x= rc.left + ((rc.right-rc.left)-4) - shrink;
    p3[2].x= rc.left + ((rc.right-rc.left)-4) - shrink;
    p3[2].y= rc.bottom-(rc.bottom-rc.top) + 2 + shrink;
    p3[2].y= rc.bottom-(rc.bottom-rc.top) + 2 + shrink;
    Polygon(hDC,p3,3);
    Polygon(hDC,p3,3);
 
 
    SelectObject(hDC,hPenOld);
    SelectObject(hDC,hPenOld);
}
}
#endif
#endif
 
 
#if 0   /* jmt: fix: no COMBOLBOX */
#if 0   /* jmt: fix: no COMBOLBOX */
extern LRESULT  DefLISTBOXProc(HWND, UINT, WPARAM, LPARAM);
extern LRESULT  DefLISTBOXProc(HWND, UINT, WPARAM, LPARAM);
extern LRESULT  ListboxCtrlProc(HWND, UINT, WPARAM, LPARAM);
extern LRESULT  ListboxCtrlProc(HWND, UINT, WPARAM, LPARAM);
#endif
#endif
 
 
#if 0
#if 0
static HPEN     GetSysColorPen(int color)
static HPEN     GetSysColorPen(int color)
{
{
        return NULL;
        return NULL;
}
}
static HBRUSH   GetSysColorBrush(int color)
static HBRUSH   GetSysColorBrush(int color)
{
{
        return NULL;
        return NULL;
}
}
#endif
#endif
 
 
typedef HWND HWND32;
typedef HWND HWND32;
 
 
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
typedef HANDLE HCLASS32;
typedef HANDLE HCLASS32;
static HCLASS32 FindClass(LPCSTR str, HINSTANCE hInstance)
static HCLASS32 FindClass(LPCSTR str, HINSTANCE hInstance)
{
{
        return NULL;
        return NULL;
}
}
#endif
#endif
 
 
#if 0   /* jmt: fix: no scrollbar */
#if 0   /* jmt: fix: no scrollbar */
static HWND TWIN_ConvertToSysScroll(HWND hwnd, BOOL status, LPPOINT pp)
static HWND TWIN_ConvertToSysScroll(HWND hwnd, BOOL status, LPPOINT pp)
{
{
        return NULL;
        return NULL;
}
}
#endif
#endif
extern HWND listwp;
extern HWND listwp;
static HWND WindowFromPoint(POINT pt)
static HWND WindowFromPoint(POINT pt)
{
{
        HWND wp,wp1;
        HWND wp,wp1;
        int dx,dy,dx1,dy1;
        int dx,dy,dx1,dy1;
#if 0
#if 0
        return NULL;    /* fix!! */
        return NULL;    /* fix!! */
#else
#else
        wp1=NULL;
        wp1=NULL;
        switch(sizeof(dx))
        switch(sizeof(dx))
        {
        {
        case 4:
        case 4:
                dx=0x7fffffff;
                dx=0x7fffffff;
                dy=0x7fffffff;
                dy=0x7fffffff;
                break;
                break;
        case 2:
        case 2:
                dx=0x7fff;
                dx=0x7fff;
                dy=0x7fff;
                dy=0x7fff;
                break;
                break;
        }
        }
        for(wp=listwp; wp; wp=wp->next)
        for(wp=listwp; wp; wp=wp->next)
        {
        {
                if (wp->winrect.left <= pt.x && pt.x <= wp->winrect.right)
                if (wp->winrect.left <= pt.x && pt.x <= wp->winrect.right)
                {
                {
                        dx1=(wp->winrect.right-pt.x);
                        dx1=(wp->winrect.right-pt.x);
                        if (dx1<dx)
                        if (dx1<dx)
                        {
                        {
                                wp1=wp;
                                wp1=wp;
                                dx=dx1;
                                dx=dx1;
                        }
                        }
                        dx1=(pt.x-wp->winrect.left);
                        dx1=(pt.x-wp->winrect.left);
                        if (dx1<dx)
                        if (dx1<dx)
                        {
                        {
                                wp1=wp;
                                wp1=wp;
                                dx=dx1;
                                dx=dx1;
                        }
                        }
                }
                }
                if (wp->winrect.top <= pt.y && pt.y <= wp->winrect.bottom)
                if (wp->winrect.top <= pt.y && pt.y <= wp->winrect.bottom)
                {
                {
                        dy1=(wp->winrect.bottom-pt.y);
                        dy1=(wp->winrect.bottom-pt.y);
                        if (dy1<dy)
                        if (dy1<dy)
                        {
                        {
                                wp1=wp;
                                wp1=wp;
                                dy=dy1;
                                dy=dy1;
                        }
                        }
                        dy1=(pt.y-wp->winrect.top);
                        dy1=(pt.y-wp->winrect.top);
                        if (dy1<dy)
                        if (dy1<dy)
                        {
                        {
                                wp1=wp;
                                wp1=wp;
                                dy=dy1;
                                dy=dy1;
                        }
                        }
                }
                }
        }
        }
#endif
#endif
        return wp1;
        return wp1;
}
}
 
 
/* internal stuff */
/* internal stuff */
static void CBoxDrawButton(HWND,UINT,COMBOBOX *);
static void CBoxDrawButton(HWND,UINT,COMBOBOX *);
static void CBoxSendMouseToLBox(COMBOBOX *, UINT, WPARAM, POINT);
static void CBoxSendMouseToLBox(COMBOBOX *, UINT, WPARAM, POINT);
static void CBoxCapture(HWND, WORD);
static void CBoxCapture(HWND, WORD);
static void CBoxDrawEdit(COMBOBOX *, HWND, UINT);
static void CBoxDrawEdit(COMBOBOX *, HWND, UINT);
static void CBoxDrawStatic(COMBOBOX *, HWND, UINT); /* MiD */
static void CBoxDrawStatic(COMBOBOX *, HWND, UINT); /* MiD */
 
 
/* handle specific CB messages */
/* handle specific CB messages */
static LRESULT DefCBProc(HWND , UINT , WPARAM , LPARAM );
static LRESULT DefCBProc(HWND , UINT , WPARAM , LPARAM );
 
 
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
static WNDPROC lpComboBinToNat = 0;
static WNDPROC lpComboBinToNat = 0;
#endif
#endif
 
 
static LRESULT CALLBACK
static LRESULT CALLBACK
DefComboboxProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
DefComboboxProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 
int WINAPI MwRegisterComboboxControl(HINSTANCE hInstance)
int WINAPI MwRegisterComboboxControl(HINSTANCE hInstance)
{
{
        WNDCLASS        wc;
        WNDCLASS        wc;
 
 
        wc.style        = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_GLOBALCLASS;
        wc.style        = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_GLOBALCLASS;
        wc.lpfnWndProc  = (WNDPROC)DefComboboxProc;
        wc.lpfnWndProc  = (WNDPROC)DefComboboxProc;
        wc.cbClsExtra   = 0;
        wc.cbClsExtra   = 0;
        wc.cbWndExtra   = 0;
        wc.cbWndExtra   = 0;
        wc.hInstance    = hInstance;
        wc.hInstance    = hInstance;
        wc.hIcon        = NULL;
        wc.hIcon        = NULL;
        wc.hCursor      = 0;
        wc.hCursor      = 0;
        wc.hbrBackground= GetStockObject(WHITE_BRUSH);
        wc.hbrBackground= GetStockObject(WHITE_BRUSH);
        wc.lpszMenuName = NULL;
        wc.lpszMenuName = NULL;
        wc.lpszClassName= "COMBOBOX";
        wc.lpszClassName= "COMBOBOX";
 
 
        return RegisterClass(&wc);
        return RegisterClass(&wc);
}
}
 
 
static LRESULT CALLBACK
static LRESULT CALLBACK
DefComboboxProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
DefComboboxProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
{
    PAINTSTRUCT ps;
    PAINTSTRUCT ps;
    HDC      hDC;
    HDC      hDC;
    TEXTMETRIC tm;
    TEXTMETRIC tm;
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
    MEASUREITEMSTRUCT mis;
    MEASUREITEMSTRUCT mis;
#endif
#endif
    COMBOBOX *lp = (COMBOBOX *)NULL;
    COMBOBOX *lp = (COMBOBOX *)NULL;
    LRESULT   rc;
    LRESULT   rc;
    HINSTANCE hInst;
    HINSTANCE hInst;
    POINT     cp,cpScreen,pp;
    POINT     cp,cpScreen,pp;
    UINT      uiKey;
    UINT      uiKey;
    LPCREATESTRUCT lpcs;
    LPCREATESTRUCT lpcs;
#if 1   /* jmt: fix: no WM_WINDOWPOSCHANGING */
#if 1   /* jmt: fix: no WM_WINDOWPOSCHANGING */
    LPWINDOWPOS lpwp;
    LPWINDOWPOS lpwp;
#endif
#endif
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
    HCLASS32 hComboClass32;
    HCLASS32 hComboClass32;
    LPMEASUREITEMSTRUCT lpmis;
    LPMEASUREITEMSTRUCT lpmis;
    LPDRAWITEMSTRUCT lpdis;
    LPDRAWITEMSTRUCT lpdis;
    LPDELETEITEMSTRUCT lpdlis;
    LPDELETEITEMSTRUCT lpdlis;
#endif
#endif
    DWORD dwStyle,dwExStyle;
    DWORD dwStyle,dwExStyle;
    WORD wEditWidth = 0,wEditHeight;
    WORD wEditWidth = 0,wEditHeight;
    WORD wCBN;
    WORD wCBN;
#if 0   /* jmt: fix: no WM_SETFONT/WM_GETFONT */
#if 0   /* jmt: fix: no WM_SETFONT/WM_GETFONT */
    RECT rcClient;
    RECT rcClient;
#endif
#endif
 
 
    rc = CB_OKAY;
    rc = CB_OKAY;
    if ((uMsg != WM_CREATE/*WM_NCCREATE*/) && /*(uMsg != WM_CONVERT) &&*/
    if ((uMsg != WM_CREATE/*WM_NCCREATE*/) && /*(uMsg != WM_CONVERT) &&*/
       !(lp = (COMBOBOX *)hWnd->userdata/*GetWindowLong(hWnd,CWD_LPCBDATA)*/))
       !(lp = (COMBOBOX *)hWnd->userdata/*GetWindowLong(hWnd,CWD_LPCBDATA)*/))
        return rc;
        return rc;
 
 
    switch(uMsg) {
    switch(uMsg) {
#if 0
#if 0
    case WM_SIZE:
    case WM_SIZE:
    case WM_ENABLE:
    case WM_ENABLE:
    case WM_LBUTTONDBLCLK:
    case WM_LBUTTONDBLCLK:
    case WM_COMPAREITEM:
    case WM_COMPAREITEM:
    case WM_CUT:
    case WM_CUT:
    case WM_CLEAR:
    case WM_CLEAR:
#endif               
#endif               
 
 
    case WM_SETFOCUS:
    case WM_SETFOCUS:
        SET_STATE(lp, CSF_FOCUS);
        SET_STATE(lp, CSF_FOCUS);
        if ((lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
        if ((lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
           {
           {
           uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
           uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
           CBoxDrawStatic(lp, hWnd, uiKey);
           CBoxDrawStatic(lp, hWnd, uiKey);
           }
           }
        if (lp->EditControl)
        if (lp->EditControl)
        {
        {
           SetFocus(lp->EditControl);
           SetFocus(lp->EditControl);
        }
        }
        break;
        break;
 
 
    case WM_KILLFOCUS:
    case WM_KILLFOCUS:
        CLEAR_STATE(lp, CSF_FOCUS);
        CLEAR_STATE(lp, CSF_FOCUS);
        if ((lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
        if ((lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
        {
        {
           uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
           uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
           CBoxDrawStatic(lp, hWnd, uiKey);
           CBoxDrawStatic(lp, hWnd, uiKey);
        }
        }
        /*
        /*
        **    Hide listbox when loosing focus to window other than
        **    Hide listbox when loosing focus to window other than
        **    our own listbox... When wParam == 0 we "loose" the focus
        **    our own listbox... When wParam == 0 we "loose" the focus
        **    to the scrollbar in a listbox!
        **    to the scrollbar in a listbox!
        */
        */
        if ((lp->wStyle & 0x0F) != CBS_SIMPLE && wParam != (WPARAM)lp->ListBoxControl && wParam != 0)
        if ((lp->wStyle & 0x0F) != CBS_SIMPLE && wParam != (WPARAM)lp->ListBoxControl && wParam != 0)
           SendMessage(hWnd, CB_SHOWDROPDOWN, 0, 0L);
           SendMessage(hWnd, CB_SHOWDROPDOWN, 0, 0L);
        fprintf(stderr," 385: WM_KILLFOCUS\n");
        fprintf(stderr," 385: WM_KILLFOCUS\n");
        break;
        break;
 
 
#if 0   /* jmt: fix: no WM_KEYDOWN */
#if 0   /* jmt: fix: no WM_KEYDOWN */
    case WM_KEYDOWN:     /* MiD 08/14/95 */
    case WM_KEYDOWN:     /* MiD 08/14/95 */
        /*
        /*
        **   We have to process this message in order to show
        **   We have to process this message in order to show
        **   current selection in a static control for certain
        **   current selection in a static control for certain
        **   keys. This doesn't affect combobox with an edit
        **   keys. This doesn't affect combobox with an edit
        **   control, since the edit traps all key messages.
        **   control, since the edit traps all key messages.
        */
        */
        {
        {
        int nCur   = SendMessage(lp->ListBoxControl, LB_GETCURSEL,0, 0L);
        int nCur   = SendMessage(lp->ListBoxControl, LB_GETCURSEL,0, 0L);
        int nPrevCur = nCur;
        int nPrevCur = nCur;
        int nCount = SendMessage(lp->ListBoxControl, LB_GETCOUNT, 0, 0L);
        int nCount = SendMessage(lp->ListBoxControl, LB_GETCOUNT, 0, 0L);
 
 
        if (nCount == 0)
        if (nCount == 0)
           break;
           break;
 
 
        switch(wParam)
        switch(wParam)
            {
            {
            case VK_HOME:
            case VK_HOME:
               nCur = 0;
               nCur = 0;
               break;
               break;
 
 
            case VK_END:
            case VK_END:
               nCur = nCount - 1;
               nCur = nCount - 1;
               break;
               break;
 
 
            case VK_UP:
            case VK_UP:
               nCur--;
               nCur--;
               break;
               break;
 
 
            case VK_DOWN:
            case VK_DOWN:
               nCur++;
               nCur++;
               break;
               break;
 
 
            default:
            default:
              return 0L;
              return 0L;
            }
            }
 
 
        if (nCur >= nCount)
        if (nCur >= nCount)
           nCur = nCount - 1;
           nCur = nCount - 1;
        if (nCur < 0)
        if (nCur < 0)
           nCur = 0;
           nCur = 0;
 
 
        SendMessage(lp->ListBoxControl, LB_SETCURSEL, nCur, 0L);
        SendMessage(lp->ListBoxControl, LB_SETCURSEL, nCur, 0L);
        SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELCHANGE));
        SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELCHANGE));
        if (nCur != nPrevCur)
        if (nCur != nPrevCur)
/* ecw */  SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELENDOK));
/* ecw */  SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELENDOK));
        InvalidateRect(hWnd, NULL, 1);
        InvalidateRect(hWnd, NULL, 1);
        break;
        break;
        }
        }
#endif  /* WM_KEYDOWN */
#endif  /* WM_KEYDOWN */
 
 
    case WM_CHAR:
    case WM_CHAR:
        {
        {
        int nNewCur;
        int nNewCur;
        int nOldCur;
        int nOldCur;
 
 
        if (lp->EditControl)
        if (lp->EditControl)
           {
           {
           SendMessage(lp->EditControl, uMsg, wParam, lParam);
           SendMessage(lp->EditControl, uMsg, wParam, lParam);
           }
           }
        else {
        else {
             nOldCur = SendMessage(lp->ListBoxControl, LB_GETCURSEL,0, 0L);
             nOldCur = SendMessage(lp->ListBoxControl, LB_GETCURSEL,0, 0L);
             SendMessage(lp->ListBoxControl, uMsg, wParam, lParam);
             SendMessage(lp->ListBoxControl, uMsg, wParam, lParam);
             nNewCur = SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
             nNewCur = SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0L);
             if (nNewCur != nOldCur)
             if (nNewCur != nOldCur)
                {
                {
                SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELCHANGE));
                SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID, hWnd, CBN_SELCHANGE));
                InvalidateRect(hWnd, NULL, 1);
                InvalidateRect(hWnd, NULL, 1);
                }
                }
             }
             }
        break;
        break;
        }
        }
 
 
#if 0   /* jmt: fix: no WM_SETREDRAW */
#if 0   /* jmt: fix: no WM_SETREDRAW */
    case WM_SETREDRAW:
    case WM_SETREDRAW:
        lp->bRedraw = wParam;
        lp->bRedraw = wParam;
        if (lp->EditControl)
        if (lp->EditControl)
           SendMessage(lp->EditControl, WM_SETREDRAW, wParam, lParam);
           SendMessage(lp->EditControl, WM_SETREDRAW, wParam, lParam);
        if (lp->ListBoxControl)
        if (lp->ListBoxControl)
           SendMessage(lp->ListBoxControl, WM_SETREDRAW, wParam, lParam);
           SendMessage(lp->ListBoxControl, WM_SETREDRAW, wParam, lParam);
        break;
        break;
#endif        
#endif        
    case WM_CREATE: /*WM_NCCREATE:*/
    case WM_CREATE: /*WM_NCCREATE:*/
        lp = (COMBOBOX *)WinMalloc(sizeof(COMBOBOX));
        lp = (COMBOBOX *)WinMalloc(sizeof(COMBOBOX));
        memset((LPSTR)lp,'\0',sizeof(COMBOBOX));
        memset((LPSTR)lp,'\0',sizeof(COMBOBOX));
 
 
        /* save ptr to internal structure */
        /* save ptr to internal structure */
        hWnd->userdata=(DWORD)lp;       /* -SetWindowLong(hWnd, CWD_LPCBDATA, (LONG) lp); */
        hWnd->userdata=(DWORD)lp;       /* -SetWindowLong(hWnd, CWD_LPCBDATA, (LONG) lp); */
 
 
        /* this is for CreateWindow calls */
        /* this is for CreateWindow calls */
        hInst = NULL;   /* -GetWindowInstance(hWnd); */
        hInst = NULL;   /* -GetWindowInstance(hWnd); */
 
 
        /* fill in the internal structure */
        /* fill in the internal structure */
        lpcs = (LPCREATESTRUCT)lParam;
        lpcs = (LPCREATESTRUCT)lParam;
        lp->bRedraw = 1;
        lp->bRedraw = 1;
        lp->wStateFlags = 0;
        lp->wStateFlags = 0;
        lp->wStyle  = (UINT)LOWORD(lpcs->style);
        lp->wStyle  = (UINT)LOWORD(lpcs->style);
        if (!BOWNERDRAW(lp))
        if (!BOWNERDRAW(lp))
           lp->wStyle |= CBS_HASSTRINGS;
           lp->wStyle |= CBS_HASSTRINGS;
        lp->bExtended  = TRUE;
        lp->bExtended  = TRUE;
        lp->hFont = 0;
        lp->hFont = 0;
        lp->hWndParent = lpcs->hwndParent;
        lp->hWndParent = lpcs->hwndParent;
        lp->nID  = (UINT)lpcs->hMenu;
        lp->nID  = (UINT)lpcs->hMenu;
 
 
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
        /* calc the height of the edit/static control */
        /* calc the height of the edit/static control */
        if (0)   /* (BOWNERDRAW(lp)) */
        if (0)   /* (BOWNERDRAW(lp)) */
           {
           {
           mis.CtlType = ODT_COMBOBOX;
           mis.CtlType = ODT_COMBOBOX;
           mis.CtlID = (UINT)lpcs->hMenu;
           mis.CtlID = (UINT)lpcs->hMenu;
           mis.itemID = (UINT)-1;
           mis.itemID = (UINT)-1;
           mis.itemData = 0L;
           mis.itemData = 0L;
           SendMessage(lpcs->hwndParent, WM_MEASUREITEM, (WPARAM)lpcs->hMenu, (LPARAM)&mis);
           SendMessage(lpcs->hwndParent, WM_MEASUREITEM, (WPARAM)lpcs->hMenu, (LPARAM)&mis);
           /*** wEditHeight = (WORD)mis.itemHeight + 2; ***/
           /*** wEditHeight = (WORD)mis.itemHeight + 2; ***/
           }
           }
#endif  /* ownerdraw */
#endif  /* ownerdraw */
 
 
        /* get system font dimensions */
        /* get system font dimensions */
        hDC = GetDC((HWND)0);
        hDC = GetDC((HWND)0);
        GetTextMetrics(hDC,&tm);
        GetTextMetrics(hDC,&tm);
        ReleaseDC((HWND)0,hDC);
        ReleaseDC((HWND)0,hDC);
 
 
        /* allow different fonts to fit, don't hard code */
        /* allow different fonts to fit, don't hard code */
        /* otherwise big fonts won't fit. */
        /* otherwise big fonts won't fit. */
        /*****wEditHeight = ((tm.tmHeight - tm.tmInternalLeading)*7)/4;*****/
        /*****wEditHeight = ((tm.tmHeight - tm.tmInternalLeading)*7)/4;*****/
        wEditHeight = tm.tmHeight + tm.tmInternalLeading * 3;
        wEditHeight = tm.tmHeight + tm.tmInternalLeading * 3;
 
 
        lp->uHeight = (UINT)wEditHeight;
        lp->uHeight = (UINT)wEditHeight;
 
 
        if ((lp->wStyle & 0x0F) != CBS_SIMPLE)
        if ((lp->wStyle & 0x0F) != CBS_SIMPLE)
           {
           {
           lp->ButtonRect.top    = 0;
           lp->ButtonRect.top    = 0;
           lp->ButtonRect.left   = lpcs->cx - 1 - GetSystemMetrics(SM_CXVSCROLL);
           lp->ButtonRect.left   = lpcs->cx - 1 - GetSystemMetrics(SM_CXVSCROLL);
           lp->ButtonRect.right  = lpcs->cx;
           lp->ButtonRect.right  = lpcs->cx;
           lp->ButtonRect.bottom = wEditHeight;
           lp->ButtonRect.bottom = wEditHeight;
           /* for CBS_DROPDOWN/DROPDOWNLIST resize the window  */
           /* for CBS_DROPDOWN/DROPDOWNLIST resize the window  */
           SetWindowPos(hWnd, 0,
           SetWindowPos(hWnd, 0,
                        0, 0, lpcs->cx, (int)wEditHeight,
                        0, 0, lpcs->cx, (int)wEditHeight,
                        SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
                        SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
           }
           }
        else SetRectEmpty(&lp->ButtonRect);
        else SetRectEmpty(&lp->ButtonRect);
 
 
        if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
        if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
           {  /* EDIT field - calc edit control style */
           {  /* EDIT field - calc edit control style */
           dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER;
           dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER;
           if (lp->wStyle & CBS_AUTOHSCROLL)
           if (lp->wStyle & CBS_AUTOHSCROLL)
              dwStyle |= ES_AUTOHSCROLL;
              dwStyle |= ES_AUTOHSCROLL;
           if (lp->wStyle & CBS_OEMCONVERT)
           if (lp->wStyle & CBS_OEMCONVERT)
              dwStyle |= ES_OEMCONVERT;
              dwStyle |= ES_OEMCONVERT;
 
 
           if ((lp->wStyle & 0x0F) == CBS_SIMPLE)
           if ((lp->wStyle & 0x0F) == CBS_SIMPLE)
           {
           {
                fprintf(stderr," 528: wEditWidth = lpcs->cx=%d\n",lpcs->cx);
                fprintf(stderr," 528: wEditWidth = lpcs->cx=%d\n",lpcs->cx);
                wEditWidth = lpcs->cx;
                wEditWidth = lpcs->cx;
           }
           }
           else /* ?if ((lp->wStyle & 0xf) == CBS_DROPDOWN) */
           else /* ?if ((lp->wStyle & 0xf) == CBS_DROPDOWN) */
           {
           {
                fprintf(stderr," 533: wEditWidth = lp->ButtonRect.left - 5=%d;\n",lp->ButtonRect.left - 5);
                fprintf(stderr," 533: wEditWidth = lp->ButtonRect.left - 5=%d;\n",lp->ButtonRect.left - 5);
                wEditWidth = lp->ButtonRect.left - 5;
                wEditWidth = lp->ButtonRect.left - 5;
           }
           }
           /* create edit control */
           /* create edit control */
           lp->EditControl = CreateWindow("EDIT", NULL, dwStyle,
           lp->EditControl = CreateWindow("EDIT", NULL, dwStyle,
                                          0, 0, wEditWidth, wEditHeight,
                                          0, 0, wEditWidth, wEditHeight,
                                          hWnd, (HMENU)CBC_EDITID,
                                          hWnd, (HMENU)CBC_EDITID,
                                          hInst,(LPVOID)NULL);
                                          hInst,(LPVOID)NULL);
           }
           }
        else /* CBS_DROPDOWN -- static instead of edit */
        else /* CBS_DROPDOWN -- static instead of edit */
             lp->EditControl = 0;
             lp->EditControl = 0;
 
 
        /* listbox style */
        /* listbox style */
        /* jmt: fix: no WS_EX_SAVEBITS, WS_EX_NOCAPTURE, WS_EX_POPUPMENU */
        /* jmt: fix: no WS_EX_SAVEBITS, WS_EX_NOCAPTURE, WS_EX_POPUPMENU */
        dwExStyle = 0L; /* WS_EX_SAVEBITS | WS_EX_NOCAPTURE | WS_EX_POPUPMENU; */
        dwExStyle = 0L; /* WS_EX_SAVEBITS | WS_EX_NOCAPTURE | WS_EX_POPUPMENU; */
        dwStyle =   WS_BORDER | LBS_NOTIFY ; /* | LBS_COMBOLBOX; */
        dwStyle =   WS_BORDER | LBS_NOTIFY ; /* | LBS_COMBOLBOX; */
        if ((lp->wStyle & 0xf) == CBS_SIMPLE)
        if ((lp->wStyle & 0xf) == CBS_SIMPLE)
            dwStyle |= WS_VISIBLE | WS_CHILD;
            dwStyle |= WS_VISIBLE | WS_CHILD;
        else
        else
            dwStyle |= WS_POPUP;
            dwStyle |= WS_POPUP;
#if 0
#if 0
        if (lp->wStyle & CBS_DISABLENOSCROLL)
        if (lp->wStyle & CBS_DISABLENOSCROLL)
            dwStyle |= LBS_DISABLENOSCROLL;
            dwStyle |= LBS_DISABLENOSCROLL;
#endif
#endif
        if (lp->wStyle & CBS_HASSTRINGS)
        if (lp->wStyle & CBS_HASSTRINGS)
            dwStyle |= LBS_HASSTRINGS;
            dwStyle |= LBS_HASSTRINGS;
        if (lp->wStyle & CBS_NOINTEGRALHEIGHT)
        if (lp->wStyle & CBS_NOINTEGRALHEIGHT)
            dwStyle |= LBS_NOINTEGRALHEIGHT;
            dwStyle |= LBS_NOINTEGRALHEIGHT;
        if (lp->wStyle & CBS_OWNERDRAWFIXED)
        if (lp->wStyle & CBS_OWNERDRAWFIXED)
            dwStyle |= LBS_OWNERDRAWFIXED;
            dwStyle |= LBS_OWNERDRAWFIXED;
        if (lp->wStyle & CBS_OWNERDRAWVARIABLE)
        if (lp->wStyle & CBS_OWNERDRAWVARIABLE)
            dwStyle |= LBS_OWNERDRAWVARIABLE;
            dwStyle |= LBS_OWNERDRAWVARIABLE;
        if (lp->wStyle & CBS_SORT)
        if (lp->wStyle & CBS_SORT)
            dwStyle |= LBS_SORT;
            dwStyle |= LBS_SORT;
        if (lpcs->style & WS_VSCROLL)
        if (lpcs->style & WS_VSCROLL)
            dwStyle |= WS_VSCROLL;
            dwStyle |= WS_VSCROLL;
 
 
        /* calc listbox dimensions and position */
        /* calc listbox dimensions and position */
        if ((lp->wStyle & 0xf) == CBS_SIMPLE) {
        if ((lp->wStyle & 0xf) == CBS_SIMPLE) {
             lp->ListBoxRect.left = 5;
             lp->ListBoxRect.left = 5;
             lp->ListBoxRect.top = wEditHeight - 1;
             lp->ListBoxRect.top = wEditHeight - 1;
             lp->ListBoxRect.right = lpcs->cx;
             lp->ListBoxRect.right = lpcs->cx;
             lp->ListBoxRect.bottom = lpcs->cy - 2;
             lp->ListBoxRect.bottom = lpcs->cy - 2;
        } else {
        } else {
             lp->ListBoxRect.left = lpcs->x;
             lp->ListBoxRect.left = lpcs->x;
             lp->ListBoxRect.right = lp->ListBoxRect.left + lpcs->cx - 1;
             lp->ListBoxRect.right = lp->ListBoxRect.left + lpcs->cx - 1;
             lp->ListBoxRect.top = lpcs->y + wEditHeight - 1;
             lp->ListBoxRect.top = lpcs->y + wEditHeight - 1;
             lp->ListBoxRect.bottom = lp->ListBoxRect.top + lpcs->cy + 1;
             lp->ListBoxRect.bottom = lp->ListBoxRect.top + lpcs->cy + 1;
             if ((lp->wStyle & 0x0F) == CBS_DROPDOWN) {
             if ((lp->wStyle & 0x0F) == CBS_DROPDOWN) {
                lp->ListBoxRect.left += 5;
                lp->ListBoxRect.left += 5;
             }
             }
        }
        }
#ifdef LATER
#ifdef LATER
        cp.x = ((lp->wStyle & 0xf) == CBS_DROPDOWNLIST)?0:5;
        cp.x = ((lp->wStyle & 0xf) == CBS_DROPDOWNLIST)?0:5;
        cp.y = wEditHeight - 1;
        cp.y = wEditHeight - 1;
        if ((lp->wStyle & 0xf) != CBS_SIMPLE)
        if ((lp->wStyle & 0xf) != CBS_SIMPLE)
            ClientToScreen(hWnd,&cp);
            ClientToScreen(hWnd,&cp);
        lp->ListBoxRect.left = cp.x;
        lp->ListBoxRect.left = cp.x;
        lp->ListBoxRect.top =  cp.y;
        lp->ListBoxRect.top =  cp.y;
        lp->ListBoxRect.right = cp.x + lpcs->cx;
        lp->ListBoxRect.right = cp.x + lpcs->cx;
        if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
        if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
            lp->ListBoxRect.right -= 5;
            lp->ListBoxRect.right -= 5;
        lp->ListBoxRect.bottom = lp->ListBoxRect.top + lpcs->cy -
        lp->ListBoxRect.bottom = lp->ListBoxRect.top + lpcs->cy -
                wEditHeight + 1;
                wEditHeight + 1;
#endif
#endif
 
 
        lp->ListBoxControl = CreateWindowEx(dwExStyle,"LISTBOX",/*"COMBOLBOX",*/
        lp->ListBoxControl = CreateWindowEx(dwExStyle,"LISTBOX",/*"COMBOLBOX",*/
            NULL, dwStyle,
            NULL, dwStyle,
            lp->ListBoxRect.left, lp->ListBoxRect.top,
            lp->ListBoxRect.left, lp->ListBoxRect.top,
            lp->ListBoxRect.right - lp->ListBoxRect.left,
            lp->ListBoxRect.right - lp->ListBoxRect.left,
            lp->ListBoxRect.bottom - lp->ListBoxRect.top,
            lp->ListBoxRect.bottom - lp->ListBoxRect.top,
            hWnd, 0,
            hWnd, 0,
            hInst,(LPVOID)NULL);
            hInst,(LPVOID)NULL);
#if MWCLIENT
#if MWCLIENT
#if 0
#if 0
        GrLowerWindow(lp->ListBoxControl->wid);
        GrLowerWindow(lp->ListBoxControl->wid);
#endif
#endif
        MwLowerWindow(lp->ListBoxControl);
        MwLowerWindow(lp->ListBoxControl);
#endif           
#endif           
#ifdef  LATER
#ifdef  LATER
        /* Microsoft Word 6.0 wants to see COMBOLBOX on top */
        /* Microsoft Word 6.0 wants to see COMBOLBOX on top */
        /*  of Z-order... */
        /*  of Z-order... */
        if (dwStyle & WS_POPUP)
        if (dwStyle & WS_POPUP)
        {
        {
            SetWindowPos(lp->ListBoxControl, HWND_TOP,
            SetWindowPos(lp->ListBoxControl, HWND_TOP,
                         0, 0, 0, 0,
                         0, 0, 0, 0,
                         SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
                         SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE);
        }
        }
#endif
#endif
 
 
#if 0   /* jmt: fix: no HWND32(LPWININFO) */
#if 0   /* jmt: fix: no HWND32(LPWININFO) */
        /* physically expand client window,
        /* physically expand client window,
           if there is a scroll style
           if there is a scroll style
        */
        */
        if (lpcs->style & WS_VSCROLL)
        if (lpcs->style & WS_VSCROLL)
           {
           {
           HWND32 hWnd32 = GETHWND32(hWnd);
           HWND32 hWnd32 = GETHWND32(hWnd);
 
 
           SetRectEmpty(&hWnd32->rcNC);
           SetRectEmpty(&hWnd32->rcNC);
 
 
           hWnd32->wWidth = (WORD) hWnd32->rWnd.right-hWnd32->rWnd.left;
           hWnd32->wWidth = (WORD) hWnd32->rWnd.right-hWnd32->rWnd.left;
           hWnd32->wHeight = (WORD)hWnd32->rWnd.bottom-hWnd32->rWnd.top;
           hWnd32->wHeight = (WORD)hWnd32->rWnd.bottom-hWnd32->rWnd.top;
           RELEASEWININFO(hWnd32);
           RELEASEWININFO(hWnd32);
           }
           }
#endif
#endif
        /*
        /*
        **   Finally turn off border drawing and WM_?SCROLL styles to prevent creation
        **   Finally turn off border drawing and WM_?SCROLL styles to prevent creation
        **   of system scrollbars.
        **   of system scrollbars.
        */
        */
        dwStyle = GetWindowLong(hWnd, GWL_STYLE);
        dwStyle = GetWindowLong(hWnd, GWL_STYLE);
        dwStyle &= ~(WS_VSCROLL | WS_HSCROLL | WS_BORDER | WS_DLGFRAME | WS_THICKFRAME);
        dwStyle &= ~(WS_VSCROLL | WS_HSCROLL | WS_BORDER | WS_DLGFRAME | WS_THICKFRAME);
        SetWindowLong(hWnd, GWL_STYLE, dwStyle);
        SetWindowLong(hWnd, GWL_STYLE, dwStyle);
        lp->nListItems = 0;
        lp->nListItems = 0;
        return TRUE;
        return TRUE;
 
 
    case WM_DESTROY: /*WM_NCDESTROY:*/
    case WM_DESTROY: /*WM_NCDESTROY:*/
        if (IsWindow(lp->ListBoxControl))
        if (IsWindow(lp->ListBoxControl))
           DestroyWindow(lp->ListBoxControl);
           DestroyWindow(lp->ListBoxControl);
        if (IsWindow(lp->EditControl))
        if (IsWindow(lp->EditControl))
           DestroyWindow(lp->EditControl);
           DestroyWindow(lp->EditControl);
        WinFree((LPSTR)lp);
        WinFree((LPSTR)lp);
        return 0L;
        return 0L;
 
 
    case WM_GETDLGCODE:
    case WM_GETDLGCODE:
        return (LRESULT)(DLGC_WANTCHARS|DLGC_WANTARROWS);
        return (LRESULT)(DLGC_WANTCHARS|DLGC_WANTARROWS);
 
 
/* jmt: twine->mwin bug fixed: */
/* jmt: twine->mwin bug fixed: */
    case WM_NCLBUTTONDOWN:      /* jmt: a must */
    case WM_NCLBUTTONDOWN:      /* jmt: a must */
#if 0   /* twine->mw buggy */
#if 0   /* twine->mw buggy */
    case WM_LBUTTONDOWN:
    case WM_LBUTTONDOWN:
#endif
#endif
        if ((lp->wStyle & 0xf) == CBS_SIMPLE)
        if ((lp->wStyle & 0xf) == CBS_SIMPLE)
            break;
            break;
 
 
        cp.x = (int)(short)LOWORD(lParam);
        cp.x = (int)(short)LOWORD(lParam);
        cp.y = (int)(short)HIWORD(lParam);
        cp.y = (int)(short)HIWORD(lParam);
#if 1   /* WM_NCLBUTTONDOWM: */
#if 1   /* WM_NCLBUTTONDOWM: */
        ScreenToClient(hWnd, &cp);      /* jmt: a must */
        ScreenToClient(hWnd, &cp);      /* jmt: a must */
#endif
#endif
        if (!IS_SET(lp, CSF_CAPTUREACTIVE)) /* no listbox yet */
        if (!IS_SET(lp, CSF_CAPTUREACTIVE)) /* no listbox yet */
        {
        {
           /* click on a button or anywhere if it's dropdown combo */
           /* click on a button or anywhere if it's dropdown combo */
           if (PtInRect(&lp->ButtonRect, cp) ||
           if (PtInRect(&lp->ButtonRect, cp) ||
              (lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
              (lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)
              {
              {
              if (PtInRect(&lp->ButtonRect, cp))
              if (PtInRect(&lp->ButtonRect, cp))
                 CBoxDrawButton(hWnd, 1, lp);
                 CBoxDrawButton(hWnd, 1, lp);
 
 
              cp.x = ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST) ? 5 : 0;
              cp.x = ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST) ? 5 : 0;
              cp.y = lp->uHeight - 1;
              cp.y = lp->uHeight - 1;
 
 
              ClientToScreen(hWnd, &cp);
              ClientToScreen(hWnd, &cp);
 
 
              fprintf(stderr," (1)lp->ListBoxRect:(%d,%d,%d,%d)\n",
              fprintf(stderr," (1)lp->ListBoxRect:(%d,%d,%d,%d)\n",
                          lp->ListBoxRect.left,
                          lp->ListBoxRect.left,
                          lp->ListBoxRect.top,
                          lp->ListBoxRect.top,
                          lp->ListBoxRect.right,
                          lp->ListBoxRect.right,
                          lp->ListBoxRect.bottom);
                          lp->ListBoxRect.bottom);
 
 
              OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
              OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
 
 
              fprintf(stderr," (2)lp->ListBoxRect:(%d,%d,%d,%d)\n",
              fprintf(stderr," (2)lp->ListBoxRect:(%d,%d,%d,%d)\n",
                          lp->ListBoxRect.left,
                          lp->ListBoxRect.left,
                          lp->ListBoxRect.top,
                          lp->ListBoxRect.top,
                          lp->ListBoxRect.right,
                          lp->ListBoxRect.right,
                          lp->ListBoxRect.bottom);
                          lp->ListBoxRect.bottom);
 
 
              SetWindowPos(lp->ListBoxControl, HWND_TOP, /*0,*/
              SetWindowPos(lp->ListBoxControl, HWND_TOP, /*0,*/
                           cp.x, cp.y, 0, 0,
                           cp.x, cp.y, 0, 0,
                           SWP_NOSIZE | /*SWP_NOZORDER |*/ SWP_NOACTIVATE);
                           SWP_NOSIZE | /*SWP_NOZORDER |*/ SWP_NOACTIVATE);
 
 
              SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_DROPDOWN));
              SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_DROPDOWN));
              /*  ECW   added following conditional...  4/4/96 */
              /*  ECW   added following conditional...  4/4/96 */
              /*  JMT   following conditional is a must for microwindows  8/14/2k */
              /*  JMT   following conditional is a must for microwindows  8/14/2k */
              if (1)    /* -(!IS_SET(lp, CSF_HASDROPPED)) jmt: a must */
              if (1)    /* -(!IS_SET(lp, CSF_HASDROPPED)) jmt: a must */
              {
              {
                  /* ??first time it drops down, size it to hold all items?? */
                  /* ??first time it drops down, size it to hold all items?? */
 
 
                  int nitems = SendMessage(lp->ListBoxControl,LB_GETCOUNT,0,0L);
                  int nitems = SendMessage(lp->ListBoxControl,LB_GETCOUNT,0,0L);
#if 0
#if 0
                  /* resize if too small, in this case, also do too long */
                  /* resize if too small, in this case, also do too long */
                  if (lp->ListBoxRect.bottom - lp->ListBoxRect.top <
                  if (lp->ListBoxRect.bottom - lp->ListBoxRect.top <
                      ((lp->uHeight-2) * nitems))
                      ((lp->uHeight-2) * nitems))
                  {
                  {
#endif
#endif
                    nitems = (nitems > 12 ? 12 : nitems); /* a dozen, max */
                    nitems = (nitems > 12 ? 12 : nitems); /* a dozen, max */
 
 
#if 0   /* twine->mw buggy? */
#if 0   /* twine->mw buggy? */
                    lp->ListBoxRect.bottom =
                    lp->ListBoxRect.bottom =
                      lp->ListBoxRect.top + ((lp->uHeight-2) * nitems);
                      lp->ListBoxRect.top + ((lp->uHeight-2) * nitems);
#endif
#endif
                    fprintf(stderr," (2.5)lp->ListBoxRect:(%d,%d,%d,%d)\n",
                    fprintf(stderr," (2.5)lp->ListBoxRect:(%d,%d,%d,%d)\n",
                          lp->ListBoxRect.left,
                          lp->ListBoxRect.left,
                          lp->ListBoxRect.top,
                          lp->ListBoxRect.top,
                          lp->ListBoxRect.right,
                          lp->ListBoxRect.right,
                          lp->ListBoxRect.bottom);
                          lp->ListBoxRect.bottom);
 
 
/* jmt: twine->mwin bug fixed: */
/* jmt: twine->mwin bug fixed: */
                    fprintf(stderr," 706: fixed: SetWindowPos(lp->ListBoxControl,,%d,%d,...)\n",cp.x,cp.y);
                    fprintf(stderr," 706: fixed: SetWindowPos(lp->ListBoxControl,,%d,%d,...)\n",cp.x,cp.y);
#if 0   /* twine->mwin bug */
#if 0   /* twine->mwin bug */
                    SetWindowPos(lp->ListBoxControl,HWND_TOP,0,0,
                    SetWindowPos(lp->ListBoxControl,HWND_TOP,0,0,
                                 lp->ListBoxRect.right - lp->ListBoxRect.left,
                                 lp->ListBoxRect.right - lp->ListBoxRect.left,
                                 lp->ListBoxRect.bottom - lp->ListBoxRect.top,
                                 lp->ListBoxRect.bottom - lp->ListBoxRect.top,
                                 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
                                 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
#else   /* jmt: twine->mwin bug fixed: */
#else   /* jmt: twine->mwin bug fixed: */
                    SetWindowPos(lp->ListBoxControl,HWND_TOP,cp.x,cp.y,
                    SetWindowPos(lp->ListBoxControl,HWND_TOP,cp.x,cp.y,
                                 lp->ListBoxRect.right - lp->ListBoxRect.left,
                                 lp->ListBoxRect.right - lp->ListBoxRect.left,
                                 lp->ListBoxRect.bottom - lp->ListBoxRect.top,
                                 lp->ListBoxRect.bottom - lp->ListBoxRect.top,
                                 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
                                 SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
#endif
#endif
 
 
#if 0
#if 0
                  }
                  }
#endif
#endif
                  SET_STATE(lp, CSF_HASDROPPED);
                  SET_STATE(lp, CSF_HASDROPPED);
              }
              }
              /*  End of addition */
              /*  End of addition */
              ShowWindow(lp->ListBoxControl, SW_SHOW);
              ShowWindow(lp->ListBoxControl, SW_SHOW);
#if 0   /* orig(twine) */
#if 0   /* orig(twine) */
              SetFocus(lp->ListBoxControl);
              SetFocus(lp->ListBoxControl);
#else   /* jmt: mwclient */
#else   /* jmt: mwclient */
              SetForegroundWindow(lp->ListBoxControl);
              SetForegroundWindow(lp->ListBoxControl);
#endif
#endif
              CBoxCapture(hWnd, 1);
              CBoxCapture(hWnd, 1);
              SET_STATE(lp, CSF_CAPTUREACTIVE);
              SET_STATE(lp, CSF_CAPTUREACTIVE);
              SET_STATE(lp, CSF_BUTTONDOWN);
              SET_STATE(lp, CSF_BUTTONDOWN);
              }
              }
        }
        }
        else
        else
        { /* there is a listbox visible */
        { /* there is a listbox visible */
             HWND hwndNewFocus = 0;
             HWND hwndNewFocus = 0;
 
 
             cpScreen = cp;
             cpScreen = cp;
 
 
             if ((lp->wStyle & 0xf) != CBS_SIMPLE)
             if ((lp->wStyle & 0xf) != CBS_SIMPLE)
             {
             {
                ClientToScreen(hWnd, &cpScreen);
                ClientToScreen(hWnd, &cpScreen);
                hwndNewFocus = WindowFromPoint(cpScreen);
                hwndNewFocus = WindowFromPoint(cpScreen);
             }
             }
 
 
             fprintf(stderr," (3)lp->ListBoxRect:(%d,%d,%d,%d)\n",
             fprintf(stderr," (3)lp->ListBoxRect:(%d,%d,%d,%d)\n",
                          lp->ListBoxRect.left,
                          lp->ListBoxRect.left,
                          lp->ListBoxRect.top,
                          lp->ListBoxRect.top,
                          lp->ListBoxRect.right,
                          lp->ListBoxRect.right,
                          lp->ListBoxRect.bottom);
                          lp->ListBoxRect.bottom);
 
 
             if (PtInRect(&lp->ListBoxRect, cpScreen))
             if (PtInRect(&lp->ListBoxRect, cpScreen))
             {
             {
                CBoxSendMouseToLBox(lp, WM_LBUTTONDOWN, wParam, cpScreen);
                CBoxSendMouseToLBox(lp, WM_LBUTTONDOWN, wParam, cpScreen);
             }
             }
             else
             else
             {
             {
                  if (PtInRect(&lp->ButtonRect, cp))
                  if (PtInRect(&lp->ButtonRect, cp))
                     CBoxDrawButton(hWnd, 0, lp);
                     CBoxDrawButton(hWnd, 0, lp);
                  if ((lp->wStyle & 0x0F) == CBS_DROPDOWN && hwndNewFocus == lp->EditControl)
                  if ((lp->wStyle & 0x0F) == CBS_DROPDOWN && hwndNewFocus == lp->EditControl)
                     /* don't close listbox */;
                     /* don't close listbox */;
                  else {
                  else {
                       SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
                       SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
 
 
                       fprintf(stderr," 802: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
                       fprintf(stderr," 802: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
 
 
                       SetWindowPos(lp->ListBoxControl, 0,
                       SetWindowPos(lp->ListBoxControl, 0,
                               0, 0, 0, 0,
                               0, 0, 0, 0,
                               SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
                               SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
#if MWCLIENT
#if MWCLIENT
                       MwLowerWindow(lp->ListBoxControl);
                       MwLowerWindow(lp->ListBoxControl);
#endif
#endif
                       CBoxCapture(hWnd, 0);
                       CBoxCapture(hWnd, 0);
                       CLEAR_STATE(lp, CSF_BUTTONDOWN);
                       CLEAR_STATE(lp, CSF_BUTTONDOWN);
                       }
                       }
                  CLEAR_STATE(lp, CSF_CAPTUREACTIVE);
                  CLEAR_STATE(lp, CSF_CAPTUREACTIVE);
 
 
                  if (hwndNewFocus && hwndNewFocus != hWnd)
                  if (hwndNewFocus && hwndNewFocus != hWnd)
                  {
                  {
                     ScreenToClient(hwndNewFocus, &cpScreen);
                     ScreenToClient(hwndNewFocus, &cpScreen);
                     SetFocus(hwndNewFocus);
                     SetFocus(hwndNewFocus);
 
 
                     SendMessage(hwndNewFocus, WM_LBUTTONDOWN, wParam, MAKELONG(cpScreen.x, cpScreen.y));
                     SendMessage(hwndNewFocus, WM_LBUTTONDOWN, wParam, MAKELONG(cpScreen.x, cpScreen.y));
                  }
                  }
              } /* !(PtInRect(&lp->ListBoxRect, cpScreen)) */
              } /* !(PtInRect(&lp->ListBoxRect, cpScreen)) */
         }
         }
        break;
        break;
 
 
/* jmt: twine->mwin bug fixed: */
/* jmt: twine->mwin bug fixed: */
    case WM_NCMOUSEMOVE:
    case WM_NCMOUSEMOVE:
#if 0   /* jmt: twine->mw buggy */
#if 0   /* jmt: twine->mw buggy */
    case WM_MOUSEMOVE:
    case WM_MOUSEMOVE:
#endif
#endif
        if (!IS_SET(lp,CSF_BUTTONDOWN) && ((lp->wStyle & 0xf) == CBS_SIMPLE))
        if (!IS_SET(lp,CSF_BUTTONDOWN) && ((lp->wStyle & 0xf) == CBS_SIMPLE))
            break;
            break;
 
 
        cp.x = (int)(short)LOWORD(lParam);
        cp.x = (int)(short)LOWORD(lParam);
        cp.y = (int)(short)HIWORD(lParam);
        cp.y = (int)(short)HIWORD(lParam);
#if 1   /* WM_NCMOUSEMOVE: */
#if 1   /* WM_NCMOUSEMOVE: */
        ScreenToClient(hWnd, &cp);      /* jmt: a must */
        ScreenToClient(hWnd, &cp);      /* jmt: a must */
#endif
#endif
 
 
        if (IS_SET(lp, CSF_CAPTUREACTIVE))
        if (IS_SET(lp, CSF_CAPTUREACTIVE))
           {
           {
           if (PtInRect(&lp->ButtonRect,cp))
           if (PtInRect(&lp->ButtonRect,cp))
              {
              {
              if (!IS_SET(lp, CSF_LOCALBUTTONDOWN))
              if (!IS_SET(lp, CSF_LOCALBUTTONDOWN))
                 CBoxDrawButton(hWnd, 1, lp);
                 CBoxDrawButton(hWnd, 1, lp);
              break;
              break;
              }
              }
           if ((lp->wStyle & 0xf) != CBS_SIMPLE)
           if ((lp->wStyle & 0xf) != CBS_SIMPLE)
              ClientToScreen(hWnd,&cp);
              ClientToScreen(hWnd,&cp);
           if (PtInRect(&lp->ListBoxRect,cp))
           if (PtInRect(&lp->ListBoxRect,cp))
              {
              {
              CBoxSendMouseToLBox(lp,WM_MOUSEMOVE,wParam,cp);
              CBoxSendMouseToLBox(lp,WM_MOUSEMOVE,wParam,cp);
              }
              }
           if (IS_SET(lp,CSF_LOCALBUTTONDOWN) && ((lp->wStyle & 0xf) != CBS_SIMPLE))
           if (IS_SET(lp,CSF_LOCALBUTTONDOWN) && ((lp->wStyle & 0xf) != CBS_SIMPLE))
              CBoxDrawButton(hWnd,0,lp);
              CBoxDrawButton(hWnd,0,lp);
           }
           }
        break;
        break;
 
 
/* jmt: twine->mwin bug fixed: */
/* jmt: twine->mwin bug fixed: */
    case WM_NCLBUTTONUP:
    case WM_NCLBUTTONUP:
#if 0   /* twine->mw buggy */
#if 0   /* twine->mw buggy */
    case WM_LBUTTONUP:
    case WM_LBUTTONUP:
#endif
#endif
        if (!IS_SET(lp, CSF_CAPTUREACTIVE))
        if (!IS_SET(lp, CSF_CAPTUREACTIVE))
            break;
            break;
 
 
        cp.x = (int)(short)LOWORD(lParam);
        cp.x = (int)(short)LOWORD(lParam);
        cp.y = (int)(short)HIWORD(lParam);
        cp.y = (int)(short)HIWORD(lParam);
#if 1   /* WM_NCLBUTTONUP */
#if 1   /* WM_NCLBUTTONUP */
        ScreenToClient(hWnd, &cp);      /* jmt: a must */
        ScreenToClient(hWnd, &cp);      /* jmt: a must */
#endif
#endif
 
 
        CLEAR_STATE(lp,CSF_BUTTONDOWN);
        CLEAR_STATE(lp,CSF_BUTTONDOWN);
 
 
        if (PtInRect(&lp->ButtonRect, cp))
        if (PtInRect(&lp->ButtonRect, cp))
           /*(lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)*/
           /*(lp->wStyle & 0x0F) == CBS_DROPDOWNLIST)*/
           {
           {
           if (PtInRect(&lp->ButtonRect, cp))
           if (PtInRect(&lp->ButtonRect, cp))
               CBoxDrawButton(hWnd, 0, lp);
               CBoxDrawButton(hWnd, 0, lp);
           if (IS_SET(lp, CSF_LBOXBUTTONDOWN))
           if (IS_SET(lp, CSF_LBOXBUTTONDOWN))
              {
              {
              if ((lp->wStyle & 0xf) != CBS_SIMPLE)
              if ((lp->wStyle & 0xf) != CBS_SIMPLE)
                 ClientToScreen(hWnd, &cp);
                 ClientToScreen(hWnd, &cp);
              CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
              CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
              CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
              CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
              }
              }
           break;
           break;
           }
           }
        if ((lp->wStyle & 0xf) != CBS_SIMPLE)
        if ((lp->wStyle & 0xf) != CBS_SIMPLE)
           ClientToScreen(hWnd, &cp);
           ClientToScreen(hWnd, &cp);
 
 
        if (PtInRect(&lp->ListBoxRect, cp))
        if (PtInRect(&lp->ListBoxRect, cp))
           {
           {
           uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
           uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
           if (uiKey != (UINT)LB_ERR)
           if (uiKey != (UINT)LB_ERR)
              {
              {
              if (lp->EditControl)
              if (lp->EditControl)
                 {
                 {
                 SetFocus(lp->EditControl);
                 SetFocus(lp->EditControl);
 
 
                 CBoxDrawEdit(lp, hWnd, uiKey);
                 CBoxDrawEdit(lp, hWnd, uiKey);
                 }
                 }
              else {
              else {
                   SetFocus(hWnd);
                   SetFocus(hWnd);
 
 
                   CBoxDrawStatic(lp, hWnd, uiKey);
                   CBoxDrawStatic(lp, hWnd, uiKey);
                   }
                   }
 
 
              /*  LATER check the WS_EX_NOPARENTNOTIFY bit in ext style.*/
              /*  LATER check the WS_EX_NOPARENTNOTIFY bit in ext style.*/
/* ecw */     SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_SELENDOK));
/* ecw */     SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_SELENDOK));
              SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
              SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
 
 
              fprintf(stderr," 844: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
              fprintf(stderr," 844: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
 
 
              SetWindowPos(lp->ListBoxControl, 0,
              SetWindowPos(lp->ListBoxControl, 0,
                           0, 0, 0, 0,
                           0, 0, 0, 0,
                           SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
                           SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
 
 
              CBoxCapture(hWnd, 0);
              CBoxCapture(hWnd, 0);
              CLEAR_STATE(lp,CSF_CAPTUREACTIVE);
              CLEAR_STATE(lp,CSF_CAPTUREACTIVE);
              } /* uiKey ok */
              } /* uiKey ok */
 
 
           CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
           CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
           CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
           CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
#if MWCLIENT
#if MWCLIENT
#if 0
#if 0
           GrLowerWindow(lp->ListBoxControl->wid);
           GrLowerWindow(lp->ListBoxControl->wid);
#endif
#endif
           MwLowerWindow(lp->ListBoxControl);
           MwLowerWindow(lp->ListBoxControl);
#endif
#endif
           }
           }
        else /* clicked somewhere outside button or listbox -
        else /* clicked somewhere outside button or listbox -
             ** the listbox should stay intact... MiD
             ** the listbox should stay intact... MiD
             */
             */
             if (IS_SET(lp, CSF_LBOXBUTTONDOWN))
             if (IS_SET(lp, CSF_LBOXBUTTONDOWN))
                {
                {
                if ((lp->wStyle & 0xf) != CBS_SIMPLE)
                if ((lp->wStyle & 0xf) != CBS_SIMPLE)
                   ClientToScreen(hWnd, &cp);
                   ClientToScreen(hWnd, &cp);
                CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
                CBoxSendMouseToLBox(lp, WM_LBUTTONUP, wParam, cp);
                CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
                CLEAR_STATE(lp,CSF_LBOXBUTTONDOWN);
                }
                }
        break;
        break;
 
 
    case WM_ERASEBKGND:
    case WM_ERASEBKGND:
        return 1L;
        return 1L;
 
 
    case WM_PAINT:
    case WM_PAINT:
        BeginPaint(hWnd,&ps);
        BeginPaint(hWnd,&ps);
        EndPaint(hWnd,&ps);
        EndPaint(hWnd,&ps);
 
 
        if (!IsWindowVisible(hWnd) || !lp->bRedraw)
        if (!IsWindowVisible(hWnd) || !lp->bRedraw)
           return 0L;
           return 0L;
 
 
        if ((lp->wStyle & 0xf) != CBS_SIMPLE)
        if ((lp->wStyle & 0xf) != CBS_SIMPLE)
           CBoxDrawButton(hWnd, IS_SET(lp,CSF_LOCALBUTTONDOWN), lp);
           CBoxDrawButton(hWnd, IS_SET(lp,CSF_LOCALBUTTONDOWN), lp);
        uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
        uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
        if (lp->EditControl)
        if (lp->EditControl)
           CBoxDrawEdit(lp, hWnd, uiKey);
           CBoxDrawEdit(lp, hWnd, uiKey);
        else CBoxDrawStatic(lp, hWnd, uiKey);
        else CBoxDrawStatic(lp, hWnd, uiKey);
        return 0L;
        return 0L;
 
 
    case WM_COMMAND:
    case WM_COMMAND:
        if (GET_WM_COMMAND_ID(wParam,lParam) == CBC_EDITID) {
        if (GET_WM_COMMAND_ID(wParam,lParam) == CBC_EDITID) {
            /* edit/static control notifications */
            /* edit/static control notifications */
            switch((short)GET_WM_COMMAND_CMD(wParam,lParam)) {
            switch((short)GET_WM_COMMAND_CMD(wParam,lParam)) {
            case EN_SETFOCUS:
            case EN_SETFOCUS:
#ifdef  LATER
#ifdef  LATER
                wCBN = CBN_SETFOCUS;
                wCBN = CBN_SETFOCUS;
#else
#else
                wCBN = 0;
                wCBN = 0;
#endif
#endif
                break;
                break;
            case EN_KILLFOCUS:
            case EN_KILLFOCUS:
                wCBN = CBN_KILLFOCUS;
                wCBN = CBN_KILLFOCUS;
                break;
                break;
            case EN_CHANGE:
            case EN_CHANGE:
                {
                {
                int  index = 0;
                int  index = 0;
                char sz[128];
                char sz[128];
                /*
                /*
                **   Advance listbox
                **   Advance listbox
                **   selection until there is string match. One first mismatch
                **   selection until there is string match. One first mismatch
                **   listbox advances to its first item.
                **   listbox advances to its first item.
                */
                */
                SendMessage(lp->EditControl, WM_GETTEXT, sizeof(sz)-1, (LPARAM)sz);
                SendMessage(lp->EditControl, WM_GETTEXT, sizeof(sz)-1, (LPARAM)sz);
                if (/*l*/strlen(sz) > 0/*L*/)
                if (/*l*/strlen(sz) > 0/*L*/)
                   index = (int)SendMessage(lp->ListBoxControl, LB_FINDSTRING, -1, (LPARAM)sz);
                   index = (int)SendMessage(lp->ListBoxControl, LB_FINDSTRING, -1, (LPARAM)sz);
                if (index == LB_ERR)
                if (index == LB_ERR)
                   index = 0;
                   index = 0;
                SendMessage(lp->ListBoxControl, LB_SETTOPINDEX, index, 0L);
                SendMessage(lp->ListBoxControl, LB_SETTOPINDEX, index, 0L);
                wCBN = CBN_EDITCHANGE;
                wCBN = CBN_EDITCHANGE;
                break;
                break;
                }
                }
            case EN_UPDATE:
            case EN_UPDATE:
                wCBN = CBN_EDITUPDATE;
                wCBN = CBN_EDITUPDATE;
                break;
                break;
            case EN_ERRSPACE:
            case EN_ERRSPACE:
                wCBN = CBN_ERRSPACE;
                wCBN = CBN_ERRSPACE;
                break;
                break;
            default:
            default:
                wCBN = 0;
                wCBN = 0;
                break;
                break;
            }
            }
            if (wCBN)
            if (wCBN)
            return SendMessage(lp->hWndParent,WM_COMMAND,
            return SendMessage(lp->hWndParent,WM_COMMAND,
                GET_WM_COMMAND_MPS(lp->nID,hWnd,wCBN));
                GET_WM_COMMAND_MPS(lp->nID,hWnd,wCBN));
            else
            else
            return rc;
            return rc;
        }
        }
        if (GET_WM_COMMAND_ID(wParam,lParam) == 0) {
        if (GET_WM_COMMAND_ID(wParam,lParam) == 0) {
            /* listbox notifications */
            /* listbox notifications */
            switch ((short)GET_WM_COMMAND_CMD(wParam,lParam)) {
            switch ((short)GET_WM_COMMAND_CMD(wParam,lParam)) {
            case LBN_ERRSPACE:
            case LBN_ERRSPACE:
                wCBN = CBN_ERRSPACE;
                wCBN = CBN_ERRSPACE;
                break;
                break;
            case LBN_SELCHANGE:
            case LBN_SELCHANGE:
                if ((lp->wStyle & 0xf) == CBS_SIMPLE)
                if ((lp->wStyle & 0xf) == CBS_SIMPLE)
                   {
                   {
                   uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
                   uiKey = (UINT)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
                   if (uiKey != (UINT)LB_ERR)
                   if (uiKey != (UINT)LB_ERR)
                      if (lp->EditControl)
                      if (lp->EditControl)
                         {
                         {
                         CBoxDrawEdit(lp, hWnd, uiKey);
                         CBoxDrawEdit(lp, hWnd, uiKey);
                         }
                         }
                   }
                   }
                wCBN = CBN_SELCHANGE;
                wCBN = CBN_SELCHANGE;
                break;
                break;
            case LBN_DBLCLK:
            case LBN_DBLCLK:
                wCBN = CBN_DBLCLK;
                wCBN = CBN_DBLCLK;
                break;
                break;
            case LBN_SELCANCEL: /* TODO */
            case LBN_SELCANCEL: /* TODO */
                wCBN = 0;
                wCBN = 0;
                break;
                break;
            case LBN_SETFOCUS:
            case LBN_SETFOCUS:
                wCBN = CBN_SETFOCUS;
                wCBN = CBN_SETFOCUS;
                break;
                break;
            case LBN_KILLFOCUS:
            case LBN_KILLFOCUS:
                wCBN = CBN_KILLFOCUS;
                wCBN = CBN_KILLFOCUS;
                break;
                break;
            default:
            default:
                wCBN = 0;
                wCBN = 0;
                break;
                break;
            }
            }
            if (wCBN)
            if (wCBN)
               return SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,wCBN));
               return SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,wCBN));
            else
            else
            return rc;
            return rc;
            }
            }
        break;
        break;
 
 
    case WM_GETTEXT:
    case WM_GETTEXT:
        if ( lp->EditControl )
        if ( lp->EditControl )
            return SendMessage(lp->EditControl,uMsg,wParam,lParam);
            return SendMessage(lp->EditControl,uMsg,wParam,lParam);
        else if ( lp->ListBoxControl ) {
        else if ( lp->ListBoxControl ) {
            WPARAM sel, len;
            WPARAM sel, len;
 
 
            sel = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
            sel = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
            if ( sel != (WPARAM)LB_ERR ) {
            if ( sel != (WPARAM)LB_ERR ) {
                len = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, 0, 0);
                len = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, 0, 0);
                if ( len <= wParam )
                if ( len <= wParam )
                    return SendMessage(lp->ListBoxControl, LB_GETTEXT, sel, lParam);
                    return SendMessage(lp->ListBoxControl, LB_GETTEXT, sel, lParam);
            }
            }
        }
        }
        return CB_ERR;
        return CB_ERR;
 
 
    case WM_GETTEXTLENGTH:
    case WM_GETTEXTLENGTH:
        if ( lp->EditControl )
        if ( lp->EditControl )
            return SendMessage(lp->EditControl,uMsg,wParam,lParam);
            return SendMessage(lp->EditControl,uMsg,wParam,lParam);
        else if ( lp->ListBoxControl ) {
        else if ( lp->ListBoxControl ) {
            WPARAM sel;
            WPARAM sel;
 
 
            sel = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
            sel = (WPARAM)SendMessage(lp->ListBoxControl, LB_GETCURSEL, 0, 0);
            if ( sel != (WPARAM)LB_ERR )
            if ( sel != (WPARAM)LB_ERR )
                return SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, sel, 0);
                return SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, sel, 0);
        }
        }
        return CB_ERR;
        return CB_ERR;
 
 
    case WM_SETTEXT:
    case WM_SETTEXT:
        if ( lp->EditControl )
        if ( lp->EditControl )
            return SendMessage(lp->EditControl,uMsg,wParam,lParam);
            return SendMessage(lp->EditControl,uMsg,wParam,lParam);
        return CB_ERR;
        return CB_ERR;
 
 
#if 0   /* jmt: fix: no WM_SETFONT/WM_GETFONT */
#if 0   /* jmt: fix: no WM_SETFONT/WM_GETFONT */
    case WM_SETFONT:
    case WM_SETFONT:
        lp->hFont = (HFONT)wParam;
        lp->hFont = (HFONT)wParam;
 
 
        hDC = GetDC(hWnd);
        hDC = GetDC(hWnd);
        SelectObject(hDC,lp->hFont);
        SelectObject(hDC,lp->hFont);
        GetTextMetrics(hDC,&tm);
        GetTextMetrics(hDC,&tm);
        ReleaseDC(hWnd,hDC);
        ReleaseDC(hWnd,hDC);
        wEditHeight = tm.tmHeight + 3 * tm.tmInternalLeading;
        wEditHeight = tm.tmHeight + 3 * tm.tmInternalLeading;
 
 
        if (wEditHeight == lp->uHeight)
        if (wEditHeight == lp->uHeight)
            return 0L;
            return 0L;
 
 
        lp->uHeight = (UINT)wEditHeight;
        lp->uHeight = (UINT)wEditHeight;
        lp->ButtonRect.bottom = wEditHeight;
        lp->ButtonRect.bottom = wEditHeight;
        /*
        /*
        **   The following SetWindowPos causes WM_WINDOWPOSCHANGING message
        **   The following SetWindowPos causes WM_WINDOWPOSCHANGING message
        **   where child windows are resized and/or moved.
        **   where child windows are resized and/or moved.
        */
        */
        ShowWindow(hWnd, SW_HIDE);
        ShowWindow(hWnd, SW_HIDE);
        GetClientRect(hWnd,&rcClient);
        GetClientRect(hWnd,&rcClient);
        if ((lp->wStyle & 0xf) != CBS_SIMPLE)
        if ((lp->wStyle & 0xf) != CBS_SIMPLE)
           SetWindowPos(hWnd, 0,
           SetWindowPos(hWnd, 0,
                        0, 0, rcClient.right, (int)wEditHeight,
                        0, 0, rcClient.right, (int)wEditHeight,
                        SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
                        SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
        else SetWindowPos(hWnd, 0,
        else SetWindowPos(hWnd, 0,
                          0, 0, rcClient.right, (int)wEditHeight + lp->ListBoxRect.bottom - lp->ListBoxRect.top + 1,
                          0, 0, rcClient.right, (int)wEditHeight + lp->ListBoxRect.bottom - lp->ListBoxRect.top + 1,
                          SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
                          SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
        ShowWindow(hWnd, SW_SHOWNA);
        ShowWindow(hWnd, SW_SHOWNA);
 
 
        if (lp->EditControl)
        if (lp->EditControl)
           SendMessage(lp->EditControl, WM_SETFONT, wParam,lParam);
           SendMessage(lp->EditControl, WM_SETFONT, wParam,lParam);
        SendMessage(lp->ListBoxControl, WM_SETFONT, wParam,lParam);
        SendMessage(lp->ListBoxControl, WM_SETFONT, wParam,lParam);
 
 
        if(LOWORD(lParam))
        if(LOWORD(lParam))
            RedrawWindow(hWnd,(const RECT *)0,(HRGN)0,
            RedrawWindow(hWnd,(const RECT *)0,(HRGN)0,
            RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
            RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
        return (LRESULT)0;
        return (LRESULT)0;
 
 
    case WM_GETFONT:
    case WM_GETFONT:
        return lp->hFont;
        return lp->hFont;
#endif  /* WM_SETFONT/WM_GETFONT */
#endif  /* WM_SETFONT/WM_GETFONT */
 
 
    case WM_MOVE: /*WM_WINDOWPOSCHANGING:*/
    case WM_MOVE: /*WM_WINDOWPOSCHANGING:*/
#if 0
#if 0
        lpwp = (LPWINDOWPOS)lParam;
        lpwp = (LPWINDOWPOS)lParam;
#else
#else
        pp.x=LOWORD(lParam);
        pp.x=LOWORD(lParam);
        pp.y=HIWORD(lParam);
        pp.y=HIWORD(lParam);
#endif
#endif
        if (1)/*(lpwp)*/ {
        if (1)/*(lpwp)*/ {
        if (1)/*(!(lpwp->flags & SWP_NOSIZE))*/ {
        if (1)/*(!(lpwp->flags & SWP_NOSIZE))*/ {
            lp->ButtonRect.right  = (hWnd->winrect.right-hWnd->winrect.left);   /* lpwp->cx; */
            lp->ButtonRect.right  = (hWnd->winrect.right-hWnd->winrect.left);   /* lpwp->cx; */
            if ((lp->wStyle & 0xf) == CBS_SIMPLE)
            if ((lp->wStyle & 0xf) == CBS_SIMPLE)
               lp->ButtonRect.left = lp->ButtonRect.right;
               lp->ButtonRect.left = lp->ButtonRect.right;
            else lp->ButtonRect.left = (hWnd->winrect.right-hWnd->winrect.left)/*lpwp->cx*/ - 1 -
            else lp->ButtonRect.left = (hWnd->winrect.right-hWnd->winrect.left)/*lpwp->cx*/ - 1 -
                    GetSystemMetrics(SM_CXVSCROLL);
                    GetSystemMetrics(SM_CXVSCROLL);
 
 
            if (lp->EditControl)
            if (lp->EditControl)
               {
               {
               wEditWidth = lp->ButtonRect.left + 1;
               wEditWidth = lp->ButtonRect.left + 1;
               if ((lp->wStyle & 0xf) == CBS_SIMPLE)
               if ((lp->wStyle & 0xf) == CBS_SIMPLE)
                  wEditWidth --;
                  wEditWidth --;
               if ((lp->wStyle & 0xf) == CBS_DROPDOWN)
               if ((lp->wStyle & 0xf) == CBS_DROPDOWN)
                  wEditWidth -= 5;
                  wEditWidth -= 5;
               SetWindowPos(lp->EditControl,(HWND)0,
               SetWindowPos(lp->EditControl,(HWND)0,
                            0,0,
                            0,0,
                            wEditWidth, lp->uHeight,
                            wEditWidth, lp->uHeight,
                            SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
                            SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
               }
               }
            if (lp->ListBoxControl)
            if (lp->ListBoxControl)
               {
               {
               if ((lp->wStyle & 0x0F) == CBS_SIMPLE)
               if ((lp->wStyle & 0x0F) == CBS_SIMPLE)
                  {
                  {
                  lp->ListBoxRect.left = 5;
                  lp->ListBoxRect.left = 5;
                  lp->ListBoxRect.top = lp->uHeight - 1;
                  lp->ListBoxRect.top = lp->uHeight - 1;
                  lp->ListBoxRect.right = (hWnd->winrect.right-hWnd->winrect.left);     /* lpwp->cx; */
                  lp->ListBoxRect.right = (hWnd->winrect.right-hWnd->winrect.left);     /* lpwp->cx; */
                  lp->ListBoxRect.bottom = (hWnd->winrect.bottom-hWnd->winrect.top)/*lpwp->cy*/ - 2;
                  lp->ListBoxRect.bottom = (hWnd->winrect.bottom-hWnd->winrect.top)/*lpwp->cy*/ - 2;
                  }
                  }
               else {
               else {
                    POINT cp;
                    POINT cp;
                    cp.x = 0;
                    cp.x = 0;
                    cp.y = lp->uHeight - 1;
                    cp.y = lp->uHeight - 1;
                    ClientToScreen(hWnd, &cp);
                    ClientToScreen(hWnd, &cp);
                    OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
                    OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
 
 
                    lp->ListBoxRect.right = lp->ListBoxRect.left + (hWnd->winrect.right-hWnd->winrect.left)/*lpwp->cx*/;
                    lp->ListBoxRect.right = lp->ListBoxRect.left + (hWnd->winrect.right-hWnd->winrect.left)/*lpwp->cx*/;
                    if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
                    if ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST)
                       lp->ListBoxRect.right -= 5;
                       lp->ListBoxRect.right -= 5;
                    }
                    }
 
 
               SetWindowPos(lp->ListBoxControl,(HWND)0,
               SetWindowPos(lp->ListBoxControl,(HWND)0,
                            lp->ListBoxRect.left, lp->ListBoxRect.top,
                            lp->ListBoxRect.left, lp->ListBoxRect.top,
                            lp->ListBoxRect.right - lp->ListBoxRect.left,
                            lp->ListBoxRect.right - lp->ListBoxRect.left,
                            lp->ListBoxRect.bottom - lp->ListBoxRect.top,
                            lp->ListBoxRect.bottom - lp->ListBoxRect.top,
                            SWP_NOACTIVATE|SWP_NOZORDER);
                            SWP_NOACTIVATE|SWP_NOZORDER);
               }
               }
#if 0   /* jmt: fix: no WM_WINDOWPOSCHANGING */
#if 0   /* jmt: fix: no WM_WINDOWPOSCHANGING */
            /* the height of the normal state stays the same */
            /* the height of the normal state stays the same */
            if ((lp->wStyle & 0xf) != CBS_SIMPLE)
            if ((lp->wStyle & 0xf) != CBS_SIMPLE)
               lpwp->cy = (int)lp->uHeight;
               lpwp->cy = (int)lp->uHeight;
#endif
#endif
            }
            }
        }
        }
        return (LRESULT)0;
        return (LRESULT)0;
 
 
    case WM_WINDOWPOSCHANGED:
    case WM_WINDOWPOSCHANGED:
        DefWindowProc(hWnd,uMsg,wParam,lParam);
        DefWindowProc(hWnd,uMsg,wParam,lParam);
        lpwp = (LPWINDOWPOS)lParam;
        lpwp = (LPWINDOWPOS)lParam;
        if (lpwp) {
        if (lpwp) {
                if (!(lpwp->flags & SWP_NOSIZE)) /* TODO */
                if (!(lpwp->flags & SWP_NOSIZE)) /* TODO */
#if 0
#if 0
                        RedrawWindow(hWnd,(const RECT *)0,(HRGN)0,
                        RedrawWindow(hWnd,(const RECT *)0,(HRGN)0,
                                RDW_INVALIDATE|RDW_ERASE);
                                RDW_INVALIDATE|RDW_ERASE);
#else
#else
                        InvalidateRect(hWnd,NULL,TRUE);
                        InvalidateRect(hWnd,NULL,TRUE);
#endif
#endif
        }
        }
        return (LRESULT)0;
        return (LRESULT)0;
 
 
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
    /*********************************************/
    /*********************************************/
    /* ownerdraw stuff               */
    /* ownerdraw stuff               */
    /*********************************************/
    /*********************************************/
    case WM_DRAWITEM:
    case WM_DRAWITEM:
        lpdis = (LPDRAWITEMSTRUCT)lParam;
        lpdis = (LPDRAWITEMSTRUCT)lParam;
        lpdis->CtlType = ODT_COMBOBOX;
        lpdis->CtlType = ODT_COMBOBOX;
        lpdis->CtlID = lp->nID;
        lpdis->CtlID = lp->nID;
        lpdis->hwndItem = hWnd;
        lpdis->hwndItem = hWnd;
        return SendMessage(lp->hWndParent,WM_DRAWITEM,
        return SendMessage(lp->hWndParent,WM_DRAWITEM,
                (WPARAM)lp->nID,lParam);
                (WPARAM)lp->nID,lParam);
 
 
    case WM_MEASUREITEM:
    case WM_MEASUREITEM:
        lpmis = (LPMEASUREITEMSTRUCT)lParam;
        lpmis = (LPMEASUREITEMSTRUCT)lParam;
        lpmis->CtlType = ODT_COMBOBOX;
        lpmis->CtlType = ODT_COMBOBOX;
        lpmis->CtlID = lp->nID;
        lpmis->CtlID = lp->nID;
        return SendMessage(lp->hWndParent,WM_MEASUREITEM,
        return SendMessage(lp->hWndParent,WM_MEASUREITEM,
                (WPARAM)lp->nID,lParam);
                (WPARAM)lp->nID,lParam);
 
 
    case WM_DELETEITEM:
    case WM_DELETEITEM:
        lpdlis = (LPDELETEITEMSTRUCT)lParam;
        lpdlis = (LPDELETEITEMSTRUCT)lParam;
        lpdlis->CtlType = ODT_COMBOBOX;
        lpdlis->CtlType = ODT_COMBOBOX;
        lpdlis->CtlID = lp->nID;
        lpdlis->CtlID = lp->nID;
        lpdlis->hwndItem = hWnd;
        lpdlis->hwndItem = hWnd;
        return SendMessage(lp->hWndParent,WM_DELETEITEM,
        return SendMessage(lp->hWndParent,WM_DELETEITEM,
                (WPARAM)lp->nID,lParam);
                (WPARAM)lp->nID,lParam);
 
 
    case WM_CONVERT:
    case WM_CONVERT:
        if (!lpComboBinToNat) {
        if (!lpComboBinToNat) {
                hComboClass32 = FindClass("COMBOBOX",0);
                hComboClass32 = FindClass("COMBOBOX",0);
                lpComboBinToNat = (WNDPROC)GetClassHandleLong(
                lpComboBinToNat = (WNDPROC)GetClassHandleLong(
                        hComboClass32,GCL_BINTONAT);
                        hComboClass32,GCL_BINTONAT);
        }
        }
        if (lpComboBinToNat)
        if (lpComboBinToNat)
        return lpComboBinToNat(hWnd, uMsg, wParam, lParam);
        return lpComboBinToNat(hWnd, uMsg, wParam, lParam);
        else
        else
        return (LRESULT)0;
        return (LRESULT)0;
#endif  /* ownerdraw */
#endif  /* ownerdraw */
 
 
    default:
    default:
        return DefCBProc( hWnd, uMsg, wParam, lParam);
        return DefCBProc( hWnd, uMsg, wParam, lParam);
    }
    }
    return rc;
    return rc;
}
}
 
 
/************************************************************************
/************************************************************************
**
**
************************************************************************/
************************************************************************/
static LRESULT DefCBProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static LRESULT DefCBProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
{
    int       len,index;
    int       len,index;
    COMBOBOX *lp;
    COMBOBOX *lp;
    char     *selection;
    char     *selection;
    int   rc;
    int   rc;
    POINT   cp;
    POINT   cp;
 
 
    lp = (COMBOBOX *) hWnd->userdata/*GetWindowLong(hWnd,CWD_LPCBDATA)*/;
    lp = (COMBOBOX *) hWnd->userdata/*GetWindowLong(hWnd,CWD_LPCBDATA)*/;
    switch(uMsg) {
    switch(uMsg) {
        /*********************************************/
        /*********************************************/
        /* messages specific to the list box control */
        /* messages specific to the list box control */
        /*********************************************/
        /*********************************************/
        case CB_ADDSTRING:
        case CB_ADDSTRING:
            lp->nListItems++;  /* shd. test for successful return */
            lp->nListItems++;  /* shd. test for successful return */
            return SendMessage(lp->ListBoxControl,LB_ADDSTRING,
            return SendMessage(lp->ListBoxControl,LB_ADDSTRING,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_DELETESTRING:
        case CB_DELETESTRING:
            if (lp->nListItems)
            if (lp->nListItems)
              lp->nListItems--;
              lp->nListItems--;
            return SendMessage(lp->ListBoxControl,LB_DELETESTRING,
            return SendMessage(lp->ListBoxControl,LB_DELETESTRING,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_DIR:
        case CB_DIR:
            return SendMessage(lp->ListBoxControl,LB_DIR,
            return SendMessage(lp->ListBoxControl,LB_DIR,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_FINDSTRING:
        case CB_FINDSTRING:
            return SendMessage(lp->ListBoxControl,LB_FINDSTRING,
            return SendMessage(lp->ListBoxControl,LB_FINDSTRING,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_FINDSTRINGEXACT:
        case CB_FINDSTRINGEXACT:
               return SendMessage(lp->ListBoxControl,LB_FINDSTRINGEXACT,
               return SendMessage(lp->ListBoxControl,LB_FINDSTRINGEXACT,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_GETCOUNT:
        case CB_GETCOUNT:
            return SendMessage(lp->ListBoxControl,LB_GETCOUNT,
            return SendMessage(lp->ListBoxControl,LB_GETCOUNT,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_GETCURSEL:
        case CB_GETCURSEL:
            return SendMessage(lp->ListBoxControl,LB_GETCURSEL,
            return SendMessage(lp->ListBoxControl,LB_GETCURSEL,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_GETITEMDATA:
        case CB_GETITEMDATA:
            return SendMessage(lp->ListBoxControl,LB_GETITEMDATA,
            return SendMessage(lp->ListBoxControl,LB_GETITEMDATA,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_GETITEMHEIGHT:
        case CB_GETITEMHEIGHT:
            return SendMessage(lp->ListBoxControl,LB_GETITEMHEIGHT,
            return SendMessage(lp->ListBoxControl,LB_GETITEMHEIGHT,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_GETLBTEXT:
        case CB_GETLBTEXT:
            return SendMessage(lp->ListBoxControl,LB_GETTEXT,
            return SendMessage(lp->ListBoxControl,LB_GETTEXT,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_GETLBTEXTLEN:
        case CB_GETLBTEXTLEN:
            return SendMessage(lp->ListBoxControl,LB_GETTEXTLEN,
            return SendMessage(lp->ListBoxControl,LB_GETTEXTLEN,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_INSERTSTRING:
        case CB_INSERTSTRING:
            return SendMessage(lp->ListBoxControl,LB_INSERTSTRING,
            return SendMessage(lp->ListBoxControl,LB_INSERTSTRING,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_SETITEMDATA:
        case CB_SETITEMDATA:
            return SendMessage(lp->ListBoxControl,LB_SETITEMDATA,
            return SendMessage(lp->ListBoxControl,LB_SETITEMDATA,
                wParam,lParam);
                wParam,lParam);
 
 
        /*********************************************/
        /*********************************************/
        /* messages specific to the edit control */
        /* messages specific to the edit control */
        /*********************************************/
        /*********************************************/
        case CB_GETEDITSEL:
        case CB_GETEDITSEL:
            return SendMessage(lp->EditControl,EM_GETSEL,0,0);
            return SendMessage(lp->EditControl,EM_GETSEL,0,0);
 
 
        case CB_LIMITTEXT:
        case CB_LIMITTEXT:
            return SendMessage(lp->EditControl,EM_LIMITTEXT,
            return SendMessage(lp->EditControl,EM_LIMITTEXT,
                wParam,lParam);
                wParam,lParam);
 
 
        case CB_SETEDITSEL:
        case CB_SETEDITSEL:
            return SendMessage(lp->EditControl,EM_SETSEL,
            return SendMessage(lp->EditControl,EM_SETSEL,
                wParam,lParam);
                wParam,lParam);
 
 
        /*********************************************/
        /*********************************************/
        /* messages handled by the combobox          */
        /* messages handled by the combobox          */
        /*********************************************/
        /*********************************************/
        case CB_GETDROPPEDCONTROLRECT:
        case CB_GETDROPPEDCONTROLRECT:
            CopyRect((LPRECT)lParam,&lp->ListBoxRect);
            CopyRect((LPRECT)lParam,&lp->ListBoxRect);
            break;
            break;
        case CB_GETDROPPEDSTATE:
        case CB_GETDROPPEDSTATE:
            return IS_SET(lp,CSF_CAPTUREACTIVE);
            return IS_SET(lp,CSF_CAPTUREACTIVE);
 
 
        case CB_GETEXTENDEDUI:
        case CB_GETEXTENDEDUI:
            return (LRESULT)lp->bExtended;
            return (LRESULT)lp->bExtended;
 
 
        case CB_RESETCONTENT:
        case CB_RESETCONTENT:
            SendMessage(lp->ListBoxControl,LB_RESETCONTENT,0,0);
            SendMessage(lp->ListBoxControl,LB_RESETCONTENT,0,0);
            if (lp->EditControl)
            if (lp->EditControl)
               SendMessage(lp->EditControl,WM_SETTEXT,0,(LPARAM)(LPSTR)"");
               SendMessage(lp->EditControl,WM_SETTEXT,0,(LPARAM)(LPSTR)"");
            break;
            break;
 
 
        case CB_SELECTSTRING:
        case CB_SELECTSTRING:
            index = (int)SendMessage(lp->ListBoxControl, LB_SELECTSTRING, wParam, lParam);
            index = (int)SendMessage(lp->ListBoxControl, LB_SELECTSTRING, wParam, lParam);
            if (index == LB_ERR)
            if (index == LB_ERR)
               return CB_ERR;
               return CB_ERR;
 
 
            len = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, index, 0);
            len = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, index, 0);
            if (len <= 0)
            if (len <= 0)
               return CB_ERR;
               return CB_ERR;
 
 
            selection = (LPSTR)WinMalloc((UINT)len+1);
            selection = (LPSTR)WinMalloc((UINT)len+1);
            rc = (int)SendMessage(lp->ListBoxControl, LB_GETTEXT, (WPARAM)index, (LPARAM)selection);
            rc = (int)SendMessage(lp->ListBoxControl, LB_GETTEXT, (WPARAM)index, (LPARAM)selection);
            if (lp->EditControl)
            if (lp->EditControl)
               rc = (int)SendMessage(lp->EditControl, WM_SETTEXT, 0, (LPARAM)selection);
               rc = (int)SendMessage(lp->EditControl, WM_SETTEXT, 0, (LPARAM)selection);
            else CBoxDrawStatic(lp, hWnd, index);
            else CBoxDrawStatic(lp, hWnd, index);
            WinFree(selection);
            WinFree(selection);
            break;
            break;
 
 
        case CB_SETCURSEL:
        case CB_SETCURSEL:
            rc = (int)SendMessage(lp->ListBoxControl, LB_SETCURSEL, wParam, lParam);
            rc = (int)SendMessage(lp->ListBoxControl, LB_SETCURSEL, wParam, lParam);
            if (rc == LB_ERR)
            if (rc == LB_ERR)
               return CB_ERR;
               return CB_ERR;
            len = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, wParam, 0);
            len = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, wParam, 0);
            if (len <= 0)
            if (len <= 0)
               return CB_ERR;
               return CB_ERR;
 
 
            selection = (LPSTR)WinMalloc((UINT)len+1);
            selection = (LPSTR)WinMalloc((UINT)len+1);
            rc = (int)SendMessage(lp->ListBoxControl, LB_GETTEXT, wParam, (LPARAM)selection);
            rc = (int)SendMessage(lp->ListBoxControl, LB_GETTEXT, wParam, (LPARAM)selection);
            if (lp->EditControl)
            if (lp->EditControl)
               rc = (int)SendMessage(lp->EditControl, WM_SETTEXT, 0, (LPARAM)selection);
               rc = (int)SendMessage(lp->EditControl, WM_SETTEXT, 0, (LPARAM)selection);
            else CBoxDrawStatic(lp, hWnd, wParam);
            else CBoxDrawStatic(lp, hWnd, wParam);
            WinFree(selection);
            WinFree(selection);
            return (LRESULT)wParam;
            return (LRESULT)wParam;
 
 
        case CB_SETEXTENDEDUI:
        case CB_SETEXTENDEDUI:
            lp->bExtended = (BOOL)wParam;
            lp->bExtended = (BOOL)wParam;
            break;
            break;
 
 
        case CB_SETITEMHEIGHT:      /* TODO */
        case CB_SETITEMHEIGHT:      /* TODO */
            break;
            break;
 
 
        case CB_SHOWDROPDOWN:
        case CB_SHOWDROPDOWN:
            if ((lp->wStyle & 0xf) == CBS_SIMPLE)
            if ((lp->wStyle & 0xf) == CBS_SIMPLE)
                return 1L;
                return 1L;
            if (wParam)
            if (wParam)
            {
            {
               if (IS_SET(lp,CSF_CAPTUREACTIVE))
               if (IS_SET(lp,CSF_CAPTUREACTIVE))
                  return 1L;
                  return 1L;
 
 
               cp.x = ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST) ? 5 : 0;
               cp.x = ((lp->wStyle & 0xf) != CBS_DROPDOWNLIST) ? 5 : 0;
               cp.y = lp->uHeight -1;
               cp.y = lp->uHeight -1;
 
 
               ClientToScreen(hWnd, &cp);
               ClientToScreen(hWnd, &cp);
               OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
               OffsetRect(&lp->ListBoxRect, cp.x - lp->ListBoxRect.left, cp.y - lp->ListBoxRect.top);
 
 
               SetWindowPos(lp->ListBoxControl, 0,
               SetWindowPos(lp->ListBoxControl, 0,
                            cp.x, cp.y, 0, 0,
                            cp.x, cp.y, 0, 0,
                            SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
                            SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
 
 
               SendMessage(lp->hWndParent,WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_DROPDOWN));
               SendMessage(lp->hWndParent,WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_DROPDOWN));
 
 
               fprintf(stderr," 1330: SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
               fprintf(stderr," 1330: SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
 
 
               SetWindowPos(lp->ListBoxControl, HWND_TOP,
               SetWindowPos(lp->ListBoxControl, HWND_TOP,
                            0, 0, 0, 0,
                            0, 0, 0, 0,
                            SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
                            SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
 
 
                CBoxCapture(hWnd, 1);
                CBoxCapture(hWnd, 1);
                SET_STATE(lp,CSF_CAPTUREACTIVE);
                SET_STATE(lp,CSF_CAPTUREACTIVE);
             }
             }
            else
            else
            {
            {
                 if (!IS_SET(lp,CSF_CAPTUREACTIVE))
                 if (!IS_SET(lp,CSF_CAPTUREACTIVE))
                    return 1L;
                    return 1L;
 
 
                 SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
                 SendMessage(lp->hWndParent, WM_COMMAND, GET_WM_COMMAND_MPS(lp->nID,hWnd,CBN_CLOSEUP));
/* test: */
/* test: */
                 fprintf(stderr," 1343: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
                 fprintf(stderr," 1343: (hide) SetWindowPos(lp->ListBoxControl, , 0, 0, 0, 0,..)\n");
 
 
                 SetWindowPos(lp->ListBoxControl, 0,
                 SetWindowPos(lp->ListBoxControl, 0,
                              0, 0, 0, 0,
                              0, 0, 0, 0,
                              SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
                              SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_HIDEWINDOW);
 
 
                 CBoxCapture(hWnd, 0);
                 CBoxCapture(hWnd, 0);
                 CLEAR_STATE(lp, CSF_CAPTUREACTIVE);
                 CLEAR_STATE(lp, CSF_CAPTUREACTIVE);
             }
             }
            return 1L;
            return 1L;
 
 
        /*********************************************/
        /*********************************************/
        /* messages handled by the defwindowproc.... */
        /* messages handled by the defwindowproc.... */
        /*********************************************/
        /*********************************************/
        default:
        default:
            return DefWindowProc( hWnd, uMsg, wParam, lParam);
            return DefWindowProc( hWnd, uMsg, wParam, lParam);
    }
    }
    return CB_OKAY;
    return CB_OKAY;
}
}
 
 
 
 
static void
static void
CBoxDrawButton(HWND hWnd,UINT wState,COMBOBOX *lp)
CBoxDrawButton(HWND hWnd,UINT wState,COMBOBOX *lp)
{
{
    HDC       hDC;
    HDC       hDC;
    int     x,y;
    int     x,y;
    int     dx,dy;
    int     dx,dy;
#if 0   /* jmt: fix: no LoadBitmap() */
#if 0   /* jmt: fix: no LoadBitmap() */
    int     cx,cy;
    int     cx,cy;
    static int nWidth,nHeight;
    static int nWidth,nHeight;
    BITMAP    bmpCombo;
    BITMAP    bmpCombo;
    static HBITMAP hbmpCombo = 0;
    static HBITMAP hbmpCombo = 0;
    HBITMAP   hbmpOld = 0;
    HBITMAP   hbmpOld = 0;
    HDC       hdcSrc;
    HDC       hdcSrc;
    COLORREF  rgbText, rgbBk;
    COLORREF  rgbText, rgbBk;
#endif
#endif
    HBRUSH    hBrush;
    HBRUSH    hBrush;
    HPEN      hPenHigh,hPenShadow;
    HPEN      hPenHigh,hPenShadow;
    RECT      rc;
    RECT      rc;
 
 
    hDC = GetDC(hWnd);
    hDC = GetDC(hWnd);
 
 
    CopyRect(&rc,&lp->ButtonRect);
    CopyRect(&rc,&lp->ButtonRect);
    x = rc.left;
    x = rc.left;
    y = rc.top;
    y = rc.top;
    dx = rc.right;
    dx = rc.right;
    dy = rc.bottom;
    dy = rc.bottom;
 
 
    hPenHigh = GetStockObject(WHITE_PEN);
    hPenHigh = GetStockObject(WHITE_PEN);
#if 0
#if 0
    hPenShadow = GetSysColorPen(COLOR_BTNSHADOW);
    hPenShadow = GetSysColorPen(COLOR_BTNSHADOW);
#else
#else
    hPenShadow = CreatePen(PS_SOLID,1,GetSysColor(COLOR_BTNSHADOW));
    hPenShadow = CreatePen(PS_SOLID,1,GetSysColor(COLOR_BTNSHADOW));
#endif
#endif
#if 0
#if 0
    hBrush = GetSysColorBrush(COLOR_BTNFACE);
    hBrush = GetSysColorBrush(COLOR_BTNFACE);
#else
#else
    hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
    hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
#endif
#endif
    FillRect(hDC, &rc, hBrush);
    FillRect(hDC, &rc, hBrush);
#if 0
#if 0
    hBrush = GetStockObject(BLACK_BRUSH);
    hBrush = GetStockObject(BLACK_BRUSH);
    FillRect/*FrameRect*/(hDC, &lp->ButtonRect, hBrush);
    FillRect/*FrameRect*/(hDC, &lp->ButtonRect, hBrush);
#else
#else
    SelectObject(hDC,GetStockObject(BLACK_PEN));
    SelectObject(hDC,GetStockObject(BLACK_PEN));
    Rectangle(hDC,lp->ButtonRect.left,lp->ButtonRect.top,lp->ButtonRect.right,lp->ButtonRect.bottom);
    Rectangle(hDC,lp->ButtonRect.left,lp->ButtonRect.top,lp->ButtonRect.right,lp->ButtonRect.bottom);
#endif
#endif
    rc.left += 1; rc.right -= 1;
    rc.left += 1; rc.right -= 1;
    rc.top += 1; rc.bottom -= 1;
    rc.top += 1; rc.bottom -= 1;
 
 
    Draw3DButtonRect(hDC,hPenHigh,hPenShadow,rc,wState);
    Draw3DButtonRect(hDC,hPenHigh,hPenShadow,rc,wState);
 
 
#if 0   /* jmt: fix: no LoadBitmap(),GetObject() */
#if 0   /* jmt: fix: no LoadBitmap(),GetObject() */
    if (hbmpCombo == 0)
    if (hbmpCombo == 0)
       {
       {
       hbmpCombo = LoadBitmap(0,(LPSTR)OBM_COMBO);
       hbmpCombo = LoadBitmap(0,(LPSTR)OBM_COMBO);
       GetObject(hbmpCombo, sizeof(BITMAP), (LPVOID)&bmpCombo);
       GetObject(hbmpCombo, sizeof(BITMAP), (LPVOID)&bmpCombo);
       nWidth  = bmpCombo.bmWidth;
       nWidth  = bmpCombo.bmWidth;
       nHeight = bmpCombo.bmHeight;
       nHeight = bmpCombo.bmHeight;
       }
       }
   /*
   /*
   **   MiD 08/15/95 changed to mono bitmap as it is in Windows. Convert
   **   MiD 08/15/95 changed to mono bitmap as it is in Windows. Convert
   **                it to colors on the fly
   **                it to colors on the fly
   */
   */
   hdcSrc = CreateCompatibleDC(hDC);
   hdcSrc = CreateCompatibleDC(hDC);
   hbmpOld = SelectObject(hdcSrc, hbmpCombo);
   hbmpOld = SelectObject(hdcSrc, hbmpCombo);
   /*
   /*
   **   Source hdc ok. Prepare the target hdc, then BitBlt to it.
   **   Source hdc ok. Prepare the target hdc, then BitBlt to it.
   */
   */
   rgbText = SetTextColor(hDC,GetSysColor(COLOR_BTNTEXT));
   rgbText = SetTextColor(hDC,GetSysColor(COLOR_BTNTEXT));
   rgbBk = SetBkColor(hDC,GetSysColor(COLOR_BTNFACE));
   rgbBk = SetBkColor(hDC,GetSysColor(COLOR_BTNFACE));
 
 
   cx = (dx - x - nWidth)/2;
   cx = (dx - x - nWidth)/2;
   cy = (dy - y - nHeight)/2;
   cy = (dy - y - nHeight)/2;
   if (wState)
   if (wState)
      {  cx++; cy++;  }
      {  cx++; cy++;  }
   BitBlt(hDC, x+cx, y+cy, nWidth, nHeight, hdcSrc, 0, 0, SRCCOPY);
   BitBlt(hDC, x+cx, y+cy, nWidth, nHeight, hdcSrc, 0, 0, SRCCOPY);
 
 
   SetTextColor(hDC, rgbText);
   SetTextColor(hDC, rgbText);
   SetBkColor(hDC, rgbBk);
   SetBkColor(hDC, rgbBk);
   SelectObject(hdcSrc,hbmpOld);
   SelectObject(hdcSrc,hbmpOld);
   DeleteDC(hdcSrc);
   DeleteDC(hdcSrc);
#endif  /* BitBlt Bitmap */
#endif  /* BitBlt Bitmap */
#if 1
#if 1
   DeleteObject(hBrush);
   DeleteObject(hBrush);
   DeleteObject(hPenShadow);
   DeleteObject(hPenShadow);
#endif
#endif
   ReleaseDC(hWnd,hDC);
   ReleaseDC(hWnd,hDC);
 
 
    if (wState)
    if (wState)
        SET_STATE(lp,CSF_LOCALBUTTONDOWN);
        SET_STATE(lp,CSF_LOCALBUTTONDOWN);
    else
    else
        CLEAR_STATE(lp,CSF_LOCALBUTTONDOWN);
        CLEAR_STATE(lp,CSF_LOCALBUTTONDOWN);
}
}
 
 
#if 0   /* jmt: fix: no COMBOLBOX */
#if 0   /* jmt: fix: no COMBOLBOX */
/************************************************************************
/************************************************************************
**
**
************************************************************************/
************************************************************************/
LRESULT DefCOMBOLBOXProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
LRESULT DefCOMBOLBOXProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
{
#if 0
#if 0
    return DefLISTBOXProc(hWnd, msg, wParam,lParam);
    return DefLISTBOXProc(hWnd, msg, wParam,lParam);
#endif
#endif
    return ListboxCtrlProc(hWnd, msg, wParam,lParam);
    return ListboxCtrlProc(hWnd, msg, wParam,lParam);
}
}
#endif
#endif
 
 
/************************************************************************
/************************************************************************
**
**
************************************************************************/
************************************************************************/
static void CBoxSendMouseToLBox(COMBOBOX *lp, UINT uiMsg, WPARAM wParam, POINT ptScreen)
static void CBoxSendMouseToLBox(COMBOBOX *lp, UINT uiMsg, WPARAM wParam, POINT ptScreen)
{
{
    POINT pt;
    POINT pt;
    int nNCHit;
    int nNCHit;
#if 0   /* jmt: fix: no scrollbar */
#if 0   /* jmt: fix: no scrollbar */
    HWND hWndScroll;
    HWND hWndScroll;
#endif
#endif
    pt = ptScreen;
    pt = ptScreen;
    ScreenToClient(lp->ListBoxControl,&pt);
    ScreenToClient(lp->ListBoxControl,&pt);
 
 
    nNCHit = LOSHORT(SendMessage(lp->ListBoxControl, WM_NCHITTEST, 0, MAKELPARAM(ptScreen.x,ptScreen.y)));
    nNCHit = LOSHORT(SendMessage(lp->ListBoxControl, WM_NCHITTEST, 0, MAKELPARAM(ptScreen.x,ptScreen.y)));
 
 
    switch (nNCHit)
    switch (nNCHit)
       {
       {
       case HTCLIENT:
       case HTCLIENT:
           if (uiMsg == WM_MOUSEMOVE && !IS_SET(lp,CSF_LBOXBUTTONDOWN))
           if (uiMsg == WM_MOUSEMOVE && !IS_SET(lp,CSF_LBOXBUTTONDOWN))
              {
              {
              SendMessage(lp->ListBoxControl, WM_LBUTTONDOWN, 0, MAKELONG((WORD)pt.x,(WORD)pt.y));
              SendMessage(lp->ListBoxControl, WM_LBUTTONDOWN, 0, MAKELONG((WORD)pt.x,(WORD)pt.y));
 
 
              SET_STATE(lp, CSF_BUTTONDOWN | CSF_LBOXBUTTONDOWN);
              SET_STATE(lp, CSF_BUTTONDOWN | CSF_LBOXBUTTONDOWN);
              }
              }
           SendMessage(lp->ListBoxControl, uiMsg, wParam, MAKELONG((WORD)pt.x,(WORD)pt.y));
           SendMessage(lp->ListBoxControl, uiMsg, wParam, MAKELONG((WORD)pt.x,(WORD)pt.y));
           break;
           break;
 
 
#if 0   /* jmt: fix: no scrollbar */
#if 0   /* jmt: fix: no scrollbar */
       case HTVSCROLL:
       case HTVSCROLL:
           if (0 != (hWndScroll = TWIN_ConvertToSysScroll(lp->ListBoxControl, TRUE /* vertical */, &pt)))
           if (0 != (hWndScroll = TWIN_ConvertToSysScroll(lp->ListBoxControl, TRUE /* vertical */, &pt)))
              SendMessage(hWndScroll, uiMsg, wParam, MAKELONG((WORD)pt.x,(WORD)pt.y));
              SendMessage(hWndScroll, uiMsg, wParam, MAKELONG((WORD)pt.x,(WORD)pt.y));
           break;
           break;
#endif           
#endif           
       default:
       default:
           break;
           break;
    }
    }
}
}
 
 
/************************************************************************
/************************************************************************
**
**
************************************************************************/
************************************************************************/
static void CBoxCapture(HWND hWnd, WORD wFunc)
static void CBoxCapture(HWND hWnd, WORD wFunc)
{
{
    static HWND hWndCapture = (HWND)0;
    static HWND hWndCapture = (HWND)0;
 
 
    if (wFunc)
    if (wFunc)
       {
       {
       hWndCapture = SetCapture(hWnd);
       hWndCapture = SetCapture(hWnd);
 
 
       SetFocus(hWnd);
       SetFocus(hWnd);
       }
       }
    else {
    else {
         if (!hWndCapture)
         if (!hWndCapture)
            ReleaseCapture();
            ReleaseCapture();
         else {
         else {
#ifdef  LATER
#ifdef  LATER
              SetCapture(hWndCapture);
              SetCapture(hWndCapture);
#else
#else
              ReleaseCapture();
              ReleaseCapture();
#endif
#endif
              hWndCapture = (HWND)0;
              hWndCapture = (HWND)0;
              }
              }
         }
         }
}
}
 
 
/************************************************************************
/************************************************************************
**
**
************************************************************************/
************************************************************************/
static void CBoxDrawEdit(COMBOBOX *lp, HWND hWnd, UINT uiKey)
static void CBoxDrawEdit(COMBOBOX *lp, HWND hWnd, UINT uiKey)
{
{
    int    nLen;
    int    nLen;
    LPVOID lpData;
    LPVOID lpData;
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
    HRGN   hRgn;
    HRGN   hRgn;
    DRAWITEMSTRUCT dis;
    DRAWITEMSTRUCT dis;
#endif
#endif
/*
/*
    if (uiKey == (UINT)LB_ERR)
    if (uiKey == (UINT)LB_ERR)
       return;
       return;
 
 
    if (!BOWNERDRAW(lp))
    if (!BOWNERDRAW(lp))
*/
*/
    if (lp->wStyle & CBS_HASSTRINGS)
    if (lp->wStyle & CBS_HASSTRINGS)
       {
       {
       if (uiKey == (UINT)LB_ERR)
       if (uiKey == (UINT)LB_ERR)
          return;
          return;
       nLen = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, uiKey, 0L);
       nLen = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, uiKey, 0L);
       if (nLen <= 0)
       if (nLen <= 0)
           return;
           return;
       lpData = (LPVOID)WinMalloc(nLen+1);
       lpData = (LPVOID)WinMalloc(nLen+1);
       SendMessage(lp->ListBoxControl, LB_GETTEXT, uiKey, (LPARAM)lpData);
       SendMessage(lp->ListBoxControl, LB_GETTEXT, uiKey, (LPARAM)lpData);
       SendMessage(lp->EditControl, WM_SETTEXT, strlen(lpData), (LPARAM)lpData);
       SendMessage(lp->EditControl, WM_SETTEXT, strlen(lpData), (LPARAM)lpData);
       Edit_SetSel(lp->EditControl, 0, -1);
       Edit_SetSel(lp->EditControl, 0, -1);
       WinFree((LPSTR)lpData);
       WinFree((LPSTR)lpData);
       }
       }
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
    else {
    else {
         dis.CtlType = ODT_COMBOBOX;
         dis.CtlType = ODT_COMBOBOX;
         dis.CtlID = (UINT)lp->nID;
         dis.CtlID = (UINT)lp->nID;
         dis.itemID = -1; /* used to be uiKey */
         dis.itemID = -1; /* used to be uiKey */
         dis.itemAction = ODA_DRAWENTIRE;
         dis.itemAction = ODA_DRAWENTIRE;
         dis.itemState = ODS_FOCUS;
         dis.itemState = ODS_FOCUS;
         dis.hwndItem = hWnd;
         dis.hwndItem = hWnd;
         dis.itemData = 0;
         dis.itemData = 0;
         GetClientRect(lp->EditControl,&dis.rcItem);
         GetClientRect(lp->EditControl,&dis.rcItem);
         dis.rcItem.left += 3;
         dis.rcItem.left += 3;
         dis.rcItem.right -= 3;
         dis.rcItem.right -= 3;
         dis.rcItem.top += 2;
         dis.rcItem.top += 2;
         dis.rcItem.bottom -= 2;
         dis.rcItem.bottom -= 2;
 
 
         dis.hDC = GetDC(lp->EditControl);
         dis.hDC = GetDC(lp->EditControl);
         hRgn = CreateRectRgnIndirect(&dis.rcItem);
         hRgn = CreateRectRgnIndirect(&dis.rcItem);
         SelectClipRgn(dis.hDC,hRgn);
         SelectClipRgn(dis.hDC,hRgn);
         SelectObject(dis.hDC, lp->hFont);
         SelectObject(dis.hDC, lp->hFont);
         SendMessage(lp->hWndParent, WM_DRAWITEM, (WPARAM)(UINT)lp->nID, (LPARAM)&dis);
         SendMessage(lp->hWndParent, WM_DRAWITEM, (WPARAM)(UINT)lp->nID, (LPARAM)&dis);
         ReleaseDC(lp->EditControl,dis.hDC);
         ReleaseDC(lp->EditControl,dis.hDC);
         DeleteObject(hRgn);
         DeleteObject(hRgn);
         }
         }
#endif  /* ownerdraw */
#endif  /* ownerdraw */
}
}
 
 
/************************************************************************
/************************************************************************
**
**
************************************************************************/
************************************************************************/
static void CBoxDrawStatic(COMBOBOX *lp, HWND hWnd, UINT uiKey)
static void CBoxDrawStatic(COMBOBOX *lp, HWND hWnd, UINT uiKey)
{
{
    int    nLen;
    int    nLen;
    HDC    hdc;
    HDC    hdc;
    LPVOID lpData;
    LPVOID lpData;
    RECT   rcClient;
    RECT   rcClient;
    HFONT  hfonOld = 0;
    HFONT  hfonOld = 0;
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
    HRGN   hRgn;
    HRGN   hRgn;
    DRAWITEMSTRUCT dis;
    DRAWITEMSTRUCT dis;
#endif
#endif
    HBRUSH hbrStatic, hbrOld;
    HBRUSH hbrStatic, hbrOld;
 
 
    /*   Draw rectangle regardless of ownerdraw style...
    /*   Draw rectangle regardless of ownerdraw style...
    */
    */
    hdc = GetDC(hWnd);
    hdc = GetDC(hWnd);
    rcClient.left   = 0;
    rcClient.left   = 0;
    rcClient.top    = 0;
    rcClient.top    = 0;
    rcClient.right  = lp->ButtonRect.left+1;
    rcClient.right  = lp->ButtonRect.left+1;
    rcClient.bottom = lp->uHeight;
    rcClient.bottom = lp->uHeight;
    hbrStatic = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
    hbrStatic = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
    hbrOld = SelectObject(hdc, hbrStatic);
    hbrOld = SelectObject(hdc, hbrStatic);
    SelectObject(hdc, GetStockObject(BLACK_PEN));/* ??? COLOR_WINDOWFRAME */
    SelectObject(hdc, GetStockObject(BLACK_PEN));/* ??? COLOR_WINDOWFRAME */
    Rectangle(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
    Rectangle(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
    SelectObject(hdc, hbrOld);
    SelectObject(hdc, hbrOld);
    DeleteObject(hbrStatic);
    DeleteObject(hbrStatic);
    ReleaseDC(hWnd, hdc);
    ReleaseDC(hWnd, hdc);
 
 
    if (uiKey == (UINT)LB_ERR)
    if (uiKey == (UINT)LB_ERR)
       return;
       return;
 
 
/* jmt: no ownerdraw */
/* jmt: no ownerdraw */
    if (1)      /* (!BOWNERDRAW(lp)) */
    if (1)      /* (!BOWNERDRAW(lp)) */
       {
       {
       /* if necessary, draw text */
       /* if necessary, draw text */
       hdc = GetDC(hWnd);
       hdc = GetDC(hWnd);
       nLen = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, (WPARAM)uiKey, 0L);
       nLen = (int)SendMessage(lp->ListBoxControl, LB_GETTEXTLEN, (WPARAM)uiKey, 0L);
       if (nLen > 0)
       if (nLen > 0)
          {
          {
          lpData = (LPVOID)WinMalloc(nLen+1);
          lpData = (LPVOID)WinMalloc(nLen+1);
          SendMessage(lp->ListBoxControl, LB_GETTEXT, uiKey, (LPARAM)lpData);
          SendMessage(lp->ListBoxControl, LB_GETTEXT, uiKey, (LPARAM)lpData);
          SetBkMode(hdc, TRANSPARENT);
          SetBkMode(hdc, TRANSPARENT);
          if (!IS_SET(lp, CSF_FOCUS))
          if (!IS_SET(lp, CSF_FOCUS))
             {
             {
             SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
             SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
             rcClient.left += 2;
             rcClient.left += 2;
             }
             }
          else {
          else {
               InflateRect(&rcClient, -2, -2);
               InflateRect(&rcClient, -2, -2);
               hbrStatic = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
               hbrStatic = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
               hbrOld = SelectObject(hdc, hbrStatic);
               hbrOld = SelectObject(hdc, hbrStatic);
               FillRect(hdc, &rcClient, hbrStatic);
               FillRect(hdc, &rcClient, hbrStatic);
#if 0   /* jmt: fix: no DrawFocusRect() */
#if 0   /* jmt: fix: no DrawFocusRect() */
               DrawFocusRect(hdc, &rcClient);
               DrawFocusRect(hdc, &rcClient);
#endif
#endif
               SelectObject(hdc, hbrOld);
               SelectObject(hdc, hbrOld);
               DeleteObject(hbrStatic);
               DeleteObject(hbrStatic);
               SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
               SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
               }
               }
          if (lp->hFont)
          if (lp->hFont)
             hfonOld = SelectObject(hdc, lp->hFont);
             hfonOld = SelectObject(hdc, lp->hFont);
          DrawText(hdc, (LPSTR)lpData, nLen, &rcClient, DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
          DrawText(hdc, (LPSTR)lpData, nLen, &rcClient, DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
          if (lp->hFont)
          if (lp->hFont)
             SelectObject(hdc, hfonOld);
             SelectObject(hdc, hfonOld);
          WinFree((LPVOID)lpData);
          WinFree((LPVOID)lpData);
          }
          }
       ReleaseDC(hWnd, hdc);
       ReleaseDC(hWnd, hdc);
       }
       }
#if 0   /* jmt: fix: no ownerdraw */
#if 0   /* jmt: fix: no ownerdraw */
    else { /* fill OWNERDRAWSTRUCT and send WM_DRAWITEM message */
    else { /* fill OWNERDRAWSTRUCT and send WM_DRAWITEM message */
         dis.CtlType    = ODT_COMBOBOX;
         dis.CtlType    = ODT_COMBOBOX;
         dis.CtlID      = (UINT)lp->nID;
         dis.CtlID      = (UINT)lp->nID;
         dis.itemID     = uiKey;
         dis.itemID     = uiKey;
         dis.itemAction = ODA_DRAWENTIRE;
         dis.itemAction = ODA_DRAWENTIRE;
         dis.itemState  = ODS_FOCUS;
         dis.itemState  = ODS_FOCUS;
         dis.hwndItem   = hWnd;
         dis.hwndItem   = hWnd;
         dis.itemData   = SendMessage(lp->ListBoxControl, LB_GETITEMDATA, uiKey, 0L);
         dis.itemData   = SendMessage(lp->ListBoxControl, LB_GETITEMDATA, uiKey, 0L);
         GetClientRect(hWnd, &dis.rcItem);
         GetClientRect(hWnd, &dis.rcItem);
         dis.rcItem.left += 3;
         dis.rcItem.left += 3;
         dis.rcItem.right = lp->ButtonRect.left - 2;  /* do not touch button */
         dis.rcItem.right = lp->ButtonRect.left - 2;  /* do not touch button */
         dis.rcItem.top += 2;
         dis.rcItem.top += 2;
         dis.rcItem.bottom -= 2;
         dis.rcItem.bottom -= 2;
 
 
         dis.hDC = GetDC(hWnd);
         dis.hDC = GetDC(hWnd);
         hRgn = CreateRectRgnIndirect(&dis.rcItem);
         hRgn = CreateRectRgnIndirect(&dis.rcItem);
         SelectClipRgn(dis.hDC, hRgn);
         SelectClipRgn(dis.hDC, hRgn);
         SelectObject(dis.hDC, lp->hFont);
         SelectObject(dis.hDC, lp->hFont);
         SendMessage(lp->hWndParent, WM_DRAWITEM, (WPARAM)(UINT)lp->nID, (LPARAM)&dis);
         SendMessage(lp->hWndParent, WM_DRAWITEM, (WPARAM)(UINT)lp->nID, (LPARAM)&dis);
         ReleaseDC(hWnd, dis.hDC);
         ReleaseDC(hWnd, dis.hDC);
         DeleteObject(hRgn);
         DeleteObject(hRgn);
         }
         }
#endif  /* ownerdraw */
#endif  /* ownerdraw */
 
 
}
}
 
 
 
 
/*------------------------- < Full Revision History > ----------------------
/*------------------------- < Full Revision History > ----------------------
** Revision 1.2  2001/11/06 23:35:46  greg
** Revision 1.2  2001/11/06 23:35:46  greg
**
**
** Revision 1.1.1.1  2001/06/21 06:32:42  greg
** Revision 1.1.1.1  2001/06/21 06:32:42  greg
** Microwindows pre8 with patches
** Microwindows pre8 with patches
**
**
** Revision 1.1.1.1  2001/06/05 03:44:01  root
** Revision 1.1.1.1  2001/06/05 03:44:01  root
** First import of 5/5/2001 Microwindows to CVS
** First import of 5/5/2001 Microwindows to CVS
**
**
** Revision 1.8  2000/08/14 jmt
** Revision 1.8  2000/08/14 jmt
** ported to microwin(non-client/server mode)
** ported to microwin(non-client/server mode)
**
**
** Revision 1.7  2000/06/28 jmt
** Revision 1.7  2000/06/28 jmt
** porting to microwin
** porting to microwin
**
**
** Revision 1.6  2000/01/21 02:48:47  robf
** Revision 1.6  2000/01/21 02:48:47  robf
** remove dead code
** remove dead code
**
**
** Revision 1.5  1999/11/29 05:07:54  robf
** Revision 1.5  1999/11/29 05:07:54  robf
** removed extraneous call CreateCompatibleDC
** removed extraneous call CreateCompatibleDC
**
**
** Revision 1.4  1999/07/08 18:52:50  mwalsh
** Revision 1.4  1999/07/08 18:52:50  mwalsh
** Updated Comments
** Updated Comments
**
**
**-------------------------------------------------------------------------*/
**-------------------------------------------------------------------------*/
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.