Corrected operand sizes for the "enter" instruction.
[wine.git] / controls / combo.c
blobc4cd2c5bbfb08d9642c0bf9fc1a3ceaa868c0538
1 /*
2 * Combo controls
3 *
4 * Copyright 1997 Alex Korobka
5 *
6 * FIXME: roll up in Netscape 3.01.
7 */
9 #include <string.h>
11 #include "winbase.h"
12 #include "winuser.h"
13 #include "wingdi.h"
14 #include "wine/winuser16.h"
15 #include "win.h"
16 #include "spy.h"
17 #include "user.h"
18 #include "heap.h"
19 #include "combo.h"
20 #include "drive.h"
21 #include "debugtools.h"
22 #include "tweak.h"
24 DEFAULT_DEBUG_CHANNEL(combo)
26 /* bits in the dwKeyData */
27 #define KEYDATA_ALT 0x2000
28 #define KEYDATA_PREVSTATE 0x4000
31 * Additional combo box definitions
34 #define CB_GETPTR( wnd ) (*(LPHEADCOMBO*)((wnd)->wExtra))
35 #define CB_NOTIFY( lphc, code ) \
36 (SendMessageA( (lphc)->owner, WM_COMMAND, \
37 MAKEWPARAM((lphc)->self->wIDmenu, (code)), (lphc)->self->hwndSelf))
38 #define CB_GETEDITTEXTLENGTH( lphc ) \
39 (SendMessageA( (lphc)->hWndEdit, WM_GETTEXTLENGTH, 0, 0 ))
41 #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03)
44 * Drawing globals
46 static HBITMAP hComboBmp = 0;
47 static UINT CBitHeight, CBitWidth;
50 * Look and feel dependant "constants"
53 #define COMBO_YBORDERGAP 5
54 #define COMBO_XBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 )
55 #define COMBO_YBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 )
56 #define COMBO_EDITBUTTONSPACE() ( (TWEAK_WineLook == WIN31_LOOK) ? 8 : 0 )
57 #define EDIT_CONTROL_PADDING() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 1 )
59 /***********************************************************************
60 * COMBO_Init
62 * Load combo button bitmap.
64 static BOOL COMBO_Init()
66 HDC hDC;
68 if( hComboBmp ) return TRUE;
69 if( (hDC = CreateCompatibleDC(0)) )
71 BOOL bRet = FALSE;
72 if( (hComboBmp = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_COMBO))) )
74 BITMAP bm;
75 HBITMAP hPrevB;
76 RECT r;
78 GetObjectA( hComboBmp, sizeof(bm), &bm );
79 CBitHeight = bm.bmHeight;
80 CBitWidth = bm.bmWidth;
82 TRACE("combo bitmap [%i,%i]\n", CBitWidth, CBitHeight );
84 hPrevB = SelectObject16( hDC, hComboBmp);
85 SetRect( &r, 0, 0, CBitWidth, CBitHeight );
86 InvertRect( hDC, &r );
87 SelectObject( hDC, hPrevB );
88 bRet = TRUE;
90 DeleteDC( hDC );
91 return bRet;
93 return FALSE;
96 /***********************************************************************
97 * COMBO_NCCreate
99 static LRESULT COMBO_NCCreate(WND* wnd, LPARAM lParam)
101 LPHEADCOMBO lphc;
103 if ( wnd && COMBO_Init() &&
104 (lphc = HeapAlloc(GetProcessHeap(), 0, sizeof(HEADCOMBO))) )
106 LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam;
108 memset( lphc, 0, sizeof(HEADCOMBO) );
109 *(LPHEADCOMBO*)wnd->wExtra = lphc;
111 /* some braindead apps do try to use scrollbar/border flags */
113 lphc->dwStyle = (lpcs->style & ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL));
114 wnd->dwStyle &= ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL);
117 * We also have to remove the client edge style to make sure
118 * we don't end-up with a non client area.
120 wnd->dwExStyle &= ~(WS_EX_CLIENTEDGE);
122 if( !(lpcs->style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) )
123 lphc->dwStyle |= CBS_HASSTRINGS;
124 if( !(wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) )
125 lphc->wState |= CBF_NOTIFY;
127 TRACE("[0x%08x], style = %08x\n",
128 (UINT)lphc, lphc->dwStyle );
130 return (LRESULT)(UINT)wnd->hwndSelf;
132 return (LRESULT)FALSE;
135 /***********************************************************************
136 * COMBO_NCDestroy
138 static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc )
141 if( lphc )
143 WND* wnd = lphc->self;
145 TRACE("[%04x]: freeing storage\n", CB_HWND(lphc));
147 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox )
148 DestroyWindow( lphc->hWndLBox );
150 HeapFree( GetProcessHeap(), 0, lphc );
151 wnd->wExtra[0] = 0;
153 return 0;
156 /***********************************************************************
157 * CBForceDummyResize
159 * The dummy resize is used for listboxes that have a popup to trigger
160 * a re-arranging of the contents of the combobox and the recalculation
161 * of the size of the "real" control window.
163 static void CBForceDummyResize(
164 LPHEADCOMBO lphc)
166 RECT windowRect;
168 GetWindowRect(CB_HWND(lphc), &windowRect);
171 * We have to be careful, resizing a combobox also has the meaning that the
172 * dropped rect will be resized. In this case, we want to trigger a resize
173 * to recalculate layout but we don't want to change the dropped rectangle
174 * So, we add the size of the dropped rectangle to the size of the control.
175 * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
176 * message.
178 SetWindowPos( CB_HWND(lphc),
179 (HWND)NULL,
180 0, 0,
181 windowRect.right - windowRect.left,
182 windowRect.bottom - windowRect.top +
183 lphc->droppedRect.bottom - lphc->droppedRect.top,
184 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
187 /***********************************************************************
188 * CBGetTextAreaHeight
190 * This method will calculate the height of the text area of the
191 * combobox.
192 * The height of the text area is set in two ways.
193 * It can be set explicitely through a combobox message of through a
194 * WM_MEASUREITEM callback.
195 * If this is not the case, the height is set to 13 dialog units.
196 * This height was determined through experimentation.
198 static INT CBGetTextAreaHeight(
199 HWND hwnd,
200 LPHEADCOMBO lphc)
202 INT iTextItemHeight;
204 if( lphc->editHeight ) /* explicitly set height */
206 iTextItemHeight = lphc->editHeight;
208 else
210 TEXTMETRICA tm;
211 HDC hDC = GetDC(hwnd);
212 HFONT hPrevFont = 0;
213 INT baseUnitY;
215 if (lphc->hFont)
216 hPrevFont = SelectObject( hDC, lphc->hFont );
218 GetTextMetricsA(hDC, &tm);
220 baseUnitY = tm.tmHeight;
222 if( hPrevFont )
223 SelectObject( hDC, hPrevFont );
225 ReleaseDC(hwnd, hDC);
227 iTextItemHeight = ((13 * baseUnitY) / 8);
230 * This "formula" calculates the height of the complete control.
231 * To calculate the height of the text area, we have to remove the
232 * borders.
234 iTextItemHeight -= 2*COMBO_YBORDERSIZE();
238 * Check the ownerdraw case if we haven't asked the parent the size
239 * of the item yet.
241 if ( CB_OWNERDRAWN(lphc) &&
242 (lphc->wState & CBF_MEASUREITEM) )
244 MEASUREITEMSTRUCT measureItem;
245 RECT clientRect;
246 INT originalItemHeight = iTextItemHeight;
249 * We use the client rect for the width of the item.
251 GetClientRect(hwnd, &clientRect);
253 lphc->wState &= ~CBF_MEASUREITEM;
256 * Send a first one to measure the size of the text area
258 measureItem.CtlType = ODT_COMBOBOX;
259 measureItem.CtlID = lphc->self->wIDmenu;
260 measureItem.itemID = -1;
261 measureItem.itemWidth = clientRect.right;
262 measureItem.itemHeight = iTextItemHeight - 6; /* ownerdrawn cb is taller */
263 measureItem.itemData = 0;
264 SendMessageA(lphc->owner, WM_MEASUREITEM,
265 (WPARAM)measureItem.CtlID, (LPARAM)&measureItem);
266 iTextItemHeight = 6 + measureItem.itemHeight;
269 * Send a second one in the case of a fixed ownerdraw list to calculate the
270 * size of the list items. (we basically do this on behalf of the listbox)
272 if (lphc->dwStyle & CBS_OWNERDRAWFIXED)
274 measureItem.CtlType = ODT_COMBOBOX;
275 measureItem.CtlID = lphc->self->wIDmenu;
276 measureItem.itemID = 0;
277 measureItem.itemWidth = clientRect.right;
278 measureItem.itemHeight = originalItemHeight;
279 measureItem.itemData = 0;
280 SendMessageA(lphc->owner, WM_MEASUREITEM,
281 (WPARAM)measureItem.CtlID, (LPARAM)&measureItem);
282 lphc->fixedOwnerDrawHeight = measureItem.itemHeight;
286 * Keep the size for the next time
288 lphc->editHeight = iTextItemHeight;
291 return iTextItemHeight;
295 /***********************************************************************
296 * CBCalcPlacement
298 * Set up component coordinates given valid lphc->RectCombo.
300 static void CBCalcPlacement(
301 HWND hwnd,
302 LPHEADCOMBO lphc,
303 LPRECT lprEdit,
304 LPRECT lprButton,
305 LPRECT lprLB)
308 * Again, start with the client rectangle.
310 GetClientRect(hwnd, lprEdit);
313 * Remove the borders
315 InflateRect(lprEdit, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
318 * Chop off the bottom part to fit with the height of the text area.
320 lprEdit->bottom = lprEdit->top + CBGetTextAreaHeight(hwnd, lphc);
323 * The button starts the same vertical position as the text area.
325 CopyRect(lprButton, lprEdit);
328 * If the combobox is "simple" there is no button.
330 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
331 lprButton->left = lprButton->right = lprButton->bottom = 0;
332 else
335 * Let's assume the combobox button is the same width as the
336 * scrollbar button.
337 * size the button horizontally and cut-off the text area.
339 lprButton->left = lprButton->right - GetSystemMetrics(SM_CXVSCROLL);
340 lprEdit->right = lprButton->left;
344 * In the case of a dropdown, there is an additional spacing between the
345 * text area and the button.
347 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
349 lprEdit->right -= COMBO_EDITBUTTONSPACE();
353 * If we have an edit control, we space it away from the borders slightly.
355 if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST)
357 InflateRect(lprEdit, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING());
361 * Adjust the size of the listbox popup.
363 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
366 * Use the client rectangle to initialize the listbox rectangle
368 GetClientRect(hwnd, lprLB);
371 * Then, chop-off the top part.
373 lprLB->top = lprEdit->bottom + COMBO_YBORDERSIZE();
375 else
378 * Make sure the dropped width is as large as the combobox itself.
380 if (lphc->droppedWidth < (lprButton->right + COMBO_XBORDERSIZE()))
382 lprLB->right = lprLB->left + (lprButton->right + COMBO_XBORDERSIZE());
385 * In the case of a dropdown, the popup listbox is offset to the right.
386 * so, we want to make sure it's flush with the right side of the
387 * combobox
389 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
390 lprLB->right -= COMBO_EDITBUTTONSPACE();
392 else
393 lprLB->right = lprLB->left + lphc->droppedWidth;
396 TRACE("\ttext\t= (%i,%i-%i,%i)\n",
397 lprEdit->left, lprEdit->top, lprEdit->right, lprEdit->bottom);
399 TRACE("\tbutton\t= (%i,%i-%i,%i)\n",
400 lprButton->left, lprButton->top, lprButton->right, lprButton->bottom);
402 TRACE("\tlbox\t= (%i,%i-%i,%i)\n",
403 lprLB->left, lprLB->top, lprLB->right, lprLB->bottom );
406 /***********************************************************************
407 * CBGetDroppedControlRect
409 static void CBGetDroppedControlRect( LPHEADCOMBO lphc, LPRECT lpRect)
411 /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner
412 of the combo box and the lower right corner of the listbox */
414 GetWindowRect(lphc->self->hwndSelf, lpRect);
416 lpRect->right = lpRect->left + lphc->droppedRect.right - lphc->droppedRect.left;
417 lpRect->bottom = lpRect->top + lphc->droppedRect.bottom - lphc->droppedRect.top;
421 /***********************************************************************
422 * COMBO_WindowPosChanging
424 static LRESULT COMBO_WindowPosChanging(
425 HWND hwnd,
426 LPHEADCOMBO lphc,
427 WINDOWPOS* posChanging)
430 * We need to override the WM_WINDOWPOSCHANGING method to handle all
431 * the non-simple comboboxes. The problem is that those controls are
432 * always the same height. We have to make sure they are not resized
433 * to another value.
435 if ( ( CB_GETTYPE(lphc) != CBS_SIMPLE ) &&
436 ((posChanging->flags & SWP_NOSIZE) == 0) )
438 int newComboHeight;
440 newComboHeight = CBGetTextAreaHeight(hwnd,lphc) +
441 2*COMBO_YBORDERSIZE();
444 * Resizing a combobox has another side effect, it resizes the dropped
445 * rectangle as well. However, it does it only if the new height for the
446 * combobox is different than the height it should have. In other words,
447 * if the application resizing the combobox only had the intention to resize
448 * the actual control, for example, to do the layout of a dialog that is
449 * resized, the height of the dropdown is not changed.
451 if (posChanging->cy != newComboHeight)
453 lphc->droppedRect.bottom = lphc->droppedRect.top + posChanging->cy - newComboHeight;
455 posChanging->cy = newComboHeight;
459 return 0;
462 /***********************************************************************
463 * COMBO_Create
465 static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, LPARAM lParam)
467 static char clbName[] = "ComboLBox";
468 static char editName[] = "Edit";
470 LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam;
472 if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE;
473 else if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
475 lphc->self = wnd;
476 lphc->owner = lpcs->hwndParent;
479 * The item height and dropped width are not set when the control
480 * is created.
482 lphc->droppedWidth = lphc->editHeight = 0;
485 * The first time we go through, we want to measure the ownerdraw item
487 lphc->wState |= CBF_MEASUREITEM;
489 /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
491 if( lphc->owner || !(lpcs->style & WS_VISIBLE) )
493 UINT lbeStyle = 0;
494 UINT lbeExStyle = 0;
497 * Initialize the dropped rect to the size of the client area of the
498 * control and then, force all the areas of the combobox to be
499 * recalculated.
501 GetClientRect( wnd->hwndSelf, &lphc->droppedRect );
503 CBCalcPlacement(wnd->hwndSelf,
504 lphc,
505 &lphc->textRect,
506 &lphc->buttonRect,
507 &lphc->droppedRect );
510 * Adjust the position of the popup listbox if it's necessary
512 if ( CB_GETTYPE(lphc) != CBS_SIMPLE )
514 lphc->droppedRect.top = lphc->textRect.bottom + COMBO_YBORDERSIZE();
517 * If it's a dropdown, the listbox is offset
519 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
520 lphc->droppedRect.left += COMBO_EDITBUTTONSPACE();
522 ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect);
523 ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect.right);
526 /* create listbox popup */
528 lbeStyle = (LBS_NOTIFY | WS_BORDER | WS_CLIPSIBLINGS) |
529 (lpcs->style & (WS_VSCROLL | CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE));
531 if( lphc->dwStyle & CBS_SORT )
532 lbeStyle |= LBS_SORT;
533 if( lphc->dwStyle & CBS_HASSTRINGS )
534 lbeStyle |= LBS_HASSTRINGS;
535 if( lphc->dwStyle & CBS_NOINTEGRALHEIGHT )
536 lbeStyle |= LBS_NOINTEGRALHEIGHT;
537 if( lphc->dwStyle & CBS_DISABLENOSCROLL )
538 lbeStyle |= LBS_DISABLENOSCROLL;
540 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */
542 lbeStyle |= WS_CHILD | WS_VISIBLE;
545 * In win 95 look n feel, the listbox in the simple combobox has
546 * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
548 if (TWEAK_WineLook > WIN31_LOOK)
550 lbeStyle &= ~WS_BORDER;
551 lbeExStyle |= WS_EX_CLIENTEDGE;
554 else /* popup listbox */
555 lbeStyle |= WS_POPUP;
557 /* Dropdown ComboLBox is not a child window and we cannot pass
558 * ID_CB_LISTBOX directly because it will be treated as a menu handle.
560 lphc->hWndLBox = CreateWindowExA(lbeExStyle,
561 clbName,
562 NULL,
563 lbeStyle,
564 lphc->droppedRect.left,
565 lphc->droppedRect.top,
566 lphc->droppedRect.right - lphc->droppedRect.left,
567 lphc->droppedRect.bottom - lphc->droppedRect.top,
568 lphc->self->hwndSelf,
569 (lphc->dwStyle & CBS_DROPDOWN)? (HMENU)0 : (HMENU)ID_CB_LISTBOX,
570 lphc->self->hInstance,
571 (LPVOID)lphc );
574 * The ComboLBox is a strange little beast (when it's not a CBS_SIMPLE)...
575 * It's a popup window but, when you get the window style, you get WS_CHILD.
576 * When created, it's parent is the combobox but, when you ask for it's parent
577 * after that, you're supposed to get the desktop. (see MFC code function
578 * AfxCancelModes)
579 * To achieve this in Wine, we have to create it as a popup and change
580 * it's style to child after the creation.
582 if ( (lphc->hWndLBox!= 0) &&
583 (CB_GETTYPE(lphc) != CBS_SIMPLE) )
585 SetWindowLongA(lphc->hWndLBox,
586 GWL_STYLE,
587 (GetWindowLongA(lphc->hWndLBox, GWL_STYLE) | WS_CHILD) & ~WS_POPUP);
590 if( lphc->hWndLBox )
592 BOOL bEdit = TRUE;
593 lbeStyle = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_LEFT;
596 * In Win95 look, the border fo the edit control is
597 * provided by the combobox
599 if (TWEAK_WineLook == WIN31_LOOK)
600 lbeStyle |= WS_BORDER;
602 if( lphc->wState & CBF_EDIT )
604 if( lphc->dwStyle & CBS_OEMCONVERT )
605 lbeStyle |= ES_OEMCONVERT;
606 if( lphc->dwStyle & CBS_AUTOHSCROLL )
607 lbeStyle |= ES_AUTOHSCROLL;
608 if( lphc->dwStyle & CBS_LOWERCASE )
609 lbeStyle |= ES_LOWERCASE;
610 else if( lphc->dwStyle & CBS_UPPERCASE )
611 lbeStyle |= ES_UPPERCASE;
613 lphc->hWndEdit = CreateWindowExA(0,
614 editName,
615 NULL,
616 lbeStyle,
617 lphc->textRect.left, lphc->textRect.top,
618 lphc->textRect.right - lphc->textRect.left,
619 lphc->textRect.bottom - lphc->textRect.top,
620 lphc->self->hwndSelf,
621 (HMENU)ID_CB_EDIT,
622 lphc->self->hInstance,
623 NULL );
625 if( !lphc->hWndEdit )
626 bEdit = FALSE;
629 if( bEdit )
632 * If the combo is a dropdown, we must resize the control to fit only
633 * the text area and button. To do this, we send a dummy resize and the
634 * WM_WINDOWPOSCHANGING message will take care of setting the height for
635 * us.
637 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
639 CBForceDummyResize(lphc);
642 TRACE("init done\n");
643 return wnd->hwndSelf;
645 ERR("edit control failure.\n");
646 } else ERR("listbox failure.\n");
647 } else ERR("no owner for visible combo.\n");
649 /* CreateWindow() will send WM_NCDESTROY to cleanup */
651 return -1;
654 /***********************************************************************
655 * CBPaintButton
657 * Paint combo button (normal, pressed, and disabled states).
659 static void CBPaintButton(
660 LPHEADCOMBO lphc,
661 HDC hdc,
662 RECT rectButton)
664 if( lphc->wState & CBF_NOREDRAW )
665 return;
667 if (TWEAK_WineLook == WIN31_LOOK)
669 UINT x, y;
670 BOOL bBool;
671 HDC hMemDC;
672 HBRUSH hPrevBrush;
673 COLORREF oldTextColor, oldBkColor;
676 hPrevBrush = SelectObject(hdc, GetSysColorBrush(COLOR_BTNFACE));
679 * Draw the button background
681 PatBlt( hdc,
682 rectButton.left,
683 rectButton.top,
684 rectButton.right-rectButton.left,
685 rectButton.bottom-rectButton.top,
686 PATCOPY );
688 if( (bBool = lphc->wState & CBF_BUTTONDOWN) )
690 DrawEdge( hdc, &rectButton, EDGE_SUNKEN, BF_RECT );
692 else
694 DrawEdge( hdc, &rectButton, EDGE_RAISED, BF_RECT );
698 * Remove the edge of the button from the rectangle
699 * and calculate the position of the bitmap.
701 InflateRect( &rectButton, -2, -2);
703 x = (rectButton.left + rectButton.right - CBitWidth) >> 1;
704 y = (rectButton.top + rectButton.bottom - CBitHeight) >> 1;
707 hMemDC = CreateCompatibleDC( hdc );
708 SelectObject( hMemDC, hComboBmp );
709 oldTextColor = SetTextColor( hdc, GetSysColor(COLOR_BTNFACE) );
710 oldBkColor = SetBkColor( hdc, CB_DISABLED(lphc) ? RGB(128,128,128) :
711 RGB(0,0,0) );
712 BitBlt( hdc, x, y, CBitWidth, CBitHeight, hMemDC, 0, 0, SRCCOPY );
713 SetBkColor( hdc, oldBkColor );
714 SetTextColor( hdc, oldTextColor );
715 DeleteDC( hMemDC );
716 SelectObject( hdc, hPrevBrush );
718 else
720 UINT buttonState = DFCS_SCROLLCOMBOBOX;
722 if (lphc->wState & CBF_BUTTONDOWN)
724 buttonState |= DFCS_PUSHED;
727 if (CB_DISABLED(lphc))
729 buttonState |= DFCS_INACTIVE;
732 DrawFrameControl(hdc,
733 &rectButton,
734 DFC_SCROLL,
735 buttonState);
739 /***********************************************************************
740 * CBPaintText
742 * Paint CBS_DROPDOWNLIST text field / update edit control contents.
744 static void CBPaintText(
745 LPHEADCOMBO lphc,
746 HDC hdc,
747 RECT rectEdit)
749 INT id, size = 0;
750 LPSTR pText = NULL;
752 if( lphc->wState & CBF_NOREDRAW ) return;
754 /* follow Windows combobox that sends a bunch of text
755 * inquiries to its listbox while processing WM_PAINT. */
757 if( (id = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0) ) != LB_ERR )
759 size = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, id, 0);
760 if( (pText = HeapAlloc( GetProcessHeap(), 0, size + 1)) )
762 SendMessageA( lphc->hWndLBox, LB_GETTEXT, (WPARAM)id, (LPARAM)pText );
763 pText[size] = '\0'; /* just in case */
764 } else return;
767 if( lphc->wState & CBF_EDIT )
769 if( CB_HASSTRINGS(lphc) ) SetWindowTextA( lphc->hWndEdit, pText ? pText : "" );
770 if( lphc->wState & CBF_FOCUSED )
771 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1));
773 else /* paint text field ourselves */
775 UINT itemState;
776 HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
779 * Give ourselves some space.
781 InflateRect( &rectEdit, -1, -1 );
783 if ( (lphc->wState & CBF_FOCUSED) &&
784 !(lphc->wState & CBF_DROPPED) )
786 /* highlight */
788 FillRect( hdc, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) );
789 SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
790 SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
791 itemState = ODS_SELECTED | ODS_FOCUS;
793 else
794 itemState = 0;
796 if( CB_OWNERDRAWN(lphc) )
798 DRAWITEMSTRUCT dis;
799 HRGN clipRegion;
802 * Save the current clip region.
803 * To retrieve the clip region, we need to create one "dummy"
804 * clip region.
806 clipRegion = CreateRectRgnIndirect(&rectEdit);
808 if (GetClipRgn(hdc, clipRegion)!=1)
810 DeleteObject(clipRegion);
811 clipRegion=(HRGN)NULL;
814 if ( lphc->self->dwStyle & WS_DISABLED )
815 itemState |= ODS_DISABLED;
817 dis.CtlType = ODT_COMBOBOX;
818 dis.CtlID = lphc->self->wIDmenu;
819 dis.hwndItem = lphc->self->hwndSelf;
820 dis.itemAction = ODA_DRAWENTIRE;
821 dis.itemID = id;
822 dis.itemState = itemState;
823 dis.hDC = hdc;
824 dis.rcItem = rectEdit;
825 dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA,
826 (WPARAM)id, 0 );
829 * Clip the DC and have the parent draw the item.
831 IntersectClipRect(hdc,
832 rectEdit.left, rectEdit.top,
833 rectEdit.right, rectEdit.bottom);
835 SendMessageA(lphc->owner, WM_DRAWITEM,
836 lphc->self->wIDmenu, (LPARAM)&dis );
839 * Reset the clipping region.
841 SelectClipRgn(hdc, clipRegion);
843 else
845 ExtTextOutA( hdc,
846 rectEdit.left + 1,
847 rectEdit.top + 1,
848 ETO_OPAQUE | ETO_CLIPPED,
849 &rectEdit,
850 pText ? pText : "" , size, NULL );
852 if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED))
853 DrawFocusRect( hdc, &rectEdit );
856 if( hPrevFont )
857 SelectObject(hdc, hPrevFont );
859 if (pText)
860 HeapFree( GetProcessHeap(), 0, pText );
863 /***********************************************************************
864 * CBPaintBorder
866 static void CBPaintBorder(
867 HWND hwnd,
868 LPHEADCOMBO lphc,
869 HDC hdc)
871 RECT clientRect;
873 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
875 GetClientRect(hwnd, &clientRect);
877 else
879 CopyRect(&clientRect, &lphc->textRect);
881 InflateRect(&clientRect, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
882 InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
885 DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT);
888 /***********************************************************************
889 * COMBO_PrepareColors
891 * This method will sent the appropriate WM_CTLCOLOR message to
892 * prepare and setup the colors for the combo's DC.
894 * It also returns the brush to use for the background.
896 static HBRUSH COMBO_PrepareColors(
897 HWND hwnd,
898 LPHEADCOMBO lphc,
899 HDC hDC)
901 HBRUSH hBkgBrush;
904 * Get the background brush for this control.
906 if (CB_DISABLED(lphc))
908 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORSTATIC,
909 hDC, lphc->self->hwndSelf );
912 * We have to change the text color since WM_CTLCOLORSTATIC will
913 * set it to the "enabled" color. This is the same behavior as the
914 * edit control
916 SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT));
918 else
920 if (lphc->wState & CBF_EDIT)
922 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLOREDIT,
923 hDC, lphc->self->hwndSelf );
925 else
927 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX,
928 hDC, lphc->self->hwndSelf );
933 * Catch errors.
935 if( !hBkgBrush )
936 hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
938 return hBkgBrush;
941 /***********************************************************************
942 * COMBO_EraseBackground
944 static LRESULT COMBO_EraseBackground(
945 HWND hwnd,
946 LPHEADCOMBO lphc,
947 HDC hParamDC)
949 HBRUSH hBkgBrush;
950 RECT clientRect;
951 HDC hDC;
953 hDC = (hParamDC) ? hParamDC
954 : GetDC(hwnd);
957 * Calculate the area that we want to erase.
959 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
961 GetClientRect(hwnd, &clientRect);
963 else
965 CopyRect(&clientRect, &lphc->textRect);
967 InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
971 * Retrieve the background brush
973 hBkgBrush = COMBO_PrepareColors(hwnd, lphc, hDC);
975 FillRect(hDC, &clientRect, hBkgBrush);
977 if (!hParamDC)
978 ReleaseDC(hwnd, hDC);
980 return TRUE;
983 /***********************************************************************
984 * COMBO_Paint
986 static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC)
988 PAINTSTRUCT ps;
989 HDC hDC;
991 hDC = (hParamDC) ? hParamDC
992 : BeginPaint( lphc->self->hwndSelf, &ps);
995 if( hDC && !(lphc->wState & CBF_NOREDRAW) )
997 HBRUSH hPrevBrush, hBkgBrush;
1000 * Retrieve the background brush and select it in the
1001 * DC.
1003 hBkgBrush = COMBO_PrepareColors(lphc->self->hwndSelf, lphc, hDC);
1005 hPrevBrush = SelectObject( hDC, hBkgBrush );
1008 * In non 3.1 look, there is a sunken border on the combobox
1010 if (TWEAK_WineLook != WIN31_LOOK)
1012 CBPaintBorder(CB_HWND(lphc), lphc, hDC);
1015 if( !IsRectEmpty(&lphc->buttonRect) )
1017 CBPaintButton(lphc, hDC, lphc->buttonRect);
1020 if( !(lphc->wState & CBF_EDIT) )
1023 * The text area has a border only in Win 3.1 look.
1025 if (TWEAK_WineLook == WIN31_LOOK)
1027 HPEN hPrevPen = SelectObject( hDC, GetSysColorPen(COLOR_WINDOWFRAME) );
1029 Rectangle( hDC,
1030 lphc->textRect.left, lphc->textRect.top,
1031 lphc->textRect.right - 1, lphc->textRect.bottom - 1);
1033 SelectObject( hDC, hPrevPen );
1036 CBPaintText( lphc, hDC, lphc->textRect);
1039 if( hPrevBrush )
1040 SelectObject( hDC, hPrevBrush );
1043 if( !hParamDC )
1044 EndPaint(lphc->self->hwndSelf, &ps);
1046 return 0;
1049 /***********************************************************************
1050 * CBUpdateLBox
1052 * Select listbox entry according to the contents of the edit control.
1054 static INT CBUpdateLBox( LPHEADCOMBO lphc )
1056 INT length, idx, ret;
1057 LPSTR pText = NULL;
1059 idx = ret = LB_ERR;
1060 length = CB_GETEDITTEXTLENGTH( lphc );
1062 if( length > 0 )
1063 pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1);
1065 TRACE("\t edit text length %i\n", length );
1067 if( pText )
1069 if( length ) GetWindowTextA( lphc->hWndEdit, pText, length + 1);
1070 else pText[0] = '\0';
1071 idx = SendMessageA( lphc->hWndLBox, LB_FINDSTRING,
1072 (WPARAM)(-1), (LPARAM)pText );
1073 if( idx == LB_ERR ) idx = 0; /* select first item */
1074 else ret = idx;
1075 HeapFree( GetProcessHeap(), 0, pText );
1078 /* select entry */
1080 SendMessageA( lphc->hWndLBox, LB_SETCURSEL, (WPARAM)idx, 0 );
1082 if( idx >= 0 )
1084 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)idx, 0 );
1085 /* probably superfluous but Windows sends this too */
1086 SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)idx, 0 );
1088 return ret;
1091 /***********************************************************************
1092 * CBUpdateEdit
1094 * Copy a listbox entry to the edit control.
1096 static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
1098 INT length;
1099 LPSTR pText = NULL;
1101 TRACE("\t %i\n", index );
1103 if( index == -1 )
1105 length = CB_GETEDITTEXTLENGTH( lphc );
1106 if( length )
1108 if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) )
1110 GetWindowTextA( lphc->hWndEdit, pText, length + 1 );
1111 index = SendMessageA( lphc->hWndLBox, LB_FINDSTRING,
1112 (WPARAM)(-1), (LPARAM)pText );
1113 HeapFree( GetProcessHeap(), 0, pText );
1118 if( index >= 0 ) /* got an entry */
1120 length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, (WPARAM)index, 0);
1121 if( length )
1123 if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) )
1125 SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1126 (WPARAM)index, (LPARAM)pText );
1128 lphc->wState |= CBF_NOEDITNOTIFY;
1130 SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, (LPARAM)pText );
1131 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
1132 HeapFree( GetProcessHeap(), 0, pText );
1138 /***********************************************************************
1139 * CBDropDown
1141 * Show listbox popup.
1143 static void CBDropDown( LPHEADCOMBO lphc )
1145 RECT rect;
1146 int nItems = 0;
1147 int i;
1148 int nHeight;
1149 int nDroppedHeight, nTempDroppedHeight;
1151 TRACE("[%04x]: drop down\n", CB_HWND(lphc));
1153 CB_NOTIFY( lphc, CBN_DROPDOWN );
1155 /* set selection */
1157 lphc->wState |= CBF_DROPPED;
1158 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1160 lphc->droppedIndex = CBUpdateLBox( lphc );
1162 if( !(lphc->wState & CBF_CAPTURE) )
1163 CBUpdateEdit( lphc, lphc->droppedIndex );
1165 else
1167 lphc->droppedIndex = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1169 if( lphc->droppedIndex == LB_ERR )
1170 lphc->droppedIndex = 0;
1172 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)lphc->droppedIndex, 0 );
1173 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
1176 /* now set popup position */
1177 GetWindowRect( lphc->self->hwndSelf, &rect );
1180 * If it's a dropdown, the listbox is offset
1182 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1183 rect.left += COMBO_EDITBUTTONSPACE();
1185 /* if the dropped height is greater than the total height of the dropped
1186 items list, then force the drop down list height to be the total height
1187 of the items in the dropped list */
1189 /* And Remove any extra space (Best Fit) */
1190 nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
1191 nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0);
1192 nHeight = COMBO_YBORDERSIZE();
1193 nTempDroppedHeight = 0;
1194 for (i = 0; i < nItems; i++)
1196 nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0);
1198 /* Did we pass the limit of what can be displayed */
1199 if (nHeight > nDroppedHeight)
1201 break;
1203 nTempDroppedHeight = nHeight;
1206 nDroppedHeight = nTempDroppedHeight;
1208 SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
1209 lphc->droppedRect.right - lphc->droppedRect.left,
1210 nDroppedHeight,
1211 SWP_NOACTIVATE | SWP_NOREDRAW);
1213 if( !(lphc->wState & CBF_NOREDRAW) )
1214 RedrawWindow( lphc->self->hwndSelf, NULL, 0, RDW_INVALIDATE |
1215 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
1217 ShowWindow( lphc->hWndLBox, SW_SHOWNA );
1220 /***********************************************************************
1221 * CBRollUp
1223 * Hide listbox popup.
1225 static void CBRollUp( LPHEADCOMBO lphc, BOOL ok, BOOL bButton )
1227 HWND hWnd = lphc->self->hwndSelf;
1229 CB_NOTIFY( lphc, (ok) ? CBN_SELENDOK : CBN_SELENDCANCEL );
1231 if( IsWindow( hWnd ) && CB_GETTYPE(lphc) != CBS_SIMPLE )
1234 TRACE("[%04x]: roll up [%i]\n", CB_HWND(lphc), (INT)ok );
1236 if( lphc->wState & CBF_DROPPED )
1238 RECT rect;
1241 * It seems useful to send the WM_LBUTTONUP with (-1,-1) when cancelling
1242 * and with (0,0) (anywhere in the listbox) when Oking.
1244 SendMessageA( lphc->hWndLBox, WM_LBUTTONUP, 0, ok ? (LPARAM)0 : (LPARAM)(-1) );
1246 lphc->wState &= ~CBF_DROPPED;
1247 ShowWindow( lphc->hWndLBox, SW_HIDE );
1248 if(GetCapture() == lphc->hWndLBox)
1250 ReleaseCapture();
1254 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1256 INT index = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1257 CBUpdateEdit( lphc, index );
1258 rect = lphc->buttonRect;
1260 else
1262 if( bButton )
1264 UnionRect( &rect,
1265 &lphc->buttonRect,
1266 &lphc->textRect);
1268 else
1269 rect = lphc->textRect;
1271 bButton = TRUE;
1274 if( bButton && !(lphc->wState & CBF_NOREDRAW) )
1275 RedrawWindow( hWnd, &rect, 0, RDW_INVALIDATE |
1276 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
1277 CB_NOTIFY( lphc, CBN_CLOSEUP );
1282 /***********************************************************************
1283 * COMBO_FlipListbox
1285 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
1287 BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL bRedrawButton )
1289 if( lphc->wState & CBF_DROPPED )
1291 CBRollUp( lphc, TRUE, bRedrawButton );
1292 return FALSE;
1295 CBDropDown( lphc );
1296 return TRUE;
1299 /***********************************************************************
1300 * COMBO_GetLBWindow
1302 * Edit control helper.
1304 HWND COMBO_GetLBWindow( WND* pWnd )
1306 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1307 if( lphc ) return lphc->hWndLBox;
1308 return 0;
1312 /***********************************************************************
1313 * CBRepaintButton
1315 static void CBRepaintButton( LPHEADCOMBO lphc )
1317 InvalidateRect(CB_HWND(lphc), &lphc->buttonRect, TRUE);
1318 UpdateWindow(CB_HWND(lphc));
1321 /***********************************************************************
1322 * COMBO_SetFocus
1324 static void COMBO_SetFocus( LPHEADCOMBO lphc )
1326 if( !(lphc->wState & CBF_FOCUSED) )
1328 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1329 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
1331 if( lphc->wState & CBF_EDIT )
1332 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
1333 lphc->wState |= CBF_FOCUSED;
1334 if( !(lphc->wState & CBF_EDIT) )
1336 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1339 CB_NOTIFY( lphc, CBN_SETFOCUS );
1343 /***********************************************************************
1344 * COMBO_KillFocus
1346 static void COMBO_KillFocus( LPHEADCOMBO lphc )
1348 HWND hWnd = lphc->self->hwndSelf;
1350 if( lphc->wState & CBF_FOCUSED )
1352 SendMessageA( hWnd, WM_LBUTTONUP, 0, (LPARAM)(-1) );
1354 CBRollUp( lphc, FALSE, TRUE );
1355 if( IsWindow( hWnd ) )
1357 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1358 SendMessageA( lphc->hWndLBox, LB_CARETOFF, 0, 0 );
1360 lphc->wState &= ~CBF_FOCUSED;
1362 /* redraw text */
1363 if( lphc->wState & CBF_EDIT )
1364 SendMessageA( lphc->hWndEdit, EM_SETSEL, (WPARAM)(-1), 0 );
1365 else
1367 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1370 CB_NOTIFY( lphc, CBN_KILLFOCUS );
1375 /***********************************************************************
1376 * COMBO_Command
1378 static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd )
1380 if ( lphc->wState & CBF_EDIT && lphc->hWndEdit == hWnd )
1382 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1384 switch( HIWORD(wParam) >> 8 )
1386 case (EN_SETFOCUS >> 8):
1388 TRACE("[%04x]: edit [%04x] got focus\n",
1389 CB_HWND(lphc), lphc->hWndEdit );
1391 if( !(lphc->wState & CBF_FOCUSED) ) COMBO_SetFocus( lphc );
1392 break;
1394 case (EN_KILLFOCUS >> 8):
1396 TRACE("[%04x]: edit [%04x] lost focus\n",
1397 CB_HWND(lphc), lphc->hWndEdit );
1399 /* NOTE: it seems that Windows' edit control sends an
1400 * undocumented message WM_USER + 0x1B instead of this
1401 * notification (only when it happens to be a part of
1402 * the combo). ?? - AK.
1405 COMBO_KillFocus( lphc );
1406 break;
1409 case (EN_CHANGE >> 8):
1411 * In some circumstances (when the selection of the combobox
1412 * is changed for example) we don't wans the EN_CHANGE notification
1413 * to be forwarded to the parent of the combobox. This code
1414 * checks a flag that is set in these occasions and ignores the
1415 * notification.
1417 if (lphc->wState & CBF_NOEDITNOTIFY)
1419 lphc->wState &= ~CBF_NOEDITNOTIFY;
1421 else
1423 CB_NOTIFY( lphc, CBN_EDITCHANGE );
1426 CBUpdateLBox( lphc );
1427 break;
1429 case (EN_UPDATE >> 8):
1430 CB_NOTIFY( lphc, CBN_EDITUPDATE );
1431 break;
1433 case (EN_ERRSPACE >> 8):
1434 CB_NOTIFY( lphc, CBN_ERRSPACE );
1437 else if( lphc->hWndLBox == hWnd )
1439 switch( HIWORD(wParam) )
1441 case LBN_ERRSPACE:
1442 CB_NOTIFY( lphc, CBN_ERRSPACE );
1443 break;
1445 case LBN_DBLCLK:
1446 CB_NOTIFY( lphc, CBN_DBLCLK );
1447 break;
1449 case LBN_SELCHANGE:
1450 case LBN_SELCANCEL:
1452 TRACE("[%04x]: lbox selection change [%04x]\n",
1453 CB_HWND(lphc), lphc->wState );
1455 /* do not roll up if selection is being tracked
1456 * by arrowkeys in the dropdown listbox */
1458 if( (lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP) )
1459 CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
1460 else lphc->wState &= ~CBF_NOROLLUP;
1462 CB_NOTIFY( lphc, CBN_SELCHANGE );
1463 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1464 /* fall through */
1466 case LBN_SETFOCUS:
1467 case LBN_KILLFOCUS:
1468 /* nothing to do here since ComboLBox always resets the focus to its
1469 * combo/edit counterpart */
1470 break;
1473 return 0;
1476 /***********************************************************************
1477 * COMBO_ItemOp
1479 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1481 static LRESULT COMBO_ItemOp( LPHEADCOMBO lphc, UINT msg,
1482 WPARAM wParam, LPARAM lParam )
1484 HWND hWnd = lphc->self->hwndSelf;
1486 TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg );
1488 #define lpIS ((LPDELETEITEMSTRUCT)lParam)
1490 /* two first items are the same in all 4 structs */
1491 lpIS->CtlType = ODT_COMBOBOX;
1492 lpIS->CtlID = lphc->self->wIDmenu;
1494 switch( msg ) /* patch window handle */
1496 case WM_DELETEITEM:
1497 lpIS->hwndItem = hWnd;
1498 #undef lpIS
1499 break;
1500 case WM_DRAWITEM:
1501 #define lpIS ((LPDRAWITEMSTRUCT)lParam)
1502 lpIS->hwndItem = hWnd;
1503 #undef lpIS
1504 break;
1505 case WM_COMPAREITEM:
1506 #define lpIS ((LPCOMPAREITEMSTRUCT)lParam)
1507 lpIS->hwndItem = hWnd;
1508 #undef lpIS
1509 break;
1512 return SendMessageA( lphc->owner, msg, lphc->self->wIDmenu, lParam );
1515 /***********************************************************************
1516 * COMBO_GetText
1518 static LRESULT COMBO_GetText( LPHEADCOMBO lphc, UINT N, LPSTR lpText)
1520 if( lphc->wState & CBF_EDIT )
1521 return SendMessageA( lphc->hWndEdit, WM_GETTEXT,
1522 (WPARAM)N, (LPARAM)lpText );
1524 /* get it from the listbox */
1526 if( lphc->hWndLBox )
1528 INT idx = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1529 if( idx != LB_ERR )
1531 LPSTR lpBuffer;
1532 INT length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN,
1533 (WPARAM)idx, 0 );
1535 /* 'length' is without the terminating character */
1536 if( length >= N )
1537 lpBuffer = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1 );
1538 else
1539 lpBuffer = lpText;
1541 if( lpBuffer )
1543 INT n = SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1544 (WPARAM)idx, (LPARAM)lpBuffer );
1546 /* truncate if buffer is too short */
1548 if( length >= N )
1550 if (N && lpText) {
1551 if( n != LB_ERR ) memcpy( lpText, lpBuffer, (N>n) ? n+1 : N-1 );
1552 lpText[N - 1] = '\0';
1554 HeapFree( GetProcessHeap(), 0, lpBuffer );
1556 return (LRESULT)n;
1560 return 0;
1564 /***********************************************************************
1565 * CBResetPos
1567 * This function sets window positions according to the updated
1568 * component placement struct.
1570 static void CBResetPos(
1571 LPHEADCOMBO lphc,
1572 LPRECT rectEdit,
1573 LPRECT rectLB,
1574 BOOL bRedraw)
1576 BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
1578 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1579 * sizing messages */
1581 if( lphc->wState & CBF_EDIT )
1582 SetWindowPos( lphc->hWndEdit, 0,
1583 rectEdit->left, rectEdit->top,
1584 rectEdit->right - rectEdit->left,
1585 rectEdit->bottom - rectEdit->top,
1586 SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
1588 SetWindowPos( lphc->hWndLBox, 0,
1589 rectLB->left, rectLB->top,
1590 rectLB->right - rectLB->left,
1591 rectLB->bottom - rectLB->top,
1592 SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) );
1594 if( bDrop )
1596 if( lphc->wState & CBF_DROPPED )
1598 lphc->wState &= ~CBF_DROPPED;
1599 ShowWindow( lphc->hWndLBox, SW_HIDE );
1602 if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
1603 RedrawWindow( lphc->self->hwndSelf, NULL, 0,
1604 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
1609 /***********************************************************************
1610 * COMBO_Size
1612 static void COMBO_Size( LPHEADCOMBO lphc )
1614 CBCalcPlacement(lphc->self->hwndSelf,
1615 lphc,
1616 &lphc->textRect,
1617 &lphc->buttonRect,
1618 &lphc->droppedRect);
1620 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1624 /***********************************************************************
1625 * COMBO_Font
1627 static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw )
1630 * Set the font
1632 lphc->hFont = hFont;
1635 * Propagate to owned windows.
1637 if( lphc->wState & CBF_EDIT )
1638 SendMessageA( lphc->hWndEdit, WM_SETFONT, (WPARAM)hFont, bRedraw );
1639 SendMessageA( lphc->hWndLBox, WM_SETFONT, (WPARAM)hFont, bRedraw );
1642 * Redo the layout of the control.
1644 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1646 CBCalcPlacement(lphc->self->hwndSelf,
1647 lphc,
1648 &lphc->textRect,
1649 &lphc->buttonRect,
1650 &lphc->droppedRect);
1652 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1654 else
1656 CBForceDummyResize(lphc);
1661 /***********************************************************************
1662 * COMBO_SetItemHeight
1664 static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height )
1666 LRESULT lRet = CB_ERR;
1668 if( index == -1 ) /* set text field height */
1670 if( height < 32768 )
1672 lphc->editHeight = height;
1675 * Redo the layout of the control.
1677 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1679 CBCalcPlacement(lphc->self->hwndSelf,
1680 lphc,
1681 &lphc->textRect,
1682 &lphc->buttonRect,
1683 &lphc->droppedRect);
1685 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1687 else
1689 CBForceDummyResize(lphc);
1692 lRet = height;
1695 else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */
1696 lRet = SendMessageA( lphc->hWndLBox, LB_SETITEMHEIGHT,
1697 (WPARAM)index, (LPARAM)height );
1698 return lRet;
1701 /***********************************************************************
1702 * COMBO_SelectString
1704 static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT start, LPCSTR pText )
1706 INT index = SendMessageA( lphc->hWndLBox, LB_SELECTSTRING,
1707 (WPARAM)start, (LPARAM)pText );
1708 if( index >= 0 )
1710 if( lphc->wState & CBF_EDIT )
1711 CBUpdateEdit( lphc, index );
1712 else
1714 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1717 return (LRESULT)index;
1720 /***********************************************************************
1721 * COMBO_LButtonDown
1723 static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam )
1725 POINT pt;
1726 BOOL bButton;
1727 HWND hWnd = lphc->self->hwndSelf;
1729 pt.x = LOWORD(lParam);
1730 pt.y = HIWORD(lParam);
1731 bButton = PtInRect(&lphc->buttonRect, pt);
1733 if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
1734 (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) )
1736 lphc->wState |= CBF_BUTTONDOWN;
1737 if( lphc->wState & CBF_DROPPED )
1739 /* got a click to cancel selection */
1741 lphc->wState &= ~CBF_BUTTONDOWN;
1742 CBRollUp( lphc, TRUE, FALSE );
1743 if( !IsWindow( hWnd ) ) return;
1745 if( lphc->wState & CBF_CAPTURE )
1747 lphc->wState &= ~CBF_CAPTURE;
1748 ReleaseCapture();
1751 else
1753 /* drop down the listbox and start tracking */
1755 lphc->wState |= CBF_CAPTURE;
1756 CBDropDown( lphc );
1757 SetCapture( hWnd );
1759 if( bButton ) CBRepaintButton( lphc );
1763 /***********************************************************************
1764 * COMBO_LButtonUp
1766 * Release capture and stop tracking if needed.
1768 static void COMBO_LButtonUp( LPHEADCOMBO lphc, LPARAM lParam )
1770 if( lphc->wState & CBF_CAPTURE )
1772 lphc->wState &= ~CBF_CAPTURE;
1773 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1775 INT index = CBUpdateLBox( lphc );
1776 CBUpdateEdit( lphc, index );
1778 ReleaseCapture();
1779 SetCapture(lphc->hWndLBox);
1783 if( lphc->wState & CBF_BUTTONDOWN )
1785 lphc->wState &= ~CBF_BUTTONDOWN;
1786 CBRepaintButton( lphc );
1790 /***********************************************************************
1791 * COMBO_MouseMove
1793 * Two things to do - track combo button and release capture when
1794 * pointer goes into the listbox.
1796 static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam )
1798 POINT pt;
1799 RECT lbRect;
1801 pt.x = LOWORD(lParam);
1802 pt.y = HIWORD(lParam);
1804 if( lphc->wState & CBF_BUTTONDOWN )
1806 BOOL bButton;
1808 bButton = PtInRect(&lphc->buttonRect, pt);
1810 if( !bButton )
1812 lphc->wState &= ~CBF_BUTTONDOWN;
1813 CBRepaintButton( lphc );
1817 GetClientRect( lphc->hWndLBox, &lbRect );
1818 MapWindowPoints( lphc->self->hwndSelf, lphc->hWndLBox, &pt, 1 );
1819 if( PtInRect(&lbRect, pt) )
1821 lphc->wState &= ~CBF_CAPTURE;
1822 ReleaseCapture();
1823 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc );
1825 /* hand over pointer tracking */
1826 SendMessageA( lphc->hWndLBox, WM_LBUTTONDOWN, wParam, lParam );
1831 /***********************************************************************
1832 * ComboWndProc_locked
1834 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm
1836 static inline LRESULT WINAPI ComboWndProc_locked( WND* pWnd, UINT message,
1837 WPARAM wParam, LPARAM lParam )
1839 if( pWnd ) {
1840 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1841 HWND hwnd = pWnd->hwndSelf;
1843 TRACE("[%04x]: msg %s wp %08x lp %08lx\n",
1844 pWnd->hwndSelf, SPY_GetMsgName(message), wParam, lParam );
1846 if( lphc || message == WM_NCCREATE )
1847 switch(message)
1850 /* System messages */
1852 case WM_NCCREATE:
1853 return COMBO_NCCreate(pWnd, lParam);
1854 case WM_NCDESTROY:
1855 COMBO_NCDestroy(lphc);
1856 break;/* -> DefWindowProc */
1858 case WM_CREATE:
1859 return COMBO_Create(lphc, pWnd, lParam);
1861 case WM_PRINTCLIENT:
1862 if (lParam & PRF_ERASEBKGND)
1863 COMBO_EraseBackground(hwnd, lphc, wParam);
1865 /* Fallthrough */
1866 case WM_PAINT:
1867 /* wParam may contain a valid HDC! */
1868 return COMBO_Paint(lphc, wParam);
1869 case WM_ERASEBKGND:
1870 return COMBO_EraseBackground(hwnd, lphc, wParam);
1871 case WM_GETDLGCODE:
1872 return (LRESULT)(DLGC_WANTARROWS | DLGC_WANTCHARS);
1873 case WM_WINDOWPOSCHANGING:
1874 return COMBO_WindowPosChanging(hwnd, lphc, (LPWINDOWPOS)lParam);
1875 case WM_SIZE:
1876 if( lphc->hWndLBox &&
1877 !(lphc->wState & CBF_NORESIZE) ) COMBO_Size( lphc );
1878 return TRUE;
1879 case WM_SETFONT:
1880 COMBO_Font( lphc, (HFONT16)wParam, (BOOL)lParam );
1881 return TRUE;
1882 case WM_GETFONT:
1883 return (LRESULT)lphc->hFont;
1884 case WM_SETFOCUS:
1885 if( lphc->wState & CBF_EDIT )
1886 SetFocus( lphc->hWndEdit );
1887 else
1888 COMBO_SetFocus( lphc );
1889 return TRUE;
1890 case WM_KILLFOCUS:
1891 #define hwndFocus ((HWND16)wParam)
1892 if( !hwndFocus ||
1893 (hwndFocus != lphc->hWndEdit && hwndFocus != lphc->hWndLBox ))
1894 COMBO_KillFocus( lphc );
1895 #undef hwndFocus
1896 return TRUE;
1897 case WM_COMMAND:
1898 return COMBO_Command( lphc, wParam, (HWND)lParam );
1899 case WM_GETTEXT:
1900 return COMBO_GetText( lphc, (UINT)wParam, (LPSTR)lParam );
1901 case WM_SETTEXT:
1902 case WM_GETTEXTLENGTH:
1903 case WM_CLEAR:
1904 case WM_CUT:
1905 case WM_PASTE:
1906 case WM_COPY:
1907 if ((message == WM_GETTEXTLENGTH) && !ISWIN31 && !(lphc->wState & CBF_EDIT))
1909 int j = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1910 if (j == -1) return 0;
1911 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
1913 else if( lphc->wState & CBF_EDIT )
1915 lphc->wState |= CBF_NOEDITNOTIFY;
1917 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1919 else return CB_ERR;
1921 case WM_DRAWITEM:
1922 case WM_DELETEITEM:
1923 case WM_COMPAREITEM:
1924 case WM_MEASUREITEM:
1925 return COMBO_ItemOp( lphc, message, wParam, lParam );
1926 case WM_ENABLE:
1927 if( lphc->wState & CBF_EDIT )
1928 EnableWindow( lphc->hWndEdit, (BOOL)wParam );
1929 EnableWindow( lphc->hWndLBox, (BOOL)wParam );
1931 /* Force the control to repaint when the enabled state changes. */
1932 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
1933 return TRUE;
1934 case WM_SETREDRAW:
1935 if( wParam )
1936 lphc->wState &= ~CBF_NOREDRAW;
1937 else
1938 lphc->wState |= CBF_NOREDRAW;
1940 if( lphc->wState & CBF_EDIT )
1941 SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1942 SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1943 return 0;
1944 case WM_SYSKEYDOWN:
1945 if( KEYDATA_ALT & HIWORD(lParam) )
1946 if( wParam == VK_UP || wParam == VK_DOWN )
1947 COMBO_FlipListbox( lphc, TRUE );
1948 break;/* -> DefWindowProc */
1950 case WM_CHAR:
1951 case WM_KEYDOWN:
1952 if( lphc->wState & CBF_EDIT )
1953 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1954 else
1955 return SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1956 case WM_LBUTTONDOWN:
1957 if( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self->hwndSelf );
1958 if( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam );
1959 return TRUE;
1960 case WM_LBUTTONUP:
1961 COMBO_LButtonUp( lphc, lParam );
1962 return TRUE;
1963 case WM_MOUSEMOVE:
1964 if( lphc->wState & CBF_CAPTURE )
1965 COMBO_MouseMove( lphc, wParam, lParam );
1966 return TRUE;
1967 /* Combo messages */
1969 case CB_ADDSTRING16:
1970 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1971 case CB_ADDSTRING:
1972 return SendMessageA( lphc->hWndLBox, LB_ADDSTRING, 0, lParam);
1973 case CB_INSERTSTRING16:
1974 wParam = (INT)(INT16)wParam;
1975 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1976 case CB_INSERTSTRING:
1977 return SendMessageA( lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam);
1978 case CB_DELETESTRING16:
1979 case CB_DELETESTRING:
1980 return SendMessageA( lphc->hWndLBox, LB_DELETESTRING, wParam, 0);
1981 case CB_SELECTSTRING16:
1982 wParam = (INT)(INT16)wParam;
1983 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1984 case CB_SELECTSTRING:
1985 return COMBO_SelectString( lphc, (INT)wParam, (LPSTR)lParam );
1986 case CB_FINDSTRING16:
1987 wParam = (INT)(INT16)wParam;
1988 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1989 case CB_FINDSTRING:
1990 return SendMessageA( lphc->hWndLBox, LB_FINDSTRING, wParam, lParam);
1991 case CB_FINDSTRINGEXACT16:
1992 wParam = (INT)(INT16)wParam;
1993 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1994 case CB_FINDSTRINGEXACT:
1995 return SendMessageA( lphc->hWndLBox, LB_FINDSTRINGEXACT,
1996 wParam, lParam );
1997 case CB_SETITEMHEIGHT16:
1998 wParam = (INT)(INT16)wParam; /* signed integer */
1999 case CB_SETITEMHEIGHT:
2000 return COMBO_SetItemHeight( lphc, (INT)wParam, (INT)lParam);
2001 case CB_GETITEMHEIGHT16:
2002 wParam = (INT)(INT16)wParam;
2003 case CB_GETITEMHEIGHT:
2004 if( (INT)wParam >= 0 ) /* listbox item */
2005 return SendMessageA( lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0);
2006 return CBGetTextAreaHeight(hwnd, lphc);
2007 case CB_RESETCONTENT16:
2008 case CB_RESETCONTENT:
2009 SendMessageA( lphc->hWndLBox, LB_RESETCONTENT, 0, 0 );
2010 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
2011 return TRUE;
2012 case CB_INITSTORAGE:
2013 return SendMessageA( lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam);
2014 case CB_GETHORIZONTALEXTENT:
2015 return SendMessageA( lphc->hWndLBox, LB_GETHORIZONTALEXTENT, 0, 0);
2016 case CB_SETHORIZONTALEXTENT:
2017 return SendMessageA( lphc->hWndLBox, LB_SETHORIZONTALEXTENT, wParam, 0);
2018 case CB_GETTOPINDEX:
2019 return SendMessageA( lphc->hWndLBox, LB_GETTOPINDEX, 0, 0);
2020 case CB_GETLOCALE:
2021 return SendMessageA( lphc->hWndLBox, LB_GETLOCALE, 0, 0);
2022 case CB_SETLOCALE:
2023 return SendMessageA( lphc->hWndLBox, LB_SETLOCALE, wParam, 0);
2024 case CB_GETDROPPEDWIDTH:
2025 if( lphc->droppedWidth )
2026 return lphc->droppedWidth;
2027 return lphc->droppedRect.right - lphc->droppedRect.left;
2028 case CB_SETDROPPEDWIDTH:
2029 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) &&
2030 (INT)wParam < 32768 ) lphc->droppedWidth = (INT)wParam;
2031 return CB_ERR;
2032 case CB_GETDROPPEDCONTROLRECT16:
2033 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2034 if( lParam )
2036 RECT r;
2037 CBGetDroppedControlRect( lphc, &r );
2038 CONV_RECT32TO16( &r, (LPRECT16)lParam );
2040 return CB_OKAY;
2041 case CB_GETDROPPEDCONTROLRECT:
2042 if( lParam ) CBGetDroppedControlRect(lphc, (LPRECT)lParam );
2043 return CB_OKAY;
2044 case CB_GETDROPPEDSTATE16:
2045 case CB_GETDROPPEDSTATE:
2046 return (lphc->wState & CBF_DROPPED) ? TRUE : FALSE;
2047 case CB_DIR16:
2048 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2049 /* fall through */
2050 case CB_DIR:
2051 return COMBO_Directory( lphc, (UINT)wParam,
2052 (LPSTR)lParam, (message == CB_DIR));
2053 case CB_SHOWDROPDOWN16:
2054 case CB_SHOWDROPDOWN:
2055 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
2057 if( wParam )
2059 if( !(lphc->wState & CBF_DROPPED) )
2060 CBDropDown( lphc );
2062 else
2063 if( lphc->wState & CBF_DROPPED )
2064 CBRollUp( lphc, FALSE, TRUE );
2066 return TRUE;
2067 case CB_GETCOUNT16:
2068 case CB_GETCOUNT:
2069 return SendMessageA( lphc->hWndLBox, LB_GETCOUNT, 0, 0);
2070 case CB_GETCURSEL16:
2071 case CB_GETCURSEL:
2072 return SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0);
2073 case CB_SETCURSEL16:
2074 wParam = (INT)(INT16)wParam;
2075 case CB_SETCURSEL:
2076 lParam = SendMessageA( lphc->hWndLBox, LB_SETCURSEL, wParam, 0);
2077 if( lphc->wState & CBF_SELCHANGE )
2079 /* no LBN_SELCHANGE in this case, update manually */
2080 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
2081 lphc->wState &= ~CBF_SELCHANGE;
2083 return lParam;
2084 case CB_GETLBTEXT16:
2085 wParam = (INT)(INT16)wParam;
2086 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2087 case CB_GETLBTEXT:
2088 return SendMessageA( lphc->hWndLBox, LB_GETTEXT, wParam, lParam);
2089 case CB_GETLBTEXTLEN16:
2090 wParam = (INT)(INT16)wParam;
2091 case CB_GETLBTEXTLEN:
2092 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
2093 case CB_GETITEMDATA16:
2094 wParam = (INT)(INT16)wParam;
2095 case CB_GETITEMDATA:
2096 return SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, wParam, 0);
2097 case CB_SETITEMDATA16:
2098 wParam = (INT)(INT16)wParam;
2099 case CB_SETITEMDATA:
2100 return SendMessageA( lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam);
2101 case CB_GETEDITSEL16:
2102 wParam = lParam = 0; /* just in case */
2103 case CB_GETEDITSEL:
2104 if( lphc->wState & CBF_EDIT )
2106 INT a, b;
2108 return SendMessageA( lphc->hWndEdit, EM_GETSEL,
2109 (wParam) ? wParam : (WPARAM)&a,
2110 (lParam) ? lParam : (LPARAM)&b );
2112 return CB_ERR;
2113 case CB_SETEDITSEL16:
2114 case CB_SETEDITSEL:
2115 if( lphc->wState & CBF_EDIT )
2116 return SendMessageA( lphc->hWndEdit, EM_SETSEL,
2117 (INT)(INT16)LOWORD(lParam), (INT)(INT16)HIWORD(lParam) );
2118 return CB_ERR;
2119 case CB_SETEXTENDEDUI16:
2120 case CB_SETEXTENDEDUI:
2121 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
2122 return CB_ERR;
2123 if( wParam )
2124 lphc->wState |= CBF_EUI;
2125 else lphc->wState &= ~CBF_EUI;
2126 return CB_OKAY;
2127 case CB_GETEXTENDEDUI16:
2128 case CB_GETEXTENDEDUI:
2129 return (lphc->wState & CBF_EUI) ? TRUE : FALSE;
2130 case (WM_USER + 0x1B):
2131 WARN("[%04x]: undocumented msg!\n", hwnd );
2133 return DefWindowProcA(hwnd, message, wParam, lParam);
2135 return CB_ERR;
2138 /***********************************************************************
2139 * ComboWndProc
2141 * This is just a wrapper for the real ComboWndProc which locks/unlocks
2142 * window structs.
2144 LRESULT WINAPI ComboWndProc( HWND hwnd, UINT message,
2145 WPARAM wParam, LPARAM lParam )
2147 WND* pWnd = WIN_FindWndPtr(hwnd);
2148 LRESULT retvalue = ComboWndProc_locked(pWnd,message,wParam,lParam);
2151 WIN_ReleaseWndPtr(pWnd);
2152 return retvalue;