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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * FIXME: roll up in Netscape 3.01.
30 #include "wine/winuser16.h"
31 #include "wine/unicode.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(combo
);
40 /* bits in the dwKeyData */
41 #define KEYDATA_ALT 0x2000
42 #define KEYDATA_PREVSTATE 0x4000
45 * Additional combo box definitions
48 #define CB_NOTIFY( lphc, code ) \
49 (SendMessageW((lphc)->owner, WM_COMMAND, \
50 MAKEWPARAM(GetWindowLongA((lphc)->self,GWL_ID), (code)), (LPARAM)(lphc)->self))
52 #define CB_DISABLED( lphc ) (!IsWindowEnabled((lphc)->self))
53 #define CB_OWNERDRAWN( lphc ) ((lphc)->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE))
54 #define CB_HASSTRINGS( lphc ) ((lphc)->dwStyle & CBS_HASSTRINGS)
55 #define CB_HWND( lphc ) ((lphc)->self)
57 #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03)
62 static HBITMAP hComboBmp
= 0;
63 static UINT CBitHeight
, CBitWidth
;
66 * Look and feel dependent "constants"
69 #define COMBO_YBORDERGAP 5
70 #define COMBO_XBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 )
71 #define COMBO_YBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 )
72 #define COMBO_EDITBUTTONSPACE() ( (TWEAK_WineLook == WIN31_LOOK) ? 8 : 0 )
73 #define EDIT_CONTROL_PADDING() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 1 )
75 static LRESULT WINAPI
ComboWndProcA( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
76 static LRESULT WINAPI
ComboWndProcW( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
78 /*********************************************************************
79 * combo class descriptor
81 const struct builtin_class_descr COMBO_builtin_class
=
83 "ComboBox", /* name */
84 CS_GLOBALCLASS
| CS_PARENTDC
| CS_DBLCLKS
, /* style */
85 ComboWndProcA
, /* procA */
86 ComboWndProcW
, /* procW */
87 sizeof(HEADCOMBO
*), /* extra */
88 IDC_ARROW
, /* cursor */
93 /***********************************************************************
96 * Load combo button bitmap.
98 static BOOL
COMBO_Init()
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 SetWindowLongA( hwnd
, 0, (LONG
)lphc
);
142 /* some braindead apps do try to use scrollbar/border flags */
144 lphc
->dwStyle
= style
& ~(WS_BORDER
| WS_HSCROLL
| WS_VSCROLL
);
145 SetWindowLongA( 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 SetWindowLongA( hwnd
, GWL_EXSTYLE
,
152 GetWindowLongA( hwnd
, GWL_EXSTYLE
) & ~WS_EX_CLIENTEDGE
);
154 if( !(style
& (CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
)) )
155 lphc
->dwStyle
|= CBS_HASSTRINGS
;
156 if( !(GetWindowLongA( 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 SetWindowLongA( 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 13 dialog units.
193 * This height was determined through experimentation.
195 static INT
CBGetTextAreaHeight(
201 if( lphc
->editHeight
) /* explicitly set height */
203 iTextItemHeight
= lphc
->editHeight
;
208 HDC hDC
= GetDC(hwnd
);
213 hPrevFont
= SelectObject( hDC
, lphc
->hFont
);
215 GetTextMetricsW(hDC
, &tm
);
217 baseUnitY
= tm
.tmHeight
;
220 SelectObject( hDC
, hPrevFont
);
222 ReleaseDC(hwnd
, hDC
);
224 iTextItemHeight
= ((13 * baseUnitY
) / 8);
227 * This "formula" calculates the height of the complete control.
228 * To calculate the height of the text area, we have to remove the
231 iTextItemHeight
-= 2*COMBO_YBORDERSIZE();
235 * Check the ownerdraw case if we haven't asked the parent the size
238 if ( CB_OWNERDRAWN(lphc
) &&
239 (lphc
->wState
& CBF_MEASUREITEM
) )
241 MEASUREITEMSTRUCT measureItem
;
243 INT originalItemHeight
= iTextItemHeight
;
244 UINT id
= GetWindowLongA( lphc
->self
, GWL_ID
);
247 * We use the client rect for the width of the item.
249 GetClientRect(hwnd
, &clientRect
);
251 lphc
->wState
&= ~CBF_MEASUREITEM
;
254 * Send a first one to measure the size of the text area
256 measureItem
.CtlType
= ODT_COMBOBOX
;
257 measureItem
.CtlID
= id
;
258 measureItem
.itemID
= -1;
259 measureItem
.itemWidth
= clientRect
.right
;
260 measureItem
.itemHeight
= iTextItemHeight
- 6; /* ownerdrawn cb is taller */
261 measureItem
.itemData
= 0;
262 SendMessageW(lphc
->owner
, WM_MEASUREITEM
, id
, (LPARAM
)&measureItem
);
263 iTextItemHeight
= 6 + measureItem
.itemHeight
;
266 * Send a second one in the case of a fixed ownerdraw list to calculate the
267 * size of the list items. (we basically do this on behalf of the listbox)
269 if (lphc
->dwStyle
& CBS_OWNERDRAWFIXED
)
271 measureItem
.CtlType
= ODT_COMBOBOX
;
272 measureItem
.CtlID
= id
;
273 measureItem
.itemID
= 0;
274 measureItem
.itemWidth
= clientRect
.right
;
275 measureItem
.itemHeight
= originalItemHeight
;
276 measureItem
.itemData
= 0;
277 SendMessageW(lphc
->owner
, WM_MEASUREITEM
, id
, (LPARAM
)&measureItem
);
278 lphc
->fixedOwnerDrawHeight
= measureItem
.itemHeight
;
282 * Keep the size for the next time
284 lphc
->editHeight
= iTextItemHeight
;
287 return iTextItemHeight
;
290 /***********************************************************************
293 * The dummy resize is used for listboxes that have a popup to trigger
294 * a re-arranging of the contents of the combobox and the recalculation
295 * of the size of the "real" control window.
297 static void CBForceDummyResize(
303 newComboHeight
= CBGetTextAreaHeight(lphc
->self
,lphc
) + 2*COMBO_YBORDERSIZE();
305 GetWindowRect(lphc
->self
, &windowRect
);
308 * We have to be careful, resizing a combobox also has the meaning that the
309 * dropped rect will be resized. In this case, we want to trigger a resize
310 * to recalculate layout but we don't want to change the dropped rectangle
311 * So, we pass the height of text area of control as the height.
312 * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
315 SetWindowPos( lphc
->self
,
318 windowRect
.right
- windowRect
.left
,
320 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
323 /***********************************************************************
326 * Set up component coordinates given valid lphc->RectCombo.
328 static void CBCalcPlacement(
336 * Again, start with the client rectangle.
338 GetClientRect(hwnd
, lprEdit
);
343 InflateRect(lprEdit
, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
346 * Chop off the bottom part to fit with the height of the text area.
348 lprEdit
->bottom
= lprEdit
->top
+ CBGetTextAreaHeight(hwnd
, lphc
);
351 * The button starts the same vertical position as the text area.
353 CopyRect(lprButton
, lprEdit
);
356 * If the combobox is "simple" there is no button.
358 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
359 lprButton
->left
= lprButton
->right
= lprButton
->bottom
= 0;
363 * Let's assume the combobox button is the same width as the
365 * size the button horizontally and cut-off the text area.
367 lprButton
->left
= lprButton
->right
- GetSystemMetrics(SM_CXVSCROLL
);
368 lprEdit
->right
= lprButton
->left
;
372 * In the case of a dropdown, there is an additional spacing between the
373 * text area and the button.
375 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
377 lprEdit
->right
-= COMBO_EDITBUTTONSPACE();
381 * If we have an edit control, we space it away from the borders slightly.
383 if (CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
)
385 InflateRect(lprEdit
, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING());
389 * Adjust the size of the listbox popup.
391 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
394 * Use the client rectangle to initialize the listbox rectangle
396 GetClientRect(hwnd
, lprLB
);
399 * Then, chop-off the top part.
401 lprLB
->top
= lprEdit
->bottom
+ COMBO_YBORDERSIZE();
406 * Make sure the dropped width is as large as the combobox itself.
408 if (lphc
->droppedWidth
< (lprButton
->right
+ COMBO_XBORDERSIZE()))
410 lprLB
->right
= lprLB
->left
+ (lprButton
->right
+ COMBO_XBORDERSIZE());
413 * In the case of a dropdown, the popup listbox is offset to the right.
414 * so, we want to make sure it's flush with the right side of the
417 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
418 lprLB
->right
-= COMBO_EDITBUTTONSPACE();
421 lprLB
->right
= lprLB
->left
+ lphc
->droppedWidth
;
424 TRACE("\ttext\t= (%ld,%ld-%ld,%ld)\n",
425 lprEdit
->left
, lprEdit
->top
, lprEdit
->right
, lprEdit
->bottom
);
427 TRACE("\tbutton\t= (%ld,%ld-%ld,%ld)\n",
428 lprButton
->left
, lprButton
->top
, lprButton
->right
, lprButton
->bottom
);
430 TRACE("\tlbox\t= (%ld,%ld-%ld,%ld)\n",
431 lprLB
->left
, lprLB
->top
, lprLB
->right
, lprLB
->bottom
);
434 /***********************************************************************
435 * CBGetDroppedControlRect
437 static void CBGetDroppedControlRect( LPHEADCOMBO lphc
, LPRECT lpRect
)
439 /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner
440 of the combo box and the lower right corner of the listbox */
442 GetWindowRect(lphc
->self
, lpRect
);
444 lpRect
->right
= lpRect
->left
+ lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
445 lpRect
->bottom
= lpRect
->top
+ lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
;
449 /***********************************************************************
450 * COMBO_WindowPosChanging
452 static LRESULT
COMBO_WindowPosChanging(
455 WINDOWPOS
* posChanging
)
458 * We need to override the WM_WINDOWPOSCHANGING method to handle all
459 * the non-simple comboboxes. The problem is that those controls are
460 * always the same height. We have to make sure they are not resized
463 if ( ( CB_GETTYPE(lphc
) != CBS_SIMPLE
) &&
464 ((posChanging
->flags
& SWP_NOSIZE
) == 0) )
468 newComboHeight
= CBGetTextAreaHeight(hwnd
,lphc
) +
469 2*COMBO_YBORDERSIZE();
472 * Resizing a combobox has another side effect, it resizes the dropped
473 * rectangle as well. However, it does it only if the new height for the
474 * combobox is different from the height it should have. In other words,
475 * if the application resizing the combobox only had the intention to resize
476 * the actual control, for example, to do the layout of a dialog that is
477 * resized, the height of the dropdown is not changed.
479 if (posChanging
->cy
!= newComboHeight
)
481 TRACE("posChanging->cy=%d, newComboHeight=%d, oldbot=%ld, oldtop=%ld\n",
482 posChanging
->cy
, newComboHeight
, lphc
->droppedRect
.bottom
,
483 lphc
->droppedRect
.top
);
484 lphc
->droppedRect
.bottom
= lphc
->droppedRect
.top
+ posChanging
->cy
- newComboHeight
;
486 posChanging
->cy
= newComboHeight
;
493 /***********************************************************************
496 static LRESULT
COMBO_Create( HWND hwnd
, LPHEADCOMBO lphc
, HWND hwndParent
, LONG style
,
499 static const WCHAR clbName
[] = {'C','o','m','b','o','L','B','o','x',0};
500 static const WCHAR editName
[] = {'E','d','i','t',0};
502 if( !CB_GETTYPE(lphc
) ) lphc
->dwStyle
|= CBS_SIMPLE
;
503 if( CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
) lphc
->wState
|= CBF_EDIT
;
505 lphc
->owner
= hwndParent
;
508 * The item height and dropped width are not set when the control
511 lphc
->droppedWidth
= lphc
->editHeight
= 0;
514 * The first time we go through, we want to measure the ownerdraw item
516 lphc
->wState
|= CBF_MEASUREITEM
;
518 /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
520 if( lphc
->owner
|| !(style
& WS_VISIBLE
) )
526 * Initialize the dropped rect to the size of the client area of the
527 * control and then, force all the areas of the combobox to be
530 GetClientRect( hwnd
, &lphc
->droppedRect
);
531 CBCalcPlacement(hwnd
, lphc
, &lphc
->textRect
, &lphc
->buttonRect
, &lphc
->droppedRect
);
534 * Adjust the position of the popup listbox if it's necessary
536 if ( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
538 lphc
->droppedRect
.top
= lphc
->textRect
.bottom
+ COMBO_YBORDERSIZE();
541 * If it's a dropdown, the listbox is offset
543 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
544 lphc
->droppedRect
.left
+= COMBO_EDITBUTTONSPACE();
546 ClientToScreen(hwnd
, (LPPOINT
)&lphc
->droppedRect
);
547 ClientToScreen(hwnd
, (LPPOINT
)&lphc
->droppedRect
.right
);
550 /* create listbox popup */
552 lbeStyle
= (LBS_NOTIFY
| WS_BORDER
| WS_CLIPSIBLINGS
| WS_CHILD
) |
553 (style
& (WS_VSCROLL
| CBS_OWNERDRAWFIXED
| CBS_OWNERDRAWVARIABLE
));
555 if( lphc
->dwStyle
& CBS_SORT
)
556 lbeStyle
|= LBS_SORT
;
557 if( lphc
->dwStyle
& CBS_HASSTRINGS
)
558 lbeStyle
|= LBS_HASSTRINGS
;
559 if( lphc
->dwStyle
& CBS_NOINTEGRALHEIGHT
)
560 lbeStyle
|= LBS_NOINTEGRALHEIGHT
;
561 if( lphc
->dwStyle
& CBS_DISABLENOSCROLL
)
562 lbeStyle
|= LBS_DISABLENOSCROLL
;
564 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
) /* child listbox */
566 lbeStyle
|= WS_VISIBLE
;
569 * In win 95 look n feel, the listbox in the simple combobox has
570 * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
572 if (TWEAK_WineLook
> WIN31_LOOK
)
574 lbeStyle
&= ~WS_BORDER
;
575 lbeExStyle
|= WS_EX_CLIENTEDGE
;
580 lphc
->hWndLBox
= CreateWindowExW(lbeExStyle
, clbName
, NULL
, lbeStyle
,
581 lphc
->droppedRect
.left
,
582 lphc
->droppedRect
.top
,
583 lphc
->droppedRect
.right
- lphc
->droppedRect
.left
,
584 lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
,
585 hwnd
, (HMENU
)ID_CB_LISTBOX
,
586 (HINSTANCE
)GetWindowLongA( hwnd
, GWL_HINSTANCE
), lphc
);
588 lphc
->hWndLBox
= CreateWindowExA(lbeExStyle
, "ComboLBox", NULL
, lbeStyle
,
589 lphc
->droppedRect
.left
,
590 lphc
->droppedRect
.top
,
591 lphc
->droppedRect
.right
- lphc
->droppedRect
.left
,
592 lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
,
593 hwnd
, (HMENU
)ID_CB_LISTBOX
,
594 (HINSTANCE
)GetWindowLongA( hwnd
, GWL_HINSTANCE
), lphc
);
599 lbeStyle
= WS_CHILD
| WS_VISIBLE
| ES_NOHIDESEL
| ES_LEFT
| ES_COMBO
;
602 * In Win95 look, the border fo the edit control is
603 * provided by the combobox
605 if (TWEAK_WineLook
== WIN31_LOOK
)
606 lbeStyle
|= WS_BORDER
;
608 if( lphc
->wState
& CBF_EDIT
)
610 if( lphc
->dwStyle
& CBS_OEMCONVERT
)
611 lbeStyle
|= ES_OEMCONVERT
;
612 if( lphc
->dwStyle
& CBS_AUTOHSCROLL
)
613 lbeStyle
|= ES_AUTOHSCROLL
;
614 if( lphc
->dwStyle
& CBS_LOWERCASE
)
615 lbeStyle
|= ES_LOWERCASE
;
616 else if( lphc
->dwStyle
& CBS_UPPERCASE
)
617 lbeStyle
|= ES_UPPERCASE
;
619 if (!IsWindowEnabled(hwnd
)) lbeStyle
|= WS_DISABLED
;
622 lphc
->hWndEdit
= CreateWindowExW(0, editName
, NULL
, lbeStyle
,
623 lphc
->textRect
.left
, lphc
->textRect
.top
,
624 lphc
->textRect
.right
- lphc
->textRect
.left
,
625 lphc
->textRect
.bottom
- lphc
->textRect
.top
,
626 hwnd
, (HMENU
)ID_CB_EDIT
,
627 (HINSTANCE
)GetWindowLongA( hwnd
, GWL_HINSTANCE
), NULL
);
629 lphc
->hWndEdit
= CreateWindowExA(0, "Edit", NULL
, lbeStyle
,
630 lphc
->textRect
.left
, lphc
->textRect
.top
,
631 lphc
->textRect
.right
- lphc
->textRect
.left
,
632 lphc
->textRect
.bottom
- lphc
->textRect
.top
,
633 hwnd
, (HMENU
)ID_CB_EDIT
,
634 (HINSTANCE
)GetWindowLongA( hwnd
, GWL_HINSTANCE
), NULL
);
636 if( !lphc
->hWndEdit
)
642 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
644 /* Now do the trick with parent */
645 SetParent(lphc
->hWndLBox
, HWND_DESKTOP
);
647 * If the combo is a dropdown, we must resize the control
648 * to fit only the text area and button. To do this,
649 * we send a dummy resize and the WM_WINDOWPOSCHANGING message
650 * will take care of setting the height for us.
652 CBForceDummyResize(lphc
);
655 TRACE("init done\n");
658 ERR("edit control failure.\n");
659 } else ERR("listbox failure.\n");
660 } else ERR("no owner for visible combo.\n");
662 /* CreateWindow() will send WM_NCDESTROY to cleanup */
667 /***********************************************************************
670 * Paint combo button (normal, pressed, and disabled states).
672 static void CBPaintButton(
677 if( lphc
->wState
& CBF_NOREDRAW
)
680 if (TWEAK_WineLook
== WIN31_LOOK
)
686 COLORREF oldTextColor
, oldBkColor
;
689 hPrevBrush
= SelectObject(hdc
, GetSysColorBrush(COLOR_BTNFACE
));
692 * Draw the button background
697 rectButton
.right
-rectButton
.left
,
698 rectButton
.bottom
-rectButton
.top
,
701 if( (bBool
= lphc
->wState
& CBF_BUTTONDOWN
) )
703 DrawEdge( hdc
, &rectButton
, EDGE_SUNKEN
, BF_RECT
);
707 DrawEdge( hdc
, &rectButton
, EDGE_RAISED
, BF_RECT
);
711 * Remove the edge of the button from the rectangle
712 * and calculate the position of the bitmap.
714 InflateRect( &rectButton
, -2, -2);
716 x
= (rectButton
.left
+ rectButton
.right
- CBitWidth
) >> 1;
717 y
= (rectButton
.top
+ rectButton
.bottom
- CBitHeight
) >> 1;
720 hMemDC
= CreateCompatibleDC( hdc
);
721 SelectObject( hMemDC
, hComboBmp
);
722 oldTextColor
= SetTextColor( hdc
, GetSysColor(COLOR_BTNFACE
) );
723 oldBkColor
= SetBkColor( hdc
, CB_DISABLED(lphc
) ? RGB(128,128,128) :
725 BitBlt( hdc
, x
, y
, CBitWidth
, CBitHeight
, hMemDC
, 0, 0, SRCCOPY
);
726 SetBkColor( hdc
, oldBkColor
);
727 SetTextColor( hdc
, oldTextColor
);
729 SelectObject( hdc
, hPrevBrush
);
733 UINT buttonState
= DFCS_SCROLLCOMBOBOX
;
735 if (lphc
->wState
& CBF_BUTTONDOWN
)
737 buttonState
|= DFCS_PUSHED
;
740 if (CB_DISABLED(lphc
))
742 buttonState
|= DFCS_INACTIVE
;
745 DrawFrameControl(hdc
,
752 /***********************************************************************
755 * Paint CBS_DROPDOWNLIST text field / update edit control contents.
757 static void CBPaintText(
765 if( lphc
->wState
& CBF_NOREDRAW
) return;
769 /* follow Windows combobox that sends a bunch of text
770 * inquiries to its listbox while processing WM_PAINT. */
772 if( (id
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0) ) != LB_ERR
)
774 size
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, id
, 0);
776 FIXME("LB_ERR probably not handled yet\n");
777 if( (pText
= HeapAlloc( GetProcessHeap(), 0, (size
+ 1) * sizeof(WCHAR
))) )
779 /* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */
780 size
=SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, (WPARAM
)id
, (LPARAM
)pText
);
781 pText
[size
] = '\0'; /* just in case */
785 if( !CB_OWNERDRAWN(lphc
) )
788 if( lphc
->wState
& CBF_EDIT
)
790 static const WCHAR empty_stringW
[] = { 0 };
791 if( CB_HASSTRINGS(lphc
) ) SetWindowTextW( lphc
->hWndEdit
, pText
? pText
: empty_stringW
);
792 if( lphc
->wState
& CBF_FOCUSED
)
793 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, (LPARAM
)(-1));
795 else /* paint text field ourselves */
797 UINT itemState
= ODS_COMBOBOXEDIT
;
798 HFONT hPrevFont
= (lphc
->hFont
) ? SelectObject(hdc
, lphc
->hFont
) : 0;
801 * Give ourselves some space.
803 InflateRect( &rectEdit
, -1, -1 );
805 if( CB_OWNERDRAWN(lphc
) )
809 UINT ctlid
= GetWindowLongA( lphc
->self
, GWL_ID
);
811 /* setup state for DRAWITEM message. Owner will highlight */
812 if ( (lphc
->wState
& CBF_FOCUSED
) &&
813 !(lphc
->wState
& CBF_DROPPED
) )
814 itemState
|= ODS_SELECTED
| ODS_FOCUS
;
817 * Save the current clip region.
818 * To retrieve the clip region, we need to create one "dummy"
821 clipRegion
= CreateRectRgnIndirect(&rectEdit
);
823 if (GetClipRgn(hdc
, clipRegion
)!=1)
825 DeleteObject(clipRegion
);
829 if (!IsWindowEnabled(lphc
->self
) & WS_DISABLED
) itemState
|= ODS_DISABLED
;
831 dis
.CtlType
= ODT_COMBOBOX
;
833 dis
.hwndItem
= lphc
->self
;
834 dis
.itemAction
= ODA_DRAWENTIRE
;
836 dis
.itemState
= itemState
;
838 dis
.rcItem
= rectEdit
;
839 dis
.itemData
= SendMessageW(lphc
->hWndLBox
, LB_GETITEMDATA
,
843 * Clip the DC and have the parent draw the item.
845 IntersectClipRect(hdc
,
846 rectEdit
.left
, rectEdit
.top
,
847 rectEdit
.right
, rectEdit
.bottom
);
849 SendMessageW(lphc
->owner
, WM_DRAWITEM
, ctlid
, (LPARAM
)&dis
);
852 * Reset the clipping region.
854 SelectClipRgn(hdc
, clipRegion
);
858 static const WCHAR empty_stringW
[] = { 0 };
860 if ( (lphc
->wState
& CBF_FOCUSED
) &&
861 !(lphc
->wState
& CBF_DROPPED
) ) {
864 FillRect( hdc
, &rectEdit
, GetSysColorBrush(COLOR_HIGHLIGHT
) );
865 SetBkColor( hdc
, GetSysColor( COLOR_HIGHLIGHT
) );
866 SetTextColor( hdc
, GetSysColor( COLOR_HIGHLIGHTTEXT
) );
872 ETO_OPAQUE
| ETO_CLIPPED
,
874 pText
? pText
: empty_stringW
, size
, NULL
);
876 if(lphc
->wState
& CBF_FOCUSED
&& !(lphc
->wState
& CBF_DROPPED
))
877 DrawFocusRect( hdc
, &rectEdit
);
881 SelectObject(hdc
, hPrevFont
);
884 HeapFree( GetProcessHeap(), 0, pText
);
887 /***********************************************************************
890 static void CBPaintBorder(
897 if (CB_GETTYPE(lphc
) != CBS_SIMPLE
)
899 GetClientRect(hwnd
, &clientRect
);
903 CopyRect(&clientRect
, &lphc
->textRect
);
905 InflateRect(&clientRect
, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
906 InflateRect(&clientRect
, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
909 DrawEdge(hdc
, &clientRect
, EDGE_SUNKEN
, BF_RECT
);
912 /***********************************************************************
913 * COMBO_PrepareColors
915 * This method will sent the appropriate WM_CTLCOLOR message to
916 * prepare and setup the colors for the combo's DC.
918 * It also returns the brush to use for the background.
920 static HBRUSH
COMBO_PrepareColors(
927 * Get the background brush for this control.
929 if (CB_DISABLED(lphc
))
931 hBkgBrush
= (HBRUSH
)SendMessageW(lphc
->owner
, WM_CTLCOLORSTATIC
,
932 (WPARAM
)hDC
, (LPARAM
)lphc
->self
);
935 * We have to change the text color since WM_CTLCOLORSTATIC will
936 * set it to the "enabled" color. This is the same behavior as the
939 SetTextColor(hDC
, GetSysColor(COLOR_GRAYTEXT
));
943 if (lphc
->wState
& CBF_EDIT
)
945 hBkgBrush
= (HBRUSH
)SendMessageW(lphc
->owner
, WM_CTLCOLOREDIT
,
946 (WPARAM
)hDC
, (LPARAM
)lphc
->self
);
950 hBkgBrush
= (HBRUSH
)SendMessageW(lphc
->owner
, WM_CTLCOLORLISTBOX
,
951 (WPARAM
)hDC
, (LPARAM
)lphc
->self
);
959 hBkgBrush
= GetSysColorBrush(COLOR_WINDOW
);
964 /***********************************************************************
965 * COMBO_EraseBackground
967 static LRESULT
COMBO_EraseBackground(
975 if(lphc
->wState
& CBF_EDIT
)
978 hDC
= (hParamDC
) ? hParamDC
981 * Retrieve the background brush
983 hBkgBrush
= COMBO_PrepareColors(lphc
, hDC
);
985 FillRect(hDC
, &lphc
->textRect
, hBkgBrush
);
988 ReleaseDC(hwnd
, hDC
);
993 /***********************************************************************
996 static LRESULT
COMBO_Paint(LPHEADCOMBO lphc
, HDC hParamDC
)
1001 hDC
= (hParamDC
) ? hParamDC
1002 : BeginPaint( lphc
->self
, &ps
);
1004 TRACE("hdc=%p\n", hDC
);
1006 if( hDC
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1008 HBRUSH hPrevBrush
, hBkgBrush
;
1011 * Retrieve the background brush and select it in the
1014 hBkgBrush
= COMBO_PrepareColors(lphc
, hDC
);
1016 hPrevBrush
= SelectObject( hDC
, hBkgBrush
);
1019 * In non 3.1 look, there is a sunken border on the combobox
1021 if (TWEAK_WineLook
!= WIN31_LOOK
)
1023 CBPaintBorder(lphc
->self
, lphc
, hDC
);
1026 if( !IsRectEmpty(&lphc
->buttonRect
) )
1028 CBPaintButton(lphc
, hDC
, lphc
->buttonRect
);
1031 /* paint the edit control padding area */
1032 if (CB_GETTYPE(lphc
) != CBS_DROPDOWNLIST
)
1034 RECT rPadEdit
= lphc
->textRect
;
1036 InflateRect(&rPadEdit
, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
1038 FrameRect( hDC
, &rPadEdit
, GetSysColorBrush(COLOR_WINDOW
) );
1041 if( !(lphc
->wState
& CBF_EDIT
) )
1044 * The text area has a border only in Win 3.1 look.
1046 if (TWEAK_WineLook
== WIN31_LOOK
)
1048 HPEN hPrevPen
= SelectObject( hDC
, SYSCOLOR_GetPen(COLOR_WINDOWFRAME
) );
1051 lphc
->textRect
.left
, lphc
->textRect
.top
,
1052 lphc
->textRect
.right
- 1, lphc
->textRect
.bottom
- 1);
1054 SelectObject( hDC
, hPrevPen
);
1057 CBPaintText( lphc
, hDC
, lphc
->textRect
);
1061 SelectObject( hDC
, hPrevBrush
);
1065 EndPaint(lphc
->self
, &ps
);
1070 /***********************************************************************
1073 * Select listbox entry according to the contents of the edit control.
1075 static INT
CBUpdateLBox( LPHEADCOMBO lphc
, BOOL bSelect
)
1078 LPWSTR pText
= NULL
;
1081 length
= SendMessageW( lphc
->hWndEdit
, WM_GETTEXTLENGTH
, 0, 0 );
1084 pText
= HeapAlloc( GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
));
1086 TRACE("\t edit text length %i\n", length
);
1090 if( length
) GetWindowTextW( lphc
->hWndEdit
, pText
, length
+ 1);
1091 else pText
[0] = '\0';
1092 idx
= SendMessageW(lphc
->hWndLBox
, LB_FINDSTRING
,
1093 (WPARAM
)(-1), (LPARAM
)pText
);
1094 HeapFree( GetProcessHeap(), 0, pText
);
1097 SendMessageW(lphc
->hWndLBox
, LB_SETCURSEL
, (WPARAM
)(bSelect
? idx
: -1), 0);
1099 /* probably superfluous but Windows sends this too */
1100 SendMessageW(lphc
->hWndLBox
, LB_SETCARETINDEX
, (WPARAM
)(idx
< 0 ? 0 : idx
), 0);
1101 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
, (WPARAM
)(idx
< 0 ? 0 : idx
), 0);
1106 /***********************************************************************
1109 * Copy a listbox entry to the edit control.
1111 static void CBUpdateEdit( LPHEADCOMBO lphc
, INT index
)
1114 LPWSTR pText
= NULL
;
1115 static const WCHAR empty_stringW
[] = { 0 };
1117 TRACE("\t %i\n", index
);
1119 if( index
>= 0 ) /* got an entry */
1121 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, (WPARAM
)index
, 0);
1122 if( length
!= LB_ERR
)
1124 if( (pText
= HeapAlloc( GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
))) )
1126 SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
,
1127 (WPARAM
)index
, (LPARAM
)pText
);
1132 lphc
->wState
|= (CBF_NOEDITNOTIFY
| CBF_NOLBSELECT
);
1133 SendMessageW(lphc
->hWndEdit
, WM_SETTEXT
, 0, pText
? (LPARAM
)pText
: (LPARAM
)empty_stringW
);
1134 lphc
->wState
&= ~(CBF_NOEDITNOTIFY
| CBF_NOLBSELECT
);
1136 if( lphc
->wState
& CBF_FOCUSED
)
1137 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, (LPARAM
)(-1));
1140 HeapFree( GetProcessHeap(), 0, pText
);
1143 /***********************************************************************
1146 * Show listbox popup.
1148 static void CBDropDown( LPHEADCOMBO lphc
)
1154 TRACE("[%p]: drop down\n", lphc
->self
);
1156 CB_NOTIFY( lphc
, CBN_DROPDOWN
);
1160 lphc
->wState
|= CBF_DROPPED
;
1161 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1163 lphc
->droppedIndex
= CBUpdateLBox( lphc
, TRUE
);
1165 /* Update edit only if item is in the list */
1166 if( !(lphc
->wState
& CBF_CAPTURE
) && lphc
->droppedIndex
>= 0)
1167 CBUpdateEdit( lphc
, lphc
->droppedIndex
);
1171 lphc
->droppedIndex
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1173 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
,
1174 (WPARAM
)(lphc
->droppedIndex
== LB_ERR
? 0 : lphc
->droppedIndex
), 0 );
1175 SendMessageW(lphc
->hWndLBox
, LB_CARETON
, 0, 0);
1178 /* now set popup position */
1179 GetWindowRect( lphc
->self
, &rect
);
1182 * If it's a dropdown, the listbox is offset
1184 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1185 rect
.left
+= COMBO_EDITBUTTONSPACE();
1187 /* if the dropped height is greater than the total height of the dropped
1188 items list, then force the drop down list height to be the total height
1189 of the items in the dropped list */
1191 /* And Remove any extra space (Best Fit) */
1192 nDroppedHeight
= lphc
->droppedRect
.bottom
- lphc
->droppedRect
.top
;
1193 /* if listbox length has been set directly by its handle */
1194 GetWindowRect(lphc
->hWndLBox
, &r
);
1195 if (nDroppedHeight
< r
.bottom
- r
.top
)
1196 nDroppedHeight
= r
.bottom
- r
.top
;
1197 nItems
= (int)SendMessageW(lphc
->hWndLBox
, LB_GETCOUNT
, 0, 0);
1204 nIHeight
= (int)SendMessageW(lphc
->hWndLBox
, LB_GETITEMHEIGHT
, 0, 0);
1206 nHeight
= nIHeight
*nItems
;
1208 if (nHeight
< nDroppedHeight
- COMBO_YBORDERSIZE())
1209 nDroppedHeight
= nHeight
+ COMBO_YBORDERSIZE();
1211 if (nDroppedHeight
< nIHeight
)
1214 nDroppedHeight
= (nItems
+1)*nIHeight
;
1216 nDroppedHeight
= 6*nIHeight
;
1220 /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/
1221 if( (rect
.bottom
+ nDroppedHeight
) >= GetSystemMetrics( SM_CYSCREEN
) )
1222 rect
.bottom
= rect
.top
- nDroppedHeight
;
1224 SetWindowPos( lphc
->hWndLBox
, HWND_TOP
, rect
.left
, rect
.bottom
,
1225 lphc
->droppedRect
.right
- lphc
->droppedRect
.left
,
1227 SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
1230 if( !(lphc
->wState
& CBF_NOREDRAW
) )
1231 RedrawWindow( lphc
->self
, NULL
, 0, RDW_INVALIDATE
|
1232 RDW_ERASE
| RDW_UPDATENOW
| RDW_NOCHILDREN
);
1234 EnableWindow( lphc
->hWndLBox
, TRUE
);
1235 if (GetCapture() != lphc
->self
)
1236 SetCapture(lphc
->hWndLBox
);
1239 /***********************************************************************
1242 * Hide listbox popup.
1244 static void CBRollUp( LPHEADCOMBO lphc
, BOOL ok
, BOOL bButton
)
1246 HWND hWnd
= lphc
->self
;
1248 TRACE("[%p]: sel ok? [%i] dropped? [%i]\n",
1249 lphc
->self
, (INT
)ok
, (INT
)(lphc
->wState
& CBF_DROPPED
));
1251 CB_NOTIFY( lphc
, (ok
) ? CBN_SELENDOK
: CBN_SELENDCANCEL
);
1253 if( IsWindow( hWnd
) && CB_GETTYPE(lphc
) != CBS_SIMPLE
)
1256 if( lphc
->wState
& CBF_DROPPED
)
1260 lphc
->wState
&= ~CBF_DROPPED
;
1261 ShowWindow( lphc
->hWndLBox
, SW_HIDE
);
1263 if(GetCapture() == lphc
->hWndLBox
)
1268 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1270 rect
= lphc
->buttonRect
;
1281 rect
= lphc
->textRect
;
1286 if( bButton
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1287 RedrawWindow( hWnd
, &rect
, 0, RDW_INVALIDATE
|
1288 RDW_ERASE
| RDW_UPDATENOW
| RDW_NOCHILDREN
);
1289 CB_NOTIFY( lphc
, CBN_CLOSEUP
);
1294 /***********************************************************************
1297 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
1299 BOOL
COMBO_FlipListbox( LPHEADCOMBO lphc
, BOOL ok
, BOOL bRedrawButton
)
1301 if( lphc
->wState
& CBF_DROPPED
)
1303 CBRollUp( lphc
, ok
, bRedrawButton
);
1311 /***********************************************************************
1314 static void CBRepaintButton( LPHEADCOMBO lphc
)
1316 InvalidateRect(lphc
->self
, &lphc
->buttonRect
, TRUE
);
1317 UpdateWindow(lphc
->self
);
1320 /***********************************************************************
1323 static void COMBO_SetFocus( LPHEADCOMBO lphc
)
1325 if( !(lphc
->wState
& CBF_FOCUSED
) )
1327 if( CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
)
1328 SendMessageW(lphc
->hWndLBox
, LB_CARETON
, 0, 0);
1330 /* This is wrong. Message sequences seem to indicate that this
1331 is set *after* the notify. */
1332 /* lphc->wState |= CBF_FOCUSED; */
1334 if( !(lphc
->wState
& CBF_EDIT
) )
1335 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1337 CB_NOTIFY( lphc
, CBN_SETFOCUS
);
1338 lphc
->wState
|= CBF_FOCUSED
;
1342 /***********************************************************************
1345 static void COMBO_KillFocus( LPHEADCOMBO lphc
)
1347 HWND hWnd
= lphc
->self
;
1349 if( lphc
->wState
& CBF_FOCUSED
)
1351 CBRollUp( lphc
, FALSE
, TRUE
);
1352 if( IsWindow( hWnd
) )
1354 if( CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
)
1355 SendMessageW(lphc
->hWndLBox
, LB_CARETOFF
, 0, 0);
1357 lphc
->wState
&= ~CBF_FOCUSED
;
1360 if( !(lphc
->wState
& CBF_EDIT
) )
1361 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1363 CB_NOTIFY( lphc
, CBN_KILLFOCUS
);
1368 /***********************************************************************
1371 static LRESULT
COMBO_Command( LPHEADCOMBO lphc
, WPARAM wParam
, HWND hWnd
)
1373 if ( lphc
->wState
& CBF_EDIT
&& lphc
->hWndEdit
== hWnd
)
1375 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1377 switch( HIWORD(wParam
) >> 8 )
1379 case (EN_SETFOCUS
>> 8):
1381 TRACE("[%p]: edit [%p] got focus\n", lphc
->self
, lphc
->hWndEdit
);
1383 COMBO_SetFocus( lphc
);
1386 case (EN_KILLFOCUS
>> 8):
1388 TRACE("[%p]: edit [%p] lost focus\n", lphc
->self
, lphc
->hWndEdit
);
1390 /* NOTE: it seems that Windows' edit control sends an
1391 * undocumented message WM_USER + 0x1B instead of this
1392 * notification (only when it happens to be a part of
1393 * the combo). ?? - AK.
1396 COMBO_KillFocus( lphc
);
1400 case (EN_CHANGE
>> 8):
1402 * In some circumstances (when the selection of the combobox
1403 * is changed for example) we don't wans the EN_CHANGE notification
1404 * to be forwarded to the parent of the combobox. This code
1405 * checks a flag that is set in these occasions and ignores the
1408 if (lphc
->wState
& CBF_NOLBSELECT
)
1410 lphc
->wState
&= ~CBF_NOLBSELECT
;
1414 CBUpdateLBox( lphc
, lphc
->wState
& CBF_DROPPED
);
1417 if (!(lphc
->wState
& CBF_NOEDITNOTIFY
))
1418 CB_NOTIFY( lphc
, CBN_EDITCHANGE
);
1421 case (EN_UPDATE
>> 8):
1422 if (!(lphc
->wState
& CBF_NOEDITNOTIFY
))
1423 CB_NOTIFY( lphc
, CBN_EDITUPDATE
);
1426 case (EN_ERRSPACE
>> 8):
1427 CB_NOTIFY( lphc
, CBN_ERRSPACE
);
1430 else if( lphc
->hWndLBox
== hWnd
)
1432 switch( HIWORD(wParam
) )
1435 CB_NOTIFY( lphc
, CBN_ERRSPACE
);
1439 CB_NOTIFY( lphc
, CBN_DBLCLK
);
1445 TRACE("[%p]: lbox selection change [%x]\n", lphc
->self
, lphc
->wState
);
1447 if( HIWORD(wParam
) == LBN_SELCHANGE
)
1449 if( lphc
->wState
& CBF_EDIT
)
1451 INT index
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1452 lphc
->wState
|= CBF_NOLBSELECT
;
1453 CBUpdateEdit( lphc
, index
);
1454 /* select text in edit, as Windows does */
1455 SendMessageW(lphc
->hWndEdit
, EM_SETSEL
, 0, (LPARAM
)(-1));
1458 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1461 /* do not roll up if selection is being tracked
1462 * by arrowkeys in the dropdown listbox */
1463 if( ((lphc
->wState
& CBF_DROPPED
) && !(lphc
->wState
& CBF_NOROLLUP
)) )
1465 CBRollUp( lphc
, (HIWORD(wParam
) == LBN_SELCHANGE
), TRUE
);
1467 else lphc
->wState
&= ~CBF_NOROLLUP
;
1469 CB_NOTIFY( lphc
, CBN_SELCHANGE
);
1475 /* nothing to do here since ComboLBox always resets the focus to its
1476 * combo/edit counterpart */
1483 /***********************************************************************
1486 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1488 static LRESULT
COMBO_ItemOp( LPHEADCOMBO lphc
, UINT msg
, LPARAM lParam
)
1490 HWND hWnd
= lphc
->self
;
1491 UINT id
= GetWindowLongA( hWnd
, GWL_ID
);
1493 TRACE("[%p]: ownerdraw op %04x\n", lphc
->self
, msg
);
1499 DELETEITEMSTRUCT
*lpIS
= (DELETEITEMSTRUCT
*)lParam
;
1500 lpIS
->CtlType
= ODT_COMBOBOX
;
1502 lpIS
->hwndItem
= hWnd
;
1507 DRAWITEMSTRUCT
*lpIS
= (DRAWITEMSTRUCT
*)lParam
;
1508 lpIS
->CtlType
= ODT_COMBOBOX
;
1510 lpIS
->hwndItem
= hWnd
;
1513 case WM_COMPAREITEM
:
1515 COMPAREITEMSTRUCT
*lpIS
= (COMPAREITEMSTRUCT
*)lParam
;
1516 lpIS
->CtlType
= ODT_COMBOBOX
;
1518 lpIS
->hwndItem
= hWnd
;
1521 case WM_MEASUREITEM
:
1523 MEASUREITEMSTRUCT
*lpIS
= (MEASUREITEMSTRUCT
*)lParam
;
1524 lpIS
->CtlType
= ODT_COMBOBOX
;
1529 return SendMessageW(lphc
->owner
, msg
, id
, lParam
);
1533 /***********************************************************************
1536 static LRESULT
COMBO_GetTextW( LPHEADCOMBO lphc
, INT count
, LPWSTR buf
)
1540 if( lphc
->wState
& CBF_EDIT
)
1541 return SendMessageW( lphc
->hWndEdit
, WM_GETTEXT
, count
, (LPARAM
)buf
);
1543 /* get it from the listbox */
1545 if (!count
|| !buf
) return 0;
1546 if( lphc
->hWndLBox
)
1548 INT idx
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1549 if (idx
== LB_ERR
) goto error
;
1550 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, idx
, 0 );
1551 if (length
== LB_ERR
) goto error
;
1553 /* 'length' is without the terminating character */
1554 if (length
>= count
)
1556 LPWSTR lpBuffer
= HeapAlloc(GetProcessHeap(), 0, (length
+ 1) * sizeof(WCHAR
));
1557 if (!lpBuffer
) goto error
;
1558 length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)lpBuffer
);
1560 /* truncate if buffer is too short */
1561 if (length
!= LB_ERR
)
1563 lstrcpynW( buf
, lpBuffer
, count
);
1566 HeapFree( GetProcessHeap(), 0, lpBuffer
);
1568 else length
= SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)buf
);
1570 if (length
== LB_ERR
) return 0;
1574 error
: /* error - truncate string, return zero */
1580 /***********************************************************************
1583 * NOTE! LB_GETTEXT does not count terminating \0, WM_GETTEXT does.
1584 * also LB_GETTEXT might return values < 0, WM_GETTEXT doesn't.
1586 static LRESULT
COMBO_GetTextA( LPHEADCOMBO lphc
, INT count
, LPSTR buf
)
1590 if( lphc
->wState
& CBF_EDIT
)
1591 return SendMessageA( lphc
->hWndEdit
, WM_GETTEXT
, count
, (LPARAM
)buf
);
1593 /* get it from the listbox */
1595 if (!count
|| !buf
) return 0;
1596 if( lphc
->hWndLBox
)
1598 INT idx
= SendMessageA(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
1599 if (idx
== LB_ERR
) goto error
;
1600 length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, idx
, 0 );
1601 if (length
== LB_ERR
) goto error
;
1603 /* 'length' is without the terminating character */
1604 if (length
>= count
)
1606 LPSTR lpBuffer
= HeapAlloc(GetProcessHeap(), 0, (length
+ 1) );
1607 if (!lpBuffer
) goto error
;
1608 length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)lpBuffer
);
1610 /* truncate if buffer is too short */
1611 if (length
!= LB_ERR
)
1613 lstrcpynA( buf
, lpBuffer
, count
);
1616 HeapFree( GetProcessHeap(), 0, lpBuffer
);
1618 else length
= SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, idx
, (LPARAM
)buf
);
1620 if (length
== LB_ERR
) return 0;
1624 error
: /* error - truncate string, return zero */
1630 /***********************************************************************
1633 * This function sets window positions according to the updated
1634 * component placement struct.
1636 static void CBResetPos(
1642 BOOL bDrop
= (CB_GETTYPE(lphc
) != CBS_SIMPLE
);
1644 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1645 * sizing messages */
1647 if( lphc
->wState
& CBF_EDIT
)
1648 SetWindowPos( lphc
->hWndEdit
, 0,
1649 rectEdit
->left
, rectEdit
->top
,
1650 rectEdit
->right
- rectEdit
->left
,
1651 rectEdit
->bottom
- rectEdit
->top
,
1652 SWP_NOZORDER
| SWP_NOACTIVATE
| ((bDrop
) ? SWP_NOREDRAW
: 0) );
1654 SetWindowPos( lphc
->hWndLBox
, 0,
1655 rectLB
->left
, rectLB
->top
,
1656 rectLB
->right
- rectLB
->left
,
1657 rectLB
->bottom
- rectLB
->top
,
1658 SWP_NOACTIVATE
| SWP_NOZORDER
| ((bDrop
) ? SWP_NOREDRAW
: 0) );
1662 if( lphc
->wState
& CBF_DROPPED
)
1664 lphc
->wState
&= ~CBF_DROPPED
;
1665 ShowWindow( lphc
->hWndLBox
, SW_HIDE
);
1668 if( bRedraw
&& !(lphc
->wState
& CBF_NOREDRAW
) )
1669 RedrawWindow( lphc
->self
, NULL
, 0,
1670 RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
);
1675 /***********************************************************************
1678 static void COMBO_Size( LPHEADCOMBO lphc
)
1680 CBCalcPlacement(lphc
->self
,
1684 &lphc
->droppedRect
);
1686 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1690 /***********************************************************************
1693 static void COMBO_Font( LPHEADCOMBO lphc
, HFONT hFont
, BOOL bRedraw
)
1698 lphc
->hFont
= hFont
;
1701 * Propagate to owned windows.
1703 if( lphc
->wState
& CBF_EDIT
)
1704 SendMessageW(lphc
->hWndEdit
, WM_SETFONT
, (WPARAM
)hFont
, bRedraw
);
1705 SendMessageW(lphc
->hWndLBox
, WM_SETFONT
, (WPARAM
)hFont
, bRedraw
);
1708 * Redo the layout of the control.
1710 if ( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
1712 CBCalcPlacement(lphc
->self
,
1716 &lphc
->droppedRect
);
1718 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1722 CBForceDummyResize(lphc
);
1727 /***********************************************************************
1728 * COMBO_SetItemHeight
1730 static LRESULT
COMBO_SetItemHeight( LPHEADCOMBO lphc
, INT index
, INT height
)
1732 LRESULT lRet
= CB_ERR
;
1734 if( index
== -1 ) /* set text field height */
1736 if( height
< 32768 )
1738 lphc
->editHeight
= height
;
1741 * Redo the layout of the control.
1743 if ( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
1745 CBCalcPlacement(lphc
->self
,
1749 &lphc
->droppedRect
);
1751 CBResetPos( lphc
, &lphc
->textRect
, &lphc
->droppedRect
, TRUE
);
1755 CBForceDummyResize(lphc
);
1761 else if ( CB_OWNERDRAWN(lphc
) ) /* set listbox item height */
1762 lRet
= SendMessageW(lphc
->hWndLBox
, LB_SETITEMHEIGHT
,
1763 (WPARAM
)index
, (LPARAM
)height
);
1767 /***********************************************************************
1768 * COMBO_SelectString
1770 static LRESULT
COMBO_SelectString( LPHEADCOMBO lphc
, INT start
, LPARAM pText
, BOOL unicode
)
1772 INT index
= unicode
? SendMessageW(lphc
->hWndLBox
, LB_SELECTSTRING
, (WPARAM
)start
, pText
) :
1773 SendMessageA(lphc
->hWndLBox
, LB_SELECTSTRING
, (WPARAM
)start
, pText
);
1776 if( lphc
->wState
& CBF_EDIT
)
1777 CBUpdateEdit( lphc
, index
);
1780 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
1783 return (LRESULT
)index
;
1786 /***********************************************************************
1789 static void COMBO_LButtonDown( LPHEADCOMBO lphc
, LPARAM lParam
)
1793 HWND hWnd
= lphc
->self
;
1795 pt
.x
= LOWORD(lParam
);
1796 pt
.y
= HIWORD(lParam
);
1797 bButton
= PtInRect(&lphc
->buttonRect
, pt
);
1799 if( (CB_GETTYPE(lphc
) == CBS_DROPDOWNLIST
) ||
1800 (bButton
&& (CB_GETTYPE(lphc
) == CBS_DROPDOWN
)) )
1802 lphc
->wState
|= CBF_BUTTONDOWN
;
1803 if( lphc
->wState
& CBF_DROPPED
)
1805 /* got a click to cancel selection */
1807 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1808 CBRollUp( lphc
, TRUE
, FALSE
);
1809 if( !IsWindow( hWnd
) ) return;
1811 if( lphc
->wState
& CBF_CAPTURE
)
1813 lphc
->wState
&= ~CBF_CAPTURE
;
1819 /* drop down the listbox and start tracking */
1821 lphc
->wState
|= CBF_CAPTURE
;
1825 if( bButton
) CBRepaintButton( lphc
);
1829 /***********************************************************************
1832 * Release capture and stop tracking if needed.
1834 static void COMBO_LButtonUp( LPHEADCOMBO lphc
)
1836 if( lphc
->wState
& CBF_CAPTURE
)
1838 lphc
->wState
&= ~CBF_CAPTURE
;
1839 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
)
1841 INT index
= CBUpdateLBox( lphc
, TRUE
);
1842 /* Update edit only if item is in the list */
1845 lphc
->wState
|= CBF_NOLBSELECT
;
1846 CBUpdateEdit( lphc
, index
);
1847 lphc
->wState
&= ~CBF_NOLBSELECT
;
1851 SetCapture(lphc
->hWndLBox
);
1854 if( lphc
->wState
& CBF_BUTTONDOWN
)
1856 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1857 CBRepaintButton( lphc
);
1861 /***********************************************************************
1864 * Two things to do - track combo button and release capture when
1865 * pointer goes into the listbox.
1867 static void COMBO_MouseMove( LPHEADCOMBO lphc
, WPARAM wParam
, LPARAM lParam
)
1872 pt
.x
= LOWORD(lParam
);
1873 pt
.y
= HIWORD(lParam
);
1875 if( lphc
->wState
& CBF_BUTTONDOWN
)
1879 bButton
= PtInRect(&lphc
->buttonRect
, pt
);
1883 lphc
->wState
&= ~CBF_BUTTONDOWN
;
1884 CBRepaintButton( lphc
);
1888 GetClientRect( lphc
->hWndLBox
, &lbRect
);
1889 MapWindowPoints( lphc
->self
, lphc
->hWndLBox
, &pt
, 1 );
1890 if( PtInRect(&lbRect
, pt
) )
1892 lphc
->wState
&= ~CBF_CAPTURE
;
1894 if( CB_GETTYPE(lphc
) == CBS_DROPDOWN
) CBUpdateLBox( lphc
, TRUE
);
1896 /* hand over pointer tracking */
1897 SendMessageW(lphc
->hWndLBox
, WM_LBUTTONDOWN
, wParam
, lParam
);
1902 /***********************************************************************
1903 * ComboWndProc_common
1905 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm
1907 static LRESULT
ComboWndProc_common( HWND hwnd
, UINT message
,
1908 WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
1910 LPHEADCOMBO lphc
= (LPHEADCOMBO
)GetWindowLongA( hwnd
, 0 );
1912 TRACE("[%p]: msg %s wp %08x lp %08lx\n",
1913 hwnd
, SPY_GetMsgName(message
, hwnd
), wParam
, lParam
);
1915 if( lphc
|| message
== WM_NCCREATE
)
1919 /* System messages */
1923 LONG style
= unicode
? ((LPCREATESTRUCTW
)lParam
)->style
:
1924 ((LPCREATESTRUCTA
)lParam
)->style
;
1925 return COMBO_NCCreate(hwnd
, style
);
1928 COMBO_NCDestroy(lphc
);
1929 break;/* -> DefWindowProc */
1937 hwndParent
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
1938 style
= ((LPCREATESTRUCTW
)lParam
)->style
;
1942 hwndParent
= ((LPCREATESTRUCTA
)lParam
)->hwndParent
;
1943 style
= ((LPCREATESTRUCTA
)lParam
)->style
;
1945 return COMBO_Create(hwnd
, lphc
, hwndParent
, style
, unicode
);
1948 case WM_PRINTCLIENT
:
1949 if (lParam
& PRF_ERASEBKGND
)
1950 COMBO_EraseBackground(hwnd
, lphc
, (HDC
)wParam
);
1954 /* wParam may contain a valid HDC! */
1955 return COMBO_Paint(lphc
, (HDC
)wParam
);
1957 return COMBO_EraseBackground(hwnd
, lphc
, (HDC
)wParam
);
1960 LRESULT result
= DLGC_WANTARROWS
| DLGC_WANTCHARS
;
1961 if (lParam
&& (((LPMSG
)lParam
)->message
== WM_KEYDOWN
))
1963 int vk
= (int)((LPMSG
)lParam
)->wParam
;
1965 if ((vk
== VK_RETURN
|| vk
== VK_ESCAPE
) && (lphc
->wState
& CBF_DROPPED
))
1966 result
|= DLGC_WANTMESSAGE
;
1970 case WM_WINDOWPOSCHANGING
:
1971 return COMBO_WindowPosChanging(hwnd
, lphc
, (LPWINDOWPOS
)lParam
);
1972 case WM_WINDOWPOSCHANGED
:
1973 /* SetWindowPos can be called on a Combobox to resize its Listbox.
1974 * In that case, the Combobox itself will not be resized, so we won't
1975 * get a WM_SIZE. Since we still want to update the Listbox, we have to
1980 if( lphc
->hWndLBox
&&
1981 !(lphc
->wState
& CBF_NORESIZE
) ) COMBO_Size( lphc
);
1984 COMBO_Font( lphc
, (HFONT
)wParam
, (BOOL
)lParam
);
1987 return (LRESULT
)lphc
->hFont
;
1989 if( lphc
->wState
& CBF_EDIT
)
1990 SetFocus( lphc
->hWndEdit
);
1992 COMBO_SetFocus( lphc
);
1996 HWND hwndFocus
= WIN_GetFullHandle( (HWND
)wParam
);
1998 (hwndFocus
!= lphc
->hWndEdit
&& hwndFocus
!= lphc
->hWndLBox
))
1999 COMBO_KillFocus( lphc
);
2003 return COMBO_Command( lphc
, wParam
, WIN_GetFullHandle( (HWND
)lParam
) );
2005 return unicode
? COMBO_GetTextW( lphc
, wParam
, (LPWSTR
)lParam
)
2006 : COMBO_GetTextA( lphc
, wParam
, (LPSTR
)lParam
);
2008 case WM_GETTEXTLENGTH
:
2010 if ((message
== WM_GETTEXTLENGTH
) && !ISWIN31
&& !(lphc
->wState
& CBF_EDIT
))
2012 int j
= SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
2013 if (j
== -1) return 0;
2014 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, j
, 0) :
2015 SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, j
, 0);
2017 else if( lphc
->wState
& CBF_EDIT
)
2020 lphc
->wState
|= CBF_NOEDITNOTIFY
;
2021 ret
= unicode
? SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
) :
2022 SendMessageA(lphc
->hWndEdit
, message
, wParam
, lParam
);
2023 lphc
->wState
&= ~CBF_NOEDITNOTIFY
;
2030 if( lphc
->wState
& CBF_EDIT
)
2032 return unicode
? SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
) :
2033 SendMessageA(lphc
->hWndEdit
, message
, wParam
, lParam
);
2039 case WM_COMPAREITEM
:
2040 case WM_MEASUREITEM
:
2041 return COMBO_ItemOp(lphc
, message
, lParam
);
2043 if( lphc
->wState
& CBF_EDIT
)
2044 EnableWindow( lphc
->hWndEdit
, (BOOL
)wParam
);
2045 EnableWindow( lphc
->hWndLBox
, (BOOL
)wParam
);
2047 /* Force the control to repaint when the enabled state changes. */
2048 InvalidateRect(lphc
->self
, NULL
, TRUE
);
2052 lphc
->wState
&= ~CBF_NOREDRAW
;
2054 lphc
->wState
|= CBF_NOREDRAW
;
2056 if( lphc
->wState
& CBF_EDIT
)
2057 SendMessageW(lphc
->hWndEdit
, message
, wParam
, lParam
);
2058 SendMessageW(lphc
->hWndLBox
, message
, wParam
, lParam
);
2061 if( KEYDATA_ALT
& HIWORD(lParam
) )
2062 if( wParam
== VK_UP
|| wParam
== VK_DOWN
)
2063 COMBO_FlipListbox( lphc
, FALSE
, FALSE
);
2072 if ((wParam
== VK_RETURN
|| wParam
== VK_ESCAPE
) &&
2073 (lphc
->wState
& CBF_DROPPED
))
2075 CBRollUp( lphc
, wParam
== VK_RETURN
, FALSE
);
2079 if( lphc
->wState
& CBF_EDIT
)
2080 hwndTarget
= lphc
->hWndEdit
;
2082 hwndTarget
= lphc
->hWndLBox
;
2084 return unicode
? SendMessageW(hwndTarget
, message
, wParam
, lParam
) :
2085 SendMessageA(hwndTarget
, message
, wParam
, lParam
);
2087 case WM_LBUTTONDOWN
:
2088 if( !(lphc
->wState
& CBF_FOCUSED
) ) SetFocus( lphc
->self
);
2089 if( lphc
->wState
& CBF_FOCUSED
) COMBO_LButtonDown( lphc
, lParam
);
2092 COMBO_LButtonUp( lphc
);
2095 if( lphc
->wState
& CBF_CAPTURE
)
2096 COMBO_MouseMove( lphc
, wParam
, lParam
);
2100 if (wParam
& (MK_SHIFT
| MK_CONTROL
))
2101 return unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
) :
2102 DefWindowProcA(hwnd
, message
, wParam
, lParam
);
2104 if (GET_WHEEL_DELTA_WPARAM(wParam
) > 0) return SendMessageW(hwnd
, WM_KEYDOWN
, VK_UP
, 0);
2105 if (GET_WHEEL_DELTA_WPARAM(wParam
) < 0) return SendMessageW(hwnd
, WM_KEYDOWN
, VK_DOWN
, 0);
2108 /* Combo messages */
2110 case CB_ADDSTRING16
:
2111 if( CB_HASSTRINGS(lphc
) ) lParam
= (LPARAM
)MapSL(lParam
);
2114 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_ADDSTRING
, 0, lParam
) :
2115 SendMessageA(lphc
->hWndLBox
, LB_ADDSTRING
, 0, lParam
);
2116 case CB_INSERTSTRING16
:
2117 wParam
= (INT
)(INT16
)wParam
;
2118 if( CB_HASSTRINGS(lphc
) ) lParam
= (LPARAM
)MapSL(lParam
);
2120 case CB_INSERTSTRING
:
2121 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_INSERTSTRING
, wParam
, lParam
) :
2122 SendMessageA(lphc
->hWndLBox
, LB_INSERTSTRING
, wParam
, lParam
);
2123 case CB_DELETESTRING16
:
2124 case CB_DELETESTRING
:
2125 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_DELETESTRING
, wParam
, 0) :
2126 SendMessageA(lphc
->hWndLBox
, LB_DELETESTRING
, wParam
, 0);
2127 case CB_SELECTSTRING16
:
2128 wParam
= (INT
)(INT16
)wParam
;
2129 if( CB_HASSTRINGS(lphc
) ) lParam
= (LPARAM
)MapSL(lParam
);
2131 case CB_SELECTSTRING
:
2132 return COMBO_SelectString(lphc
, (INT
)wParam
, lParam
, unicode
);
2133 case CB_FINDSTRING16
:
2134 wParam
= (INT
)(INT16
)wParam
;
2135 if( CB_HASSTRINGS(lphc
) ) lParam
= (LPARAM
)MapSL(lParam
);
2138 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_FINDSTRING
, wParam
, lParam
) :
2139 SendMessageA(lphc
->hWndLBox
, LB_FINDSTRING
, wParam
, lParam
);
2140 case CB_FINDSTRINGEXACT16
:
2141 wParam
= (INT
)(INT16
)wParam
;
2142 if( CB_HASSTRINGS(lphc
) ) lParam
= (LPARAM
)MapSL(lParam
);
2144 case CB_FINDSTRINGEXACT
:
2145 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_FINDSTRINGEXACT
, wParam
, lParam
) :
2146 SendMessageA(lphc
->hWndLBox
, LB_FINDSTRINGEXACT
, wParam
, lParam
);
2147 case CB_SETITEMHEIGHT16
:
2148 wParam
= (INT
)(INT16
)wParam
; /* signed integer */
2150 case CB_SETITEMHEIGHT
:
2151 return COMBO_SetItemHeight( lphc
, (INT
)wParam
, (INT
)lParam
);
2152 case CB_GETITEMHEIGHT16
:
2153 wParam
= (INT
)(INT16
)wParam
;
2155 case CB_GETITEMHEIGHT
:
2156 if( (INT
)wParam
>= 0 ) /* listbox item */
2157 return SendMessageW(lphc
->hWndLBox
, LB_GETITEMHEIGHT
, wParam
, 0);
2158 return CBGetTextAreaHeight(hwnd
, lphc
);
2159 case CB_RESETCONTENT16
:
2160 case CB_RESETCONTENT
:
2161 SendMessageW(lphc
->hWndLBox
, LB_RESETCONTENT
, 0, 0);
2162 if( (lphc
->wState
& CBF_EDIT
) && CB_HASSTRINGS(lphc
) )
2164 static const WCHAR empty_stringW
[] = { 0 };
2165 SendMessageW(lphc
->hWndEdit
, WM_SETTEXT
, 0, (LPARAM
)empty_stringW
);
2168 InvalidateRect(lphc
->self
, NULL
, TRUE
);
2170 case CB_INITSTORAGE
:
2171 return SendMessageW(lphc
->hWndLBox
, LB_INITSTORAGE
, wParam
, lParam
);
2172 case CB_GETHORIZONTALEXTENT
:
2173 return SendMessageW(lphc
->hWndLBox
, LB_GETHORIZONTALEXTENT
, 0, 0);
2174 case CB_SETHORIZONTALEXTENT
:
2175 return SendMessageW(lphc
->hWndLBox
, LB_SETHORIZONTALEXTENT
, wParam
, 0);
2176 case CB_GETTOPINDEX
:
2177 return SendMessageW(lphc
->hWndLBox
, LB_GETTOPINDEX
, 0, 0);
2179 return SendMessageW(lphc
->hWndLBox
, LB_GETLOCALE
, 0, 0);
2181 return SendMessageW(lphc
->hWndLBox
, LB_SETLOCALE
, wParam
, 0);
2182 case CB_GETDROPPEDWIDTH
:
2183 if( lphc
->droppedWidth
)
2184 return lphc
->droppedWidth
;
2185 return lphc
->droppedRect
.right
- lphc
->droppedRect
.left
;
2186 case CB_SETDROPPEDWIDTH
:
2187 if( (CB_GETTYPE(lphc
) != CBS_SIMPLE
) &&
2188 (INT
)wParam
< 32768 ) lphc
->droppedWidth
= (INT
)wParam
;
2190 case CB_GETDROPPEDCONTROLRECT16
:
2191 lParam
= (LPARAM
)MapSL(lParam
);
2195 CBGetDroppedControlRect( lphc
, &r
);
2196 CONV_RECT32TO16( &r
, (LPRECT16
)lParam
);
2199 case CB_GETDROPPEDCONTROLRECT
:
2200 if( lParam
) CBGetDroppedControlRect(lphc
, (LPRECT
)lParam
);
2202 case CB_GETDROPPEDSTATE16
:
2203 case CB_GETDROPPEDSTATE
:
2204 return (lphc
->wState
& CBF_DROPPED
) ? TRUE
: FALSE
;
2206 lParam
= (LPARAM
)MapSL(lParam
);
2210 if(message
== CB_DIR
) message
= LB_DIR
;
2211 return unicode
? SendMessageW(lphc
->hWndLBox
, message
, wParam
, lParam
) :
2212 SendMessageA(lphc
->hWndLBox
, message
, wParam
, lParam
);
2214 case CB_SHOWDROPDOWN16
:
2215 case CB_SHOWDROPDOWN
:
2216 if( CB_GETTYPE(lphc
) != CBS_SIMPLE
)
2220 if( !(lphc
->wState
& CBF_DROPPED
) )
2224 if( lphc
->wState
& CBF_DROPPED
)
2225 CBRollUp( lphc
, FALSE
, TRUE
);
2230 return SendMessageW(lphc
->hWndLBox
, LB_GETCOUNT
, 0, 0);
2231 case CB_GETCURSEL16
:
2233 return SendMessageW(lphc
->hWndLBox
, LB_GETCURSEL
, 0, 0);
2234 case CB_SETCURSEL16
:
2235 wParam
= (INT
)(INT16
)wParam
;
2238 lParam
= SendMessageW(lphc
->hWndLBox
, LB_SETCURSEL
, wParam
, 0);
2240 SendMessageW(lphc
->hWndLBox
, LB_SETTOPINDEX
, wParam
, 0);
2242 /* no LBN_SELCHANGE in this case, update manually */
2243 if( lphc
->wState
& CBF_EDIT
)
2244 CBUpdateEdit( lphc
, (INT
)wParam
);
2246 InvalidateRect(lphc
->self
, &lphc
->textRect
, TRUE
);
2247 lphc
->wState
&= ~CBF_SELCHANGE
;
2249 case CB_GETLBTEXT16
:
2250 wParam
= (INT
)(INT16
)wParam
;
2251 lParam
= (LPARAM
)MapSL(lParam
);
2254 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXT
, wParam
, lParam
) :
2255 SendMessageA(lphc
->hWndLBox
, LB_GETTEXT
, wParam
, lParam
);
2256 case CB_GETLBTEXTLEN16
:
2257 wParam
= (INT
)(INT16
)wParam
;
2259 case CB_GETLBTEXTLEN
:
2260 return unicode
? SendMessageW(lphc
->hWndLBox
, LB_GETTEXTLEN
, wParam
, 0) :
2261 SendMessageA(lphc
->hWndLBox
, LB_GETTEXTLEN
, wParam
, 0);
2262 case CB_GETITEMDATA16
:
2263 wParam
= (INT
)(INT16
)wParam
;
2265 case CB_GETITEMDATA
:
2266 return SendMessageW(lphc
->hWndLBox
, LB_GETITEMDATA
, wParam
, 0);
2267 case CB_SETITEMDATA16
:
2268 wParam
= (INT
)(INT16
)wParam
;
2270 case CB_SETITEMDATA
:
2271 return SendMessageW(lphc
->hWndLBox
, LB_SETITEMDATA
, wParam
, lParam
);
2272 case CB_GETEDITSEL16
:
2273 wParam
= lParam
= 0; /* just in case */
2276 /* Edit checks passed parameters itself */
2277 if( lphc
->wState
& CBF_EDIT
)
2278 return SendMessageW(lphc
->hWndEdit
, EM_GETSEL
, wParam
, lParam
);
2280 case CB_SETEDITSEL16
:
2282 if( lphc
->wState
& CBF_EDIT
)
2283 return SendMessageW(lphc
->hWndEdit
, EM_SETSEL
,
2284 (INT
)(INT16
)LOWORD(lParam
), (INT
)(INT16
)HIWORD(lParam
) );
2286 case CB_SETEXTENDEDUI16
:
2287 case CB_SETEXTENDEDUI
:
2288 if( CB_GETTYPE(lphc
) == CBS_SIMPLE
)
2291 lphc
->wState
|= CBF_EUI
;
2292 else lphc
->wState
&= ~CBF_EUI
;
2294 case CB_GETEXTENDEDUI16
:
2295 case CB_GETEXTENDEDUI
:
2296 return (lphc
->wState
& CBF_EUI
) ? TRUE
: FALSE
;
2299 if (message
>= WM_USER
)
2300 WARN("unknown msg WM_USER+%04x wp=%04x lp=%08lx\n",
2301 message
- WM_USER
, wParam
, lParam
);
2304 return unicode
? DefWindowProcW(hwnd
, message
, wParam
, lParam
) :
2305 DefWindowProcA(hwnd
, message
, wParam
, lParam
);
2308 /***********************************************************************
2311 * This is just a wrapper for the real ComboWndProc which locks/unlocks
2314 static LRESULT WINAPI
ComboWndProcA( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2316 if (!IsWindow(hwnd
)) return 0;
2317 return ComboWndProc_common( hwnd
, message
, wParam
, lParam
, FALSE
);
2320 /***********************************************************************
2323 static LRESULT WINAPI
ComboWndProcW( HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
2325 if (!IsWindow(hwnd
)) return 0;
2326 return ComboWndProc_common( hwnd
, message
, wParam
, lParam
, TRUE
);
2329 /*************************************************************************
2330 * GetComboBoxInfo (USER32.@)
2332 BOOL WINAPI
GetComboBoxInfo(HWND hwndCombo
, /* [in] handle to combo box */
2333 PCOMBOBOXINFO pcbi
/* [in/out] combo box information */)