Fixed potential buffer overflows (spotted by Francois Gouget).
[wine/multimedia.git] / controls / combo.c
blob8ff63334d1c2fef0098c5ab5d95c690702d269d7
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;
1058 LPSTR pText = NULL;
1060 idx = 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 HeapFree( GetProcessHeap(), 0, pText );
1077 if( idx >= 0 )
1079 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)idx, 0 );
1080 /* probably superfluous but Windows sends this too */
1081 SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)idx, 0 );
1083 return idx;
1086 /***********************************************************************
1087 * CBUpdateEdit
1089 * Copy a listbox entry to the edit control.
1091 static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
1093 INT length;
1094 LPSTR pText = NULL;
1096 TRACE("\t %i\n", index );
1098 if( index >= 0 ) /* got an entry */
1100 length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, (WPARAM)index, 0);
1101 if( length )
1103 if( (pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1)) )
1105 SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1106 (WPARAM)index, (LPARAM)pText );
1111 lphc->wState |= CBF_NOEDITNOTIFY;
1113 SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, pText ? (LPARAM)pText : (LPARAM)"" );
1115 if( pText )
1116 HeapFree( GetProcessHeap(), 0, pText );
1119 /***********************************************************************
1120 * CBDropDown
1122 * Show listbox popup.
1124 static void CBDropDown( LPHEADCOMBO lphc )
1126 RECT rect;
1127 int nItems = 0;
1128 int i;
1129 int nHeight;
1130 int nDroppedHeight, nTempDroppedHeight;
1132 TRACE("[%04x]: drop down\n", CB_HWND(lphc));
1134 CB_NOTIFY( lphc, CBN_DROPDOWN );
1136 /* set selection */
1138 lphc->wState |= CBF_DROPPED;
1139 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1141 lphc->droppedIndex = CBUpdateLBox( lphc );
1143 if( !(lphc->wState & CBF_CAPTURE) )
1144 CBUpdateEdit( lphc, lphc->droppedIndex );
1146 else
1148 lphc->droppedIndex = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1150 if( lphc->droppedIndex == LB_ERR )
1151 lphc->droppedIndex = 0;
1153 SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, (WPARAM)lphc->droppedIndex, 0 );
1154 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
1157 /* now set popup position */
1158 GetWindowRect( lphc->self->hwndSelf, &rect );
1161 * If it's a dropdown, the listbox is offset
1163 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1164 rect.left += COMBO_EDITBUTTONSPACE();
1166 /* if the dropped height is greater than the total height of the dropped
1167 items list, then force the drop down list height to be the total height
1168 of the items in the dropped list */
1170 /* And Remove any extra space (Best Fit) */
1171 nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
1172 nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0);
1173 nHeight = COMBO_YBORDERSIZE();
1174 nTempDroppedHeight = 0;
1175 for (i = 0; i < nItems; i++)
1177 nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0);
1179 /* Did we pass the limit of what can be displayed */
1180 if (nHeight > nDroppedHeight)
1182 break;
1184 nTempDroppedHeight = nHeight;
1187 nDroppedHeight = nTempDroppedHeight;
1189 SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
1190 lphc->droppedRect.right - lphc->droppedRect.left,
1191 nDroppedHeight,
1192 SWP_NOACTIVATE | SWP_NOREDRAW);
1194 if( !(lphc->wState & CBF_NOREDRAW) )
1195 RedrawWindow( lphc->self->hwndSelf, NULL, 0, RDW_INVALIDATE |
1196 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
1198 ShowWindow( lphc->hWndLBox, SW_SHOWNA );
1201 /***********************************************************************
1202 * CBRollUp
1204 * Hide listbox popup.
1206 static void CBRollUp( LPHEADCOMBO lphc, BOOL ok, BOOL bButton )
1208 HWND hWnd = lphc->self->hwndSelf;
1210 CB_NOTIFY( lphc, (ok) ? CBN_SELENDOK : CBN_SELENDCANCEL );
1212 if( IsWindow( hWnd ) && CB_GETTYPE(lphc) != CBS_SIMPLE )
1215 TRACE("[%04x]: roll up [%i]\n", CB_HWND(lphc), (INT)ok );
1217 if( lphc->wState & CBF_DROPPED )
1219 RECT rect;
1221 lphc->wState &= ~CBF_DROPPED;
1222 ShowWindow( lphc->hWndLBox, SW_HIDE );
1223 if(GetCapture() == lphc->hWndLBox)
1225 ReleaseCapture();
1228 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1230 INT index = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1231 CBUpdateEdit( lphc, index );
1232 rect = lphc->buttonRect;
1234 else
1236 if( bButton )
1238 UnionRect( &rect,
1239 &lphc->buttonRect,
1240 &lphc->textRect);
1242 else
1243 rect = lphc->textRect;
1245 bButton = TRUE;
1248 if( bButton && !(lphc->wState & CBF_NOREDRAW) )
1249 RedrawWindow( hWnd, &rect, 0, RDW_INVALIDATE |
1250 RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
1251 CB_NOTIFY( lphc, CBN_CLOSEUP );
1256 /***********************************************************************
1257 * COMBO_FlipListbox
1259 * Used by the ComboLBox to show/hide itself in response to VK_F4, etc...
1261 BOOL COMBO_FlipListbox( LPHEADCOMBO lphc, BOOL bRedrawButton )
1263 if( lphc->wState & CBF_DROPPED )
1265 CBRollUp( lphc, TRUE, bRedrawButton );
1266 return FALSE;
1269 CBDropDown( lphc );
1270 return TRUE;
1273 /***********************************************************************
1274 * COMBO_GetLBWindow
1276 * Edit control helper.
1278 HWND COMBO_GetLBWindow( WND* pWnd )
1280 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1281 if( lphc ) return lphc->hWndLBox;
1282 return 0;
1286 /***********************************************************************
1287 * CBRepaintButton
1289 static void CBRepaintButton( LPHEADCOMBO lphc )
1291 InvalidateRect(CB_HWND(lphc), &lphc->buttonRect, TRUE);
1292 UpdateWindow(CB_HWND(lphc));
1295 /***********************************************************************
1296 * COMBO_SetFocus
1298 static void COMBO_SetFocus( LPHEADCOMBO lphc )
1300 if( !(lphc->wState & CBF_FOCUSED) )
1302 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1303 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
1305 lphc->wState |= CBF_FOCUSED;
1307 if( !(lphc->wState & CBF_EDIT) )
1308 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1310 CB_NOTIFY( lphc, CBN_SETFOCUS );
1314 /***********************************************************************
1315 * COMBO_KillFocus
1317 static void COMBO_KillFocus( LPHEADCOMBO lphc )
1319 HWND hWnd = lphc->self->hwndSelf;
1321 if( lphc->wState & CBF_FOCUSED )
1323 CBRollUp( lphc, FALSE, TRUE );
1324 if( IsWindow( hWnd ) )
1326 if( CB_GETTYPE(lphc) == CBS_DROPDOWNLIST )
1327 SendMessageA( lphc->hWndLBox, LB_CARETOFF, 0, 0 );
1329 lphc->wState &= ~CBF_FOCUSED;
1331 /* redraw text */
1332 if( !(lphc->wState & CBF_EDIT) )
1333 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1335 CB_NOTIFY( lphc, CBN_KILLFOCUS );
1340 /***********************************************************************
1341 * COMBO_Command
1343 static LRESULT COMBO_Command( LPHEADCOMBO lphc, WPARAM wParam, HWND hWnd )
1345 if ( lphc->wState & CBF_EDIT && lphc->hWndEdit == hWnd )
1347 /* ">> 8" makes gcc generate jump-table instead of cmp ladder */
1349 switch( HIWORD(wParam) >> 8 )
1351 case (EN_SETFOCUS >> 8):
1353 TRACE("[%04x]: edit [%04x] got focus\n",
1354 CB_HWND(lphc), lphc->hWndEdit );
1356 COMBO_SetFocus( lphc );
1357 break;
1359 case (EN_KILLFOCUS >> 8):
1361 TRACE("[%04x]: edit [%04x] lost focus\n",
1362 CB_HWND(lphc), lphc->hWndEdit );
1364 /* NOTE: it seems that Windows' edit control sends an
1365 * undocumented message WM_USER + 0x1B instead of this
1366 * notification (only when it happens to be a part of
1367 * the combo). ?? - AK.
1370 COMBO_KillFocus( lphc );
1371 break;
1374 case (EN_CHANGE >> 8):
1376 * In some circumstances (when the selection of the combobox
1377 * is changed for example) we don't wans the EN_CHANGE notification
1378 * to be forwarded to the parent of the combobox. This code
1379 * checks a flag that is set in these occasions and ignores the
1380 * notification.
1382 if (lphc->wState & CBF_NOEDITNOTIFY)
1384 lphc->wState &= ~CBF_NOEDITNOTIFY;
1386 else
1388 CB_NOTIFY( lphc, CBN_EDITCHANGE );
1391 CBUpdateLBox( lphc );
1392 break;
1394 case (EN_UPDATE >> 8):
1395 CB_NOTIFY( lphc, CBN_EDITUPDATE );
1396 break;
1398 case (EN_ERRSPACE >> 8):
1399 CB_NOTIFY( lphc, CBN_ERRSPACE );
1402 else if( lphc->hWndLBox == hWnd )
1404 switch( HIWORD(wParam) )
1406 case LBN_ERRSPACE:
1407 CB_NOTIFY( lphc, CBN_ERRSPACE );
1408 break;
1410 case LBN_DBLCLK:
1411 CB_NOTIFY( lphc, CBN_DBLCLK );
1412 break;
1414 case LBN_SELCHANGE:
1415 case LBN_SELCANCEL:
1417 TRACE("[%04x]: lbox selection change [%04x]\n",
1418 CB_HWND(lphc), lphc->wState );
1420 /* do not roll up if selection is being tracked
1421 * by arrowkeys in the dropdown listbox */
1423 if( (lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP) )
1424 CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
1425 else lphc->wState &= ~CBF_NOROLLUP;
1427 if( lphc->wState & CBF_EDIT )
1429 INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
1430 CBUpdateEdit( lphc, index );
1431 /* select text in edit, as Windows does */
1432 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
1434 else
1435 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1437 CB_NOTIFY( lphc, CBN_SELCHANGE );
1438 /* fall through */
1440 case LBN_SETFOCUS:
1441 case LBN_KILLFOCUS:
1442 /* nothing to do here since ComboLBox always resets the focus to its
1443 * combo/edit counterpart */
1444 break;
1447 return 0;
1450 /***********************************************************************
1451 * COMBO_ItemOp
1453 * Fixup an ownerdrawn item operation and pass it up to the combobox owner.
1455 static LRESULT COMBO_ItemOp( LPHEADCOMBO lphc, UINT msg,
1456 WPARAM wParam, LPARAM lParam )
1458 HWND hWnd = lphc->self->hwndSelf;
1460 TRACE("[%04x]: ownerdraw op %04x\n", CB_HWND(lphc), msg );
1462 #define lpIS ((LPDELETEITEMSTRUCT)lParam)
1464 /* two first items are the same in all 4 structs */
1465 lpIS->CtlType = ODT_COMBOBOX;
1466 lpIS->CtlID = lphc->self->wIDmenu;
1468 switch( msg ) /* patch window handle */
1470 case WM_DELETEITEM:
1471 lpIS->hwndItem = hWnd;
1472 #undef lpIS
1473 break;
1474 case WM_DRAWITEM:
1475 #define lpIS ((LPDRAWITEMSTRUCT)lParam)
1476 lpIS->hwndItem = hWnd;
1477 #undef lpIS
1478 break;
1479 case WM_COMPAREITEM:
1480 #define lpIS ((LPCOMPAREITEMSTRUCT)lParam)
1481 lpIS->hwndItem = hWnd;
1482 #undef lpIS
1483 break;
1486 return SendMessageA( lphc->owner, msg, lphc->self->wIDmenu, lParam );
1489 /***********************************************************************
1490 * COMBO_GetText
1492 static LRESULT COMBO_GetText( LPHEADCOMBO lphc, UINT N, LPSTR lpText)
1494 if( lphc->wState & CBF_EDIT )
1495 return SendMessageA( lphc->hWndEdit, WM_GETTEXT,
1496 (WPARAM)N, (LPARAM)lpText );
1498 /* get it from the listbox */
1500 if( lphc->hWndLBox )
1502 INT idx = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1503 if( idx != LB_ERR )
1505 LPSTR lpBuffer;
1506 INT length = SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN,
1507 (WPARAM)idx, 0 );
1509 /* 'length' is without the terminating character */
1510 if( length >= N )
1511 lpBuffer = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1 );
1512 else
1513 lpBuffer = lpText;
1515 if( lpBuffer )
1517 INT n = SendMessageA( lphc->hWndLBox, LB_GETTEXT,
1518 (WPARAM)idx, (LPARAM)lpBuffer );
1520 /* truncate if buffer is too short */
1522 if( length >= N )
1524 if (N && lpText) {
1525 if( n != LB_ERR ) memcpy( lpText, lpBuffer, (N>n) ? n+1 : N-1 );
1526 lpText[N - 1] = '\0';
1528 HeapFree( GetProcessHeap(), 0, lpBuffer );
1530 return (LRESULT)n;
1534 return 0;
1538 /***********************************************************************
1539 * CBResetPos
1541 * This function sets window positions according to the updated
1542 * component placement struct.
1544 static void CBResetPos(
1545 LPHEADCOMBO lphc,
1546 LPRECT rectEdit,
1547 LPRECT rectLB,
1548 BOOL bRedraw)
1550 BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE);
1552 /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of
1553 * sizing messages */
1555 if( lphc->wState & CBF_EDIT )
1556 SetWindowPos( lphc->hWndEdit, 0,
1557 rectEdit->left, rectEdit->top,
1558 rectEdit->right - rectEdit->left,
1559 rectEdit->bottom - rectEdit->top,
1560 SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) );
1562 SetWindowPos( lphc->hWndLBox, 0,
1563 rectLB->left, rectLB->top,
1564 rectLB->right - rectLB->left,
1565 rectLB->bottom - rectLB->top,
1566 SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) );
1568 if( bDrop )
1570 if( lphc->wState & CBF_DROPPED )
1572 lphc->wState &= ~CBF_DROPPED;
1573 ShowWindow( lphc->hWndLBox, SW_HIDE );
1576 if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
1577 RedrawWindow( lphc->self->hwndSelf, NULL, 0,
1578 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
1583 /***********************************************************************
1584 * COMBO_Size
1586 static void COMBO_Size( LPHEADCOMBO lphc )
1588 CBCalcPlacement(lphc->self->hwndSelf,
1589 lphc,
1590 &lphc->textRect,
1591 &lphc->buttonRect,
1592 &lphc->droppedRect);
1594 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1598 /***********************************************************************
1599 * COMBO_Font
1601 static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw )
1604 * Set the font
1606 lphc->hFont = hFont;
1609 * Propagate to owned windows.
1611 if( lphc->wState & CBF_EDIT )
1612 SendMessageA( lphc->hWndEdit, WM_SETFONT, (WPARAM)hFont, bRedraw );
1613 SendMessageA( lphc->hWndLBox, WM_SETFONT, (WPARAM)hFont, bRedraw );
1616 * Redo the layout of the control.
1618 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1620 CBCalcPlacement(lphc->self->hwndSelf,
1621 lphc,
1622 &lphc->textRect,
1623 &lphc->buttonRect,
1624 &lphc->droppedRect);
1626 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1628 else
1630 CBForceDummyResize(lphc);
1635 /***********************************************************************
1636 * COMBO_SetItemHeight
1638 static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height )
1640 LRESULT lRet = CB_ERR;
1642 if( index == -1 ) /* set text field height */
1644 if( height < 32768 )
1646 lphc->editHeight = height;
1649 * Redo the layout of the control.
1651 if ( CB_GETTYPE(lphc) == CBS_SIMPLE)
1653 CBCalcPlacement(lphc->self->hwndSelf,
1654 lphc,
1655 &lphc->textRect,
1656 &lphc->buttonRect,
1657 &lphc->droppedRect);
1659 CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE );
1661 else
1663 CBForceDummyResize(lphc);
1666 lRet = height;
1669 else if ( CB_OWNERDRAWN(lphc) ) /* set listbox item height */
1670 lRet = SendMessageA( lphc->hWndLBox, LB_SETITEMHEIGHT,
1671 (WPARAM)index, (LPARAM)height );
1672 return lRet;
1675 /***********************************************************************
1676 * COMBO_SelectString
1678 static LRESULT COMBO_SelectString( LPHEADCOMBO lphc, INT start, LPCSTR pText )
1680 INT index = SendMessageA( lphc->hWndLBox, LB_SELECTSTRING,
1681 (WPARAM)start, (LPARAM)pText );
1682 if( index >= 0 )
1684 if( lphc->wState & CBF_EDIT )
1685 CBUpdateEdit( lphc, index );
1686 else
1688 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
1691 return (LRESULT)index;
1694 /***********************************************************************
1695 * COMBO_LButtonDown
1697 static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam )
1699 POINT pt;
1700 BOOL bButton;
1701 HWND hWnd = lphc->self->hwndSelf;
1703 pt.x = LOWORD(lParam);
1704 pt.y = HIWORD(lParam);
1705 bButton = PtInRect(&lphc->buttonRect, pt);
1707 if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
1708 (bButton && (CB_GETTYPE(lphc) == CBS_DROPDOWN)) )
1710 lphc->wState |= CBF_BUTTONDOWN;
1711 if( lphc->wState & CBF_DROPPED )
1713 /* got a click to cancel selection */
1715 lphc->wState &= ~CBF_BUTTONDOWN;
1716 CBRollUp( lphc, TRUE, FALSE );
1717 if( !IsWindow( hWnd ) ) return;
1719 if( lphc->wState & CBF_CAPTURE )
1721 lphc->wState &= ~CBF_CAPTURE;
1722 ReleaseCapture();
1725 else
1727 /* drop down the listbox and start tracking */
1729 lphc->wState |= CBF_CAPTURE;
1730 CBDropDown( lphc );
1731 SetCapture( hWnd );
1733 if( bButton ) CBRepaintButton( lphc );
1737 /***********************************************************************
1738 * COMBO_LButtonUp
1740 * Release capture and stop tracking if needed.
1742 static void COMBO_LButtonUp( LPHEADCOMBO lphc, LPARAM lParam )
1744 if( lphc->wState & CBF_CAPTURE )
1746 lphc->wState &= ~CBF_CAPTURE;
1747 if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
1749 INT index = CBUpdateLBox( lphc );
1750 CBUpdateEdit( lphc, index );
1752 ReleaseCapture();
1753 SetCapture(lphc->hWndLBox);
1757 if( lphc->wState & CBF_BUTTONDOWN )
1759 lphc->wState &= ~CBF_BUTTONDOWN;
1760 CBRepaintButton( lphc );
1764 /***********************************************************************
1765 * COMBO_MouseMove
1767 * Two things to do - track combo button and release capture when
1768 * pointer goes into the listbox.
1770 static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam )
1772 POINT pt;
1773 RECT lbRect;
1775 pt.x = LOWORD(lParam);
1776 pt.y = HIWORD(lParam);
1778 if( lphc->wState & CBF_BUTTONDOWN )
1780 BOOL bButton;
1782 bButton = PtInRect(&lphc->buttonRect, pt);
1784 if( !bButton )
1786 lphc->wState &= ~CBF_BUTTONDOWN;
1787 CBRepaintButton( lphc );
1791 GetClientRect( lphc->hWndLBox, &lbRect );
1792 MapWindowPoints( lphc->self->hwndSelf, lphc->hWndLBox, &pt, 1 );
1793 if( PtInRect(&lbRect, pt) )
1795 lphc->wState &= ~CBF_CAPTURE;
1796 ReleaseCapture();
1797 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) CBUpdateLBox( lphc );
1799 /* hand over pointer tracking */
1800 SendMessageA( lphc->hWndLBox, WM_LBUTTONDOWN, wParam, lParam );
1805 /***********************************************************************
1806 * ComboWndProc_locked
1808 * http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/ctrl/src/combobox_15.htm
1810 static inline LRESULT WINAPI ComboWndProc_locked( WND* pWnd, UINT message,
1811 WPARAM wParam, LPARAM lParam )
1813 if( pWnd ) {
1814 LPHEADCOMBO lphc = CB_GETPTR(pWnd);
1815 HWND hwnd = pWnd->hwndSelf;
1817 TRACE("[%04x]: msg %s wp %08x lp %08lx\n",
1818 pWnd->hwndSelf, SPY_GetMsgName(message), wParam, lParam );
1820 if( lphc || message == WM_NCCREATE )
1821 switch(message)
1824 /* System messages */
1826 case WM_NCCREATE:
1827 return COMBO_NCCreate(pWnd, lParam);
1828 case WM_NCDESTROY:
1829 COMBO_NCDestroy(lphc);
1830 break;/* -> DefWindowProc */
1832 case WM_CREATE:
1833 return COMBO_Create(lphc, pWnd, lParam);
1835 case WM_PRINTCLIENT:
1836 if (lParam & PRF_ERASEBKGND)
1837 COMBO_EraseBackground(hwnd, lphc, wParam);
1839 /* Fallthrough */
1840 case WM_PAINT:
1841 /* wParam may contain a valid HDC! */
1842 return COMBO_Paint(lphc, wParam);
1843 case WM_ERASEBKGND:
1844 return COMBO_EraseBackground(hwnd, lphc, wParam);
1845 case WM_GETDLGCODE:
1846 return (LRESULT)(DLGC_WANTARROWS | DLGC_WANTCHARS);
1847 case WM_WINDOWPOSCHANGING:
1848 return COMBO_WindowPosChanging(hwnd, lphc, (LPWINDOWPOS)lParam);
1849 case WM_SIZE:
1850 if( lphc->hWndLBox &&
1851 !(lphc->wState & CBF_NORESIZE) ) COMBO_Size( lphc );
1852 return TRUE;
1853 case WM_SETFONT:
1854 COMBO_Font( lphc, (HFONT16)wParam, (BOOL)lParam );
1855 return TRUE;
1856 case WM_GETFONT:
1857 return (LRESULT)lphc->hFont;
1858 case WM_SETFOCUS:
1859 if( lphc->wState & CBF_EDIT )
1860 SetFocus( lphc->hWndEdit );
1861 else
1862 COMBO_SetFocus( lphc );
1863 return TRUE;
1864 case WM_KILLFOCUS:
1865 #define hwndFocus ((HWND16)wParam)
1866 if( !hwndFocus ||
1867 (hwndFocus != lphc->hWndEdit && hwndFocus != lphc->hWndLBox ))
1868 COMBO_KillFocus( lphc );
1869 #undef hwndFocus
1870 return TRUE;
1871 case WM_COMMAND:
1872 return COMBO_Command( lphc, wParam, (HWND)lParam );
1873 case WM_GETTEXT:
1874 return COMBO_GetText( lphc, (UINT)wParam, (LPSTR)lParam );
1875 case WM_SETTEXT:
1876 case WM_GETTEXTLENGTH:
1877 case WM_CLEAR:
1878 case WM_CUT:
1879 case WM_PASTE:
1880 case WM_COPY:
1881 if ((message == WM_GETTEXTLENGTH) && !ISWIN31 && !(lphc->wState & CBF_EDIT))
1883 int j = SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0 );
1884 if (j == -1) return 0;
1885 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, j, 0);
1887 else if( lphc->wState & CBF_EDIT )
1889 lphc->wState |= CBF_NOEDITNOTIFY;
1891 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1893 else return CB_ERR;
1895 case WM_DRAWITEM:
1896 case WM_DELETEITEM:
1897 case WM_COMPAREITEM:
1898 case WM_MEASUREITEM:
1899 return COMBO_ItemOp( lphc, message, wParam, lParam );
1900 case WM_ENABLE:
1901 if( lphc->wState & CBF_EDIT )
1902 EnableWindow( lphc->hWndEdit, (BOOL)wParam );
1903 EnableWindow( lphc->hWndLBox, (BOOL)wParam );
1905 /* Force the control to repaint when the enabled state changes. */
1906 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
1907 return TRUE;
1908 case WM_SETREDRAW:
1909 if( wParam )
1910 lphc->wState &= ~CBF_NOREDRAW;
1911 else
1912 lphc->wState |= CBF_NOREDRAW;
1914 if( lphc->wState & CBF_EDIT )
1915 SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1916 SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1917 return 0;
1918 case WM_SYSKEYDOWN:
1919 if( KEYDATA_ALT & HIWORD(lParam) )
1920 if( wParam == VK_UP || wParam == VK_DOWN )
1921 COMBO_FlipListbox( lphc, TRUE );
1922 break;/* -> DefWindowProc */
1924 case WM_CHAR:
1925 case WM_KEYDOWN:
1926 if( lphc->wState & CBF_EDIT )
1927 return SendMessageA( lphc->hWndEdit, message, wParam, lParam );
1928 else
1929 return SendMessageA( lphc->hWndLBox, message, wParam, lParam );
1930 case WM_LBUTTONDOWN:
1931 if( !(lphc->wState & CBF_FOCUSED) ) SetFocus( lphc->self->hwndSelf );
1932 if( lphc->wState & CBF_FOCUSED ) COMBO_LButtonDown( lphc, lParam );
1933 return TRUE;
1934 case WM_LBUTTONUP:
1935 COMBO_LButtonUp( lphc, lParam );
1936 return TRUE;
1937 case WM_MOUSEMOVE:
1938 if( lphc->wState & CBF_CAPTURE )
1939 COMBO_MouseMove( lphc, wParam, lParam );
1940 return TRUE;
1941 /* Combo messages */
1943 case CB_ADDSTRING16:
1944 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1945 case CB_ADDSTRING:
1946 return SendMessageA( lphc->hWndLBox, LB_ADDSTRING, 0, lParam);
1947 case CB_INSERTSTRING16:
1948 wParam = (INT)(INT16)wParam;
1949 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1950 case CB_INSERTSTRING:
1951 return SendMessageA( lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam);
1952 case CB_DELETESTRING16:
1953 case CB_DELETESTRING:
1954 return SendMessageA( lphc->hWndLBox, LB_DELETESTRING, wParam, 0);
1955 case CB_SELECTSTRING16:
1956 wParam = (INT)(INT16)wParam;
1957 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1958 case CB_SELECTSTRING:
1959 return COMBO_SelectString( lphc, (INT)wParam, (LPSTR)lParam );
1960 case CB_FINDSTRING16:
1961 wParam = (INT)(INT16)wParam;
1962 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1963 case CB_FINDSTRING:
1964 return SendMessageA( lphc->hWndLBox, LB_FINDSTRING, wParam, lParam);
1965 case CB_FINDSTRINGEXACT16:
1966 wParam = (INT)(INT16)wParam;
1967 if( CB_HASSTRINGS(lphc) ) lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
1968 case CB_FINDSTRINGEXACT:
1969 return SendMessageA( lphc->hWndLBox, LB_FINDSTRINGEXACT,
1970 wParam, lParam );
1971 case CB_SETITEMHEIGHT16:
1972 wParam = (INT)(INT16)wParam; /* signed integer */
1973 case CB_SETITEMHEIGHT:
1974 return COMBO_SetItemHeight( lphc, (INT)wParam, (INT)lParam);
1975 case CB_GETITEMHEIGHT16:
1976 wParam = (INT)(INT16)wParam;
1977 case CB_GETITEMHEIGHT:
1978 if( (INT)wParam >= 0 ) /* listbox item */
1979 return SendMessageA( lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0);
1980 return CBGetTextAreaHeight(hwnd, lphc);
1981 case CB_RESETCONTENT16:
1982 case CB_RESETCONTENT:
1983 SendMessageA( lphc->hWndLBox, LB_RESETCONTENT, 0, 0 );
1984 InvalidateRect(CB_HWND(lphc), NULL, TRUE);
1985 return TRUE;
1986 case CB_INITSTORAGE:
1987 return SendMessageA( lphc->hWndLBox, LB_INITSTORAGE, wParam, lParam);
1988 case CB_GETHORIZONTALEXTENT:
1989 return SendMessageA( lphc->hWndLBox, LB_GETHORIZONTALEXTENT, 0, 0);
1990 case CB_SETHORIZONTALEXTENT:
1991 return SendMessageA( lphc->hWndLBox, LB_SETHORIZONTALEXTENT, wParam, 0);
1992 case CB_GETTOPINDEX:
1993 return SendMessageA( lphc->hWndLBox, LB_GETTOPINDEX, 0, 0);
1994 case CB_GETLOCALE:
1995 return SendMessageA( lphc->hWndLBox, LB_GETLOCALE, 0, 0);
1996 case CB_SETLOCALE:
1997 return SendMessageA( lphc->hWndLBox, LB_SETLOCALE, wParam, 0);
1998 case CB_GETDROPPEDWIDTH:
1999 if( lphc->droppedWidth )
2000 return lphc->droppedWidth;
2001 return lphc->droppedRect.right - lphc->droppedRect.left;
2002 case CB_SETDROPPEDWIDTH:
2003 if( (CB_GETTYPE(lphc) != CBS_SIMPLE) &&
2004 (INT)wParam < 32768 ) lphc->droppedWidth = (INT)wParam;
2005 return CB_ERR;
2006 case CB_GETDROPPEDCONTROLRECT16:
2007 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2008 if( lParam )
2010 RECT r;
2011 CBGetDroppedControlRect( lphc, &r );
2012 CONV_RECT32TO16( &r, (LPRECT16)lParam );
2014 return CB_OKAY;
2015 case CB_GETDROPPEDCONTROLRECT:
2016 if( lParam ) CBGetDroppedControlRect(lphc, (LPRECT)lParam );
2017 return CB_OKAY;
2018 case CB_GETDROPPEDSTATE16:
2019 case CB_GETDROPPEDSTATE:
2020 return (lphc->wState & CBF_DROPPED) ? TRUE : FALSE;
2021 case CB_DIR16:
2022 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2023 /* fall through */
2024 case CB_DIR:
2025 return COMBO_Directory( lphc, (UINT)wParam,
2026 (LPSTR)lParam, (message == CB_DIR));
2027 case CB_SHOWDROPDOWN16:
2028 case CB_SHOWDROPDOWN:
2029 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
2031 if( wParam )
2033 if( !(lphc->wState & CBF_DROPPED) )
2034 CBDropDown( lphc );
2036 else
2037 if( lphc->wState & CBF_DROPPED )
2038 CBRollUp( lphc, FALSE, TRUE );
2040 return TRUE;
2041 case CB_GETCOUNT16:
2042 case CB_GETCOUNT:
2043 return SendMessageA( lphc->hWndLBox, LB_GETCOUNT, 0, 0);
2044 case CB_GETCURSEL16:
2045 case CB_GETCURSEL:
2046 return SendMessageA( lphc->hWndLBox, LB_GETCURSEL, 0, 0);
2047 case CB_SETCURSEL16:
2048 wParam = (INT)(INT16)wParam;
2049 case CB_SETCURSEL:
2050 lParam = SendMessageA( lphc->hWndLBox, LB_SETCURSEL, wParam, 0);
2051 if( lphc->wState & CBF_SELCHANGE )
2053 /* no LBN_SELCHANGE in this case, update manually */
2054 if( lphc->wState & CBF_EDIT )
2055 CBUpdateEdit( lphc, (INT)wParam );
2056 else
2057 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
2058 lphc->wState &= ~CBF_SELCHANGE;
2060 return lParam;
2061 case CB_GETLBTEXT16:
2062 wParam = (INT)(INT16)wParam;
2063 lParam = (LPARAM)PTR_SEG_TO_LIN(lParam);
2064 case CB_GETLBTEXT:
2065 return SendMessageA( lphc->hWndLBox, LB_GETTEXT, wParam, lParam);
2066 case CB_GETLBTEXTLEN16:
2067 wParam = (INT)(INT16)wParam;
2068 case CB_GETLBTEXTLEN:
2069 return SendMessageA( lphc->hWndLBox, LB_GETTEXTLEN, wParam, 0);
2070 case CB_GETITEMDATA16:
2071 wParam = (INT)(INT16)wParam;
2072 case CB_GETITEMDATA:
2073 return SendMessageA( lphc->hWndLBox, LB_GETITEMDATA, wParam, 0);
2074 case CB_SETITEMDATA16:
2075 wParam = (INT)(INT16)wParam;
2076 case CB_SETITEMDATA:
2077 return SendMessageA( lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam);
2078 case CB_GETEDITSEL16:
2079 wParam = lParam = 0; /* just in case */
2080 case CB_GETEDITSEL:
2081 if( lphc->wState & CBF_EDIT )
2083 INT a, b;
2085 return SendMessageA( lphc->hWndEdit, EM_GETSEL,
2086 (wParam) ? wParam : (WPARAM)&a,
2087 (lParam) ? lParam : (LPARAM)&b );
2089 return CB_ERR;
2090 case CB_SETEDITSEL16:
2091 case CB_SETEDITSEL:
2092 if( lphc->wState & CBF_EDIT )
2093 return SendMessageA( lphc->hWndEdit, EM_SETSEL,
2094 (INT)(INT16)LOWORD(lParam), (INT)(INT16)HIWORD(lParam) );
2095 return CB_ERR;
2096 case CB_SETEXTENDEDUI16:
2097 case CB_SETEXTENDEDUI:
2098 if( CB_GETTYPE(lphc) == CBS_SIMPLE )
2099 return CB_ERR;
2100 if( wParam )
2101 lphc->wState |= CBF_EUI;
2102 else lphc->wState &= ~CBF_EUI;
2103 return CB_OKAY;
2104 case CB_GETEXTENDEDUI16:
2105 case CB_GETEXTENDEDUI:
2106 return (lphc->wState & CBF_EUI) ? TRUE : FALSE;
2108 default:
2109 if (message >= WM_USER)
2110 WARN("unknown msg WM_USER+%04x wp=%04x lp=%08lx\n",
2111 message - WM_USER, wParam, lParam );
2112 break;
2114 return DefWindowProcA(hwnd, message, wParam, lParam);
2116 return CB_ERR;
2119 /***********************************************************************
2120 * ComboWndProc
2122 * This is just a wrapper for the real ComboWndProc which locks/unlocks
2123 * window structs.
2125 LRESULT WINAPI ComboWndProc( HWND hwnd, UINT message,
2126 WPARAM wParam, LPARAM lParam )
2128 WND* pWnd = WIN_FindWndPtr(hwnd);
2129 LRESULT retvalue = ComboWndProc_locked(pWnd,message,wParam,lParam);
2132 WIN_ReleaseWndPtr(pWnd);
2133 return retvalue;