ReactOS 0.4.15-dev-7842-g558ab78
combo.c File Reference
#include <user32.h>
Include dependency graph for combo.c:

Go to the source code of this file.

Macros

#define CB_NOTIFY(lphc, code)
 
#define CB_DISABLED(lphc)   (!IsWindowEnabled((lphc)->self))
 
#define CB_OWNERDRAWN(lphc)   ((lphc)->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE))
 
#define CB_HASSTRINGS(lphc)   ((lphc)->dwStyle & CBS_HASSTRINGS)
 
#define CB_HWND(lphc)   ((lphc)->self)
 
#define CB_GETTYPE(lphc)   ((lphc)->dwStyle & (CBS_DROPDOWNLIST))
 
#define ISWIN31   (LOWORD(GetVersion()) == 0x0a03)
 
#define COMBO_YBORDERGAP   5
 
#define COMBO_XBORDERSIZE()   2
 
#define COMBO_YBORDERSIZE()   2
 
#define COMBO_EDITBUTTONSPACE()   0
 
#define EDIT_CONTROL_PADDING()   1
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (combo)
 
static BOOL COMBO_Init (void)
 
static LRESULT COMBO_NCCreate (HWND hwnd, LONG style)
 
static LRESULT COMBO_NCDestroy (LPHEADCOMBO lphc)
 
static INT CBGetTextAreaHeight (HWND hwnd, LPHEADCOMBO lphc)
 
static void CBForceDummyResize (LPHEADCOMBO lphc)
 
static void CBCalcPlacement (HWND hwnd, LPHEADCOMBO lphc, LPRECT lprEdit, LPRECT lprButton, LPRECT lprLB)
 
static void CBGetDroppedControlRect (LPHEADCOMBO lphc, LPRECT lpRect)
 
static LRESULT COMBO_Create (HWND hwnd, LPHEADCOMBO lphc, HWND hwndParent, LONG style, BOOL unicode)
 
static void CBPaintButton (LPHEADCOMBO lphc, HDC hdc, RECT rectButton)
 
static HBRUSH COMBO_PrepareColors (LPHEADCOMBO lphc, HDC hDC)
 
static void CBPaintText (LPHEADCOMBO lphc, HDC hdc_paint)
 
static void CBPaintBorder (HWND hwnd, const HEADCOMBO *lphc, HDC hdc)
 
static LRESULT COMBO_Paint (LPHEADCOMBO lphc, HDC hParamDC)
 
static INT CBUpdateLBox (LPHEADCOMBO lphc, BOOL bSelect)
 
static void CBUpdateEdit (LPHEADCOMBO lphc, INT index)
 
static void CBDropDown (LPHEADCOMBO lphc)
 
static void CBRollUp (LPHEADCOMBO lphc, BOOL ok, BOOL bButton)
 
BOOL COMBO_FlipListbox (LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton)
 
static void CBRepaintButton (LPHEADCOMBO lphc)
 
static void COMBO_SetFocus (LPHEADCOMBO lphc)
 
static void COMBO_KillFocus (LPHEADCOMBO lphc)
 
static LRESULT COMBO_Command (LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd)
 
static LRESULT COMBO_ItemOp (LPHEADCOMBO lphc, UINT msg, LPARAM lParam)
 
static LRESULT COMBO_GetTextW (LPHEADCOMBO lphc, INT count, LPWSTR buf)
 
static LRESULT COMBO_GetTextA (LPHEADCOMBO lphc, INT count, LPSTR buf)
 
static void CBResetPos (LPHEADCOMBO lphc, const RECT *rectEdit, const RECT *rectLB, BOOL bRedraw)
 
static void COMBO_Size (LPHEADCOMBO lphc)
 
static void COMBO_Font (LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw)
 
static LRESULT COMBO_SetItemHeight (LPHEADCOMBO lphc, INT index, INT height)
 
static LRESULT COMBO_SelectString (LPHEADCOMBO lphc, INT start, LPARAM pText, BOOL unicode)
 
static void COMBO_LButtonDown (LPHEADCOMBO lphc, LPARAM lParam)
 
static void COMBO_LButtonUp (LPHEADCOMBO lphc)
 
static void COMBO_MouseMove (LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam)
 
static LRESULT COMBO_GetComboBoxInfo (const HEADCOMBO *lphc, COMBOBOXINFO *pcbi)
 
static charstrdupA (LPCSTR str)
 
LRESULT WINAPI ComboWndProc_common (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
BOOL WINAPI GetComboBoxInfo (HWND hwndCombo, PCOMBOBOXINFO pcbi)
 

Variables

static HBITMAP hComboBmp = 0
 
static UINT CBitHeight
 
static UINT CBitWidth
 
static const WCHAR comboboxW [] = {'C','o','m','b','o','B','o','x',0}
 
const struct builtin_class_descr COMBO_builtin_class
 

Macro Definition Documentation

◆ CB_DISABLED

#define CB_DISABLED (   lphc)    (!IsWindowEnabled((lphc)->self))

Definition at line 36 of file combo.c.

◆ CB_GETTYPE

#define CB_GETTYPE (   lphc)    ((lphc)->dwStyle & (CBS_DROPDOWNLIST))

Definition at line 42 of file combo.c.

◆ CB_HASSTRINGS

#define CB_HASSTRINGS (   lphc)    ((lphc)->dwStyle & CBS_HASSTRINGS)

Definition at line 38 of file combo.c.

◆ CB_HWND

#define CB_HWND (   lphc)    ((lphc)->self)

Definition at line 39 of file combo.c.

◆ CB_NOTIFY

#define CB_NOTIFY (   lphc,
  code 
)
Value:
(SendMessageW((lphc)->owner, WM_COMMAND, \
MAKEWPARAM(GetWindowLongPtrW((lphc)->self,GWLP_ID), (code)), (LPARAM)(lphc)->self))
Definition: inflate.c:139
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define WM_COMMAND
Definition: winuser.h:1740
#define GWLP_ID
Definition: winuser.h:860
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Definition at line 32 of file combo.c.

◆ CB_OWNERDRAWN

#define CB_OWNERDRAWN (   lphc)    ((lphc)->dwStyle & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE))

Definition at line 37 of file combo.c.

◆ COMBO_EDITBUTTONSPACE

#define COMBO_EDITBUTTONSPACE ( )    0

Definition at line 60 of file combo.c.

◆ COMBO_XBORDERSIZE

#define COMBO_XBORDERSIZE ( )    2

Definition at line 58 of file combo.c.

◆ COMBO_YBORDERGAP

#define COMBO_YBORDERGAP   5

Definition at line 57 of file combo.c.

◆ COMBO_YBORDERSIZE

#define COMBO_YBORDERSIZE ( )    2

Definition at line 59 of file combo.c.

◆ EDIT_CONTROL_PADDING

#define EDIT_CONTROL_PADDING ( )    1

Definition at line 61 of file combo.c.

◆ ISWIN31

#define ISWIN31   (LOWORD(GetVersion()) == 0x0a03)

Definition at line 45 of file combo.c.

Function Documentation

◆ CBCalcPlacement()

static void CBCalcPlacement ( HWND  hwnd,
LPHEADCOMBO  lphc,
LPRECT  lprEdit,
LPRECT  lprButton,
LPRECT  lprLB 
)
static

Definition at line 327 of file combo.c.

333{
334 /*
335 * Again, start with the client rectangle.
336 */
337 GetClientRect(hwnd, lprEdit);
338
339 /*
340 * Remove the borders
341 */
343
344 /*
345 * Chop off the bottom part to fit with the height of the text area.
346 */
347 lprEdit->bottom = lprEdit->top + CBGetTextAreaHeight(hwnd, lphc);
348
349 /*
350 * The button starts the same vertical position as the text area.
351 */
352 CopyRect(lprButton, lprEdit);
353
354 /*
355 * If the combobox is "simple" there is no button.
356 */
357 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
358 lprButton->left = lprButton->right = lprButton->bottom = 0;
359 else
360 {
361 /*
362 * Let's assume the combobox button is the same width as the
363 * scrollbar button.
364 * size the button horizontally and cut-off the text area.
365 */
366 lprButton->left = lprButton->right - GetSystemMetrics(SM_CXVSCROLL);
367 lprEdit->right = lprButton->left;
368 }
369
370 /*
371 * In the case of a dropdown, there is an additional spacing between the
372 * text area and the button.
373 */
374 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
375 {
376 lprEdit->right -= COMBO_EDITBUTTONSPACE();
377 }
378
379 /*
380 * If we have an edit control, we space it away from the borders slightly.
381 */
382 if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST)
383 {
385 }
386
387 /*
388 * Adjust the size of the listbox popup.
389 */
390 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
391 {
392 /*
393 * Use the client rectangle to initialize the listbox rectangle
394 */
395 GetClientRect(hwnd, lprLB);
396
397 /*
398 * Then, chop-off the top part.
399 */
400 lprLB->top = lprEdit->bottom + COMBO_YBORDERSIZE();
401 }
402 else
403 {
404 /*
405 * Make sure the dropped width is as large as the combobox itself.
406 */
407 if (lphc->droppedWidth < (lprButton->right + COMBO_XBORDERSIZE()))
408 {
409 lprLB->right = lprLB->left + (lprButton->right + COMBO_XBORDERSIZE());
410
411 /*
412 * In the case of a dropdown, the popup listbox is offset to the right.
413 * so, we want to make sure it's flush with the right side of the
414 * combobox
415 */
416 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
417 lprLB->right -= COMBO_EDITBUTTONSPACE();
418 }
419 else
420 lprLB->right = lprLB->left + lphc->droppedWidth;
421 }
422
423 /* don't allow negative window width */
424 if (lprEdit->right < lprEdit->left)
425 lprEdit->right = lprEdit->left;
426
427 TRACE("\ttext\t= (%s)\n", wine_dbgstr_rect(lprEdit));
428
429 TRACE("\tbutton\t= (%s)\n", wine_dbgstr_rect(lprButton));
430
431 TRACE("\tlbox\t= (%s)\n", wine_dbgstr_rect(lprLB));
432}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define COMBO_EDITBUTTONSPACE()
Definition: combo.c:76
#define EDIT_CONTROL_PADDING()
Definition: combo.c:77
#define CB_GETTYPE(lphc)
Definition: combo.c:59
#define COMBO_YBORDERSIZE()
Definition: combo.c:75
static INT CBGetTextAreaHeight(HWND hwnd, LPHEADCOMBO lphc)
Definition: combo.c:185
#define COMBO_XBORDERSIZE()
Definition: combo.c:74
#define TRACE(s)
Definition: solgame.cpp:4
INT droppedWidth
Definition: comctl32.h:156
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
#define CBS_DROPDOWNLIST
Definition: winuser.h:284
#define SM_CXVSCROLL
Definition: winuser.h:961
#define CBS_SIMPLE
Definition: winuser.h:291
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define CBS_DROPDOWN
Definition: winuser.h:283
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
int WINAPI GetSystemMetrics(_In_ int)

◆ CBDropDown()

static void CBDropDown ( LPHEADCOMBO  lphc)
static

Definition at line 983 of file combo.c.

