CB_SETCURSEL should not generate another listbox event after updating
[wine.git] / controls / combo.c
blob902643f97bb8fbabbf5ee4831436f70f9ec7539e
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 "windef.h"
13 #include "wingdi.h"
14 #include "winuser.h"
15 #include "wine/winuser16.h"
16 #include "win.h"
17 #include "spy.h"
18 #include "user.h"
19 #include "heap.h"
20 #include "combo.h"
21 #include "drive.h"
22 #include "debugtools.h"
23 #include "tweak.h"
25 DEFAULT_DEBUG_CHANNEL(combo)
27 /* bits in the dwKeyData */
28 #define KEYDATA_ALT 0x2000
29 #define KEYDATA_PREVSTATE 0x4000
32 * Additional combo box definitions
35 #define CB_GETPTR( wnd ) (*(LPHEADCOMBO*)((wnd)->wExtra))
36 #define CB_NOTIFY( lphc, code ) \
37 (SendMessageA( (lphc)->owner, WM_COMMAND, \
38 MAKEWPARAM((lphc)->self->wIDmenu, (code)), (lphc)->self->hwndSelf))
39 #define CB_GETEDITTEXTLENGTH( lphc ) \
40 (SendMessageA( (lphc)->hWndEdit, WM_GETTEXTLENGTH, 0, 0 ))
42 #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03)
45 * Drawing globals
47 static HBITMAP hComboBmp = 0;
48 static UINT CBitHeight, CBitWidth;
51 * Look and feel dependant "constants"
54 #define COMBO_YBORDERGAP 5
55 #define COMBO_XBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 )
56 #define COMBO_YBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 )
57 #define COMBO_EDITBUTTONSPACE() ( (TWEAK_WineLook == WIN31_LOOK) ? 8 : 0 )
58 #define EDIT_CONTROL_PADDING() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 1 )
60 /***********************************************************************
61 * COMBO_Init
63 * Load combo button bitmap.
65 static BOOL COMBO_Init()
67 HDC hDC;
69 if( hComboBmp ) return TRUE;
70 if( (hDC = CreateCompatibleDC(0)) )
72 BOOL bRet = FALSE;
73 if( (hComboBmp = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_COMBO))) )
75 BITMAP bm;
76 HBITMAP hPrevB;
77 RECT r;
79 GetObjectA( hComboBmp, sizeof(bm), &bm );
80 CBitHeight = bm.bmHeight;
81 CBitWidth = bm.bmWidth;
83 TRACE("combo bitmap [%i,%i]\n", CBitWidth, CBitHeight );
85 hPrevB = SelectObject16( hDC, hComboBmp);
86 SetRect( &r, 0, 0, CBitWidth, CBitHeight );
87 InvertRect( hDC, &r );
88 SelectObject( hDC, hPrevB );
89 bRet = TRUE;
91 DeleteDC( hDC );
92 return bRet;
94 return FALSE;
97 /***********************************************************************
98 * COMBO_NCCreate
100 static LRESULT COMBO_NCCreate(WND* wnd, LPARAM lParam)
102 LPHEADCOMBO lphc;
104 if ( wnd && COMBO_Init() &&
105 (lphc = HeapAlloc(GetProcessHeap(), 0, sizeof(HEADCOMBO))) )
107 LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam;
109 memset( lphc, 0, sizeof(HEADCOMBO) );
110 *(LPHEADCOMBO*)wnd->wExtra = lphc;
112 /* some braindead apps do try to use scrollbar/border flags */
114 lphc->dwStyle = (lpcs->style & ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL));
115 wnd->dwStyle &= ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL);
118 * We also have to remove the client edge style to make sure
119 * we don't end-up with a non client area.
121 wnd->dwExStyle &= ~(WS_EX_CLIENTEDGE);
123 if( !(lpcs->style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) )
124 lphc->dwStyle |= CBS_HASSTRINGS;
125 if( !(wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) )
126 lphc->wState |= CBF_NOTIFY;
128 TRACE("[0x%08x], style = %08x\n",
129 (UINT)lphc, lphc->dwStyle );
131 return (LRESULT)(UINT)wnd->hwndSelf;
133 return (LRESULT)FALSE;
136 /***********************************************************************
137 * COMBO_NCDestroy
139 static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc )
142 if( lphc )
144 WND* wnd = lphc->self;
146 TRACE("[%04x]: freeing storage\n", CB_HWND(lphc));
148 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox )
149 DestroyWindow( lphc->hWndLBox );
151 HeapFree( GetProcessHeap(), 0, lphc );
152 wnd->wExtra[0] = 0;
154 return 0;
157 /***********************************************************************
158 * CBGetTextAreaHeight
160 * This method will calculate the height of the text area of the
161 * combobox.
162 * The height of the text area is set in two ways.
163 * It can be set explicitely through a combobox message of through a
164 * WM_MEASUREITEM callback.
165 * If this is not the case, the height is set to 13 dialog units.
166 * This height was determined through experimentation.
168 static INT CBGetTextAreaHeight(
169 HWND hwnd,
170 LPHEADCOMBO lphc)
172 INT iTextItemHeight;
174 if( lphc->editHeight ) /* explicitly set height */
176 iTextItemHeight = lphc->editHeight;
178 else
180 TEXTMETRICA tm;
181 HDC hDC = GetDC(hwnd);
182 HFONT hPrevFont = 0;
183 INT baseUnitY;
185 if (lphc->hFont)
186 hPrevFont = SelectObject( hDC, lphc->hFont );
188 GetTextMetricsA(hDC, &tm);
190 baseUnitY = tm.tmHeight;
192 if( hPrevFont )
193 SelectObject( hDC, hPrevFont );
195 ReleaseDC(hwnd, hDC);
197 iTextItemHeight = ((13 * baseUnitY) / 8);
200 * This "formula" calculates the height of the complete control.
201 * To calculate the height of the text area, we have to remove the
202 * borders.
204 iTextItemHeight -= 2*COMBO_YBORDERSIZE();
208 * Check the ownerdraw case if we haven't asked the parent the size
209 * of the item yet.
211 if ( CB_OWNERDRAWN(lphc) &&
212 (lphc->wState & CBF_MEASUREITEM) )
214 MEASUREITEMSTRUCT measureItem;
215 RECT clientRect;
216 INT originalItemHeight = iTextItemHeight;
219 * We use the client rect for the width of the item.
221 GetClientRect(hwnd, &clientRect);
223 lphc->wState &= ~CBF_MEASUREITEM;
226 * Send a first one to measure the size of the text area
228 measureItem.CtlType = ODT_COMBOBOX;
229 measureItem.CtlID = lphc->self->wIDmenu;
230 measureItem.itemID = -1;
231 measureItem.itemWidth = clientRect.right;
232 measureItem.itemHeight = iTextItemHeight - 6; /* ownerdrawn cb is taller */
233 measureItem.itemData = 0;
234 SendMessageA(lphc->owner, WM_MEASUREITEM,
235 (WPARAM)measureItem.CtlID, (LPARAM)&measureItem);
236 iTextItemHeight = 6 + measureItem.itemHeight;
239 * Send a second one in the case of a fixed ownerdraw list to calculate the
240 * size of the list items. (we basically do this on behalf of the listbox)
242 if (lphc->dwStyle & CBS_OWNERDRAWFIXED)
244 measureItem.CtlType = ODT_COMBOBOX;
245 measureItem.CtlID = lphc->self->wIDmenu;
246 measureItem.itemID = 0;
247 measureItem.itemWidth = clientRect.right;
248 measureItem.itemHeight = originalItemHeight;
249 measureItem.itemData = 0;
250 SendMessageA(lphc->owner, WM_MEASUREITEM,
251 (WPARAM)measureItem.CtlID, (LPARAM)&measureItem);
252 lphc->fixedOwnerDrawHeight = measureItem.itemHeight;
256 * Keep the size for the next time
258 lphc->editHeight = iTextItemHeight;
261 return iTextItemHeight;
264 /***********************************************************************
265 * CBForceDummyResize
267 * The dummy resize is used for listboxes that have a popup to trigger
268 * a re-arranging of the contents of the combobox and the recalculation
269 * of the size of the "real" control window.
271 static void CBForceDummyResize(
272 LPHEADCOMBO lphc)
274 RECT windowRect;
275 int newComboHeight;
277 newComboHeight = CBGetTextAreaHeight(CB_HWND(lphc),lphc) + 2*COMBO_YBORDERSIZE();
279 GetWindowRect(CB_HWND(lphc), &windowRect);
282 * We have to be careful, resizing a combobox also has the meaning that the
283 * dropped rect will be resized. In this case, we want to trigger a resize
284 * to recalculate layout but we don't want to change the dropped rectangle
285 * So, we pass the height of text area of control as the height.
286 * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
287 * message.
289 SetWindowPos( CB_HWND(lphc),
290 (HWND)NULL,
291 0, 0,
292 windowRect.right - windowRect.left,
293 newComboHeight,
294 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
297 /***********************************************************************
298 * CBCalcPlacement
300 * Set up component coordinates given valid lphc->RectCombo.
302 static void CBCalcPlacement(
303 HWND hwnd,
304 LPHEADCOMBO lphc,
305 LPRECT lprEdit,
306 LPRECT lprButton,
307 LPRECT lprLB)
310 * Again, start with the client rectangle.
312 GetClientRect(hwnd, lprEdit);
315 * Remove the borders
317 InflateRect(lprEdit, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
320 * Chop off the bottom part to fit with the height of the text area.
322 lprEdit->bottom = lprEdit->top + CBGetTextAreaHeight(hwnd, lphc);
325 * The button starts the same vertical position as the text area.
327 CopyRect(lprButton, lprEdit);
330 * If the combobox is "simple" there is no button.
332 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
333 lprButton->left = lprButton->right = lprButton->bottom = 0;
334 else
337 * Let's assume the combobox button is the same width as the
338 * scrollbar button.
339 * size the button horizontally and cut-off the text area.
341 lprButton->left = lprButton->right - GetSystemMetrics(SM_CXVSCROLL);
342 lprEdit->right = lprButton->left;
346 * In the case of a dropdown, there is an additional spacing between the
347 * text area and the button.
349 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
351 lprEdit->right -= COMBO_EDITBUTTONSPACE();
355 * If we have an edit control, we space it away from the borders slightly.
357 if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST)
359 InflateRect(lprEdit, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING());
363 * Adjust the size of the listbox popup.
365 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
368 * Use the client rectangle to initialize the listbox rectangle
370 GetClientRect(hwnd, lprLB);
373 * Then, chop-off the top part.
375 lprLB->top = lprEdit->bottom + COMBO_YBORDERSIZE();
377 else
380 * Make sure the dropped width is as large as the combobox itself.
382 if (lphc->droppedWidth < (lprButton->right + COMBO_XBORDERSIZE()))
384 lprLB->right = lprLB->left + (lprButton->right + COMBO_XBORDERSIZE());
387 * In the case of a dropdown, the popup listbox is offset to the right.
388 * so, we want to make sure it's flush with the right side of the
389 * combobox
391 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
392 lprLB->right -= COMBO_EDITBUTTONSPACE();
394 else
395 lprLB->right = lprLB->left + lphc->droppedWidth;
398 TRACE("\ttext\t= (%i,%i-%i,%i)\n",
399 lprEdit->left, lprEdit->top, lprEdit->right, lprEdit->bottom);
401 TRACE("\tbutton\t= (%i,%i-%i,%i)\n",
402 lprButton->left, lprButton->top, lprButton->right, lprButton->bottom);
404 TRACE("\tlbox\t= (%i,%i-%i,%i)\n",
405 lprLB->left, lprLB->top, lprLB->right, lprLB->bottom );
408 /***********************************************************************
409 * CBGetDroppedControlRect
411 static void CBGetDroppedControlRect( LPHEADCOMBO lphc, LPRECT lpRect)
413 /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner
414 of the combo box and the lower right corner of the listbox */
416 GetWindowRect(lphc->self->hwndSelf, lpRect);
418 lpRect->right = lpRect->left + lphc->droppedRect.right - lphc->droppedRect.left;
419 lpRect->bottom = lpRect->top + lphc->droppedRect.bottom - lphc->droppedRect.top;
423 /***********************************************************************
424 * COMBO_WindowPosChanging
426 static LRESULT COMBO_WindowPosChanging(
427 HWND hwnd,
428 LPHEADCOMBO lphc,
429 WINDOWPOS* posChanging)
432 * We need to override the WM_WINDOWPOSCHANGING method to handle all
433 * the non-simple comboboxes. The problem is that those controls are
434 * always the same height. We have to make sure they are not resized
435 * to another value.
437 if ( ( CB_GETTYPE(lphc) != CBS_SIMPLE ) &&
438 ((posChanging->flags & SWP_NOSIZE) == 0) )
440 int newComboHeight;
442 newComboHeight = CBGetTextAreaHeight(hwnd,lphc) +
443 2*COMBO_YBORDERSIZE();
446 * Resizing a combobox has another side effect, it resizes the dropped
447 * rectangle as well. However, it does it only if the new height for the
448 * combobox is different than the height it should have. In other words,
449 * if the application resizing the combobox only had the intention to resize
450 * the actual control, for example, to do the layout of a dialog that is
451 * resized, the height of the dropdown is not changed.
453 if (posChanging->cy != newComboHeight)
455 lphc->droppedRect.bottom = lphc->droppedRect.top + posChanging->cy - newComboHeight;
457 posChanging->cy = newComboHeight;
461 return 0;
464 /***********************************************************************
465 * COMBO_Create
467 static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, LPARAM lParam)
469 static char clbName[] = "ComboLBox";
470 static char editName[] = "Edit";
472 LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam;
474 if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE;
475 if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
477 lphc->self = wnd;
478 lphc->owner = lpcs->hwndParent;
481 * The item height and dropped width are not set when the control
482 * is created.
484 lphc->droppedWidth = lphc->editHeight = 0;
487 * The first time we go through, we want to measure the ownerdraw item
489 lphc->wState |= CBF_MEASUREITEM;
491 /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
493 if( lphc->owner || !(lpcs->style & WS_VISIBLE) )
495 UINT lbeStyle = 0;
496 UINT lbeExStyle = 0;
499 * Initialize the dropped rect to the size of the client area of the
500 * control and then, force all the areas of the combobox to be
501 * recalculated.
503 GetClientRect( wnd->hwndSelf, &lphc->droppedRect );
505 CBCalcPlacement(wnd->hwndSelf,
506 lphc,
507 &lphc->textRect,
508 &lphc->buttonRect,
509 &lphc->droppedRect );
512 * Adjust the position of the popup listbox if it's necessary
514 if ( CB_GETTYPE(lphc) != CBS_SIMPLE )
516 lphc->droppedRect.top = lphc->textRect.bottom + COMBO_YBORDERSIZE();
519 * If it's a dropdown, the listbox is offset
521 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
522 lphc->droppedRect.left += COMBO_EDITBUTTONSPACE();
524 ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect);
525 ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect.right);
528 /* create listbox popup */
530 lbeStyle = (LBS_NOTIFY | WS_BORDER | WS_CLIPSIBLINGS | WS_CHILD) |
531 (lpcs->style & (WS_VSCROLL | CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE));
533 if( lphc->dwStyle & CBS_SORT )
534 lbeStyle |= LBS_SORT;
535 if( lphc->dwStyle & CBS_HASSTRINGS )
536 lbeStyle |= LBS_HASSTRINGS;
537 if( lphc->dwStyle & CBS_NOINTEGRALHEIGHT )
538 lbeStyle |= LBS_NOINTEGRALHEIGHT;
539 if( lphc->dwStyle & CBS_DISABLENOSCROLL )
540 lbeStyle |= LBS_DISABLENOSCROLL;
542 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */
544 lbeStyle |= WS_VISIBLE;
547 * In win 95 look n feel, the listbox in the simple combobox has
548 * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
550 if (TWEAK_WineLook > WIN31_LOOK)
552 lbeStyle &= ~WS_BORDER;
553 lbeExStyle |= WS_EX_CLIENTEDGE;
557 lphc->hWndLBox = CreateWindowExA(lbeExStyle,
558 clbName,
559 NULL,
560 lbeStyle,
561 lphc->droppedRect.left,
562 lphc->droppedRect.top,
563 lphc->droppedRect.right - lphc->droppedRect.left,
564 lphc->droppedRect.bottom - lphc->droppedRect.top,
565 lphc->self->hwndSelf,
566 (HMENU)ID_CB_LISTBOX,
567 lphc->self->hInstance,
568 (LPVOID)lphc );
570 if( lphc->hWndLBox )
572 BOOL bEdit = TRUE;
573 lbeStyle = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_LEFT | ES_COMBO;
576 * In Win95 look, the border fo the edit control is
577 * provided by the combobox
579 if (TWEAK_WineLook == WIN31_LOOK)
580 lbeStyle |= WS_BORDER;
582 if( lphc->wState & CBF_EDIT )
584 if( lphc->dwStyle & CBS_OEMCONVERT )
585 lbeStyle |= ES_OEMCONVERT;
586 if( lphc->dwStyle & CBS_AUTOHSCROLL )
587 lbeStyle |= ES_AUTOHSCROLL;
588 if( lphc->dwStyle & CBS_LOWERCASE )
589 lbeStyle |= ES_LOWERCASE;
590 else if( lphc->dwStyle & CBS_UPPERCASE )
591 lbeStyle |= ES_UPPERCASE;
593 lphc->hWndEdit = CreateWindowExA(0,
594 editName,
595 NULL,
596 lbeStyle,
597 lphc->textRect.left, lphc->textRect.top,
598 lphc->textRect.right - lphc->textRect.left,
599 lphc->textRect.bottom - lphc->textRect.top,
600 lphc->self->hwndSelf,
601 (HMENU)ID_CB_EDIT,
602 lphc->self->hInstance,
603 NULL );
605 if( !lphc->hWndEdit )
606 bEdit = FALSE;
609 if( bEdit )
611 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
613 /* Now do the trick with parent */
614 SetParent(lphc->hWndLBox, HWND_DESKTOP);
616 * If the combo is a dropdown, we must resize the control to fit only
617 * the text area and button. To do this, we send a dummy resize and the
618 * WM_WINDOWPOSCHANGING message will take care of setting the height for
619 * us.
621 CBForceDummyResize(lphc);
624 TRACE("init done\n");
625 return wnd->hwndSelf;
627 ERR("edit control failure.\n");
628 } else ERR("listbox failure.\n");
629 } else ERR("no owner for visible combo.\n");
631 /* CreateWindow() will send WM_NCDESTROY to cleanup */
633 return -1;
636 /***********************************************************************
637 * CBPaintButton
639 * Paint combo button (normal, pressed, and disabled states).
641 static void CBPaintButton(
642 LPHEADCOMBO lphc,
643 HDC hdc,
644 RECT rectButton)
646 if( lphc->wState & CBF_NOREDRAW )
647 return;
649 if (TWEAK_WineLook == WIN31_LOOK)
651 UINT x, y;
652 BOOL bBool;
653 HDC hMemDC;
654 HBRUSH hPrevBrush;
655 COLORREF oldTextColor, oldBkColor;
658 hPrevBrush = SelectObject(hdc, GetSysColorBrush(COLOR_BTNFACE));
661 * Draw the button background
663 PatBlt( hdc,
664 rectButton.left,
665 rectButton.top,
666 rectButton.right-rectButton.left,
667 rectButton.bottom-rectButton.top,
668 PATCOPY );
670 if( (bBool = lphc->wState & CBF_BUTTONDOWN) )
672 DrawEdge( hdc, &rectButton, EDGE_SUNKEN, BF_RECT );
674 else
676 DrawEdge( hdc, &rectButton, EDGE_RAISED, BF_RECT );
680 * Remove the edge of the button from the rectangle
681 * and calculate the position of the bitmap.
683 InflateRect( &rectButton, -2, -2);
685 x = (rectButton.left + rectButton.right - CBitWidth) >> 1;
686 y = (rectButton.top + rectButton.bottom - CBitHeight) >> 1;
689 hMemDC = CreateCompatibleDC( hdc );
690 SelectObject( hMemDC, hComboBmp );
691 oldTextColor = SetTextColor( hdc, GetSysColor(COLOR_BTNFACE) );
692 oldBkColor = SetBkColor( hdc, CB_DISABLED(lphc) ? RGB(128,128,128) :
693 RGB(0,0,0) );
694 BitBlt( hdc, x, y, CBitWidth, CBitHeight, hMemDC, 0, 0, SRCCOPY );
695 SetBkColor( hdc, oldBkColor );
696 SetTextColor( hdc, oldTextColor );
697 DeleteDC( hMemDC );
698 SelectObject( hdc, hPrevBrush );
700 else
702 UINT buttonState = DFCS_SCROLLCOMBOBOX;
704 if (lphc->wState & CBF_BUTTONDOWN)
706 buttonState |= DFCS_PUSHED;
709 if (CB_DISABLED(lphc))
711 buttonState |= DFCS_INACTIVE;
714 DrawFrameControl(hdc,
715 &rectButton,
716 DFC_SCROLL,
717 buttonState);
721 /***********************************************************************
722 * CBPaintText
724 * Paint CBS_DROPDOWNLIST text field / update edit control contents.
726 static void CBPaintText(
727 LPHEADCOMBO lphc,
728 HDC hdc,
729 RECT rectEdit)
731 INT id, size = 0;
732 LPSTR pText = NULL;
734 if( lphc->wState & CBF_NOREDRAW ) return;
736 /* follow Windows combobox that sends a bunch of text
737 * inquiries to its listbox while processing WM_PAINT. */
739 if( (id = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0) ) != LB_ERR )
741 size = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, id, 0);
742 if( (pText = HeapAlloc( GetProcessHeap(), 0, size + 1)) )
744 SendMessageA( lphc->hWndLBox, LB_GETTEXT, (WPARAM)id, (LPARAM)pText );
745 pText[size] = '\0'; /* just in case */
746 } else return;
749 if( lphc->wState & CBF_EDIT )
751 if( CB_HASSTRINGS(lphc) ) SetWindowTextA( lphc->hWndEdit, pText ? pText : "" );
752 if( lphc->wState & CBF_FOCUSED )
753 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1));
755 else /* paint text field ourselves */
757 UINT itemState;
758 HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
761 * Give ourselves some space.
763 InflateRect( &rectEdit, -1, -1 );
765 if ( (lphc->wState & CBF_FOCUSED) &&
766 !(lphc->wState & CBF_DROPPED) )
768 /* highlight */
770 FillRect( hdc, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) );
771 SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
772 SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
773 itemState = ODS_SELECTED | ODS_FOCUS;
775 else
776 itemState = 0;
778 if( CB_OWNERDRAWN(lphc) )
780 DRAWITEMSTRUCT dis;
781 HRGN clipRegion;
784 * Save the current clip region.
785 * To retrieve the clip region, we need to create one "dummy"
786 * clip region.
788 clipRegion = CreateRectRgnIndirect(&rectEdit);
790 if (GetClipRgn(hdc, clipRegion)!=1)
792 DeleteObject(clipRegion);
793 clipRegion=(HRGN)NULL;
796 if ( lphc->self->dwStyle & WS_DISABLED )
797 itemState |= ODS_DISABLED;
799 dis.CtlType = ODT_COMBOBOX;
800 dis.CtlID = lphc->self->wIDmenu;
801 dis.hwndItem = lphc->self->hwndSelf;
802 dis.itemAction = ODA_DRAWENTIRE;
803 dis.itemID = id;
804 dis.itemState = itemState;
805 dis.hDC = hdc;
806 dis.rcItem = rectEdit;
807 dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA,
808 (WPARAM)id, 0 );
811 * Clip the DC and have the parent draw the item.
813 IntersectClipRect(hdc,
814 rectEdit.left, rectEdit.top,
815 rectEdit.right, rectEdit.bottom);
817 SendMessageA(lphc->owner, WM_DRAWITEM,
818 lphc->self->wIDmenu, (LPARAM)&dis );
821 * Reset the clipping region.
823 SelectClipRgn(hdc, clipRegion);
825 else
827 ExtTextOutA( hdc,
828 rectEdit.left + 1,
829 rectEdit.top + 1,
830 ETO_OPAQUE | ETO_CLIPPED,
831 &rectEdit,
832 pText ? pText : "" , size, NULL );
834 if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED))
835 DrawFocusRect( hdc, &rectEdit );
838 if( hPrevFont )
839 SelectObject(hdc, hPrevFont );
841 if (pText)
842 HeapFree( GetProcessHeap(), 0, pText );
845 /***********************************************************************
846 * CBPaintBorder
848 static void CBPaintBorder(
849 HWND hwnd,
850 LPHEADCOMBO lphc,
851 HDC hdc)
853 RECT clientRect;
855 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
857 GetClientRect(hwnd, &clientRect);
859 else
861 CopyRect(&clientRect, &lphc->textRect);
863 InflateRect(&clientRect, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
864 InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
867 DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT);
870 /***********************************************************************
871 * COMBO_PrepareColors
873 * This method will sent the appropriate WM_CTLCOLOR message to
874 * prepare and setup the colors for the combo's DC.
876 * It also returns the brush to use for the background.
878 static HBRUSH COMBO_PrepareColors(
879 HWND hwnd,
880 LPHEADCOMBO lphc,
881 HDC hDC)
883 HBRUSH hBkgBrush;
886 * Get the background brush for this control.
888 if (CB_DISABLED(lphc))
890 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORSTATIC,
891 hDC, lphc->self->hwndSelf );
894 * We have to change the text color since WM_CTLCOLORSTATIC will
895 * set it to the "enabled" color. This is the same behavior as the
896 * edit control
898 SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT));
900 else
902 if (lphc->wState & CBF_EDIT)
904 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLOREDIT,
905 hDC, lphc->self->hwndSelf );
907 else
909 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX,
910 hDC, lphc->self->hwndSelf );
915 * Catch errors.
917 if( !hBkgBrush )
918 hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
920 return hBkgBrush;
923 /***********************************************************************
924 * COMBO_EraseBackground
926 static LRESULT COMBO_EraseBackground(
927 HWND hwnd,
928 LPHEADCOMBO lphc,
929 HDC hParamDC)
931 HBRUSH hBkgBrush;
932 RECT clientRect;
933 HDC hDC;
935 hDC = (hParamDC) ? hParamDC
936 : GetDC(hwnd);
939 * Calculate the area that we want to erase.
941 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
943 GetClientRect(hwnd, &clientRect);
945 else
947 CopyRect(&clientRect, &lphc->textRect);
949 InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
953 * Retrieve the background brush
955 hBkgBrush = COMBO_PrepareColors(hwnd, lphc, hDC);
957 FillRect(hDC, &clientRect, hBkgBrush);
959 if (!hParamDC)
960 ReleaseDC(hwnd, hDC);
962 return TRUE;
965 /***********************************************************************
966 * COMBO_Paint
968 static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC)
970 PAINTSTRUCT ps;
971 HDC hDC;
973 hDC = (hParamDC) ? hParamDC
974 : BeginPaint( lphc->self->hwndSelf, &ps);
977 if( hDC && !(lphc->wState & CBF_NOREDRAW) )
979 HBRUSH hPrevBrush, hBkgBrush;
982 * Retrieve the background brush and select it in the
983 * DC.
985 hBkgBrush = COMBO_PrepareColors(lphc->self->hwndSelf, lphc, hDC);
987 hPrevBrush = SelectObject( hDC, hBkgBrush );
990 * In non 3.1 look, there is a sunken border on the combobox
992 if (TWEAK_WineLook != WIN31_LOOK)
994 CBPaintBorder(CB_HWND(lphc), lphc, hDC);
997 if( !IsRectEmpty(&lphc->buttonRect) )
999 CBPaintButton(lphc, hDC, lphc->buttonRect);
1002 if( !(lphc->wState & CBF_EDIT) )
1005 * The text area has a border only in Win 3.1 look.
1007 if (TWEAK_WineLook == WIN31_LOOK)
1009 HPEN hPrevPen = SelectObject( hDC, GetSysColorPen(COLOR_WINDOWFRAME) );
1011 Rectangle( hDC,
1012 lphc->textRect.left, lphc->textRect.top,
1013 lphc->textRect.right - 1, lphc->textRect.bottom - 1);
1015 SelectObject( hDC, hPrevPen );
1018 CBPaintText( lphc, hDC, lphc->textRect);
1021 if( hPrevBrush )
1022 SelectObject( hDC, hPrevBrush );
1025 if( !hParamDC )
1026 EndPaint(lphc->self->hwndSelf, &ps);
1028 return 0;
1031 /***********************************************************************
1032 * CBUpdateLBox
1034 * Select listbox entry according to the contents of the edit control.
1036 static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect )
1038 INT length, idx;
1039 LPSTR pText = NULL;
1041 idx = LB_ERR;
1042 length = CB_GETEDITTEXTLENGTH( lphc );
1044 if( length > 0 )
1045 pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1);
1047 TRACE("\t edit text length %i\n", length );
1049 if( pText )
1051 if( length ) GetWindowTextA( lphc->hWndEdit, pText, length + 1);
1052 else pText[0] = '\0';
1053 idx = SendMessageA( lphc->hWndLBox, LB_FINDSTRING,
1054 (WPARAM)(-1), (LPARAM)pText );
1055 HeapFree( GetProcessHeap(), 0, pText );
1058 SendMessageA( lphc->hWndLBox, LB_SETCURSEL, (WPARAM)(bSelect ? idx : -1), 0 );
1060 /* probably superfluous but Windows sends this too */
1061 SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)(idx < 0 ? 0 : idx), 0 );
1062 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)(idx < 0 ? 0 : idx), 0 );
1063 return idx;
1066 /***********************************************************************
1067 * CBUpdateEdit
1069 * Copy a listbox entry to the edit control.
1071 static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
1073 INT length;
1074 LPSTR pText = NULL;
1076 TRACE("\t %i\n", index );
1078 if( index >= 0 ) /* got an entry */
1080 length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, (WPARAM)index, 0);
1081 if( length )
1083 if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) )
1085 SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1086 (WPARAM)index, (LPARAM)pText );
1091 lphc->wState |= (CBF_NOEDITNOTIFY | CBF_NOLBSELECT);
1092 SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, pText ? (LPARAM)pText : (LPARAM)"" );
1093 lphc->wState &= ~(CBF_NOEDITNOTIFY | CBF_NOLBSELECT);
1095 if( lphc->wState & CBF_FOCUSED )
1096 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
1098 if( pText )
1099 HeapFree( GetProcessHeap(), 0, pText );
1102 /***********************************************************************
1103 * CBDropDown
1105 * Show listbox popup.
1107 static void CBDropDown( LPHEADCOMBO lphc )
1109 RECT rect;
1110 int nItems = 0;
1111 int nDroppedHeight;
1113 TRACE("[%04x]: drop down\n", CB_HWND(lphc));
1115 CB_NOTIFY( lphc, CBN_DROPDOWN );
1117 /* set selection */
1119 lphc->wState |= CBF_DROPPED;
1120 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1122 lphc->droppedIndex = CBUpdateLBox( lphc, TRUE );
1124 if( !(lphc->wState & CBF_CAPTURE) )
1125 CBUpdateEdit( lphc, lphc->droppedIndex );
1127 else
1129 lphc->droppedIndex = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1131 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX,
1132 (WPARAM)(lphc->droppedIndex == LB_ERR ? 0 : lphc->droppedIndex), 0 );
1133 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
1136 /* now set popup position */
1137 GetWindowRect( lphc->self->hwndSelf, &rect );
1140 * If it's a dropdown, the listbox is offset
1142 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1143 rect.left += COMBO_EDITBUTTONSPACE();
1145 /* if the dropped height is greater than the total height of the dropped
1146 items list, then force the drop down list height to be the total height
1147 of the items in the dropped list */
1149 /* And Remove any extra space (Best Fit) */
1150 nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
1151 nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0);
1153 if (nItems > 0)
1155 int nHeight;
1157 nHeight = (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, 0, 0);
1158 nHeight *= nItems;
1160 if (nHeight < nDroppedHeight - COMBO_YBORDERSIZE())
1161 nDroppedHeight = nHeight + COMBO_YBORDERSIZE();
1164 /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/
1165 if( (rect.bottom + nDroppedHeight) >= GetSystemMetrics( SM_CYSCREEN ) )
1166 rect.bottom = rect.top - nDroppedHeight;
1168 SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
1169 lphc->droppedRect.right - lphc->droppedRect.left,
1170 nDroppedHeight,
1171 SWP_NOACTIVATE | SWP_SHOWWINDOW);
1174 if( !(lphc->wState & CBF_NOREDRAW) )
1175 RedrawWindow( lphc->self->hwndSelf, NULL, 0, RDW_INVALIDATE |
1176 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
1178 EnableWindow( lphc->hWndLBox, TRUE );
1179 if (GetCapture() != lphc->self->hwndSelf)
1180 SetCapture(lphc->hWndLBox);
1183 /***********************************************************************
1184 * CBRollUp
1186 * Hide listbox popup.
1188 static void CBRollUp( LPHEADCOMBO lphc, BOOL ok, BOOL bButton )
1190 HWND hWnd = lphc->self->hwndSelf;
1192 CB_NOTIFY( lphc, (ok) ? CBN_SELENDOK : CBN_SELENDCANCEL );
1194 if( IsWindow( hWnd ) && CB_GETTYPE(lphc) != CBS_SIMPLE )
1197 TRACE("[%04x]: roll up [%i]\n", CB_HWND(lphc), (INT)ok );
1199 if( lphc->wState & CBF_DROPPED )
1201 RECT rect;
1203 lphc->wState &= ~CBF_DROPPED;
1204 ShowWindow( lphc->hWndLBox, SW_HIDE );
1205 if(GetCapture() == lphc->hWndLBox)
1207 ReleaseCapture();
1210 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1212 rect = lphc->buttonRect;
1214 else
1216 if( bButton )
1218 UnionRect( &rect,
1219 &lphc->buttonRect,
1220 &lphc->textRect);
1222 else
1223 rect = lphc->textRect;
1225 bButton = TRUE;
1228 if( bButton && !(lphc->wState & CBF_NOREDRAW) )
1229 RedrawWindow( hWnd, &rect, 0, RDW_INVALIDATE |
1230 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
1231 CB_NOTIFY( lphc, CBN_CLOSEUP );
1236 /***********************************************************************
1237 * COMBO_FlipListbox
1239 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
1241 BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton )
1243 if( lphc->wState & CBF_DROPPED )
1245 CBRollUp( lphc, ok, bRedrawButton );
1246 return FALSE;
1249 CBDropDown( lphc );
1250 return TRUE;
1253 /***********************************************************************
1254 * CBRepaintButton
1256 static void CBRepaintButton( LPHEADCOMBO lphc )
1258 InvalidateRect(CB_HWND(lphc), &lphc->buttonRect, TRUE);
1259 UpdateWindow(CB_HWND(lphc));
1262 /***********************************************************************
1263 * COMBO_SetFocus
1265 static void COMBO_SetFocus( LPHEADCOMBO lphc )
1267 if( !(lphc->wState & CBF_FOCUSED) )
1269 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1270 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
1272 lphc->wState |= CBF_FOCUSED;
1274 if( !(lphc->wState & CBF_EDIT) )
1275 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1277 CB_NOTIFY( lphc, CBN_SETFOCUS );
1281 /***********************************************************************
1282 * COMBO_KillFocus
1284 static void COMBO_KillFocus( LPHEADCOMBO lphc )
1286 HWND hWnd = lphc->self->hwndSelf;
1288 if( lphc->wState & CBF_FOCUSED )
1290 CBRollUp( lphc, FALSE, TRUE );
1291 if( IsWindow( hWnd ) )
1293 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1294 SendMessageA( lphc->hWndLBox, LB_CARETOFF, 0, 0 );
1296 lphc->wState &= ~CBF_FOCUSED;
1298 /* redraw text */
1299 if( !(lphc->wState & CBF_EDIT) )
1300 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1302 CB_NOTIFY( lphc, CBN_KILLFOCUS );
1307 /***********************************************************************
1308 * COMBO_Command
1310 static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd )
1312 if ( lphc->wState & CBF_EDIT && lphc->hWndEdit == hWnd )
1314 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1316 switch( HIWORD(wParam) >> 8 )
1318 case (EN_SETFOCUS >> 8):
1320 TRACE("[%04x]: edit [%04x] got focus\n",
1321 CB_HWND(lphc), lphc->hWndEdit );
1323 COMBO_SetFocus( lphc );
1324 break;
1326 case (EN_KILLFOCUS >> 8):
1328 TRACE("[%04x]: edit [%04x] lost focus\n",
1329 CB_HWND(lphc), lphc->hWndEdit );
1331 /* NOTE: it seems that Windows' edit control sends an
1332 * undocumented message WM_USER + 0x1B instead of this
1333 * notification (only when it happens to be a part of
1334 * the combo). ?? - AK.
1337 COMBO_KillFocus( lphc );
1338 break;
1341 case (EN_CHANGE >> 8):
1343 * In some circumstances (when the selection of the combobox
1344 * is changed for example) we don't wans the EN_CHANGE notification
1345 * to be forwarded to the parent of the combobox. This code
1346 * checks a flag that is set in these occasions and ignores the
1347 * notification.
1349 if (!(lphc->wState & CBF_NOEDITNOTIFY))
1350 CB_NOTIFY( lphc, CBN_EDITCHANGE );
1352 if (lphc->wState & CBF_NOLBSELECT)
1354 lphc->wState &= ~CBF_NOLBSELECT;
1356 else
1358 CBUpdateLBox( lphc, lphc->wState & CBF_DROPPED );
1360 break;
1362 case (EN_UPDATE >> 8):
1363 if (!(lphc->wState & CBF_NOEDITNOTIFY))
1364 CB_NOTIFY( lphc, CBN_EDITUPDATE );
1365 break;
1367 case (EN_ERRSPACE >> 8):
1368 CB_NOTIFY( lphc, CBN_ERRSPACE );
1371 else if( lphc->hWndLBox == hWnd )
1373 switch( HIWORD(wParam) )
1375 case LBN_ERRSPACE:
1376 CB_NOTIFY( lphc, CBN_ERRSPACE );
1377 break;
1379 case LBN_DBLCLK:
1380 CB_NOTIFY( lphc, CBN_DBLCLK );
1381 break;
1383 case LBN_SELCHANGE:
1384 case LBN_SELCANCEL:
1386 TRACE("[%04x]: lbox selection change [%04x]\n",
1387 CB_HWND(lphc), lphc->wState );
1389 /* do not roll up if selection is being tracked
1390 * by arrowkeys in the dropdown listbox */
1392 if( (lphc->dwStyle & CBS_SIMPLE) ||
1393 ((lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP)) )
1395 CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
1397 else lphc->wState &= ~CBF_NOROLLUP;
1399 CB_NOTIFY( lphc, CBN_SELCHANGE );
1401 if( HIWORD(wParam) == LBN_SELCHANGE)
1403 if( lphc->wState & CBF_EDIT )
1405 INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
1406 lphc->wState |= CBF_NOLBSELECT;
1407 CBUpdateEdit( lphc, index );
1408 /* select text in edit, as Windows does */
1409 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
1411 else
1412 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1415 /* fall through */
1417 case LBN_SETFOCUS:
1418 case LBN_KILLFOCUS:
1419 /* nothing to do here since ComboLBox always resets the focus to its
1420 * combo/edit counterpart */
1421 break;
1424 return 0;
1427 /***********************************************************************
1428 * COMBO_ItemOp
1430 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1432 static LRESULT COMBO_ItemOp( LPHEADCOMBO lphc, UINT msg,
1433 WPARAM wParam, LPARAM lParam )
1435 HWND hWnd = lphc->self->hwndSelf;
1437 TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg );
1439 #define lpIS ((LPDELETEITEMSTRUCT)lParam)
1441 /* two first items are the same in all 4 structs */
1442 lpIS->CtlType = ODT_COMBOBOX;
1443 lpIS->CtlID = lphc->self->wIDmenu;
1445 switch( msg ) /* patch window handle */
1447 case WM_DELETEITEM:
1448 lpIS->hwndItem = hWnd;
1449 #undef lpIS
1450 break;
1451 case WM_DRAWITEM:
1452 #define lpIS ((LPDRAWITEMSTRUCT)lParam)
1453 lpIS->hwndItem = hWnd;
1454 #undef lpIS
1455 break;
1456 case WM_COMPAREITEM:
1457 #define lpIS ((LPCOMPAREITEMSTRUCT)lParam)
1458 lpIS->hwndItem = hWnd;
1459 #undef lpIS
1460 break;
1463 return SendMessageA( lphc->owner, msg, lphc->self->wIDmenu, lParam );
1466 /***********************************************************************
1467 * COMBO_GetText
1469 static LRESULT COMBO_GetText( LPHEADCOMBO lphc, UINT N, LPSTR lpText)
1471 if( lphc->wState & CBF_EDIT )
1472 return SendMessageA( lphc->hWndEdit, WM_GETTEXT,
1473 (WPARAM)N, (LPARAM)lpText );
1475 /* get it from the listbox */
1477 if( lphc->hWndLBox )
1479 INT idx = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1480 if( idx != LB_ERR )
1482 LPSTR lpBuffer;
1483 INT length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN,
1484 (WPARAM)idx, 0 );
1486 /* 'length' is without the terminating character */
1487 if( length >= N )
1488 lpBuffer = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1 );
1489 else
1490 lpBuffer = lpText;
1492 if( lpBuffer )
1494 INT n = SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1495 (WPARAM)idx, (LPARAM)lpBuffer );
1497 /* truncate if buffer is too short */
1499 if( length >= N )
1501 if (N && lpText) {
1502 if( n != LB_ERR ) memcpy( lpText, lpBuffer, (N>n) ? n+1 : N-1 );
1503 lpText[N - 1] = '\0';
1505 HeapFree( GetProcessHeap(), 0, lpBuffer );
1507 return (LRESULT)n;
1511 return 0;
1515 /***********************************************************************
1516 * CBResetPos
1518 * This function sets window positions according to the updated
1519 * component placement struct.
1521 static void CBResetPos(
1522 LPHEADCOMBO lphc,
1523 LPRECT rectEdit,
1524 LPRECT rectLB,
1525 BOOL bRedraw)
1527 BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
1529 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1530 * sizing messages */
1532 if( lphc->wState & CBF_EDIT )
1533 SetWindowPos( lphc->hWndEdit, 0,
1534 rectEdit->left, rectEdit->top,
1535 rectEdit->right - rectEdit->left,
1536 rectEdit->bottom - rectEdit->top,
1537 SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
1539 SetWindowPos( lphc->hWndLBox, 0,
1540 rectLB->left, rectLB->top,
1541 rectLB->right - rectLB->left,
1542 rectLB->bottom - rectLB->top,
1543 SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) );
1545 if( bDrop )
1547 if( lphc->wState & CBF_DROPPED )
1549 lphc->wState &= ~CBF_DROPPED;
1550 ShowWindow( lphc->hWndLBox, SW_HIDE );
1553 if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
1554 RedrawWindow( lphc->self->hwndSelf, NULL, 0,
1555 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
1560 /***********************************************************************
1561 * COMBO_Size
1563 static void COMBO_Size( LPHEADCOMBO lphc )
1565 CBCalcPlacement(lphc->self->hwndSelf,
1566 lphc,
1567 &lphc->textRect,
1568 &lphc->buttonRect,
1569 &lphc->droppedRect);
1571 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1575 /***********************************************************************
1576 * COMBO_Font
1578 static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw )
1581 * Set the font
1583 lphc->hFont = hFont;
1586 * Propagate to owned windows.
1588 if( lphc->wState & CBF_EDIT )
1589 SendMessageA( lphc->hWndEdit, WM_SETFONT, (WPARAM)hFont, bRedraw );
1590 SendMessageA( lphc->hWndLBox, WM_SETFONT, (WPARAM)hFont, bRedraw );
1593 * Redo the layout of the control.
1595 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1597 CBCalcPlacement(lphc->self->hwndSelf,
1598 lphc,
1599 &lphc->textRect,
1600 &lphc->buttonRect,
1601 &lphc->droppedRect);
1603 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1605 else
1607 CBForceDummyResize(lphc);
1612 /***********************************************************************
1613 * COMBO_SetItemHeight
1615 static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height )
1617 LRESULT lRet = CB_ERR;
1619 if( index == -1 ) /* set text field height */
1621 if( height < 32768 )
1623 lphc->editHeight = height;
1626 * Redo the layout of the control.
1628 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1630 CBCalcPlacement(lphc->self->hwndSelf,
1631 lphc,
1632 &lphc->textRect,
1633 &lphc->buttonRect,
1634 &lphc->droppedRect);
1636 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1638 else
1640 CBForceDummyResize(lphc);
1643 lRet = height;
1646 else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */
1647 lRet = SendMessageA( lphc->hWndLBox, LB_SETITEMHEIGHT,
1648 (WPARAM)index, (LPARAM)height );
1649 return lRet;
1652 /***********************************************************************
1653 * COMBO_SelectString
1655 static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT start, LPCSTR pText )
1657 INT index = SendMessageA( lphc->hWndLBox, LB_SELECTSTRING,
1658 (WPARAM)start, (LPARAM)pText );
1659 if( index >= 0 )
1661 if( lphc->wState & CBF_EDIT )
1662 CBUpdateEdit( lphc, index );
1663 else
1665 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1668 return (LRESULT)index;
1671 /***********************************************************************
1672 * COMBO_LButtonDown
1674 static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam )
1676 POINT pt;
1677 BOOL bButton;
1678 HWND hWnd = lphc->self->hwndSelf;
1680 pt.x = LOWORD(lParam);
1681 pt.y = HIWORD(lParam);
1682 bButton = PtInRect(&lphc->buttonRect, pt);
1684 if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
1685 (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) )
1687 lphc->wState |= CBF_BUTTONDOWN;
1688 if( lphc->wState & CBF_DROPPED )
1690 /* got a click to cancel selection */
1692 lphc->wState &= ~CBF_BUTTONDOWN;
1693 CBRollUp( lphc, TRUE, FALSE );
1694 if( !IsWindow( hWnd ) ) return;
1696 if( lphc->wState & CBF_CAPTURE )
1698 lphc->wState &= ~CBF_CAPTURE;
1699 ReleaseCapture();
1702 else
1704 /* drop down the listbox and start tracking */
1706 lphc->wState |= CBF_CAPTURE;
1707 SetCapture( hWnd );
1708 CBDropDown( lphc );
1710 if( bButton ) CBRepaintButton( lphc );
1714 /***********************************************************************
1715 * COMBO_LButtonUp
1717 * Release capture and stop tracking if needed.
1719 static void COMBO_LButtonUp( LPHEADCOMBO lphc, LPARAM lParam )
1721 if( lphc->wState & CBF_CAPTURE )
1723 lphc->wState &= ~CBF_CAPTURE;
1724 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1726 INT index = CBUpdateLBox( lphc, TRUE );
1727 lphc->wState |= CBF_NOLBSELECT;
1728 CBUpdateEdit( lphc, index );
1729 lphc->wState &= ~CBF_NOLBSELECT;
1731 ReleaseCapture();
1732 SetCapture(lphc->hWndLBox);
1736 if( lphc->wState & CBF_BUTTONDOWN )
1738 lphc->wState &= ~CBF_BUTTONDOWN;
1739 CBRepaintButton( lphc );
1743 /***********************************************************************
1744 * COMBO_MouseMove
1746 * Two things to do - track combo button and release capture when
1747 * pointer goes into the listbox.
1749 static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam )
1751 POINT pt;
1752 RECT lbRect;
1754 pt.x = LOWORD(lParam);
1755 pt.y = HIWORD(lParam);
1757 if( lphc->wState & CBF_BUTTONDOWN )
1759 BOOL bButton;
1761 bButton = PtInRect(&lphc->buttonRect, pt);
1763 if( !bButton )
1765 lphc->wState &= ~CBF_BUTTONDOWN;
1766 CBRepaintButton( lphc );
1770 GetClientRect( lphc->hWndLBox, &lbRect );
1771 MapWindowPoints( lphc->self->hwndSelf, lphc->hWndLBox, &pt, 1 );
1772 if( PtInRect(&lbRect, pt) )
1774 lphc->wState &= ~CBF_CAPTURE;
1775 ReleaseCapture();
1776 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc, TRUE );
1778 /* hand over pointer tracking */
1779 SendMessageA( lphc->hWndLBox, WM_LBUTTONDOWN, wParam, lParam );
1784 /***********************************************************************
1785 * ComboWndProc_locked
1787 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm
1789 static inline LRESULT WINAPI ComboWndProc_locked( WND* pWnd, UINT message,
1790 WPARAM wParam, LPARAM lParam )
1792 if( pWnd ) {
1793 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1794 HWND hwnd = pWnd->hwndSelf;
1796 TRACE("[%04x]: msg %s wp %08x lp %08lx\n",
1797 pWnd->hwndSelf, SPY_GetMsgName(message), wParam, lParam );
1799 if( lphc || message == WM_NCCREATE )
1800 switch(message)
1803 /* System messages */
1805 case WM_NCCREATE:
1806 return COMBO_NCCreate(pWnd, lParam);
1807 case WM_NCDESTROY:
1808 COMBO_NCDestroy(lphc);
1809 break;/* -> DefWindowProc */
1811 case WM_CREATE:
1812 return COMBO_Create(lphc, pWnd, lParam);
1814 case WM_PRINTCLIENT:
1815 if (lParam & PRF_ERASEBKGND)
1816 COMBO_EraseBackground(hwnd, lphc, wParam);
1818 /* Fallthrough */
1819 case WM_PAINT:
1820 /* wParam may contain a valid HDC! */
1821 return COMBO_Paint(lphc, wParam);
1822 case WM_ERASEBKGND:
1823 return COMBO_EraseBackground(hwnd, lphc, wParam);
1824 case WM_GETDLGCODE:
1826 LRESULT result = DLGC_WANTARROWS | DLGC_WANTCHARS;
1827 if (lParam && (((LPMSG)lParam)->message == WM_KEYDOWN))
1829 int vk = (int)((LPMSG)lParam)->wParam;
1831 if ((vk == VK_RETURN || vk == VK_ESCAPE) && (lphc->wState & CBF_DROPPED))
1832 result |= DLGC_WANTMESSAGE;
1834 return result;
1836 case WM_WINDOWPOSCHANGING:
1837 return COMBO_WindowPosChanging(hwnd, lphc, (LPWINDOWPOS)lParam);
1838 case WM_SIZE:
1839 if( lphc->hWndLBox &&
1840 !(lphc->wState & CBF_NORESIZE) ) COMBO_Size( lphc );
1841 return TRUE;
1842 case WM_SETFONT:
1843 COMBO_Font( lphc, (HFONT16)wParam, (BOOL)lParam );
1844 return TRUE;
1845 case WM_GETFONT:
1846 return (LRESULT)lphc->hFont;
1847 case WM_SETFOCUS:
1848 if( lphc->wState & CBF_EDIT )
1849 SetFocus( lphc->hWndEdit );
1850 else
1851 COMBO_SetFocus( lphc );
1852 return TRUE;
1853 case WM_KILLFOCUS:
1854 #define hwndFocus ((HWND16)wParam)
1855 if( !hwndFocus ||
1856 (hwndFocus != lphc->hWndEdit && hwndFocus != lphc->hWndLBox ))
1857 COMBO_KillFocus( lphc );
1858 #undef hwndFocus
1859 return TRUE;
1860 case WM_COMMAND:
1861 return COMBO_Command( lphc, wParam, (HWND)lParam );
1862 case WM_GETTEXT:
1863 return COMBO_GetText( lphc, (UINT)wParam, (LPSTR)lParam );
1864 case WM_SETTEXT:
1865 case WM_GETTEXTLENGTH:
1866 case WM_CLEAR:
1867 case WM_CUT:
1868 case WM_PASTE:
1869 case WM_COPY:
1870 if ((message == WM_GETTEXTLENGTH) && !ISWIN31 && !(lphc->wState & CBF_EDIT))
1872 int j = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1873 if (j == -1) return 0;
1874 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
1876 else if( lphc->wState & CBF_EDIT )
1878 LRESULT ret;
1879 lphc->wState |= CBF_NOEDITNOTIFY;
1880 ret = SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1881 lphc->wState &= ~CBF_NOEDITNOTIFY;
1882 return ret;
1884 else return CB_ERR;
1886 case WM_DRAWITEM:
1887 case WM_DELETEITEM:
1888 case WM_COMPAREITEM:
1889 case WM_MEASUREITEM:
1890 return COMBO_ItemOp( lphc, message, wParam, lParam );
1891 case WM_ENABLE:
1892 if( lphc->wState & CBF_EDIT )
1893 EnableWindow( lphc->hWndEdit, (BOOL)wParam );
1894 EnableWindow( lphc->hWndLBox, (BOOL)wParam );
1896 /* Force the control to repaint when the enabled state changes. */
1897 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
1898 return TRUE;
1899 case WM_SETREDRAW:
1900 if( wParam )
1901 lphc->wState &= ~CBF_NOREDRAW;
1902 else
1903 lphc->wState |= CBF_NOREDRAW;
1905 if( lphc->wState & CBF_EDIT )
1906 SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1907 SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1908 return 0;
1909 case WM_SYSKEYDOWN:
1910 if( KEYDATA_ALT & HIWORD(lParam) )
1911 if( wParam == VK_UP || wParam == VK_DOWN )
1912 COMBO_FlipListbox( lphc, FALSE, FALSE );
1913 return 0;
1915 case WM_CHAR:
1916 case WM_KEYDOWN:
1917 if (((CHAR)wParam == VK_RETURN || (CHAR)wParam == VK_ESCAPE) &&
1918 (lphc->wState & CBF_DROPPED))
1920 CBRollUp( lphc, (CHAR)wParam == VK_RETURN, FALSE );
1921 return TRUE;
1924 if( lphc->wState & CBF_EDIT )
1925 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1926 else
1927 return SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1928 case WM_LBUTTONDOWN:
1929 if( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self->hwndSelf );
1930 if( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam );
1931 return TRUE;
1932 case WM_LBUTTONUP:
1933 COMBO_LButtonUp( lphc, lParam );
1934 return TRUE;
1935 case WM_MOUSEMOVE:
1936 if( lphc->wState & CBF_CAPTURE )
1937 COMBO_MouseMove( lphc, wParam, lParam );
1938 return TRUE;
1940 case WM_MOUSEWHEEL:
1941 if (wParam & (MK_SHIFT | MK_CONTROL))
1942 return DefWindowProcA( hwnd, message, wParam, lParam );
1943 if ((short) HIWORD(wParam) > 0) return SendMessageA(hwnd,WM_KEYDOWN,VK_UP,0);
1944 if ((short) HIWORD(wParam) < 0) return SendMessageA(hwnd,WM_KEYDOWN,VK_DOWN,0);
1945 return TRUE;
1947 /* Combo messages */
1949 case CB_ADDSTRING16:
1950 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1951 case CB_ADDSTRING:
1952 return SendMessageA( lphc->hWndLBox, LB_ADDSTRING, 0, lParam);
1953 case CB_INSERTSTRING16:
1954 wParam = (INT)(INT16)wParam;
1955 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1956 case CB_INSERTSTRING:
1957 return SendMessageA( lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam);
1958 case CB_DELETESTRING16:
1959 case CB_DELETESTRING:
1960 return SendMessageA( lphc->hWndLBox, LB_DELETESTRING, wParam, 0);
1961 case CB_SELECTSTRING16:
1962 wParam = (INT)(INT16)wParam;
1963 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1964 case CB_SELECTSTRING:
1965 return COMBO_SelectString( lphc, (INT)wParam, (LPSTR)lParam );
1966 case CB_FINDSTRING16:
1967 wParam = (INT)(INT16)wParam;
1968 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1969 case CB_FINDSTRING:
1970 return SendMessageA( lphc->hWndLBox, LB_FINDSTRING, wParam, lParam);
1971 case CB_FINDSTRINGEXACT16:
1972 wParam = (INT)(INT16)wParam;
1973 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1974 case CB_FINDSTRINGEXACT:
1975 return SendMessageA( lphc->hWndLBox, LB_FINDSTRINGEXACT,
1976 wParam, lParam );
1977 case CB_SETITEMHEIGHT16:
1978 wParam = (INT)(INT16)wParam; /* signed integer */
1979 case CB_SETITEMHEIGHT:
1980 return COMBO_SetItemHeight( lphc, (INT)wParam, (INT)lParam);
1981 case CB_GETITEMHEIGHT16:
1982 wParam = (INT)(INT16)wParam;
1983 case CB_GETITEMHEIGHT:
1984 if( (INT)wParam >= 0 ) /* listbox item */
1985 return SendMessageA( lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0);
1986 return CBGetTextAreaHeight(hwnd, lphc);
1987 case CB_RESETCONTENT16:
1988 case CB_RESETCONTENT:
1989 SendMessageA( lphc->hWndLBox, LB_RESETCONTENT, 0, 0 );
1990 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
1991 return TRUE;
1992 case CB_INITSTORAGE:
1993 return SendMessageA( lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam);
1994 case CB_GETHORIZONTALEXTENT:
1995 return SendMessageA( lphc->hWndLBox, LB_GETHORIZONTALEXTENT, 0, 0);
1996 case CB_SETHORIZONTALEXTENT:
1997 return SendMessageA( lphc->hWndLBox, LB_SETHORIZONTALEXTENT, wParam, 0);
1998 case CB_GETTOPINDEX:
1999 return SendMessageA( lphc->hWndLBox, LB_GETTOPINDEX, 0, 0);
2000 case CB_GETLOCALE:
2001 return SendMessageA( lphc->hWndLBox, LB_GETLOCALE, 0, 0);
2002 case CB_SETLOCALE:
2003 return SendMessageA( lphc->hWndLBox, LB_SETLOCALE, wParam, 0);
2004 case CB_GETDROPPEDWIDTH:
2005 if( lphc->droppedWidth )
2006 return lphc->droppedWidth;
2007 return lphc->droppedRect.right - lphc->droppedRect.left;
2008 case CB_SETDROPPEDWIDTH:
2009 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) &&
2010 (INT)wParam < 32768 ) lphc->droppedWidth = (INT)wParam;
2011 return CB_ERR;
2012 case CB_GETDROPPEDCONTROLRECT16:
2013 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2014 if( lParam )
2016 RECT r;
2017 CBGetDroppedControlRect( lphc, &r );
2018 CONV_RECT32TO16( &r, (LPRECT16)lParam );
2020 return CB_OKAY;
2021 case CB_GETDROPPEDCONTROLRECT:
2022 if( lParam ) CBGetDroppedControlRect(lphc, (LPRECT)lParam );
2023 return CB_OKAY;
2024 case CB_GETDROPPEDSTATE16:
2025 case CB_GETDROPPEDSTATE:
2026 return (lphc->wState & CBF_DROPPED) ? TRUE : FALSE;
2027 case CB_DIR16:
2028 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2029 /* fall through */
2030 case CB_DIR:
2031 return COMBO_Directory( lphc, (UINT)wParam,
2032 (LPSTR)lParam, (message == CB_DIR));
2033 case CB_SHOWDROPDOWN16:
2034 case CB_SHOWDROPDOWN:
2035 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
2037 if( wParam )
2039 if( !(lphc->wState & CBF_DROPPED) )
2040 CBDropDown( lphc );
2042 else
2043 if( lphc->wState & CBF_DROPPED )
2044 CBRollUp( lphc, FALSE, TRUE );
2046 return TRUE;
2047 case CB_GETCOUNT16:
2048 case CB_GETCOUNT:
2049 return SendMessageA( lphc->hWndLBox, LB_GETCOUNT, 0, 0);
2050 case CB_GETCURSEL16:
2051 case CB_GETCURSEL:
2052 return SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0);
2053 case CB_SETCURSEL16:
2054 wParam = (INT)(INT16)wParam;
2055 case CB_SETCURSEL:
2056 lParam = SendMessageA( lphc->hWndLBox, LB_SETCURSEL, wParam, 0);
2057 if( lParam >= 0 )
2058 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, wParam, 0);
2059 if( lphc->wState & CBF_SELCHANGE )
2061 /* no LBN_SELCHANGE in this case, update manually */
2062 if( lphc->wState & CBF_EDIT )
2063 CBUpdateEdit( lphc, (INT)wParam );
2064 else
2065 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
2066 lphc->wState &= ~CBF_SELCHANGE;
2068 return lParam;
2069 case CB_GETLBTEXT16:
2070 wParam = (INT)(INT16)wParam;
2071 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2072 case CB_GETLBTEXT:
2073 return SendMessageA( lphc->hWndLBox, LB_GETTEXT, wParam, lParam);
2074 case CB_GETLBTEXTLEN16:
2075 wParam = (INT)(INT16)wParam;
2076 case CB_GETLBTEXTLEN:
2077 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
2078 case CB_GETITEMDATA16:
2079 wParam = (INT)(INT16)wParam;
2080 case CB_GETITEMDATA:
2081 return SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, wParam, 0);
2082 case CB_SETITEMDATA16:
2083 wParam = (INT)(INT16)wParam;
2084 case CB_SETITEMDATA:
2085 return SendMessageA( lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam);
2086 case CB_GETEDITSEL16:
2087 wParam = lParam = 0; /* just in case */
2088 case CB_GETEDITSEL:
2089 if( lphc->wState & CBF_EDIT )
2091 INT a, b;
2093 return SendMessageA( lphc->hWndEdit, EM_GETSEL,
2094 (wParam) ? wParam : (WPARAM)&a,
2095 (lParam) ? lParam : (LPARAM)&b );
2097 return CB_ERR;
2098 case CB_SETEDITSEL16:
2099 case CB_SETEDITSEL:
2100 if( lphc->wState & CBF_EDIT )
2101 return SendMessageA( lphc->hWndEdit, EM_SETSEL,
2102 (INT)(INT16)LOWORD(lParam), (INT)(INT16)HIWORD(lParam) );
2103 return CB_ERR;
2104 case CB_SETEXTENDEDUI16:
2105 case CB_SETEXTENDEDUI:
2106 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
2107 return CB_ERR;
2108 if( wParam )
2109 lphc->wState |= CBF_EUI;
2110 else lphc->wState &= ~CBF_EUI;
2111 return CB_OKAY;
2112 case CB_GETEXTENDEDUI16:
2113 case CB_GETEXTENDEDUI:
2114 return (lphc->wState & CBF_EUI) ? TRUE : FALSE;
2116 default:
2117 if (message >= WM_USER)
2118 WARN("unknown msg WM_USER+%04x wp=%04x lp=%08lx\n",
2119 message - WM_USER, wParam, lParam );
2120 break;
2122 return DefWindowProcA(hwnd, message, wParam, lParam);
2124 return CB_ERR;
2127 /***********************************************************************
2128 * ComboWndProc
2130 * This is just a wrapper for the real ComboWndProc which locks/unlocks
2131 * window structs.
2133 LRESULT WINAPI ComboWndProc( HWND hwnd, UINT message,
2134 WPARAM wParam, LPARAM lParam )
2136 WND* pWnd = WIN_FindWndPtr(hwnd);
2137 LRESULT retvalue = ComboWndProc_locked(pWnd,message,wParam,lParam);
2140 WIN_ReleaseWndPtr(pWnd);
2141 return retvalue;