Added support to the server for loading new format (version 2) files.
[wine/hacks.git] / controls / combo.c
blobc3e9f33570250f053e9d282ab61388d0d91c1186
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 CB_NOTIFY( lphc, CBN_SELCHANGE );
1464 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1465 /* fall through */
1467 case LBN_SETFOCUS:
1468 case LBN_KILLFOCUS:
1469 /* nothing to do here since ComboLBox always resets the focus to its
1470 * combo/edit counterpart */
1471 break;
1474 return 0;
1477 /***********************************************************************
1478 * COMBO_ItemOp
1480 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1482 static LRESULT COMBO_ItemOp( LPHEADCOMBO lphc, UINT msg,
1483 WPARAM wParam, LPARAM lParam )
1485 HWND hWnd = lphc->self->hwndSelf;
1487 TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg );
1489 #define lpIS ((LPDELETEITEMSTRUCT)lParam)
1491 /* two first items are the same in all 4 structs */
1492 lpIS->CtlType = ODT_COMBOBOX;
1493 lpIS->CtlID = lphc->self->wIDmenu;
1495 switch( msg ) /* patch window handle */
1497 case WM_DELETEITEM:
1498 lpIS->hwndItem = hWnd;
1499 #undef lpIS
1500 break;
1501 case WM_DRAWITEM:
1502 #define lpIS ((LPDRAWITEMSTRUCT)lParam)
1503 lpIS->hwndItem = hWnd;
1504 #undef lpIS
1505 break;
1506 case WM_COMPAREITEM:
1507 #define lpIS ((LPCOMPAREITEMSTRUCT)lParam)
1508 lpIS->hwndItem = hWnd;
1509 #undef lpIS
1510 break;
1513 return SendMessageA( lphc->owner, msg, lphc->self->wIDmenu, lParam );
1516 /***********************************************************************
1517 * COMBO_GetText
1519 static LRESULT COMBO_GetText( LPHEADCOMBO lphc, UINT N, LPSTR lpText)
1521 if( lphc->wState & CBF_EDIT )
1522 return SendMessageA( lphc->hWndEdit, WM_GETTEXT,
1523 (WPARAM)N, (LPARAM)lpText );
1525 /* get it from the listbox */
1527 if( lphc->hWndLBox )
1529 INT idx = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1530 if( idx != LB_ERR )
1532 LPSTR lpBuffer;
1533 INT length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN,
1534 (WPARAM)idx, 0 );
1536 /* 'length' is without the terminating character */
1537 if( length >= N )
1538 lpBuffer = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1 );
1539 else
1540 lpBuffer = lpText;
1542 if( lpBuffer )
1544 INT n = SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1545 (WPARAM)idx, (LPARAM)lpBuffer );
1547 /* truncate if buffer is too short */
1549 if( length >= N )
1551 if (N && lpText) {
1552 if( n != LB_ERR ) memcpy( lpText, lpBuffer, (N>n) ? n+1 : N-1 );
1553 lpText[N - 1] = '\0';
1555 HeapFree( GetProcessHeap(), 0, lpBuffer );
1557 return (LRESULT)n;
1561 return 0;
1565 /***********************************************************************
1566 * CBResetPos
1568 * This function sets window positions according to the updated
1569 * component placement struct.
1571 static void CBResetPos(
1572 LPHEADCOMBO lphc,
1573 LPRECT rectEdit,
1574 LPRECT rectLB,
1575 BOOL bRedraw)
1577 BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
1579 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1580 * sizing messages */
1582 if( lphc->wState & CBF_EDIT )
1583 SetWindowPos( lphc->hWndEdit, 0,
1584 rectEdit->left, rectEdit->top,
1585 rectEdit->right - rectEdit->left,
1586 rectEdit->bottom - rectEdit->top,
1587 SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
1589 SetWindowPos( lphc->hWndLBox, 0,
1590 rectLB->left, rectLB->top,
1591 rectLB->right - rectLB->left,
1592 rectLB->bottom - rectLB->top,
1593 SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) );
1595 if( bDrop )
1597 if( lphc->wState & CBF_DROPPED )
1599 lphc->wState &= ~CBF_DROPPED;
1600 ShowWindow( lphc->hWndLBox, SW_HIDE );
1603 if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
1604 RedrawWindow( lphc->self->hwndSelf, NULL, 0,
1605 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
1610 /***********************************************************************
1611 * COMBO_Size
1613 static void COMBO_Size( LPHEADCOMBO lphc )
1615 CBCalcPlacement(lphc->self->hwndSelf,
1616 lphc,
1617 &lphc->textRect,
1618 &lphc->buttonRect,
1619 &lphc->droppedRect);
1621 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1625 /***********************************************************************
1626 * COMBO_Font
1628 static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw )
1631 * Set the font
1633 lphc->hFont = hFont;
1636 * Propagate to owned windows.
1638 if( lphc->wState & CBF_EDIT )
1639 SendMessageA( lphc->hWndEdit, WM_SETFONT, (WPARAM)hFont, bRedraw );
1640 SendMessageA( lphc->hWndLBox, WM_SETFONT, (WPARAM)hFont, bRedraw );
1643 * Redo the layout of the control.
1645 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1647 CBCalcPlacement(lphc->self->hwndSelf,
1648 lphc,
1649 &lphc->textRect,
1650 &lphc->buttonRect,
1651 &lphc->droppedRect);
1653 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1655 else
1657 CBForceDummyResize(lphc);
1662 /***********************************************************************
1663 * COMBO_SetItemHeight
1665 static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height )
1667 LRESULT lRet = CB_ERR;
1669 if( index == -1 ) /* set text field height */
1671 if( height < 32768 )
1673 lphc->editHeight = height;
1676 * Redo the layout of the control.
1678 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1680 CBCalcPlacement(lphc->self->hwndSelf,
1681 lphc,
1682 &lphc->textRect,
1683 &lphc->buttonRect,
1684 &lphc->droppedRect);
1686 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1688 else
1690 CBForceDummyResize(lphc);
1693 lRet = height;
1696 else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */
1697 lRet = SendMessageA( lphc->hWndLBox, LB_SETITEMHEIGHT,
1698 (WPARAM)index, (LPARAM)height );
1699 return lRet;
1702 /***********************************************************************
1703 * COMBO_SelectString
1705 static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT start, LPCSTR pText )
1707 INT index = SendMessageA( lphc->hWndLBox, LB_SELECTSTRING,
1708 (WPARAM)start, (LPARAM)pText );
1709 if( index >= 0 )
1711 if( lphc->wState & CBF_EDIT )
1712 CBUpdateEdit( lphc, index );
1713 else
1715 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1718 return (LRESULT)index;
1721 /***********************************************************************
1722 * COMBO_LButtonDown
1724 static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam )
1726 POINT pt;
1727 BOOL bButton;
1728 HWND hWnd = lphc->self->hwndSelf;
1730 pt.x = LOWORD(lParam);
1731 pt.y = HIWORD(lParam);
1732 bButton = PtInRect(&lphc->buttonRect, pt);
1734 if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
1735 (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) )
1737 lphc->wState |= CBF_BUTTONDOWN;
1738 if( lphc->wState & CBF_DROPPED )
1740 /* got a click to cancel selection */
1742 lphc->wState &= ~CBF_BUTTONDOWN;
1743 CBRollUp( lphc, TRUE, FALSE );
1744 if( !IsWindow( hWnd ) ) return;
1746 if( lphc->wState & CBF_CAPTURE )
1748 lphc->wState &= ~CBF_CAPTURE;
1749 ReleaseCapture();
1752 else
1754 /* drop down the listbox and start tracking */
1756 lphc->wState |= CBF_CAPTURE;
1757 CBDropDown( lphc );
1758 SetCapture( hWnd );
1760 if( bButton ) CBRepaintButton( lphc );
1764 /***********************************************************************
1765 * COMBO_LButtonUp
1767 * Release capture and stop tracking if needed.
1769 static void COMBO_LButtonUp( LPHEADCOMBO lphc, LPARAM lParam )
1771 if( lphc->wState & CBF_CAPTURE )
1773 lphc->wState &= ~CBF_CAPTURE;
1774 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1776 INT index = CBUpdateLBox( lphc );
1777 CBUpdateEdit( lphc, index );
1779 ReleaseCapture();
1780 SetCapture(lphc->hWndLBox);
1784 if( lphc->wState & CBF_BUTTONDOWN )
1786 lphc->wState &= ~CBF_BUTTONDOWN;
1787 CBRepaintButton( lphc );
1791 /***********************************************************************
1792 * COMBO_MouseMove
1794 * Two things to do - track combo button and release capture when
1795 * pointer goes into the listbox.
1797 static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam )
1799 POINT pt;
1800 RECT lbRect;
1802 pt.x = LOWORD(lParam);
1803 pt.y = HIWORD(lParam);
1805 if( lphc->wState & CBF_BUTTONDOWN )
1807 BOOL bButton;
1809 bButton = PtInRect(&lphc->buttonRect, pt);
1811 if( !bButton )
1813 lphc->wState &= ~CBF_BUTTONDOWN;
1814 CBRepaintButton( lphc );
1818 GetClientRect( lphc->hWndLBox, &lbRect );
1819 MapWindowPoints( lphc->self->hwndSelf, lphc->hWndLBox, &pt, 1 );
1820 if( PtInRect(&lbRect, pt) )
1822 lphc->wState &= ~CBF_CAPTURE;
1823 ReleaseCapture();
1824 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc );
1826 /* hand over pointer tracking */
1827 SendMessageA( lphc->hWndLBox, WM_LBUTTONDOWN, wParam, lParam );
1832 /***********************************************************************
1833 * ComboWndProc_locked
1835 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm
1837 static inline LRESULT WINAPI ComboWndProc_locked( WND* pWnd, UINT message,
1838 WPARAM wParam, LPARAM lParam )
1840 if( pWnd ) {
1841 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1842 HWND hwnd = pWnd->hwndSelf;
1844 TRACE("[%04x]: msg %s wp %08x lp %08lx\n",
1845 pWnd->hwndSelf, SPY_GetMsgName(message), wParam, lParam );
1847 if( lphc || message == WM_NCCREATE )
1848 switch(message)
1851 /* System messages */
1853 case WM_NCCREATE:
1854 return COMBO_NCCreate(pWnd, lParam);
1855 case WM_NCDESTROY:
1856 COMBO_NCDestroy(lphc);
1857 break;/* -> DefWindowProc */
1859 case WM_CREATE:
1860 return COMBO_Create(lphc, pWnd, lParam);
1862 case WM_PRINTCLIENT:
1863 if (lParam & PRF_ERASEBKGND)
1864 COMBO_EraseBackground(hwnd, lphc, wParam);
1866 /* Fallthrough */
1867 case WM_PAINT:
1868 /* wParam may contain a valid HDC! */
1869 return COMBO_Paint(lphc, wParam);
1870 case WM_ERASEBKGND:
1871 return COMBO_EraseBackground(hwnd, lphc, wParam);
1872 case WM_GETDLGCODE:
1873 return (LRESULT)(DLGC_WANTARROWS | DLGC_WANTCHARS);
1874 case WM_WINDOWPOSCHANGING:
1875 return COMBO_WindowPosChanging(hwnd, lphc, (LPWINDOWPOS)lParam);
1876 case WM_SIZE:
1877 if( lphc->hWndLBox &&
1878 !(lphc->wState & CBF_NORESIZE) ) COMBO_Size( lphc );
1879 return TRUE;
1880 case WM_SETFONT:
1881 COMBO_Font( lphc, (HFONT16)wParam, (BOOL)lParam );
1882 return TRUE;
1883 case WM_GETFONT:
1884 return (LRESULT)lphc->hFont;
1885 case WM_SETFOCUS:
1886 if( lphc->wState & CBF_EDIT )
1887 SetFocus( lphc->hWndEdit );
1888 else
1889 COMBO_SetFocus( lphc );
1890 return TRUE;
1891 case WM_KILLFOCUS:
1892 #define hwndFocus ((HWND16)wParam)
1893 if( !hwndFocus ||
1894 (hwndFocus != lphc->hWndEdit && hwndFocus != lphc->hWndLBox ))
1895 COMBO_KillFocus( lphc );
1896 #undef hwndFocus
1897 return TRUE;
1898 case WM_COMMAND:
1899 return COMBO_Command( lphc, wParam, (HWND)lParam );
1900 case WM_GETTEXT:
1901 return COMBO_GetText( lphc, (UINT)wParam, (LPSTR)lParam );
1902 case WM_SETTEXT:
1903 case WM_GETTEXTLENGTH:
1904 case WM_CLEAR:
1905 case WM_CUT:
1906 case WM_PASTE:
1907 case WM_COPY:
1908 if ((message == WM_GETTEXTLENGTH) && !ISWIN31 && !(lphc->wState & CBF_EDIT))
1910 int j = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1911 if (j == -1) return 0;
1912 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
1914 else if( lphc->wState & CBF_EDIT )
1916 lphc->wState |= CBF_NOEDITNOTIFY;
1918 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1920 else return CB_ERR;
1922 case WM_DRAWITEM:
1923 case WM_DELETEITEM:
1924 case WM_COMPAREITEM:
1925 case WM_MEASUREITEM:
1926 return COMBO_ItemOp( lphc, message, wParam, lParam );
1927 case WM_ENABLE:
1928 if( lphc->wState & CBF_EDIT )
1929 EnableWindow( lphc->hWndEdit, (BOOL)wParam );
1930 EnableWindow( lphc->hWndLBox, (BOOL)wParam );
1932 /* Force the control to repaint when the enabled state changes. */
1933 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
1934 return TRUE;
1935 case WM_SETREDRAW:
1936 if( wParam )
1937 lphc->wState &= ~CBF_NOREDRAW;
1938 else
1939 lphc->wState |= CBF_NOREDRAW;
1941 if( lphc->wState & CBF_EDIT )
1942 SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1943 SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1944 return 0;
1945 case WM_SYSKEYDOWN:
1946 if( KEYDATA_ALT & HIWORD(lParam) )
1947 if( wParam == VK_UP || wParam == VK_DOWN )
1948 COMBO_FlipListbox( lphc, TRUE );
1949 break;/* -> DefWindowProc */
1951 case WM_CHAR:
1952 case WM_KEYDOWN:
1953 if( lphc->wState & CBF_EDIT )
1954 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1955 else
1956 return SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1957 case WM_LBUTTONDOWN:
1958 if( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self->hwndSelf );
1959 if( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam );
1960 return TRUE;
1961 case WM_LBUTTONUP:
1962 COMBO_LButtonUp( lphc, lParam );
1963 return TRUE;
1964 case WM_MOUSEMOVE:
1965 if( lphc->wState & CBF_CAPTURE )
1966 COMBO_MouseMove( lphc, wParam, lParam );
1967 return TRUE;
1968 /* Combo messages */
1970 case CB_ADDSTRING16:
1971 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1972 case CB_ADDSTRING:
1973 return SendMessageA( lphc->hWndLBox, LB_ADDSTRING, 0, lParam);
1974 case CB_INSERTSTRING16:
1975 wParam = (INT)(INT16)wParam;
1976 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1977 case CB_INSERTSTRING:
1978 return SendMessageA( lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam);
1979 case CB_DELETESTRING16:
1980 case CB_DELETESTRING:
1981 return SendMessageA( lphc->hWndLBox, LB_DELETESTRING, wParam, 0);
1982 case CB_SELECTSTRING16:
1983 wParam = (INT)(INT16)wParam;
1984 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1985 case CB_SELECTSTRING:
1986 return COMBO_SelectString( lphc, (INT)wParam, (LPSTR)lParam );
1987 case CB_FINDSTRING16:
1988 wParam = (INT)(INT16)wParam;
1989 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1990 case CB_FINDSTRING:
1991 return SendMessageA( lphc->hWndLBox, LB_FINDSTRING, wParam, lParam);
1992 case CB_FINDSTRINGEXACT16:
1993 wParam = (INT)(INT16)wParam;
1994 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1995 case CB_FINDSTRINGEXACT:
1996 return SendMessageA( lphc->hWndLBox, LB_FINDSTRINGEXACT,
1997 wParam, lParam );
1998 case CB_SETITEMHEIGHT16:
1999 wParam = (INT)(INT16)wParam; /* signed integer */
2000 case CB_SETITEMHEIGHT:
2001 return COMBO_SetItemHeight( lphc, (INT)wParam, (INT)lParam);
2002 case CB_GETITEMHEIGHT16:
2003 wParam = (INT)(INT16)wParam;
2004 case CB_GETITEMHEIGHT:
2005 if( (INT)wParam >= 0 ) /* listbox item */
2006 return SendMessageA( lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0);
2007 return CBGetTextAreaHeight(hwnd, lphc);
2008 case CB_RESETCONTENT16:
2009 case CB_RESETCONTENT:
2010 SendMessageA( lphc->hWndLBox, LB_RESETCONTENT, 0, 0 );
2011 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
2012 return TRUE;
2013 case CB_INITSTORAGE:
2014 return SendMessageA( lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam);
2015 case CB_GETHORIZONTALEXTENT:
2016 return SendMessageA( lphc->hWndLBox, LB_GETHORIZONTALEXTENT, 0, 0);
2017 case CB_SETHORIZONTALEXTENT:
2018 return SendMessageA( lphc->hWndLBox, LB_SETHORIZONTALEXTENT, wParam, 0);
2019 case CB_GETTOPINDEX:
2020 return SendMessageA( lphc->hWndLBox, LB_GETTOPINDEX, 0, 0);
2021 case CB_GETLOCALE:
2022 return SendMessageA( lphc->hWndLBox, LB_GETLOCALE, 0, 0);
2023 case CB_SETLOCALE:
2024 return SendMessageA( lphc->hWndLBox, LB_SETLOCALE, wParam, 0);
2025 case CB_GETDROPPEDWIDTH:
2026 if( lphc->droppedWidth )
2027 return lphc->droppedWidth;
2028 return lphc->droppedRect.right - lphc->droppedRect.left;
2029 case CB_SETDROPPEDWIDTH:
2030 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) &&
2031 (INT)wParam < 32768 ) lphc->droppedWidth = (INT)wParam;
2032 return CB_ERR;
2033 case CB_GETDROPPEDCONTROLRECT16:
2034 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2035 if( lParam )
2037 RECT r;
2038 CBGetDroppedControlRect( lphc, &r );
2039 CONV_RECT32TO16( &r, (LPRECT16)lParam );
2041 return CB_OKAY;
2042 case CB_GETDROPPEDCONTROLRECT:
2043 if( lParam ) CBGetDroppedControlRect(lphc, (LPRECT)lParam );
2044 return CB_OKAY;
2045 case CB_GETDROPPEDSTATE16:
2046 case CB_GETDROPPEDSTATE:
2047 return (lphc->wState & CBF_DROPPED) ? TRUE : FALSE;
2048 case CB_DIR16:
2049 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2050 /* fall through */
2051 case CB_DIR:
2052 return COMBO_Directory( lphc, (UINT)wParam,
2053 (LPSTR)lParam, (message == CB_DIR));
2054 case CB_SHOWDROPDOWN16:
2055 case CB_SHOWDROPDOWN:
2056 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
2058 if( wParam )
2060 if( !(lphc->wState & CBF_DROPPED) )
2061 CBDropDown( lphc );
2063 else
2064 if( lphc->wState & CBF_DROPPED )
2065 CBRollUp( lphc, FALSE, TRUE );
2067 return TRUE;
2068 case CB_GETCOUNT16:
2069 case CB_GETCOUNT:
2070 return SendMessageA( lphc->hWndLBox, LB_GETCOUNT, 0, 0);
2071 case CB_GETCURSEL16:
2072 case CB_GETCURSEL:
2073 return SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0);
2074 case CB_SETCURSEL16:
2075 wParam = (INT)(INT16)wParam;
2076 case CB_SETCURSEL:
2077 lParam = SendMessageA( lphc->hWndLBox, LB_SETCURSEL, wParam, 0);
2078 if( lphc->wState & CBF_SELCHANGE )
2080 /* no LBN_SELCHANGE in this case, update manually */
2081 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
2082 lphc->wState &= ~CBF_SELCHANGE;
2084 return lParam;
2085 case CB_GETLBTEXT16:
2086 wParam = (INT)(INT16)wParam;
2087 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2088 case CB_GETLBTEXT:
2089 return SendMessageA( lphc->hWndLBox, LB_GETTEXT, wParam, lParam);
2090 case CB_GETLBTEXTLEN16:
2091 wParam = (INT)(INT16)wParam;
2092 case CB_GETLBTEXTLEN:
2093 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
2094 case CB_GETITEMDATA16:
2095 wParam = (INT)(INT16)wParam;
2096 case CB_GETITEMDATA:
2097 return SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, wParam, 0);
2098 case CB_SETITEMDATA16:
2099 wParam = (INT)(INT16)wParam;
2100 case CB_SETITEMDATA:
2101 return SendMessageA( lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam);
2102 case CB_GETEDITSEL16:
2103 wParam = lParam = 0; /* just in case */
2104 case CB_GETEDITSEL:
2105 if( lphc->wState & CBF_EDIT )
2107 INT a, b;
2109 return SendMessageA( lphc->hWndEdit, EM_GETSEL,
2110 (wParam) ? wParam : (WPARAM)&a,
2111 (lParam) ? lParam : (LPARAM)&b );
2113 return CB_ERR;
2114 case CB_SETEDITSEL16:
2115 case CB_SETEDITSEL:
2116 if( lphc->wState & CBF_EDIT )
2117 return SendMessageA( lphc->hWndEdit, EM_SETSEL,
2118 (INT)(INT16)LOWORD(lParam), (INT)(INT16)HIWORD(lParam) );
2119 return CB_ERR;
2120 case CB_SETEXTENDEDUI16:
2121 case CB_SETEXTENDEDUI:
2122 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
2123 return CB_ERR;
2124 if( wParam )
2125 lphc->wState |= CBF_EUI;
2126 else lphc->wState &= ~CBF_EUI;
2127 return CB_OKAY;
2128 case CB_GETEXTENDEDUI16:
2129 case CB_GETEXTENDEDUI:
2130 return (lphc->wState & CBF_EUI) ? TRUE : FALSE;
2131 case (WM_USER + 0x1B):
2132 WARN("[%04x]: undocumented msg!\n", hwnd );
2134 return DefWindowProcA(hwnd, message, wParam, lParam);
2136 return CB_ERR;
2139 /***********************************************************************
2140 * ComboWndProc
2142 * This is just a wrapper for the real ComboWndProc which locks/unlocks
2143 * window structs.
2145 LRESULT WINAPI ComboWndProc( HWND hwnd, UINT message,
2146 WPARAM wParam, LPARAM lParam )
2148 WND* pWnd = WIN_FindWndPtr(hwnd);
2149 LRESULT retvalue = ComboWndProc_locked(pWnd,message,wParam,lParam);
2152 WIN_ReleaseWndPtr(pWnd);
2153 return retvalue;