4 * Copyright 1997 Alex Korobka
6 * FIXME: roll up in Netscape 3.01.
13 #include "sysmetrics.h"
25 /* bits in the dwKeyData */
26 #define KEYDATA_ALT 0x2000
27 #define KEYDATA_PREVSTATE 0x4000
30 * Additional combo box definitions
33 #define CB_GETPTR( wnd ) (*(LPHEADCOMBO*)((wnd)->wExtra))
34 #define CB_NOTIFY( lphc, code ) \
35 (SendMessage32A( (lphc)->owner, WM_COMMAND, \
36 MAKEWPARAM((lphc)->self->wIDmenu, (code)), (lphc)->self->hwndSelf))
37 #define CB_GETEDITTEXTLENGTH( lphc ) \
38 (SendMessage32A( (lphc)->hWndEdit, WM_GETTEXTLENGTH, 0, 0 ))
40 static HBITMAP16 hComboBmp = 0;
41 static UINT16 CBitHeight, CBitWidth;
42 static UINT16 CBitOffset = 8;
44 /***********************************************************************
47 * Load combo button bitmap.
49 static BOOL32 COMBO_Init()
53 if( hComboBmp ) return TRUE;
54 if( (hDC = CreateCompatibleDC16(0)) )
57 if( (hComboBmp = LoadBitmap16(0, MAKEINTRESOURCE(OBM_COMBO))) )
63 GetObject16( hComboBmp, sizeof(bm), &bm );
64 CBitHeight = bm.bmHeight;
65 CBitWidth = bm.bmWidth;
67 dprintf_combo(stddeb, "combo bitmap [%i,%i]\n", CBitWidth, CBitHeight );
69 hPrevB = SelectObject16( hDC, hComboBmp);
70 SetRect16( &r, 0, 0, CBitWidth, CBitHeight );
71 InvertRect16( hDC, &r );
72 SelectObject16( hDC, hPrevB );
81 /***********************************************************************
84 static LRESULT COMBO_NCCreate(WND* wnd, LPARAM lParam)
88 if ( wnd && COMBO_Init() &&
89 (lphc = HeapAlloc(GetProcessHeap(), 0, sizeof(HEADCOMBO))) )
91 LPCREATESTRUCT32A lpcs = (CREATESTRUCT32A*)lParam;
93 memset( lphc, 0, sizeof(HEADCOMBO) );
94 *(LPHEADCOMBO*)wnd->wExtra = lphc;
96 /* some braindead apps do try to use scrollbar/border flags */
98 lphc->dwStyle = (lpcs->style & ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL));
99 wnd->dwStyle &= ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL);
101 if( !(lpcs->style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) )
102 lphc->dwStyle |= CBS_HASSTRINGS;
103 if( !(wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) )
104 lphc->wState |= CBF_NOTIFY;
106 dprintf_combo(stddeb, "COMBO_NCCreate: [0x%08x], style = %08x\n",
107 (UINT32)lphc, lphc->dwStyle );
109 return (LRESULT)(UINT32)wnd->hwndSelf;
111 return (LRESULT)FALSE;
114 /***********************************************************************
117 static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc )
122 WND* wnd = lphc->self;
124 dprintf_combo(stddeb,"Combo [%04x]: freeing storage\n", CB_HWND(lphc));
126 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox )
127 DestroyWindow32( lphc->hWndLBox );
129 HeapFree( GetProcessHeap(), 0, lphc );
135 /***********************************************************************
138 * Set up component coordinates given valid lphc->RectCombo.
140 static void CBCalcPlacement( LPHEADCOMBO lphc,
141 LPRECT16 lprEdit, LPRECT16 lprButton, LPRECT16 lprLB )
143 RECT16 rect = lphc->RectCombo;
146 /* get combo height and width */
148 if( lphc->editHeight )
149 size.cy = (INT16)lphc->editHeight;
152 HDC16 hDC = GetDC16( lphc->self->hwndSelf );
153 HFONT16 hPrevFont = (HFONT16)0;
155 if( lphc->hFont ) hPrevFont = SelectObject16( hDC, lphc->hFont );
157 GetTextExtentPoint16( hDC, "0", 1, &size);
159 size.cy += size.cy / 4 + 4 * SYSMETRICS_CYBORDER;
161 if( hPrevFont ) SelectObject16( hDC, hPrevFont );
162 ReleaseDC16( lphc->self->hwndSelf, hDC );
164 size.cx = rect.right - rect.left;
166 if( CB_OWNERDRAWN(lphc) )
168 UINT16 u = lphc->RectEdit.bottom - lphc->RectEdit.top;
170 if( lphc->wState & CBF_MEASUREITEM ) /* first initialization */
172 MEASUREITEMSTRUCT32 mi32;
174 lphc->wState &= ~CBF_MEASUREITEM;
175 mi32.CtlType = ODT_COMBOBOX;
176 mi32.CtlID = lphc->self->wIDmenu;
178 mi32.itemWidth = size.cx;
179 mi32.itemHeight = size.cy - 6; /* ownerdrawn cb is taller */
181 SendMessage32A(lphc->owner, WM_MEASUREITEM,
182 (WPARAM32)mi32.CtlID, (LPARAM)&mi32);
183 u = 6 + (UINT16)mi32.itemHeight;
188 /* calculate text and button placement */
190 lprEdit->left = lprEdit->top = lprButton->top = 0;
191 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* no button */
192 lprButton->left = lprButton->right = lprButton->bottom = 0;
195 INT32 i = size.cx - CBitWidth - 10; /* seems ok */
197 lprButton->right = size.cx;
198 lprButton->left = (INT16)i;
199 lprButton->bottom = lprButton->top + size.cy;
201 if( i < 0 ) size.cx = 0;
202 else size.cx = (INT16)i;
205 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
207 size.cx -= CBitOffset;
208 if( size.cx < 0 ) size.cx = 0;
211 lprEdit->right = size.cx; lprEdit->bottom = size.cy;
213 /* listbox placement */
215 lprLB->left = ( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST ) ? 0 : CBitOffset;
216 lprLB->top = lprEdit->bottom - SYSMETRICS_CYBORDER;
217 lprLB->right = rect.right - rect.left;
218 lprLB->bottom = rect.bottom - rect.top;
220 if( lphc->droppedWidth > (lprLB->right - lprLB->left) )
221 lprLB->right = lprLB->left + (INT16)lphc->droppedWidth;
223 dprintf_combo(stddeb,"Combo [%04x]: (%i,%i-%i,%i) placement\n\ttext\t= (%i,%i-%i,%i)\
224 \n\tbutton\t= (%i,%i-%i,%i)\n\tlbox\t= (%i,%i-%i,%i)\n", CB_HWND(lphc),
225 lphc->RectCombo.left, lphc->RectCombo.top, lphc->RectCombo.right, lphc->RectCombo.bottom,
226 lprEdit->left, lprEdit->top, lprEdit->right, lprEdit->bottom,
227 lprButton->left, lprButton->top, lprButton->right, lprButton->bottom,
228 lprLB->left, lprLB->top, lprLB->right, lprLB->bottom );
232 /***********************************************************************
233 * CBGetDroppedControlRect32
235 static void CBGetDroppedControlRect32( LPHEADCOMBO lphc, LPRECT32 lpRect)
237 lpRect->left = lphc->RectCombo.left +
238 (lphc->wState & CBF_EDIT) ? CBitOffset : 0;
239 lpRect->top = lphc->RectCombo.top + lphc->RectEdit.bottom -
241 lpRect->right = lphc->RectCombo.right;
242 lpRect->bottom = lphc->RectCombo.bottom - SYSMETRICS_CYBORDER;
245 /***********************************************************************
248 static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, LPARAM lParam)
250 static char clbName[] = "ComboLBox";
251 static char editName[] = "Edit";
253 LPCREATESTRUCT32A lpcs = (CREATESTRUCT32A*)lParam;
255 if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE;
256 else if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
259 lphc->owner = lpcs->hwndParent;
261 /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
263 if( lphc->owner || !(lpcs->style & WS_VISIBLE) )
266 RECT16 editRect, btnRect, lbRect;
268 GetWindowRect16( wnd->hwndSelf, &lphc->RectCombo );
270 lphc->wState |= CBF_MEASUREITEM;
271 CBCalcPlacement( lphc, &editRect, &btnRect, &lbRect );
272 lphc->RectButton = btnRect;
273 lphc->droppedWidth = lphc->editHeight = 0;
275 /* create listbox popup */
277 lbeStyle = (LBS_NOTIFY | WS_BORDER | WS_CLIPSIBLINGS) |
278 (lpcs->style & (WS_VSCROLL | CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE));
280 if( lphc->dwStyle & CBS_SORT )
281 lbeStyle |= LBS_SORT;
282 if( lphc->dwStyle & CBS_HASSTRINGS )
283 lbeStyle |= LBS_HASSTRINGS;
284 if( lphc->dwStyle & CBS_NOINTEGRALHEIGHT )
285 lbeStyle |= LBS_NOINTEGRALHEIGHT;
286 if( lphc->dwStyle & CBS_DISABLENOSCROLL )
287 lbeStyle |= LBS_DISABLENOSCROLL;
289 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */
290 lbeStyle |= WS_CHILD | WS_VISIBLE;
291 else /* popup listbox */
293 lbeStyle |= WS_POPUP;
294 OffsetRect16( &lbRect, lphc->RectCombo.left, lphc->RectCombo.top );
297 /* Dropdown ComboLBox is not a child window and we cannot pass
298 * ID_CB_LISTBOX directly because it will be treated as a menu handle.
301 lphc->hWndLBox = CreateWindowEx32A( 0, clbName, NULL, lbeStyle,
302 lbRect.left + SYSMETRICS_CXBORDER,
303 lbRect.top + SYSMETRICS_CYBORDER,
304 lbRect.right - lbRect.left - 2 * SYSMETRICS_CXBORDER,
305 lbRect.bottom - lbRect.top - 2 * SYSMETRICS_CYBORDER,
306 lphc->self->hwndSelf,
307 (lphc->dwStyle & CBS_DROPDOWN)? (HMENU32)0 : (HMENU32)ID_CB_LISTBOX,
308 lphc->self->hInstance, (LPVOID)lphc );
312 lbeStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NOHIDESEL | ES_LEFT;
313 if( lphc->wState & CBF_EDIT )
315 if( lphc->dwStyle & CBS_OEMCONVERT )
316 lbeStyle |= ES_OEMCONVERT;
317 if( lphc->dwStyle & CBS_AUTOHSCROLL )
318 lbeStyle |= ES_AUTOHSCROLL;
319 if( lphc->dwStyle & CBS_LOWERCASE )
320 lbeStyle |= ES_LOWERCASE;
321 else if( lphc->dwStyle & CBS_UPPERCASE )
322 lbeStyle |= ES_UPPERCASE;
323 lphc->hWndEdit = CreateWindowEx32A( 0, editName, NULL, lbeStyle,
324 editRect.left, editRect.top, editRect.right - editRect.left,
325 editRect.bottom - editRect.top, lphc->self->hwndSelf,
326 (HMENU32)ID_CB_EDIT, lphc->self->hInstance, NULL );
327 if( !lphc->hWndEdit ) bEdit = FALSE;
332 lphc->RectEdit = editRect;
333 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
335 lphc->wState |= CBF_NORESIZE;
336 SetWindowPos32( wnd->hwndSelf, 0, 0, 0,
337 lphc->RectCombo.right - lphc->RectCombo.left,
338 lphc->RectEdit.bottom - lphc->RectEdit.top,
339 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
340 lphc->wState &= ~CBF_NORESIZE;
342 dprintf_combo(stddeb,"COMBO_Create: init done\n");
343 return wnd->hwndSelf;
345 dprintf_combo(stderr, "COMBO_Create: edit control failure.\n");
346 } else dprintf_combo(stderr, "COMBO_Create: listbox failure.\n");
347 } else dprintf_combo(stderr, "COMBO_Create: no owner for visible combo.\n");
349 /* CreateWindow() will send WM_NCDESTROY to cleanup */
354 /***********************************************************************
357 * Paint combo button (normal, pressed, and disabled states).
359 static void CBPaintButton(LPHEADCOMBO lphc, HDC16 hdc)
366 if( lphc->wState & CBF_NOREDRAW )
369 hPrevBrush = (HBRUSH32)SelectObject32(hdc, sysColorObjects.hbrushBtnFace);
370 CONV_RECT16TO32( &lphc->RectButton, &r );
372 Rectangle32(hdc, r.left, r.top, r.right, r.bottom );
373 InflateRect32( &r, -1, -1 );
374 if( (bBool = lphc->wState & CBF_BUTTONDOWN) )
376 GRAPH_DrawReliefRect(hdc, &r, 1, 0, TRUE);
377 OffsetRect32( &r, 1, 1 );
378 } else GRAPH_DrawReliefRect(hdc, &r, 1, 2, FALSE);
380 x = (r.left + r.right - CBitWidth) >> 1;
381 y = (r.top + r.bottom - CBitHeight) >> 1;
383 InflateRect32( &r, -3, -3 );
384 if( (bBool = CB_DISABLED(lphc)) )
386 GRAPH_SelectClipMask(hdc, hComboBmp, x + 1, y + 1 );
387 FillRect32(hdc, &r, (HBRUSH32)GetStockObject32(WHITE_BRUSH));
390 GRAPH_SelectClipMask(hdc, hComboBmp, x, y );
391 FillRect32(hdc, &r, (HBRUSH32)GetStockObject32((bBool) ? GRAY_BRUSH : BLACK_BRUSH));
393 GRAPH_SelectClipMask(hdc, (HBITMAP32)0, 0, 0);
394 SelectObject32( hdc, hPrevBrush );
397 /***********************************************************************
400 * Paint CBS_DROPDOWNLIST text field / update edit control contents.
402 static void CBPaintText(LPHEADCOMBO lphc, HDC16 hdc)
407 if( lphc->wState & CBF_NOREDRAW )
410 /* follow Windows combobox that sends a bunch of text
411 * inquiries to its listbox while processing WM_PAINT. */
413 if( (id = SendMessage32A(lphc->hWndLBox, LB_GETCURSEL32, 0, 0) ) != LB_ERR )
415 size = SendMessage32A( lphc->hWndLBox, LB_GETTEXTLEN32, id, 0);
416 if( (pText = HeapAlloc( GetProcessHeap(), 0, size + 1)) )
418 SendMessage32A( lphc->hWndLBox, LB_GETTEXT32, (WPARAM32)id, (LPARAM)pText );
419 pText[size] = '\0'; /* just in case */
423 if( lphc->wState & CBF_EDIT )
425 if( CB_HASSTRINGS(lphc) ) SetWindowText32A( lphc->hWndEdit, pText );
426 if( lphc->wState & CBF_FOCUSED )
427 SendMessage32A( lphc->hWndEdit, EM_SETSEL32, 0, (LPARAM)(-1));
429 else /* paint text field ourselves */
431 HBRUSH32 hPrevBrush = 0;
436 if ((hDC = GetDC32(lphc->self->hwndSelf)))
438 HBRUSH32 hBrush = SendMessage32A( lphc->owner,
440 hDC, lphc->self->hwndSelf );
441 hPrevBrush = SelectObject32( hDC,
442 (hBrush) ? hBrush : GetStockObject32(WHITE_BRUSH) );
449 HFONT32 hPrevFont = (lphc->hFont) ? SelectObject32(hDC, lphc->hFont) : 0;
451 PatBlt32( hDC, (rect.left = lphc->RectEdit.left + SYSMETRICS_CXBORDER),
452 (rect.top = lphc->RectEdit.top + SYSMETRICS_CYBORDER),
453 (rect.right = lphc->RectEdit.right - SYSMETRICS_CXBORDER),
454 (rect.bottom = lphc->RectEdit.bottom - SYSMETRICS_CYBORDER) - 1, PATCOPY );
455 InflateRect32( &rect, -1, -1 );
457 if( lphc->wState & CBF_FOCUSED &&
458 !(lphc->wState & CBF_DROPPED) )
462 FillRect32( hDC, &rect, sysColorObjects.hbrushHighlight );
463 SetBkColor32( hDC, GetSysColor32( COLOR_HIGHLIGHT ) );
464 SetTextColor32( hDC, GetSysColor32( COLOR_HIGHLIGHTTEXT ) );
465 itemState = ODS_SELECTED | ODS_FOCUS;
466 } else itemState = 0;
468 if( CB_OWNERDRAWN(lphc) )
470 DRAWITEMSTRUCT32 dis;
472 if( lphc->self->dwStyle & WS_DISABLED ) itemState |= ODS_DISABLED;
474 dis.CtlType = ODT_COMBOBOX;
475 dis.CtlID = lphc->self->wIDmenu;
476 dis.hwndItem = lphc->self->hwndSelf;
477 dis.itemAction = ODA_DRAWENTIRE;
479 dis.itemState = itemState;
482 dis.itemData = SendMessage32A( lphc->hWndLBox, LB_GETITEMDATA32,
484 SendMessage32A( lphc->owner, WM_DRAWITEM,
485 lphc->self->wIDmenu, (LPARAM)&dis );
489 ExtTextOut32A( hDC, rect.left + 1, rect.top + 1,
490 ETO_OPAQUE | ETO_CLIPPED, &rect,
491 (pText) ? pText : "" , size, NULL );
492 if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED))
493 DrawFocusRect32( hDC, &rect );
496 if( hPrevFont ) SelectObject32(hDC, hPrevFont );
499 if( hPrevBrush ) SelectObject32( hDC, hPrevBrush );
500 ReleaseDC32( lphc->self->hwndSelf, hDC );
504 HeapFree( GetProcessHeap(), 0, pText );
507 /***********************************************************************
510 static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC16 hParamDC)
515 hDC = (hParamDC) ? hParamDC
516 : BeginPaint16( lphc->self->hwndSelf, &ps);
517 if( hDC && !(lphc->wState & CBF_NOREDRAW) )
519 HBRUSH32 hPrevBrush, hBkgBrush;
521 hBkgBrush = SendMessage32A( lphc->owner, WM_CTLCOLORLISTBOX,
522 hDC, lphc->self->hwndSelf );
523 if( !hBkgBrush ) hBkgBrush = GetStockObject32(WHITE_BRUSH);
525 hPrevBrush = SelectObject32( hDC, hBkgBrush );
526 if( !IsRectEmpty16(&lphc->RectButton) )
528 /* paint everything to the right of the text field */
530 PatBlt32( hDC, lphc->RectEdit.right, lphc->RectEdit.top,
531 lphc->RectButton.right - lphc->RectEdit.right,
532 lphc->RectEdit.bottom - lphc->RectEdit.top, PATCOPY );
533 CBPaintButton( lphc, hDC );
536 if( !(lphc->wState & CBF_EDIT) )
538 /* paint text field */
540 GRAPH_DrawRectangle( hDC, lphc->RectEdit.left, lphc->RectEdit.top,
541 lphc->RectEdit.right - lphc->RectEdit.left,
542 lphc->RectButton.bottom - lphc->RectButton.top,
543 sysColorObjects.hpenWindowFrame );
544 CBPaintText( lphc, hDC );
546 if( hPrevBrush ) SelectObject32( hDC, hPrevBrush );
548 if( !hParamDC ) EndPaint16(lphc->self->hwndSelf, &ps);
552 /***********************************************************************
555 * Select listbox entry according to the contents of the edit control.
557 static INT32 CBUpdateLBox( LPHEADCOMBO lphc )
559 INT32 length, idx, ret;
563 length = CB_GETEDITTEXTLENGTH( lphc );
566 pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1);
568 dprintf_combo(stddeb,"\tCBUpdateLBox: edit text length %i\n", length );
572 if( length ) GetWindowText32A( lphc->hWndEdit, pText, length + 1);
573 else pText[0] = '\0';
574 idx = SendMessage32A( lphc->hWndLBox, LB_FINDSTRING32,
575 (WPARAM32)(-1), (LPARAM)pText );
576 if( idx == LB_ERR ) idx = 0; /* select first item */
578 HeapFree( GetProcessHeap(), 0, pText );
583 SendMessage32A( lphc->hWndLBox, LB_SETCURSEL32, (WPARAM32)idx, 0 );
587 SendMessage32A( lphc->hWndLBox, LB_SETTOPINDEX32, (WPARAM32)idx, 0 );
588 /* probably superfluous but Windows sends this too */
589 SendMessage32A( lphc->hWndLBox, LB_SETCARETINDEX32, (WPARAM32)idx, 0 );
594 /***********************************************************************
597 * Copy a listbox entry to the edit control.
599 static void CBUpdateEdit( LPHEADCOMBO lphc , INT32 index )
604 dprintf_combo(stddeb,"\tCBUpdateEdit: %i\n", index );
608 length = CB_GETEDITTEXTLENGTH( lphc );
611 if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) )
613 GetWindowText32A( lphc->hWndEdit, pText, length + 1 );
614 index = SendMessage32A( lphc->hWndLBox, LB_FINDSTRING32,
615 (WPARAM32)(-1), (LPARAM)pText );
616 HeapFree( GetProcessHeap(), 0, pText );
621 if( index >= 0 ) /* got an entry */
623 length = SendMessage32A( lphc->hWndLBox, LB_GETTEXTLEN32, (WPARAM32)index, 0);
626 if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) )
628 SendMessage32A( lphc->hWndLBox, LB_GETTEXT32,
629 (WPARAM32)index, (LPARAM)pText );
630 SendMessage32A( lphc->hWndEdit, WM_SETTEXT, 0, (LPARAM)pText );
631 SendMessage32A( lphc->hWndEdit, EM_SETSEL32, 0, (LPARAM)(-1) );
632 HeapFree( GetProcessHeap(), 0, pText );
638 /***********************************************************************
641 * Show listbox popup.
643 static void CBDropDown( LPHEADCOMBO lphc )
647 LPRECT16 pRect = NULL;
649 dprintf_combo(stddeb,"Combo [%04x]: drop down\n", CB_HWND(lphc));
651 CB_NOTIFY( lphc, CBN_DROPDOWN );
655 lphc->wState |= CBF_DROPPED;
656 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
658 index = CBUpdateLBox( lphc );
659 if( !(lphc->wState & CBF_CAPTURE) ) CBUpdateEdit( lphc, index );
663 index = SendMessage32A( lphc->hWndLBox, LB_GETCURSEL32, 0, 0 );
664 if( index == LB_ERR ) index = 0;
665 SendMessage32A( lphc->hWndLBox, LB_SETTOPINDEX32, (WPARAM32)index, 0 );
666 SendMessage32A( lphc->hWndLBox, LB_CARETON32, 0, 0 );
667 pRect = &lphc->RectEdit;
670 /* now set popup position */
672 GetWindowRect16( lphc->self->hwndSelf, &rect );
674 rect.top += lphc->RectEdit.bottom - lphc->RectEdit.top - SYSMETRICS_CYBORDER;
675 rect.bottom = rect.top + lphc->RectCombo.bottom -
676 lphc->RectCombo.top - SYSMETRICS_CYBORDER;
677 rect.right = rect.left + lphc->RectCombo.right - lphc->RectCombo.left;
678 rect.left += ( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST ) ? 0 : CBitOffset;
680 SetWindowPos32( lphc->hWndLBox, HWND_TOP, rect.left, rect.top,
681 rect.right - rect.left, rect.bottom - rect.top,
682 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOREDRAW);
683 if( !(lphc->wState & CBF_NOREDRAW) )
686 RedrawWindow16( lphc->self->hwndSelf, pRect, 0, RDW_INVALIDATE |
687 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
688 ShowWindow32( lphc->hWndLBox, SW_SHOWNA );
692 /***********************************************************************
695 * Hide listbox popup.
697 static void CBRollUp( LPHEADCOMBO lphc, BOOL32 ok, BOOL32 bButton )
699 HWND32 hWnd = lphc->self->hwndSelf;
701 CB_NOTIFY( lphc, (ok) ? CBN_SELENDOK : CBN_SELENDCANCEL );
703 if( IsWindow32( hWnd ) && CB_GETTYPE(lphc) != CBS_SIMPLE )
706 dprintf_combo(stddeb,"Combo [%04x]: roll up [%i]\n", CB_HWND(lphc), (INT32)ok );
708 /* always send WM_LBUTTONUP? */
709 SendMessage32A( lphc->hWndLBox, WM_LBUTTONUP, 0, (LPARAM)(-1) );
711 if( lphc->wState & CBF_DROPPED )
715 lphc->wState &= ~CBF_DROPPED;
716 ShowWindow32( lphc->hWndLBox, SW_HIDE );
718 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
720 INT32 index = SendMessage32A( lphc->hWndLBox, LB_GETCURSEL32, 0, 0 );
721 CBUpdateEdit( lphc, index );
722 rect = lphc->RectButton;
727 UnionRect16( &rect, &lphc->RectButton,
730 rect = lphc->RectEdit;
734 if( bButton && !(lphc->wState & CBF_NOREDRAW) )
735 RedrawWindow16( hWnd, &rect, 0, RDW_INVALIDATE |
736 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
737 CB_NOTIFY( lphc, CBN_CLOSEUP );
742 /***********************************************************************
745 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
747 BOOL32 COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL32 bRedrawButton )
749 if( lphc->wState & CBF_DROPPED )
751 CBRollUp( lphc, TRUE, bRedrawButton );
759 /***********************************************************************
762 * Edit control helper.
764 HWND32 COMBO_GetLBWindow( WND* pWnd )
766 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
767 if( lphc ) return lphc->hWndLBox;
772 /***********************************************************************
775 static void CBRepaintButton( LPHEADCOMBO lphc )
777 HDC32 hDC = GetDC32( lphc->self->hwndSelf );
781 CBPaintButton( lphc, (HDC16)hDC );
782 ReleaseDC32( lphc->self->hwndSelf, hDC );
786 /***********************************************************************
789 static void COMBO_SetFocus( LPHEADCOMBO lphc )
791 if( !(lphc->wState & CBF_FOCUSED) )
793 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
794 SendMessage32A( lphc->hWndLBox, LB_CARETON32, 0, 0 );
796 if( lphc->wState & CBF_EDIT )
797 SendMessage32A( lphc->hWndEdit, EM_SETSEL32, 0, (LPARAM)(-1) );
798 lphc->wState |= CBF_FOCUSED;
799 if( !(lphc->wState & CBF_EDIT) ) CBPaintText( lphc, 0 );
801 CB_NOTIFY( lphc, CBN_SETFOCUS );
805 /***********************************************************************
808 static void COMBO_KillFocus( LPHEADCOMBO lphc )
810 HWND32 hWnd = lphc->self->hwndSelf;
812 if( lphc->wState & CBF_FOCUSED )
814 SendMessage32A( hWnd, WM_LBUTTONUP, 0, (LPARAM)(-1) );
816 CBRollUp( lphc, FALSE, TRUE );
817 if( IsWindow32( hWnd ) )
819 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
820 SendMessage32A( lphc->hWndLBox, LB_CARETOFF32, 0, 0 );
822 lphc->wState &= ~CBF_FOCUSED;
825 if( lphc->wState & CBF_EDIT )
826 SendMessage32A( lphc->hWndEdit, EM_SETSEL32, (WPARAM32)(-1), 0 );
827 else CBPaintText( lphc, 0 );
829 CB_NOTIFY( lphc, CBN_KILLFOCUS );
834 /***********************************************************************
837 static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM32 wParam, HWND32 hWnd )
839 if( lphc->wState & CBF_EDIT && lphc->hWndEdit == hWnd )
841 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
843 switch( HIWORD(wParam) >> 8 )
845 case (EN_SETFOCUS >> 8):
847 dprintf_combo(stddeb,"Combo [%04x]: edit [%04x] got focus\n",
848 CB_HWND(lphc), (HWND16)lphc->hWndEdit );
850 if( !(lphc->wState & CBF_FOCUSED) ) COMBO_SetFocus( lphc );
853 case (EN_KILLFOCUS >> 8):
855 dprintf_combo(stddeb,"Combo [%04x]: edit [%04x] lost focus\n",
856 CB_HWND(lphc), (HWND16)lphc->hWndEdit );
858 /* NOTE: it seems that Windows' edit control sends an
859 * undocumented message WM_USER + 0x1B instead of this
860 * notification (only when it happens to be a part of
861 * the combo). ?? - AK.
864 COMBO_KillFocus( lphc );
868 case (EN_CHANGE >> 8):
869 CB_NOTIFY( lphc, CBN_EDITCHANGE );
870 CBUpdateLBox( lphc );
873 case (EN_UPDATE >> 8):
874 CB_NOTIFY( lphc, CBN_EDITUPDATE );
877 case (EN_ERRSPACE >> 8):
878 CB_NOTIFY( lphc, CBN_ERRSPACE );
881 else if( lphc->hWndLBox == hWnd )
883 switch( HIWORD(wParam) )
886 CB_NOTIFY( lphc, CBN_ERRSPACE );
890 CB_NOTIFY( lphc, CBN_DBLCLK );
896 dprintf_combo(stddeb,"Combo [%04x]: lbox selection change [%04x]\n",
897 CB_HWND(lphc), lphc->wState );
899 /* do not roll up if selection is being tracked
900 * by arrowkeys in the dropdown listbox */
902 if( (lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP) )
903 CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
904 else lphc->wState &= ~CBF_NOROLLUP;
906 CB_NOTIFY( lphc, CBN_SELCHANGE );
907 CBPaintText( lphc, 0 );
912 /* nothing to do here since ComboLBox always resets the focus to its
913 * combo/edit counterpart */
920 /***********************************************************************
923 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
925 static LRESULT COMBO_ItemOp32( LPHEADCOMBO lphc, UINT32 msg,
926 WPARAM32 wParam, LPARAM lParam )
928 HWND32 hWnd = lphc->self->hwndSelf;
930 dprintf_combo(stddeb,"Combo [%04x]: ownerdraw op %04x\n",
931 CB_HWND(lphc), (UINT16)msg );
933 #define lpIS ((LPDELETEITEMSTRUCT32)lParam)
935 /* two first items are the same in all 4 structs */
936 lpIS->CtlType = ODT_COMBOBOX;
937 lpIS->CtlID = lphc->self->wIDmenu;
939 switch( msg ) /* patch window handle */
942 lpIS->hwndItem = hWnd;
946 #define lpIS ((LPDRAWITEMSTRUCT32)lParam)
947 lpIS->hwndItem = hWnd;
951 #define lpIS ((LPCOMPAREITEMSTRUCT32)lParam)
952 lpIS->hwndItem = hWnd;
957 return SendMessage32A( lphc->owner, msg, lphc->self->wIDmenu, lParam );
960 /***********************************************************************
963 static LRESULT COMBO_GetText( LPHEADCOMBO lphc, UINT32 N, LPSTR lpText)
967 if( lphc->wState & CBF_EDIT )
968 return SendMessage32A( lphc->hWndEdit, WM_GETTEXT,
969 (WPARAM32)N, (LPARAM)lpText );
971 /* get it from the listbox */
973 idx = SendMessage32A( lphc->hWndLBox, LB_GETCURSEL32, 0, 0 );
977 INT32 length = SendMessage32A( lphc->hWndLBox, LB_GETTEXTLEN32,
980 /* 'length' is without the terminating character */
982 lpBuffer = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1 );
988 INT32 n = SendMessage32A( lphc->hWndLBox, LB_GETTEXT32,
989 (WPARAM32)idx, (LPARAM)lpText );
991 /* truncate if buffer is too short */
995 if( n != LB_ERR ) memcpy( lpText, lpBuffer, (N>n) ? n+1 : N-1 );
996 lpText[N - 1] = '\0';
997 HeapFree( GetProcessHeap(), 0, lpBuffer );
1006 /***********************************************************************
1009 * This function sets window positions according to the updated
1010 * component placement struct.
1012 static void CBResetPos( LPHEADCOMBO lphc, LPRECT16 lbRect, BOOL32 bRedraw )
1014 BOOL32 bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
1016 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1017 * sizing messages */
1019 if( lphc->wState & CBF_EDIT )
1020 SetWindowPos32( lphc->hWndEdit, 0, lphc->RectEdit.left, lphc->RectEdit.top,
1021 lphc->RectEdit.right - lphc->RectEdit.left,
1022 lphc->RectEdit.bottom - lphc->RectEdit.top,
1023 SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
1026 OffsetRect16( lbRect, lphc->RectCombo.left, lphc->RectCombo.top );
1028 lbRect->right -= lbRect->left; /* convert to width */
1029 lbRect->bottom -= lbRect->top;
1030 SetWindowPos32( lphc->hWndLBox, 0, lbRect->left, lbRect->top,
1031 lbRect->right, lbRect->bottom,
1032 SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) );
1036 if( lphc->wState & CBF_DROPPED )
1038 lphc->wState &= ~CBF_DROPPED;
1039 ShowWindow32( lphc->hWndLBox, SW_HIDE );
1042 lphc->wState |= CBF_NORESIZE;
1043 SetWindowPos32( lphc->self->hwndSelf, 0, 0, 0,
1044 lphc->RectCombo.right - lphc->RectCombo.left,
1045 lphc->RectEdit.bottom - lphc->RectEdit.top,
1046 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW );
1047 lphc->wState &= ~CBF_NORESIZE;
1048 if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
1049 RedrawWindow32( lphc->self->hwndSelf, NULL, 0,
1050 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
1055 /***********************************************************************
1058 static void COMBO_Size( LPHEADCOMBO lphc )
1063 GetWindowRect16( lphc->self->hwndSelf, &rect );
1064 w = rect.right - rect.left; h = rect.bottom - rect.top;
1066 dprintf_combo(stddeb,"COMBO_Size: w = %i, h = %i\n", w, h );
1068 /* CreateWindow() may send a bogus WM_SIZE, ignore it */
1070 if( w == (lphc->RectCombo.right - lphc->RectCombo.left) )
1071 if( (CB_GETTYPE(lphc) == CBS_SIMPLE) &&
1072 (h == (lphc->RectCombo.bottom - lphc->RectCombo.top)) )
1074 else if( (lphc->dwStyle & CBS_DROPDOWN) &&
1075 (h == (lphc->RectEdit.bottom - lphc->RectEdit.top)) )
1078 lphc->RectCombo = rect;
1079 CBCalcPlacement( lphc, &lphc->RectEdit, &lphc->RectButton, &rect );
1080 CBResetPos( lphc, &rect, TRUE );
1084 /***********************************************************************
1087 static void COMBO_Font( LPHEADCOMBO lphc, HFONT16 hFont, BOOL32 bRedraw )
1091 lphc->hFont = hFont;
1093 if( lphc->wState & CBF_EDIT )
1094 SendMessage32A( lphc->hWndEdit, WM_SETFONT, (WPARAM32)hFont, bRedraw );
1095 SendMessage32A( lphc->hWndLBox, WM_SETFONT, (WPARAM32)hFont, bRedraw );
1097 GetWindowRect16( lphc->self->hwndSelf, &rect );
1098 OffsetRect16( &lphc->RectCombo, rect.left - lphc->RectCombo.left,
1099 rect.top - lphc->RectCombo.top );
1100 CBCalcPlacement( lphc, &lphc->RectEdit,
1101 &lphc->RectButton, &rect );
1102 CBResetPos( lphc, &rect, bRedraw );
1106 /***********************************************************************
1107 * COMBO_SetItemHeight
1109 static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT32 index, INT32 height )
1111 LRESULT lRet = CB_ERR;
1113 if( index == -1 ) /* set text field height */
1115 if( height < 32768 )
1119 lphc->editHeight = height;
1120 GetWindowRect16( lphc->self->hwndSelf, &rect );
1121 OffsetRect16( &lphc->RectCombo, rect.left - lphc->RectCombo.left,
1122 rect.top - lphc->RectCombo.top );
1123 CBCalcPlacement( lphc, &lphc->RectEdit,
1124 &lphc->RectButton, &rect );
1125 CBResetPos( lphc, &rect, TRUE );
1129 else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */
1130 lRet = SendMessage32A( lphc->hWndLBox, LB_SETITEMHEIGHT32,
1131 (WPARAM32)index, (LPARAM)height );
1135 /***********************************************************************
1136 * COMBO_SelectString
1138 static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT32 start, LPCSTR pText )
1140 INT32 index = SendMessage32A( lphc->hWndLBox, LB_SELECTSTRING32,
1141 (WPARAM32)start, (LPARAM)pText );
1143 if( lphc->wState & CBF_EDIT )
1144 CBUpdateEdit( lphc, index );
1146 CBPaintText( lphc, 0 );
1147 return (LRESULT)index;
1150 /***********************************************************************
1153 static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam )
1155 BOOL32 bButton = PtInRect16(&lphc->RectButton, MAKEPOINT16(lParam));
1156 HWND32 hWnd = lphc->self->hwndSelf;
1158 if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
1159 (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) )
1161 lphc->wState |= CBF_BUTTONDOWN;
1162 if( lphc->wState & CBF_DROPPED )
1164 /* got a click to cancel selection */
1166 CBRollUp( lphc, TRUE, FALSE );
1167 if( !IsWindow32( hWnd ) ) return;
1169 if( lphc->wState & CBF_CAPTURE )
1171 lphc->wState &= ~CBF_CAPTURE;
1174 lphc->wState &= ~CBF_BUTTONDOWN;
1178 /* drop down the listbox and start tracking */
1180 lphc->wState |= CBF_CAPTURE;
1182 SetCapture32( hWnd );
1184 if( bButton ) CBRepaintButton( lphc );
1188 /***********************************************************************
1191 * Release capture and stop tracking if needed.
1193 static void COMBO_LButtonUp( LPHEADCOMBO lphc, LPARAM lParam )
1195 if( lphc->wState & CBF_CAPTURE )
1197 lphc->wState &= ~CBF_CAPTURE;
1198 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1200 INT32 index = CBUpdateLBox( lphc );
1201 CBUpdateEdit( lphc, index );
1206 if( lphc->wState & CBF_BUTTONDOWN )
1208 lphc->wState &= ~CBF_BUTTONDOWN;
1209 CBRepaintButton( lphc );
1213 /***********************************************************************
1216 * Two things to do - track combo button and release capture when
1217 * pointer goes into the listbox.
1219 static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM32 wParam, LPARAM lParam )
1223 if( lphc->wState & CBF_BUTTONDOWN )
1225 BOOL32 bButton = PtInRect16(&lphc->RectButton, MAKEPOINT16(lParam));
1229 lphc->wState &= ~CBF_BUTTONDOWN;
1230 CBRepaintButton( lphc );
1234 GetClientRect16( lphc->hWndLBox, &lbRect );
1235 MapWindowPoints16( lphc->self->hwndSelf,
1236 lphc->hWndLBox, (LPPOINT16)&lParam, 1 );
1237 if( PtInRect16(&lbRect, MAKEPOINT16(lParam)) )
1239 lphc->wState &= ~CBF_CAPTURE;
1241 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc );
1243 /* hand over pointer tracking */
1244 SendMessage32A( lphc->hWndLBox, WM_LBUTTONDOWN, wParam, lParam );
1249 /***********************************************************************
1252 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm
1254 LRESULT WINAPI ComboWndProc( HWND32 hwnd, UINT32 message,
1255 WPARAM32 wParam, LPARAM lParam )
1257 WND* pWnd = WIN_FindWndPtr(hwnd);
1261 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1263 dprintf_combo( stddeb, "Combo [%04x]: msg %s wp %08x lp %08lx\n",
1264 pWnd->hwndSelf, SPY_GetMsgName(message), wParam, lParam );
1266 if( lphc || message == WM_NCCREATE )
1270 /* System messages */
1273 return COMBO_NCCreate(pWnd, lParam);
1276 COMBO_NCDestroy(lphc);
1280 return COMBO_Create(lphc, pWnd, lParam);
1283 /* wParam may contain a valid HDC! */
1284 return COMBO_Paint(lphc, (HDC16)wParam);
1290 return (LRESULT)(DLGC_WANTARROWS | DLGC_WANTCHARS);
1293 if( lphc->hWndLBox &&
1294 !(lphc->wState & CBF_NORESIZE) ) COMBO_Size( lphc );
1298 COMBO_Font( lphc, (HFONT16)wParam, (BOOL32)lParam );
1302 return (LRESULT)lphc->hFont;
1305 if( lphc->wState & CBF_EDIT )
1306 SetFocus32( lphc->hWndEdit );
1308 COMBO_SetFocus( lphc );
1312 #define hwndFocus ((HWND16)wParam)
1314 (hwndFocus != lphc->hWndEdit && hwndFocus != lphc->hWndLBox ))
1315 COMBO_KillFocus( lphc );
1320 return COMBO_Command( lphc, wParam, (HWND32)lParam );
1323 return COMBO_GetText( lphc, (UINT32)wParam, (LPSTR)lParam );
1326 case WM_GETTEXTLENGTH:
1331 if( lphc->wState & CBF_EDIT )
1332 return SendMessage32A( lphc->hWndEdit, message, wParam, lParam );
1337 case WM_COMPAREITEM:
1338 case WM_MEASUREITEM:
1339 return COMBO_ItemOp32( lphc, message, wParam, lParam );
1342 if( lphc->wState & CBF_EDIT )
1343 EnableWindow32( lphc->hWndEdit, (BOOL32)wParam );
1344 EnableWindow32( lphc->hWndLBox, (BOOL32)wParam );
1349 lphc->wState &= ~CBF_NOREDRAW;
1351 lphc->wState |= CBF_NOREDRAW;
1353 if( lphc->wState & CBF_EDIT )
1354 SendMessage32A( lphc->hWndEdit, message, wParam, lParam );
1355 SendMessage32A( lphc->hWndLBox, message, wParam, lParam );
1359 if( KEYDATA_ALT & HIWORD(lParam) )
1360 if( wParam == VK_UP || wParam == VK_DOWN )
1361 COMBO_FlipListbox( lphc, TRUE );
1366 if( lphc->wState & CBF_EDIT )
1367 return SendMessage32A( lphc->hWndEdit, message, wParam, lParam );
1369 return SendMessage32A( lphc->hWndLBox, message, wParam, lParam );
1371 case WM_LBUTTONDOWN:
1372 if( !(lphc->wState & CBF_FOCUSED) ) SetFocus32( lphc->self->hwndSelf );
1373 if( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam );
1377 COMBO_LButtonUp( lphc, lParam );
1381 if( lphc->wState & CBF_CAPTURE )
1382 COMBO_MouseMove( lphc, wParam, lParam );
1385 /* Combo messages */
1387 case CB_ADDSTRING16:
1388 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1389 case CB_ADDSTRING32:
1390 return SendMessage32A( lphc->hWndLBox, LB_ADDSTRING32, 0, lParam);
1392 case CB_INSERTSTRING16:
1393 wParam = (INT32)(INT16)wParam;
1394 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1395 case CB_INSERTSTRING32:
1396 return SendMessage32A( lphc->hWndLBox, LB_INSERTSTRING32, wParam, lParam);
1398 case CB_DELETESTRING16:
1399 case CB_DELETESTRING32:
1400 return SendMessage32A( lphc->hWndLBox, LB_DELETESTRING32, wParam, 0);
1402 case CB_SELECTSTRING16:
1403 wParam = (INT32)(INT16)wParam;
1404 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1405 case CB_SELECTSTRING32:
1406 return COMBO_SelectString( lphc, (INT32)wParam, (LPSTR)lParam );
1408 case CB_FINDSTRING16:
1409 wParam = (INT32)(INT16)wParam;
1410 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1411 case CB_FINDSTRING32:
1412 return SendMessage32A( lphc->hWndLBox, LB_FINDSTRING32, wParam, lParam);
1414 case CB_FINDSTRINGEXACT16:
1415 wParam = (INT32)(INT16)wParam;
1416 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1417 case CB_FINDSTRINGEXACT32:
1418 return SendMessage32A( lphc->hWndLBox, LB_FINDSTRINGEXACT32,
1420 case CB_SETITEMHEIGHT16:
1421 wParam = (INT32)(INT16)wParam;
1422 case CB_SETITEMHEIGHT32:
1423 return COMBO_SetItemHeight( lphc, (INT32)wParam, (INT32)lParam);
1425 case CB_RESETCONTENT16:
1426 case CB_RESETCONTENT32:
1427 SendMessage32A( lphc->hWndLBox, LB_RESETCONTENT32, 0, 0 );
1428 CBPaintText( lphc, 0 );
1431 case CB_INITSTORAGE32:
1432 return SendMessage32A( lphc->hWndLBox, LB_INITSTORAGE32, wParam, lParam);
1434 case CB_GETHORIZONTALEXTENT32:
1435 return SendMessage32A( lphc->hWndLBox, LB_GETHORIZONTALEXTENT32, 0, 0);
1437 case CB_SETHORIZONTALEXTENT32:
1438 return SendMessage32A( lphc->hWndLBox, LB_SETHORIZONTALEXTENT32, wParam, 0);
1440 case CB_GETTOPINDEX32:
1441 return SendMessage32A( lphc->hWndLBox, LB_GETTOPINDEX32, 0, 0);
1443 case CB_GETLOCALE32:
1444 return SendMessage32A( lphc->hWndLBox, LB_GETLOCALE32, 0, 0);
1446 case CB_SETLOCALE32:
1447 return SendMessage32A( lphc->hWndLBox, LB_SETLOCALE32, wParam, 0);
1449 case CB_GETDROPPEDWIDTH32:
1450 if( lphc->droppedWidth )
1451 return lphc->droppedWidth;
1452 return lphc->RectCombo.right - lphc->RectCombo.left -
1453 (lphc->wState & CBF_EDIT) ? CBitOffset : 0;
1455 case CB_SETDROPPEDWIDTH32:
1456 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) &&
1457 (INT32)wParam < 32768 ) lphc->droppedWidth = (INT32)wParam;
1460 case CB_GETDROPPEDCONTROLRECT16:
1461 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1465 CBGetDroppedControlRect32( lphc, &r );
1466 CONV_RECT32TO16( &r, (LPRECT16)lParam );
1470 case CB_GETDROPPEDCONTROLRECT32:
1471 if( lParam ) CBGetDroppedControlRect32(lphc, (LPRECT32)lParam );
1474 case CB_GETDROPPEDSTATE16:
1475 case CB_GETDROPPEDSTATE32:
1476 return (lphc->wState & CBF_DROPPED) ? TRUE : FALSE;
1479 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1482 return COMBO_Directory( lphc, (UINT32)wParam,
1483 (LPSTR)lParam, (message == CB_DIR32));
1484 case CB_SHOWDROPDOWN16:
1485 case CB_SHOWDROPDOWN32:
1486 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
1489 if( !(lphc->wState & CBF_DROPPED) )
1493 if( lphc->wState & CBF_DROPPED )
1494 CBRollUp( lphc, FALSE, TRUE );
1499 return SendMessage32A( lphc->hWndLBox, LB_GETCOUNT32, 0, 0);
1501 case CB_GETCURSEL16:
1502 case CB_GETCURSEL32:
1503 return SendMessage32A( lphc->hWndLBox, LB_GETCURSEL32, 0, 0);
1505 case CB_SETCURSEL16:
1506 wParam = (INT32)(INT16)wParam;
1507 case CB_SETCURSEL32:
1508 return SendMessage32A( lphc->hWndLBox, LB_SETCURSEL32, wParam, 0);
1510 case CB_GETLBTEXT16:
1511 wParam = (INT32)(INT16)wParam;
1512 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1513 case CB_GETLBTEXT32:
1514 return SendMessage32A( lphc->hWndLBox, LB_GETTEXT32, wParam, lParam);
1516 case CB_GETLBTEXTLEN16:
1517 wParam = (INT32)(INT16)wParam;
1518 case CB_GETLBTEXTLEN32:
1519 return SendMessage32A( lphc->hWndLBox, LB_GETTEXTLEN32, wParam, 0);
1521 case CB_GETITEMDATA16:
1522 wParam = (INT32)(INT16)wParam;
1523 case CB_GETITEMDATA32:
1524 return SendMessage32A( lphc->hWndLBox, LB_GETITEMDATA32, wParam, 0);
1526 case CB_SETITEMDATA16:
1527 wParam = (INT32)(INT16)wParam;
1528 case CB_SETITEMDATA32:
1529 return SendMessage32A( lphc->hWndLBox, LB_SETITEMDATA32, wParam, lParam);
1531 case CB_GETEDITSEL16:
1532 wParam = lParam = 0; /* just in case */
1533 case CB_GETEDITSEL32:
1534 if( lphc->wState & CBF_EDIT )
1538 return SendMessage32A( lphc->hWndEdit, EM_GETSEL32,
1539 (wParam) ? wParam : (WPARAM32)&a,
1540 (lParam) ? lParam : (LPARAM)&b );
1544 case CB_SETEDITSEL16:
1545 case CB_SETEDITSEL32:
1546 if( lphc->wState & CBF_EDIT )
1547 return SendMessage32A( lphc->hWndEdit, EM_SETSEL32,
1548 (INT32)(INT16)LOWORD(lParam), (INT32)(INT16)HIWORD(lParam) );
1551 case CB_SETEXTENDEDUI16:
1552 case CB_SETEXTENDEDUI32:
1553 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) return CB_ERR;
1556 lphc->wState |= CBF_EUI;
1557 else lphc->wState &= ~CBF_EUI;
1560 case CB_GETEXTENDEDUI16:
1561 case CB_GETEXTENDEDUI32:
1562 return (lphc->wState & CBF_EUI) ? TRUE : FALSE;
1564 case (WM_USER + 0x1B):
1565 dprintf_combo(stddeb,"Combo [%04x]: undocumented msg!\n", (HWND16)hwnd );
1567 return DefWindowProc32A(hwnd, message, wParam, lParam);