984{
985 HMONITOR monitor;
986 MONITORINFO mon_info;
987 RECT rect,r;
988 int nItems = 0;
989 int nDroppedHeight;
990
991 TRACE("[%p]: drop down\n", lphc->self);
992
993 CB_NOTIFY( lphc, CBN_DROPDOWN );
994
995 /* set selection */
996
997 lphc->wState |= CBF_DROPPED;
998 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
999 {
1000 lphc->droppedIndex = CBUpdateLBox( lphc, TRUE );
1001
1002 /* Update edit only if item is in the list */
1003 if( !(lphc->wState & CBF_CAPTURE) && lphc->droppedIndex >= 0)
1004 CBUpdateEdit( lphc, lphc->droppedIndex );
1005 }
1006 else
1007 {
1008 lphc->droppedIndex = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
1009
1011 (WPARAM)(lphc->droppedIndex == LB_ERR ? 0 : lphc->droppedIndex), 0);
1012 SendMessageW(lphc->hWndLBox, LB_CARETON, 0, 0);
1013 }
1014
1015 /* now set popup position */
1016 GetWindowRect( lphc->self, &rect );
1017
1018 /*
1019 * If it's a dropdown, the listbox is offset
1020 */
1021 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1022 rect.left += COMBO_EDITBUTTONSPACE();
1023
1024 /* if the dropped height is greater than the total height of the dropped
1025 items list, then force the drop down list height to be the total height
1026 of the items in the dropped list */
1027
1028 /* And Remove any extra space (Best Fit) */
1029 nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
1030 /* if listbox length has been set directly by its handle */
1031 GetWindowRect(lphc->hWndLBox, &r);
1032 if (nDroppedHeight < r.bottom - r.top)
1033 nDroppedHeight = r.bottom - r.top;
1034 nItems = (int)SendMessageW(lphc->hWndLBox, LB_GETCOUNT, 0, 0);
1035
1036 if (nItems > 0)
1037 {
1038 int nHeight;
1039 int nIHeight;
1040
1041 nIHeight = (int)SendMessageW(lphc->hWndLBox, LB_GETITEMHEIGHT, 0, 0);
1042
1043 nHeight = nIHeight*nItems;
1044
1045 if (nHeight < nDroppedHeight - COMBO_YBORDERSIZE())
1046 nDroppedHeight = nHeight + COMBO_YBORDERSIZE();
1047 }
1048
1049 r.left = rect.left;
1050 r.top = rect.bottom;
1051 r.right = r.left + lphc->droppedRect.right - lphc->droppedRect.left;
1052 r.bottom = r.top + nDroppedHeight;
1053
1054 /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/
1055 monitor = MonitorFromRect( &rect, MONITOR_DEFAULTTOPRIMARY );
1056 mon_info.cbSize = sizeof(mon_info);
1057 GetMonitorInfoW( monitor, &mon_info );
1058
1059 if (r.bottom > mon_info.rcWork.bottom)
1060 {
1061 r.top = max( rect.top - nDroppedHeight, mon_info.rcWork.top );
1062 r.bottom = min( r.top + nDroppedHeight, mon_info.rcWork.bottom );
1063 }
1064
1065 SetWindowPos( lphc->hWndLBox, HWND_TOPMOST, r.left, r.top, r.right - r.left, r.bottom - r.top,
1067
1068
1069 if( !(lphc->wState & CBF_NOREDRAW) )
1071
1072 EnableWindow( lphc->hWndLBox, TRUE );
1073 if (GetCapture() != lphc->self)
1074 SetCapture(lphc->hWndLBox);
1075}
int nItems
Definition: appswitch.c:56
#define CBF_DROPPED
Definition: controls.h:45
#define CBF_NOREDRAW
Definition: controls.h:54
#define CBF_CAPTURE
Definition: controls.h:50
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static INT CBUpdateLBox(LPHEADCOMBO lphc, BOOL bSelect)
Definition: combo.c:889
#define CB_NOTIFY(lphc, code)
Definition: combo.c:51
static void CBUpdateEdit(LPHEADCOMBO lphc, INT index)
Definition: combo.c:923
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define min(a, b)
Definition: monoChain.cc:55
HMONITOR WINAPI MonitorFromRect(LPCRECT, DWORD)
& rect
Definition: startmenu.cpp:1413
RECT droppedRect
Definition: comctl32.h:153
UINT wState
Definition: comctl32.h:149
HWND hWndLBox
Definition: comctl32.h:148
INT droppedIndex
Definition: comctl32.h:154
HWND self
Definition: comctl32.h:144
DWORD cbSize
Definition: winuser.h:3784
#define max(a, b)
Definition: svc.c:63
#define LB_CARETON
Definition: undocuser.h:51
UINT_PTR WPARAM
Definition: windef.h:207
#define LB_ERR
Definition: winuser.h:2432
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define LB_GETCOUNT
Definition: winuser.h:2038
#define SWP_NOACTIVATE
Definition: winuser.h:1242
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define HWND_TOPMOST
Definition: winuser.h:1208
#define LB_SETTOPINDEX
Definition: winuser.h:2070
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define RDW_UPDATENOW
Definition: winuser.h:1220
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define RDW_ERASE
Definition: winuser.h:1211
#define CBN_DROPDOWN
Definition: winuser.h:1974
#define LB_GETITEMHEIGHT
Definition: winuser.h:2042
#define SWP_SHOWWINDOW
Definition: winuser.h:1248
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#define LB_GETCURSEL
Definition: winuser.h:2039
#define RDW_INVALIDATE
Definition: winuser.h:1214

◆ CBForceDummyResize()

static void CBForceDummyResize ( LPHEADCOMBO  lphc)
static

Definition at line 296 of file combo.c.

298{
299 RECT windowRect;
300 int newComboHeight;
301
302 newComboHeight = CBGetTextAreaHeight(lphc->self,lphc) + 2*COMBO_YBORDERSIZE();
303
304 GetWindowRect(lphc->self, &windowRect);
305
306 /*
307 * We have to be careful, resizing a combobox also has the meaning that the
308 * dropped rect will be resized. In this case, we want to trigger a resize
309 * to recalculate layout but we don't want to change the dropped rectangle
310 * So, we pass the height of text area of control as the height.
311 * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
312 * message.
313 */
314 SetWindowPos( lphc->self,
315 NULL,
316 0, 0,
317 windowRect.right - windowRect.left,
318 newComboHeight,
320}
#define SWP_NOMOVE
Definition: winuser.h:1244
#define SWP_NOZORDER
Definition: winuser.h:1247

◆ CBGetDroppedControlRect()

static void CBGetDroppedControlRect ( LPHEADCOMBO  lphc,
LPRECT  lpRect 
)
static

Definition at line 437 of file combo.c.

438{
439 /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner
440 of the combo box and the lower right corner of the listbox */
441
442 GetWindowRect(lphc->self, lpRect);
443
444 lpRect->right = lpRect->left + lphc->droppedRect.right - lphc->droppedRect.left;
445 lpRect->bottom = lpRect->top + lphc->droppedRect.bottom - lphc->droppedRect.top;
446
447}

◆ CBGetTextAreaHeight()

static INT CBGetTextAreaHeight ( HWND  hwnd,
LPHEADCOMBO  lphc 
)
static

Definition at line 201 of file combo.c.

204{
205 INT iTextItemHeight;
206
207 if( lphc->editHeight ) /* explicitly set height */
208 {
209 iTextItemHeight = lphc->editHeight;
210 }
211 else
212 {
214 HDC hDC = GetDC(hwnd);
215 HFONT hPrevFont = 0;
216 INT baseUnitY;
217
218 if (lphc->hFont)
219 hPrevFont = SelectObject( hDC, lphc->hFont );
220
222
223 baseUnitY = tm.tmHeight;
224
225 if( hPrevFont )
226 SelectObject( hDC, hPrevFont );
227
229
230 iTextItemHeight = baseUnitY + 4;
231 }
232
233 /*
234 * Check the ownerdraw case if we haven't asked the parent the size
235 * of the item yet.
236 */
237 if ( CB_OWNERDRAWN(lphc) &&
238 (lphc->wState & CBF_MEASUREITEM) )
239 {
240 MEASUREITEMSTRUCT measureItem;
241 RECT clientRect;
242 INT originalItemHeight = iTextItemHeight;
243 UINT id = (UINT)GetWindowLongPtrW( lphc->self, GWLP_ID );
244
245 /*
246 * We use the client rect for the width of the item.
247 */
248 GetClientRect(hwnd, &clientRect);
249
250 lphc->wState &= ~CBF_MEASUREITEM;
251
252 /*
253 * Send a first one to measure the size of the text area
254 */
255 measureItem.CtlType = ODT_COMBOBOX;
256 measureItem.CtlID = id;
257 measureItem.itemID = -1;
258 measureItem.itemWidth = clientRect.right;
259 measureItem.itemHeight = iTextItemHeight - 6; /* ownerdrawn cb is taller */
260 measureItem.itemData = 0;
261 SendMessageW(lphc->owner, WM_MEASUREITEM, id, (LPARAM)&measureItem);
262 iTextItemHeight = 6 + measureItem.itemHeight;
263
264 /*
265 * Send a second one in the case of a fixed ownerdraw list to calculate the
266 * size of the list items. (we basically do this on behalf of the listbox)
267 */
268 if (lphc->dwStyle & CBS_OWNERDRAWFIXED)
269 {
270 measureItem.CtlType = ODT_COMBOBOX;
271 measureItem.CtlID = id;
272 measureItem.itemID = 0;
273 measureItem.itemWidth = clientRect.right;
274 measureItem.itemHeight = originalItemHeight;
275 measureItem.itemData = 0;
276 SendMessageW(lphc->owner, WM_MEASUREITEM, id, (LPARAM)&measureItem);
277 lphc->fixedOwnerDrawHeight = measureItem.itemHeight;
278 }
279
280 /*
281 * Keep the size for the next time
282 */
283 lphc->editHeight = iTextItemHeight;
284 }
285
286 return iTextItemHeight;
287}
static HDC hDC
Definition: 3dtext.c:33
#define CBF_MEASUREITEM
Definition: controls.h:48
#define CB_OWNERDRAWN(lphc)
Definition: combo.c:56
GLuint id
Definition: glext.h:5910
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
unsigned int UINT
Definition: ndis.h:50
INT fixedOwnerDrawHeight
Definition: comctl32.h:155
HWND owner
Definition: comctl32.h:145
HFONT hFont
Definition: comctl32.h:150
INT editHeight
Definition: comctl32.h:157
UINT dwStyle
Definition: comctl32.h:146
ULONG_PTR itemData
Definition: winuser.h:3646
Definition: time.h:68
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define CBS_OWNERDRAWFIXED
Definition: winuser.h:289
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define ODT_COMBOBOX
Definition: winuser.h:2539
HDC WINAPI GetDC(_In_opt_ HWND)
#define WM_MEASUREITEM
Definition: winuser.h:1646

◆ CBPaintBorder()

static void CBPaintBorder ( HWND  hwnd,
const HEADCOMBO lphc,
HDC  hdc 
)
static

Definition at line 830 of file combo.c.

834{
835 RECT clientRect;
836
837 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
838 {
839 GetClientRect(hwnd, &clientRect);
840 }
841 else
842 {
843 CopyRect(&clientRect, &lphc->textRect);
844
847 }
848
849 DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT);
850}
HDC hdc
Definition: main.c:9
RECT textRect
Definition: comctl32.h:151
#define EDGE_SUNKEN
Definition: winuser.h:451
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define BF_RECT
Definition: winuser.h:462

◆ CBPaintButton()

static void CBPaintButton ( LPHEADCOMBO  lphc,
HDC  hdc,
RECT  rectButton 
)
static

Definition at line 625 of file combo.c.

626{
627 UINT buttonState = DFCS_SCROLLCOMBOBOX;
628
629 if( lphc->wState & CBF_NOREDRAW )
630 return;
631
632
633 if (lphc->wState & CBF_BUTTONDOWN)
634 buttonState |= DFCS_PUSHED;
635
636 if (CB_DISABLED(lphc))
637 buttonState |= DFCS_INACTIVE;
638
639 DrawFrameControl(hdc, &rectButton, DFC_SCROLL, buttonState);
640}
#define CB_DISABLED(lphc)
Definition: combo.c:55
#define CBF_BUTTONDOWN
Definition: window.c:3462
#define DFC_SCROLL
Definition: winuser.h:475
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DFCS_INACTIVE
Definition: winuser.h:502
#define DFCS_SCROLLCOMBOBOX
Definition: winuser.h:493
#define DFCS_PUSHED
Definition: winuser.h:503

◆ CBPaintText()

static void CBPaintText ( LPHEADCOMBO  lphc,
HDC  hdc_paint 
)
static

Definition at line 699 of file combo.c.

