Added stubs for several MRU list functions and documented some others.
[wine.git] / controls / combo.c
blob5961b8a226d3fa5acea43cc42929b6076779ab00
1 /*
2 * Combo controls
3 *
4 * Copyright 1997 Alex Korobka
5 *
6 * FIXME: roll up in Netscape 3.01.
7 */
9 #include <string.h>
11 #include "winbase.h"
12 #include "winuser.h"
13 #include "wingdi.h"
14 #include "wine/winuser16.h"
15 #include "win.h"
16 #include "spy.h"
17 #include "user.h"
18 #include "heap.h"
19 #include "combo.h"
20 #include "drive.h"
21 #include "debugtools.h"
22 #include "tweak.h"
24 DEFAULT_DEBUG_CHANNEL(combo)
26 /* bits in the dwKeyData */
27 #define KEYDATA_ALT 0x2000
28 #define KEYDATA_PREVSTATE 0x4000
31 * Additional combo box definitions
34 #define CB_GETPTR( wnd ) (*(LPHEADCOMBO*)((wnd)->wExtra))
35 #define CB_NOTIFY( lphc, code ) \
36 (SendMessageA( (lphc)->owner, WM_COMMAND, \
37 MAKEWPARAM((lphc)->self->wIDmenu, (code)), (lphc)->self->hwndSelf))
38 #define CB_GETEDITTEXTLENGTH( lphc ) \
39 (SendMessageA( (lphc)->hWndEdit, WM_GETTEXTLENGTH, 0, 0 ))
41 #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03)
44 * Drawing globals
46 static HBITMAP hComboBmp = 0;
47 static UINT CBitHeight, CBitWidth;
50 * Look and feel dependant "constants"
53 #define COMBO_YBORDERGAP 5
54 #define COMBO_XBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 )
55 #define COMBO_YBORDERSIZE() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 2 )
56 #define COMBO_EDITBUTTONSPACE() ( (TWEAK_WineLook == WIN31_LOOK) ? 8 : 0 )
57 #define EDIT_CONTROL_PADDING() ( (TWEAK_WineLook == WIN31_LOOK) ? 0 : 1 )
59 /***********************************************************************
60 * COMBO_Init
62 * Load combo button bitmap.
64 static BOOL COMBO_Init()
66 HDC hDC;
68 if( hComboBmp ) return TRUE;
69 if( (hDC = CreateCompatibleDC(0)) )
71 BOOL bRet = FALSE;
72 if( (hComboBmp = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_COMBO))) )
74 BITMAP bm;
75 HBITMAP hPrevB;
76 RECT r;
78 GetObjectA( hComboBmp, sizeof(bm), &bm );
79 CBitHeight = bm.bmHeight;
80 CBitWidth = bm.bmWidth;
82 TRACE("combo bitmap [%i,%i]\n", CBitWidth, CBitHeight );
84 hPrevB = SelectObject16( hDC, hComboBmp);
85 SetRect( &r, 0, 0, CBitWidth, CBitHeight );
86 InvertRect( hDC, &r );
87 SelectObject( hDC, hPrevB );
88 bRet = TRUE;
90 DeleteDC( hDC );
91 return bRet;
93 return FALSE;
96 /***********************************************************************
97 * COMBO_NCCreate
99 static LRESULT COMBO_NCCreate(WND* wnd, LPARAM lParam)
101 LPHEADCOMBO lphc;
103 if ( wnd && COMBO_Init() &&
104 (lphc = HeapAlloc(GetProcessHeap(), 0, sizeof(HEADCOMBO))) )
106 LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam;
108 memset( lphc, 0, sizeof(HEADCOMBO) );
109 *(LPHEADCOMBO*)wnd->wExtra = lphc;
111 /* some braindead apps do try to use scrollbar/border flags */
113 lphc->dwStyle = (lpcs->style & ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL));
114 wnd->dwStyle &= ~(WS_BORDER | WS_HSCROLL | WS_VSCROLL);
117 * We also have to remove the client edge style to make sure
118 * we don't end-up with a non client area.
120 wnd->dwExStyle &= ~(WS_EX_CLIENTEDGE);
122 if( !(lpcs->style & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)) )
123 lphc->dwStyle |= CBS_HASSTRINGS;
124 if( !(wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) )
125 lphc->wState |= CBF_NOTIFY;
127 TRACE("[0x%08x], style = %08x\n",
128 (UINT)lphc, lphc->dwStyle );
130 return (LRESULT)(UINT)wnd->hwndSelf;
132 return (LRESULT)FALSE;
135 /***********************************************************************
136 * COMBO_NCDestroy
138 static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc )
141 if( lphc )
143 WND* wnd = lphc->self;
145 TRACE("[%04x]: freeing storage\n", CB_HWND(lphc));
147 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) && lphc->hWndLBox )
148 DestroyWindow( lphc->hWndLBox );
150 HeapFree( GetProcessHeap(), 0, lphc );
151 wnd->wExtra[0] = 0;
153 return 0;
156 /***********************************************************************
157 * CBGetTextAreaHeight
159 * This method will calculate the height of the text area of the
160 * combobox.
161 * The height of the text area is set in two ways.
162 * It can be set explicitely through a combobox message of through a
163 * WM_MEASUREITEM callback.
164 * If this is not the case, the height is set to 13 dialog units.
165 * This height was determined through experimentation.
167 static INT CBGetTextAreaHeight(
168 HWND hwnd,
169 LPHEADCOMBO lphc)
171 INT iTextItemHeight;
173 if( lphc->editHeight ) /* explicitly set height */
175 iTextItemHeight = lphc->editHeight;
177 else
179 TEXTMETRICA tm;
180 HDC hDC = GetDC(hwnd);
181 HFONT hPrevFont = 0;
182 INT baseUnitY;
184 if (lphc->hFont)
185 hPrevFont = SelectObject( hDC, lphc->hFont );
187 GetTextMetricsA(hDC, &tm);
189 baseUnitY = tm.tmHeight;
191 if( hPrevFont )
192 SelectObject( hDC, hPrevFont );
194 ReleaseDC(hwnd, hDC);
196 iTextItemHeight = ((13 * baseUnitY) / 8);
199 * This "formula" calculates the height of the complete control.
200 * To calculate the height of the text area, we have to remove the
201 * borders.
203 iTextItemHeight -= 2*COMBO_YBORDERSIZE();
207 * Check the ownerdraw case if we haven't asked the parent the size
208 * of the item yet.
210 if ( CB_OWNERDRAWN(lphc) &&
211 (lphc->wState & CBF_MEASUREITEM) )
213 MEASUREITEMSTRUCT measureItem;
214 RECT clientRect;
215 INT originalItemHeight = iTextItemHeight;
218 * We use the client rect for the width of the item.
220 GetClientRect(hwnd, &clientRect);
222 lphc->wState &= ~CBF_MEASUREITEM;
225 * Send a first one to measure the size of the text area
227 measureItem.CtlType = ODT_COMBOBOX;
228 measureItem.CtlID = lphc->self->wIDmenu;
229 measureItem.itemID = -1;
230 measureItem.itemWidth = clientRect.right;
231 measureItem.itemHeight = iTextItemHeight - 6; /* ownerdrawn cb is taller */
232 measureItem.itemData = 0;
233 SendMessageA(lphc->owner, WM_MEASUREITEM,
234 (WPARAM)measureItem.CtlID, (LPARAM)&measureItem);
235 iTextItemHeight = 6 + measureItem.itemHeight;
238 * Send a second one in the case of a fixed ownerdraw list to calculate the
239 * size of the list items. (we basically do this on behalf of the listbox)
241 if (lphc->dwStyle & CBS_OWNERDRAWFIXED)
243 measureItem.CtlType = ODT_COMBOBOX;
244 measureItem.CtlID = lphc->self->wIDmenu;
245 measureItem.itemID = 0;
246 measureItem.itemWidth = clientRect.right;
247 measureItem.itemHeight = originalItemHeight;
248 measureItem.itemData = 0;
249 SendMessageA(lphc->owner, WM_MEASUREITEM,
250 (WPARAM)measureItem.CtlID, (LPARAM)&measureItem);
251 lphc->fixedOwnerDrawHeight = measureItem.itemHeight;
255 * Keep the size for the next time
257 lphc->editHeight = iTextItemHeight;
260 return iTextItemHeight;
263 /***********************************************************************
264 * CBForceDummyResize
266 * The dummy resize is used for listboxes that have a popup to trigger
267 * a re-arranging of the contents of the combobox and the recalculation
268 * of the size of the "real" control window.
270 static void CBForceDummyResize(
271 LPHEADCOMBO lphc)
273 RECT windowRect;
274 int newComboHeight;
276 newComboHeight = CBGetTextAreaHeight(CB_HWND(lphc),lphc) + 2*COMBO_YBORDERSIZE();
278 GetWindowRect(CB_HWND(lphc), &windowRect);
281 * We have to be careful, resizing a combobox also has the meaning that the
282 * dropped rect will be resized. In this case, we want to trigger a resize
283 * to recalculate layout but we don't want to change the dropped rectangle
284 * So, we pass the height of text area of control as the height.
285 * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
286 * message.
288 SetWindowPos( CB_HWND(lphc),
289 (HWND)NULL,
290 0, 0,
291 windowRect.right - windowRect.left,
292 newComboHeight,
293 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
296 /***********************************************************************
297 * CBCalcPlacement
299 * Set up component coordinates given valid lphc->RectCombo.
301 static void CBCalcPlacement(
302 HWND hwnd,
303 LPHEADCOMBO lphc,
304 LPRECT lprEdit,
305 LPRECT lprButton,
306 LPRECT lprLB)
309 * Again, start with the client rectangle.
311 GetClientRect(hwnd, lprEdit);
314 * Remove the borders
316 InflateRect(lprEdit, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
319 * Chop off the bottom part to fit with the height of the text area.
321 lprEdit->bottom = lprEdit->top + CBGetTextAreaHeight(hwnd, lphc);
324 * The button starts the same vertical position as the text area.
326 CopyRect(lprButton, lprEdit);
329 * If the combobox is "simple" there is no button.
331 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
332 lprButton->left = lprButton->right = lprButton->bottom = 0;
333 else
336 * Let's assume the combobox button is the same width as the
337 * scrollbar button.
338 * size the button horizontally and cut-off the text area.
340 lprButton->left = lprButton->right - GetSystemMetrics(SM_CXVSCROLL);
341 lprEdit->right = lprButton->left;
345 * In the case of a dropdown, there is an additional spacing between the
346 * text area and the button.
348 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
350 lprEdit->right -= COMBO_EDITBUTTONSPACE();
354 * If we have an edit control, we space it away from the borders slightly.
356 if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST)
358 InflateRect(lprEdit, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING());
362 * Adjust the size of the listbox popup.
364 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
367 * Use the client rectangle to initialize the listbox rectangle
369 GetClientRect(hwnd, lprLB);
372 * Then, chop-off the top part.
374 lprLB->top = lprEdit->bottom + COMBO_YBORDERSIZE();
376 else
379 * Make sure the dropped width is as large as the combobox itself.
381 if (lphc->droppedWidth < (lprButton->right + COMBO_XBORDERSIZE()))
383 lprLB->right = lprLB->left + (lprButton->right + COMBO_XBORDERSIZE());
386 * In the case of a dropdown, the popup listbox is offset to the right.
387 * so, we want to make sure it's flush with the right side of the
388 * combobox
390 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
391 lprLB->right -= COMBO_EDITBUTTONSPACE();
393 else
394 lprLB->right = lprLB->left + lphc->droppedWidth;
397 TRACE("\ttext\t= (%i,%i-%i,%i)\n",
398 lprEdit->left, lprEdit->top, lprEdit->right, lprEdit->bottom);
400 TRACE("\tbutton\t= (%i,%i-%i,%i)\n",
401 lprButton->left, lprButton->top, lprButton->right, lprButton->bottom);
403 TRACE("\tlbox\t= (%i,%i-%i,%i)\n",
404 lprLB->left, lprLB->top, lprLB->right, lprLB->bottom );
407 /***********************************************************************
408 * CBGetDroppedControlRect
410 static void CBGetDroppedControlRect( LPHEADCOMBO lphc, LPRECT lpRect)
412 /* In windows, CB_GETDROPPEDCONTROLRECT returns the upper left corner
413 of the combo box and the lower right corner of the listbox */
415 GetWindowRect(lphc->self->hwndSelf, lpRect);
417 lpRect->right = lpRect->left + lphc->droppedRect.right - lphc->droppedRect.left;
418 lpRect->bottom = lpRect->top + lphc->droppedRect.bottom - lphc->droppedRect.top;
422 /***********************************************************************
423 * COMBO_WindowPosChanging
425 static LRESULT COMBO_WindowPosChanging(
426 HWND hwnd,
427 LPHEADCOMBO lphc,
428 WINDOWPOS* posChanging)
431 * We need to override the WM_WINDOWPOSCHANGING method to handle all
432 * the non-simple comboboxes. The problem is that those controls are
433 * always the same height. We have to make sure they are not resized
434 * to another value.
436 if ( ( CB_GETTYPE(lphc) != CBS_SIMPLE ) &&
437 ((posChanging->flags & SWP_NOSIZE) == 0) )
439 int newComboHeight;
441 newComboHeight = CBGetTextAreaHeight(hwnd,lphc) +
442 2*COMBO_YBORDERSIZE();
445 * Resizing a combobox has another side effect, it resizes the dropped
446 * rectangle as well. However, it does it only if the new height for the
447 * combobox is different than the height it should have. In other words,
448 * if the application resizing the combobox only had the intention to resize
449 * the actual control, for example, to do the layout of a dialog that is
450 * resized, the height of the dropdown is not changed.
452 if (posChanging->cy != newComboHeight)
454 lphc->droppedRect.bottom = lphc->droppedRect.top + posChanging->cy - newComboHeight;
456 posChanging->cy = newComboHeight;
460 return 0;
463 /***********************************************************************
464 * COMBO_Create
466 static LRESULT COMBO_Create( LPHEADCOMBO lphc, WND* wnd, LPARAM lParam)
468 static char clbName[] = "ComboLBox";
469 static char editName[] = "Edit";
471 LPCREATESTRUCTA lpcs = (CREATESTRUCTA*)lParam;
473 if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE;
474 else if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
476 lphc->self = wnd;
477 lphc->owner = lpcs->hwndParent;
480 * The item height and dropped width are not set when the control
481 * is created.
483 lphc->droppedWidth = lphc->editHeight = 0;
486 * The first time we go through, we want to measure the ownerdraw item
488 lphc->wState |= CBF_MEASUREITEM;
490 /* M$ IE 3.01 actually creates (and rapidly destroys) an ownerless combobox */
492 if( lphc->owner || !(lpcs->style & WS_VISIBLE) )
494 UINT lbeStyle = 0;
495 UINT lbeExStyle = 0;
498 * Initialize the dropped rect to the size of the client area of the
499 * control and then, force all the areas of the combobox to be
500 * recalculated.
502 GetClientRect( wnd->hwndSelf, &lphc->droppedRect );
504 CBCalcPlacement(wnd->hwndSelf,
505 lphc,
506 &lphc->textRect,
507 &lphc->buttonRect,
508 &lphc->droppedRect );
511 * Adjust the position of the popup listbox if it's necessary
513 if ( CB_GETTYPE(lphc) != CBS_SIMPLE )
515 lphc->droppedRect.top = lphc->textRect.bottom + COMBO_YBORDERSIZE();
518 * If it's a dropdown, the listbox is offset
520 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
521 lphc->droppedRect.left += COMBO_EDITBUTTONSPACE();
523 ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect);
524 ClientToScreen(wnd->hwndSelf, (LPPOINT)&lphc->droppedRect.right);
527 /* create listbox popup */
529 lbeStyle = (LBS_NOTIFY | WS_BORDER | WS_CLIPSIBLINGS) |
530 (lpcs->style & (WS_VSCROLL | CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE));
532 if( lphc->dwStyle & CBS_SORT )
533 lbeStyle |= LBS_SORT;
534 if( lphc->dwStyle & CBS_HASSTRINGS )
535 lbeStyle |= LBS_HASSTRINGS;
536 if( lphc->dwStyle & CBS_NOINTEGRALHEIGHT )
537 lbeStyle |= LBS_NOINTEGRALHEIGHT;
538 if( lphc->dwStyle & CBS_DISABLENOSCROLL )
539 lbeStyle |= LBS_DISABLENOSCROLL;
541 if( CB_GETTYPE(lphc) == CBS_SIMPLE ) /* child listbox */
543 lbeStyle |= WS_CHILD | WS_VISIBLE;
546 * In win 95 look n feel, the listbox in the simple combobox has
547 * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
549 if (TWEAK_WineLook > WIN31_LOOK)
551 lbeStyle &= ~WS_BORDER;
552 lbeExStyle |= WS_EX_CLIENTEDGE;
555 else /* popup listbox */
556 lbeStyle |= WS_POPUP;
558 /* Dropdown ComboLBox is not a child window and we cannot pass
559 * ID_CB_LISTBOX directly because it will be treated as a menu handle.
561 lphc->hWndLBox = CreateWindowExA(lbeExStyle,
562 clbName,
563 NULL,
564 lbeStyle,
565 lphc->droppedRect.left,
566 lphc->droppedRect.top,
567 lphc->droppedRect.right - lphc->droppedRect.left,
568 lphc->droppedRect.bottom - lphc->droppedRect.top,
569 lphc->self->hwndSelf,
570 (lphc->dwStyle & CBS_DROPDOWN)? (HMENU)0 : (HMENU)ID_CB_LISTBOX,
571 lphc->self->hInstance,
572 (LPVOID)lphc );
575 * The ComboLBox is a strange little beast (when it's not a CBS_SIMPLE)...
576 * It's a popup window but, when you get the window style, you get WS_CHILD.
577 * When created, it's parent is the combobox but, when you ask for it's parent
578 * after that, you're supposed to get the desktop. (see MFC code function
579 * AfxCancelModes)
580 * To achieve this in Wine, we have to create it as a popup and change
581 * it's style to child after the creation.
583 if ( (lphc->hWndLBox!= 0) &&
584 (CB_GETTYPE(lphc) != CBS_SIMPLE) )
586 SetWindowLongA(lphc->hWndLBox,
587 GWL_STYLE,
588 (GetWindowLongA(lphc->hWndLBox, GWL_STYLE) | WS_CHILD) & ~WS_POPUP);
591 if( lphc->hWndLBox )
593 BOOL bEdit = TRUE;
594 lbeStyle = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL | ES_LEFT;
597 * In Win95 look, the border fo the edit control is
598 * provided by the combobox
600 if (TWEAK_WineLook == WIN31_LOOK)
601 lbeStyle |= WS_BORDER;
603 if( lphc->wState & CBF_EDIT )
605 if( lphc->dwStyle & CBS_OEMCONVERT )
606 lbeStyle |= ES_OEMCONVERT;
607 if( lphc->dwStyle & CBS_AUTOHSCROLL )
608 lbeStyle |= ES_AUTOHSCROLL;
609 if( lphc->dwStyle & CBS_LOWERCASE )
610 lbeStyle |= ES_LOWERCASE;
611 else if( lphc->dwStyle & CBS_UPPERCASE )
612 lbeStyle |= ES_UPPERCASE;
614 lphc->hWndEdit = CreateWindowExA(0,
615 editName,
616 NULL,
617 lbeStyle,
618 lphc->textRect.left, lphc->textRect.top,
619 lphc->textRect.right - lphc->textRect.left,
620 lphc->textRect.bottom - lphc->textRect.top,
621 lphc->self->hwndSelf,
622 (HMENU)ID_CB_EDIT,
623 lphc->self->hInstance,
624 NULL );
626 if( !lphc->hWndEdit )
627 bEdit = FALSE;
630 if( bEdit )
633 * If the combo is a dropdown, we must resize the control to fit only
634 * the text area and button. To do this, we send a dummy resize and the
635 * WM_WINDOWPOSCHANGING message will take care of setting the height for
636 * us.
638 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
640 CBForceDummyResize(lphc);
643 TRACE("init done\n");
644 return wnd->hwndSelf;
646 ERR("edit control failure.\n");
647 } else ERR("listbox failure.\n");
648 } else ERR("no owner for visible combo.\n");
650 /* CreateWindow() will send WM_NCDESTROY to cleanup */
652 return -1;
655 /***********************************************************************
656 * CBPaintButton
658 * Paint combo button (normal, pressed, and disabled states).
660 static void CBPaintButton(
661 LPHEADCOMBO lphc,
662 HDC hdc,
663 RECT rectButton)
665 if( lphc->wState & CBF_NOREDRAW )
666 return;
668 if (TWEAK_WineLook == WIN31_LOOK)
670 UINT x, y;
671 BOOL bBool;
672 HDC hMemDC;
673 HBRUSH hPrevBrush;
674 COLORREF oldTextColor, oldBkColor;
677 hPrevBrush = SelectObject(hdc, GetSysColorBrush(COLOR_BTNFACE));
680 * Draw the button background
682 PatBlt( hdc,
683 rectButton.left,
684 rectButton.top,
685 rectButton.right-rectButton.left,
686 rectButton.bottom-rectButton.top,
687 PATCOPY );
689 if( (bBool = lphc->wState & CBF_BUTTONDOWN) )
691 DrawEdge( hdc, &rectButton, EDGE_SUNKEN, BF_RECT );
693 else
695 DrawEdge( hdc, &rectButton, EDGE_RAISED, BF_RECT );
699 * Remove the edge of the button from the rectangle
700 * and calculate the position of the bitmap.
702 InflateRect( &rectButton, -2, -2);
704 x = (rectButton.left + rectButton.right - CBitWidth) >> 1;
705 y = (rectButton.top + rectButton.bottom - CBitHeight) >> 1;
708 hMemDC = CreateCompatibleDC( hdc );
709 SelectObject( hMemDC, hComboBmp );
710 oldTextColor = SetTextColor( hdc, GetSysColor(COLOR_BTNFACE) );
711 oldBkColor = SetBkColor( hdc, CB_DISABLED(lphc) ? RGB(128,128,128) :
712 RGB(0,0,0) );
713 BitBlt( hdc, x, y, CBitWidth, CBitHeight, hMemDC, 0, 0, SRCCOPY );
714 SetBkColor( hdc, oldBkColor );
715 SetTextColor( hdc, oldTextColor );
716 DeleteDC( hMemDC );
717 SelectObject( hdc, hPrevBrush );
719 else
721 UINT buttonState = DFCS_SCROLLCOMBOBOX;
723 if (lphc->wState & CBF_BUTTONDOWN)
725 buttonState |= DFCS_PUSHED;
728 if (CB_DISABLED(lphc))
730 buttonState |= DFCS_INACTIVE;
733 DrawFrameControl(hdc,
734 &rectButton,
735 DFC_SCROLL,
736 buttonState);
740 /***********************************************************************
741 * CBPaintText
743 * Paint CBS_DROPDOWNLIST text field / update edit control contents.
745 static void CBPaintText(
746 LPHEADCOMBO lphc,
747 HDC hdc,
748 RECT rectEdit)
750 INT id, size = 0;
751 LPSTR pText = NULL;
753 if( lphc->wState & CBF_NOREDRAW ) return;
755 /* follow Windows combobox that sends a bunch of text
756 * inquiries to its listbox while processing WM_PAINT. */
758 if( (id = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0) ) != LB_ERR )
760 size = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, id, 0);
761 if( (pText = HeapAlloc( GetProcessHeap(), 0, size + 1)) )
763 SendMessageA( lphc->hWndLBox, LB_GETTEXT, (WPARAM)id, (LPARAM)pText );
764 pText[size] = '\0'; /* just in case */
765 } else return;
768 if( lphc->wState & CBF_EDIT )
770 if( CB_HASSTRINGS(lphc) ) SetWindowTextA( lphc->hWndEdit, pText ? pText : "" );
771 if( lphc->wState & CBF_FOCUSED )
772 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1));
774 else /* paint text field ourselves */
776 UINT itemState;
777 HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0;
780 * Give ourselves some space.
782 InflateRect( &rectEdit, -1, -1 );
784 if ( (lphc->wState & CBF_FOCUSED) &&
785 !(lphc->wState & CBF_DROPPED) )
787 /* highlight */
789 FillRect( hdc, &rectEdit, GetSysColorBrush(COLOR_HIGHLIGHT) );
790 SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
791 SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
792 itemState = ODS_SELECTED | ODS_FOCUS;
794 else
795 itemState = 0;
797 if( CB_OWNERDRAWN(lphc) )
799 DRAWITEMSTRUCT dis;
800 HRGN clipRegion;
803 * Save the current clip region.
804 * To retrieve the clip region, we need to create one "dummy"
805 * clip region.
807 clipRegion = CreateRectRgnIndirect(&rectEdit);
809 if (GetClipRgn(hdc, clipRegion)!=1)
811 DeleteObject(clipRegion);
812 clipRegion=(HRGN)NULL;
815 if ( lphc->self->dwStyle & WS_DISABLED )
816 itemState |= ODS_DISABLED;
818 dis.CtlType = ODT_COMBOBOX;
819 dis.CtlID = lphc->self->wIDmenu;
820 dis.hwndItem = lphc->self->hwndSelf;
821 dis.itemAction = ODA_DRAWENTIRE;
822 dis.itemID = id;
823 dis.itemState = itemState;
824 dis.hDC = hdc;
825 dis.rcItem = rectEdit;
826 dis.itemData = SendMessageA( lphc->hWndLBox, LB_GETITEMDATA,
827 (WPARAM)id, 0 );
830 * Clip the DC and have the parent draw the item.
832 IntersectClipRect(hdc,
833 rectEdit.left, rectEdit.top,
834 rectEdit.right, rectEdit.bottom);
836 SendMessageA(lphc->owner, WM_DRAWITEM,
837 lphc->self->wIDmenu, (LPARAM)&dis );
840 * Reset the clipping region.
842 SelectClipRgn(hdc, clipRegion);
844 else
846 ExtTextOutA( hdc,
847 rectEdit.left + 1,
848 rectEdit.top + 1,
849 ETO_OPAQUE | ETO_CLIPPED,
850 &rectEdit,
851 pText ? pText : "" , size, NULL );
853 if(lphc->wState & CBF_FOCUSED && !(lphc->wState & CBF_DROPPED))
854 DrawFocusRect( hdc, &rectEdit );
857 if( hPrevFont )
858 SelectObject(hdc, hPrevFont );
860 if (pText)
861 HeapFree( GetProcessHeap(), 0, pText );
864 /***********************************************************************
865 * CBPaintBorder
867 static void CBPaintBorder(
868 HWND hwnd,
869 LPHEADCOMBO lphc,
870 HDC hdc)
872 RECT clientRect;
874 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
876 GetClientRect(hwnd, &clientRect);
878 else
880 CopyRect(&clientRect, &lphc->textRect);
882 InflateRect(&clientRect, EDIT_CONTROL_PADDING(), EDIT_CONTROL_PADDING());
883 InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
886 DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_RECT);
889 /***********************************************************************
890 * COMBO_PrepareColors
892 * This method will sent the appropriate WM_CTLCOLOR message to
893 * prepare and setup the colors for the combo's DC.
895 * It also returns the brush to use for the background.
897 static HBRUSH COMBO_PrepareColors(
898 HWND hwnd,
899 LPHEADCOMBO lphc,
900 HDC hDC)
902 HBRUSH hBkgBrush;
905 * Get the background brush for this control.
907 if (CB_DISABLED(lphc))
909 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORSTATIC,
910 hDC, lphc->self->hwndSelf );
913 * We have to change the text color since WM_CTLCOLORSTATIC will
914 * set it to the "enabled" color. This is the same behavior as the
915 * edit control
917 SetTextColor(hDC, GetSysColor(COLOR_GRAYTEXT));
919 else
921 if (lphc->wState & CBF_EDIT)
923 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLOREDIT,
924 hDC, lphc->self->hwndSelf );
926 else
928 hBkgBrush = SendMessageA( lphc->owner, WM_CTLCOLORLISTBOX,
929 hDC, lphc->self->hwndSelf );
934 * Catch errors.
936 if( !hBkgBrush )
937 hBkgBrush = GetSysColorBrush(COLOR_WINDOW);
939 return hBkgBrush;
942 /***********************************************************************
943 * COMBO_EraseBackground
945 static LRESULT COMBO_EraseBackground(
946 HWND hwnd,
947 LPHEADCOMBO lphc,
948 HDC hParamDC)
950 HBRUSH hBkgBrush;
951 RECT clientRect;
952 HDC hDC;
954 hDC = (hParamDC) ? hParamDC
955 : GetDC(hwnd);
958 * Calculate the area that we want to erase.
960 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
962 GetClientRect(hwnd, &clientRect);
964 else
966 CopyRect(&clientRect, &lphc->textRect);
968 InflateRect(&clientRect, COMBO_XBORDERSIZE(), COMBO_YBORDERSIZE());
972 * Retrieve the background brush
974 hBkgBrush = COMBO_PrepareColors(hwnd, lphc, hDC);
976 FillRect(hDC, &clientRect, hBkgBrush);
978 if (!hParamDC)
979 ReleaseDC(hwnd, hDC);
981 return TRUE;
984 /***********************************************************************
985 * COMBO_Paint
987 static LRESULT COMBO_Paint(LPHEADCOMBO lphc, HDC hParamDC)
989 PAINTSTRUCT ps;
990 HDC hDC;
992 hDC = (hParamDC) ? hParamDC
993 : BeginPaint( lphc->self->hwndSelf, &ps);
996 if( hDC && !(lphc->wState & CBF_NOREDRAW) )
998 HBRUSH hPrevBrush, hBkgBrush;
1001 * Retrieve the background brush and select it in the
1002 * DC.
1004 hBkgBrush = COMBO_PrepareColors(lphc->self->hwndSelf, lphc, hDC);
1006 hPrevBrush = SelectObject( hDC, hBkgBrush );
1009 * In non 3.1 look, there is a sunken border on the combobox
1011 if (TWEAK_WineLook != WIN31_LOOK)
1013 CBPaintBorder(CB_HWND(lphc), lphc, hDC);
1016 if( !IsRectEmpty(&lphc->buttonRect) )
1018 CBPaintButton(lphc, hDC, lphc->buttonRect);
1021 if( !(lphc->wState & CBF_EDIT) )
1024 * The text area has a border only in Win 3.1 look.
1026 if (TWEAK_WineLook == WIN31_LOOK)
1028 HPEN hPrevPen = SelectObject( hDC, GetSysColorPen(COLOR_WINDOWFRAME) );
1030 Rectangle( hDC,
1031 lphc->textRect.left, lphc->textRect.top,
1032 lphc->textRect.right - 1, lphc->textRect.bottom - 1);
1034 SelectObject( hDC, hPrevPen );
1037 CBPaintText( lphc, hDC, lphc->textRect);
1040 if( hPrevBrush )
1041 SelectObject( hDC, hPrevBrush );
1044 if( !hParamDC )
1045 EndPaint(lphc->self->hwndSelf, &ps);
1047 return 0;
1050 /***********************************************************************
1051 * CBUpdateLBox
1053 * Select listbox entry according to the contents of the edit control.
1055 static INT CBUpdateLBox( LPHEADCOMBO lphc )
1057 INT length, idx, ret;
1058 LPSTR pText = NULL;
1060 idx = ret = LB_ERR;
1061 length = CB_GETEDITTEXTLENGTH( lphc );
1063 if( length > 0 )
1064 pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1);
1066 TRACE("\t edit text length %i\n", length );
1068 if( pText )
1070 if( length ) GetWindowTextA( lphc->hWndEdit, pText, length + 1);
1071 else pText[0] = '\0';
1072 idx = SendMessageA( lphc->hWndLBox, LB_FINDSTRING,
1073 (WPARAM)(-1), (LPARAM)pText );
1074 if( idx == LB_ERR ) idx = 0; /* select first item */
1075 else ret = idx;
1076 HeapFree( GetProcessHeap(), 0, pText );
1079 /* select entry */
1081 SendMessageA( lphc->hWndLBox, LB_SETCURSEL, (WPARAM)idx, 0 );
1083 if( idx >= 0 )
1085 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)idx, 0 );
1086 /* probably superfluous but Windows sends this too */
1087 SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)idx, 0 );
1089 return ret;
1092 /***********************************************************************
1093 * CBUpdateEdit
1095 * Copy a listbox entry to the edit control.
1097 static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
1099 INT length;
1100 LPSTR pText = NULL;
1102 TRACE("\t %i\n", index );
1104 if( index == -1 )
1106 length = CB_GETEDITTEXTLENGTH( lphc );
1107 if( length )
1109 if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) )
1111 GetWindowTextA( lphc->hWndEdit, pText, length + 1 );
1112 index = SendMessageA( lphc->hWndLBox, LB_FINDSTRING,
1113 (WPARAM)(-1), (LPARAM)pText );
1114 HeapFree( GetProcessHeap(), 0, pText );
1119 if( index >= 0 ) /* got an entry */
1121 length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, (WPARAM)index, 0);
1122 if( length )
1124 if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) )
1126 SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1127 (WPARAM)index, (LPARAM)pText );
1129 lphc->wState |= CBF_NOEDITNOTIFY;
1131 SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, (LPARAM)pText );
1132 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
1133 HeapFree( GetProcessHeap(), 0, pText );
1139 /***********************************************************************
1140 * CBDropDown
1142 * Show listbox popup.
1144 static void CBDropDown( LPHEADCOMBO lphc )
1146 RECT rect;
1147 int nItems = 0;
1148 int i;
1149 int nHeight;
1150 int nDroppedHeight, nTempDroppedHeight;
1152 TRACE("[%04x]: drop down\n", CB_HWND(lphc));
1154 CB_NOTIFY( lphc, CBN_DROPDOWN );
1156 /* set selection */
1158 lphc->wState |= CBF_DROPPED;
1159 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1161 lphc->droppedIndex = CBUpdateLBox( lphc );
1163 if( !(lphc->wState & CBF_CAPTURE) )
1164 CBUpdateEdit( lphc, lphc->droppedIndex );
1166 else
1168 lphc->droppedIndex = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1170 if( lphc->droppedIndex == LB_ERR )
1171 lphc->droppedIndex = 0;
1173 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)lphc->droppedIndex, 0 );
1174 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
1177 /* now set popup position */
1178 GetWindowRect( lphc->self->hwndSelf, &rect );
1181 * If it's a dropdown, the listbox is offset
1183 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1184 rect.left += COMBO_EDITBUTTONSPACE();
1186 /* if the dropped height is greater than the total height of the dropped
1187 items list, then force the drop down list height to be the total height
1188 of the items in the dropped list */
1190 /* And Remove any extra space (Best Fit) */
1191 nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
1192 nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0);
1193 nHeight = COMBO_YBORDERSIZE();
1194 nTempDroppedHeight = 0;
1195 for (i = 0; i < nItems; i++)
1197 nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0);
1199 /* Did we pass the limit of what can be displayed */
1200 if (nHeight > nDroppedHeight)
1202 break;
1204 nTempDroppedHeight = nHeight;
1207 nDroppedHeight = nTempDroppedHeight;
1209 SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
1210 lphc->droppedRect.right - lphc->droppedRect.left,
1211 nDroppedHeight,
1212 SWP_NOACTIVATE | SWP_NOREDRAW);
1214 if( !(lphc->wState & CBF_NOREDRAW) )
1215 RedrawWindow( lphc->self->hwndSelf, NULL, 0, RDW_INVALIDATE |
1216 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
1218 ShowWindow( lphc->hWndLBox, SW_SHOWNA );
1221 /***********************************************************************
1222 * CBRollUp
1224 * Hide listbox popup.
1226 static void CBRollUp( LPHEADCOMBO lphc, BOOL ok, BOOL bButton )
1228 HWND hWnd = lphc->self->hwndSelf;
1230 CB_NOTIFY( lphc, (ok) ? CBN_SELENDOK : CBN_SELENDCANCEL );
1232 if( IsWindow( hWnd ) && CB_GETTYPE(lphc) != CBS_SIMPLE )
1235 TRACE("[%04x]: roll up [%i]\n", CB_HWND(lphc), (INT)ok );
1237 if( lphc->wState & CBF_DROPPED )
1239 RECT rect;
1242 * It seems useful to send the WM_LBUTTONUP with (-1,-1) when cancelling
1243 * and with (0,0) (anywhere in the listbox) when Oking.
1245 SendMessageA( lphc->hWndLBox, WM_LBUTTONUP, 0, ok ? (LPARAM)0 : (LPARAM)(-1) );
1247 lphc->wState &= ~CBF_DROPPED;
1248 ShowWindow( lphc->hWndLBox, SW_HIDE );
1249 if(GetCapture() == lphc->hWndLBox)
1251 ReleaseCapture();
1255 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1257 INT index = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1258 CBUpdateEdit( lphc, index );
1259 rect = lphc->buttonRect;
1261 else
1263 if( bButton )
1265 UnionRect( &rect,
1266 &lphc->buttonRect,
1267 &lphc->textRect);
1269 else
1270 rect = lphc->textRect;
1272 bButton = TRUE;
1275 if( bButton && !(lphc->wState & CBF_NOREDRAW) )
1276 RedrawWindow( hWnd, &rect, 0, RDW_INVALIDATE |
1277 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
1278 CB_NOTIFY( lphc, CBN_CLOSEUP );
1283 /***********************************************************************
1284 * COMBO_FlipListbox
1286 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
1288 BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL bRedrawButton )
1290 if( lphc->wState & CBF_DROPPED )
1292 CBRollUp( lphc, TRUE, bRedrawButton );
1293 return FALSE;
1296 CBDropDown( lphc );
1297 return TRUE;
1300 /***********************************************************************
1301 * COMBO_GetLBWindow
1303 * Edit control helper.
1305 HWND COMBO_GetLBWindow( WND* pWnd )
1307 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1308 if( lphc ) return lphc->hWndLBox;
1309 return 0;
1313 /***********************************************************************
1314 * CBRepaintButton
1316 static void CBRepaintButton( LPHEADCOMBO lphc )
1318 InvalidateRect(CB_HWND(lphc), &lphc->buttonRect, TRUE);
1319 UpdateWindow(CB_HWND(lphc));
1322 /***********************************************************************
1323 * COMBO_SetFocus
1325 static void COMBO_SetFocus( LPHEADCOMBO lphc )
1327 if( !(lphc->wState & CBF_FOCUSED) )
1329 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1330 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
1332 if( lphc->wState & CBF_EDIT )
1333 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
1334 lphc->wState |= CBF_FOCUSED;
1335 if( !(lphc->wState & CBF_EDIT) )
1337 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1340 CB_NOTIFY( lphc, CBN_SETFOCUS );
1344 /***********************************************************************
1345 * COMBO_KillFocus
1347 static void COMBO_KillFocus( LPHEADCOMBO lphc )
1349 HWND hWnd = lphc->self->hwndSelf;
1351 if( lphc->wState & CBF_FOCUSED )
1353 SendMessageA( hWnd, WM_LBUTTONUP, 0, (LPARAM)(-1) );
1355 CBRollUp( lphc, FALSE, TRUE );
1356 if( IsWindow( hWnd ) )
1358 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1359 SendMessageA( lphc->hWndLBox, LB_CARETOFF, 0, 0 );
1361 lphc->wState &= ~CBF_FOCUSED;
1363 /* redraw text */
1364 if( lphc->wState & CBF_EDIT )
1365 SendMessageA( lphc->hWndEdit, EM_SETSEL, (WPARAM)(-1), 0 );
1366 else
1368 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1371 CB_NOTIFY( lphc, CBN_KILLFOCUS );
1376 /***********************************************************************
1377 * COMBO_Command
1379 static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd )
1381 if ( lphc->wState & CBF_EDIT && lphc->hWndEdit == hWnd )
1383 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1385 switch( HIWORD(wParam) >> 8 )
1387 case (EN_SETFOCUS >> 8):
1389 TRACE("[%04x]: edit [%04x] got focus\n",
1390 CB_HWND(lphc), lphc->hWndEdit );
1392 if( !(lphc->wState & CBF_FOCUSED) ) COMBO_SetFocus( lphc );
1393 break;
1395 case (EN_KILLFOCUS >> 8):
1397 TRACE("[%04x]: edit [%04x] lost focus\n",
1398 CB_HWND(lphc), lphc->hWndEdit );
1400 /* NOTE: it seems that Windows' edit control sends an
1401 * undocumented message WM_USER + 0x1B instead of this
1402 * notification (only when it happens to be a part of
1403 * the combo). ?? - AK.
1406 COMBO_KillFocus( lphc );
1407 break;
1410 case (EN_CHANGE >> 8):
1412 * In some circumstances (when the selection of the combobox
1413 * is changed for example) we don't wans the EN_CHANGE notification
1414 * to be forwarded to the parent of the combobox. This code
1415 * checks a flag that is set in these occasions and ignores the
1416 * notification.
1418 if (lphc->wState & CBF_NOEDITNOTIFY)
1420 lphc->wState &= ~CBF_NOEDITNOTIFY;
1422 else
1424 CB_NOTIFY( lphc, CBN_EDITCHANGE );
1427 CBUpdateLBox( lphc );
1428 break;
1430 case (EN_UPDATE >> 8):
1431 CB_NOTIFY( lphc, CBN_EDITUPDATE );
1432 break;
1434 case (EN_ERRSPACE >> 8):
1435 CB_NOTIFY( lphc, CBN_ERRSPACE );
1438 else if( lphc->hWndLBox == hWnd )
1440 switch( HIWORD(wParam) )
1442 case LBN_ERRSPACE:
1443 CB_NOTIFY( lphc, CBN_ERRSPACE );
1444 break;
1446 case LBN_DBLCLK:
1447 CB_NOTIFY( lphc, CBN_DBLCLK );
1448 break;
1450 case LBN_SELCHANGE:
1451 case LBN_SELCANCEL:
1453 TRACE("[%04x]: lbox selection change [%04x]\n",
1454 CB_HWND(lphc), lphc->wState );
1456 /* do not roll up if selection is being tracked
1457 * by arrowkeys in the dropdown listbox */
1459 if( (lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP) )
1460 CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
1461 else lphc->wState &= ~CBF_NOROLLUP;
1463 if( lphc->wState & CBF_EDIT )
1465 INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
1466 CBUpdateEdit( lphc, index );
1468 else
1469 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1471 CB_NOTIFY( lphc, CBN_SELCHANGE );
1472 /* fall through */
1474 case LBN_SETFOCUS:
1475 case LBN_KILLFOCUS:
1476 /* nothing to do here since ComboLBox always resets the focus to its
1477 * combo/edit counterpart */
1478 break;
1481 return 0;
1484 /***********************************************************************
1485 * COMBO_ItemOp
1487 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1489 static LRESULT COMBO_ItemOp( LPHEADCOMBO lphc, UINT msg,
1490 WPARAM wParam, LPARAM lParam )
1492 HWND hWnd = lphc->self->hwndSelf;
1494 TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg );
1496 #define lpIS ((LPDELETEITEMSTRUCT)lParam)
1498 /* two first items are the same in all 4 structs */
1499 lpIS->CtlType = ODT_COMBOBOX;
1500 lpIS->CtlID = lphc->self->wIDmenu;
1502 switch( msg ) /* patch window handle */
1504 case WM_DELETEITEM:
1505 lpIS->hwndItem = hWnd;
1506 #undef lpIS
1507 break;
1508 case WM_DRAWITEM:
1509 #define lpIS ((LPDRAWITEMSTRUCT)lParam)
1510 lpIS->hwndItem = hWnd;
1511 #undef lpIS
1512 break;
1513 case WM_COMPAREITEM:
1514 #define lpIS ((LPCOMPAREITEMSTRUCT)lParam)
1515 lpIS->hwndItem = hWnd;
1516 #undef lpIS
1517 break;
1520 return SendMessageA( lphc->owner, msg, lphc->self->wIDmenu, lParam );
1523 /***********************************************************************
1524 * COMBO_GetText
1526 static LRESULT COMBO_GetText( LPHEADCOMBO lphc, UINT N, LPSTR lpText)
1528 if( lphc->wState & CBF_EDIT )
1529 return SendMessageA( lphc->hWndEdit, WM_GETTEXT,
1530 (WPARAM)N, (LPARAM)lpText );
1532 /* get it from the listbox */
1534 if( lphc->hWndLBox )
1536 INT idx = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1537 if( idx != LB_ERR )
1539 LPSTR lpBuffer;
1540 INT length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN,
1541 (WPARAM)idx, 0 );
1543 /* 'length' is without the terminating character */
1544 if( length >= N )
1545 lpBuffer = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1 );
1546 else
1547 lpBuffer = lpText;
1549 if( lpBuffer )
1551 INT n = SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1552 (WPARAM)idx, (LPARAM)lpBuffer );
1554 /* truncate if buffer is too short */
1556 if( length >= N )
1558 if (N && lpText) {
1559 if( n != LB_ERR ) memcpy( lpText, lpBuffer, (N>n) ? n+1 : N-1 );
1560 lpText[N - 1] = '\0';
1562 HeapFree( GetProcessHeap(), 0, lpBuffer );
1564 return (LRESULT)n;
1568 return 0;
1572 /***********************************************************************
1573 * CBResetPos
1575 * This function sets window positions according to the updated
1576 * component placement struct.
1578 static void CBResetPos(
1579 LPHEADCOMBO lphc,
1580 LPRECT rectEdit,
1581 LPRECT rectLB,
1582 BOOL bRedraw)
1584 BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
1586 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1587 * sizing messages */
1589 if( lphc->wState & CBF_EDIT )
1590 SetWindowPos( lphc->hWndEdit, 0,
1591 rectEdit->left, rectEdit->top,
1592 rectEdit->right - rectEdit->left,
1593 rectEdit->bottom - rectEdit->top,
1594 SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
1596 SetWindowPos( lphc->hWndLBox, 0,
1597 rectLB->left, rectLB->top,
1598 rectLB->right - rectLB->left,
1599 rectLB->bottom - rectLB->top,
1600 SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) );
1602 if( bDrop )
1604 if( lphc->wState & CBF_DROPPED )
1606 lphc->wState &= ~CBF_DROPPED;
1607 ShowWindow( lphc->hWndLBox, SW_HIDE );
1610 if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
1611 RedrawWindow( lphc->self->hwndSelf, NULL, 0,
1612 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
1617 /***********************************************************************
1618 * COMBO_Size
1620 static void COMBO_Size( LPHEADCOMBO lphc )
1622 CBCalcPlacement(lphc->self->hwndSelf,
1623 lphc,
1624 &lphc->textRect,
1625 &lphc->buttonRect,
1626 &lphc->droppedRect);
1628 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1632 /***********************************************************************
1633 * COMBO_Font
1635 static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw )
1638 * Set the font
1640 lphc->hFont = hFont;
1643 * Propagate to owned windows.
1645 if( lphc->wState & CBF_EDIT )
1646 SendMessageA( lphc->hWndEdit, WM_SETFONT, (WPARAM)hFont, bRedraw );
1647 SendMessageA( lphc->hWndLBox, WM_SETFONT, (WPARAM)hFont, bRedraw );
1650 * Redo the layout of the control.
1652 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1654 CBCalcPlacement(lphc->self->hwndSelf,
1655 lphc,
1656 &lphc->textRect,
1657 &lphc->buttonRect,
1658 &lphc->droppedRect);
1660 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1662 else
1664 CBForceDummyResize(lphc);
1669 /***********************************************************************
1670 * COMBO_SetItemHeight
1672 static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height )
1674 LRESULT lRet = CB_ERR;
1676 if( index == -1 ) /* set text field height */
1678 if( height < 32768 )
1680 lphc->editHeight = height;
1683 * Redo the layout of the control.
1685 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1687 CBCalcPlacement(lphc->self->hwndSelf,
1688 lphc,
1689 &lphc->textRect,
1690 &lphc->buttonRect,
1691 &lphc->droppedRect);
1693 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1695 else
1697 CBForceDummyResize(lphc);
1700 lRet = height;
1703 else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */
1704 lRet = SendMessageA( lphc->hWndLBox, LB_SETITEMHEIGHT,
1705 (WPARAM)index, (LPARAM)height );
1706 return lRet;
1709 /***********************************************************************
1710 * COMBO_SelectString
1712 static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT start, LPCSTR pText )
1714 INT index = SendMessageA( lphc->hWndLBox, LB_SELECTSTRING,
1715 (WPARAM)start, (LPARAM)pText );
1716 if( index >= 0 )
1718 if( lphc->wState & CBF_EDIT )
1719 CBUpdateEdit( lphc, index );
1720 else
1722 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1725 return (LRESULT)index;
1728 /***********************************************************************
1729 * COMBO_LButtonDown
1731 static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam )
1733 POINT pt;
1734 BOOL bButton;
1735 HWND hWnd = lphc->self->hwndSelf;
1737 pt.x = LOWORD(lParam);
1738 pt.y = HIWORD(lParam);
1739 bButton = PtInRect(&lphc->buttonRect, pt);
1741 if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
1742 (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) )
1744 lphc->wState |= CBF_BUTTONDOWN;
1745 if( lphc->wState & CBF_DROPPED )
1747 /* got a click to cancel selection */
1749 lphc->wState &= ~CBF_BUTTONDOWN;
1750 CBRollUp( lphc, TRUE, FALSE );
1751 if( !IsWindow( hWnd ) ) return;
1753 if( lphc->wState & CBF_CAPTURE )
1755 lphc->wState &= ~CBF_CAPTURE;
1756 ReleaseCapture();
1759 else
1761 /* drop down the listbox and start tracking */
1763 lphc->wState |= CBF_CAPTURE;
1764 CBDropDown( lphc );
1765 SetCapture( hWnd );
1767 if( bButton ) CBRepaintButton( lphc );
1771 /***********************************************************************
1772 * COMBO_LButtonUp
1774 * Release capture and stop tracking if needed.
1776 static void COMBO_LButtonUp( LPHEADCOMBO lphc, LPARAM lParam )
1778 if( lphc->wState & CBF_CAPTURE )
1780 lphc->wState &= ~CBF_CAPTURE;
1781 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1783 INT index = CBUpdateLBox( lphc );
1784 CBUpdateEdit( lphc, index );
1786 ReleaseCapture();
1787 SetCapture(lphc->hWndLBox);
1791 if( lphc->wState & CBF_BUTTONDOWN )
1793 lphc->wState &= ~CBF_BUTTONDOWN;
1794 CBRepaintButton( lphc );
1798 /***********************************************************************
1799 * COMBO_MouseMove
1801 * Two things to do - track combo button and release capture when
1802 * pointer goes into the listbox.
1804 static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam )
1806 POINT pt;
1807 RECT lbRect;
1809 pt.x = LOWORD(lParam);
1810 pt.y = HIWORD(lParam);
1812 if( lphc->wState & CBF_BUTTONDOWN )
1814 BOOL bButton;
1816 bButton = PtInRect(&lphc->buttonRect, pt);
1818 if( !bButton )
1820 lphc->wState &= ~CBF_BUTTONDOWN;
1821 CBRepaintButton( lphc );
1825 GetClientRect( lphc->hWndLBox, &lbRect );
1826 MapWindowPoints( lphc->self->hwndSelf, lphc->hWndLBox, &pt, 1 );
1827 if( PtInRect(&lbRect, pt) )
1829 lphc->wState &= ~CBF_CAPTURE;
1830 ReleaseCapture();
1831 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc );
1833 /* hand over pointer tracking */
1834 SendMessageA( lphc->hWndLBox, WM_LBUTTONDOWN, wParam, lParam );
1839 /***********************************************************************
1840 * ComboWndProc_locked
1842 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm
1844 static inline LRESULT WINAPI ComboWndProc_locked( WND* pWnd, UINT message,
1845 WPARAM wParam, LPARAM lParam )
1847 if( pWnd ) {
1848 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1849 HWND hwnd = pWnd->hwndSelf;
1851 TRACE("[%04x]: msg %s wp %08x lp %08lx\n",
1852 pWnd->hwndSelf, SPY_GetMsgName(message), wParam, lParam );
1854 if( lphc || message == WM_NCCREATE )
1855 switch(message)
1858 /* System messages */
1860 case WM_NCCREATE:
1861 return COMBO_NCCreate(pWnd, lParam);
1862 case WM_NCDESTROY:
1863 COMBO_NCDestroy(lphc);
1864 break;/* -> DefWindowProc */
1866 case WM_CREATE:
1867 return COMBO_Create(lphc, pWnd, lParam);
1869 case WM_PRINTCLIENT:
1870 if (lParam & PRF_ERASEBKGND)
1871 COMBO_EraseBackground(hwnd, lphc, wParam);
1873 /* Fallthrough */
1874 case WM_PAINT:
1875 /* wParam may contain a valid HDC! */
1876 return COMBO_Paint(lphc, wParam);
1877 case WM_ERASEBKGND:
1878 return COMBO_EraseBackground(hwnd, lphc, wParam);
1879 case WM_GETDLGCODE:
1880 return (LRESULT)(DLGC_WANTARROWS | DLGC_WANTCHARS);
1881 case WM_WINDOWPOSCHANGING:
1882 return COMBO_WindowPosChanging(hwnd, lphc, (LPWINDOWPOS)lParam);
1883 case WM_SIZE:
1884 if( lphc->hWndLBox &&
1885 !(lphc->wState & CBF_NORESIZE) ) COMBO_Size( lphc );
1886 return TRUE;
1887 case WM_SETFONT:
1888 COMBO_Font( lphc, (HFONT16)wParam, (BOOL)lParam );
1889 return TRUE;
1890 case WM_GETFONT:
1891 return (LRESULT)lphc->hFont;
1892 case WM_SETFOCUS:
1893 if( lphc->wState & CBF_EDIT )
1894 SetFocus( lphc->hWndEdit );
1895 else
1896 COMBO_SetFocus( lphc );
1897 return TRUE;
1898 case WM_KILLFOCUS:
1899 #define hwndFocus ((HWND16)wParam)
1900 if( !hwndFocus ||
1901 (hwndFocus != lphc->hWndEdit && hwndFocus != lphc->hWndLBox ))
1902 COMBO_KillFocus( lphc );
1903 #undef hwndFocus
1904 return TRUE;
1905 case WM_COMMAND:
1906 return COMBO_Command( lphc, wParam, (HWND)lParam );
1907 case WM_GETTEXT:
1908 return COMBO_GetText( lphc, (UINT)wParam, (LPSTR)lParam );
1909 case WM_SETTEXT:
1910 case WM_GETTEXTLENGTH:
1911 case WM_CLEAR:
1912 case WM_CUT:
1913 case WM_PASTE:
1914 case WM_COPY:
1915 if ((message == WM_GETTEXTLENGTH) && !ISWIN31 && !(lphc->wState & CBF_EDIT))
1917 int j = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1918 if (j == -1) return 0;
1919 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
1921 else if( lphc->wState & CBF_EDIT )
1923 lphc->wState |= CBF_NOEDITNOTIFY;
1925 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1927 else return CB_ERR;
1929 case WM_DRAWITEM:
1930 case WM_DELETEITEM:
1931 case WM_COMPAREITEM:
1932 case WM_MEASUREITEM:
1933 return COMBO_ItemOp( lphc, message, wParam, lParam );
1934 case WM_ENABLE:
1935 if( lphc->wState & CBF_EDIT )
1936 EnableWindow( lphc->hWndEdit, (BOOL)wParam );
1937 EnableWindow( lphc->hWndLBox, (BOOL)wParam );
1939 /* Force the control to repaint when the enabled state changes. */
1940 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
1941 return TRUE;
1942 case WM_SETREDRAW:
1943 if( wParam )
1944 lphc->wState &= ~CBF_NOREDRAW;
1945 else
1946 lphc->wState |= CBF_NOREDRAW;
1948 if( lphc->wState & CBF_EDIT )
1949 SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1950 SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1951 return 0;
1952 case WM_SYSKEYDOWN:
1953 if( KEYDATA_ALT & HIWORD(lParam) )
1954 if( wParam == VK_UP || wParam == VK_DOWN )
1955 COMBO_FlipListbox( lphc, TRUE );
1956 break;/* -> DefWindowProc */
1958 case WM_CHAR:
1959 case WM_KEYDOWN:
1960 if( lphc->wState & CBF_EDIT )
1961 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1962 else
1963 return SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1964 case WM_LBUTTONDOWN:
1965 if( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self->hwndSelf );
1966 if( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam );
1967 return TRUE;
1968 case WM_LBUTTONUP:
1969 COMBO_LButtonUp( lphc, lParam );
1970 return TRUE;
1971 case WM_MOUSEMOVE:
1972 if( lphc->wState & CBF_CAPTURE )
1973 COMBO_MouseMove( lphc, wParam, lParam );
1974 return TRUE;
1975 /* Combo messages */
1977 case CB_ADDSTRING16:
1978 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1979 case CB_ADDSTRING:
1980 return SendMessageA( lphc->hWndLBox, LB_ADDSTRING, 0, lParam);
1981 case CB_INSERTSTRING16:
1982 wParam = (INT)(INT16)wParam;
1983 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1984 case CB_INSERTSTRING:
1985 return SendMessageA( lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam);
1986 case CB_DELETESTRING16:
1987 case CB_DELETESTRING:
1988 return SendMessageA( lphc->hWndLBox, LB_DELETESTRING, wParam, 0);
1989 case CB_SELECTSTRING16:
1990 wParam = (INT)(INT16)wParam;
1991 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1992 case CB_SELECTSTRING:
1993 return COMBO_SelectString( lphc, (INT)wParam, (LPSTR)lParam );
1994 case CB_FINDSTRING16:
1995 wParam = (INT)(INT16)wParam;
1996 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1997 case CB_FINDSTRING:
1998 return SendMessageA( lphc->hWndLBox, LB_FINDSTRING, wParam, lParam);
1999 case CB_FINDSTRINGEXACT16:
2000 wParam = (INT)(INT16)wParam;
2001 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2002 case CB_FINDSTRINGEXACT:
2003 return SendMessageA( lphc->hWndLBox, LB_FINDSTRINGEXACT,
2004 wParam, lParam );
2005 case CB_SETITEMHEIGHT16:
2006 wParam = (INT)(INT16)wParam; /* signed integer */
2007 case CB_SETITEMHEIGHT:
2008 return COMBO_SetItemHeight( lphc, (INT)wParam, (INT)lParam);
2009 case CB_GETITEMHEIGHT16:
2010 wParam = (INT)(INT16)wParam;
2011 case CB_GETITEMHEIGHT:
2012 if( (INT)wParam >= 0 ) /* listbox item */
2013 return SendMessageA( lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0);
2014 return CBGetTextAreaHeight(hwnd, lphc);
2015 case CB_RESETCONTENT16:
2016 case CB_RESETCONTENT:
2017 SendMessageA( lphc->hWndLBox, LB_RESETCONTENT, 0, 0 );
2018 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
2019 return TRUE;
2020 case CB_INITSTORAGE:
2021 return SendMessageA( lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam);
2022 case CB_GETHORIZONTALEXTENT:
2023 return SendMessageA( lphc->hWndLBox, LB_GETHORIZONTALEXTENT, 0, 0);
2024 case CB_SETHORIZONTALEXTENT:
2025 return SendMessageA( lphc->hWndLBox, LB_SETHORIZONTALEXTENT, wParam, 0);
2026 case CB_GETTOPINDEX:
2027 return SendMessageA( lphc->hWndLBox, LB_GETTOPINDEX, 0, 0);
2028 case CB_GETLOCALE:
2029 return SendMessageA( lphc->hWndLBox, LB_GETLOCALE, 0, 0);
2030 case CB_SETLOCALE:
2031 return SendMessageA( lphc->hWndLBox, LB_SETLOCALE, wParam, 0);
2032 case CB_GETDROPPEDWIDTH:
2033 if( lphc->droppedWidth )
2034 return lphc->droppedWidth;
2035 return lphc->droppedRect.right - lphc->droppedRect.left;
2036 case CB_SETDROPPEDWIDTH:
2037 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) &&
2038 (INT)wParam < 32768 ) lphc->droppedWidth = (INT)wParam;
2039 return CB_ERR;
2040 case CB_GETDROPPEDCONTROLRECT16:
2041 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2042 if( lParam )
2044 RECT r;
2045 CBGetDroppedControlRect( lphc, &r );
2046 CONV_RECT32TO16( &r, (LPRECT16)lParam );
2048 return CB_OKAY;
2049 case CB_GETDROPPEDCONTROLRECT:
2050 if( lParam ) CBGetDroppedControlRect(lphc, (LPRECT)lParam );
2051 return CB_OKAY;
2052 case CB_GETDROPPEDSTATE16:
2053 case CB_GETDROPPEDSTATE:
2054 return (lphc->wState & CBF_DROPPED) ? TRUE : FALSE;
2055 case CB_DIR16:
2056 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2057 /* fall through */
2058 case CB_DIR:
2059 return COMBO_Directory( lphc, (UINT)wParam,
2060 (LPSTR)lParam, (message == CB_DIR));
2061 case CB_SHOWDROPDOWN16:
2062 case CB_SHOWDROPDOWN:
2063 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
2065 if( wParam )
2067 if( !(lphc->wState & CBF_DROPPED) )
2068 CBDropDown( lphc );
2070 else
2071 if( lphc->wState & CBF_DROPPED )
2072 CBRollUp( lphc, FALSE, TRUE );
2074 return TRUE;
2075 case CB_GETCOUNT16:
2076 case CB_GETCOUNT:
2077 return SendMessageA( lphc->hWndLBox, LB_GETCOUNT, 0, 0);
2078 case CB_GETCURSEL16:
2079 case CB_GETCURSEL:
2080 return SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0);
2081 case CB_SETCURSEL16:
2082 wParam = (INT)(INT16)wParam;
2083 case CB_SETCURSEL:
2084 lParam = SendMessageA( lphc->hWndLBox, LB_SETCURSEL, wParam, 0);
2085 if( lphc->wState & CBF_SELCHANGE )
2087 /* no LBN_SELCHANGE in this case, update manually */
2088 if( lphc->wState & CBF_EDIT )
2089 CBUpdateEdit( lphc, (INT)wParam );
2090 else
2091 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
2092 lphc->wState &= ~CBF_SELCHANGE;
2094 return lParam;
2095 case CB_GETLBTEXT16:
2096 wParam = (INT)(INT16)wParam;
2097 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2098 case CB_GETLBTEXT:
2099 return SendMessageA( lphc->hWndLBox, LB_GETTEXT, wParam, lParam);
2100 case CB_GETLBTEXTLEN16:
2101 wParam = (INT)(INT16)wParam;
2102 case CB_GETLBTEXTLEN:
2103 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
2104 case CB_GETITEMDATA16:
2105 wParam = (INT)(INT16)wParam;
2106 case CB_GETITEMDATA:
2107 return SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, wParam, 0);
2108 case CB_SETITEMDATA16:
2109 wParam = (INT)(INT16)wParam;
2110 case CB_SETITEMDATA:
2111 return SendMessageA( lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam);
2112 case CB_GETEDITSEL16:
2113 wParam = lParam = 0; /* just in case */
2114 case CB_GETEDITSEL:
2115 if( lphc->wState & CBF_EDIT )
2117 INT a, b;
2119 return SendMessageA( lphc->hWndEdit, EM_GETSEL,
2120 (wParam) ? wParam : (WPARAM)&a,
2121 (lParam) ? lParam : (LPARAM)&b );
2123 return CB_ERR;
2124 case CB_SETEDITSEL16:
2125 case CB_SETEDITSEL:
2126 if( lphc->wState & CBF_EDIT )
2127 return SendMessageA( lphc->hWndEdit, EM_SETSEL,
2128 (INT)(INT16)LOWORD(lParam), (INT)(INT16)HIWORD(lParam) );
2129 return CB_ERR;
2130 case CB_SETEXTENDEDUI16:
2131 case CB_SETEXTENDEDUI:
2132 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
2133 return CB_ERR;
2134 if( wParam )
2135 lphc->wState |= CBF_EUI;
2136 else lphc->wState &= ~CBF_EUI;
2137 return CB_OKAY;
2138 case CB_GETEXTENDEDUI16:
2139 case CB_GETEXTENDEDUI:
2140 return (lphc->wState & CBF_EUI) ? TRUE : FALSE;
2141 case (WM_USER + 0x1B):
2142 WARN("[%04x]: undocumented msg!\n", hwnd );
2144 return DefWindowProcA(hwnd, message, wParam, lParam);
2146 return CB_ERR;
2149 /***********************************************************************
2150 * ComboWndProc
2152 * This is just a wrapper for the real ComboWndProc which locks/unlocks
2153 * window structs.
2155 LRESULT WINAPI ComboWndProc( HWND hwnd, UINT message,
2156 WPARAM wParam, LPARAM lParam )
2158 WND* pWnd = WIN_FindWndPtr(hwnd);
2159 LRESULT retvalue = ComboWndProc_locked(pWnd,message,wParam,lParam);
2162 WIN_ReleaseWndPtr(pWnd);
2163 return retvalue;