4 * Copyright 1997 Alex Korobka
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Oct. 4, 2004, by Dimitrie O. Paun.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features, or bugs, please note them below.
30 * - ComboBox_[GS]etMinVisible()
31 * - CB_GETMINVISIBLE, CB_SETMINVISIBLE
44 #include "wine/unicode.h"
45 #include "user_private.h"
49 #include "wine/debug.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(combo
);
53 /* bits in the dwKeyData */
54 #define KEYDATA_ALT 0x2000
55 #define KEYDATA_PREVSTATE 0x4000
58 * Additional combo box definitions
61 #define CB_NOTIFY( lphc, code ) \
62 (SendMessageW((lphc)->owner, WM_COMMAND, \
63 MAKEWPARAM(GetWindowLongPtrW((lphc)->self,GWLP_ID), (code)), (LPARAM)(lphc)->self))
65 #define CB_DISABLED( lphc ) (!IsWindowEnabled((lphc)->self))
66 #define CB_OWNERDRAWN( lphc ) ((lphc)->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE))
67 #define CB_HASSTRINGS( lphc ) ((lphc)->dwStyle & CBS_HASSTRINGS)
68 #define CB_HWND( lphc ) ((lphc)->self)
69 #define CB_GETTYPE( lphc ) ((lphc)->dwStyle & (CBS_DROPDOWNLIST))
71 #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03)
76 static HBITMAP hComboBmp
= 0;
77 static UINT CBitHeight
, CBitWidth
;
80 * Look and feel dependent "constants"
83 #define COMBO_YBORDERGAP 5
84 #define COMBO_XBORDERSIZE() 2
85 #define COMBO_YBORDERSIZE() 2
86 #define COMBO_EDITBUTTONSPACE() 0
87 #define EDIT_CONTROL_PADDING() 1
89 /*********************************************************************
90 * combo class descriptor
92 static const WCHAR comboboxW
[] = {'C','o','m','b','o','B','o','x',0};
93 const struct builtin_class_descr COMBO_builtin_class
=
96 CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
, /* style */
97 WINPROC_COMBO
, /* proc */
98 sizeof(HEADCOMBO
*), /* extra */
99 IDC_ARROW
, /* cursor */
104 /***********************************************************************
107 * Load combo button bitmap.
109 static BOOL
COMBO_Init(void)
113 if( hComboBmp
) return TRUE
;
114 if( (hDC
= CreateCompatibleDC(0)) )
117 if( (hComboBmp
= LoadBitmapW(0, MAKEINTRESOURCEW(OBM_COMBO
))) )
123 GetObjectW( hComboBmp
, sizeof(bm
), &bm
);
124 CBitHeight
= bm
.bmHeight
;
125 CBitWidth
= bm
.bmWidth
;
127 TRACE("combo bitmap [%i,%i]\n", CBitWidth
, CBitHeight
);
129 hPrevB
= SelectObject( hDC
, hComboBmp
);
130 SetRect( &r
, 0, 0, CBitWidth
, CBitHeight
);
131 InvertRect( hDC
, &r
);
132 SelectObject( hDC
, hPrevB
);
141 /***********************************************************************
144 static LRESULT
COMBO_NCCreate(HWND hwnd
, LONG style
)
148 if (COMBO_Init() && (lphc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(HEADCOMBO
))) )
151 SetWindowLongPtrW( hwnd
, 0, (LONG_PTR
)lphc
);
153 /* some braindead apps do try to use scrollbar/border flags */
155 lphc
->dwStyle
= style
& ~(WS_BORDER
| WS_HSCROLL
| WS_VSCROLL
);
156 SetWindowLongW( hwnd
, GWL_STYLE
, style
& ~(WS_BORDER
| WS_HSCROLL
| WS_VSCROLL
) );
159 * We also have to remove the client edge style to make sure
160 * we don't end-up with a non client area.
162 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
163 GetWindowLongW( hwnd
, GWL_EXSTYLE
) & ~WS_EX_CLIENTEDGE
);
165 if( !(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) )
166 lphc
->dwStyle
|= CBS_HASSTRINGS
;
167 if( !(GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_NOPARENTNOTIFY
) )
168 lphc
->wState
|= CBF_NOTIFY
;
170 TRACE("[%p], style = %08x\n", lphc
, lphc
->dwStyle
);
176 /***********************************************************************
179 static LRESULT
COMBO_NCDestroy( LPHEADCOMBO lphc
)
184 TRACE("[%p]: freeing storage\n", lphc
->self
);
186 if( (CB_GETTYPE(lphc
) != CBS_SIMPLE
) && lphc
->hWndLBox
)
187 DestroyWindow( lphc
->hWndLBox
);
189 SetWindowLongPtrW( lphc
->self
, 0, 0 );
190 HeapFree( GetProcessHeap(), 0, lphc
);
195 /***********************************************************************
196 * CBGetTextAreaHeight
198 * This method will calculate the height of the text area of the
200 * The height of the text area is set in two ways.
201 * It can be set explicitly through a combobox message or through a
202 * WM_MEASUREITEM callback.
203 * If this is not the case, the height is set to font height + 4px
204 * This height was determined through experimentation.
205 * CBCalcPlacement will add 2*COMBO_YBORDERSIZE pixels for the border
207 static INT
CBGetTextAreaHeight(
213 if( lphc
->editHeight
) /* explicitly set height */
215 iTextItemHeight
= lphc
->editHeight
;
220 HDC hDC
= GetDC(hwnd
);
225 hPrevFont
= SelectObject( hDC
, lphc
->hFont
);
227 GetTextMetricsW(hDC
, &tm
);
229 baseUnitY
= tm
.tmHeight
;
232 SelectObject( hDC
, hPrevFont
);
234 ReleaseDC(hwnd
, hDC
);
236 iTextItemHeight
= baseUnitY
+ 4;
240 * Check the ownerdraw case if we haven't asked the parent the size
243 if ( CB_OWNERDRAWN(lphc
) &&
244 (lphc
->wState
& CBF_MEASUREITEM
) )
246 MEASUREITEMSTRUCT measureItem
;
248 INT originalItemHeight
= iTextItemHeight
;
249 UINT id
= (UINT
)GetWindowLongPtrW( lphc
->self
, GWLP_ID
);
252 * We use the client rect for the width of the item.
254 GetClientRect(hwnd
, &clientRect
);
256 lphc
->wState
&= ~CBF_MEASUREITEM
;
259 * Send a first one to measure the size of the text area
261 measureItem
.CtlType
= ODT_COMBOBOX
;
262 measureItem
.CtlID
= id
;
263 measureItem
.itemID
= -1;
264 measureItem
.itemWidth
= clientRect
.right
;
265 measureItem
.itemHeight
= iTextItemHeight
- 6; /* ownerdrawn cb is taller */
266 measureItem
.itemData
= 0;
267 SendMessageW(lphc
->owner
, WM_MEASUREITEM
, id
, (LPARAM
)&measureItem
);
268 iTextItemHeight
= 6 + measureItem
.itemHeight
;
271 * Send a second one in the case of a fixed ownerdraw list to calculate the
272 * size of the list items. (we basically do this on behalf of the listbox)
274 if (lphc
->dwStyle
& CBS_OWNERDRAWFIXED
)
276 measureItem
.CtlType
= ODT_COMBOBOX
;
277 measureItem
.CtlID
= id
;
278 measureItem
.itemID
= 0;
279 measureItem
.itemWidth
= clientRect
.right
;
280 measureItem
.itemHeight
= originalItemHeight
;
281 measureItem
.itemData
= 0;
282 SendMessageW(lphc
->owner
, WM_MEASUREITEM
, id
, (LPARAM
)&measureItem
);
283 lphc
->fixedOwnerDrawHeight
= measureItem
.itemHeight
;
287 * Keep the size for the next time
289 lphc
->editHeight
= iTextItemHeight
;
292 return iTextItemHeight
;
295 /***********************************************************************
298 * The dummy resize is used for listboxes that have a popup to trigger
299 * a re-arranging of the contents of the combobox and the recalculation
300 * of the size of the "real" control window.
302 static void CBForceDummyResize(
308 newComboHeight
= CBGetTextAreaHeight(lphc
->self
,lphc
) + 2*COMBO_YBORDERSIZE();
310 GetWindowRect(lphc
->self
, &windowRect
);
313 * We have to be careful, resizing a combobox also has the meaning that the
314 * dropped rect will be resized. In this case, we want to trigger a resize
315 * to recalculate layout but we don't want to change the dropped rectangle
316 * So, we pass the height of text area of control as the height.
317 * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
320 SetWindowPos( lphc
->self
,
323 windowRect
.right
- windowRect
.left
,
325 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
328 /***********************************************************************
331 * Set up component coordinates given valid lphc->RectCombo.
333 static void CBCalcPlacement(
341 * Again, start with the client rectangle.
343 GetClientRect(hwnd
, lprEdit
);
348 InflateRect(lprEdit
, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
351 * Chop off the bottom part to fit with the height of the text area.
353 lprEdit
->bottom
= lprEdit
->top
+ CBGetTextAreaHeight(hwnd
, lphc
);
356 * The button starts the same vertical position as the text area.
358 CopyRect(lprButton
, lprEdit
);
361 * If the combobox is "simple" there is no button.
363 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
364 lprButton
->left
= lprButton
->right
= lprButton
->bottom
= 0;
368 * Let's assume the combobox button is the same width as the
370 * size the button horizontally and cut-off the text area.
372 lprButton
->left
= lprButton
->right
- GetSystemMetrics(SM_CXVSCROLL
);
373 lprEdit
->right
= lprButton
->left
;
377 * In the case of a dropdown, there is an additional spacing between the
378 * text area and the button.
380 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
382 lprEdit
->right
-= COMBO_EDITBUTTONSPACE();
386 * If we have an edit control, we space it away from the borders slightly.
388 if (CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
)
390 InflateRect(lprEdit
, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING());
394 * Adjust the size of the listbox popup.
396 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
399 * Use the client rectangle to initialize the listbox rectangle
401 GetClientRect(hwnd
, lprLB
);
404 * Then, chop-off the top part.
406 lprLB
->top
= lprEdit
->bottom
+ COMBO_YBORDERSIZE();
411 * Make sure the dropped width is as large as the combobox itself.
413 if (lphc
->droppedWidth
< (lprButton
->right
+ COMBO_XBORDERSIZE()))
415 lprLB
->right
= lprLB
->left
+ (lprButton
->right
+ COMBO_XBORDERSIZE());
418 * In the case of a dropdown, the popup listbox is offset to the right.
419 * so, we want to make sure it's flush with the right side of the
422 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
423 lprLB
->right
-= COMBO_EDITBUTTONSPACE();
426 lprLB
->right
= lprLB
->left
+ lphc
->droppedWidth
;
429 /* don't allow negative window width */
430 if (lprEdit
->right
< lprEdit
->left
)
431 lprEdit
->right
= lprEdit
->left
;
433 TRACE("\ttext\t= (%s)\n", wine_dbgstr_rect(lprEdit
));
435 TRACE("\tbutton\t= (%s)\n", wine_dbgstr_rect(lprButton
));
437 TRACE("\tlbox\t= (%s)\n", wine_dbgstr_rect(lprLB
));
440 /***********************************************************************
441 * CBGetDroppedControlRect
443 static void CBGetDroppedControlRect( LPHEADCOMBO lphc
, LPRECT lpRect
)
445 /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner
446 of the combo box and the lower right corner of the listbox */
448 GetWindowRect(lphc
->self
, lpRect
);
450 lpRect
->right
= lpRect
->left
+ lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
451 lpRect
->bottom
= lpRect
->top
+ lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
;
455 /***********************************************************************
458 static LRESULT
COMBO_Create( HWND hwnd
, LPHEADCOMBO lphc
, HWND hwndParent
, LONG style
,
461 static const WCHAR clbName
[] = {'C','o','m','b','o','L','B','o','x',0};
462 static const WCHAR editName
[] = {'E','d','i','t',0};
464 if( !CB_GETTYPE(lphc
) ) lphc
->dwStyle
|= CBS_SIMPLE
;
465 if( CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
) lphc
->wState
|= CBF_EDIT
;
467 lphc
->owner
= hwndParent
;
470 * The item height and dropped width are not set when the control
473 lphc
->droppedWidth
= lphc
->editHeight
= 0;
476 * The first time we go through, we want to measure the ownerdraw item
478 lphc
->wState
|= CBF_MEASUREITEM
;
480 /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
482 if( lphc
->owner
|| !(style
& WS_VISIBLE
) )
488 * Initialize the dropped rect to the size of the client area of the
489 * control and then, force all the areas of the combobox to be
492 GetClientRect( hwnd
, &lphc
->droppedRect
);
493 CBCalcPlacement(hwnd
, lphc
, &lphc
->textRect
, &lphc
->buttonRect
, &lphc
->droppedRect
);
496 * Adjust the position of the popup listbox if it's necessary
498 if ( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
500 lphc
->droppedRect
.top
= lphc
->textRect
.bottom
+ COMBO_YBORDERSIZE();
503 * If it's a dropdown, the listbox is offset
505 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
506 lphc
->droppedRect
.left
+= COMBO_EDITBUTTONSPACE();
508 if (lphc
->droppedRect
.bottom
< lphc
->droppedRect
.top
)
509 lphc
->droppedRect
.bottom
= lphc
->droppedRect
.top
;
510 if (lphc
->droppedRect
.right
< lphc
->droppedRect
.left
)
511 lphc
->droppedRect
.right
= lphc
->droppedRect
.left
;
512 MapWindowPoints( hwnd
, 0, (LPPOINT
)&lphc
->droppedRect
, 2 );
515 /* create listbox popup */
517 lbeStyle
= (LBS_NOTIFY
| LBS_COMBOBOX
| WS_BORDER
| WS_CLIPSIBLINGS
| WS_CHILD
) |
518 (style
& (WS_VSCROLL
| CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
));
520 if( lphc
->dwStyle
& CBS_SORT
)
521 lbeStyle
|= LBS_SORT
;
522 if( lphc
->dwStyle
& CBS_HASSTRINGS
)
523 lbeStyle
|= LBS_HASSTRINGS
;
524 if( lphc
->dwStyle
& CBS_NOINTEGRALHEIGHT
)
525 lbeStyle
|= LBS_NOINTEGRALHEIGHT
;
526 if( lphc
->dwStyle
& CBS_DISABLENOSCROLL
)
527 lbeStyle
|= LBS_DISABLENOSCROLL
;
529 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
) /* child listbox */
531 lbeStyle
|= WS_VISIBLE
;
534 * In win 95 look n feel, the listbox in the simple combobox has
535 * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
537 lbeStyle
&= ~WS_BORDER
;
538 lbeExStyle
|= WS_EX_CLIENTEDGE
;
542 lbeExStyle
|= (WS_EX_TOPMOST
| WS_EX_TOOLWINDOW
);
546 lphc
->hWndLBox
= CreateWindowExW(lbeExStyle
, clbName
, NULL
, lbeStyle
,
547 lphc
->droppedRect
.left
,
548 lphc
->droppedRect
.top
,
549 lphc
->droppedRect
.right
- lphc
->droppedRect
.left
,
550 lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
,
551 hwnd
, (HMENU
)ID_CB_LISTBOX
,
552 (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
), lphc
);
554 lphc
->hWndLBox
= CreateWindowExA(lbeExStyle
, "ComboLBox", NULL
, lbeStyle
,
555 lphc
->droppedRect
.left
,
556 lphc
->droppedRect
.top
,
557 lphc
->droppedRect
.right
- lphc
->droppedRect
.left
,
558 lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
,
559 hwnd
, (HMENU
)ID_CB_LISTBOX
,
560 (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
), lphc
);
565 lbeStyle
= WS_CHILD
| WS_VISIBLE
| ES_NOHIDESEL
| ES_LEFT
| ES_COMBO
;
567 if( lphc
->wState
& CBF_EDIT
)
569 if( lphc
->dwStyle
& CBS_OEMCONVERT
)
570 lbeStyle
|= ES_OEMCONVERT
;
571 if( lphc
->dwStyle
& CBS_AUTOHSCROLL
)
572 lbeStyle
|= ES_AUTOHSCROLL
;
573 if( lphc
->dwStyle
& CBS_LOWERCASE
)
574 lbeStyle
|= ES_LOWERCASE
;
575 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
576 lbeStyle
|= ES_UPPERCASE
;
578 if (!IsWindowEnabled(hwnd
)) lbeStyle
|= WS_DISABLED
;
581 lphc
->hWndEdit
= CreateWindowExW(0, editName
, NULL
, lbeStyle
,
582 lphc
->textRect
.left
, lphc
->textRect
.top
,
583 lphc
->textRect
.right
- lphc
->textRect
.left
,
584 lphc
->textRect
.bottom
- lphc
->textRect
.top
,
585 hwnd
, (HMENU
)ID_CB_EDIT
,
586 (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
), NULL
);
588 lphc
->hWndEdit
= CreateWindowExA(0, "Edit", NULL
, lbeStyle
,
589 lphc
->textRect
.left
, lphc
->textRect
.top
,
590 lphc
->textRect
.right
- lphc
->textRect
.left
,
591 lphc
->textRect
.bottom
- lphc
->textRect
.top
,
592 hwnd
, (HMENU
)ID_CB_EDIT
,
593 (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
), NULL
);
595 if( !lphc
->hWndEdit
)
601 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
603 /* Now do the trick with parent */
604 SetParent(lphc
->hWndLBox
, HWND_DESKTOP
);
606 * If the combo is a dropdown, we must resize the control
607 * to fit only the text area and button. To do this,
608 * we send a dummy resize and the WM_WINDOWPOSCHANGING message
609 * will take care of setting the height for us.
611 CBForceDummyResize(lphc
);
614 TRACE("init done\n");
617 ERR("edit control failure.\n");
618 } else ERR("listbox failure.\n");
619 } else ERR("no owner for visible combo.\n");
621 /* CreateWindow() will send WM_NCDESTROY to cleanup */
626 /***********************************************************************
629 * Paint combo button (normal, pressed, and disabled states).
631 static void CBPaintButton( LPHEADCOMBO lphc
, HDC hdc
, RECT rectButton
)
633 UINT buttonState
= DFCS_SCROLLCOMBOBOX
;
635 if( lphc
->wState
& CBF_NOREDRAW
)
639 if (lphc
->wState
& CBF_BUTTONDOWN
)
640 buttonState
|= DFCS_PUSHED
;
642 if (CB_DISABLED(lphc
))
643 buttonState
|= DFCS_INACTIVE
;
645 DrawFrameControl(hdc
, &rectButton
, DFC_SCROLL
, buttonState
);
648 /***********************************************************************
649 * COMBO_PrepareColors
651 * This method will sent the appropriate WM_CTLCOLOR message to
652 * prepare and setup the colors for the combo's DC.
654 * It also returns the brush to use for the background.
656 static HBRUSH
COMBO_PrepareColors(
663 * Get the background brush for this control.
665 if (CB_DISABLED(lphc
))
667 hBkgBrush
= (HBRUSH
)SendMessageW(lphc
->owner
, WM_CTLCOLORSTATIC
,
668 (WPARAM
)hDC
, (LPARAM
)lphc
->self
);
671 * We have to change the text color since WM_CTLCOLORSTATIC will
672 * set it to the "enabled" color. This is the same behavior as the
675 SetTextColor(hDC
, GetSysColor(COLOR_GRAYTEXT
));
679 /* FIXME: In which cases WM_CTLCOLORLISTBOX should be sent? */
680 hBkgBrush
= (HBRUSH
)SendMessageW(lphc
->owner
, WM_CTLCOLOREDIT
,
681 (WPARAM
)hDC
, (LPARAM
)lphc
->self
);
688 hBkgBrush
= GetSysColorBrush(COLOR_WINDOW
);
693 /***********************************************************************
696 * Paint CBS_DROPDOWNLIST text field / update edit control contents.
698 static void CBPaintText(
702 RECT rectEdit
= lphc
->textRect
;
706 if( lphc
->wState
& CBF_NOREDRAW
) return;
710 /* follow Windows combobox that sends a bunch of text
711 * inquiries to its listbox while processing WM_PAINT. */
713 if( (id
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0) ) != LB_ERR
)
715 size
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, id
, 0);
717 FIXME("LB_ERR probably not handled yet\n");
718 if( (pText
= HeapAlloc( GetProcessHeap(), 0, (size
+ 1) * sizeof(WCHAR
))) )
720 /* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */
721 size
=SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, id
, (LPARAM
)pText
);
722 pText
[size
] = '\0'; /* just in case */
726 if( !CB_OWNERDRAWN(lphc
) )
729 if( lphc
->wState
& CBF_EDIT
)
731 static const WCHAR empty_stringW
[] = { 0 };
732 if( CB_HASSTRINGS(lphc
) ) SetWindowTextW( lphc
->hWndEdit
, pText
? pText
: empty_stringW
);
733 if( lphc
->wState
& CBF_FOCUSED
)
734 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, -1);
736 else /* paint text field ourselves */
738 HDC hdc
= hdc_paint
? hdc_paint
: GetDC(lphc
->self
);
739 UINT itemState
= ODS_COMBOBOXEDIT
;
740 HFONT hPrevFont
= (lphc
->hFont
) ? SelectObject(hdc
, lphc
->hFont
) : 0;
741 HBRUSH hPrevBrush
, hBkgBrush
;
744 * Give ourselves some space.
746 InflateRect( &rectEdit
, -1, -1 );
748 hBkgBrush
= COMBO_PrepareColors( lphc
, hdc
);
749 hPrevBrush
= SelectObject( hdc
, hBkgBrush
);
750 FillRect( hdc
, &rectEdit
, hBkgBrush
);
752 if( CB_OWNERDRAWN(lphc
) )
756 UINT ctlid
= (UINT
)GetWindowLongPtrW( lphc
->self
, GWLP_ID
);
758 /* setup state for DRAWITEM message. Owner will highlight */
759 if ( (lphc
->wState
& CBF_FOCUSED
) &&
760 !(lphc
->wState
& CBF_DROPPED
) )
761 itemState
|= ODS_SELECTED
| ODS_FOCUS
;
763 if (!IsWindowEnabled(lphc
->self
)) itemState
|= ODS_DISABLED
;
765 dis
.CtlType
= ODT_COMBOBOX
;
767 dis
.hwndItem
= lphc
->self
;
768 dis
.itemAction
= ODA_DRAWENTIRE
;
770 dis
.itemState
= itemState
;
772 dis
.rcItem
= rectEdit
;
773 dis
.itemData
= SendMessageW(lphc
->hWndLBox
, LB_GETITEMDATA
, id
, 0);
776 * Clip the DC and have the parent draw the item.
778 clipRegion
= set_control_clipping( hdc
, &rectEdit
);
780 SendMessageW(lphc
->owner
, WM_DRAWITEM
, ctlid
, (LPARAM
)&dis
);
782 SelectClipRgn( hdc
, clipRegion
);
783 if (clipRegion
) DeleteObject( clipRegion
);
787 static const WCHAR empty_stringW
[] = { 0 };
789 if ( (lphc
->wState
& CBF_FOCUSED
) &&
790 !(lphc
->wState
& CBF_DROPPED
) ) {
793 FillRect( hdc
, &rectEdit
, GetSysColorBrush(COLOR_HIGHLIGHT
) );
794 SetBkColor( hdc
, GetSysColor( COLOR_HIGHLIGHT
) );
795 SetTextColor( hdc
, GetSysColor( COLOR_HIGHLIGHTTEXT
) );
801 ETO_OPAQUE
| ETO_CLIPPED
,
803 pText
? pText
: empty_stringW
, size
, NULL
);
805 if(lphc
->wState
& CBF_FOCUSED
&& !(lphc
->wState
& CBF_DROPPED
))
806 DrawFocusRect( hdc
, &rectEdit
);
810 SelectObject(hdc
, hPrevFont
);
813 SelectObject( hdc
, hPrevBrush
);
816 ReleaseDC( lphc
->self
, hdc
);
818 HeapFree( GetProcessHeap(), 0, pText
);
821 /***********************************************************************
824 static void CBPaintBorder(
826 const HEADCOMBO
*lphc
,
831 if (CB_GETTYPE(lphc
) != CBS_SIMPLE
)
833 GetClientRect(hwnd
, &clientRect
);
837 clientRect
= lphc
->textRect
;
839 InflateRect(&clientRect
, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
840 InflateRect(&clientRect
, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
843 DrawEdge(hdc
, &clientRect
, EDGE_SUNKEN
, BF_RECT
);
846 /***********************************************************************
849 static LRESULT
COMBO_Paint(LPHEADCOMBO lphc
, HDC hParamDC
)
854 hDC
= (hParamDC
) ? hParamDC
855 : BeginPaint( lphc
->self
, &ps
);
857 TRACE("hdc=%p\n", hDC
);
859 if( hDC
&& !(lphc
->wState
& CBF_NOREDRAW
) )
861 HBRUSH hPrevBrush
, hBkgBrush
;
864 * Retrieve the background brush and select it in the
867 hBkgBrush
= COMBO_PrepareColors(lphc
, hDC
);
869 hPrevBrush
= SelectObject( hDC
, hBkgBrush
);
870 if (!(lphc
->wState
& CBF_EDIT
))
871 FillRect(hDC
, &lphc
->textRect
, hBkgBrush
);
874 * In non 3.1 look, there is a sunken border on the combobox
876 CBPaintBorder(lphc
->self
, lphc
, hDC
);
878 if( !IsRectEmpty(&lphc
->buttonRect
) )
880 CBPaintButton(lphc
, hDC
, lphc
->buttonRect
);
883 /* paint the edit control padding area */
884 if (CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
)
886 RECT rPadEdit
= lphc
->textRect
;
888 InflateRect(&rPadEdit
, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
890 FrameRect( hDC
, &rPadEdit
, GetSysColorBrush(COLOR_WINDOW
) );
893 if( !(lphc
->wState
& CBF_EDIT
) )
894 CBPaintText( lphc
, hDC
);
897 SelectObject( hDC
, hPrevBrush
);
901 EndPaint(lphc
->self
, &ps
);
906 /***********************************************************************
909 * Select listbox entry according to the contents of the edit control.
911 static INT
CBUpdateLBox( LPHEADCOMBO lphc
, BOOL bSelect
)
917 length
= SendMessageW( lphc
->hWndEdit
, WM_GETTEXTLENGTH
, 0, 0 );
920 pText
= HeapAlloc( GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
));
922 TRACE("\t edit text length %i\n", length
);
926 GetWindowTextW( lphc
->hWndEdit
, pText
, length
+ 1);
927 idx
= SendMessageW(lphc
->hWndLBox
, LB_FINDSTRING
, -1, (LPARAM
)pText
);
928 HeapFree( GetProcessHeap(), 0, pText
);
931 SendMessageW(lphc
->hWndLBox
, LB_SETCURSEL
, bSelect
? idx
: -1, 0);
933 /* probably superfluous but Windows sends this too */
934 SendMessageW(lphc
->hWndLBox
, LB_SETCARETINDEX
, idx
< 0 ? 0 : idx
, 0);
935 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
, idx
< 0 ? 0 : idx
, 0);
940 /***********************************************************************
943 * Copy a listbox entry to the edit control.
945 static void CBUpdateEdit( LPHEADCOMBO lphc
, INT index
)
949 static const WCHAR empty_stringW
[] = { 0 };
951 TRACE("\t %i\n", index
);
953 if( index
>= 0 ) /* got an entry */
955 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, index
, 0);
956 if( length
!= LB_ERR
)
958 if( (pText
= HeapAlloc( GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
))) )
960 SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, index
, (LPARAM
)pText
);
965 if( CB_HASSTRINGS(lphc
) )
967 lphc
->wState
|= (CBF_NOEDITNOTIFY
| CBF_NOLBSELECT
);
968 SendMessageW(lphc
->hWndEdit
, WM_SETTEXT
, 0, pText
? (LPARAM
)pText
: (LPARAM
)empty_stringW
);
969 lphc
->wState
&= ~(CBF_NOEDITNOTIFY
| CBF_NOLBSELECT
);
972 if( lphc
->wState
& CBF_FOCUSED
)
973 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, -1);
975 HeapFree( GetProcessHeap(), 0, pText
);
978 /***********************************************************************
981 * Show listbox popup.
983 static void CBDropDown( LPHEADCOMBO lphc
)
986 MONITORINFO mon_info
;
991 TRACE("[%p]: drop down\n", lphc
->self
);
993 CB_NOTIFY( lphc
, CBN_DROPDOWN
);
997 lphc
->wState
|= CBF_DROPPED
;
998 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1000 lphc
->droppedIndex
= CBUpdateLBox( lphc
, TRUE
);
1002 /* Update edit only if item is in the list */
1003 if( !(lphc
->wState
& CBF_CAPTURE
) && lphc
->droppedIndex
>= 0)
1004 CBUpdateEdit( lphc
, lphc
->droppedIndex
);
1008 lphc
->droppedIndex
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1010 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
,
1011 lphc
->droppedIndex
== LB_ERR
? 0 : lphc
->droppedIndex
, 0);
1012 SendMessageW(lphc
->hWndLBox
, LB_CARETON
, 0, 0);
1015 /* now set popup position */
1016 GetWindowRect( lphc
->self
, &rect
);
1019 * If it's a dropdown, the listbox is offset
1021 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1022 rect
.left
+= COMBO_EDITBUTTONSPACE();
1024 /* if the dropped height is greater than the total height of the dropped
1025 items list, then force the drop down list height to be the total height
1026 of the items in the dropped list */
1028 /* And Remove any extra space (Best Fit) */
1029 nDroppedHeight
= lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
;
1030 /* if listbox length has been set directly by its handle */
1031 GetWindowRect(lphc
->hWndLBox
, &r
);
1032 if (nDroppedHeight
< r
.bottom
- r
.top
)
1033 nDroppedHeight
= r
.bottom
- r
.top
;
1034 nItems
= (int)SendMessageW(lphc
->hWndLBox
, LB_GETCOUNT
, 0, 0);
1041 nIHeight
= (int)SendMessageW(lphc
->hWndLBox
, LB_GETITEMHEIGHT
, 0, 0);
1043 nHeight
= nIHeight
*nItems
;
1045 if (nHeight
< nDroppedHeight
- COMBO_YBORDERSIZE())
1046 nDroppedHeight
= nHeight
+ COMBO_YBORDERSIZE();
1050 r
.top
= rect
.bottom
;
1051 r
.right
= r
.left
+ lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
1052 r
.bottom
= r
.top
+ nDroppedHeight
;
1054 /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/
1055 monitor
= MonitorFromRect( &rect
, MONITOR_DEFAULTTOPRIMARY
);
1056 mon_info
.cbSize
= sizeof(mon_info
);
1057 GetMonitorInfoW( monitor
, &mon_info
);
1059 if (r
.bottom
> mon_info
.rcWork
.bottom
)
1061 r
.top
= max( rect
.top
- nDroppedHeight
, mon_info
.rcWork
.top
);
1062 r
.bottom
= min( r
.top
+ nDroppedHeight
, mon_info
.rcWork
.bottom
);
1065 SetWindowPos( lphc
->hWndLBox
, HWND_TOPMOST
, r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
- r
.top
,
1066 SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
1069 if( !(lphc
->wState
& CBF_NOREDRAW
) )
1070 RedrawWindow( lphc
->self
, NULL
, 0, RDW_INVALIDATE
|
1071 RDW_ERASE
| RDW_UPDATENOW
| RDW_NOCHILDREN
);
1073 EnableWindow( lphc
->hWndLBox
, TRUE
);
1074 if (GetCapture() != lphc
->self
)
1075 SetCapture(lphc
->hWndLBox
);
1078 /***********************************************************************
1081 * Hide listbox popup.
1083 static void CBRollUp( LPHEADCOMBO lphc
, BOOL ok
, BOOL bButton
)
1085 HWND hWnd
= lphc
->self
;
1087 TRACE("[%p]: sel ok? [%i] dropped? [%i]\n",
1088 lphc
->self
, ok
, (INT
)(lphc
->wState
& CBF_DROPPED
));
1090 CB_NOTIFY( lphc
, (ok
) ? CBN_SELENDOK
: CBN_SELENDCANCEL
);
1092 if( IsWindow( hWnd
) && CB_GETTYPE(lphc
) != CBS_SIMPLE
)
1095 if( lphc
->wState
& CBF_DROPPED
)
1099 lphc
->wState
&= ~CBF_DROPPED
;
1100 ShowWindow( lphc
->hWndLBox
, SW_HIDE
);
1102 if(GetCapture() == lphc
->hWndLBox
)
1107 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1109 rect
= lphc
->buttonRect
;
1120 rect
= lphc
->textRect
;
1125 if( bButton
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1126 RedrawWindow( hWnd
, &rect
, 0, RDW_INVALIDATE
|
1127 RDW_ERASE
| RDW_UPDATENOW
| RDW_NOCHILDREN
);
1128 CB_NOTIFY( lphc
, CBN_CLOSEUP
);
1133 /***********************************************************************
1136 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
1138 BOOL
COMBO_FlipListbox( LPHEADCOMBO lphc
, BOOL ok
, BOOL bRedrawButton
)
1140 if( lphc
->wState
& CBF_DROPPED
)
1142 CBRollUp( lphc
, ok
, bRedrawButton
);
1150 /***********************************************************************
1153 static void CBRepaintButton( LPHEADCOMBO lphc
)
1155 InvalidateRect(lphc
->self
, &lphc
->buttonRect
, TRUE
);
1156 UpdateWindow(lphc
->self
);
1159 /***********************************************************************
1162 static void COMBO_SetFocus( LPHEADCOMBO lphc
)
1164 if( !(lphc
->wState
& CBF_FOCUSED
) )
1166 if( CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
)
1167 SendMessageW(lphc
->hWndLBox
, LB_CARETON
, 0, 0);
1169 /* This is wrong. Message sequences seem to indicate that this
1170 is set *after* the notify. */
1171 /* lphc->wState |= CBF_FOCUSED; */
1173 if( !(lphc
->wState
& CBF_EDIT
) )
1174 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1176 CB_NOTIFY( lphc
, CBN_SETFOCUS
);
1177 lphc
->wState
|= CBF_FOCUSED
;
1181 /***********************************************************************
1184 static void COMBO_KillFocus( LPHEADCOMBO lphc
)
1186 HWND hWnd
= lphc
->self
;
1188 if( lphc
->wState
& CBF_FOCUSED
)
1190 CBRollUp( lphc
, FALSE
, TRUE
);
1191 if( IsWindow( hWnd
) )
1193 if( CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
)
1194 SendMessageW(lphc
->hWndLBox
, LB_CARETOFF
, 0, 0);
1196 lphc
->wState
&= ~CBF_FOCUSED
;
1199 if( !(lphc
->wState
& CBF_EDIT
) )
1200 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1202 CB_NOTIFY( lphc
, CBN_KILLFOCUS
);
1207 /***********************************************************************
1210 static LRESULT
COMBO_Command( LPHEADCOMBO lphc
, WPARAM wParam
, HWND hWnd
)
1212 if ( lphc
->wState
& CBF_EDIT
&& lphc
->hWndEdit
== hWnd
)
1214 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1216 switch( HIWORD(wParam
) >> 8 )
1218 case (EN_SETFOCUS
>> 8):
1220 TRACE("[%p]: edit [%p] got focus\n", lphc
->self
, lphc
->hWndEdit
);
1222 COMBO_SetFocus( lphc
);
1225 case (EN_KILLFOCUS
>> 8):
1227 TRACE("[%p]: edit [%p] lost focus\n", lphc
->self
, lphc
->hWndEdit
);
1229 /* NOTE: it seems that Windows' edit control sends an
1230 * undocumented message WM_USER + 0x1B instead of this
1231 * notification (only when it happens to be a part of
1232 * the combo). ?? - AK.
1235 COMBO_KillFocus( lphc
);
1239 case (EN_CHANGE
>> 8):
1241 * In some circumstances (when the selection of the combobox
1242 * is changed for example) we don't want the EN_CHANGE notification
1243 * to be forwarded to the parent of the combobox. This code
1244 * checks a flag that is set in these occasions and ignores the
1247 if (lphc
->wState
& CBF_NOLBSELECT
)
1249 lphc
->wState
&= ~CBF_NOLBSELECT
;
1253 CBUpdateLBox( lphc
, lphc
->wState
& CBF_DROPPED
);
1256 if (!(lphc
->wState
& CBF_NOEDITNOTIFY
))
1257 CB_NOTIFY( lphc
, CBN_EDITCHANGE
);
1260 case (EN_UPDATE
>> 8):
1261 if (!(lphc
->wState
& CBF_NOEDITNOTIFY
))
1262 CB_NOTIFY( lphc
, CBN_EDITUPDATE
);
1265 case (EN_ERRSPACE
>> 8):
1266 CB_NOTIFY( lphc
, CBN_ERRSPACE
);
1269 else if( lphc
->hWndLBox
== hWnd
)
1271 switch( (short)HIWORD(wParam
) )
1274 CB_NOTIFY( lphc
, CBN_ERRSPACE
);
1278 CB_NOTIFY( lphc
, CBN_DBLCLK
);
1284 TRACE("[%p]: lbox selection change [%x]\n", lphc
->self
, lphc
->wState
);
1286 /* do not roll up if selection is being tracked
1287 * by arrow keys in the dropdown listbox */
1288 if (!(lphc
->wState
& CBF_NOROLLUP
))
1290 CBRollUp( lphc
, (HIWORD(wParam
) == LBN_SELCHANGE
), TRUE
);
1292 else lphc
->wState
&= ~CBF_NOROLLUP
;
1294 CB_NOTIFY( lphc
, CBN_SELCHANGE
);
1296 if( HIWORD(wParam
) == LBN_SELCHANGE
)
1298 if( lphc
->wState
& CBF_EDIT
)
1299 lphc
->wState
|= CBF_NOLBSELECT
;
1300 CBPaintText( lphc
, NULL
);
1306 /* nothing to do here since ComboLBox always resets the focus to its
1307 * combo/edit counterpart */
1314 /***********************************************************************
1317 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1319 static LRESULT
COMBO_ItemOp( LPHEADCOMBO lphc
, UINT msg
, LPARAM lParam
)
1321 HWND hWnd
= lphc
->self
;
1322 UINT id
= (UINT
)GetWindowLongPtrW( hWnd
, GWLP_ID
);
1324 TRACE("[%p]: ownerdraw op %04x\n", lphc
->self
, msg
);
1330 DELETEITEMSTRUCT
*lpIS
= (DELETEITEMSTRUCT
*)lParam
;
1331 lpIS
->CtlType
= ODT_COMBOBOX
;
1333 lpIS
->hwndItem
= hWnd
;
1338 DRAWITEMSTRUCT
*lpIS
= (DRAWITEMSTRUCT
*)lParam
;
1339 lpIS
->CtlType
= ODT_COMBOBOX
;
1341 lpIS
->hwndItem
= hWnd
;
1344 case WM_COMPAREITEM
:
1346 COMPAREITEMSTRUCT
*lpIS
= (COMPAREITEMSTRUCT
*)lParam
;
1347 lpIS
->CtlType
= ODT_COMBOBOX
;
1349 lpIS
->hwndItem
= hWnd
;
1352 case WM_MEASUREITEM
:
1354 MEASUREITEMSTRUCT
*lpIS
= (MEASUREITEMSTRUCT
*)lParam
;
1355 lpIS
->CtlType
= ODT_COMBOBOX
;
1360 return SendMessageW(lphc
->owner
, msg
, id
, lParam
);
1364 /***********************************************************************
1367 static LRESULT
COMBO_GetTextW( LPHEADCOMBO lphc
, INT count
, LPWSTR buf
)
1371 if( lphc
->wState
& CBF_EDIT
)
1372 return SendMessageW( lphc
->hWndEdit
, WM_GETTEXT
, count
, (LPARAM
)buf
);
1374 /* get it from the listbox */
1376 if (!count
|| !buf
) return 0;
1377 if( lphc
->hWndLBox
)
1379 INT idx
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1380 if (idx
== LB_ERR
) goto error
;
1381 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, idx
, 0 );
1382 if (length
== LB_ERR
) goto error
;
1384 /* 'length' is without the terminating character */
1385 if (length
>= count
)
1387 LPWSTR lpBuffer
= HeapAlloc(GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
));
1388 if (!lpBuffer
) goto error
;
1389 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)lpBuffer
);
1391 /* truncate if buffer is too short */
1392 if (length
!= LB_ERR
)
1394 lstrcpynW( buf
, lpBuffer
, count
);
1397 HeapFree( GetProcessHeap(), 0, lpBuffer
);
1399 else length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)buf
);
1401 if (length
== LB_ERR
) return 0;
1405 error
: /* error - truncate string, return zero */
1411 /***********************************************************************
1414 * NOTE! LB_GETTEXT does not count terminating \0, WM_GETTEXT does.
1415 * also LB_GETTEXT might return values < 0, WM_GETTEXT doesn't.
1417 static LRESULT
COMBO_GetTextA( LPHEADCOMBO lphc
, INT count
, LPSTR buf
)
1421 if( lphc
->wState
& CBF_EDIT
)
1422 return SendMessageA( lphc
->hWndEdit
, WM_GETTEXT
, count
, (LPARAM
)buf
);
1424 /* get it from the listbox */
1426 if (!count
|| !buf
) return 0;
1427 if( lphc
->hWndLBox
)
1429 INT idx
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1430 if (idx
== LB_ERR
) goto error
;
1431 length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, idx
, 0 );
1432 if (length
== LB_ERR
) goto error
;
1434 /* 'length' is without the terminating character */
1435 if (length
>= count
)
1437 LPSTR lpBuffer
= HeapAlloc(GetProcessHeap(), 0, (length
+ 1) );
1438 if (!lpBuffer
) goto error
;
1439 length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)lpBuffer
);
1441 /* truncate if buffer is too short */
1442 if (length
!= LB_ERR
)
1444 lstrcpynA( buf
, lpBuffer
, count
);
1447 HeapFree( GetProcessHeap(), 0, lpBuffer
);
1449 else length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)buf
);
1451 if (length
== LB_ERR
) return 0;
1455 error
: /* error - truncate string, return zero */
1461 /***********************************************************************
1464 * This function sets window positions according to the updated
1465 * component placement struct.
1467 static void CBResetPos(
1469 const RECT
*rectEdit
,
1473 BOOL bDrop
= (CB_GETTYPE(lphc
) != CBS_SIMPLE
);
1475 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1476 * sizing messages */
1478 if( lphc
->wState
& CBF_EDIT
)
1479 SetWindowPos( lphc
->hWndEdit
, 0,
1480 rectEdit
->left
, rectEdit
->top
,
1481 rectEdit
->right
- rectEdit
->left
,
1482 rectEdit
->bottom
- rectEdit
->top
,
1483 SWP_NOZORDER
| SWP_NOACTIVATE
| ((bDrop
) ? SWP_NOREDRAW
: 0) );
1485 SetWindowPos( lphc
->hWndLBox
, 0,
1486 rectLB
->left
, rectLB
->top
,
1487 rectLB
->right
- rectLB
->left
,
1488 rectLB
->bottom
- rectLB
->top
,
1489 SWP_NOACTIVATE
| SWP_NOZORDER
| ((bDrop
) ? SWP_NOREDRAW
: 0) );
1493 if( lphc
->wState
& CBF_DROPPED
)
1495 lphc
->wState
&= ~CBF_DROPPED
;
1496 ShowWindow( lphc
->hWndLBox
, SW_HIDE
);
1499 if( bRedraw
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1500 RedrawWindow( lphc
->self
, NULL
, 0,
1501 RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
);
1506 /***********************************************************************
1509 static void COMBO_Size( LPHEADCOMBO lphc
)
1512 * Those controls are always the same height. So we have to make sure
1513 * they are not resized to another value.
1515 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
1517 int newComboHeight
, curComboHeight
, curComboWidth
;
1520 GetWindowRect(lphc
->self
, &rc
);
1521 curComboHeight
= rc
.bottom
- rc
.top
;
1522 curComboWidth
= rc
.right
- rc
.left
;
1523 newComboHeight
= CBGetTextAreaHeight(lphc
->self
, lphc
) + 2*COMBO_YBORDERSIZE();
1526 * Resizing a combobox has another side effect, it resizes the dropped
1527 * rectangle as well. However, it does it only if the new height for the
1528 * combobox is more than the height it should have. In other words,
1529 * if the application resizing the combobox only had the intention to resize
1530 * the actual control, for example, to do the layout of a dialog that is
1531 * resized, the height of the dropdown is not changed.
1533 if( curComboHeight
> newComboHeight
)
1535 TRACE("oldComboHeight=%d, newComboHeight=%d, oldDropBottom=%d, oldDropTop=%d\n",
1536 curComboHeight
, newComboHeight
, lphc
->droppedRect
.bottom
,
1537 lphc
->droppedRect
.top
);
1538 lphc
->droppedRect
.bottom
= lphc
->droppedRect
.top
+ curComboHeight
- newComboHeight
;
1541 * Restore original height
1543 if( curComboHeight
!= newComboHeight
)
1544 SetWindowPos(lphc
->self
, 0, 0, 0, curComboWidth
, newComboHeight
,
1545 SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
);
1548 CBCalcPlacement(lphc
->self
,
1552 &lphc
->droppedRect
);
1554 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1558 /***********************************************************************
1561 static void COMBO_Font( LPHEADCOMBO lphc
, HFONT hFont
, BOOL bRedraw
)
1566 lphc
->hFont
= hFont
;
1569 * Propagate to owned windows.
1571 if( lphc
->wState
& CBF_EDIT
)
1572 SendMessageW(lphc
->hWndEdit
, WM_SETFONT
, (WPARAM
)hFont
, bRedraw
);
1573 SendMessageW(lphc
->hWndLBox
, WM_SETFONT
, (WPARAM
)hFont
, bRedraw
);
1576 * Redo the layout of the control.
1578 if ( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
1580 CBCalcPlacement(lphc
->self
,
1584 &lphc
->droppedRect
);
1586 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1590 CBForceDummyResize(lphc
);
1595 /***********************************************************************
1596 * COMBO_SetItemHeight
1598 static LRESULT
COMBO_SetItemHeight( LPHEADCOMBO lphc
, INT index
, INT height
)
1600 LRESULT lRet
= CB_ERR
;
1602 if( index
== -1 ) /* set text field height */
1604 if( height
< 32768 )
1606 lphc
->editHeight
= height
+ 2; /* Is the 2 for 2*EDIT_CONTROL_PADDING? */
1609 * Redo the layout of the control.
1611 if ( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
1613 CBCalcPlacement(lphc
->self
,
1617 &lphc
->droppedRect
);
1619 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1623 CBForceDummyResize(lphc
);
1629 else if ( CB_OWNERDRAWN(lphc
) ) /* set listbox item height */
1630 lRet
= SendMessageW(lphc
->hWndLBox
, LB_SETITEMHEIGHT
, index
, height
);
1634 /***********************************************************************
1635 * COMBO_SelectString
1637 static LRESULT
COMBO_SelectString( LPHEADCOMBO lphc
, INT start
, LPARAM pText
, BOOL unicode
)
1639 INT index
= unicode
? SendMessageW(lphc
->hWndLBox
, LB_SELECTSTRING
, start
, pText
) :
1640 SendMessageA(lphc
->hWndLBox
, LB_SELECTSTRING
, start
, pText
);
1643 if( lphc
->wState
& CBF_EDIT
)
1644 CBUpdateEdit( lphc
, index
);
1647 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1650 return (LRESULT
)index
;
1653 /***********************************************************************
1656 static void COMBO_LButtonDown( LPHEADCOMBO lphc
, LPARAM lParam
)
1660 HWND hWnd
= lphc
->self
;
1662 pt
.x
= (short)LOWORD(lParam
);
1663 pt
.y
= (short)HIWORD(lParam
);
1664 bButton
= PtInRect(&lphc
->buttonRect
, pt
);
1666 if( (CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
) ||
1667 (bButton
&& (CB_GETTYPE(lphc
) == CBS_DROPDOWN
)) )
1669 lphc
->wState
|= CBF_BUTTONDOWN
;
1670 if( lphc
->wState
& CBF_DROPPED
)
1672 /* got a click to cancel selection */
1674 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1675 CBRollUp( lphc
, TRUE
, FALSE
);
1676 if( !IsWindow( hWnd
) ) return;
1678 if( lphc
->wState
& CBF_CAPTURE
)
1680 lphc
->wState
&= ~CBF_CAPTURE
;
1686 /* drop down the listbox and start tracking */
1688 lphc
->wState
|= CBF_CAPTURE
;
1692 if( bButton
) CBRepaintButton( lphc
);
1696 /***********************************************************************
1699 * Release capture and stop tracking if needed.
1701 static void COMBO_LButtonUp( LPHEADCOMBO lphc
)
1703 if( lphc
->wState
& CBF_CAPTURE
)
1705 lphc
->wState
&= ~CBF_CAPTURE
;
1706 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1708 INT index
= CBUpdateLBox( lphc
, TRUE
);
1709 /* Update edit only if item is in the list */
1712 lphc
->wState
|= CBF_NOLBSELECT
;
1713 CBUpdateEdit( lphc
, index
);
1714 lphc
->wState
&= ~CBF_NOLBSELECT
;
1718 SetCapture(lphc
->hWndLBox
);
1721 if( lphc
->wState
& CBF_BUTTONDOWN
)
1723 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1724 CBRepaintButton( lphc
);
1728 /***********************************************************************
1731 * Two things to do - track combo button and release capture when
1732 * pointer goes into the listbox.
1734 static void COMBO_MouseMove( LPHEADCOMBO lphc
, WPARAM wParam
, LPARAM lParam
)
1739 pt
.x
= (short)LOWORD(lParam
);
1740 pt
.y
= (short)HIWORD(lParam
);
1742 if( lphc
->wState
& CBF_BUTTONDOWN
)
1746 bButton
= PtInRect(&lphc
->buttonRect
, pt
);
1750 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1751 CBRepaintButton( lphc
);
1755 GetClientRect( lphc
->hWndLBox
, &lbRect
);
1756 MapWindowPoints( lphc
->self
, lphc
->hWndLBox
, &pt
, 1 );
1757 if( PtInRect(&lbRect
, pt
) )
1759 lphc
->wState
&= ~CBF_CAPTURE
;
1761 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
) CBUpdateLBox( lphc
, TRUE
);
1763 /* hand over pointer tracking */
1764 SendMessageW(lphc
->hWndLBox
, WM_LBUTTONDOWN
, wParam
, lParam
);
1768 static LRESULT
COMBO_GetComboBoxInfo(const HEADCOMBO
*lphc
, COMBOBOXINFO
*pcbi
)
1770 if (!pcbi
|| (pcbi
->cbSize
< sizeof(COMBOBOXINFO
)))
1773 pcbi
->rcItem
= lphc
->textRect
;
1774 pcbi
->rcButton
= lphc
->buttonRect
;
1775 pcbi
->stateButton
= 0;
1776 if (lphc
->wState
& CBF_BUTTONDOWN
)
1777 pcbi
->stateButton
|= STATE_SYSTEM_PRESSED
;
1778 if (IsRectEmpty(&lphc
->buttonRect
))
1779 pcbi
->stateButton
|= STATE_SYSTEM_INVISIBLE
;
1780 pcbi
->hwndCombo
= lphc
->self
;
1781 pcbi
->hwndItem
= lphc
->hWndEdit
;
1782 pcbi
->hwndList
= lphc
->hWndLBox
;
1786 static char *strdupA(LPCSTR str
)
1791 if(!str
) return NULL
;
1794 ret
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
1795 memcpy(ret
, str
, len
+ 1);
1799 /***********************************************************************
1800 * ComboWndProc_common
1802 LRESULT
ComboWndProc_common( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
1804 LPHEADCOMBO lphc
= (LPHEADCOMBO
)GetWindowLongPtrW( hwnd
, 0 );
1806 TRACE("[%p]: msg %s wp %08lx lp %08lx\n",
1807 hwnd
, SPY_GetMsgName(message
, hwnd
), wParam
, lParam
);
1809 if (!IsWindow(hwnd
)) return 0;
1811 if( lphc
|| message
== WM_NCCREATE
)
1815 /* System messages */
1819 LONG style
= unicode
? ((LPCREATESTRUCTW
)lParam
)->style
:
1820 ((LPCREATESTRUCTA
)lParam
)->style
;
1821 return COMBO_NCCreate(hwnd
, style
);
1824 COMBO_NCDestroy(lphc
);
1825 break;/* -> DefWindowProc */
1833 hwndParent
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
1834 style
= ((LPCREATESTRUCTW
)lParam
)->style
;
1838 hwndParent
= ((LPCREATESTRUCTA
)lParam
)->hwndParent
;
1839 style
= ((LPCREATESTRUCTA
)lParam
)->style
;
1841 return COMBO_Create(hwnd
, lphc
, hwndParent
, style
, unicode
);
1844 case WM_PRINTCLIENT
:
1847 /* wParam may contain a valid HDC! */
1848 return COMBO_Paint(lphc
, (HDC
)wParam
);
1851 /* do all painting in WM_PAINT like Windows does */
1856 LRESULT result
= DLGC_WANTARROWS
| DLGC_WANTCHARS
;
1857 if (lParam
&& (((LPMSG
)lParam
)->message
== WM_KEYDOWN
))
1859 int vk
= (int)((LPMSG
)lParam
)->wParam
;
1861 if ((vk
== VK_RETURN
|| vk
== VK_ESCAPE
) && (lphc
->wState
& CBF_DROPPED
))
1862 result
|= DLGC_WANTMESSAGE
;
1867 if( lphc
->hWndLBox
&&
1868 !(lphc
->wState
& CBF_NORESIZE
) ) COMBO_Size( lphc
);
1871 COMBO_Font( lphc
, (HFONT
)wParam
, (BOOL
)lParam
);
1874 return (LRESULT
)lphc
->hFont
;
1876 if( lphc
->wState
& CBF_EDIT
) {
1877 SetFocus( lphc
->hWndEdit
);
1878 /* The first time focus is received, select all the text */
1879 if( !(lphc
->wState
& CBF_BEENFOCUSED
) ) {
1880 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, -1);
1881 lphc
->wState
|= CBF_BEENFOCUSED
;
1885 COMBO_SetFocus( lphc
);
1889 HWND hwndFocus
= WIN_GetFullHandle( (HWND
)wParam
);
1891 (hwndFocus
!= lphc
->hWndEdit
&& hwndFocus
!= lphc
->hWndLBox
))
1892 COMBO_KillFocus( lphc
);
1896 return COMBO_Command( lphc
, wParam
, WIN_GetFullHandle( (HWND
)lParam
) );
1898 return unicode
? COMBO_GetTextW( lphc
, wParam
, (LPWSTR
)lParam
)
1899 : COMBO_GetTextA( lphc
, wParam
, (LPSTR
)lParam
);
1901 case WM_GETTEXTLENGTH
:
1903 if ((message
== WM_GETTEXTLENGTH
) && !ISWIN31
&& !(lphc
->wState
& CBF_EDIT
))
1905 int j
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1906 if (j
== -1) return 0;
1907 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, j
, 0) :
1908 SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, j
, 0);
1910 else if( lphc
->wState
& CBF_EDIT
)
1913 lphc
->wState
|= CBF_NOEDITNOTIFY
;
1914 ret
= unicode
? SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
) :
1915 SendMessageA(lphc
->hWndEdit
, message
, wParam
, lParam
);
1916 lphc
->wState
&= ~CBF_NOEDITNOTIFY
;
1923 if( lphc
->wState
& CBF_EDIT
)
1925 return unicode
? SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
) :
1926 SendMessageA(lphc
->hWndEdit
, message
, wParam
, lParam
);
1932 case WM_COMPAREITEM
:
1933 case WM_MEASUREITEM
:
1934 return COMBO_ItemOp(lphc
, message
, lParam
);
1936 if( lphc
->wState
& CBF_EDIT
)
1937 EnableWindow( lphc
->hWndEdit
, (BOOL
)wParam
);
1938 EnableWindow( lphc
->hWndLBox
, (BOOL
)wParam
);
1940 /* Force the control to repaint when the enabled state changes. */
1941 InvalidateRect(lphc
->self
, NULL
, TRUE
);
1945 lphc
->wState
&= ~CBF_NOREDRAW
;
1947 lphc
->wState
|= CBF_NOREDRAW
;
1949 if( lphc
->wState
& CBF_EDIT
)
1950 SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
);
1951 SendMessageW(lphc
->hWndLBox
, message
, wParam
, lParam
);
1954 if( KEYDATA_ALT
& HIWORD(lParam
) )
1955 if( wParam
== VK_UP
|| wParam
== VK_DOWN
)
1956 COMBO_FlipListbox( lphc
, FALSE
, FALSE
);
1960 if ((wParam
== VK_RETURN
|| wParam
== VK_ESCAPE
) &&
1961 (lphc
->wState
& CBF_DROPPED
))
1963 CBRollUp( lphc
, wParam
== VK_RETURN
, FALSE
);
1966 else if ((wParam
== VK_F4
) && !(lphc
->wState
& CBF_EUI
))
1968 COMBO_FlipListbox( lphc
, FALSE
, FALSE
);
1977 if( lphc
->wState
& CBF_EDIT
)
1978 hwndTarget
= lphc
->hWndEdit
;
1980 hwndTarget
= lphc
->hWndLBox
;
1982 return unicode
? SendMessageW(hwndTarget
, message
, wParam
, lParam
) :
1983 SendMessageA(hwndTarget
, message
, wParam
, lParam
);
1985 case WM_LBUTTONDOWN
:
1986 if( !(lphc
->wState
& CBF_FOCUSED
) ) SetFocus( lphc
->self
);
1987 if( lphc
->wState
& CBF_FOCUSED
) COMBO_LButtonDown( lphc
, lParam
);
1990 COMBO_LButtonUp( lphc
);
1993 if( lphc
->wState
& CBF_CAPTURE
)
1994 COMBO_MouseMove( lphc
, wParam
, lParam
);
1998 if (wParam
& (MK_SHIFT
| MK_CONTROL
))
1999 return unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
) :
2000 DefWindowProcA(hwnd
, message
, wParam
, lParam
);
2002 if (GET_WHEEL_DELTA_WPARAM(wParam
) > 0) return SendMessageW(hwnd
, WM_KEYDOWN
, VK_UP
, 0);
2003 if (GET_WHEEL_DELTA_WPARAM(wParam
) < 0) return SendMessageW(hwnd
, WM_KEYDOWN
, VK_DOWN
, 0);
2006 /* Combo messages */
2011 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2012 CharLowerW((LPWSTR
)lParam
);
2013 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2014 CharUpperW((LPWSTR
)lParam
);
2015 return SendMessageW(lphc
->hWndLBox
, LB_ADDSTRING
, 0, lParam
);
2017 else /* unlike the unicode version, the ansi version does not overwrite
2018 the string if converting case */
2020 char *string
= NULL
;
2022 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2024 string
= strdupA((LPSTR
)lParam
);
2028 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2030 string
= strdupA((LPSTR
)lParam
);
2034 ret
= SendMessageA(lphc
->hWndLBox
, LB_ADDSTRING
, 0, string
? (LPARAM
)string
: lParam
);
2035 HeapFree(GetProcessHeap(), 0, string
);
2038 case CB_INSERTSTRING
:
2041 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2042 CharLowerW((LPWSTR
)lParam
);
2043 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2044 CharUpperW((LPWSTR
)lParam
);
2045 return SendMessageW(lphc
->hWndLBox
, LB_INSERTSTRING
, wParam
, lParam
);
2049 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2050 CharLowerA((LPSTR
)lParam
);
2051 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2052 CharUpperA((LPSTR
)lParam
);
2054 return SendMessageA(lphc
->hWndLBox
, LB_INSERTSTRING
, wParam
, lParam
);
2056 case CB_DELETESTRING
:
2057 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_DELETESTRING
, wParam
, 0) :
2058 SendMessageA(lphc
->hWndLBox
, LB_DELETESTRING
, wParam
, 0);
2059 case CB_SELECTSTRING
:
2060 return COMBO_SelectString(lphc
, (INT
)wParam
, lParam
, unicode
);
2062 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_FINDSTRING
, wParam
, lParam
) :
2063 SendMessageA(lphc
->hWndLBox
, LB_FINDSTRING
, wParam
, lParam
);
2064 case CB_FINDSTRINGEXACT
:
2065 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_FINDSTRINGEXACT
, wParam
, lParam
) :
2066 SendMessageA(lphc
->hWndLBox
, LB_FINDSTRINGEXACT
, wParam
, lParam
);
2067 case CB_SETITEMHEIGHT
:
2068 return COMBO_SetItemHeight( lphc
, (INT
)wParam
, (INT
)lParam
);
2069 case CB_GETITEMHEIGHT
:
2070 if( (INT
)wParam
>= 0 ) /* listbox item */
2071 return SendMessageW(lphc
->hWndLBox
, LB_GETITEMHEIGHT
, wParam
, 0);
2072 return CBGetTextAreaHeight(hwnd
, lphc
);
2073 case CB_RESETCONTENT
:
2074 SendMessageW(lphc
->hWndLBox
, LB_RESETCONTENT
, 0, 0);
2075 if( (lphc
->wState
& CBF_EDIT
) && CB_HASSTRINGS(lphc
) )
2077 static const WCHAR empty_stringW
[] = { 0 };
2078 SendMessageW(lphc
->hWndEdit
, WM_SETTEXT
, 0, (LPARAM
)empty_stringW
);
2081 InvalidateRect(lphc
->self
, NULL
, TRUE
);
2083 case CB_INITSTORAGE
:
2084 return SendMessageW(lphc
->hWndLBox
, LB_INITSTORAGE
, wParam
, lParam
);
2085 case CB_GETHORIZONTALEXTENT
:
2086 return SendMessageW(lphc
->hWndLBox
, LB_GETHORIZONTALEXTENT
, 0, 0);
2087 case CB_SETHORIZONTALEXTENT
:
2088 return SendMessageW(lphc
->hWndLBox
, LB_SETHORIZONTALEXTENT
, wParam
, 0);
2089 case CB_GETTOPINDEX
:
2090 return SendMessageW(lphc
->hWndLBox
, LB_GETTOPINDEX
, 0, 0);
2092 return SendMessageW(lphc
->hWndLBox
, LB_GETLOCALE
, 0, 0);
2094 return SendMessageW(lphc
->hWndLBox
, LB_SETLOCALE
, wParam
, 0);
2095 case CB_SETDROPPEDWIDTH
:
2096 if( (CB_GETTYPE(lphc
) == CBS_SIMPLE
) ||
2097 (INT
)wParam
>= 32768 )
2099 /* new value must be higher than combobox width */
2100 if((INT
)wParam
>= lphc
->droppedRect
.right
- lphc
->droppedRect
.left
)
2101 lphc
->droppedWidth
= wParam
;
2103 lphc
->droppedWidth
= 0;
2105 /* recalculate the combobox area */
2106 CBCalcPlacement(hwnd
, lphc
, &lphc
->textRect
, &lphc
->buttonRect
, &lphc
->droppedRect
);
2109 case CB_GETDROPPEDWIDTH
:
2110 if( lphc
->droppedWidth
)
2111 return lphc
->droppedWidth
;
2112 return lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
2113 case CB_GETDROPPEDCONTROLRECT
:
2114 if( lParam
) CBGetDroppedControlRect(lphc
, (LPRECT
)lParam
);
2116 case CB_GETDROPPEDSTATE
:
2117 return (lphc
->wState
& CBF_DROPPED
) != 0;
2119 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_DIR
, wParam
, lParam
) :
2120 SendMessageA(lphc
->hWndLBox
, LB_DIR
, wParam
, lParam
);
2122 case CB_SHOWDROPDOWN
:
2123 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
2127 if( !(lphc
->wState
& CBF_DROPPED
) )
2131 if( lphc
->wState
& CBF_DROPPED
)
2132 CBRollUp( lphc
, FALSE
, TRUE
);
2136 return SendMessageW(lphc
->hWndLBox
, LB_GETCOUNT
, 0, 0);
2138 return SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
2140 lParam
= SendMessageW(lphc
->hWndLBox
, LB_SETCURSEL
, wParam
, 0);
2142 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
, wParam
, 0);
2144 /* no LBN_SELCHANGE in this case, update manually */
2145 CBPaintText( lphc
, NULL
);
2146 lphc
->wState
&= ~CBF_SELCHANGE
;
2149 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, wParam
, lParam
) :
2150 SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, wParam
, lParam
);
2151 case CB_GETLBTEXTLEN
:
2152 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, wParam
, 0) :
2153 SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, wParam
, 0);
2154 case CB_GETITEMDATA
:
2155 return SendMessageW(lphc
->hWndLBox
, LB_GETITEMDATA
, wParam
, 0);
2156 case CB_SETITEMDATA
:
2157 return SendMessageW(lphc
->hWndLBox
, LB_SETITEMDATA
, wParam
, lParam
);
2159 /* Edit checks passed parameters itself */
2160 if( lphc
->wState
& CBF_EDIT
)
2161 return SendMessageW(lphc
->hWndEdit
, EM_GETSEL
, wParam
, lParam
);
2164 if( lphc
->wState
& CBF_EDIT
)
2165 return SendMessageW(lphc
->hWndEdit
, EM_SETSEL
,
2166 (INT
)(SHORT
)LOWORD(lParam
), (INT
)(SHORT
)HIWORD(lParam
) );
2168 case CB_SETEXTENDEDUI
:
2169 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
2172 lphc
->wState
|= CBF_EUI
;
2173 else lphc
->wState
&= ~CBF_EUI
;
2175 case CB_GETEXTENDEDUI
:
2176 return (lphc
->wState
& CBF_EUI
) != 0;
2177 case CB_GETCOMBOBOXINFO
:
2178 return COMBO_GetComboBoxInfo(lphc
, (COMBOBOXINFO
*)lParam
);
2180 if( lphc
->wState
& CBF_EDIT
)
2181 return SendMessageW(lphc
->hWndEdit
, EM_LIMITTEXT
, wParam
, lParam
);
2184 if (message
>= WM_USER
)
2185 WARN("unknown msg WM_USER+%04x wp=%04lx lp=%08lx\n",
2186 message
- WM_USER
, wParam
, lParam
);
2189 return unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
) :
2190 DefWindowProcA(hwnd
, message
, wParam
, lParam
);
2193 /*************************************************************************
2194 * GetComboBoxInfo (USER32.@)
2196 BOOL WINAPI
GetComboBoxInfo(HWND hwndCombo
, /* [in] handle to combo box */
2197 PCOMBOBOXINFO pcbi
/* [in/out] combo box information */)
2199 TRACE("(%p, %p)\n", hwndCombo
, pcbi
);
2200 return SendMessageW(hwndCombo
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
);