702{
703 RECT rectEdit = lphc->textRect;
704 INT id, size = 0;
705 LPWSTR pText = NULL;
706
707 TRACE("\n");
708
709 /* follow Windows combobox that sends a bunch of text
710 * inquiries to its listbox while processing WM_PAINT. */
711
712 if( (id = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0) ) != LB_ERR )
713 {
714 size = SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, id, 0);
715 if (size == LB_ERR)
716 FIXME("LB_ERR probably not handled yet\n");
717 if( (pText = HeapAlloc( GetProcessHeap(), 0, (size + 1) * sizeof(WCHAR))) )
718 {
719 /* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */
721 pText[size] = '\0'; /* just in case */
722 } else return;
723 }
724
725 if( lphc->wState & CBF_EDIT )
726 {
727 static const WCHAR empty_stringW[] = { 0 };
729 if( lphc->wState & CBF_FOCUSED )
731 }
732 else if(!(lphc->wState & CBF_NOREDRAW) && IsWindowVisible( lphc->self ))
733 {
734 /* paint text field ourselves */
735 HDC hdc = hdc_paint ? hdc_paint : GetDC(lphc->self);
736 UINT itemState = ODS_COMBOBOXEDIT;
737 HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
738 HBRUSH hPrevBrush, hBkgBrush;
739
740 /*
741 * Give ourselves some space.
742 */
743 InflateRect( &rectEdit, -1, -1 );
744
745 hBkgBrush = COMBO_PrepareColors( lphc, hdc );
746 hPrevBrush = SelectObject( hdc, hBkgBrush );
747 FillRect( hdc, &rectEdit, hBkgBrush );
748
749 if( CB_OWNERDRAWN(lphc) )
750 {
751 DRAWITEMSTRUCT dis;
752 HRGN clipRegion;
753 UINT ctlid = (UINT)GetWindowLongPtrW( lphc->self, GWLP_ID );
754
755 /* setup state for DRAWITEM message. Owner will highlight */
756 if ( (lphc->wState & CBF_FOCUSED) &&
757 !(lphc->wState & CBF_DROPPED) )
758 itemState |= ODS_SELECTED | ODS_FOCUS;
759
760 if (!IsWindowEnabled(lphc->self)) itemState |= ODS_DISABLED;
761
762 dis.CtlType = ODT_COMBOBOX;
763 dis.CtlID = ctlid;
764 dis.hwndItem = lphc->self;
766 dis.itemID = id;
767 dis.itemState = itemState;
768 dis.hDC = hdc;
769 dis.rcItem = rectEdit;
770 dis.itemData = SendMessageW(lphc->hWndLBox, LB_GETITEMDATA, id, 0);
771
772 /*
773 * Clip the DC and have the parent draw the item.
774 */
775 clipRegion = set_control_clipping( hdc, &rectEdit );
776
777 SendMessageW(lphc->owner, WM_DRAWITEM, ctlid, (LPARAM)&dis );
778
779 SelectClipRgn( hdc, clipRegion );
780 if (clipRegion) DeleteObject( clipRegion );
781 }
782 else
783 {
784 static const WCHAR empty_stringW[] = { 0 };
785
786 if ( (lphc->wState & CBF_FOCUSED) &&
787 !(lphc->wState & CBF_DROPPED) ) {
788
789 /* highlight */
793 }
794
796 rectEdit.left + 1,
797 rectEdit.top + 1,
799 &rectEdit,
801
802#ifdef __REACTOS__
803 if(lphc->wState & CBF_FOCUSED &&
804 !(lphc->wState & CBF_DROPPED) &&
805 !(lphc->UIState & UISF_HIDEFOCUS))
806#else
807 if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED))
808#endif
809 DrawFocusRect( hdc, &rectEdit );
810 }
811
812 if( hPrevFont )
813 SelectObject(hdc, hPrevFont );
814
815 if( hPrevBrush )
816 SelectObject( hdc, hPrevBrush );
817
818 if( !hdc_paint )
819 ReleaseDC( lphc->self, hdc );
820 }
821#ifdef __REACTOS__
822 if (pText)
823#endif
825}
#define FIXME(fmt,...)
Definition: debug.h:111
#define CBF_EDIT
Definition: controls.h:51
#define CBF_FOCUSED
Definition: controls.h:49
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:239
static HBRUSH COMBO_PrepareColors(LPHEADCOMBO lphc, HDC hDC)
Definition: combo.c:617
#define CB_HASSTRINGS(lphc)
Definition: combo.c:57
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
pKey DeleteObject()
GLsizeiptr size
Definition: glext.h:5919
LONG UIState
Definition: window.c:3452
HWND hWndEdit
Definition: comctl32.h:147
ULONG_PTR itemData
Definition: winuser.h:3093
LPCSTR pText
Definition: txtscale.cpp:79
#define MAXLONG
Definition: umtypes.h:116
static const WCHAR empty_stringW[]
Definition: edit.c:173
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
#define ETO_CLIPPED
Definition: wingdi.h:648
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define ETO_OPAQUE
Definition: wingdi.h:647
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define ODS_DISABLED
Definition: winuser.h:2547
DWORD WINAPI GetSysColor(_In_ int)
#define ODS_SELECTED
Definition: winuser.h:2545
#define LB_GETITEMDATA
Definition: winuser.h:2041
#define ODA_DRAWENTIRE
Definition: winuser.h:2542
#define LB_GETTEXT
Definition: winuser.h:2049
#define COLOR_HIGHLIGHT
Definition: winuser.h:926
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1645
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:927
#define EM_SETSEL
Definition: winuser.h:2018
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define LB_GETTEXTLEN
Definition: winuser.h:2050
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define ODS_FOCUS
Definition: winuser.h:2549
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ CBRepaintButton()

static void CBRepaintButton ( LPHEADCOMBO  lphc)
static

Definition at line 1152 of file combo.c.

1153 {
1154 InvalidateRect(lphc->self, &lphc->buttonRect, TRUE);
1155 UpdateWindow(lphc->self);
1156}
RECT buttonRect
Definition: comctl32.h:152
BOOL WINAPI UpdateWindow(_In_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

◆ CBResetPos()

static void CBResetPos ( LPHEADCOMBO  lphc,
const RECT rectEdit,
const RECT rectLB,
BOOL  bRedraw 
)
static

Definition at line 1476 of file combo.c.

1481{
1482 BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
1483
1484 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1485 * sizing messages */
1486
1487 if( lphc->wState & CBF_EDIT )
1488 SetWindowPos( lphc->hWndEdit, 0,
1489 rectEdit->left, rectEdit->top,
1490 rectEdit->right - rectEdit->left,
1491 rectEdit->bottom - rectEdit->top,
1492 SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
1493
1494 SetWindowPos( lphc->hWndLBox, 0,
1495 rectLB->left, rectLB->top,
1496 rectLB->right - rectLB->left,
1497 rectLB->bottom - rectLB->top,
1498 SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) );
1499
1500 if( bDrop )
1501 {
1502 if( lphc->wState & CBF_DROPPED )
1503 {
1504 lphc->wState &= ~CBF_DROPPED;
1505 ShowWindow( lphc->hWndLBox, SW_HIDE );
1506 }
1507
1508 if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
1509 RedrawWindow( lphc->self, NULL, 0,
1511 }
1512}
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SW_HIDE
Definition: winuser.h:768
#define SWP_NOREDRAW
Definition: winuser.h:1246
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)

◆ CBRollUp()

static void CBRollUp ( LPHEADCOMBO  lphc,
BOOL  ok,
BOOL  bButton 
)
static

Definition at line 1082 of file combo.c.

1083{
1084 HWND hWnd = lphc->self;
1085
1086 TRACE("[%p]: sel ok? [%i] dropped? [%i]\n",
1087 lphc->self, ok, (INT)(lphc->wState & CBF_DROPPED));
1088
1090
1091 if( IsWindow( hWnd ) && CB_GETTYPE(lphc) != CBS_SIMPLE )
1092 {
1093
1094 if( lphc->wState & CBF_DROPPED )
1095 {
1096 RECT rect;
1097
1098 lphc->wState &= ~CBF_DROPPED;
1099 ShowWindow( lphc->hWndLBox, SW_HIDE );
1100
1101 if(GetCapture() == lphc->hWndLBox)
1102 {
1104 }
1105
1106 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1107 {
1108 rect = lphc->buttonRect;
1109 }
1110 else
1111 {
1112 if( bButton )
1113 {
1114 UnionRect( &rect,
1115 &lphc->buttonRect,
1116 &lphc->textRect);
1117 }
1118 else
1119 rect = lphc->textRect;
1120
1121 bButton = TRUE;
1122 }
1123
1124 if( bButton && !(lphc->wState & CBF_NOREDRAW) )
1127 CB_NOTIFY( lphc, CBN_CLOSEUP );
1128 }
1129 }
1130}
#define ok(value,...)
Definition: atltest.h:57
HWND hWnd
Definition: settings.c:17
BOOL WINAPI IsWindow(_In_opt_ HWND)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define RDW_NOCHILDREN
Definition: winuser.h:1222
#define CBN_CLOSEUP
Definition: winuser.h:1972
#define CBN_SELENDOK
Definition: winuser.h:1981
#define CBN_SELENDCANCEL
Definition: winuser.h:1980
BOOL WINAPI UnionRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)

◆ CBUpdateEdit()

static void CBUpdateEdit ( LPHEADCOMBO  lphc,
INT  index 
)
static

Definition at line 947 of file combo.c.

948{
949 INT length;
950 LPWSTR pText = NULL;
951 static const WCHAR empty_stringW[] = { 0 };
952
953 TRACE("\t %i\n", index );
954
955 if( index >= 0 ) /* got an entry */
956 {
958 if( length != LB_ERR)
959 {
960 if ((pText = HeapAlloc(GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR))))
962 }
963 }
964
965 if( CB_HASSTRINGS(lphc) )
966 {
970 }
971
972 if( lphc->wState & CBF_FOCUSED )
973 SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1));
974
976}
#define CBF_NOLBSELECT
Definition: controls.h:57
#define CBF_NOEDITNOTIFY
Definition: controls.h:56
GLuint index
Definition: glext.h:6031
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define WM_SETTEXT
Definition: winuser.h:1617

◆ CBUpdateLBox()

static INT CBUpdateLBox ( LPHEADCOMBO  lphc,
BOOL  bSelect 
)
static

Definition at line 913 of file combo.c.

914{
915 INT length, idx;
916 LPWSTR pText = NULL;
917
918 idx = LB_ERR;
920
921 if (length > 0)
922 pText = HeapAlloc( GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR));
923
924 TRACE("\t edit text length %i\n", length );
925
926 if( pText )
927 {
928 GetWindowTextW( lphc->hWndEdit, pText, length + 1);
931 }
932
933 SendMessageW(lphc->hWndLBox, LB_SETCURSEL, (WPARAM)(bSelect ? idx : -1), 0);
934
935 /* probably superfluous but Windows sends this too */
936 SendMessageW(lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)(idx < 0 ? 0 : idx), 0);
937 SendMessageW(lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)(idx < 0 ? 0 : idx), 0);
938
939 return idx;
940}
unsigned int idx
Definition: utils.c:41
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
#define WM_GETTEXTLENGTH
Definition: winuser.h:1619
#define LB_FINDSTRING
Definition: winuser.h:2034
#define LB_SETCURSEL
Definition: winuser.h:2063
#define LB_SETCARETINDEX
Definition: winuser.h:2060

◆ COMBO_Command()

static LRESULT COMBO_Command ( LPHEADCOMBO  lphc,
WPARAM  wParam,
HWND  hWnd 
)
static

Definition at line 1209 of file combo.c.

1210{
1211 if ( lphc->wState & CBF_EDIT && lphc->hWndEdit == hWnd )
1212 {
1213 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1214
1215 switch( HIWORD(wParam) >> 8 )
1216 {
1217 case (EN_SETFOCUS >> 8):
1218
1219 TRACE("[%p]: edit [%p] got focus\n", lphc->self, lphc->hWndEdit );
1220
1221 COMBO_SetFocus( lphc );
1222 break;
1223
1224 case (EN_KILLFOCUS >> 8):
1225
1226 TRACE("[%p]: edit [%p] lost focus\n", lphc->self, lphc->hWndEdit );
1227
1228 /* NOTE: it seems that Windows' edit control sends an
1229 * undocumented message WM_USER + 0x1B instead of this
1230 * notification (only when it happens to be a part of
1231 * the combo). ?? - AK.
1232 */
1233
1234 COMBO_KillFocus( lphc );
1235 break;
1236
1237
1238 case (EN_CHANGE >> 8):
1239 /*
1240 * In some circumstances (when the selection of the combobox
1241 * is changed for example) we don't want the EN_CHANGE notification
1242 * to be forwarded to the parent of the combobox. This code
1243 * checks a flag that is set in these occasions and ignores the
1244 * notification.
1245 */
1246 if (lphc->wState & CBF_NOLBSELECT)
1247 {
1248 lphc->wState &= ~CBF_NOLBSELECT;
1249 }
1250 else
1251 {
1252 CBUpdateLBox( lphc, lphc->wState & CBF_DROPPED );
1253 }
1254
1255 if (!(lphc->wState & CBF_NOEDITNOTIFY))
1256 CB_NOTIFY( lphc, CBN_EDITCHANGE );
1257 break;
1258
1259 case (EN_UPDATE >> 8):
1260 if (!(lphc->wState & CBF_NOEDITNOTIFY))
1261 CB_NOTIFY( lphc, CBN_EDITUPDATE );
1262 break;
1263
1264 case (EN_ERRSPACE >> 8):
1265 CB_NOTIFY( lphc, CBN_ERRSPACE );
1266 }
1267 }
1268 else if( lphc->hWndLBox == hWnd )
1269 {
1270 switch( (short)HIWORD(wParam) )
1271 {
1272 case LBN_ERRSPACE:
1273 CB_NOTIFY( lphc, CBN_ERRSPACE );
1274 break;
1275
1276 case LBN_DBLCLK:
1277 CB_NOTIFY( lphc, CBN_DBLCLK );
1278 break;
1279
1280 case LBN_SELCHANGE:
1281 case LBN_SELCANCEL:
1282
1283 TRACE("[%p]: lbox selection change [%x]\n", lphc->self, lphc->wState );
1284
1285 /* do not roll up if selection is being tracked
1286 * by arrow keys in the dropdown listbox */
1287 if (!(lphc->wState & CBF_NOROLLUP))
1288 {
1289 CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
1290 }
1291 else lphc->wState &= ~CBF_NOROLLUP;
1292
1293 CB_NOTIFY( lphc, CBN_SELCHANGE );
1294
1295 if( HIWORD(wParam) == LBN_SELCHANGE)
1296 {
1297 if( lphc->wState & CBF_EDIT )
1298 {
1299 INT index = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
1300 lphc->wState |= CBF_NOLBSELECT;
1301 CBUpdateEdit( lphc, index );
1302 /* select text in edit, as Windows does */
1303 SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1));
1304 }
1305 else
1306 {
1307 InvalidateRect(lphc->self, &lphc->textRect, TRUE);
1308 UpdateWindow(lphc->self);
1309 }
1310 }
1311 break;
1312
1313 case LBN_SETFOCUS:
1314 case LBN_KILLFOCUS:
1315 /* nothing to do here since ComboLBox always resets the focus to its
1316 * combo/edit counterpart */
1317 break;
1318 }
1319 }
1320 return 0;
1321}
WPARAM wParam
Definition: combotst.c:138
#define CBF_NOROLLUP
Definition: controls.h:47
static void COMBO_KillFocus(LPHEADCOMBO lphc)
Definition: combo.c:1162
static void COMBO_SetFocus(LPHEADCOMBO lphc)
Definition: combo.c:1140
static void CBRollUp(LPHEADCOMBO lphc, BOOL ok, BOOL bButton)
Definition: combo.c:1061
#define HIWORD(l)
Definition: typedefs.h:247
#define LBN_ERRSPACE
Definition: winuser.h:2072
#define CBN_ERRSPACE
Definition: winuser.h:1977
#define EN_KILLFOCUS
Definition: winuser.h:2025
#define LBN_SELCANCEL
Definition: winuser.h:2074
#define LBN_DBLCLK
Definition: winuser.h:2071
#define EN_SETFOCUS
Definition: winuser.h:2027
#define EN_UPDATE
Definition: winuser.h:2028
#define LBN_SETFOCUS
Definition: winuser.h:2076
#define CBN_EDITUPDATE
Definition: winuser.h:1976
#define CBN_SELCHANGE
Definition: winuser.h:1979
#define LBN_SELCHANGE
Definition: winuser.h:2075
#define CBN_DBLCLK
Definition: winuser.h:1973
#define LBN_KILLFOCUS
Definition: winuser.h:2073
#define EN_ERRSPACE
Definition: winuser.h:2023
#define CBN_EDITCHANGE
Definition: winuser.h:1975
#define EN_CHANGE
Definition: winuser.h:2022

