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
33 #include "wine/unicode.h"
34 #include "user_private.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(combo
);
42 /* bits in the dwKeyData */
43 #define KEYDATA_ALT 0x2000
44 #define KEYDATA_PREVSTATE 0x4000
47 * Additional combo box definitions
50 #define CB_NOTIFY( lphc, code ) \
51 (SendMessageW((lphc)->owner, WM_COMMAND, \
52 MAKEWPARAM(GetWindowLongPtrW((lphc)->self,GWLP_ID), (code)), (LPARAM)(lphc)->self))
54 #define CB_DISABLED( lphc ) (!IsWindowEnabled((lphc)->self))
55 #define CB_OWNERDRAWN( lphc ) ((lphc)->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE))
56 #define CB_HASSTRINGS( lphc ) ((lphc)->dwStyle & CBS_HASSTRINGS)
57 #define CB_HWND( lphc ) ((lphc)->self)
58 #define CB_GETTYPE( lphc ) ((lphc)->dwStyle & (CBS_DROPDOWNLIST))
60 #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03)
65 static HBITMAP hComboBmp
= 0;
66 static UINT CBitHeight
, CBitWidth
;
69 * Look and feel dependent "constants"
72 #define COMBO_YBORDERGAP 5
73 #define COMBO_XBORDERSIZE() 2
74 #define COMBO_YBORDERSIZE() 2
75 #define COMBO_EDITBUTTONSPACE() 0
76 #define EDIT_CONTROL_PADDING() 1
78 /*********************************************************************
79 * combo class descriptor
81 static const WCHAR comboboxW
[] = {'C','o','m','b','o','B','o','x',0};
82 const struct builtin_class_descr COMBO_builtin_class
=
85 CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
, /* style */
86 WINPROC_COMBO
, /* proc */
87 sizeof(HEADCOMBO
*), /* extra */
88 IDC_ARROW
, /* cursor */
93 /***********************************************************************
96 * Load combo button bitmap.
98 static BOOL
COMBO_Init(void)
102 if( hComboBmp
) return TRUE
;
103 if( (hDC
= CreateCompatibleDC(0)) )
106 if( (hComboBmp
= LoadBitmapW(0, MAKEINTRESOURCEW(OBM_COMBO
))) )
112 GetObjectW( hComboBmp
, sizeof(bm
), &bm
);
113 CBitHeight
= bm
.bmHeight
;
114 CBitWidth
= bm
.bmWidth
;
116 TRACE("combo bitmap [%i,%i]\n", CBitWidth
, CBitHeight
);
118 hPrevB
= SelectObject( hDC
, hComboBmp
);
119 SetRect( &r
, 0, 0, CBitWidth
, CBitHeight
);
120 InvertRect( hDC
, &r
);
121 SelectObject( hDC
, hPrevB
);
130 /***********************************************************************
133 static LRESULT
COMBO_NCCreate(HWND hwnd
, LONG style
)
137 if (COMBO_Init() && (lphc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(HEADCOMBO
))) )
140 SetWindowLongPtrW( hwnd
, 0, (LONG_PTR
)lphc
);
142 /* some braindead apps do try to use scrollbar/border flags */
144 lphc
->dwStyle
= style
& ~(WS_BORDER
| WS_HSCROLL
| WS_VSCROLL
);
145 SetWindowLongW( hwnd
, GWL_STYLE
, style
& ~(WS_BORDER
| WS_HSCROLL
| WS_VSCROLL
) );
148 * We also have to remove the client edge style to make sure
149 * we don't end-up with a non client area.
151 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
152 GetWindowLongW( hwnd
, GWL_EXSTYLE
) & ~WS_EX_CLIENTEDGE
);
154 if( !(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) )
155 lphc
->dwStyle
|= CBS_HASSTRINGS
;
156 if( !(GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_NOPARENTNOTIFY
) )
157 lphc
->wState
|= CBF_NOTIFY
;
159 TRACE("[%p], style = %08x\n", lphc
, lphc
->dwStyle
);
165 /***********************************************************************
168 static LRESULT
COMBO_NCDestroy( LPHEADCOMBO lphc
)
173 TRACE("[%p]: freeing storage\n", lphc
->self
);
175 if( (CB_GETTYPE(lphc
) != CBS_SIMPLE
) && lphc
->hWndLBox
)
176 DestroyWindow( lphc
->hWndLBox
);
178 SetWindowLongPtrW( lphc
->self
, 0, 0 );
179 HeapFree( GetProcessHeap(), 0, lphc
);
184 /***********************************************************************
185 * CBGetTextAreaHeight
187 * This method will calculate the height of the text area of the
189 * The height of the text area is set in two ways.
190 * It can be set explicitly through a combobox message or through a
191 * WM_MEASUREITEM callback.
192 * If this is not the case, the height is set to font height + 4px
193 * This height was determined through experimentation.
194 * CBCalcPlacement will add 2*COMBO_YBORDERSIZE pixels for the border
196 static INT
CBGetTextAreaHeight(
202 if( lphc
->editHeight
) /* explicitly set height */
204 iTextItemHeight
= lphc
->editHeight
;
209 HDC hDC
= GetDC(hwnd
);
214 hPrevFont
= SelectObject( hDC
, lphc
->hFont
);
216 GetTextMetricsW(hDC
, &tm
);
218 baseUnitY
= tm
.tmHeight
;
221 SelectObject( hDC
, hPrevFont
);
223 ReleaseDC(hwnd
, hDC
);
225 iTextItemHeight
= baseUnitY
+ 4;
229 * Check the ownerdraw case if we haven't asked the parent the size
232 if ( CB_OWNERDRAWN(lphc
) &&
233 (lphc
->wState
& CBF_MEASUREITEM
) )
235 MEASUREITEMSTRUCT measureItem
;
237 INT originalItemHeight
= iTextItemHeight
;
238 UINT id
= (UINT
)GetWindowLongPtrW( lphc
->self
, GWLP_ID
);
241 * We use the client rect for the width of the item.
243 GetClientRect(hwnd
, &clientRect
);
245 lphc
->wState
&= ~CBF_MEASUREITEM
;
248 * Send a first one to measure the size of the text area
250 measureItem
.CtlType
= ODT_COMBOBOX
;
251 measureItem
.CtlID
= id
;
252 measureItem
.itemID
= -1;
253 measureItem
.itemWidth
= clientRect
.right
;
254 measureItem
.itemHeight
= iTextItemHeight
- 6; /* ownerdrawn cb is taller */
255 measureItem
.itemData
= 0;
256 SendMessageW(lphc
->owner
, WM_MEASUREITEM
, id
, (LPARAM
)&measureItem
);
257 iTextItemHeight
= 6 + measureItem
.itemHeight
;
260 * Send a second one in the case of a fixed ownerdraw list to calculate the
261 * size of the list items. (we basically do this on behalf of the listbox)
263 if (lphc
->dwStyle
& CBS_OWNERDRAWFIXED
)
265 measureItem
.CtlType
= ODT_COMBOBOX
;
266 measureItem
.CtlID
= id
;
267 measureItem
.itemID
= 0;
268 measureItem
.itemWidth
= clientRect
.right
;
269 measureItem
.itemHeight
= originalItemHeight
;
270 measureItem
.itemData
= 0;
271 SendMessageW(lphc
->owner
, WM_MEASUREITEM
, id
, (LPARAM
)&measureItem
);
272 lphc
->fixedOwnerDrawHeight
= measureItem
.itemHeight
;
276 * Keep the size for the next time
278 lphc
->editHeight
= iTextItemHeight
;
281 return iTextItemHeight
;
284 /***********************************************************************
287 * The dummy resize is used for listboxes that have a popup to trigger
288 * a re-arranging of the contents of the combobox and the recalculation
289 * of the size of the "real" control window.
291 static void CBForceDummyResize(
297 newComboHeight
= CBGetTextAreaHeight(lphc
->self
,lphc
) + 2*COMBO_YBORDERSIZE();
299 GetWindowRect(lphc
->self
, &windowRect
);
302 * We have to be careful, resizing a combobox also has the meaning that the
303 * dropped rect will be resized. In this case, we want to trigger a resize
304 * to recalculate layout but we don't want to change the dropped rectangle
305 * So, we pass the height of text area of control as the height.
306 * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
309 SetWindowPos( lphc
->self
,
312 windowRect
.right
- windowRect
.left
,
314 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
317 /***********************************************************************
320 * Set up component coordinates given valid lphc->RectCombo.
322 static void CBCalcPlacement(
330 * Again, start with the client rectangle.
332 GetClientRect(hwnd
, lprEdit
);
337 InflateRect(lprEdit
, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
340 * Chop off the bottom part to fit with the height of the text area.
342 lprEdit
->bottom
= lprEdit
->top
+ CBGetTextAreaHeight(hwnd
, lphc
);
345 * The button starts the same vertical position as the text area.
347 CopyRect(lprButton
, lprEdit
);
350 * If the combobox is "simple" there is no button.
352 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
353 lprButton
->left
= lprButton
->right
= lprButton
->bottom
= 0;
357 * Let's assume the combobox button is the same width as the
359 * size the button horizontally and cut-off the text area.
361 lprButton
->left
= lprButton
->right
- GetSystemMetrics(SM_CXVSCROLL
);
362 lprEdit
->right
= lprButton
->left
;
366 * In the case of a dropdown, there is an additional spacing between the
367 * text area and the button.
369 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
371 lprEdit
->right
-= COMBO_EDITBUTTONSPACE();
375 * If we have an edit control, we space it away from the borders slightly.
377 if (CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
)
379 InflateRect(lprEdit
, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING());
383 * Adjust the size of the listbox popup.
385 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
388 * Use the client rectangle to initialize the listbox rectangle
390 GetClientRect(hwnd
, lprLB
);
393 * Then, chop-off the top part.
395 lprLB
->top
= lprEdit
->bottom
+ COMBO_YBORDERSIZE();
400 * Make sure the dropped width is as large as the combobox itself.
402 if (lphc
->droppedWidth
< (lprButton
->right
+ COMBO_XBORDERSIZE()))
404 lprLB
->right
= lprLB
->left
+ (lprButton
->right
+ COMBO_XBORDERSIZE());
407 * In the case of a dropdown, the popup listbox is offset to the right.
408 * so, we want to make sure it's flush with the right side of the
411 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
412 lprLB
->right
-= COMBO_EDITBUTTONSPACE();
415 lprLB
->right
= lprLB
->left
+ lphc
->droppedWidth
;
418 /* don't allow negative window width */
419 if (lprEdit
->right
< lprEdit
->left
)
420 lprEdit
->right
= lprEdit
->left
;
422 TRACE("\ttext\t= (%s)\n", wine_dbgstr_rect(lprEdit
));
424 TRACE("\tbutton\t= (%s)\n", wine_dbgstr_rect(lprButton
));
426 TRACE("\tlbox\t= (%s)\n", wine_dbgstr_rect(lprLB
));
429 /***********************************************************************
430 * CBGetDroppedControlRect
432 static void CBGetDroppedControlRect( LPHEADCOMBO lphc
, LPRECT lpRect
)
434 /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner
435 of the combo box and the lower right corner of the listbox */
437 GetWindowRect(lphc
->self
, lpRect
);
439 lpRect
->right
= lpRect
->left
+ lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
440 lpRect
->bottom
= lpRect
->top
+ lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
;
444 /***********************************************************************
447 static LRESULT
COMBO_Create( HWND hwnd
, LPHEADCOMBO lphc
, HWND hwndParent
, LONG style
,
450 static const WCHAR clbName
[] = {'C','o','m','b','o','L','B','o','x',0};
451 static const WCHAR editName
[] = {'E','d','i','t',0};
453 if( !CB_GETTYPE(lphc
) ) lphc
->dwStyle
|= CBS_SIMPLE
;
454 if( CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
) lphc
->wState
|= CBF_EDIT
;
456 lphc
->owner
= hwndParent
;
459 * The item height and dropped width are not set when the control
462 lphc
->droppedWidth
= lphc
->editHeight
= 0;
465 * The first time we go through, we want to measure the ownerdraw item
467 lphc
->wState
|= CBF_MEASUREITEM
;
469 /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
471 if( lphc
->owner
|| !(style
& WS_VISIBLE
) )
477 * Initialize the dropped rect to the size of the client area of the
478 * control and then, force all the areas of the combobox to be
481 GetClientRect( hwnd
, &lphc
->droppedRect
);
482 CBCalcPlacement(hwnd
, lphc
, &lphc
->textRect
, &lphc
->buttonRect
, &lphc
->droppedRect
);
485 * Adjust the position of the popup listbox if it's necessary
487 if ( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
489 lphc
->droppedRect
.top
= lphc
->textRect
.bottom
+ COMBO_YBORDERSIZE();
492 * If it's a dropdown, the listbox is offset
494 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
495 lphc
->droppedRect
.left
+= COMBO_EDITBUTTONSPACE();
497 if (lphc
->droppedRect
.bottom
< lphc
->droppedRect
.top
)
498 lphc
->droppedRect
.bottom
= lphc
->droppedRect
.top
;
499 if (lphc
->droppedRect
.right
< lphc
->droppedRect
.left
)
500 lphc
->droppedRect
.right
= lphc
->droppedRect
.left
;
501 MapWindowPoints( hwnd
, 0, (LPPOINT
)&lphc
->droppedRect
, 2 );
504 /* create listbox popup */
506 lbeStyle
= (LBS_NOTIFY
| LBS_COMBOBOX
| WS_BORDER
| WS_CLIPSIBLINGS
| WS_CHILD
) |
507 (style
& (WS_VSCROLL
| CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
));
509 if( lphc
->dwStyle
& CBS_SORT
)
510 lbeStyle
|= LBS_SORT
;
511 if( lphc
->dwStyle
& CBS_HASSTRINGS
)
512 lbeStyle
|= LBS_HASSTRINGS
;
513 if( lphc
->dwStyle
& CBS_NOINTEGRALHEIGHT
)
514 lbeStyle
|= LBS_NOINTEGRALHEIGHT
;
515 if( lphc
->dwStyle
& CBS_DISABLENOSCROLL
)
516 lbeStyle
|= LBS_DISABLENOSCROLL
;
518 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
) /* child listbox */
520 lbeStyle
|= WS_VISIBLE
;
523 * In win 95 look n feel, the listbox in the simple combobox has
524 * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
526 lbeStyle
&= ~WS_BORDER
;
527 lbeExStyle
|= WS_EX_CLIENTEDGE
;
531 lbeExStyle
|= (WS_EX_TOPMOST
| WS_EX_TOOLWINDOW
);
535 lphc
->hWndLBox
= CreateWindowExW(lbeExStyle
, clbName
, NULL
, lbeStyle
,
536 lphc
->droppedRect
.left
,
537 lphc
->droppedRect
.top
,
538 lphc
->droppedRect
.right
- lphc
->droppedRect
.left
,
539 lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
,
540 hwnd
, (HMENU
)ID_CB_LISTBOX
,
541 (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
), lphc
);
543 lphc
->hWndLBox
= CreateWindowExA(lbeExStyle
, "ComboLBox", NULL
, lbeStyle
,
544 lphc
->droppedRect
.left
,
545 lphc
->droppedRect
.top
,
546 lphc
->droppedRect
.right
- lphc
->droppedRect
.left
,
547 lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
,
548 hwnd
, (HMENU
)ID_CB_LISTBOX
,
549 (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
), lphc
);
554 lbeStyle
= WS_CHILD
| WS_VISIBLE
| ES_NOHIDESEL
| ES_LEFT
| ES_COMBO
;
556 if( lphc
->wState
& CBF_EDIT
)
558 if( lphc
->dwStyle
& CBS_OEMCONVERT
)
559 lbeStyle
|= ES_OEMCONVERT
;
560 if( lphc
->dwStyle
& CBS_AUTOHSCROLL
)
561 lbeStyle
|= ES_AUTOHSCROLL
;
562 if( lphc
->dwStyle
& CBS_LOWERCASE
)
563 lbeStyle
|= ES_LOWERCASE
;
564 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
565 lbeStyle
|= ES_UPPERCASE
;
567 if (!IsWindowEnabled(hwnd
)) lbeStyle
|= WS_DISABLED
;
570 lphc
->hWndEdit
= CreateWindowExW(0, editName
, NULL
, lbeStyle
,
571 lphc
->textRect
.left
, lphc
->textRect
.top
,
572 lphc
->textRect
.right
- lphc
->textRect
.left
,
573 lphc
->textRect
.bottom
- lphc
->textRect
.top
,
574 hwnd
, (HMENU
)ID_CB_EDIT
,
575 (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
), NULL
);
577 lphc
->hWndEdit
= CreateWindowExA(0, "Edit", NULL
, lbeStyle
,
578 lphc
->textRect
.left
, lphc
->textRect
.top
,
579 lphc
->textRect
.right
- lphc
->textRect
.left
,
580 lphc
->textRect
.bottom
- lphc
->textRect
.top
,
581 hwnd
, (HMENU
)ID_CB_EDIT
,
582 (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
), NULL
);
584 if( !lphc
->hWndEdit
)
590 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
592 /* Now do the trick with parent */
593 SetParent(lphc
->hWndLBox
, HWND_DESKTOP
);
595 * If the combo is a dropdown, we must resize the control
596 * to fit only the text area and button. To do this,
597 * we send a dummy resize and the WM_WINDOWPOSCHANGING message
598 * will take care of setting the height for us.
600 CBForceDummyResize(lphc
);
603 TRACE("init done\n");
606 ERR("edit control failure.\n");
607 } else ERR("listbox failure.\n");
608 } else ERR("no owner for visible combo.\n");
610 /* CreateWindow() will send WM_NCDESTROY to cleanup */
615 /***********************************************************************
618 * Paint combo button (normal, pressed, and disabled states).
620 static void CBPaintButton( LPHEADCOMBO lphc
, HDC hdc
, RECT rectButton
)
622 UINT buttonState
= DFCS_SCROLLCOMBOBOX
;
624 if( lphc
->wState
& CBF_NOREDRAW
)
628 if (lphc
->wState
& CBF_BUTTONDOWN
)
629 buttonState
|= DFCS_PUSHED
;
631 if (CB_DISABLED(lphc
))
632 buttonState
|= DFCS_INACTIVE
;
634 DrawFrameControl(hdc
, &rectButton
, DFC_SCROLL
, buttonState
);
637 /***********************************************************************
638 * COMBO_PrepareColors
640 * This method will sent the appropriate WM_CTLCOLOR message to
641 * prepare and setup the colors for the combo's DC.
643 * It also returns the brush to use for the background.
645 static HBRUSH
COMBO_PrepareColors(
652 * Get the background brush for this control.
654 if (CB_DISABLED(lphc
))
656 hBkgBrush
= (HBRUSH
)SendMessageW(lphc
->owner
, WM_CTLCOLORSTATIC
,
657 (WPARAM
)hDC
, (LPARAM
)lphc
->self
);
660 * We have to change the text color since WM_CTLCOLORSTATIC will
661 * set it to the "enabled" color. This is the same behavior as the
664 SetTextColor(hDC
, GetSysColor(COLOR_GRAYTEXT
));
668 /* FIXME: In which cases WM_CTLCOLORLISTBOX should be sent? */
669 hBkgBrush
= (HBRUSH
)SendMessageW(lphc
->owner
, WM_CTLCOLOREDIT
,
670 (WPARAM
)hDC
, (LPARAM
)lphc
->self
);
677 hBkgBrush
= GetSysColorBrush(COLOR_WINDOW
);
682 /***********************************************************************
685 * Paint CBS_DROPDOWNLIST text field / update edit control contents.
687 static void CBPaintText(
691 RECT rectEdit
= lphc
->textRect
;
697 /* follow Windows combobox that sends a bunch of text
698 * inquiries to its listbox while processing WM_PAINT. */
700 if( (id
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0) ) != LB_ERR
)
702 size
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, id
, 0);
704 FIXME("LB_ERR probably not handled yet\n");
705 if( (pText
= HeapAlloc( GetProcessHeap(), 0, (size
+ 1) * sizeof(WCHAR
))) )
707 /* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */
708 size
=SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, id
, (LPARAM
)pText
);
709 pText
[size
] = '\0'; /* just in case */
713 if( lphc
->wState
& CBF_EDIT
)
715 static const WCHAR empty_stringW
[] = { 0 };
716 if( CB_HASSTRINGS(lphc
) ) SetWindowTextW( lphc
->hWndEdit
, pText
? pText
: empty_stringW
);
717 if( lphc
->wState
& CBF_FOCUSED
)
718 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, MAXLONG
);
720 else if(!(lphc
->wState
& CBF_NOREDRAW
) && IsWindowVisible( lphc
->self
))
722 /* paint text field ourselves */
723 HDC hdc
= hdc_paint
? hdc_paint
: GetDC(lphc
->self
);
724 UINT itemState
= ODS_COMBOBOXEDIT
;
725 HFONT hPrevFont
= (lphc
->hFont
) ? SelectObject(hdc
, lphc
->hFont
) : 0;
726 HBRUSH hPrevBrush
, hBkgBrush
;
729 * Give ourselves some space.
731 InflateRect( &rectEdit
, -1, -1 );
733 hBkgBrush
= COMBO_PrepareColors( lphc
, hdc
);
734 hPrevBrush
= SelectObject( hdc
, hBkgBrush
);
735 FillRect( hdc
, &rectEdit
, hBkgBrush
);
737 if( CB_OWNERDRAWN(lphc
) )
741 UINT ctlid
= (UINT
)GetWindowLongPtrW( lphc
->self
, GWLP_ID
);
743 /* setup state for DRAWITEM message. Owner will highlight */
744 if ( (lphc
->wState
& CBF_FOCUSED
) &&
745 !(lphc
->wState
& CBF_DROPPED
) )
746 itemState
|= ODS_SELECTED
| ODS_FOCUS
;
748 if (!IsWindowEnabled(lphc
->self
)) itemState
|= ODS_DISABLED
;
750 dis
.CtlType
= ODT_COMBOBOX
;
752 dis
.hwndItem
= lphc
->self
;
753 dis
.itemAction
= ODA_DRAWENTIRE
;
755 dis
.itemState
= itemState
;
757 dis
.rcItem
= rectEdit
;
758 dis
.itemData
= SendMessageW(lphc
->hWndLBox
, LB_GETITEMDATA
, id
, 0);
761 * Clip the DC and have the parent draw the item.
763 clipRegion
= set_control_clipping( hdc
, &rectEdit
);
765 SendMessageW(lphc
->owner
, WM_DRAWITEM
, ctlid
, (LPARAM
)&dis
);
767 SelectClipRgn( hdc
, clipRegion
);
768 if (clipRegion
) DeleteObject( clipRegion
);
772 static const WCHAR empty_stringW
[] = { 0 };
774 if ( (lphc
->wState
& CBF_FOCUSED
) &&
775 !(lphc
->wState
& CBF_DROPPED
) ) {
778 FillRect( hdc
, &rectEdit
, GetSysColorBrush(COLOR_HIGHLIGHT
) );
779 SetBkColor( hdc
, GetSysColor( COLOR_HIGHLIGHT
) );
780 SetTextColor( hdc
, GetSysColor( COLOR_HIGHLIGHTTEXT
) );
786 ETO_OPAQUE
| ETO_CLIPPED
,
788 pText
? pText
: empty_stringW
, size
, NULL
);
790 if(lphc
->wState
& CBF_FOCUSED
&& !(lphc
->wState
& CBF_DROPPED
))
791 DrawFocusRect( hdc
, &rectEdit
);
795 SelectObject(hdc
, hPrevFont
);
798 SelectObject( hdc
, hPrevBrush
);
801 ReleaseDC( lphc
->self
, hdc
);
803 HeapFree( GetProcessHeap(), 0, pText
);
806 /***********************************************************************
809 static void CBPaintBorder(
811 const HEADCOMBO
*lphc
,
816 if (CB_GETTYPE(lphc
) != CBS_SIMPLE
)
818 GetClientRect(hwnd
, &clientRect
);
822 clientRect
= lphc
->textRect
;
824 InflateRect(&clientRect
, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
825 InflateRect(&clientRect
, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
828 DrawEdge(hdc
, &clientRect
, EDGE_SUNKEN
, BF_RECT
);
831 /***********************************************************************
834 static LRESULT
COMBO_Paint(LPHEADCOMBO lphc
, HDC hParamDC
)
839 hDC
= (hParamDC
) ? hParamDC
840 : BeginPaint( lphc
->self
, &ps
);
842 TRACE("hdc=%p\n", hDC
);
844 if( hDC
&& !(lphc
->wState
& CBF_NOREDRAW
) )
846 HBRUSH hPrevBrush
, hBkgBrush
;
849 * Retrieve the background brush and select it in the
852 hBkgBrush
= COMBO_PrepareColors(lphc
, hDC
);
854 hPrevBrush
= SelectObject( hDC
, hBkgBrush
);
855 if (!(lphc
->wState
& CBF_EDIT
))
856 FillRect(hDC
, &lphc
->textRect
, hBkgBrush
);
859 * In non 3.1 look, there is a sunken border on the combobox
861 CBPaintBorder(lphc
->self
, lphc
, hDC
);
863 if( !IsRectEmpty(&lphc
->buttonRect
) )
865 CBPaintButton(lphc
, hDC
, lphc
->buttonRect
);
868 /* paint the edit control padding area */
869 if (CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
)
871 RECT rPadEdit
= lphc
->textRect
;
873 InflateRect(&rPadEdit
, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
875 FrameRect( hDC
, &rPadEdit
, GetSysColorBrush(COLOR_WINDOW
) );
878 if( !(lphc
->wState
& CBF_EDIT
) )
879 CBPaintText( lphc
, hDC
);
882 SelectObject( hDC
, hPrevBrush
);
886 EndPaint(lphc
->self
, &ps
);
891 /***********************************************************************
894 * Select listbox entry according to the contents of the edit control.
896 static INT
CBUpdateLBox( LPHEADCOMBO lphc
, BOOL bSelect
)
902 length
= SendMessageW( lphc
->hWndEdit
, WM_GETTEXTLENGTH
, 0, 0 );
905 pText
= HeapAlloc( GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
));
907 TRACE("\t edit text length %i\n", length
);
911 GetWindowTextW( lphc
->hWndEdit
, pText
, length
+ 1);
912 idx
= SendMessageW(lphc
->hWndLBox
, LB_FINDSTRING
, -1, (LPARAM
)pText
);
913 HeapFree( GetProcessHeap(), 0, pText
);
916 SendMessageW(lphc
->hWndLBox
, LB_SETCURSEL
, bSelect
? idx
: -1, 0);
918 /* probably superfluous but Windows sends this too */
919 SendMessageW(lphc
->hWndLBox
, LB_SETCARETINDEX
, idx
< 0 ? 0 : idx
, 0);
920 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
, idx
< 0 ? 0 : idx
, 0);
925 /***********************************************************************
928 * Copy a listbox entry to the edit control.
930 static void CBUpdateEdit( LPHEADCOMBO lphc
, INT index
)
934 static const WCHAR empty_stringW
[] = { 0 };
936 TRACE("\t %i\n", index
);
938 if( index
>= 0 ) /* got an entry */
940 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, index
, 0);
941 if( length
!= LB_ERR
)
943 if( (pText
= HeapAlloc( GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
))) )
945 SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, index
, (LPARAM
)pText
);
950 if( CB_HASSTRINGS(lphc
) )
952 lphc
->wState
|= (CBF_NOEDITNOTIFY
| CBF_NOLBSELECT
);
953 SendMessageW(lphc
->hWndEdit
, WM_SETTEXT
, 0, pText
? (LPARAM
)pText
: (LPARAM
)empty_stringW
);
954 lphc
->wState
&= ~(CBF_NOEDITNOTIFY
| CBF_NOLBSELECT
);
957 if( lphc
->wState
& CBF_FOCUSED
)
958 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, -1);
960 HeapFree( GetProcessHeap(), 0, pText
);
963 /***********************************************************************
966 * Show listbox popup.
968 static void CBDropDown( LPHEADCOMBO lphc
)
971 MONITORINFO mon_info
;
976 TRACE("[%p]: drop down\n", lphc
->self
);
978 CB_NOTIFY( lphc
, CBN_DROPDOWN
);
982 lphc
->wState
|= CBF_DROPPED
;
983 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
985 lphc
->droppedIndex
= CBUpdateLBox( lphc
, TRUE
);
987 /* Update edit only if item is in the list */
988 if( !(lphc
->wState
& CBF_CAPTURE
) && lphc
->droppedIndex
>= 0)
989 CBUpdateEdit( lphc
, lphc
->droppedIndex
);
993 lphc
->droppedIndex
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
995 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
,
996 lphc
->droppedIndex
== LB_ERR
? 0 : lphc
->droppedIndex
, 0);
997 SendMessageW(lphc
->hWndLBox
, LB_CARETON
, 0, 0);
1000 /* now set popup position */
1001 GetWindowRect( lphc
->self
, &rect
);
1004 * If it's a dropdown, the listbox is offset
1006 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1007 rect
.left
+= COMBO_EDITBUTTONSPACE();
1009 /* if the dropped height is greater than the total height of the dropped
1010 items list, then force the drop down list height to be the total height
1011 of the items in the dropped list */
1013 /* And Remove any extra space (Best Fit) */
1014 nDroppedHeight
= lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
;
1015 /* if listbox length has been set directly by its handle */
1016 GetWindowRect(lphc
->hWndLBox
, &r
);
1017 if (nDroppedHeight
< r
.bottom
- r
.top
)
1018 nDroppedHeight
= r
.bottom
- r
.top
;
1019 nItems
= (int)SendMessageW(lphc
->hWndLBox
, LB_GETCOUNT
, 0, 0);
1026 nIHeight
= (int)SendMessageW(lphc
->hWndLBox
, LB_GETITEMHEIGHT
, 0, 0);
1028 nHeight
= nIHeight
*nItems
;
1030 if (nHeight
< nDroppedHeight
- COMBO_YBORDERSIZE())
1031 nDroppedHeight
= nHeight
+ COMBO_YBORDERSIZE();
1035 r
.top
= rect
.bottom
;
1036 r
.right
= r
.left
+ lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
1037 r
.bottom
= r
.top
+ nDroppedHeight
;
1039 /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/
1040 monitor
= MonitorFromRect( &rect
, MONITOR_DEFAULTTOPRIMARY
);
1041 mon_info
.cbSize
= sizeof(mon_info
);
1042 GetMonitorInfoW( monitor
, &mon_info
);
1044 if (r
.bottom
> mon_info
.rcWork
.bottom
)
1046 r
.top
= max( rect
.top
- nDroppedHeight
, mon_info
.rcWork
.top
);
1047 r
.bottom
= min( r
.top
+ nDroppedHeight
, mon_info
.rcWork
.bottom
);
1050 SetWindowPos( lphc
->hWndLBox
, HWND_TOPMOST
, r
.left
, r
.top
, r
.right
- r
.left
, r
.bottom
- r
.top
,
1051 SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
1054 if( !(lphc
->wState
& CBF_NOREDRAW
) )
1055 RedrawWindow( lphc
->self
, NULL
, 0, RDW_INVALIDATE
|
1056 RDW_ERASE
| RDW_UPDATENOW
| RDW_NOCHILDREN
);
1058 EnableWindow( lphc
->hWndLBox
, TRUE
);
1059 if (GetCapture() != lphc
->self
)
1060 SetCapture(lphc
->hWndLBox
);
1063 /***********************************************************************
1066 * Hide listbox popup.
1068 static void CBRollUp( LPHEADCOMBO lphc
, BOOL ok
, BOOL bButton
)
1070 HWND hWnd
= lphc
->self
;
1072 TRACE("[%p]: sel ok? [%i] dropped? [%i]\n",
1073 lphc
->self
, ok
, (INT
)(lphc
->wState
& CBF_DROPPED
));
1075 CB_NOTIFY( lphc
, (ok
) ? CBN_SELENDOK
: CBN_SELENDCANCEL
);
1077 if( IsWindow( hWnd
) && CB_GETTYPE(lphc
) != CBS_SIMPLE
)
1080 if( lphc
->wState
& CBF_DROPPED
)
1084 lphc
->wState
&= ~CBF_DROPPED
;
1085 ShowWindow( lphc
->hWndLBox
, SW_HIDE
);
1087 if(GetCapture() == lphc
->hWndLBox
)
1092 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1094 rect
= lphc
->buttonRect
;
1105 rect
= lphc
->textRect
;
1110 if( bButton
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1111 RedrawWindow( hWnd
, &rect
, 0, RDW_INVALIDATE
|
1112 RDW_ERASE
| RDW_UPDATENOW
| RDW_NOCHILDREN
);
1113 CB_NOTIFY( lphc
, CBN_CLOSEUP
);
1118 /***********************************************************************
1121 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
1123 BOOL
COMBO_FlipListbox( LPHEADCOMBO lphc
, BOOL ok
, BOOL bRedrawButton
)
1125 if( lphc
->wState
& CBF_DROPPED
)
1127 CBRollUp( lphc
, ok
, bRedrawButton
);
1135 /***********************************************************************
1138 static void CBRepaintButton( LPHEADCOMBO lphc
)
1140 InvalidateRect(lphc
->self
, &lphc
->buttonRect
, TRUE
);
1141 UpdateWindow(lphc
->self
);
1144 /***********************************************************************
1147 static void COMBO_SetFocus( LPHEADCOMBO lphc
)
1149 if( !(lphc
->wState
& CBF_FOCUSED
) )
1151 if( CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
)
1152 SendMessageW(lphc
->hWndLBox
, LB_CARETON
, 0, 0);
1154 /* This is wrong. Message sequences seem to indicate that this
1155 is set *after* the notify. */
1156 /* lphc->wState |= CBF_FOCUSED; */
1158 if( !(lphc
->wState
& CBF_EDIT
) )
1159 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1161 CB_NOTIFY( lphc
, CBN_SETFOCUS
);
1162 lphc
->wState
|= CBF_FOCUSED
;
1166 /***********************************************************************
1169 static void COMBO_KillFocus( LPHEADCOMBO lphc
)
1171 HWND hWnd
= lphc
->self
;
1173 if( lphc
->wState
& CBF_FOCUSED
)
1175 CBRollUp( lphc
, FALSE
, TRUE
);
1176 if( IsWindow( hWnd
) )
1178 if( CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
)
1179 SendMessageW(lphc
->hWndLBox
, LB_CARETOFF
, 0, 0);
1181 lphc
->wState
&= ~CBF_FOCUSED
;
1184 if( !(lphc
->wState
& CBF_EDIT
) )
1185 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1187 CB_NOTIFY( lphc
, CBN_KILLFOCUS
);
1192 /***********************************************************************
1195 static LRESULT
COMBO_Command( LPHEADCOMBO lphc
, WPARAM wParam
, HWND hWnd
)
1197 if ( lphc
->wState
& CBF_EDIT
&& lphc
->hWndEdit
== hWnd
)
1199 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1201 switch( HIWORD(wParam
) >> 8 )
1203 case (EN_SETFOCUS
>> 8):
1205 TRACE("[%p]: edit [%p] got focus\n", lphc
->self
, lphc
->hWndEdit
);
1207 COMBO_SetFocus( lphc
);
1210 case (EN_KILLFOCUS
>> 8):
1212 TRACE("[%p]: edit [%p] lost focus\n", lphc
->self
, lphc
->hWndEdit
);
1214 /* NOTE: it seems that Windows' edit control sends an
1215 * undocumented message WM_USER + 0x1B instead of this
1216 * notification (only when it happens to be a part of
1217 * the combo). ?? - AK.
1220 COMBO_KillFocus( lphc
);
1224 case (EN_CHANGE
>> 8):
1226 * In some circumstances (when the selection of the combobox
1227 * is changed for example) we don't want the EN_CHANGE notification
1228 * to be forwarded to the parent of the combobox. This code
1229 * checks a flag that is set in these occasions and ignores the
1232 if (lphc
->wState
& CBF_NOLBSELECT
)
1234 lphc
->wState
&= ~CBF_NOLBSELECT
;
1238 CBUpdateLBox( lphc
, lphc
->wState
& CBF_DROPPED
);
1241 if (!(lphc
->wState
& CBF_NOEDITNOTIFY
))
1242 CB_NOTIFY( lphc
, CBN_EDITCHANGE
);
1245 case (EN_UPDATE
>> 8):
1246 if (!(lphc
->wState
& CBF_NOEDITNOTIFY
))
1247 CB_NOTIFY( lphc
, CBN_EDITUPDATE
);
1250 case (EN_ERRSPACE
>> 8):
1251 CB_NOTIFY( lphc
, CBN_ERRSPACE
);
1254 else if( lphc
->hWndLBox
== hWnd
)
1256 switch( (short)HIWORD(wParam
) )
1259 CB_NOTIFY( lphc
, CBN_ERRSPACE
);
1263 CB_NOTIFY( lphc
, CBN_DBLCLK
);
1269 TRACE("[%p]: lbox selection change [%x]\n", lphc
->self
, lphc
->wState
);
1271 /* do not roll up if selection is being tracked
1272 * by arrow keys in the dropdown listbox */
1273 if (!(lphc
->wState
& CBF_NOROLLUP
))
1275 CBRollUp( lphc
, (HIWORD(wParam
) == LBN_SELCHANGE
), TRUE
);
1277 else lphc
->wState
&= ~CBF_NOROLLUP
;
1279 CB_NOTIFY( lphc
, CBN_SELCHANGE
);
1281 if( HIWORD(wParam
) == LBN_SELCHANGE
)
1283 if( lphc
->wState
& CBF_EDIT
)
1284 lphc
->wState
|= CBF_NOLBSELECT
;
1285 CBPaintText( lphc
, NULL
);
1291 /* nothing to do here since ComboLBox always resets the focus to its
1292 * combo/edit counterpart */
1299 /***********************************************************************
1302 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1304 static LRESULT
COMBO_ItemOp( LPHEADCOMBO lphc
, UINT msg
, LPARAM lParam
)
1306 HWND hWnd
= lphc
->self
;
1307 UINT id
= (UINT
)GetWindowLongPtrW( hWnd
, GWLP_ID
);
1309 TRACE("[%p]: ownerdraw op %04x\n", lphc
->self
, msg
);
1315 DELETEITEMSTRUCT
*lpIS
= (DELETEITEMSTRUCT
*)lParam
;
1316 lpIS
->CtlType
= ODT_COMBOBOX
;
1318 lpIS
->hwndItem
= hWnd
;
1323 DRAWITEMSTRUCT
*lpIS
= (DRAWITEMSTRUCT
*)lParam
;
1324 lpIS
->CtlType
= ODT_COMBOBOX
;
1326 lpIS
->hwndItem
= hWnd
;
1329 case WM_COMPAREITEM
:
1331 COMPAREITEMSTRUCT
*lpIS
= (COMPAREITEMSTRUCT
*)lParam
;
1332 lpIS
->CtlType
= ODT_COMBOBOX
;
1334 lpIS
->hwndItem
= hWnd
;
1337 case WM_MEASUREITEM
:
1339 MEASUREITEMSTRUCT
*lpIS
= (MEASUREITEMSTRUCT
*)lParam
;
1340 lpIS
->CtlType
= ODT_COMBOBOX
;
1345 return SendMessageW(lphc
->owner
, msg
, id
, lParam
);
1349 /***********************************************************************
1352 static LRESULT
COMBO_GetTextW( LPHEADCOMBO lphc
, INT count
, LPWSTR buf
)
1356 if( lphc
->wState
& CBF_EDIT
)
1357 return SendMessageW( lphc
->hWndEdit
, WM_GETTEXT
, count
, (LPARAM
)buf
);
1359 /* get it from the listbox */
1361 if (!count
|| !buf
) return 0;
1362 if( lphc
->hWndLBox
)
1364 INT idx
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1365 if (idx
== LB_ERR
) goto error
;
1366 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, idx
, 0 );
1367 if (length
== LB_ERR
) goto error
;
1369 /* 'length' is without the terminating character */
1370 if (length
>= count
)
1372 LPWSTR lpBuffer
= HeapAlloc(GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
));
1373 if (!lpBuffer
) goto error
;
1374 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)lpBuffer
);
1376 /* truncate if buffer is too short */
1377 if (length
!= LB_ERR
)
1379 lstrcpynW( buf
, lpBuffer
, count
);
1382 HeapFree( GetProcessHeap(), 0, lpBuffer
);
1384 else length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)buf
);
1386 if (length
== LB_ERR
) return 0;
1390 error
: /* error - truncate string, return zero */
1396 /***********************************************************************
1399 * NOTE! LB_GETTEXT does not count terminating \0, WM_GETTEXT does.
1400 * also LB_GETTEXT might return values < 0, WM_GETTEXT doesn't.
1402 static LRESULT
COMBO_GetTextA( LPHEADCOMBO lphc
, INT count
, LPSTR buf
)
1406 if( lphc
->wState
& CBF_EDIT
)
1407 return SendMessageA( lphc
->hWndEdit
, WM_GETTEXT
, count
, (LPARAM
)buf
);
1409 /* get it from the listbox */
1411 if (!count
|| !buf
) return 0;
1412 if( lphc
->hWndLBox
)
1414 INT idx
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1415 if (idx
== LB_ERR
) goto error
;
1416 length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, idx
, 0 );
1417 if (length
== LB_ERR
) goto error
;
1419 /* 'length' is without the terminating character */
1420 if (length
>= count
)
1422 LPSTR lpBuffer
= HeapAlloc(GetProcessHeap(), 0, (length
+ 1) );
1423 if (!lpBuffer
) goto error
;
1424 length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)lpBuffer
);
1426 /* truncate if buffer is too short */
1427 if (length
!= LB_ERR
)
1429 lstrcpynA( buf
, lpBuffer
, count
);
1432 HeapFree( GetProcessHeap(), 0, lpBuffer
);
1434 else length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)buf
);
1436 if (length
== LB_ERR
) return 0;
1440 error
: /* error - truncate string, return zero */
1446 /***********************************************************************
1449 * This function sets window positions according to the updated
1450 * component placement struct.
1452 static void CBResetPos(
1454 const RECT
*rectEdit
,
1458 BOOL bDrop
= (CB_GETTYPE(lphc
) != CBS_SIMPLE
);
1460 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1461 * sizing messages */
1463 if( lphc
->wState
& CBF_EDIT
)
1464 SetWindowPos( lphc
->hWndEdit
, 0,
1465 rectEdit
->left
, rectEdit
->top
,
1466 rectEdit
->right
- rectEdit
->left
,
1467 rectEdit
->bottom
- rectEdit
->top
,
1468 SWP_NOZORDER
| SWP_NOACTIVATE
| ((bDrop
) ? SWP_NOREDRAW
: 0) );
1470 SetWindowPos( lphc
->hWndLBox
, 0,
1471 rectLB
->left
, rectLB
->top
,
1472 rectLB
->right
- rectLB
->left
,
1473 rectLB
->bottom
- rectLB
->top
,
1474 SWP_NOACTIVATE
| SWP_NOZORDER
| ((bDrop
) ? SWP_NOREDRAW
: 0) );
1478 if( lphc
->wState
& CBF_DROPPED
)
1480 lphc
->wState
&= ~CBF_DROPPED
;
1481 ShowWindow( lphc
->hWndLBox
, SW_HIDE
);
1484 if( bRedraw
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1485 RedrawWindow( lphc
->self
, NULL
, 0,
1486 RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
);
1491 /***********************************************************************
1494 static void COMBO_Size( LPHEADCOMBO lphc
)
1497 * Those controls are always the same height. So we have to make sure
1498 * they are not resized to another value.
1500 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
1502 int newComboHeight
, curComboHeight
, curComboWidth
;
1505 GetWindowRect(lphc
->self
, &rc
);
1506 curComboHeight
= rc
.bottom
- rc
.top
;
1507 curComboWidth
= rc
.right
- rc
.left
;
1508 newComboHeight
= CBGetTextAreaHeight(lphc
->self
, lphc
) + 2*COMBO_YBORDERSIZE();
1511 * Resizing a combobox has another side effect, it resizes the dropped
1512 * rectangle as well. However, it does it only if the new height for the
1513 * combobox is more than the height it should have. In other words,
1514 * if the application resizing the combobox only had the intention to resize
1515 * the actual control, for example, to do the layout of a dialog that is
1516 * resized, the height of the dropdown is not changed.
1518 if( curComboHeight
> newComboHeight
)
1520 TRACE("oldComboHeight=%d, newComboHeight=%d, oldDropBottom=%d, oldDropTop=%d\n",
1521 curComboHeight
, newComboHeight
, lphc
->droppedRect
.bottom
,
1522 lphc
->droppedRect
.top
);
1523 lphc
->droppedRect
.bottom
= lphc
->droppedRect
.top
+ curComboHeight
- newComboHeight
;
1526 * Restore original height
1528 if( curComboHeight
!= newComboHeight
)
1529 SetWindowPos(lphc
->self
, 0, 0, 0, curComboWidth
, newComboHeight
,
1530 SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_NOREDRAW
);
1533 CBCalcPlacement(lphc
->self
,
1537 &lphc
->droppedRect
);
1539 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1543 /***********************************************************************
1546 static void COMBO_Font( LPHEADCOMBO lphc
, HFONT hFont
, BOOL bRedraw
)
1551 lphc
->hFont
= hFont
;
1554 * Propagate to owned windows.
1556 if( lphc
->wState
& CBF_EDIT
)
1557 SendMessageW(lphc
->hWndEdit
, WM_SETFONT
, (WPARAM
)hFont
, bRedraw
);
1558 SendMessageW(lphc
->hWndLBox
, WM_SETFONT
, (WPARAM
)hFont
, bRedraw
);
1561 * Redo the layout of the control.
1563 if ( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
1565 CBCalcPlacement(lphc
->self
,
1569 &lphc
->droppedRect
);
1571 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1575 CBForceDummyResize(lphc
);
1580 /***********************************************************************
1581 * COMBO_SetItemHeight
1583 static LRESULT
COMBO_SetItemHeight( LPHEADCOMBO lphc
, INT index
, INT height
)
1585 LRESULT lRet
= CB_ERR
;
1587 if( index
== -1 ) /* set text field height */
1589 if( height
< 32768 )
1591 lphc
->editHeight
= height
+ 2; /* Is the 2 for 2*EDIT_CONTROL_PADDING? */
1594 * Redo the layout of the control.
1596 if ( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
1598 CBCalcPlacement(lphc
->self
,
1602 &lphc
->droppedRect
);
1604 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1608 CBForceDummyResize(lphc
);
1614 else if ( CB_OWNERDRAWN(lphc
) ) /* set listbox item height */
1615 lRet
= SendMessageW(lphc
->hWndLBox
, LB_SETITEMHEIGHT
, index
, height
);
1619 /***********************************************************************
1620 * COMBO_SelectString
1622 static LRESULT
COMBO_SelectString( LPHEADCOMBO lphc
, INT start
, LPARAM pText
, BOOL unicode
)
1624 INT index
= unicode
? SendMessageW(lphc
->hWndLBox
, LB_SELECTSTRING
, start
, pText
) :
1625 SendMessageA(lphc
->hWndLBox
, LB_SELECTSTRING
, start
, pText
);
1628 if( lphc
->wState
& CBF_EDIT
)
1629 CBUpdateEdit( lphc
, index
);
1632 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1635 return (LRESULT
)index
;
1638 /***********************************************************************
1641 static void COMBO_LButtonDown( LPHEADCOMBO lphc
, LPARAM lParam
)
1645 HWND hWnd
= lphc
->self
;
1647 pt
.x
= (short)LOWORD(lParam
);
1648 pt
.y
= (short)HIWORD(lParam
);
1649 bButton
= PtInRect(&lphc
->buttonRect
, pt
);
1651 if( (CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
) ||
1652 (bButton
&& (CB_GETTYPE(lphc
) == CBS_DROPDOWN
)) )
1654 lphc
->wState
|= CBF_BUTTONDOWN
;
1655 if( lphc
->wState
& CBF_DROPPED
)
1657 /* got a click to cancel selection */
1659 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1660 CBRollUp( lphc
, TRUE
, FALSE
);
1661 if( !IsWindow( hWnd
) ) return;
1663 if( lphc
->wState
& CBF_CAPTURE
)
1665 lphc
->wState
&= ~CBF_CAPTURE
;
1671 /* drop down the listbox and start tracking */
1673 lphc
->wState
|= CBF_CAPTURE
;
1677 if( bButton
) CBRepaintButton( lphc
);
1681 /***********************************************************************
1684 * Release capture and stop tracking if needed.
1686 static void COMBO_LButtonUp( LPHEADCOMBO lphc
)
1688 if( lphc
->wState
& CBF_CAPTURE
)
1690 lphc
->wState
&= ~CBF_CAPTURE
;
1691 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1693 INT index
= CBUpdateLBox( lphc
, TRUE
);
1694 /* Update edit only if item is in the list */
1697 lphc
->wState
|= CBF_NOLBSELECT
;
1698 CBUpdateEdit( lphc
, index
);
1699 lphc
->wState
&= ~CBF_NOLBSELECT
;
1703 SetCapture(lphc
->hWndLBox
);
1706 if( lphc
->wState
& CBF_BUTTONDOWN
)
1708 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1709 CBRepaintButton( lphc
);
1713 /***********************************************************************
1716 * Two things to do - track combo button and release capture when
1717 * pointer goes into the listbox.
1719 static void COMBO_MouseMove( LPHEADCOMBO lphc
, WPARAM wParam
, LPARAM lParam
)
1724 pt
.x
= (short)LOWORD(lParam
);
1725 pt
.y
= (short)HIWORD(lParam
);
1727 if( lphc
->wState
& CBF_BUTTONDOWN
)
1731 bButton
= PtInRect(&lphc
->buttonRect
, pt
);
1735 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1736 CBRepaintButton( lphc
);
1740 GetClientRect( lphc
->hWndLBox
, &lbRect
);
1741 MapWindowPoints( lphc
->self
, lphc
->hWndLBox
, &pt
, 1 );
1742 if( PtInRect(&lbRect
, pt
) )
1744 lphc
->wState
&= ~CBF_CAPTURE
;
1746 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
) CBUpdateLBox( lphc
, TRUE
);
1748 /* hand over pointer tracking */
1749 SendMessageW(lphc
->hWndLBox
, WM_LBUTTONDOWN
, wParam
, lParam
);
1753 static LRESULT
COMBO_GetComboBoxInfo(const HEADCOMBO
*lphc
, COMBOBOXINFO
*pcbi
)
1755 if (!pcbi
|| (pcbi
->cbSize
< sizeof(COMBOBOXINFO
)))
1758 pcbi
->rcItem
= lphc
->textRect
;
1759 pcbi
->rcButton
= lphc
->buttonRect
;
1760 pcbi
->stateButton
= 0;
1761 if (lphc
->wState
& CBF_BUTTONDOWN
)
1762 pcbi
->stateButton
|= STATE_SYSTEM_PRESSED
;
1763 if (IsRectEmpty(&lphc
->buttonRect
))
1764 pcbi
->stateButton
|= STATE_SYSTEM_INVISIBLE
;
1765 pcbi
->hwndCombo
= lphc
->self
;
1766 pcbi
->hwndItem
= lphc
->hWndEdit
;
1767 pcbi
->hwndList
= lphc
->hWndLBox
;
1771 static char *strdupA(LPCSTR str
)
1776 if(!str
) return NULL
;
1779 ret
= HeapAlloc(GetProcessHeap(), 0, len
+ 1);
1780 memcpy(ret
, str
, len
+ 1);
1784 /***********************************************************************
1785 * ComboWndProc_common
1787 LRESULT
ComboWndProc_common( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
1789 LPHEADCOMBO lphc
= (LPHEADCOMBO
)GetWindowLongPtrW( hwnd
, 0 );
1791 TRACE("[%p]: msg %s wp %08lx lp %08lx\n",
1792 hwnd
, SPY_GetMsgName(message
, hwnd
), wParam
, lParam
);
1794 if (!IsWindow(hwnd
)) return 0;
1796 if( lphc
|| message
== WM_NCCREATE
)
1800 /* System messages */
1804 LONG style
= unicode
? ((LPCREATESTRUCTW
)lParam
)->style
:
1805 ((LPCREATESTRUCTA
)lParam
)->style
;
1806 return COMBO_NCCreate(hwnd
, style
);
1809 COMBO_NCDestroy(lphc
);
1810 break;/* -> DefWindowProc */
1818 hwndParent
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
1819 style
= ((LPCREATESTRUCTW
)lParam
)->style
;
1823 hwndParent
= ((LPCREATESTRUCTA
)lParam
)->hwndParent
;
1824 style
= ((LPCREATESTRUCTA
)lParam
)->style
;
1826 return COMBO_Create(hwnd
, lphc
, hwndParent
, style
, unicode
);
1829 case WM_PRINTCLIENT
:
1832 /* wParam may contain a valid HDC! */
1833 return COMBO_Paint(lphc
, (HDC
)wParam
);
1836 /* do all painting in WM_PAINT like Windows does */
1841 LRESULT result
= DLGC_WANTARROWS
| DLGC_WANTCHARS
;
1842 if (lParam
&& (((LPMSG
)lParam
)->message
== WM_KEYDOWN
))
1844 int vk
= (int)((LPMSG
)lParam
)->wParam
;
1846 if ((vk
== VK_RETURN
|| vk
== VK_ESCAPE
) && (lphc
->wState
& CBF_DROPPED
))
1847 result
|= DLGC_WANTMESSAGE
;
1852 if( lphc
->hWndLBox
&&
1853 !(lphc
->wState
& CBF_NORESIZE
) ) COMBO_Size( lphc
);
1856 COMBO_Font( lphc
, (HFONT
)wParam
, (BOOL
)lParam
);
1859 return (LRESULT
)lphc
->hFont
;
1861 if( lphc
->wState
& CBF_EDIT
) {
1862 SetFocus( lphc
->hWndEdit
);
1863 /* The first time focus is received, select all the text */
1864 if( !(lphc
->wState
& CBF_BEENFOCUSED
) ) {
1865 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, -1);
1866 lphc
->wState
|= CBF_BEENFOCUSED
;
1870 COMBO_SetFocus( lphc
);
1874 HWND hwndFocus
= WIN_GetFullHandle( (HWND
)wParam
);
1876 (hwndFocus
!= lphc
->hWndEdit
&& hwndFocus
!= lphc
->hWndLBox
))
1877 COMBO_KillFocus( lphc
);
1881 return COMBO_Command( lphc
, wParam
, WIN_GetFullHandle( (HWND
)lParam
) );
1883 return unicode
? COMBO_GetTextW( lphc
, wParam
, (LPWSTR
)lParam
)
1884 : COMBO_GetTextA( lphc
, wParam
, (LPSTR
)lParam
);
1886 case WM_GETTEXTLENGTH
:
1888 if ((message
== WM_GETTEXTLENGTH
) && !ISWIN31
&& !(lphc
->wState
& CBF_EDIT
))
1890 int j
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1891 if (j
== -1) return 0;
1892 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, j
, 0) :
1893 SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, j
, 0);
1895 else if( lphc
->wState
& CBF_EDIT
)
1898 lphc
->wState
|= CBF_NOEDITNOTIFY
;
1899 ret
= unicode
? SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
) :
1900 SendMessageA(lphc
->hWndEdit
, message
, wParam
, lParam
);
1901 lphc
->wState
&= ~CBF_NOEDITNOTIFY
;
1908 if( lphc
->wState
& CBF_EDIT
)
1910 return unicode
? SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
) :
1911 SendMessageA(lphc
->hWndEdit
, message
, wParam
, lParam
);
1917 case WM_COMPAREITEM
:
1918 case WM_MEASUREITEM
:
1919 return COMBO_ItemOp(lphc
, message
, lParam
);
1921 if( lphc
->wState
& CBF_EDIT
)
1922 EnableWindow( lphc
->hWndEdit
, (BOOL
)wParam
);
1923 EnableWindow( lphc
->hWndLBox
, (BOOL
)wParam
);
1925 /* Force the control to repaint when the enabled state changes. */
1926 InvalidateRect(lphc
->self
, NULL
, TRUE
);
1930 lphc
->wState
&= ~CBF_NOREDRAW
;
1932 lphc
->wState
|= CBF_NOREDRAW
;
1934 if( lphc
->wState
& CBF_EDIT
)
1935 SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
);
1936 SendMessageW(lphc
->hWndLBox
, message
, wParam
, lParam
);
1939 if( KEYDATA_ALT
& HIWORD(lParam
) )
1940 if( wParam
== VK_UP
|| wParam
== VK_DOWN
)
1941 COMBO_FlipListbox( lphc
, FALSE
, FALSE
);
1945 if ((wParam
== VK_RETURN
|| wParam
== VK_ESCAPE
) &&
1946 (lphc
->wState
& CBF_DROPPED
))
1948 CBRollUp( lphc
, wParam
== VK_RETURN
, FALSE
);
1951 else if ((wParam
== VK_F4
) && !(lphc
->wState
& CBF_EUI
))
1953 COMBO_FlipListbox( lphc
, FALSE
, FALSE
);
1962 if( lphc
->wState
& CBF_EDIT
)
1963 hwndTarget
= lphc
->hWndEdit
;
1965 hwndTarget
= lphc
->hWndLBox
;
1967 return unicode
? SendMessageW(hwndTarget
, message
, wParam
, lParam
) :
1968 SendMessageA(hwndTarget
, message
, wParam
, lParam
);
1970 case WM_LBUTTONDOWN
:
1971 if( !(lphc
->wState
& CBF_FOCUSED
) ) SetFocus( lphc
->self
);
1972 if( lphc
->wState
& CBF_FOCUSED
) COMBO_LButtonDown( lphc
, lParam
);
1975 COMBO_LButtonUp( lphc
);
1978 if( lphc
->wState
& CBF_CAPTURE
)
1979 COMBO_MouseMove( lphc
, wParam
, lParam
);
1983 if (wParam
& (MK_SHIFT
| MK_CONTROL
))
1984 return unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
) :
1985 DefWindowProcA(hwnd
, message
, wParam
, lParam
);
1987 if (GET_WHEEL_DELTA_WPARAM(wParam
) > 0) return SendMessageW(hwnd
, WM_KEYDOWN
, VK_UP
, 0);
1988 if (GET_WHEEL_DELTA_WPARAM(wParam
) < 0) return SendMessageW(hwnd
, WM_KEYDOWN
, VK_DOWN
, 0);
1991 /* Combo messages */
1996 if( lphc
->dwStyle
& CBS_LOWERCASE
)
1997 CharLowerW((LPWSTR
)lParam
);
1998 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
1999 CharUpperW((LPWSTR
)lParam
);
2000 return SendMessageW(lphc
->hWndLBox
, LB_ADDSTRING
, 0, lParam
);
2002 else /* unlike the unicode version, the ansi version does not overwrite
2003 the string if converting case */
2005 char *string
= NULL
;
2007 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2009 string
= strdupA((LPSTR
)lParam
);
2013 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2015 string
= strdupA((LPSTR
)lParam
);
2019 ret
= SendMessageA(lphc
->hWndLBox
, LB_ADDSTRING
, 0, string
? (LPARAM
)string
: lParam
);
2020 HeapFree(GetProcessHeap(), 0, string
);
2023 case CB_INSERTSTRING
:
2026 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2027 CharLowerW((LPWSTR
)lParam
);
2028 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2029 CharUpperW((LPWSTR
)lParam
);
2030 return SendMessageW(lphc
->hWndLBox
, LB_INSERTSTRING
, wParam
, lParam
);
2034 if( lphc
->dwStyle
& CBS_LOWERCASE
)
2035 CharLowerA((LPSTR
)lParam
);
2036 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
2037 CharUpperA((LPSTR
)lParam
);
2039 return SendMessageA(lphc
->hWndLBox
, LB_INSERTSTRING
, wParam
, lParam
);
2041 case CB_DELETESTRING
:
2042 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_DELETESTRING
, wParam
, 0) :
2043 SendMessageA(lphc
->hWndLBox
, LB_DELETESTRING
, wParam
, 0);
2044 case CB_SELECTSTRING
:
2045 return COMBO_SelectString(lphc
, (INT
)wParam
, lParam
, unicode
);
2047 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_FINDSTRING
, wParam
, lParam
) :
2048 SendMessageA(lphc
->hWndLBox
, LB_FINDSTRING
, wParam
, lParam
);
2049 case CB_FINDSTRINGEXACT
:
2050 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_FINDSTRINGEXACT
, wParam
, lParam
) :
2051 SendMessageA(lphc
->hWndLBox
, LB_FINDSTRINGEXACT
, wParam
, lParam
);
2052 case CB_SETITEMHEIGHT
:
2053 return COMBO_SetItemHeight( lphc
, (INT
)wParam
, (INT
)lParam
);
2054 case CB_GETITEMHEIGHT
:
2055 if( (INT
)wParam
>= 0 ) /* listbox item */
2056 return SendMessageW(lphc
->hWndLBox
, LB_GETITEMHEIGHT
, wParam
, 0);
2057 return CBGetTextAreaHeight(hwnd
, lphc
);
2058 case CB_RESETCONTENT
:
2059 SendMessageW(lphc
->hWndLBox
, LB_RESETCONTENT
, 0, 0);
2060 if( (lphc
->wState
& CBF_EDIT
) && CB_HASSTRINGS(lphc
) )
2062 static const WCHAR empty_stringW
[] = { 0 };
2063 SendMessageW(lphc
->hWndEdit
, WM_SETTEXT
, 0, (LPARAM
)empty_stringW
);
2066 InvalidateRect(lphc
->self
, NULL
, TRUE
);
2068 case CB_INITSTORAGE
:
2069 return SendMessageW(lphc
->hWndLBox
, LB_INITSTORAGE
, wParam
, lParam
);
2070 case CB_GETHORIZONTALEXTENT
:
2071 return SendMessageW(lphc
->hWndLBox
, LB_GETHORIZONTALEXTENT
, 0, 0);
2072 case CB_SETHORIZONTALEXTENT
:
2073 return SendMessageW(lphc
->hWndLBox
, LB_SETHORIZONTALEXTENT
, wParam
, 0);
2074 case CB_GETTOPINDEX
:
2075 return SendMessageW(lphc
->hWndLBox
, LB_GETTOPINDEX
, 0, 0);
2077 return SendMessageW(lphc
->hWndLBox
, LB_GETLOCALE
, 0, 0);
2079 return SendMessageW(lphc
->hWndLBox
, LB_SETLOCALE
, wParam
, 0);
2080 case CB_SETDROPPEDWIDTH
:
2081 if( (CB_GETTYPE(lphc
) == CBS_SIMPLE
) ||
2082 (INT
)wParam
>= 32768 )
2084 /* new value must be higher than combobox width */
2085 if((INT
)wParam
>= lphc
->droppedRect
.right
- lphc
->droppedRect
.left
)
2086 lphc
->droppedWidth
= wParam
;
2088 lphc
->droppedWidth
= 0;
2090 /* recalculate the combobox area */
2091 CBCalcPlacement(hwnd
, lphc
, &lphc
->textRect
, &lphc
->buttonRect
, &lphc
->droppedRect
);
2094 case CB_GETDROPPEDWIDTH
:
2095 if( lphc
->droppedWidth
)
2096 return lphc
->droppedWidth
;
2097 return lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
2098 case CB_GETDROPPEDCONTROLRECT
:
2099 if( lParam
) CBGetDroppedControlRect(lphc
, (LPRECT
)lParam
);
2101 case CB_GETDROPPEDSTATE
:
2102 return (lphc
->wState
& CBF_DROPPED
) != 0;
2104 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_DIR
, wParam
, lParam
) :
2105 SendMessageA(lphc
->hWndLBox
, LB_DIR
, wParam
, lParam
);
2107 case CB_SHOWDROPDOWN
:
2108 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
2112 if( !(lphc
->wState
& CBF_DROPPED
) )
2116 if( lphc
->wState
& CBF_DROPPED
)
2117 CBRollUp( lphc
, FALSE
, TRUE
);
2121 return SendMessageW(lphc
->hWndLBox
, LB_GETCOUNT
, 0, 0);
2123 return SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
2125 lParam
= SendMessageW(lphc
->hWndLBox
, LB_SETCURSEL
, wParam
, 0);
2127 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
, wParam
, 0);
2129 /* no LBN_SELCHANGE in this case, update manually */
2130 CBPaintText( lphc
, NULL
);
2131 lphc
->wState
&= ~CBF_SELCHANGE
;
2134 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, wParam
, lParam
) :
2135 SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, wParam
, lParam
);
2136 case CB_GETLBTEXTLEN
:
2137 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, wParam
, 0) :
2138 SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, wParam
, 0);
2139 case CB_GETITEMDATA
:
2140 return SendMessageW(lphc
->hWndLBox
, LB_GETITEMDATA
, wParam
, 0);
2141 case CB_SETITEMDATA
:
2142 return SendMessageW(lphc
->hWndLBox
, LB_SETITEMDATA
, wParam
, lParam
);
2144 /* Edit checks passed parameters itself */
2145 if( lphc
->wState
& CBF_EDIT
)
2146 return SendMessageW(lphc
->hWndEdit
, EM_GETSEL
, wParam
, lParam
);
2149 if( lphc
->wState
& CBF_EDIT
)
2150 return SendMessageW(lphc
->hWndEdit
, EM_SETSEL
,
2151 (INT
)(SHORT
)LOWORD(lParam
), (INT
)(SHORT
)HIWORD(lParam
) );
2153 case CB_SETEXTENDEDUI
:
2154 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
2157 lphc
->wState
|= CBF_EUI
;
2158 else lphc
->wState
&= ~CBF_EUI
;
2160 case CB_GETEXTENDEDUI
:
2161 return (lphc
->wState
& CBF_EUI
) != 0;
2162 case CB_GETCOMBOBOXINFO
:
2163 return COMBO_GetComboBoxInfo(lphc
, (COMBOBOXINFO
*)lParam
);
2165 if( lphc
->wState
& CBF_EDIT
)
2166 return SendMessageW(lphc
->hWndEdit
, EM_LIMITTEXT
, wParam
, lParam
);
2169 if (message
>= WM_USER
)
2170 WARN("unknown msg WM_USER+%04x wp=%04lx lp=%08lx\n",
2171 message
- WM_USER
, wParam
, lParam
);
2174 return unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
) :
2175 DefWindowProcA(hwnd
, message
, wParam
, lParam
);
2178 /*************************************************************************
2179 * GetComboBoxInfo (USER32.@)
2181 BOOL WINAPI
GetComboBoxInfo(HWND hwndCombo
, /* [in] handle to combo box */
2182 PCOMBOBOXINFO pcbi
/* [in/out] combo box information */)
2184 TRACE("(%p, %p)\n", hwndCombo
, pcbi
);
2185 return SendMessageW(hwndCombo
, CB_GETCOMBOBOXINFO
, 0, (LPARAM
)pcbi
);