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
;
708 /* follow Windows combobox that sends a bunch of text
709 * inquiries to its listbox while processing WM_PAINT. */
711 if( (id
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0) ) != LB_ERR
)
713 size
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, id
, 0);
715 FIXME("LB_ERR probably not handled yet\n");
716 if( (pText
= HeapAlloc( GetProcessHeap(), 0, (size
+ 1) * sizeof(WCHAR
))) )
718 /* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */
719 size
=SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, id
, (LPARAM
)pText
);
720 pText
[size
] = '\0'; /* just in case */
724 if( lphc
->wState
& CBF_EDIT
)
726 static const WCHAR empty_stringW
[] = { 0 };
727 if( CB_HASSTRINGS(lphc
) ) SetWindowTextW( lphc
->hWndEdit
, pText
? pText
: empty_stringW
);
728 if( lphc
->wState
& CBF_FOCUSED
)
729 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, MAXLONG
);
731 else if(!(lphc
->wState
& CBF_NOREDRAW
) && IsWindowVisible( lphc
->self
))
733 /* paint text field ourselves */
734 HDC hdc
= hdc_paint
? hdc_paint
: GetDC(lphc
->self
);
735 UINT itemState
= ODS_COMBOBOXEDIT
;
736 HFONT hPrevFont
= (lphc
->hFont
) ? SelectObject(hdc
, lphc
->hFont
) : 0;
737 HBRUSH hPrevBrush
, hBkgBrush
;
740 * Give ourselves some space.
742 InflateRect( &rectEdit
, -1, -1 );
744 hBkgBrush
= COMBO_PrepareColors( lphc
, hdc
);
745 hPrevBrush
= SelectObject( hdc
, hBkgBrush
);
746 FillRect( hdc
, &rectEdit
, hBkgBrush
);
748 if( CB_OWNERDRAWN(lphc
) )
752 UINT ctlid
= (UINT
)GetWindowLongPtrW( lphc
->self
, GWLP_ID
);
754 /* setup state for DRAWITEM message. Owner will highlight */
755 if ( (lphc
->wState
& CBF_FOCUSED
) &&
756 !(lphc
->wState
& CBF_DROPPED
) )
757 itemState
|= ODS_SELECTED
| ODS_FOCUS
;
759 if (!IsWindowEnabled(lphc
->self
)) itemState
|= ODS_DISABLED
;
761 dis
.CtlType
= ODT_COMBOBOX
;
763 dis
.hwndItem
= lphc
->self
;
764 dis
.itemAction
= ODA_DRAWENTIRE
;
766 dis
.itemState
= itemState
;
768 dis
.rcItem
= rectEdit
;
769 dis
.itemData
= SendMessageW(lphc
->hWndLBox
, LB_GETITEMDATA
, id
, 0);
772 * Clip the DC and have the parent draw the item.
774 clipRegion
= set_control_clipping( hdc
, &rectEdit
);
776 SendMessageW(lphc
->owner
, WM_DRAWITEM
, ctlid
, (LPARAM
)&dis
);
778 SelectClipRgn( hdc
, clipRegion
);
779 if (clipRegion
) DeleteObject( clipRegion
);
783 static const WCHAR empty_stringW
[] = { 0 };
785 if ( (lphc
->wState
& CBF_FOCUSED
) &&
786 !(lphc
->wState
& CBF_DROPPED
) ) {
789 FillRect( hdc
, &rectEdit
, GetSysColorBrush(COLOR_HIGHLIGHT
) );
790 SetBkColor( hdc
, GetSysColor( COLOR_HIGHLIGHT
) );
791 SetTextColor( hdc
, GetSysColor( COLOR_HIGHLIGHTTEXT
) );
797 ETO_OPAQUE
| ETO_CLIPPED
,
799 pText
? pText
: empty_stringW
, size
, NULL
);
801 if(lphc
->wState
& CBF_FOCUSED
&& !(lphc
->wState
& CBF_DROPPED
))
802 DrawFocusRect( hdc
, &rectEdit
);
806 SelectObject(hdc
, hPrevFont
);
809 SelectObject( hdc
, hPrevBrush
);
812 ReleaseDC( lphc
->self
, hdc
);
814 HeapFree( GetProcessHeap(), 0, pText
);
817 /***********************************************************************
820 static void CBPaintBorder(
822 const HEADCOMBO
*lphc
,
827 if (CB_GETTYPE(lphc
) != CBS_SIMPLE
)
829 GetClientRect(hwnd
, &clientRect
);
833 clientRect
= lphc
->textRect
;
835 InflateRect(&clientRect
, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
836 InflateRect(&clientRect
, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
839 DrawEdge(hdc
, &clientRect
, EDGE_SUNKEN
, BF_RECT
);
842 /***********************************************************************
845 static LRESULT
COMBO_Paint(LPHEADCOMBO lphc
, HDC hParamDC
)
850 hDC
= (hParamDC
) ? hParamDC
851 : BeginPaint( lphc
->self
, &ps
);
853 TRACE("hdc=%p\n", hDC
);
855 if( hDC
&& !(lphc
->wState
& CBF_NOREDRAW
) )
857 HBRUSH hPrevBrush
, hBkgBrush
;
860 * Retrieve the background brush and select it in the
863 hBkgBrush
= COMBO_PrepareColors(lphc
, hDC
);
865 hPrevBrush
= SelectObject( hDC
, hBkgBrush
);
866 if (!(lphc
->wState
& CBF_EDIT
))
867 FillRect(hDC
, &lphc
->textRect
, hBkgBrush
);
870 * In non 3.1 look, there is a sunken border on the combobox
872 CBPaintBorder(lphc
->self
, lphc
, hDC
);
874 if( !IsRectEmpty(&lphc
->buttonRect
) )
876 CBPaintButton(lphc
, hDC
, lphc
->buttonRect
);
879 /* paint the edit control padding area */
880 if (CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
)
882 RECT rPadEdit
= lphc
->textRect
;
884 InflateRect(&rPadEdit
, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
886 FrameRect( hDC
, &rPadEdit
, GetSysColorBrush(COLOR_WINDOW
) );
889 if( !(lphc
->wState
& CBF_EDIT
) )
890 CBPaintText( lphc
, hDC
);
893 SelectObject( hDC
, hPrevBrush
);
897 EndPaint(lphc
->self
, &ps
);
902 /***********************************************************************
905 * Select listbox entry according to the contents of the edit control.
907 static INT
CBUpdateLBox( LPHEADCOMBO lphc
, BOOL bSelect
)
913 length
= SendMessageW( lphc
->hWndEdit
, WM_GETTEXTLENGTH
, 0, 0 );
916 pText
= HeapAlloc( GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
));
918 TRACE("\t edit text length %i\n", length
);
922 GetWindowTextW( lphc
->hWndEdit
, pText
, length
+ 1);
923 idx
= SendMessageW(lphc
->hWndLBox
, LB_FINDSTRING
, -1, (LPARAM
)pText
);
924 HeapFree( GetProcessHeap(), 0, pText
);
927 SendMessageW(lphc
->hWndLBox
, LB_SETCURSEL
, bSelect
? idx
: -1, 0);
929 /* probably superfluous but Windows sends this too */
930 SendMessageW(lphc
->hWndLBox
, LB_SETCARETINDEX
, idx
< 0 ? 0 : idx
, 0);
931 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
, idx
< 0 ? 0 : idx
, 0);
936 /***********************************************************************
939 * Copy a listbox entry to the edit control.
941 static void CBUpdateEdit( LPHEADCOMBO lphc
, INT index
)
945 static const WCHAR empty_stringW
[] = { 0 };
947 TRACE("\t %i\n", index
);
949 if( index
>= 0 ) /* got an entry */
951 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, index
, 0);
952 if( length
!= LB_ERR
)
954 if( (pText
= HeapAlloc( GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
))) )
956 SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, index
, (LPARAM
)pText
);
961 if( CB_HASSTRINGS(lphc
) )
963 lphc
->wState
|= (CBF_NOEDITNOTIFY
| CBF_NOLBSELECT
);
964 SendMessageW(lphc
->hWndEdit
, WM_SETTEXT
, 0, pText
? (LPARAM
)pText
: (LPARAM
)empty_stringW
);
965 lphc
->wState
&= ~(CBF_NOEDITNOTIFY
| CBF_NOLBSELECT
);
968 if( lphc
->wState
& CBF_FOCUSED
)
969 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, -1);
971 HeapFree( GetProcessHeap(), 0, pText
);
974 /***********************************************************************
977 * Show listbox popup.
979 static void CBDropDown( LPHEADCOMBO lphc
)
982 MONITORINFO mon_info
;
987 TRACE("[%p]: drop down\n", lphc
->self
);
989 CB_NOTIFY( lphc
, CBN_DROPDOWN
);
993 lphc
->wState
|= CBF_DROPPED
;
994 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
996 lphc
->droppedIndex
= CBUpdateLBox( lphc
, TRUE
);
998 /* Update edit only if item is in the list */
999 if( !(lphc
->wState
& CBF_CAPTURE
) && lphc
->droppedIndex
>= 0)
1000 CBUpdateEdit( lphc
, lphc
->droppedIndex
);
1004 lphc
->droppedIndex
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1006 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
,
1007 lphc
->droppedIndex
== LB_ERR
? 0 : lphc
->droppedIndex
, 0);
1008 SendMessageW(lphc
->hWndLBox
, LB_CARETON
, 0, 0);
1011 /* now set popup position */
1012 GetWindowRect( lphc
->self
, &rect
);
1015 * If it's a dropdown, the listbox is offset
1017 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1018 rect
.left
+= COMBO_EDITBUTTONSPACE();
1020 /* if the dropped height is greater than the total height of the dropped
1021 items list, then force the drop down list height to be the total height
1022 of the items in the dropped list */
1024 /* And Remove any extra space (Best Fit) */
1025 nDroppedHeight
= lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
;
1026 /* if listbox length has been set directly by its handle */
1027 GetWindowRect(lphc
->hWndLBox
, &r
);
1028 if (nDroppedHeight
< r
.bottom
- r
.top
)
1029 nDroppedHeight
= r
.bottom
- r
.top
;
1030 nItems
= (int)SendMessageW(lphc
->hWndLBox
, LB_GETCOUNT
, 0, 0);
1037 nIHeight
= (int)SendMessageW(lphc
->hWndLBox
, LB_GETITEMHEIGHT
, 0, 0);
1039 nHeight
= nIHeight
*nItems
;
1041 if (nHeight
< nDroppedHeight
- COMBO_YBORDERSIZE())
1042 nDroppedHeight
= nHeight
+ COMBO_YBORDERSIZE();
1044 if (nDroppedHeight
< nHeight
)
1047 nDroppedHeight
= (nItems
+1)*nIHeight
;
1048 else if (nDroppedHeight
< 6*nIHeight
)
1049 nDroppedHeight
= 6*nIHeight
;
1054 r
.top
= rect
.bottom
;
1055 r
.right
= r
.left
+ lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
1056 r
.bottom
= r
.top
+ nDroppedHeight
;
1058 /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/
1059 monitor
= MonitorFromRect( &rect
, MONITOR_DEFAULTTOPRIMARY
);
1060 mon_info
.cbSize
= sizeof(mon_info
);
1061 GetMonitorInfoW( monitor
, &mon_info
);
1063 if (r
.bottom
> mon_info
.rcWork
.bottom
)
1065 r
.top
= max( rect
.top
- nDroppedHeight
, mon_info
.rcWork
.top
);
1066 r
.bottom
= min( r
.top
+ nDroppedHeight
, mon_info
.rcWork
.bottom
);
1069 SetWindowPos( lphc
->hWndLBox
, HWND_TOPMOST
, r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
- r
.top
,
1070 SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
1073 if( !(lphc
->wState
& CBF_NOREDRAW
) )
1074 RedrawWindow( lphc
->self
, NULL
, 0, RDW_INVALIDATE
|
1075 RDW_ERASE
| RDW_UPDATENOW
| RDW_NOCHILDREN
);
1077 EnableWindow( lphc
->hWndLBox
, TRUE
);
1078 if (GetCapture() != lphc
->self
)
1079 SetCapture(lphc
->hWndLBox
);
1082 /***********************************************************************
1085 * Hide listbox popup.
1087 static void CBRollUp( LPHEADCOMBO lphc
, BOOL ok
, BOOL bButton
)
1089 HWND hWnd
= lphc
->self
;
1091 TRACE("[%p]: sel ok? [%i] dropped? [%i]\n",
1092 lphc
->self
, ok
, (INT
)(lphc
->wState
& CBF_DROPPED
));
1094 CB_NOTIFY( lphc
, (ok
) ? CBN_SELENDOK
: CBN_SELENDCANCEL
);
1096 if( IsWindow( hWnd
) && CB_GETTYPE(lphc
) != CBS_SIMPLE
)
1099 if( lphc
->wState
& CBF_DROPPED
)
1103 lphc
->wState
&= ~CBF_DROPPED
;
1104 ShowWindow( lphc
->hWndLBox
, SW_HIDE
);
1106 if(GetCapture() == lphc
->hWndLBox
)
1111 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1113 rect
= lphc
->buttonRect
;
1124 rect
= lphc
->textRect
;
1129 if( bButton
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1130 RedrawWindow( hWnd
, &rect
, 0, RDW_INVALIDATE
|
1131 RDW_ERASE
| RDW_UPDATENOW
| RDW_NOCHILDREN
);
1132 CB_NOTIFY( lphc
, CBN_CLOSEUP
);
1137 /***********************************************************************
1140 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
1142 BOOL
COMBO_FlipListbox( LPHEADCOMBO lphc
, BOOL ok
, BOOL bRedrawButton
)
1144 if( lphc
->wState
& CBF_DROPPED
)
1146 CBRollUp( lphc
, ok
, bRedrawButton
);
1154 /***********************************************************************
1157 static void CBRepaintButton( LPHEADCOMBO lphc
)
1159 InvalidateRect(lphc
->self
, &lphc
->buttonRect
, TRUE
);
1160 UpdateWindow(lphc
->self
);
1163 /***********************************************************************
1166 static void COMBO_SetFocus( LPHEADCOMBO lphc
)
1168 if( !(lphc
->wState
& CBF_FOCUSED
) )
1170 if( CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
)
1171 SendMessageW(lphc
->hWndLBox
, LB_CARETON
, 0, 0);
1173 /* This is wrong. Message sequences seem to indicate that this
1174 is set *after* the notify. */
1175 /* lphc->wState |= CBF_FOCUSED; */
1177 if( !(lphc
->wState
& CBF_EDIT
) )
1178 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1180 CB_NOTIFY( lphc
, CBN_SETFOCUS
);
1181 lphc
->wState
|= CBF_FOCUSED
;
1185 /***********************************************************************
1188 static void COMBO_KillFocus( LPHEADCOMBO lphc
)
1190 HWND hWnd
= lphc
->self
;
1192 if( lphc
->wState
& CBF_FOCUSED
)
1194 CBRollUp( lphc
, FALSE
, TRUE
);
1195 if( IsWindow( hWnd
) )
1197 if( CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
)
1198 SendMessageW(lphc
->hWndLBox
, LB_CARETOFF
, 0, 0);
1200 lphc
->wState
&= ~CBF_FOCUSED
;
1203 if( !(lphc
->wState
& CBF_EDIT
) )
1204 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1206 CB_NOTIFY( lphc
, CBN_KILLFOCUS
);
1211 /***********************************************************************
1214 static LRESULT
COMBO_Command( LPHEADCOMBO lphc
, WPARAM wParam
, HWND hWnd
)
1216 if ( lphc
->wState
& CBF_EDIT
&& lphc
->hWndEdit
== hWnd
)
1218 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1220 switch( HIWORD(wParam
) >> 8 )
1222 case (EN_SETFOCUS
>> 8):
1224 TRACE("[%p]: edit [%p] got focus\n", lphc
->self
, lphc
->hWndEdit
);
1226 COMBO_SetFocus( lphc
);
1229 case (EN_KILLFOCUS
>> 8):
1231 TRACE("[%p]: edit [%p] lost focus\n", lphc
->self
, lphc
->hWndEdit
);
1233 /* NOTE: it seems that Windows' edit control sends an
1234 * undocumented message WM_USER + 0x1B instead of this
1235 * notification (only when it happens to be a part of
1236 * the combo). ?? - AK.
1239 COMBO_KillFocus( lphc
);
1243 case (EN_CHANGE
>> 8):
1245 * In some circumstances (when the selection of the combobox
1246 * is changed for example) we don't want the EN_CHANGE notification
1247 * to be forwarded to the parent of the combobox. This code
1248 * checks a flag that is set in these occasions and ignores the
1251 if (lphc
->wState
& CBF_NOLBSELECT
)
1253 lphc
->wState
&= ~CBF_NOLBSELECT
;
1257 CBUpdateLBox( lphc
, lphc
->wState
& CBF_DROPPED
);
1260 if (!(lphc
->wState
& CBF_NOEDITNOTIFY
))
1261 CB_NOTIFY( lphc
, CBN_EDITCHANGE
);
1264 case (EN_UPDATE
>> 8):
1265 if (!(lphc
->wState
& CBF_NOEDITNOTIFY
))
1266 CB_NOTIFY( lphc
, CBN_EDITUPDATE
);
1269 case (EN_ERRSPACE
>> 8):
1270 CB_NOTIFY( lphc
, CBN_ERRSPACE
);
1273 else if( lphc
->hWndLBox
== hWnd
)
1275 switch( (short)HIWORD(wParam
) )
1278 CB_NOTIFY( lphc
, CBN_ERRSPACE
);
1282 CB_NOTIFY( lphc
, CBN_DBLCLK
);
1288 TRACE("[%p]: lbox selection change [%x]\n", lphc
->self
, lphc
->wState
);
1290 /* do not roll up if selection is being tracked
1291 * by arrow keys in the dropdown listbox */
1292 if (!(lphc
->wState
& CBF_NOROLLUP
))
1294 CBRollUp( lphc
, (HIWORD(wParam
) == LBN_SELCHANGE
), TRUE
);
1296 else lphc
->wState
&= ~CBF_NOROLLUP
;
1298 CB_NOTIFY( lphc
, CBN_SELCHANGE
);
1300 if( HIWORD(wParam
) == LBN_SELCHANGE
)
1302 if( lphc
->wState
& CBF_EDIT
)
1303 lphc
->wState
|= CBF_NOLBSELECT
;
1304 CBPaintText( lphc
, NULL
);
1310 /* nothing to do here since ComboLBox always resets the focus to its
1311 * combo/edit counterpart */
1318 /***********************************************************************
1321 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1323 static LRESULT
COMBO_ItemOp( LPHEADCOMBO lphc
, UINT msg
, LPARAM lParam
)
1325 HWND hWnd
= lphc
->self
;
1326 UINT id
= (UINT
)GetWindowLongPtrW( hWnd
, GWLP_ID
);
1328 TRACE("[%p]: ownerdraw op %04x\n", lphc
->self
, msg
);
1334 DELETEITEMSTRUCT
*lpIS
= (DELETEITEMSTRUCT
*)lParam
;
1335 lpIS
->CtlType
= ODT_COMBOBOX
;
1337 lpIS
->hwndItem
= hWnd
;
1342 DRAWITEMSTRUCT
*lpIS
= (DRAWITEMSTRUCT
*)lParam
;
1343 lpIS
->CtlType
= ODT_COMBOBOX
;
1345 lpIS
->hwndItem
= hWnd
;
1348 case WM_COMPAREITEM
:
1350 COMPAREITEMSTRUCT
*lpIS
= (COMPAREITEMSTRUCT
*)lParam
;
1351 lpIS
->CtlType
= ODT_COMBOBOX
;
1353 lpIS
->hwndItem
= hWnd
;
1356 case WM_MEASUREITEM
:
1358 MEASUREITEMSTRUCT
*lpIS
= (MEASUREITEMSTRUCT
*)lParam
;
1359 lpIS
->CtlType
= ODT_COMBOBOX
;
1364 return SendMessageW(lphc
->owner
, msg
, id
, lParam
);
1368 /***********************************************************************
1371 static LRESULT
COMBO_GetTextW( LPHEADCOMBO lphc
, INT count
, LPWSTR buf
)
1375 if( lphc
->wState
& CBF_EDIT
)
1376 return SendMessageW( lphc
->hWndEdit
, WM_GETTEXT
, count
, (LPARAM
)buf
);
1378 /* get it from the listbox */
1380 if (!count
|| !buf
) return 0;
1381 if( lphc
->hWndLBox
)
1383 INT idx
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1384 if (idx
== LB_ERR
) goto error
;
1385 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, idx
, 0 );
1386 if (length
== LB_ERR
) goto error
;
1388 /* 'length' is without the terminating character */
1389 if (length
>= count
)
1391 LPWSTR lpBuffer
= HeapAlloc(GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
));
1392 if (!lpBuffer
) goto error
;
1393 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)lpBuffer
);
1395 /* truncate if buffer is too short */
1396 if (length
!= LB_ERR
)
1398 lstrcpynW( buf
, lpBuffer
, count
);
1401 HeapFree( GetProcessHeap(), 0, lpBuffer
);
1403 else length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)buf
);
1405 if (length
== LB_ERR
) return 0;
1409 error
: /* error - truncate string, return zero */
1415 /***********************************************************************
1418 * NOTE! LB_GETTEXT does not count terminating \0, WM_GETTEXT does.
1419 * also LB_GETTEXT might return values < 0, WM_GETTEXT doesn't.
1421 static LRESULT
COMBO_GetTextA( LPHEADCOMBO lphc
, INT count
, LPSTR buf
)
1425 if( lphc
->wState
& CBF_EDIT
)
1426 return SendMessageA( lphc
->hWndEdit
, WM_GETTEXT
, count
, (LPARAM
)buf
);
1428 /* get it from the listbox */
1430 if (!count
|| !buf
) return 0;
1431 if( lphc
->hWndLBox
)
1433 INT idx
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1434 if (idx
== LB_ERR
) goto error
;
1435 length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, idx
, 0 );
1436 if (length
== LB_ERR
) goto error
;
1438 /* 'length' is without the terminating character */
1439 if (length
>= count
)
1441 LPSTR lpBuffer
= HeapAlloc(GetProcessHeap(), 0, (length
+ 1) );
1442 if (!lpBuffer
) goto error
;
1443 length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)lpBuffer
);
1445 /* truncate if buffer is too short */
1446 if (length
!= LB_ERR
)
1448 lstrcpynA( buf
, lpBuffer
, count
);
1451 HeapFree( GetProcessHeap(), 0, lpBuffer
);
1453 else length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)buf
);
1455 if (length
== LB_ERR
) return 0;
1459 error
: /* error - truncate string, return zero */
1465 /***********************************************************************
1468 * This function sets window positions according to the updated
1469 * component placement struct.
1471 static void CBResetPos(
1473 const RECT
*rectEdit
,
1477 BOOL bDrop
= (CB_GETTYPE(lphc
) != CBS_SIMPLE
);
1479 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1480 * sizing messages */
1482 if( lphc
->wState
& CBF_EDIT
)
1483 SetWindowPos( lphc
->hWndEdit
, 0,
1484 rectEdit
->left
, rectEdit
->top
,
1485 rectEdit
->right
- rectEdit
->left
,
1486 rectEdit
->bottom
- rectEdit
->top
,
1487 SWP_NOZORDER
| SWP_NOACTIVATE
| ((bDrop
) ? SWP_NOREDRAW
: 0) );
1489 SetWindowPos( lphc
->hWndLBox
, 0,
1490 rectLB
->left
, rectLB
->top
,
1491 rectLB
->right
- rectLB
->left
,
1492 rectLB
->bottom
- rectLB
->top
,
1493 SWP_NOACTIVATE
| SWP_NOZORDER
| ((bDrop
) ? SWP_NOREDRAW
: 0) );
1497 if( lphc
->wState
& CBF_DROPPED
)
1499 lphc
->wState
&= ~CBF_DROPPED
;
1500 ShowWindow( lphc
->hWndLBox
, SW_HIDE
);
1503 if( bRedraw
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1504 RedrawWindow( lphc
->self
, NULL
, 0,
1505 RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
);
1510 /***********************************************************************
1513 static void COMBO_Size( LPHEADCOMBO lphc
)
1516 * Those controls are always the same height. So we have to make sure
1517 * they are not resized to another value.
1519 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
1521 int newComboHeight
, curComboHeight
, curComboWidth
;
1524 GetWindowRect(lphc
->self
, &rc
);
1525 curComboHeight
= rc
.bottom
- rc
.top
;
1526 curComboWidth
= rc
.right
- rc
.left
;
1527 newComboHeight
= CBGetTextAreaHeight(lphc
->self
, lphc
) + 2*COMBO_YBORDERSIZE();
1530 * Resizing a combobox has another side effect, it resizes the dropped
1531 * rectangle as well. However, it does it only if the new height for the
1532 * combobox is more than the height it should have. In other words,
1533 * if the application resizing the combobox only had the intention to resize
1534 * the actual control, for example, to do the layout of a dialog that is
1535 * resized, the height of the dropdown is not changed.
1537 if( curComboHeight
> newComboHeight
)
1539 TRACE("oldComboHeight=%d, newComboHeight=%d, oldDropBottom=%d, oldDropTop=%d\n",
1540 curComboHeight
, newComboHeight
, lphc
->droppedRect
.bottom
,
1541 lphc
->droppedRect
.top
);
1542 lphc
->droppedRect
.bottom
= lphc
->droppedRect
.top
+ curComboHeight
- newComboHeight
;
1545 * Restore original height
1547 if( curComboHeight
!= newComboHeight
)
1548 SetWindowPos(lphc
->self
, 0, 0, 0, curComboWidth
, newComboHeight
,
1549 SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
);
1552 CBCalcPlacement(lphc
->self
,
1556 &lphc
->droppedRect
);
1558 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1562 /***********************************************************************
1565 static void COMBO_Font( LPHEADCOMBO lphc
, HFONT hFont
, BOOL bRedraw
)
1570 lphc
->hFont
= hFont
;
1573 * Propagate to owned windows.
1575 if( lphc
->wState
& CBF_EDIT
)
1576 SendMessageW(lphc
->hWndEdit
, WM_SETFONT
, (WPARAM
)hFont
, bRedraw
);
1577 SendMessageW(lphc
->hWndLBox
, WM_SETFONT
, (WPARAM
)hFont
, bRedraw
);
1580 * Redo the layout of the control.
1582 if ( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
1584 CBCalcPlacement(lphc
->self
,
1588 &lphc
->droppedRect
);
1590 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1594 CBForceDummyResize(lphc
);
1599 /***********************************************************************
1600 * COMBO_SetItemHeight
1602 static LRESULT
COMBO_SetItemHeight( LPHEADCOMBO lphc
, INT index
, INT height
)
1604 LRESULT lRet
= CB_ERR
;
1606 if( index
== -1 ) /* set text field height */
1608 if( height
< 32768 )
1610 lphc
->editHeight
= height
+ 2; /* Is the 2 for 2*EDIT_CONTROL_PADDING? */
1613 * Redo the layout of the control.
1615 if ( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
1617 CBCalcPlacement(lphc
->self
,
1621 &lphc
->droppedRect
);
1623 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1627 CBForceDummyResize(lphc
);
1633 else if ( CB_OWNERDRAWN(lphc
) ) /* set listbox item height */
1634 lRet
= SendMessageW(lphc
->hWndLBox
, LB_SETITEMHEIGHT
, index
, height
);
1638 /***********************************************************************
1639 * COMBO_SelectString
1641 static LRESULT
COMBO_SelectString( LPHEADCOMBO lphc
, INT start
, LPARAM pText
, BOOL unicode
)
1643 INT index
= unicode
? SendMessageW(lphc
->hWndLBox
, LB_SELECTSTRING
, start
, pText
) :
1644 SendMessageA(lphc
->hWndLBox
, LB_SELECTSTRING
, start
, pText
);
1647 if( lphc
->wState
& CBF_EDIT
)
1648 CBUpdateEdit( lphc
, index
);
1651 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1654 return (LRESULT
)index
;
1657 /***********************************************************************
1660 static void COMBO_LButtonDown( LPHEADCOMBO lphc
, LPARAM lParam
)
1664 HWND hWnd
= lphc
->self
;
1666 pt
.x
= (short)LOWORD(lParam
);
1667 pt
.y
= (short)HIWORD(lParam
);
1668 bButton
= PtInRect(&lphc
->buttonRect
, pt
);
1670 if( (CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
) ||
1671 (bButton
&& (CB_GETTYPE(lphc
) == CBS_DROPDOWN
)) )
1673 lphc
->wState
|= CBF_BUTTONDOWN
;
1674 if( lphc
->wState
& CBF_DROPPED
)
1676 /* got a click to cancel selection */
1678 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1679 CBRollUp( lphc
, TRUE
, FALSE
);
1680 if( !IsWindow( hWnd
) ) return;
1682 if( lphc
->wState
& CBF_CAPTURE
)
1684 lphc
->wState
&= ~CBF_CAPTURE
;
1690 /* drop down the listbox and start tracking */
1692 lphc
->wState
|= CBF_CAPTURE
;
1696 if( bButton
) CBRepaintButton( lphc
);
1700 /***********************************************************************
1703 * Release capture and stop tracking if needed.
1705 static void COMBO_LButtonUp( LPHEADCOMBO lphc
)
1707 if( lphc
->wState
& CBF_CAPTURE
)
1709 lphc
->wState
&= ~CBF_CAPTURE
;
1710 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1712 INT index
= CBUpdateLBox( lphc
, TRUE
);
1713 /* Update edit only if item is in the list */
1716 lphc
->wState
|= CBF_NOLBSELECT
;
1717 CBUpdateEdit( lphc
, index
);
1718 lphc
->wState
&= ~CBF_NOLBSELECT
;
1722 SetCapture(lphc
->hWndLBox
);
1725 if( lphc
->wState
& CBF_BUTTONDOWN
)
1727 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1728 CBRepaintButton( lphc
);
1732 /***********************************************************************
1735 * Two things to do - track combo button and release capture when
1736 * pointer goes into the listbox.
1738 static void COMBO_MouseMove( LPHEADCOMBO lphc
, WPARAM wParam
, LPARAM lParam
)
1743 pt
.x
= (short)LOWORD(lParam
);
1744 pt
.y
= (short)HIWORD(lParam
);
1746 if( lphc
->wState
& CBF_BUTTONDOWN
)
1750 bButton
= PtInRect(&lphc
->buttonRect
, pt
);
1754 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1755 CBRepaintButton( lphc
);
1759 GetClientRect( lphc
->hWndLBox
, &lbRect
);
1760 MapWindowPoints( lphc
->self
, lphc
->hWndLBox
, &pt
, 1 );
1761 if( PtInRect(&lbRect
, pt
) )
1763 lphc
->wState
&= ~CBF_CAPTURE
;
1765 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
) CBUpdateLBox( lphc
, TRUE
);
1767 /* hand over pointer tracking */
1768 SendMessageW(lphc
->hWndLBox
, WM_LBUTTONDOWN
, wParam
, lParam
);
1772 static LRESULT
COMBO_GetComboBoxInfo(const HEADCOMBO
*lphc
, COMBOBOXINFO
*pcbi
)
1774 if (!pcbi
|| (pcbi
->cbSize
< sizeof(COMBOBOXINFO
)))
1777 pcbi
->rcItem
= lphc
->textRect
;
1778 pcbi
->rcButton
= lphc
->buttonRect
;
1779 pcbi
->stateButton
= 0;
1780 if (lphc
->wState
& CBF_BUTTONDOWN
)
1781 pcbi
->stateButton
|= STATE_SYSTEM_PRESSED
;
1782 if (IsRectEmpty(&lphc
->buttonRect
))
1783 pcbi
->stateButton
|= STATE_SYSTEM_INVISIBLE
;
1784 pcbi
->hwndCombo
= lphc
->self
;
1785 pcbi
->hwndItem
= lphc
->hWndEdit
;
1786 pcbi
->hwndList
= lphc
->hWndLBox
;
1790 static char *strdupA(LPCSTR str
)
1795 if(!str
) return NULL
;
1798 ret
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
1799 memcpy(ret
, str
, len
+ 1);
1803 /***********************************************************************
1804 * ComboWndProc_common
1806 LRESULT
ComboWndProc_common( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
1808 LPHEADCOMBO lphc
= (LPHEADCOMBO
)GetWindowLongPtrW( hwnd
, 0 );
1810 TRACE("[%p]: msg %s wp %08lx lp %08lx\n",
1811 hwnd
, SPY_GetMsgName(message
, hwnd
), wParam
, lParam
);
1813 if (!IsWindow(hwnd
)) return 0;
1815 if( lphc
|| message
== WM_NCCREATE
)
1819 /* System messages */
1823 LONG style
= unicode
? ((LPCREATESTRUCTW
)lParam
)->style
:
1824 ((LPCREATESTRUCTA
)lParam
)->style
;
1825 return COMBO_NCCreate(hwnd
, style
);
1828 COMBO_NCDestroy(lphc
);
1829 break;/* -> DefWindowProc */
1837 hwndParent
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
1838 style
= ((LPCREATESTRUCTW
)lParam
)->style
;
1842 hwndParent
= ((LPCREATESTRUCTA
)lParam
)->hwndParent
;
1843 style
= ((LPCREATESTRUCTA
)lParam
)->style
;
1845 return COMBO_Create(hwnd
, lphc
, hwndParent
, style
, unicode
);
1848 case WM_PRINTCLIENT
:
1851 /* wParam may contain a valid HDC! */
1852 return COMBO_Paint(lphc
, (HDC
)wParam
);
1855 /* do all painting in WM_PAINT like Windows does */
1860 LRESULT result
= DLGC_WANTARROWS
| DLGC_WANTCHARS
;
1861 if (lParam
&& (((LPMSG
)lParam
)->message
== WM_KEYDOWN
))
1863 int vk
= (int)((LPMSG
)lParam
)->wParam
;
1865 if ((vk
== VK_RETURN
|| vk
== VK_ESCAPE
) && (lphc
->wState
& CBF_DROPPED
))
1866 result
|= DLGC_WANTMESSAGE
;
1871 if( lphc
->hWndLBox
&&
1872 !(lphc
->wState
& CBF_NORESIZE
) ) COMBO_Size( lphc
);
1875 COMBO_Font( lphc
, (HFONT
)wParam
, (BOOL
)lParam
);
1878 return (LRESULT
)lphc
->hFont
;
1880 if( lphc
->wState
& CBF_EDIT
) {
1881 SetFocus( lphc
->hWndEdit
);
1882 /* The first time focus is received, select all the text */
1883 if( !(lphc
->wState
& CBF_BEENFOCUSED
) ) {
1884 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, -1);
1885 lphc
->wState
|= CBF_BEENFOCUSED
;
1889 COMBO_SetFocus( lphc
);
1893 HWND hwndFocus
= WIN_GetFullHandle( (HWND
)wParam
);
1895 (hwndFocus
!= lphc
->hWndEdit
&& hwndFocus
!= lphc
->hWndLBox
))
1896 COMBO_KillFocus( lphc
);
1900 return COMBO_Command( lphc
, wParam
, WIN_GetFullHandle( (HWND
)lParam
) );
1902 return unicode
? COMBO_GetTextW( lphc
, wParam
, (LPWSTR
)lParam
)
1903 : COMBO_GetTextA( lphc
, wParam
, (LPSTR
)lParam
);
1905 case WM_GETTEXTLENGTH
:
1907 if ((message
== WM_GETTEXTLENGTH
) && !ISWIN31
&& !(lphc
->wState
& CBF_EDIT
))
1909 int j
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1910 if (j
== -1) return 0;
1911 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, j
, 0) :
1912 SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, j
, 0);
1914 else if( lphc
->wState
& CBF_EDIT
)
1917 lphc
->wState
|= CBF_NOEDITNOTIFY
;
1918 ret
= unicode
? SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
) :
1919 SendMessageA(lphc
->hWndEdit
, message
, wParam
, lParam
);
1920 lphc
->wState
&= ~CBF_NOEDITNOTIFY
;
1927 if( lphc
->wState
& CBF_EDIT
)
1929 return unicode
? SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
) :
1930 SendMessageA(lphc
->hWndEdit
, message
, wParam
, lParam
);
1936 case WM_COMPAREITEM
:
1937 case WM_MEASUREITEM
:
1938 return COMBO_ItemOp(lphc
, message
, lParam
);
1940 if( lphc
->wState
& CBF_EDIT
)
1941 EnableWindow( lphc
->hWndEdit
, (BOOL
)wParam
);
1942 EnableWindow( lphc
->hWndLBox
, (BOOL
)wParam
);
1944 /* Force the control to repaint when the enabled state changes. */
1945 InvalidateRect(lphc
->self
, NULL
, TRUE
);
1949 lphc
->wState
&= ~CBF_NOREDRAW
;
1951 lphc
->wState
|= CBF_NOREDRAW
;
1953 if( lphc
->wState
& CBF_EDIT
)
1954 SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
);
1955 SendMessageW(lphc
->hWndLBox
, message
, wParam
, lParam
);
1958 if( KEYDATA_ALT
& HIWORD(lParam
) )
1959 if( wParam
== VK_UP
|| wParam
== VK_DOWN
)
1960 COMBO_FlipListbox( lphc
, FALSE
, FALSE
);
1964 if ((wParam
== VK_RETURN
|| wParam
== VK_ESCAPE
) &&
1965 (lphc
->wState
& CBF_DROPPED
))
1967 CBRollUp( lphc
, wParam
== VK_RETURN
, FALSE
);
1970 else if ((wParam
== VK_F4
) && !(lphc
->wState
& CBF_EUI
))
1972 COMBO_FlipListbox( lphc
, FALSE
, FALSE
);
1981 if( lphc
->wState
& CBF_EDIT
)
1982 hwndTarget
= lphc
->hWndEdit
;
1984 hwndTarget
= lphc
->hWndLBox
;
1986 return unicode
? SendMessageW(hwndTarget
, message
, wParam
, lParam
) :
1987 SendMessageA(hwndTarget
, message
, wParam
, lParam
);
1989 case WM_LBUTTONDOWN
:
1990 if( !(lphc
->wState
& CBF_FOCUSED
) ) SetFocus( lphc
->self
);
1991 if( lphc
->wState
& CBF_FOCUSED
) COMBO_LButtonDown( lphc
, lParam
);
1994 COMBO_LButtonUp( lphc
);
1997 if( lphc
->wState
& CBF_CAPTURE
)
1998 COMBO_MouseMove( lphc
, wParam
, lParam
);
2002 if (wParam
& (MK_SHIFT
| MK_CONTROL
))
2003 return unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
) :
2004 DefWindowProcA(hwnd
, message
, wParam
, lParam
);
2006 if (GET_WHEEL_DELTA_WPARAM(wParam
) > 0) return SendMessageW(hwnd
, WM_KEYDOWN
, VK_UP
, 0);
2007 if (GET_WHEEL_DELTA_WPARAM(wParam
) < 0) return SendMessageW(hwnd
, WM_KEYDOWN
, VK_DOWN
, 0);
2010 /* Combo messages */
2015 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2016 CharLowerW((LPWSTR
)lParam
);
2017 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2018 CharUpperW((LPWSTR
)lParam
);
2019 return SendMessageW(lphc
->hWndLBox
, LB_ADDSTRING
, 0, lParam
);
2021 else /* unlike the unicode version, the ansi version does not overwrite
2022 the string if converting case */
2024 char *string
= NULL
;
2026 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2028 string
= strdupA((LPSTR
)lParam
);
2032 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2034 string
= strdupA((LPSTR
)lParam
);
2038 ret
= SendMessageA(lphc
->hWndLBox
, LB_ADDSTRING
, 0, string
? (LPARAM
)string
: lParam
);
2039 HeapFree(GetProcessHeap(), 0, string
);
2042 case CB_INSERTSTRING
:
2045 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2046 CharLowerW((LPWSTR
)lParam
);
2047 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2048 CharUpperW((LPWSTR
)lParam
);
2049 return SendMessageW(lphc
->hWndLBox
, LB_INSERTSTRING
, wParam
, lParam
);
2053 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2054 CharLowerA((LPSTR
)lParam
);
2055 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2056 CharUpperA((LPSTR
)lParam
);
2058 return SendMessageA(lphc
->hWndLBox
, LB_INSERTSTRING
, wParam
, lParam
);
2060 case CB_DELETESTRING
:
2061 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_DELETESTRING
, wParam
, 0) :
2062 SendMessageA(lphc
->hWndLBox
, LB_DELETESTRING
, wParam
, 0);
2063 case CB_SELECTSTRING
:
2064 return COMBO_SelectString(lphc
, (INT
)wParam
, lParam
, unicode
);
2066 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_FINDSTRING
, wParam
, lParam
) :
2067 SendMessageA(lphc
->hWndLBox
, LB_FINDSTRING
, wParam
, lParam
);
2068 case CB_FINDSTRINGEXACT
:
2069 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_FINDSTRINGEXACT
, wParam
, lParam
) :
2070 SendMessageA(lphc
->hWndLBox
, LB_FINDSTRINGEXACT
, wParam
, lParam
);
2071 case CB_SETITEMHEIGHT
:
2072 return COMBO_SetItemHeight( lphc
, (INT
)wParam
, (INT
)lParam
);
2073 case CB_GETITEMHEIGHT
:
2074 if( (INT
)wParam
>= 0 ) /* listbox item */
2075 return SendMessageW(lphc
->hWndLBox
, LB_GETITEMHEIGHT
, wParam
, 0);
2076 return CBGetTextAreaHeight(hwnd
, lphc
);
2077 case CB_RESETCONTENT
:
2078 SendMessageW(lphc
->hWndLBox
, LB_RESETCONTENT
, 0, 0);
2079 if( (lphc
->wState
& CBF_EDIT
) && CB_HASSTRINGS(lphc
) )
2081 static const WCHAR empty_stringW
[] = { 0 };
2082 SendMessageW(lphc
->hWndEdit
, WM_SETTEXT
, 0, (LPARAM
)empty_stringW
);
2085 InvalidateRect(lphc
->self
, NULL
, TRUE
);
2087 case CB_INITSTORAGE
:
2088 return SendMessageW(lphc
->hWndLBox
, LB_INITSTORAGE
, wParam
, lParam
);
2089 case CB_GETHORIZONTALEXTENT
:
2090 return SendMessageW(lphc
->hWndLBox
, LB_GETHORIZONTALEXTENT
, 0, 0);
2091 case CB_SETHORIZONTALEXTENT
:
2092 return SendMessageW(lphc
->hWndLBox
, LB_SETHORIZONTALEXTENT
, wParam
, 0);
2093 case CB_GETTOPINDEX
:
2094 return SendMessageW(lphc
->hWndLBox
, LB_GETTOPINDEX
, 0, 0);
2096 return SendMessageW(lphc
->hWndLBox
, LB_GETLOCALE
, 0, 0);
2098 return SendMessageW(lphc
->hWndLBox
, LB_SETLOCALE
, wParam
, 0);
2099 case CB_SETDROPPEDWIDTH
:
2100 if( (CB_GETTYPE(lphc
) == CBS_SIMPLE
) ||
2101 (INT
)wParam
>= 32768 )
2103 /* new value must be higher than combobox width */
2104 if((INT
)wParam
>= lphc
->droppedRect
.right
- lphc
->droppedRect
.left
)
2105 lphc
->droppedWidth
= wParam
;
2107 lphc
->droppedWidth
= 0;
2109 /* recalculate the combobox area */
2110 CBCalcPlacement(hwnd
, lphc
, &lphc
->textRect
, &lphc
->buttonRect
, &lphc
->droppedRect
);
2113 case CB_GETDROPPEDWIDTH
:
2114 if( lphc
->droppedWidth
)
2115 return lphc
->droppedWidth
;
2116 return lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
2117 case CB_GETDROPPEDCONTROLRECT
:
2118 if( lParam
) CBGetDroppedControlRect(lphc
, (LPRECT
)lParam
);
2120 case CB_GETDROPPEDSTATE
:
2121 return (lphc
->wState
& CBF_DROPPED
) != 0;
2123 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_DIR
, wParam
, lParam
) :
2124 SendMessageA(lphc
->hWndLBox
, LB_DIR
, wParam
, lParam
);
2126 case CB_SHOWDROPDOWN
:
2127 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
2131 if( !(lphc
->wState
& CBF_DROPPED
) )
2135 if( lphc
->wState
& CBF_DROPPED
)
2136 CBRollUp( lphc
, FALSE
, TRUE
);
2140 return SendMessageW(lphc
->hWndLBox
, LB_GETCOUNT
, 0, 0);
2142 return SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
2144 lParam
= SendMessageW(lphc
->hWndLBox
, LB_SETCURSEL
, wParam
, 0);
2146 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
, wParam
, 0);
2148 /* no LBN_SELCHANGE in this case, update manually */
2149 CBPaintText( lphc
, NULL
);
2150 lphc
->wState
&= ~CBF_SELCHANGE
;
2153 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, wParam
, lParam
) :
2154 SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, wParam
, lParam
);
2155 case CB_GETLBTEXTLEN
:
2156 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, wParam
, 0) :
2157 SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, wParam
, 0);
2158 case CB_GETITEMDATA
:
2159 return SendMessageW(lphc
->hWndLBox
, LB_GETITEMDATA
, wParam
, 0);
2160 case CB_SETITEMDATA
:
2161 return SendMessageW(lphc
->hWndLBox
, LB_SETITEMDATA
, wParam
, lParam
);
2163 /* Edit checks passed parameters itself */
2164 if( lphc
->wState
& CBF_EDIT
)
2165 return SendMessageW(lphc
->hWndEdit
, EM_GETSEL
, wParam
, lParam
);
2168 if( lphc
->wState
& CBF_EDIT
)
2169 return SendMessageW(lphc
->hWndEdit
, EM_SETSEL
,
2170 (INT
)(SHORT
)LOWORD(lParam
), (INT
)(SHORT
)HIWORD(lParam
) );
2172 case CB_SETEXTENDEDUI
:
2173 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
2176 lphc
->wState
|= CBF_EUI
;
2177 else lphc
->wState
&= ~CBF_EUI
;
2179 case CB_GETEXTENDEDUI
:
2180 return (lphc
->wState
& CBF_EUI
) != 0;
2181 case CB_GETCOMBOBOXINFO
:
2182 return COMBO_GetComboBoxInfo(lphc
, (COMBOBOXINFO
*)lParam
);
2184 if( lphc
->wState
& CBF_EDIT
)
2185 return SendMessageW(lphc
->hWndEdit
, EM_LIMITTEXT
, wParam
, lParam
);
2188 if (message
>= WM_USER
)
2189 WARN("unknown msg WM_USER+%04x wp=%04lx lp=%08lx\n",
2190 message
- WM_USER
, wParam
, lParam
);
2193 return unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
) :
2194 DefWindowProcA(hwnd
, message
, wParam
, lParam
);
2197 /*************************************************************************
2198 * GetComboBoxInfo (USER32.@)
2200 BOOL WINAPI
GetComboBoxInfo(HWND hwndCombo
, /* [in] handle to combo box */
2201 PCOMBOBOXINFO pcbi
/* [in/out] combo box information */)
2203 TRACE("(%p, %p)\n", hwndCombo
, pcbi
);
2204 return SendMessageW(hwndCombo
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
);