◆ COMBO_Create()

static LRESULT COMBO_Create ( HWND  hwnd,
LPHEADCOMBO  lphc,
HWND  hwndParent,
LONG  style,
BOOL  unicode 
)
static

Definition at line 452 of file combo.c.

454{
455 static const WCHAR clbName[] = {'C','o','m','b','o','L','B','o','x',0};
456 static const WCHAR editName[] = {'E','d','i','t',0};
457
458 if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE;
459 if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
460
461 lphc->owner = hwndParent;
462
463 /*
464 * The item height and dropped width are not set when the control
465 * is created.
466 */
467 lphc->droppedWidth = lphc->editHeight = 0;
468
469 /*
470 * The first time we go through, we want to measure the ownerdraw item
471 */
472 lphc->wState |= CBF_MEASUREITEM;
473
474 /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
475
476 if( lphc->owner || !(style & WS_VISIBLE) )
477 {
478 UINT lbeStyle = 0;
479 UINT lbeExStyle = 0;
480
481 /*
482 * Initialize the dropped rect to the size of the client area of the
483 * control and then, force all the areas of the combobox to be
484 * recalculated.
485 */
486 GetClientRect( hwnd, &lphc->droppedRect );
487 CBCalcPlacement(hwnd, lphc, &lphc->textRect, &lphc->buttonRect, &lphc->droppedRect );
488
489 /*
490 * Adjust the position of the popup listbox if it's necessary
491 */
492 if ( CB_GETTYPE(lphc) != CBS_SIMPLE )
493 {
495
496 /*
497 * If it's a dropdown, the listbox is offset
498 */
499 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
501
502 if (lphc->droppedRect.bottom < lphc->droppedRect.top)
503 lphc->droppedRect.bottom = lphc->droppedRect.top;
504 if (lphc->droppedRect.right < lphc->droppedRect.left)
505 lphc->droppedRect.right = lphc->droppedRect.left;
506 MapWindowPoints( hwnd, 0, (LPPOINT)&lphc->droppedRect, 2 );
507 }
508
509 /* create listbox popup */
510
513
514 if( lphc->dwStyle & CBS_SORT )
515 lbeStyle |= LBS_SORT;
516 if( lphc->dwStyle & CBS_HASSTRINGS )
517 lbeStyle |= LBS_HASSTRINGS;
518 if( lphc->dwStyle & CBS_NOINTEGRALHEIGHT )
519 lbeStyle |= LBS_NOINTEGRALHEIGHT;
520 if( lphc->dwStyle & CBS_DISABLENOSCROLL )
521 lbeStyle |= LBS_DISABLENOSCROLL;
522
523 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */
524 {
525 lbeStyle |= WS_VISIBLE;
526
527 /*
528 * In win 95 look n feel, the listbox in the simple combobox has
529 * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
530 */
531 lbeStyle &= ~WS_BORDER;
532 lbeExStyle |= WS_EX_CLIENTEDGE;
533 }
534 else
535 {
536 lbeExStyle |= (WS_EX_TOPMOST | WS_EX_TOOLWINDOW);
537 }
538
539 if (unicode)
540 lphc->hWndLBox = CreateWindowExW(lbeExStyle, clbName, NULL, lbeStyle,
541 lphc->droppedRect.left,
542 lphc->droppedRect.top,
543 lphc->droppedRect.right - lphc->droppedRect.left,
544 lphc->droppedRect.bottom - lphc->droppedRect.top,
547 else
548 lphc->hWndLBox = CreateWindowExA(lbeExStyle, "ComboLBox", NULL, lbeStyle,
549 lphc->droppedRect.left,
550 lphc->droppedRect.top,
551 lphc->droppedRect.right - lphc->droppedRect.left,
552 lphc->droppedRect.bottom - lphc->droppedRect.top,
555
556 if( lphc->hWndLBox )
557 {
558 BOOL bEdit = TRUE;
560
561 if( lphc->wState & CBF_EDIT )
562 {
563 if( lphc->dwStyle & CBS_OEMCONVERT )
564 lbeStyle |= ES_OEMCONVERT;
565 if( lphc->dwStyle & CBS_AUTOHSCROLL )
566 lbeStyle |= ES_AUTOHSCROLL;
567 if( lphc->dwStyle & CBS_LOWERCASE )
568 lbeStyle |= ES_LOWERCASE;
569 else if( lphc->dwStyle & CBS_UPPERCASE )
570 lbeStyle |= ES_UPPERCASE;
571
572 if (!IsWindowEnabled(hwnd)) lbeStyle |= WS_DISABLED;
573
574 if (unicode)
575 lphc->hWndEdit = CreateWindowExW(0, editName, NULL, lbeStyle,
576 lphc->textRect.left, lphc->textRect.top,
577 lphc->textRect.right - lphc->textRect.left,
578 lphc->textRect.bottom - lphc->textRect.top,
581 else
582 lphc->hWndEdit = CreateWindowExA(0, "Edit", NULL, lbeStyle,
583 lphc->textRect.left, lphc->textRect.top,
584 lphc->textRect.right - lphc->textRect.left,
585 lphc->textRect.bottom - lphc->textRect.top,
588
589 if( !lphc->hWndEdit )
590 bEdit = FALSE;
591 }
592
593 if( bEdit )
594 {
595 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
596 {
597 /* Now do the trick with parent */
599 /*
600 * If the combo is a dropdown, we must resize the control
601 * to fit only the text area and button. To do this,
602 * we send a dummy resize and the WM_WINDOWPOSCHANGING message
603 * will take care of setting the height for us.
604 */
605 CBForceDummyResize(lphc);
606 }
607
608 TRACE("init done\n");
609 return 0;
610 }
611 ERR("edit control failure.\n");
612 } else ERR("listbox failure.\n");
613 } else ERR("no owner for visible combo.\n");
614
615 /* CreateWindow() will send WM_NCDESTROY to cleanup */
616
617 return -1;
618}
Arabic default style
Definition: afstyles.h:94
#define ERR(fmt,...)
Definition: debug.h:110
static HWND hwndParent
Definition: cryptui.c:300
#define FALSE
Definition: types.h:117
#define ID_CB_LISTBOX
Definition: combo.c:79
#define ID_CB_EDIT
Definition: combo.c:80
static void CBCalcPlacement(HWND hwnd, LPHEADCOMBO lphc, LPRECT lprEdit, LPRECT lprButton, LPRECT lprLB)
Definition: combo.c:311
static void CBForceDummyResize(LPHEADCOMBO lphc)
Definition: combo.c:280
#define ES_COMBO
Definition: edit.c:29
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define WS_CHILD
Definition: pedump.c:617
#define ES_LOWERCASE
Definition: pedump.c:669
#define LBS_DISABLENOSCROLL
Definition: pedump.c:690
#define LBS_SORT
Definition: pedump.c:679
#define ES_UPPERCASE
Definition: pedump.c:668
#define WS_BORDER
Definition: pedump.c:625
#define ES_NOHIDESEL
Definition: pedump.c:673
#define LBS_HASSTRINGS
Definition: pedump.c:684
#define WS_VSCROLL
Definition: pedump.c:627
#define ES_AUTOHSCROLL
Definition: pedump.c:672
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define WS_DISABLED
Definition: pedump.c:621
#define ES_LEFT
Definition: pedump.c:664
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define LBS_NOINTEGRALHEIGHT
Definition: pedump.c:686
#define LBS_NOTIFY
Definition: pedump.c:678
#define ES_OEMCONVERT
Definition: pedump.c:674
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define CBS_NOINTEGRALHEIGHT
Definition: winuser.h:287
#define CBS_AUTOHSCROLL
Definition: winuser.h:281
#define CBS_OWNERDRAWVARIABLE
Definition: winuser.h:290
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
#define CBS_DISABLENOSCROLL
Definition: winuser.h:282
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define GWLP_HINSTANCE
Definition: winuser.h:856
#define HWND_DESKTOP
Definition: winuser.h:1209
#define LBS_COMBOBOX
Definition: winuser.h:324
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define CBS_LOWERCASE
Definition: winuser.h:286
#define CBS_HASSTRINGS
Definition: winuser.h:285
#define CBS_SORT
Definition: winuser.h:292
#define CBS_OEMCONVERT
Definition: winuser.h:288
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define CBS_UPPERCASE
Definition: winuser.h:293

◆ COMBO_FlipListbox()

BOOL COMBO_FlipListbox ( LPHEADCOMBO  lphc,
BOOL  ok,
BOOL  bRedrawButton 
)

Definition at line 1137 of file combo.c.

1138{
1139 if( lphc->wState & CBF_DROPPED )
1140 {
1141 CBRollUp( lphc, ok, bRedrawButton );
1142 return FALSE;
1143 }
1144
1145 CBDropDown( lphc );
1146 return TRUE;
1147}
static void CBDropDown(LPHEADCOMBO lphc)
Definition: combo.c:959

◆ COMBO_Font()

static void COMBO_Font ( LPHEADCOMBO  lphc,
HFONT  hFont,
BOOL  bRedraw 
)
static

Definition at line 1570 of file combo.c.

1571{
1572 /*
1573 * Set the font
1574 */
1575 lphc->hFont = hFont;
1576
1577 /*
1578 * Propagate to owned windows.
1579 */
1580 if( lphc->wState & CBF_EDIT )
1581 SendMessageW(lphc->hWndEdit, WM_SETFONT, (WPARAM)hFont, bRedraw);
1582 SendMessageW(lphc->hWndLBox, WM_SETFONT, (WPARAM)hFont, bRedraw);
1583
1584 /*
1585 * Redo the layout of the control.
1586 */
1587 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1588 {
1589 CBCalcPlacement(lphc->self,
1590 lphc,
1591 &lphc->textRect,
1592 &lphc->buttonRect,
1593 &lphc->droppedRect);
1594
1595 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1596 }
1597 else
1598 {
1599 CBForceDummyResize(lphc);
1600 }
1601}
HFONT hFont
Definition: main.c:53
static void CBResetPos(LPHEADCOMBO lphc, const RECT *rectEdit, const RECT *rectLB, BOOL bRedraw)
Definition: combo.c:1394
#define WM_SETFONT
Definition: winuser.h:1650

◆ COMBO_GetComboBoxInfo()

static LRESULT COMBO_GetComboBoxInfo ( const HEADCOMBO lphc,
COMBOBOXINFO pcbi 
)
static

Definition at line 1777 of file combo.c.

1778{
1779 if (!pcbi || (pcbi->cbSize < sizeof(COMBOBOXINFO)))
1780 return FALSE;
1781
1782 pcbi->rcItem = lphc->textRect;
1783 pcbi->rcButton = lphc->buttonRect;
1784 pcbi->stateButton = 0;
1785 if (lphc->wState & CBF_BUTTONDOWN)
1787 if (IsRectEmpty(&lphc->buttonRect))
1789 pcbi->hwndCombo = lphc->self;
1790 pcbi->hwndItem = lphc->hWndEdit;
1791 pcbi->hwndList = lphc->hWndLBox;
1792 return TRUE;
1793}
DWORD stateButton
Definition: winuser.h:3712
#define STATE_SYSTEM_PRESSED
Definition: winuser.h:2865
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define STATE_SYSTEM_INVISIBLE
Definition: winuser.h:2877

◆ COMBO_GetTextA()

static LRESULT COMBO_GetTextA ( LPHEADCOMBO  lphc,
INT  count,
LPSTR  buf 
)
static

Definition at line 1426 of file combo.c.

1427{
1428 INT length;
1429
1430 if( lphc->wState & CBF_EDIT )
1431 return SendMessageA( lphc->hWndEdit, WM_GETTEXT, count, (LPARAM)buf );
1432
1433 /* get it from the listbox */
1434
1435 if (!count || !buf) return 0;
1436 if( lphc->hWndLBox )
1437 {
1438 INT idx = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
1439 if (idx == LB_ERR) goto error;
1441 if (length == LB_ERR) goto error;
1442
1443 /* 'length' is without the terminating character */
1444 if (length >= count)
1445 {
1447 if (!lpBuffer) goto error;
1449
1450 /* truncate if buffer is too short */
1451 if (length != LB_ERR)
1452 {
1454 length = count;
1455 }
1457 }
1459
1460 if (length == LB_ERR) return 0;
1461 return length;
1462 }
1463
1464 error: /* error - truncate string, return zero */
1465 buf[0] = 0;
1466 return 0;
1467}
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define lstrcpynA
Definition: compat.h:751
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define error(str)
Definition: mkdosfs.c:1605
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_GETTEXT
Definition: winuser.h:1618
char * LPSTR
Definition: xmlstorage.h:182

Referenced by ComboWndProc_common().

◆ COMBO_GetTextW()

static LRESULT COMBO_GetTextW ( LPHEADCOMBO  lphc,
INT  count,
LPWSTR  buf 
)
static

Definition at line 1376 of file combo.c.

1377{
1378 INT length;
1379
1380 if( lphc->wState & CBF_EDIT )
1381 return SendMessageW( lphc->hWndEdit, WM_GETTEXT, count, (LPARAM)buf );
1382
1383 /* get it from the listbox */
1384
1385 if (!count || !buf) return 0;
1386 if( lphc->hWndLBox )
1387 {
1388 INT idx = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
1389 if (idx == LB_ERR) goto error;
1391 if (length == LB_ERR) goto error;
1392
1393 /* 'length' is without the terminating character */
1394 if (length >= count)
1395 {
1396 LPWSTR lpBuffer = HeapAlloc(GetProcessHeap(), 0, (length + 1) * sizeof(WCHAR));
1397 if (!lpBuffer) goto error;
1399
1400 /* truncate if buffer is too short */
1401 if (length != LB_ERR)
1402 {
1404 length = count;
1405 }
1407 }
1409
1410 if (length == LB_ERR) return 0;
1411 return length;
1412 }
1413
1414 error: /* error - truncate string, return zero */
1415 buf[0] = 0;
1416 return 0;
1417}
#define lstrcpynW
Definition: compat.h:738

Referenced by ComboWndProc_common().

◆ COMBO_Init()

static BOOL COMBO_Init ( void  )
static

Definition at line 88 of file combo.c.

89{
90 HDC hDC;
91
92 if( hComboBmp ) return TRUE;
93 if( (hDC = CreateCompatibleDC(0)) )
94 {
95 BOOL bRet = FALSE;
96 if( (hComboBmp = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_COMBO))) )
97 {
98 BITMAP bm;
99 HBITMAP hPrevB;
100 RECT r;
101
102 GetObjectW( hComboBmp, sizeof(bm), &bm );
103 CBitHeight = bm.bmHeight;
104 CBitWidth = bm.bmWidth;
105
106 TRACE("combo bitmap [%i,%i]\n", CBitWidth, CBitHeight );
107
108 hPrevB = SelectObject( hDC, hComboBmp);
109 SetRect( &r, 0, 0, CBitWidth, CBitHeight );
110 InvertRect( hDC, &r );
111 SelectObject( hDC, hPrevB );
112 bRet = TRUE;
113 }
114 DeleteDC( hDC );
115 return bRet;
116 }
117 return FALSE;
118}
static HBITMAP hComboBmp
Definition: combo.c:66
static UINT CBitWidth
Definition: combo.c:67
static UINT CBitHeight
Definition: combo.c:67
static HBITMAP
Definition: button.c:44
Definition: bl.h:1331
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI InvertRect(_In_ HDC, _In_ LPCRECT)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2163
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

◆ COMBO_ItemOp()

static LRESULT COMBO_ItemOp ( LPHEADCOMBO  lphc,
UINT  msg,
LPARAM  lParam 
)
static

Definition at line 1328 of file combo.c.

1329{
1330 HWND hWnd = lphc->self;
1332
1333 TRACE("[%p]: ownerdraw op %04x\n", lphc->self, msg );
1334
1335 switch( msg )
1336 {
1337 case WM_DELETEITEM:
1338 {
1340 lpIS->CtlType = ODT_COMBOBOX;
1341 lpIS->CtlID = id;
1342 lpIS->hwndItem = hWnd;
1343 break;
1344 }
1345 case WM_DRAWITEM:
1346 {
1348 lpIS->CtlType = ODT_COMBOBOX;
1349 lpIS->CtlID = id;
1350 lpIS->hwndItem = hWnd;
1351 break;
1352 }
1353 case WM_COMPAREITEM:
1354 {
1356 lpIS->CtlType = ODT_COMBOBOX;
1357 lpIS->CtlID = id;
1358 lpIS->hwndItem = hWnd;
1359 break;
1360 }
1361 case WM_MEASUREITEM:
1362 {
1364 lpIS->CtlType = ODT_COMBOBOX;
1365 lpIS->CtlID = id;
1366 break;
1367 }
1368 }
1369 return SendMessageW(lphc->owner, msg, id, lParam);
1370}
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139
#define WM_DELETEITEM
Definition: winuser.h:1647
#define WM_COMPAREITEM
Definition: winuser.h:1655

◆ COMBO_KillFocus()

static void COMBO_KillFocus ( LPHEADCOMBO  lphc)
static

Definition at line 1183 of file combo.c.

1184{
1185 HWND hWnd = lphc->self;
1186
1187 if( lphc->wState & CBF_FOCUSED )
1188 {
1189 CBRollUp( lphc, FALSE, TRUE );
1190 if( IsWindow( hWnd ) )
1191 {
1192 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1193 SendMessageW(lphc->hWndLBox, LB_CARETOFF, 0, 0);
1194
1195 lphc->wState &= ~CBF_FOCUSED;
1196
1197 /* redraw text */
1198 if( !(lphc->wState & CBF_EDIT) )
1199 InvalidateRect(lphc->self, &lphc->textRect, TRUE);
1200
1201 CB_NOTIFY( lphc, CBN_KILLFOCUS );
1202 }
1203 }
1204}
#define LB_CARETOFF
Definition: undocuser.h:52
#define CBN_KILLFOCUS
Definition: winuser.h:1978

◆ COMBO_LButtonDown()

static void COMBO_LButtonDown ( LPHEADCOMBO  lphc,
LPARAM  lParam 
)
static

Definition at line 1665 of file combo.c.

1666{
1667 POINT pt;
1668 BOOL bButton;
1669 HWND hWnd = lphc->self;
1670
1671 pt.x = (short)LOWORD(lParam);
1672 pt.y = (short)HIWORD(lParam);
1673 bButton = PtInRect(&lphc->buttonRect, pt);
1674
1675 if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
1676 (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) )
1677 {
1678 lphc->wState |= CBF_BUTTONDOWN;
1679 if( lphc->wState & CBF_DROPPED )
1680 {
1681 /* got a click to cancel selection */
1682
1683 lphc->wState &= ~CBF_BUTTONDOWN;
1684 CBRollUp( lphc, TRUE, FALSE );
1685 if( !IsWindow( hWnd ) ) return;
1686
1687 if( lphc->wState & CBF_CAPTURE )
1688 {
1689 lphc->wState &= ~CBF_CAPTURE;
1691 }
1692 }
1693 else
1694 {
1695 /* drop down the listbox and start tracking */
1696
1697 lphc->wState |= CBF_CAPTURE;
1698 SetCapture( hWnd );
1699 CBDropDown( lphc );
1700 }
1701 if( bButton ) CBRepaintButton( lphc );
1702 }
1703}
static void CBRepaintButton(LPHEADCOMBO lphc)
Definition: combo.c:1131
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
#define LOWORD(l)
Definition: pedump.c:82
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)

◆ COMBO_LButtonUp()

static void COMBO_LButtonUp ( LPHEADCOMBO  lphc)
static

Definition at line 1710 of file combo.c.

1711{
1712 if( lphc->wState & CBF_CAPTURE )
1713 {
1714 lphc->wState &= ~CBF_CAPTURE;
1715 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1716 {
1717 INT index = CBUpdateLBox( lphc, TRUE );
1718 /* Update edit only if item is in the list */
1719 if(index >= 0)
1720 {
1721 lphc->wState |= CBF_NOLBSELECT;
1722 CBUpdateEdit( lphc, index );
1723 lphc->wState &= ~CBF_NOLBSELECT;
1724 }
1725 }
1727 SetCapture(lphc->hWndLBox);
1728 }
1729
1730 if( lphc->wState & CBF_BUTTONDOWN )
1731 {
1732 lphc->wState &= ~CBF_BUTTONDOWN;
1733 CBRepaintButton( lphc );
1734 }
1735}

◆ COMBO_MouseMove()

static void COMBO_MouseMove ( LPHEADCOMBO  lphc,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1743 of file combo.c.

1744{
1745 POINT pt;
1746 RECT lbRect;
1747
1748 pt.x = (short)LOWORD(lParam);
1749 pt.y = (short)HIWORD(lParam);
1750
1751 if( lphc->wState & CBF_BUTTONDOWN )
1752 {
1753 BOOL bButton;
1754
1755 bButton = PtInRect(&lphc->buttonRect, pt);
1756
1757 if( !bButton )
1758 {
1759 lphc->wState &= ~CBF_BUTTONDOWN;
1760 CBRepaintButton( lphc );
1761 }
1762 }
1763
1764 GetClientRect( lphc->hWndLBox, &lbRect );
1765 MapWindowPoints( lphc->self, lphc->hWndLBox, &pt, 1 );
1766 if( PtInRect(&lbRect, pt) )
1767 {
1768 lphc->wState &= ~CBF_CAPTURE;
1770 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc, TRUE );
1771
1772 /* hand over pointer tracking */
1774 }
1775}
#define WM_LBUTTONDOWN
Definition: winuser.h:1776

◆ COMBO_NCCreate()

static LRESULT COMBO_NCCreate ( HWND  hwnd,
LONG  style 
)
static

Definition at line 135 of file combo.c.

136{
137 LPHEADCOMBO lphc;
138
139 if (COMBO_Init() && (lphc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(HEADCOMBO))) )
140 {
141 lphc->self = hwnd;
142 SetWindowLongPtrW( hwnd, 0, (LONG_PTR)lphc );
143
144#ifdef __REACTOS__
145 COMBO_update_uistate(lphc);
146#endif
147
148 /* some braindead apps do try to use scrollbar/border flags */
149
152
153 /*
154 * We also have to remove the client edge style to make sure
155 * we don't end-up with a non client area.
156 */
159
161 lphc->dwStyle |= CBS_HASSTRINGS;
163 lphc->wState |= CBF_NOTIFY;
164
165 TRACE("[%p], style = %08x\n", lphc, lphc->dwStyle );
166 return TRUE;
167 }
168 return FALSE;
169}
#define CBF_NOTIFY
Definition: controls.h:53
static BOOL COMBO_Init(void)
Definition: combo.c:87
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_EX_NOPARENTNOTIFY
Definition: pedump.c:646
#define WS_HSCROLL
Definition: pedump.c:628
#define SetWindowLongPtrW
Definition: winuser.h:5346
#define GWL_STYLE
Definition: winuser.h:852
#define GWL_EXSTYLE
Definition: winuser.h:851

◆ COMBO_NCDestroy()

static LRESULT COMBO_NCDestroy ( LPHEADCOMBO  lphc)
static

Definition at line 174 of file combo.c.

175{
176 if (lphc)
177 {
178 TRACE("[%p]: freeing storage\n", lphc->self);
179
180 if ( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox )
181 DestroyWindow( lphc->hWndLBox );
182
183 SetWindowLongPtrW( lphc->self, 0, 0 );
184 HeapFree( GetProcessHeap(), 0, lphc );
185 }
186 return 0;
187}
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ COMBO_Paint()

static LRESULT COMBO_Paint ( LPHEADCOMBO  lphc,
HDC  hParamDC 
)
static

Definition at line 855 of file combo.c.

856{
857 PAINTSTRUCT ps;
858 HDC hDC;
859
860 hDC = (hParamDC) ? hParamDC : BeginPaint(lphc->self, &ps);
861
862 TRACE("hdc=%p\n", hDC);
863
864 if( hDC && !(lphc->wState & CBF_NOREDRAW) )
865 {
866 HBRUSH hPrevBrush, hBkgBrush;
867
868 /*
869 * Retrieve the background brush and select it in the
870 * DC.
871 */
872 hBkgBrush = COMBO_PrepareColors(lphc, hDC);
873 hPrevBrush = SelectObject(hDC, hBkgBrush);
874 if (!(lphc->wState & CBF_EDIT))
875 FillRect(hDC, &lphc->textRect, hBkgBrush);
876
877 /*
878 * In non 3.1 look, there is a sunken border on the combobox
879 */
880 CBPaintBorder(lphc->self, lphc, hDC);
881
882 if (!IsRectEmpty(&lphc->buttonRect))
883 CBPaintButton(lphc, hDC, lphc->buttonRect);
884
885 /* paint the edit control padding area */
886 if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST)
887 {
888 RECT rPadEdit = lphc->textRect;
889
891
893 }
894
895 if (!(lphc->wState & CBF_EDIT))
896 CBPaintText( lphc, hDC );
897
898 if (hPrevBrush)
899 SelectObject( hDC, hPrevBrush );
900 }
901
902 if( !hParamDC )
903 EndPaint(lphc->self, &ps);
904
905 return 0;
906}
static void CBPaintBorder(HWND hwnd, const HEADCOMBO *lphc, HDC hdc)
Definition: combo.c:780
static void CBPaintText(HEADCOMBO *lphc, HDC hdc_paint)
Definition: combo.c:659
static void CBPaintButton(LPHEADCOMBO lphc, HDC hdc, RECT rectButton)
Definition: combo.c:592
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)
#define COLOR_WINDOW
Definition: winuser.h:918
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

◆ COMBO_PrepareColors()

static HBRUSH COMBO_PrepareColors ( LPHEADCOMBO  lphc,
HDC  hDC 
)
static

Definition at line 650 of file combo.c.

653{
654 HBRUSH hBkgBrush;
655
656 /*
657 * Get the background brush for this control.
658 */
659 if (CB_DISABLED(lphc))
660 {
661#ifdef __REACTOS__
662 hBkgBrush = GetControlColor(lphc->owner, lphc->self, hDC, WM_CTLCOLORSTATIC);
663#else
664 hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLORSTATIC,
665 (WPARAM)hDC, (LPARAM)lphc->self );
666#endif
667 /*
668 * We have to change the text color since WM_CTLCOLORSTATIC will
669 * set it to the "enabled" color. This is the same behavior as the
670 * edit control
671 */
673 }
674 else
675 {
676 /* FIXME: In which cases WM_CTLCOLORLISTBOX should be sent? */
677#ifdef __REACTOS__
678 hBkgBrush = GetControlColor(lphc->owner, lphc->self, hDC, WM_CTLCOLOREDIT);
679#else
680 hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLOREDIT,
681 (WPARAM)hDC, (LPARAM)lphc->self );
682#endif
683 }
684
685 /*
686 * Catch errors.
687 */
688 if( !hBkgBrush )
689 hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
690
691 return hBkgBrush;
692}
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:154
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1772
#define COLOR_GRAYTEXT
Definition: winuser.h:932
#define WM_CTLCOLOREDIT
Definition: winuser.h:1767

◆ COMBO_SelectString()

static LRESULT COMBO_SelectString ( LPHEADCOMBO  lphc,
INT  start,
LPARAM  pText,
BOOL  unicode 
)
static

Definition at line 1646 of file combo.c.

1647{
1649 SendMessageA(lphc->hWndLBox, LB_SELECTSTRING, (WPARAM)start, pText);
1650 if( index >= 0 )
1651 {
1652 if( lphc->wState & CBF_EDIT )
1653 CBUpdateEdit( lphc, index );
1654 else
1655 {
1656 InvalidateRect(lphc->self, &lphc->textRect, TRUE);
1657 }
1658 }
1659 return (LRESULT)index;
1660}
#define index(s, c)
Definition: various.h:29
GLuint start
Definition: gl.h:1545
LONG_PTR LRESULT
Definition: windef.h:209
#define LB_SELECTSTRING
Definition: winuser.h:2056

◆ COMBO_SetFocus()

static void COMBO_SetFocus ( LPHEADCOMBO  lphc)
static

Definition at line 1161 of file combo.c.

1162{
1163 if( !(lphc->wState & CBF_FOCUSED) )
1164 {
1165 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1166 SendMessageW(lphc->hWndLBox, LB_CARETON, 0, 0);
1167
1168 /* This is wrong. Message sequences seem to indicate that this
1169 is set *after* the notify. */
1170 /* lphc->wState |= CBF_FOCUSED; */
1171
1172 if( !(lphc->wState & CBF_EDIT) )
1173 InvalidateRect(lphc->self, &lphc->textRect, TRUE);
1174
1175 CB_NOTIFY( lphc, CBN_SETFOCUS );
1176 lphc->wState |= CBF_FOCUSED;
1177 }
1178}
#define CBN_SETFOCUS
Definition: winuser.h:1982

◆ COMBO_SetItemHeight()

static LRESULT COMBO_SetItemHeight ( LPHEADCOMBO  lphc,
INT  index,
INT  height 
)
static

Definition at line 1607 of file combo.c.

1608{
1609 LRESULT lRet = CB_ERR;
1610
1611 if( index == -1 ) /* set text field height */
1612 {
1613 if( height < 32768 )
1614 {
1615 lphc->editHeight = height + 2; /* Is the 2 for 2*EDIT_CONTROL_PADDING? */
1616
1617 /*
1618 * Redo the layout of the control.
1619 */
1620 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1621 {
1622 CBCalcPlacement(lphc->self,
1623 lphc,
1624 &lphc->textRect,
1625 &lphc->buttonRect,
1626 &lphc->droppedRect);
1627
1628 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1629 }
1630 else
1631 {
1632 CBForceDummyResize(lphc);
1633 }
1634
1635 lRet = height;
1636 }
1637 }
1638 else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */
1640 return lRet;
1641}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define CB_ERR
Definition: winuser.h:2435
#define LB_SETITEMHEIGHT
Definition: winuser.h:2066

◆ COMBO_Size()

static void COMBO_Size ( LPHEADCOMBO  lphc)
static

Definition at line 1518 of file combo.c.

1519{
1520 /*
1521 * Those controls are always the same height. So we have to make sure
1522 * they are not resized to another value.
1523 */
1524 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
1525 {
1526 int newComboHeight, curComboHeight, curComboWidth;
1527 RECT rc;
1528
1529 GetWindowRect(lphc->self, &rc);
1530 curComboHeight = rc.bottom - rc.top;
1531 curComboWidth = rc.right - rc.left;
1532 newComboHeight = CBGetTextAreaHeight(lphc->self, lphc) + 2*COMBO_YBORDERSIZE();
1533
1534 /*
1535 * Resizing a combobox has another side effect, it resizes the dropped
1536 * rectangle as well. However, it does it only if the new height for the
1537 * combobox is more than the height it should have. In other words,
1538 * if the application resizing the combobox only had the intention to resize
1539 * the actual control, for example, to do the layout of a dialog that is
1540 * resized, the height of the dropdown is not changed.
1541 */
1542 if( curComboHeight > newComboHeight )
1543 {
1544 TRACE("oldComboHeight=%d, newComboHeight=%d, oldDropBottom=%d, oldDropTop=%d\n",
1545 curComboHeight, newComboHeight, lphc->droppedRect.bottom,
1546 lphc->droppedRect.top);
1547 lphc->droppedRect.bottom = lphc->droppedRect.top + curComboHeight - newComboHeight;
1548 }
1549 /*
1550 * Restore original height
1551 */
1552 if( curComboHeight != newComboHeight )
1553 SetWindowPos(lphc->self, 0, 0, 0, curComboWidth, newComboHeight,
1555 }
1556
1557 CBCalcPlacement(lphc->self,
1558 lphc,
1559 &lphc->textRect,
1560 &lphc->buttonRect,
1561 &lphc->droppedRect);
1562
1563 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, FALSE );
1564}

◆ ComboWndProc_common()

LRESULT WINAPI ComboWndProc_common ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode 
)

Definition at line 1814 of file combo.c.

1815{
1817#ifdef __REACTOS__
1818 PWND pWnd;
1819
1820 pWnd = ValidateHwnd(hwnd);
1821 if (pWnd)
1822 {
1823 if (!pWnd->fnid)
1824 {
1826 }
1827 else
1828 {
1829 if (pWnd->fnid != FNID_COMBOBOX)
1830 {
1831 ERR("Wrong window class for ComboBox! fnId 0x%x\n",pWnd->fnid);
1832 return 0;
1833 }
1834 }
1835 }
1836#endif
1837
1838 TRACE("[%p]: msg %s wp %08lx lp %08lx\n", hwnd, SPY_GetMsgName(message, hwnd), wParam, lParam);
1839
1840#ifndef __REACTOS__
1841 if (!IsWindow(hwnd)) return 0;
1842#endif
1843
1844 if (lphc || message == WM_NCCREATE)
1845 switch(message)
1846 {
1847 case WM_NCCREATE:
1848 {
1849 LONG style = unicode ? ((LPCREATESTRUCTW)lParam)->style : ((LPCREATESTRUCTA)lParam)->style;
1850 return COMBO_NCCreate(hwnd, style);
1851 }
1852 case WM_NCDESTROY:
1853 COMBO_NCDestroy(lphc);
1854#ifdef __REACTOS__
1856#endif
1857 break;/* -> DefWindowProc */
1858
1859 case WM_CREATE:
1860 {
1862 LONG style;
1863 if(unicode)
1864 {
1865 hwndParent = ((LPCREATESTRUCTW)lParam)->hwndParent;
1866 style = ((LPCREATESTRUCTW)lParam)->style;
1867 }
1868 else
1869 {
1870 hwndParent = ((LPCREATESTRUCTA)lParam)->hwndParent;
1871 style = ((LPCREATESTRUCTA)lParam)->style;
1872 }
1873 return COMBO_Create(hwnd, lphc, hwndParent, style, unicode);
1874 }
1875 case WM_PRINTCLIENT:
1876 /* Fallthrough */
1877 case WM_PAINT:
1878 /* wParam may contain a valid HDC! */
1879 return COMBO_Paint(lphc, (HDC)wParam);
1880 case WM_ERASEBKGND:
1881 /* do all painting in WM_PAINT like Windows does */
1882 return 1;
1883
1884 case WM_GETDLGCODE:
1885 {
1887 if (lParam && (((LPMSG)lParam)->message == WM_KEYDOWN))
1888 {
1889 int vk = (int)((LPMSG)lParam)->wParam;
1890
1891 if ((vk == VK_RETURN || vk == VK_ESCAPE) && (lphc->wState & CBF_DROPPED))
1893 }
1894 return result;
1895 }
1896 case WM_SIZE:
1897 if (lphc->hWndLBox && !(lphc->wState & CBF_NORESIZE))
1898 COMBO_Size( lphc );
1899 return TRUE;
1900 case WM_SETFONT:
1901 COMBO_Font( lphc, (HFONT)wParam, (BOOL)lParam );
1902 return TRUE;
1903 case WM_GETFONT:
1904 return (LRESULT)lphc->hFont;
1905 case WM_SETFOCUS:
1906 if (lphc->wState & CBF_EDIT)
1907 {
1908 SetFocus( lphc->hWndEdit );
1909 /* The first time focus is received, select all the text */
1910 if (!(lphc->wState & CBF_BEENFOCUSED))
1911 {
1912 SendMessageW(lphc->hWndEdit, EM_SETSEL, 0, -1);
1913 lphc->wState |= CBF_BEENFOCUSED;
1914 }
1915 }
1916 else
1917 COMBO_SetFocus( lphc );
1918 return TRUE;
1919 case WM_KILLFOCUS:
1920 {
1921 HWND hwndFocus = WIN_GetFullHandle((HWND)wParam);
1922 if (!hwndFocus || (hwndFocus != lphc->hWndEdit && hwndFocus != lphc->hWndLBox))
1923 COMBO_KillFocus( lphc );
1924 return TRUE;
1925 }
1926 case WM_COMMAND:
1928 case WM_GETTEXT:
1929 return unicode ? COMBO_GetTextW( lphc, wParam, (LPWSTR)lParam )
1930 : COMBO_GetTextA( lphc, wParam, (LPSTR)lParam );
1931 case WM_SETTEXT:
1932 case WM_GETTEXTLENGTH:
1933 case WM_CLEAR:
1934 if ((message == WM_GETTEXTLENGTH) && !ISWIN31 && !(lphc->wState & CBF_EDIT))
1935 {
1936 int j = SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
1937 if (j == -1) return 0;
1938 return unicode ? SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, j, 0) :
1939 SendMessageA(lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
1940 }
1941 else if ( lphc->wState & CBF_EDIT )
1942 {
1943 LRESULT ret;
1944 lphc->wState |= CBF_NOEDITNOTIFY;
1945 ret = unicode ? SendMessageW(lphc->hWndEdit, message, wParam, lParam) :
1946 SendMessageA(lphc->hWndEdit, message, wParam, lParam);
1947 lphc->wState &= ~CBF_NOEDITNOTIFY;
1948 return ret;
1949 }
1950 else
1951 return CB_ERR;
1952 case WM_CUT:
1953 case WM_PASTE:
1954 case WM_COPY:
1955 if (lphc->wState & CBF_EDIT)
1956 {
1957 return unicode ? SendMessageW(lphc->hWndEdit, message, wParam, lParam) :
1958 SendMessageA(lphc->hWndEdit, message, wParam, lParam);
1959 }
1960 else return CB_ERR;
1961
1962 case WM_DRAWITEM:
1963 case WM_DELETEITEM:
1964 case WM_COMPAREITEM:
1965 case WM_MEASUREITEM:
1966 return COMBO_ItemOp(lphc, message, lParam);
1967 case WM_ENABLE:
1968 if (lphc->wState & CBF_EDIT)
1969 EnableWindow( lphc->hWndEdit, (BOOL)wParam );
1970 EnableWindow( lphc->hWndLBox, (BOOL)wParam );
1971
1972 /* Force the control to repaint when the enabled state changes. */
1973 InvalidateRect(lphc->self, NULL, TRUE);
1974 return TRUE;
1975 case WM_SETREDRAW:
1976 if (wParam)
1977 lphc->wState &= ~CBF_NOREDRAW;
1978 else
1979 lphc->wState |= CBF_NOREDRAW;
1980
1981 if ( lphc->wState & CBF_EDIT )
1984 return 0;
1985 case WM_SYSKEYDOWN:
1986#ifdef __REACTOS__
1987 if ( KF_ALTDOWN & HIWORD(lParam) )
1988#else
1989 if ( KEYDATA_ALT & HIWORD(lParam) )
1990#endif
1991 if( wParam == VK_UP || wParam == VK_DOWN )
1992#ifdef __REACTOS__
1993 {
1994#endif
1995 COMBO_FlipListbox( lphc, FALSE, FALSE );
1996 return 0;
1997#ifdef __REACTOS__
1998 }
1999 break;
2000#endif
2001
2002 case WM_KEYDOWN:
2003 if ((wParam == VK_RETURN || wParam == VK_ESCAPE) &&
2004 (lphc->wState & CBF_DROPPED))
2005 {
2006 CBRollUp( lphc, wParam == VK_RETURN, FALSE );
2007 return TRUE;
2008 }
2009 else if ((wParam == VK_F4) && !(lphc->wState & CBF_EUI))
2010 {
2011 COMBO_FlipListbox( lphc, FALSE, FALSE );
2012 return TRUE;
2013 }
2014 /* fall through */
2015 case WM_CHAR:
2016 case WM_IME_CHAR:
2017 {
2018 HWND hwndTarget;
2019
2020#ifdef __REACTOS__
2021 if (lphc->wState & CBF_DROPPED)
2022 lphc->wState |= CBF_NOROLLUP;
2023#endif
2024 if ( lphc->wState & CBF_EDIT )
2025 hwndTarget = lphc->hWndEdit;
2026 else
2027 hwndTarget = lphc->hWndLBox;
2028
2029 return unicode ? SendMessageW(hwndTarget, message, wParam, lParam) :
2030 SendMessageA(hwndTarget, message, wParam, lParam);
2031 }
2032 case WM_LBUTTONDOWN:
2033 if ( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self );
2034 if ( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam );
2035 return TRUE;
2036 case WM_LBUTTONUP:
2037 COMBO_LButtonUp( lphc );
2038 return TRUE;
2039 case WM_MOUSEMOVE:
2040 if ( lphc->wState & CBF_CAPTURE )
2041 COMBO_MouseMove( lphc, wParam, lParam );
2042 return TRUE;
2043
2044 case WM_MOUSEWHEEL:
2045 if (wParam & (MK_SHIFT | MK_CONTROL))
2046 return unicode ? DefWindowProcW(hwnd, message, wParam, lParam) :
2048
2049 if (GET_WHEEL_DELTA_WPARAM(wParam) > 0) return SendMessageW(hwnd, WM_KEYDOWN, VK_UP, 0);
2050 if (GET_WHEEL_DELTA_WPARAM(wParam) < 0) return SendMessageW(hwnd, WM_KEYDOWN, VK_DOWN, 0);
2051 return TRUE;
2052
2053 case WM_CTLCOLOR:
2054 case WM_CTLCOLORMSGBOX:
2055 case WM_CTLCOLOREDIT:
2056 case WM_CTLCOLORLISTBOX:
2057 case WM_CTLCOLORBTN:
2058 case WM_CTLCOLORDLG:
2060 case WM_CTLCOLORSTATIC:
2061#ifdef __REACTOS__
2062 if (pWnd && !(pWnd->state2 & WNDS2_WIN40COMPAT)) break; // Must be Win 4.0 and above.
2063#endif
2064 if (lphc->owner)
2065 return SendMessageW(lphc->owner, message, wParam, lParam);
2066 break;
2067
2068 /* Combo messages */
2069 case CB_ADDSTRING:
2070 if (unicode)
2071 {
2072 if (lphc->dwStyle & CBS_LOWERCASE)
2074 else if (lphc->dwStyle & CBS_UPPERCASE)
2076 return SendMessageW(lphc->hWndLBox, LB_ADDSTRING, 0, lParam);
2077 }
2078 else /* unlike the unicode version, the ansi version does not overwrite
2079 the string if converting case */
2080 {
2081 char *string = NULL;
2082 LRESULT ret;
2083 if (lphc->dwStyle & CBS_LOWERCASE)
2084 {
2085 string = strdupA((LPSTR)lParam);
2086 CharLowerA(string);
2087 }
2088
2089 else if (lphc->dwStyle & CBS_UPPERCASE)
2090 {
2091 string = strdupA((LPSTR)lParam);
2092 CharUpperA(string);
2093 }
2094
2095 ret = SendMessageA(lphc->hWndLBox, LB_ADDSTRING, 0, string ? (LPARAM)string : lParam);
2096 HeapFree(GetProcessHeap(), 0, string);
2097 return ret;
2098 }
2099 case CB_INSERTSTRING:
2100 if (unicode)
2101 {
2102 if (lphc->dwStyle & CBS_LOWERCASE)
2104 else if (lphc->dwStyle & CBS_UPPERCASE)
2107 }
2108 else
2109 {
2110 if (lphc->dwStyle & CBS_LOWERCASE)
2112 else if (lphc->dwStyle & CBS_UPPERCASE)
2115 }
2116 case CB_DELETESTRING:
2117 return unicode ? SendMessageW(lphc->hWndLBox, LB_DELETESTRING, wParam, 0) :
2118 SendMessageA(lphc->hWndLBox, LB_DELETESTRING, wParam, 0);
2119 case CB_SELECTSTRING:
2120 return COMBO_SelectString(lphc, (INT)wParam, lParam, unicode);
2121 case CB_FINDSTRING:
2122 return unicode ? SendMessageW(lphc->hWndLBox, LB_FINDSTRING, wParam, lParam) :
2123 SendMessageA(lphc->hWndLBox, LB_FINDSTRING, wParam, lParam);
2124 case CB_FINDSTRINGEXACT:
2125 return unicode ? SendMessageW(lphc->hWndLBox, LB_FINDSTRINGEXACT, wParam, lParam) :
2126 SendMessageA(lphc->hWndLBox, LB_FINDSTRINGEXACT, wParam, lParam);
2127 case CB_SETITEMHEIGHT:
2128 return COMBO_SetItemHeight( lphc, (INT)wParam, (INT)lParam);
2129 case CB_GETITEMHEIGHT:
2130 if ((INT)wParam >= 0) /* listbox item */
2131 return SendMessageW(lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0);
2132 return CBGetTextAreaHeight(hwnd, lphc);
2133 case CB_RESETCONTENT:
2135 if ((lphc->wState & CBF_EDIT) && CB_HASSTRINGS(lphc))
2136 {
2137 static const WCHAR empty_stringW[] = { 0 };
2139 }
2140 else
2141 InvalidateRect(lphc->self, NULL, TRUE);
2142 return TRUE;
2143 case CB_INITSTORAGE:
2146 return SendMessageW(lphc->hWndLBox, LB_GETHORIZONTALEXTENT, 0, 0);
2149 case CB_GETTOPINDEX:
2150 return SendMessageW(lphc->hWndLBox, LB_GETTOPINDEX, 0, 0);
2151 case CB_GETLOCALE:
2152 return SendMessageW(lphc->hWndLBox, LB_GETLOCALE, 0, 0);
2153 case CB_SETLOCALE:
2154 return SendMessageW(lphc->hWndLBox, LB_SETLOCALE, wParam, 0);
2155 case CB_SETDROPPEDWIDTH:
2156 if ((CB_GETTYPE(lphc) == CBS_SIMPLE) || (INT)wParam >= 32768)
2157 return CB_ERR;
2158 /* new value must be higher than combobox width */
2159 if ((INT)wParam >= lphc->droppedRect.right - lphc->droppedRect.left)
2160 lphc->droppedWidth = wParam;
2161 else if (wParam)
2162 lphc->droppedWidth = 0;
2163
2164 /* recalculate the combobox area */
2165 CBCalcPlacement(hwnd, lphc, &lphc->textRect, &lphc->buttonRect, &lphc->droppedRect );
2166
2167 /* fall through */
2168 case CB_GETDROPPEDWIDTH:
2169 if (lphc->droppedWidth)
2170 return lphc->droppedWidth;
2171 return lphc->droppedRect.right - lphc->droppedRect.left;
2174 return CB_OKAY;
2175 case CB_GETDROPPEDSTATE:
2176 return (lphc->wState & CBF_DROPPED) != 0;
2177 case CB_DIR:
2178 return unicode ? SendMessageW(lphc->hWndLBox, LB_DIR, wParam, lParam) :
2179 SendMessageA(lphc->hWndLBox, LB_DIR, wParam, lParam);
2180
2181 case CB_SHOWDROPDOWN:
2182 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
2183 {
2184 if (wParam)
2185 {
2186 if (!(lphc->wState & CBF_DROPPED))
2187 CBDropDown( lphc );
2188 }
2189 else if (lphc->wState & CBF_DROPPED)
2190 CBRollUp( lphc, FALSE, TRUE );
2191 }
2192 return TRUE;
2193 case CB_GETCOUNT:
2194 return SendMessageW(lphc->hWndLBox, LB_GETCOUNT, 0, 0);
2195 case CB_GETCURSEL:
2196 return SendMessageW(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
2197 case CB_SETCURSEL:
2199 if (lParam >= 0)
2201
2202 /* no LBN_SELCHANGE in this case, update manually */
2203 CBPaintText(lphc, NULL);
2204 lphc->wState &= ~CBF_SELCHANGE;
2205 return lParam;
2206 case CB_GETLBTEXT:
2207 return unicode ? SendMessageW(lphc->hWndLBox, LB_GETTEXT, wParam, lParam) :
2208 SendMessageA(lphc->hWndLBox, LB_GETTEXT, wParam, lParam);
2209 case CB_GETLBTEXTLEN:
2210 return unicode ? SendMessageW(lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0) :
2211 SendMessageA(lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
2212 case CB_GETITEMDATA:
2213 return SendMessageW(lphc->hWndLBox, LB_GETITEMDATA, wParam, 0);
2214 case CB_SETITEMDATA:
2216 case CB_GETEDITSEL:
2217 /* Edit checks passed parameters itself */
2218 if (lphc->wState & CBF_EDIT)
2219 return SendMessageW(lphc->hWndEdit, EM_GETSEL, wParam, lParam);
2220 return CB_ERR;
2221 case CB_SETEDITSEL:
2222 if (lphc->wState & CBF_EDIT)
2224 return CB_ERR;
2225 case CB_SETEXTENDEDUI:
2226 if (CB_GETTYPE(lphc) == CBS_SIMPLE )
2227 return CB_ERR;
2228 if (wParam)
2229 lphc->wState |= CBF_EUI;
2230 else lphc->wState &= ~CBF_EUI;
2231 return CB_OKAY;
2232 case CB_GETEXTENDEDUI:
2233 return (lphc->wState & CBF_EUI) != 0;
2234 case CB_GETCOMBOBOXINFO:
2235 return COMBO_GetComboBoxInfo(lphc, (COMBOBOXINFO *)lParam);
2236 case CB_LIMITTEXT:
2237 if (lphc->wState & CBF_EDIT)
2239 return TRUE;
2240
2241#ifdef __REACTOS__
2242 case WM_UPDATEUISTATE:
2243 if (unicode)
2245 else
2247
2248 if (COMBO_update_uistate(lphc))
2249 {
2250 /* redraw text */
2251 if (!(lphc->wState & CBF_EDIT))
2252 NtUserInvalidateRect(lphc->self, &lphc->textRect, TRUE);
2253 }
2254 break;
2255
2256 case WM_CBLOSTTEXTFOCUS: /* undocumented message - deselects the text when focus is lost */
2257 if (lphc->hWndEdit != NULL)
2258 {
2259 SendMessage(lphc->self, WM_LBUTTONUP, 0, 0xFFFFFFFF);
2260 SendMessage(lphc->hWndEdit, EM_SETSEL, 0, 0);
2261 lphc->wState &= ~(CBF_FOCUSED | CBF_BEENFOCUSED);
2262 CB_NOTIFY(lphc, CBN_KILLFOCUS);
2263 }
2264 return TRUE;
2265#endif
2266
2267 default:
2268 if (message >= WM_USER)
2269 WARN("unknown msg WM_USER+%04x wp=%04lx lp=%08lx\n", message - WM_USER, wParam, lParam );
2270 break;
2271 }
2272 return unicode ? DefWindowProcW(hwnd, message, wParam, lParam) :
2274}
signed short INT16
#define WARN(fmt,...)
Definition: debug.h:112
struct HEADCOMBO * LPHEADCOMBO
#define CBF_EUI
Definition: controls.h:59
#define CBF_BEENFOCUSED
Definition: controls.h:58
#define CBF_NORESIZE
Definition: controls.h:52
static LRESULT COMBO_Paint(HEADCOMBO *lphc, HDC hdc)
Definition: combo.c:842
static LRESULT COMBO_NCDestroy(HEADCOMBO *lphc)
Definition: combo.c:157
static LRESULT COMBO_NCCreate(HWND hwnd, LONG style)
Definition: combo.c:122
#define ISWIN31
Definition: combo.c:61
static void COMBO_LButtonDown(LPHEADCOMBO lphc, LPARAM lParam)
Definition: combo.c:1582
static void COMBO_MouseMove(LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam)
Definition: combo.c:1660
static LRESULT COMBO_GetComboBoxInfo(const HEADCOMBO *lphc, COMBOBOXINFO *pcbi)
Definition: combo.c:1694
static LRESULT COMBO_Command(LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd)
Definition: combo.c:1188
static void COMBO_LButtonUp(LPHEADCOMBO lphc)
Definition: combo.c:1627
static void COMBO_Size(LPHEADCOMBO lphc)
Definition: combo.c:1436
#define KEYDATA_ALT
Definition: combo.c:44
static LRESULT COMBO_ItemOp(LPHEADCOMBO lphc, UINT msg, LPARAM lParam)
Definition: combo.c:1297
static LRESULT COMBO_SelectString(LPHEADCOMBO lphc, INT start, LPARAM pText)
Definition: combo.c:1564
BOOL COMBO_FlipListbox(LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton)
Definition: combo.c:1116
static LRESULT COMBO_SetItemHeight(LPHEADCOMBO lphc, INT index, INT height)
Definition: combo.c:1525
static void COMBO_Font(LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw)
Definition: combo.c:1488
static void CBGetDroppedControlRect(LPHEADCOMBO lphc, LPRECT lpRect)
Definition: combo.c:421
static LRESULT COMBO_Create(HWND hwnd, LPHEADCOMBO lphc, HWND hwndParent, LONG style)
Definition: combo.c:436
#define ValidateHwnd(hwnd)
Definition: precomp.h:85
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define WNDS2_WIN40COMPAT
Definition: ntuser.h:650
#define FNID_DESTROY
Definition: ntuser.h:898
#define FNID_COMBOBOX
Definition: ntuser.h:867
BOOL NTAPI NtUserInvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase)
Definition: painting.c:2535
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4330
WORD vk
Definition: input.c:77
long LONG
Definition: pedump.c:60
#define WM_PRINTCLIENT
Definition: richedit.h:70
Definition: ntuser.h:694
DWORD state2
Definition: ntuser.h:702
DWORD fnid
Definition: ntuser.h:709
Definition: tftpd.h:60
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define WM_CBLOSTTEXTFOCUS
Definition: undocuser.h:50
const char * SPY_GetMsgName(UINT msg, HWND hWnd)
Definition: spy.c:2218
#define WIN_GetFullHandle(h)
Definition: user_x.h:108
int ret
static LRESULT COMBO_GetTextW(LPHEADCOMBO lphc, INT count, LPWSTR buf)
Definition: combo.c:1376
static char * strdupA(LPCSTR str)
Definition: combo.c:1795
static LRESULT COMBO_GetTextA(LPHEADCOMBO lphc, INT count, LPSTR buf)
Definition: combo.c:1426
#define WM_CTLCOLOR
Definition: windowsx.h:29
#define WM_PAINT
Definition: winuser.h:1620
#define WM_ERASEBKGND
Definition: winuser.h:1625
#define CB_SELECTSTRING
Definition: winuser.h:1960
#define CB_SETITEMDATA
Definition: winuser.h:1966
#define CB_GETHORIZONTALEXTENT
Definition: winuser.h:1949
#define MK_SHIFT
Definition: winuser.h:2369
#define CB_SETDROPPEDWIDTH
Definition: winuser.h:1962
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2035
#define CB_GETLBTEXTLEN
Definition: winuser.h:1953
#define EM_LIMITTEXT
Definition: winuser.h:2000
#define CB_GETLBTEXT
Definition: winuser.h:1952
#define WM_ENABLE
Definition: winuser.h:1615
#define WM_PASTE
Definition: winuser.h:1863
#define LB_SETHORIZONTALEXTENT
Definition: winuser.h:2064
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_OKAY
Definition: winuser.h:2434
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1608
#define DLGC_WANTCHARS
Definition: winuser.h:2618
#define CB_SHOWDROPDOWN
Definition: winuser.h:1970
#define CB_GETITEMHEIGHT
Definition: winuser.h:1951
#define EM_GETSEL
Definition: winuser.h:1997
#define CB_SETHORIZONTALEXTENT
Definition: winuser.h:1965
#define LB_DIR
Definition: winuser.h:2033
#define WM_SIZE
Definition: winuser.h:1611
#define KF_ALTDOWN
Definition: winuser.h:2449
struct tagCREATESTRUCTA * LPCREATESTRUCTA
LPWSTR WINAPI CharLowerW(_Inout_ LPWSTR)
#define CB_INITSTORAGE
Definition: winuser.h:1956
LPSTR WINAPI CharLowerA(_Inout_ LPSTR)
#define CB_SETCURSEL
Definition: winuser.h:1961
#define LB_GETTOPINDEX
Definition: winuser.h:2051
#define VK_UP
Definition: winuser.h:2225
#define WM_SETFOCUS
Definition: winuser.h:1613
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define LB_GETLOCALE
Definition: winuser.h:2045
#define WM_CTLCOLORSCROLLBAR
Definition: winuser.h:1771
LPSTR WINAPI CharUpperA(_Inout_ LPSTR)
#define WM_CUT
Definition: winuser.h:1861
#define LB_SETLOCALE
Definition: winuser.h:2067
#define CB_RESETCONTENT
Definition: winuser.h:1959
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1940
#define LB_ADDSTRING
Definition: winuser.h:2031
#define CB_DIR
Definition: winuser.h:1938
#define CB_GETCOUNT
Definition: winuser.h:1942
#define WM_GETFONT
Definition: winuser.h:1651
#define CB_GETDROPPEDWIDTH
Definition: winuser.h:1946
#define CB_GETCOMBOBOXINFO
Definition: winuser.h:1941
#define WM_CTLCOLORMSGBOX
Definition: winuser.h:1766
#define CB_SETLOCALE
Definition: winuser.h:1968
#define WM_NCCREATE
Definition: winuser.h:1683
#define WM_CTLCOLORBTN
Definition: winuser.h:1769
#define WM_IME_CHAR
Definition: winuser.h:1834
#define LB_RESETCONTENT
Definition: winuser.h:2055
#define LB_DELETESTRING
Definition: winuser.h:2032
#define VK_RETURN
Definition: winuser.h:2201
#define CB_GETDROPPEDCONTROLRECT
Definition: winuser.h:1944
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MK_CONTROL
Definition: winuser.h:2370
#define LB_GETHORIZONTALEXTENT
Definition: winuser.h:2040
#define DLGC_WANTARROWS
Definition: winuser.h:2610
#define LB_INSERTSTRING
Definition: winuser.h:2053
#define CB_ADDSTRING
Definition: winuser.h:1936
#define CB_GETITEMDATA
Definition: winuser.h:1950
#define SendMessage
Definition: winuser.h:5843
#define CB_SETEDITSEL
Definition: winuser.h:1963
#define VK_F4
Definition: winuser.h:2258
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1945
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define WM_CHAR
Definition: winuser.h:1717
#define LB_SETITEMDATA
Definition: winuser.h:2065
#define WM_NCDESTROY
Definition: winuser.h:1684
#define CB_GETEXTENDEDUI
Definition: winuser.h:1948
#define VK_DOWN
Definition: winuser.h:2227
#define WM_COPY
Definition: winuser.h:1862
#define CB_GETTOPINDEX
Definition: winuser.h:1955
#define CB_LIMITTEXT
Definition: winuser.h:1958
#define WM_USER
Definition: winuser.h:1895
#define CB_GETEDITSEL
Definition: winuser.h:1947
#define WM_CTLCOLORLISTBOX
Definition: winuser.h:1768
#define DLGC_WANTMESSAGE
Definition: winuser.h:2613
#define CB_FINDSTRING
Definition: winuser.h:1939
#define WM_CLEAR
Definition: winuser.h:1864
#define WM_KEYDOWN
Definition: winuser.h:1715
#define CB_SETEXTENDEDUI
Definition: winuser.h:1964
#define CB_INSERTSTRING
Definition: winuser.h:1957
#define CB_GETCURSEL
Definition: winuser.h:1943
#define CB_DELETESTRING
Definition: winuser.h:1937
#define CB_GETLOCALE
Definition: winuser.h:1954
#define CB_SETITEMHEIGHT
Definition: winuser.h:1967
#define LB_INITSTORAGE
Definition: winuser.h:2052
#define VK_ESCAPE
Definition: winuser.h:2214
#define WM_CTLCOLORDLG
Definition: winuser.h:1770
#define WM_KILLFOCUS
Definition: winuser.h:1614
struct tagCREATESTRUCTW * LPCREATESTRUCTW
#define WM_SYSKEYDOWN
Definition: winuser.h:1719
#define WM_GETDLGCODE
Definition: winuser.h:1689
#define WM_SETREDRAW
Definition: winuser.h:1616
LPWSTR WINAPI CharUpperW(_Inout_ LPWSTR)

Referenced by RegisterClientPFN().

◆ GetComboBoxInfo()

BOOL WINAPI GetComboBoxInfo ( HWND  hwndCombo,
PCOMBOBOXINFO  pcbi 
)

Definition at line 2304 of file combo.c.

2307{
2308 TRACE("(%p, %p)\n", hwndCombo, pcbi);
2309#ifdef __REACTOS__
2310 return NtUserGetComboBoxInfo(hwndCombo, pcbi);
2311#else
2312 return SendMessageW(hwndCombo, CB_GETCOMBOBOXINFO, 0, (LPARAM)pcbi);
2313#endif
2314}
BOOL NTAPI NtUserGetComboBoxInfo(HWND hWnd, PCOMBOBOXINFO pcbi)
Definition: window.c:3468

◆ strdupA()

static char * strdupA ( LPCSTR  str)
static

Definition at line 1795 of file combo.c.

1796{
1797 char *ret;
1798 DWORD len;
1799
1800 if(!str) return NULL;
1801
1802 len = strlen(str);
1803 ret = HeapAlloc(GetProcessHeap(), 0, len + 1);
1804#ifdef __REACTOS__
1805 if (ret != NULL)
1806#endif
1807 memcpy(ret, str, len + 1);
1808 return ret;
1809}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const WCHAR * str

Referenced by ComboWndProc_common().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( combo  )

Variable Documentation

◆ CBitHeight

UINT CBitHeight
static

Definition at line 51 of file combo.c.

◆ CBitWidth

UINT CBitWidth
static

Definition at line 51 of file combo.c.

◆ COMBO_builtin_class

const struct builtin_class_descr COMBO_builtin_class
Initial value:
=
{
WINPROC_COMBO,
sizeof(HEADCOMBO *),
0
}
static const WCHAR comboboxW[]
Definition: combo.c:66
#define CS_VREDRAW
Definition: winuser.h:658
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
#define CS_PARENTDC
Definition: winuser.h:656

Definition at line 67 of file combo.c.

◆ comboboxW

const WCHAR comboboxW[] = {'C','o','m','b','o','B','o','x',0}
static

Definition at line 66 of file combo.c.

◆ hComboBmp

HBITMAP hComboBmp = 0
static

Definition at line 50 of file combo.c.