3 * 1. The following extended styles need to be implemented, use will
5 * CBES_EX_NOEDITIMAGEINDENT
6 * CBES_EX_PATHWORDBREAKPROC
8 * CBES_EX_CASESENSITIVE
9 * 2. None of the following callback items are implemented. Therefor
10 * no CBEN_GETDISPINFO notifies are issued. Use in either CBEM_INSERTITEM
11 * or CBEM_SETITEM will result in a FIXME:
15 * 3. No use is made of the iOverlay image.
16 * 4. Notify CBEN_DRAGBEGIN is not implemented.
21 * ComboBoxEx control v2 (mod4)
23 * Copyright 1998, 1999 Eric Kohl
26 * This is just a dummy control. An author is needed! Any volunteers?
27 * I will only improve this control once in a while.
28 * Eric <ekohl@abo.rhein-zeitung.de>
31 * Changes Guy Albertelli <galberte@neo.lrun.com>
32 * v1 Implemented messages: CB_SETITEMHEIGHT, WM_WINDOWPOSCHANGING,
33 * WM_DRAWITEM, and WM_MEASUREITEM. Fixed WM_CREATE. Fixed height
34 * of window rect reported fixing rebar control.
36 * 1. Rewrite of WM_Create for own created EDIT control. Also try to
37 * generate message sequence similar to native DLL.
38 * 2. Handle case where CBEM_SETITEM is called to display data in EDIT
40 * 3. Add override for WNDPROC for the EDIT control (reqed for VK_RETURN).
41 * 4. Dump input data for things using COMBOBOXEXITEM{A|W}.
42 * 5. Handle positioning EDIT control based on whether icon present.
43 * 6. Make InsertItemA use InsertItemW, and store all data in ..W form.
44 * 7. Implement CBEM_DELETEITEM, CBEM_GETITEM{A|W}, CB_SETCURSEL,
45 * CBEM_{GET|SET}UNICODEFORMAT.
46 * 8. Add override for WNDPROC for the COMBO control.
47 * 9. Support extended style CBES_EX_NOEDITIMAGE and warn others are not
49 * 10. Implement CB_FINDSTRINGEXACT in both the Combo and ComboEx window
50 * procs to match the items. This eliminates dup entries in the listbox.
53 * 1. Implemented CBN_SELCHANGE, CBN_KILLFOCUS, and CBN_SELENDOK.
54 * 2. Fix putting text in CBEN_ENDEDIT notifys for CBN_DROPDOWN case.
55 * 3. Lock image selected status to focus state of edit control if
56 * edit control exists. Mimics native actions.
57 * 4. Implemented WM_SETFOCUS in EditWndProc to track status of
59 * 5. The LBN_SELCHANGE is just for documentation purposes.
61 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe),
68 #include "debugtools.h"
69 #include "wine/unicode.h"
71 DEFAULT_DEBUG_CHANNEL(comboex);
73 * The following is necessary for the test done in COMBOEX_DrawItem
74 * to determine whether to dump out the DRAWITEM structure or not.
76 DECLARE_DEBUG_CHANNEL(message);
92 /* ComboBoxEx structure */
96 HWND hwndSelf; /* my own hwnd */
99 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */
100 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */
102 DWORD flags; /* WINE internal flags */
104 INT nb_items; /* Number of items */
105 BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
106 CBE_ITEMDATA *edit; /* item data for edit item */
107 CBE_ITEMDATA *items; /* Array of items */
110 /* internal flags in the COMBOEX_INFO structure */
111 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e.
112 * CBEN_BEGINEDIT issued
113 * but CBEN_ENDEDIT{A|W}
115 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */
116 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */
119 #define ID_CB_EDIT 1001
123 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
124 * the ComboEx version of the Combo Window Proc so that when the
125 * WM_DRAWITEM message is then passed to ComboEx, we know that this
126 * particular WM_DRAWITEM message is for listbox only items. Any messasges
127 * without this flag is then for the Edit control field.
129 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
130 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
132 #define ODS_COMBOEXLBOX 0x4000
136 /* Height in pixels of control over the amount of the selected font */
139 /* Indent amount per MS documentation */
140 #define CBE_INDENT 10
142 /* Offset in pixels from left side for start of image or text */
143 #define CBE_STARTOFFSET 6
145 /* Offset between image and text */
148 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
151 /* Things common to the entire DLL */
152 static ATOM ComboExInfo;
153 static LRESULT WINAPI
154 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
155 static LRESULT WINAPI
156 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
159 COMBOEX_DumpItem (CBE_ITEMDATA *item)
161 if (TRACE_ON(comboex)){
162 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
163 item, item->mask, item->pszText, item->cchTextMax,
165 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
166 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
167 if ((item->mask & CBEIF_TEXT) && item->pszText)
168 TRACE("item %p - pszText=%s\n",
169 item, debugstr_w((const WCHAR *)item->pszText));
175 COMBOEX_DumpInput (COMBOBOXEXITEMA *input, BOOL true_for_w)
177 if (TRACE_ON(comboex)){
178 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
179 input->mask, input->iItem, input->pszText, input->cchTextMax,
181 if ((input->mask & CBEIF_TEXT) && input->pszText) {
183 TRACE("input - pszText=<%s>\n",
184 debugstr_w((const WCHAR *)input->pszText));
186 TRACE("input - pszText=<%s>\n",
187 debugstr_a((const char *)input->pszText));
189 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
190 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
195 inline static LRESULT
196 COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
198 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
200 if (infoPtr->hwndCombo)
201 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
208 COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr, BOOL doW)
211 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
212 hdr->hwndFrom = infoPtr->hwndSelf;
215 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
218 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
224 COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
229 mydc = GetDC (0); /* why the entire screen???? */
230 nfont = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
231 ofont = (HFONT) SelectObject (mydc, nfont);
232 GetTextExtentPointA (mydc, "A", 1, size);
233 SelectObject (mydc, ofont);
235 TRACE("selected font hwnd=%08x, height=%ld\n", nfont, size->cy);
240 COMBOEX_CopyItem (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
242 if (cit->mask & CBEIF_TEXT) {
243 cit->pszText = item->pszText;
244 cit->cchTextMax = item->cchTextMax;
246 if (cit->mask & CBEIF_IMAGE)
247 cit->iImage = item->iImage;
248 if (cit->mask & CBEIF_SELECTEDIMAGE)
249 cit->iSelectedImage = item->iSelectedImage;
250 if (cit->mask & CBEIF_OVERLAY)
251 cit->iOverlay = item->iOverlay;
252 if (cit->mask & CBEIF_INDENT)
253 cit->iIndent = item->iIndent;
254 if (cit->mask & CBEIF_LPARAM)
255 cit->lParam = item->lParam;
261 COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
265 INT x, y, w, h, xoff = 0;
268 if (!infoPtr->hwndEdit) return;
269 iinfo.rcImage.left = iinfo.rcImage.right = 0;
271 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
272 xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
274 GetClientRect (infoPtr->hwndCombo, &rect);
275 InflateRect (&rect, -2, -2);
276 InvalidateRect (infoPtr->hwndCombo, &rect, TRUE);
278 /* reposition the Edit control based on whether icon exists */
279 COMBOEX_GetComboFontSize (infoPtr, &mysize);
280 TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy);
281 x = xoff + CBE_STARTOFFSET + 1;
283 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
286 TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n",
287 rect.left, rect.top, rect.right, rect.bottom,
289 SetWindowPos(infoPtr->hwndEdit, HWND_TOP,
292 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
297 COMBOEX_ReSize (HWND hwnd, COMBOEX_INFO *infoPtr)
303 COMBOEX_GetComboFontSize (infoPtr, &mysize);
304 cy = mysize.cy + CBE_EXTRA;
306 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
307 cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
308 TRACE("upgraded height due to image: height=%d\n", cy);
310 SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
311 if (infoPtr->hwndCombo)
312 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
313 (WPARAM) 0, (LPARAM) cy);
318 COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
320 if (!infoPtr->hwndEdit) return;
321 /* native issues the following messages to the {Edit} control */
322 /* WM_SETTEXT (0,addr) */
323 /* EM_SETSEL32 (0,0) */
324 /* EM_SETSEL32 (0,-1) */
325 if (item->mask & CBEIF_TEXT) {
326 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
327 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
328 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
333 static CBE_ITEMDATA *
334 COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
339 if ((index > infoPtr->nb_items) || (index < -1))
342 return infoPtr->edit;
343 item = infoPtr->items;
344 i = infoPtr->nb_items - 1;
346 /* find the item in the list */
347 while (item && (i > index)) {
348 item = (CBE_ITEMDATA *)item->next;
351 if (!item || (i != index)) {
352 FIXME("COMBOBOXEX item structures broken. Please report!\n");
360 COMBOEX_WarnCallBack (CBE_ITEMDATA *item)
362 if (item->pszText == LPSTR_TEXTCALLBACKW)
363 FIXME("Callback not implemented yet for pszText\n");
364 if (item->iImage == I_IMAGECALLBACK)
365 FIXME("Callback not implemented yet for iImage\n");
366 if (item->iSelectedImage == I_IMAGECALLBACK)
367 FIXME("Callback not implemented yet for iSelectedImage\n");
368 if (item->iOverlay == I_IMAGECALLBACK)
369 FIXME("Callback not implemented yet for iOverlay\n");
370 if (item->iIndent == I_INDENTCALLBACK)
371 FIXME("Callback not implemented yet for iIndent\n");
375 /* *** CBEM_xxx message support *** */
379 COMBOEX_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
381 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
382 INT index = (INT) wParam;
385 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
387 /* if item number requested does not exist then return failure */
388 if ((index > infoPtr->nb_items) || (index < 0)) {
389 ERR("attempt to delete item that does not exist\n");
393 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
394 ERR("attempt to delete item that was not found!\n");
398 /* doing this will result in WM_DELETEITEM being issued */
399 SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0);
401 return infoPtr->nb_items;
405 inline static LRESULT
406 COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
408 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
412 return (LRESULT)infoPtr->hwndCombo;
416 inline static LRESULT
417 COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
419 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
421 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
424 TRACE("-- 0x%x\n", infoPtr->hwndEdit);
426 return (LRESULT)infoPtr->hwndEdit;
430 inline static LRESULT
431 COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
433 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
435 TRACE("-- 0x%08lx\n", infoPtr->dwExtStyle);
437 return (LRESULT)infoPtr->dwExtStyle;
441 inline static LRESULT
442 COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
444 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
446 TRACE("-- 0x%p\n", infoPtr->himl);
448 return (LRESULT)infoPtr->himl;
453 COMBOEX_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
455 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
456 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
460 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
462 /* get real index of item to insert */
465 /* if item number requested does not exist then return failure */
466 if ((index > infoPtr->nb_items) || (index < -1)) {
467 ERR("attempt to get item that does not exist\n");
471 /* if the item is the edit control and there is no edit control, skip */
473 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
476 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
477 ERR("attempt to get item that was not found!\n");
481 COMBOEX_CopyItem (infoPtr, item, cit);
487 inline static LRESULT
488 COMBOEX_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
490 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
491 COMBOBOXEXITEMW tmpcit;
494 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
496 tmpcit.mask = cit->mask;
497 tmpcit.iItem = cit->iItem;
498 COMBOEX_GetItemW (hwnd, wParam, (LPARAM) &tmpcit);
500 len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL);
502 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
503 cit->pszText, cit->cchTextMax, NULL, NULL);
505 cit->iImage = tmpcit.iImage;
506 cit->iSelectedImage = tmpcit.iSelectedImage;
507 cit->iOverlay = tmpcit.iOverlay;
508 cit->iIndent = tmpcit.iIndent;
509 cit->lParam = tmpcit.lParam;
515 inline static LRESULT
516 COMBOEX_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
518 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
520 TRACE("%s hwnd=0x%x stub!\n",
521 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
523 return infoPtr->bUnicode;
527 inline static LRESULT
528 COMBOEX_HasEditChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
530 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
532 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
534 if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) ==
535 (WCBE_ACTEDIT | WCBE_EDITCHG))
542 COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
544 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
545 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
552 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
554 /* get real index of item to insert */
556 if (index == -1) index = infoPtr->nb_items;
557 if (index > infoPtr->nb_items) index = infoPtr->nb_items;
559 /* get space and chain it in */
560 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
562 item->pszText = NULL;
564 /* locate position to insert new item in */
565 if (index == infoPtr->nb_items) {
566 /* fast path for iItem = -1 */
567 item->next = infoPtr->items;
568 infoPtr->items = item;
571 INT i = infoPtr->nb_items-1;
572 CBE_ITEMDATA *moving = infoPtr->items;
574 while ((i > index) && moving) {
575 moving = (CBE_ITEMDATA *)moving->next;
579 FIXME("COMBOBOXEX item structures broken. Please report!\n");
583 item->next = moving->next;
587 /* fill in our hidden item structure */
588 item->mask = cit->mask;
589 if (item->mask & CBEIF_TEXT) {
594 if (!str) str = (LPWSTR) L"";
597 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
598 strcpyW (item->pszText, str);
600 item->cchTextMax = cit->cchTextMax;
602 if (item->mask & CBEIF_IMAGE)
603 item->iImage = cit->iImage;
604 if (item->mask & CBEIF_SELECTEDIMAGE)
605 item->iSelectedImage = cit->iSelectedImage;
606 if (item->mask & CBEIF_OVERLAY)
607 item->iOverlay = cit->iOverlay;
608 if (item->mask & CBEIF_INDENT)
609 item->iIndent = cit->iIndent;
610 if (item->mask & CBEIF_LPARAM)
611 item->lParam = cit->lParam;
614 COMBOEX_WarnCallBack (item);
616 COMBOEX_DumpItem (item);
618 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
619 (WPARAM)cit->iItem, (LPARAM)item);
621 COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
622 COMBOEX_Notify (infoPtr, CBEN_INSERTITEM, (NMHDR *)&nmcit, TRUE);
630 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
632 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
633 COMBOBOXEXITEMW citW;
636 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
637 if (cit->mask & CBEIF_TEXT) {
643 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
645 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
646 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
649 ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);;
651 if (cit->mask & CBEIF_TEXT)
652 COMCTL32_Free(citW.pszText);
658 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
660 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
663 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
665 dwTemp = infoPtr->dwExtStyle;
667 if (lParam & (CBES_EX_NOEDITIMAGEINDENT |
668 CBES_EX_PATHWORDBREAKPROC |
669 CBES_EX_NOSIZELIMIT |
670 CBES_EX_CASESENSITIVE))
671 FIXME("Extended style not implemented %08lx\n", lParam);
674 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
677 infoPtr->dwExtStyle = (DWORD)lParam;
680 * native does this for CBES_EX_NOEDITIMAGE state change
682 if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^
683 (dwTemp & CBES_EX_NOEDITIMAGE)) {
684 /* if state of EX_NOEDITIMAGE changes, invalidate all */
685 TRACE("EX_NOEDITIMAGE state changed to %ld\n",
686 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
687 InvalidateRect (hwnd, NULL, TRUE);
688 COMBOEX_AdjustEditPos (infoPtr);
689 if (infoPtr->hwndEdit)
690 InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
693 return (LRESULT)dwTemp;
697 inline static LRESULT
698 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
700 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
703 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
705 himlTemp = infoPtr->himl;
706 infoPtr->himl = (HIMAGELIST)lParam;
708 COMBOEX_ReSize (hwnd, infoPtr);
709 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
711 /* reposition the Edit control based on whether icon exists */
712 COMBOEX_AdjustEditPos (infoPtr);
713 return (LRESULT)himlTemp;
717 COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
719 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
720 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
724 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
726 /* get real index of item to insert */
729 /* if item number requested does not exist then return failure */
730 if ((index > infoPtr->nb_items) || (index < -1)) {
731 ERR("attempt to set item that does not exist yet!\n");
735 /* if the item is the edit control and there is no edit control, skip */
737 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
740 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
741 ERR("attempt to set item that was not found!\n");
745 /* add/change stuff to the internal item structure */
746 item->mask |= cit->mask;
747 if (cit->mask & CBEIF_TEXT) {
750 WCHAR emptystr[1] = {0};
753 if (!str) str=emptystr;
756 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
757 strcpyW(item->pszText,str);
759 item->cchTextMax = cit->cchTextMax;
761 if (cit->mask & CBEIF_IMAGE)
762 item->iImage = cit->iImage;
763 if (cit->mask & CBEIF_SELECTEDIMAGE)
764 item->iSelectedImage = cit->iSelectedImage;
765 if (cit->mask & CBEIF_OVERLAY)
766 item->iOverlay = cit->iOverlay;
767 if (cit->mask & CBEIF_INDENT)
768 item->iIndent = cit->iIndent;
769 if (cit->mask & CBEIF_LPARAM)
770 cit->lParam = cit->lParam;
772 COMBOEX_WarnCallBack (item);
774 COMBOEX_DumpItem (item);
776 /* if original request was to update edit control, do some fast foot work */
777 if (cit->iItem == -1) {
778 COMBOEX_SetEditText (infoPtr, item);
779 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
785 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
787 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
788 COMBOBOXEXITEMW citW;
791 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
792 if (cit->mask & CBEIF_TEXT) {
798 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
800 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
801 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
804 ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
806 if (cit->mask & CBEIF_TEXT)
807 COMCTL32_Free(citW.pszText);
812 inline static LRESULT
813 COMBOEX_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
815 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
818 TRACE("%s hwnd=0x%04x stub!\n",
819 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
821 bTemp = infoPtr->bUnicode;
822 infoPtr->bUnicode = (BOOL)wParam;
829 /* *** CB_xxx message support *** */
833 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
837 LPWSTR desired = NULL;
838 INT start = (INT) wParam;
840 i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
842 desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
843 MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
846 count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0 , 0);
848 /* now search from after starting loc and wrapping back to start */
849 for(i=start+1; i<count; i++) {
850 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
851 CB_GETITEMDATA, (WPARAM)i, 0);
852 TRACE("desired=%s, item=%s\n",
853 debugstr_w(desired), debugstr_w(item->pszText));
854 if (lstrcmpiW(item->pszText, desired) == 0) {
855 COMCTL32_Free (desired);
859 for(i=0; i<=start; i++) {
860 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
861 CB_GETITEMDATA, (WPARAM)i, 0);
862 TRACE("desired=%s, item=%s\n",
863 debugstr_w(desired), debugstr_w(item->pszText));
864 if (lstrcmpiW(item->pszText, desired) == 0) {
865 COMCTL32_Free (desired);
869 COMCTL32_Free(desired);
875 COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam)
878 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
882 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
883 /* FIXME: need to clear selection */
887 TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
888 debugstr_w(item->pszText) : "<null>");
890 lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam);
891 COMBOEX_SetEditText (infoPtr, item);
897 COMBOEX_SetItemHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
899 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
900 RECT cb_wrect, cbx_wrect, cbx_crect;
904 /* First, lets forward the message to the normal combo control
905 just like Windows. */
906 if (infoPtr->hwndCombo)
907 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
909 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
910 GetWindowRect (hwnd, &cbx_wrect);
911 GetClientRect (hwnd, &cbx_crect);
912 /* the height of comboex as height of the combo + comboex border */
913 height = cb_wrect.bottom-cb_wrect.top
914 + cbx_wrect.bottom-cbx_wrect.top
915 - (cbx_crect.bottom-cbx_crect.top);
916 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
917 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
918 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
919 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
920 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
921 cbx_wrect.right-cbx_wrect.left, height);
922 SetWindowPos (hwnd, HWND_TOP, 0, 0,
923 cbx_wrect.right-cbx_wrect.left,
925 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
931 /* *** WM_xxx message support *** */
935 COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
937 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
938 COMBOEX_INFO *infoPtr;
942 RECT wnrc1, clrc1, cmbwrc;
945 /* allocate memory for info structure */
946 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
947 if (infoPtr == NULL) {
948 ERR("could not allocate info memory!\n");
952 /* initialize info structure */
954 infoPtr->items = NULL;
955 infoPtr->nb_items = 0;
956 infoPtr->hwndSelf = hwnd;
958 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
960 /* create combo box */
961 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
962 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
964 TRACE("combo style=%08lx, additional style=%08lx\n", dwComboStyle,
965 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
966 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
967 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
969 /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
970 /* specified. It then creates it's own version of the EDIT control */
971 /* and makes the ComboBox the parent. This is because a normal */
972 /* DROPDOWNLIST does not have a EDIT control, but we need one. */
973 /* We also need to place the edit control at the proper location */
974 /* (allow space for the icons). */
976 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
977 /* following line added to match native */
978 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
979 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
980 /* was base and is necessary */
981 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
982 cs->y, cs->x, cs->cx, cs->cy, hwnd,
983 (HMENU) GetWindowLongA (hwnd, GWL_ID),
984 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
987 * native does the following at this point according to trace:
988 * GetWindowThreadProcessId(hwndCombo,0)
989 * GetCurrentThreadId()
990 * GetWindowThreadProcessId(hwndCombo, &???)
991 * GetCurrentProcessId()
995 * Setup a property to hold the pointer to the COMBOBOXEX
998 test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo);
999 if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
1000 SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
1002 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo,
1003 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
1004 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1008 * Now create our own EDIT control so we can position it.
1009 * It is created only for CBS_DROPDOWN style
1011 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
1012 infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
1013 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
1014 0, 0, 0, 0, /* will set later */
1016 (HMENU) GetWindowLongA (hwnd, GWL_ID),
1017 GetWindowLongA (hwnd, GWL_HINSTANCE),
1020 /* native does the following at this point according to trace:
1021 * GetWindowThreadProcessId(hwndEdit,0)
1022 * GetCurrentThreadId()
1023 * GetWindowThreadProcessId(hwndEdit, &???)
1024 * GetCurrentProcessId()
1028 * Setup a property to hold the pointer to the COMBOBOXEX
1031 test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
1032 if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
1033 SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
1035 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
1036 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
1037 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1040 infoPtr->hwndEdit = 0;
1045 * Locate the default font if necessary and then set it in
1046 * all associated controls
1048 if (!infoPtr->font) {
1049 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
1051 infoPtr->font = CreateFontIndirectA (&mylogfont);
1053 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1054 if (infoPtr->hwndEdit) {
1055 SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1056 SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
1059 COMBOEX_ReSize (hwnd, infoPtr);
1061 /* Above is fairly certain, below is much less certain. */
1063 GetWindowRect(hwnd, &wnrc1);
1064 GetClientRect(hwnd, &clrc1);
1065 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1066 TRACE("Ex wnd=(%d,%d)-(%d,%d) Ex clt=(%d,%d)-(%d,%d) Cb wnd=(%d,%d)-(%d,%d)\n",
1067 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
1068 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
1069 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1070 SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
1071 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
1072 SWP_NOACTIVATE | SWP_NOREDRAW);
1074 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1075 TRACE("Ex wnd=(%d,%d)-(%d,%d)\n",
1076 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1077 SetWindowPos(hwnd, HWND_TOP,
1078 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
1079 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
1081 COMBOEX_AdjustEditPos (infoPtr);
1084 * Create an item structure to represent the data in the
1087 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
1089 item->pszText = NULL;
1091 infoPtr->edit = item;
1097 inline static LRESULT
1098 COMBOEX_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
1101 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1102 INT command = HIWORD(wParam);
1103 CBE_ITEMDATA *item = 0;
1105 INT cursel, n, oldItem;
1106 NMCBEENDEDITA cbeend;
1108 TRACE("for command %d\n", command);
1113 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1116 * from native trace of first dropdown after typing in URL in IE4
1117 * CB_GETCURSEL(Combo)
1118 * GetWindowText(Edit)
1119 * CB_GETCURSEL(Combo)
1120 * CB_GETCOUNT(Combo)
1121 * CB_GETITEMDATA(Combo, n)
1122 * WM_NOTIFY(parent, CBEN_ENDEDITA|W)
1123 * CB_GETCURSEL(Combo)
1124 * CB_SETCURSEL(COMBOEX, n)
1126 * the rest is supposition
1128 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1130 /* find match from edit against those in Combobox */
1131 GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
1132 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
1133 for (cursel = 0; cursel < n; cursel++){
1134 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1137 if ((INT)item == CB_ERR) break;
1138 if (lstrcmpiW(item->pszText, wintext) == 0) break;
1140 if ((cursel == n) || ((INT)item == CB_ERR)) {
1141 TRACE("failed to find match??? item=%p cursel=%d\n",
1143 if (infoPtr->hwndEdit)
1144 SetFocus(infoPtr->hwndEdit);
1149 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1152 if ((INT)item == CB_ERR) {
1153 TRACE("failed to find match??? item=%p cursel=%d\n",
1155 if (infoPtr->hwndEdit)
1156 SetFocus(infoPtr->hwndEdit);
1160 if (infoPtr->flags & WCBE_ACTEDIT) {
1161 WideCharToMultiByte (CP_ACP, 0, item->pszText, -1,
1162 cbeend.szText, sizeof(cbeend.szText),
1164 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1165 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1166 CB_GETCURSEL, 0, 0);
1167 cbeend.iWhy = CBENF_DROPDOWN;
1169 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1170 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1171 (NMHDR *)&cbeend, FALSE)) {
1172 /* abort the change */
1173 TRACE("Notify requested abort of change\n");
1177 SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
1178 SetFocus(infoPtr->hwndCombo);
1183 * CB_GETCURSEL(Combo)
1184 * CB_GETITEMDATA(Combo) < simulated by COMBOEX_FindItem
1187 * WM_GETTEXTLENGTH(Edit)
1189 * EM_SETSEL(Edit, 0,0)
1190 * WM_GETTEXTLENGTH(Edit)
1192 * EM_SETSEL(Edit, 0,len)
1193 * return WM_COMMAND to parent
1195 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1196 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1197 ERR("item %d not found. Problem!\n", oldItem);
1200 COMBOEX_SetEditText (infoPtr, item);
1201 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1206 * We have to change the handle since we are the control
1207 * issuing the message. IE4 depends on this.
1209 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1214 * from native trace:
1217 * WM_GETTEXT(Edit, 104)
1218 * CB_GETCURSEL(Combo) rets -1
1219 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1220 * CB_GETCURSEL(Combo)
1221 * InvalidateRect(Combo, 0, 0)
1224 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1226 if (infoPtr->flags & WCBE_ACTEDIT) {
1227 GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
1228 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1229 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1230 CB_GETCURSEL, 0, 0);
1231 cbeend.iWhy = CBENF_KILLFOCUS;
1233 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1234 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1235 (NMHDR *)&cbeend, FALSE)) {
1236 /* abort the change */
1237 TRACE("Notify requested abort of change\n");
1241 /* possible CB_GETCURSEL */
1242 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1248 * We have to change the handle since we are the control
1249 * issuing the message. IE4 depends on this.
1250 * We also need to set the focus back to the Edit control
1251 * after passing the command to the parent of the ComboEx.
1253 lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1255 if (infoPtr->hwndEdit)
1256 SetFocus(infoPtr->hwndEdit);
1263 inline static LRESULT
1264 COMBOEX_WM_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1266 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1267 DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)lParam;
1268 CBE_ITEMDATA *item, *olditem;
1270 NMCOMBOBOXEXW nmcit;
1272 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
1273 dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
1275 if ((dis->itemID >= infoPtr->nb_items) || (dis->itemID < 0)) return FALSE;
1277 olditem = infoPtr->items;
1278 i = infoPtr->nb_items - 1;
1280 if (i == dis->itemID) {
1281 infoPtr->items = infoPtr->items->next;
1287 /* find the prior item in the list */
1288 while (item->next && (i > dis->itemID)) {
1289 item = (CBE_ITEMDATA *)item->next;
1292 if (!item->next || (i != dis->itemID)) {
1293 FIXME("COMBOBOXEX item structures broken. Please report!\n");
1296 olditem = item->next;
1297 item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
1299 infoPtr->nb_items--;
1301 COMBOEX_CopyItem (infoPtr, olditem, &nmcit.ceItem);
1302 COMBOEX_Notify (infoPtr, CBEN_DELETEITEM, (NMHDR *)&nmcit, TRUE);
1304 COMCTL32_Free(olditem);
1311 inline static LRESULT
1312 COMBOEX_DrawItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1314 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1315 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
1316 CBE_ITEMDATA *item = 0;
1319 int drawimage, drawstate;
1321 UINT xioff = 0; /* size and spacer of image if any */
1325 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
1328 /* "itemID - Specifies the menu item identifier for a menu */
1329 /* item or the index of the item in a list box or combo box. */
1330 /* For an empty list box or combo box, this member can be -1. */
1331 /* This allows the application to draw only the focus */
1332 /* rectangle at the coordinates specified by the rcItem */
1333 /* member even though there are no items in the control. */
1334 /* This indicates to the user whether the list box or combo */
1335 /* box has the focus. How the bits are set in the itemAction */
1336 /* member determines whether the rectangle is to be drawn as */
1337 /* though the list box or combo box has the focus. */
1338 if (dis->itemID == 0xffffffff) {
1339 if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
1340 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
1342 TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
1343 dis->rcItem.left, dis->rcItem.top,
1344 dis->rcItem.right, dis->rcItem.bottom);
1346 else if ((dis->CtlType == ODT_COMBOBOX) &&
1347 (dis->itemAction == ODA_DRAWENTIRE)) {
1348 /* draw of edit control data */
1352 RECT exrc, cbrc, edrc;
1353 GetWindowRect (hwnd, &exrc);
1354 GetWindowRect (infoPtr->hwndCombo, &cbrc);
1355 edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
1356 if (infoPtr->hwndEdit)
1357 GetWindowRect (infoPtr->hwndEdit, &edrc);
1358 TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
1359 exrc.left, exrc.top, exrc.right, exrc.bottom,
1360 cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
1361 edrc.left, edrc.top, edrc.right, edrc.bottom);
1365 ERR("NOT drawing item -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
1366 dis->rcItem.left, dis->rcItem.top,
1367 dis->rcItem.right, dis->rcItem.bottom,
1368 dis->itemAction, dis->itemState);
1373 /* If draw item is -1 (edit control) setup the item pointer */
1374 if (dis->itemID == 0xffffffff) {
1378 if (!infoPtr->hwndEdit) {
1379 ERR("request to draw edit item, but no edit control exists!\n");
1383 item = infoPtr->edit;
1384 /* free previous text of edit item */
1385 if (item->pszText) {
1386 COMCTL32_Free(item->pszText);
1388 item->mask &= ~CBEIF_TEXT;
1390 alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
1391 TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
1392 infoPtr->hwndEdit, alen, str);
1394 item->mask |= CBEIF_TEXT;
1395 wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
1397 item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
1398 MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
1403 /* if the item pointer is not set, then get the data and locate it */
1405 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1406 CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
1407 if (item == (CBE_ITEMDATA *)CB_ERR)
1409 FIXME("invalid item for id %d \n",dis->itemID);
1414 /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
1415 if (!TRACE_ON(message)) {
1416 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
1417 dis->CtlType, dis->CtlID);
1418 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
1419 dis->itemID, dis->itemAction, dis->itemState);
1420 TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
1421 dis->hwndItem, dis->hDC, dis->rcItem.left,
1422 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
1425 COMBOEX_DumpItem (item);
1427 xbase = CBE_STARTOFFSET;
1428 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX))
1429 xbase += (item->iIndent * CBE_INDENT);
1430 if (item->mask & CBEIF_IMAGE) {
1431 ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
1432 xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
1435 switch (dis->itemAction) {
1437 if (dis->itemState & ODS_SELECTED /*1*/) {
1438 if ((item->mask & CBEIF_TEXT) && item->pszText) {
1441 len = strlenW (item->pszText);
1442 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
1443 rect.left = xbase + xioff - 1;
1444 rect.right = rect.left + txtsize.cx + 2;
1445 rect.top = dis->rcItem.top;
1446 rect.bottom = dis->rcItem.bottom;
1447 GetClipBox (dis->hDC, &rect2);
1448 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
1449 dis->itemID, rect.left, rect.top,
1450 rect.right, rect.bottom);
1451 TRACE(" clip=(%d,%d)-(%d,%d)\n",
1452 rect2.left, rect2.top,
1453 rect2.right, rect2.bottom);
1455 DrawFocusRect(dis->hDC, &rect);
1458 FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
1462 FIXME("ODA_FOCUS but not ODS_SELECTED\n");
1466 case ODA_DRAWENTIRE:
1468 drawstate = ILD_NORMAL;
1469 if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
1470 if (item->mask & CBEIF_IMAGE)
1471 drawimage = item->iImage;
1472 if (dis->itemState & ODS_COMBOEXLBOX) {
1473 /* drawing listbox entry */
1474 if (dis->itemState & ODS_SELECTED) {
1475 if (item->mask & CBEIF_SELECTEDIMAGE)
1476 drawimage = item->iSelectedImage;
1477 drawstate = ILD_SELECTED;
1481 /* drawing combo/edit entry */
1482 if (infoPtr->hwndEdit) {
1483 /* if we have an edit control, the slave the
1484 * selection state to the Edit focus state
1486 if (infoPtr->flags & WCBE_EDITFOCUSED) {
1487 if (item->mask & CBEIF_SELECTEDIMAGE)
1488 drawimage = item->iSelectedImage;
1489 drawstate = ILD_SELECTED;
1493 /* if we don't have an edit control, use
1494 * the requested state.
1496 if (dis->itemState & ODS_SELECTED) {
1497 if (item->mask & CBEIF_SELECTEDIMAGE)
1498 drawimage = item->iSelectedImage;
1499 drawstate = ILD_SELECTED;
1504 if (drawimage != -1) {
1505 TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
1506 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
1507 xbase, dis->rcItem.top, drawstate);
1509 if ((item->mask & CBEIF_TEXT) && item->pszText) {
1511 COLORREF nbkc, ntxc;
1513 len = lstrlenW (item->pszText);
1514 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
1515 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1516 COLOR_HIGHLIGHT : COLOR_WINDOW);
1517 SetBkColor (dis->hDC, nbkc);
1518 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1519 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
1520 SetTextColor (dis->hDC, ntxc);
1522 y = dis->rcItem.top +
1523 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
1525 rect.right = x + txtsize.cx;
1526 rect.top = dis->rcItem.top + 1;
1527 rect.bottom = dis->rcItem.bottom - 1;
1528 TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
1529 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1530 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
1531 &rect, item->pszText, len, 0);
1532 if (dis->itemState & ODS_FOCUS) {
1537 TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
1538 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1539 DrawFocusRect (dis->hDC, &rect);
1544 FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
1545 hwnd, wParam, lParam, dis->itemAction);
1553 COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1555 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1557 if (infoPtr->hwndCombo)
1558 DestroyWindow (infoPtr->hwndCombo);
1560 if (infoPtr->edit) {
1561 COMCTL32_Free (infoPtr->edit);
1565 if (infoPtr->items) {
1566 CBE_ITEMDATA *this, *next;
1568 this = infoPtr->items;
1570 next = (CBE_ITEMDATA *)this->next;
1571 if ((this->mask & CBEIF_TEXT) && this->pszText)
1572 COMCTL32_Free (this->pszText);
1573 COMCTL32_Free (this);
1578 DeleteObject (infoPtr->font);
1580 /* free comboex info data */
1581 COMCTL32_Free (infoPtr);
1582 SetWindowLongA (hwnd, 0, 0);
1588 COMBOEX_MeasureItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1590 /*COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);*/
1591 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
1596 GetTextExtentPointA (hdc, "W", 1, &mysize);
1598 mis->itemHeight = mysize.cy + CBE_EXTRA;
1600 TRACE("adjusted height hwnd=%08x, height=%d\n",
1601 hwnd, mis->itemHeight);
1608 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1610 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1613 GetWindowRect (hwnd, &rect);
1614 TRACE("my rect (%d,%d)-(%d,%d)\n",
1615 rect.left, rect.top, rect.right, rect.bottom);
1617 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
1618 rect.bottom - rect.top, TRUE);
1620 COMBOEX_AdjustEditPos (infoPtr);
1627 COMBOEX_WindowPosChanging (HWND hwnd, WPARAM wParam, LPARAM lParam)
1629 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1631 RECT cbx_wrect, cbx_crect, cb_wrect;
1633 WINDOWPOS *wp = (WINDOWPOS *)lParam;
1635 ret = DefWindowProcA (hwnd, WM_WINDOWPOSCHANGING, wParam, lParam);
1636 GetWindowRect (hwnd, &cbx_wrect);
1637 GetClientRect (hwnd, &cbx_crect);
1638 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1640 /* width is winpos value + border width of comboex */
1642 + (cbx_wrect.right-cbx_wrect.left)
1643 - (cbx_crect.right-cbx_crect.left);
1645 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
1646 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
1647 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
1648 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
1649 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
1650 width, cb_wrect.bottom-cb_wrect.top);
1652 if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
1654 cb_wrect.bottom-cb_wrect.top,
1657 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1659 /* height is combo window height plus border width of comboex */
1660 height = (cb_wrect.bottom-cb_wrect.top)
1661 + (cbx_wrect.bottom-cbx_wrect.top)
1662 - (cbx_crect.bottom-cbx_crect.top);
1663 if (wp->cy < height) wp->cy = height;
1664 if (infoPtr->hwndEdit) {
1665 COMBOEX_AdjustEditPos (infoPtr);
1666 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1673 static LRESULT WINAPI
1674 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1676 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
1677 NMCBEENDEDITA cbeend;
1678 COLORREF nbkc, obkc;
1683 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1684 hwnd, uMsg, wParam, lParam, infoPtr);
1686 if (!infoPtr) return 0;
1692 /* handle (ignore) the return character */
1693 if (wParam == VK_RETURN) return 0;
1694 /* all other characters pass into the real Edit */
1695 return CallWindowProcA (infoPtr->prevEditWndProc,
1696 hwnd, uMsg, wParam, lParam);
1700 * The following was determined by traces of the native
1703 nbkc = GetSysColor (COLOR_WINDOW);
1704 obkc = SetBkColor (hDC, nbkc);
1705 GetClientRect (hwnd, &rect);
1706 TRACE("erasing (%d,%d)-(%d,%d)\n",
1707 rect.left, rect.top, rect.right, rect.bottom);
1708 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1709 SetBkColor (hDC, obkc);
1710 return CallWindowProcA (infoPtr->prevEditWndProc,
1711 hwnd, uMsg, wParam, lParam);
1714 INT oldItem, selected;
1716 WCHAR edit_text[260];
1718 switch ((INT)wParam)
1721 /* native version seems to do following for COMBOEX */
1723 * GetWindowTextA(Edit,&?, 0x104) x
1724 * CB_GETCURSEL to Combo rets -1 x
1725 * WM_NOTIFY to COMBOEX parent (rebar) x
1726 * (CBEN_ENDEDIT{A|W}
1727 * fChanged = FALSE x
1728 * inewSelection = -1 x
1731 * CB_GETCURSEL to Combo rets -1 x
1732 * InvalidateRect(Combo, 0) x
1733 * WM_SETTEXT to Edit x
1734 * EM_SETSEL to Edit (0,0) x
1735 * EM_SETSEL to Edit (0,-1) x
1736 * RedrawWindow(Combo, 0, 0, 5) x
1738 TRACE("special code for VK_ESCAPE\n");
1740 GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
1742 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1743 cbeend.fChanged = FALSE;
1744 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1745 CB_GETCURSEL, 0, 0);
1746 cbeend.iWhy = CBENF_ESCAPE;
1748 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1749 (NMHDR *)&cbeend, FALSE)) {
1750 /* abort the change */
1751 TRACE("Notify requested abort of change\n");
1754 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1755 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1756 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1757 ERR("item %d not found. Problem!\n", oldItem);
1761 COMBOEX_SetEditText (infoPtr, item);
1762 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1767 /* native version seems to do following for COMBOEX */
1769 * GetWindowTextA(Edit,&?, 0x104) x
1770 * CB_GETCURSEL to Combo rets -1 x
1771 * CB_GETCOUNT to Combo rets 0
1773 * CB_GETITEMDATA to match
1774 * *** above 3 lines simulated by FindItem x
1775 * WM_NOTIFY to COMBOEX parent (rebar) x
1776 * (CBEN_ENDEDIT{A|W} x
1777 * fChanged = TRUE (-1) x
1778 * iNewSelection = -1 or selected x
1780 * iWhy = 2 (CBENF_RETURN) x
1781 * CB_GETCURSEL to Combo rets -1 x
1782 * if -1 send CB_SETCURSEL to Combo -1 x
1783 * InvalidateRect(Combo, 0, 0) x
1785 * CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
1788 TRACE("special code for VK_RETURN\n");
1790 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1792 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1793 selected = SendMessageW (infoPtr->hwndCombo,
1794 CB_GETCURSEL, 0, 0);
1796 if (selected != -1) {
1797 item = COMBOEX_FindItem (infoPtr, selected);
1798 TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
1799 selected, debugstr_w(item->pszText));
1800 TRACE("handling VK_RETURN, edittext=%s\n",
1801 debugstr_w(edit_text));
1802 if (lstrcmpiW (item->pszText, edit_text)) {
1803 /* strings not equal -- indicate edit has changed */
1808 cbeend.iNewSelection = selected;
1809 cbeend.fChanged = TRUE;
1810 cbeend.iWhy = CBENF_RETURN;
1811 WideCharToMultiByte (CP_ACP, 0, edit_text, -1,
1812 cbeend.szText, sizeof(cbeend.szText),
1815 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1816 (NMHDR *)&cbeend, FALSE)) {
1817 /* abort the change, restore previous */
1818 TRACE("Notify requested abort of change\n");
1819 COMBOEX_SetEditText (infoPtr, infoPtr->edit);
1820 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1824 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1825 if (oldItem != -1) {
1826 /* if something is selected, then deselect it */
1827 SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
1830 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1831 SetFocus(infoPtr->hwndEdit);
1835 return CallWindowProcA (infoPtr->prevEditWndProc,
1836 hwnd, uMsg, wParam, lParam);
1842 /* remember the focus to set state of icon */
1843 lret = CallWindowProcA (infoPtr->prevEditWndProc,
1844 hwnd, uMsg, wParam, lParam);
1845 infoPtr->flags |= WCBE_EDITFOCUSED;
1850 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
1852 infoPtr->flags &= ~WCBE_EDITFOCUSED;
1853 if (infoPtr->flags & WCBE_ACTEDIT) {
1854 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1855 cbeend.fChanged = FALSE;
1856 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1857 CB_GETCURSEL, 0, 0);
1858 cbeend.iWhy = CBENF_KILLFOCUS;
1860 COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1861 (NMHDR *)&cbeend, FALSE);
1866 return CallWindowProcA (infoPtr->prevEditWndProc,
1867 hwnd, uMsg, wParam, lParam);
1873 static LRESULT WINAPI
1874 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1876 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
1877 NMCBEENDEDITA cbeend;
1879 COLORREF nbkc, obkc;
1884 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1885 hwnd, uMsg, wParam, lParam, infoPtr);
1887 if (!infoPtr) return 0;
1892 case CB_FINDSTRINGEXACT:
1893 return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
1897 * The only way this message should come is from the
1898 * child Listbox issuing the message. Flag this so
1899 * that ComboEx knows this is listbox.
1901 ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
1902 return CallWindowProcA (infoPtr->prevComboWndProc,
1903 hwnd, uMsg, wParam, lParam);
1907 * The following was determined by traces of the native
1910 nbkc = GetSysColor (COLOR_WINDOW);
1911 obkc = SetBkColor (hDC, nbkc);
1912 GetClientRect (hwnd, &rect);
1913 TRACE("erasing (%d,%d)-(%d,%d)\n",
1914 rect.left, rect.top, rect.right, rect.bottom);
1915 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1916 SetBkColor (hDC, obkc);
1917 return CallWindowProcA (infoPtr->prevComboWndProc,
1918 hwnd, uMsg, wParam, lParam);
1922 * WM_NOTIFY to comboex parent (rebar)
1923 * with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
1924 * CallWindowProc (previous)
1926 nmmse.dwItemSpec = 0;
1927 nmmse.dwItemData = 0;
1930 nmmse.dwHitInfo = lParam;
1931 COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse, FALSE);
1932 return CallWindowProcA (infoPtr->prevComboWndProc,
1933 hwnd, uMsg, wParam, lParam);
1936 switch (HIWORD(wParam)) {
1939 /* traces show that COMBOEX does not issue CBN_EDITUPDATE
1948 * GetFocus() retns AA
1949 * GetWindowTextA(Edit)
1950 * CB_GETCURSEL(Combo) (got -1)
1951 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1952 * CB_GETCURSEL(Combo) (got -1)
1953 * InvalidateRect(Combo, 0, 0)
1954 * WM_KILLFOCUS(Combo, AA)
1957 focusedhwnd = GetFocus();
1958 if (infoPtr->flags & WCBE_ACTEDIT) {
1959 GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
1960 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1961 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1962 CB_GETCURSEL, 0, 0);
1963 cbeend.iWhy = CBENF_KILLFOCUS;
1965 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1966 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1967 (NMHDR *)&cbeend, FALSE)) {
1968 /* abort the change */
1969 TRACE("Notify requested abort of change\n");
1973 /* possible CB_GETCURSEL */
1974 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1976 SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
1977 (WPARAM)focusedhwnd, 0);
1982 * For EN_SETFOCUS this issues the same calls and messages
1983 * as the native seems to do.
1985 * for some cases however native does the following:
1986 * (noticed after SetFocus during LBUTTONDOWN on
1987 * on dropdown arrow)
1988 * WM_GETTEXTLENGTH (Edit);
1989 * WM_GETTEXT (Edit, len+1, str);
1990 * EM_SETSEL (Edit, 0, 0);
1991 * WM_GETTEXTLENGTH (Edit);
1992 * WM_GETTEXT (Edit, len+1, str);
1993 * EM_SETSEL (Edit, 0, len);
1994 * WM_NOTIFY (parent, CBEN_BEGINEDIT)
1998 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
1999 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
2000 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr, FALSE);
2001 infoPtr->flags |= WCBE_ACTEDIT;
2002 infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
2008 * For EN_CHANGE this issues the same calls and messages
2009 * as the native seems to do.
2011 WCHAR edit_text[260];
2016 selected = SendMessageW (infoPtr->hwndCombo,
2017 CB_GETCURSEL, 0, 0);
2019 /* lstrlenA( lastworkingURL ) */
2021 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2022 if (selected == -1) {
2023 lastwrk = infoPtr->edit->pszText;
2024 cnt = lstrlenW (lastwrk);
2025 if (cnt >= 259) cnt = 259;
2028 item = COMBOEX_FindItem (infoPtr, selected);
2029 cnt = lstrlenW (item->pszText);
2030 lastwrk = item->pszText;
2031 if (cnt >= 259) cnt = 259;
2034 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
2035 selected, debugstr_w(lastwrk));
2036 TRACE("handling EN_CHANGE, edittext=%s\n",
2037 debugstr_w(edit_text));
2039 /* lstrcmpiW is between lastworkingURL and GetWindowText */
2041 if (lstrcmpiW (lastwrk, edit_text)) {
2042 /* strings not equal -- indicate edit has changed */
2043 infoPtr->flags |= WCBE_EDITCHG;
2045 SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
2046 MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
2054 * Therefore from traces there is no additional code here
2058 * Using native COMCTL32 gets the following:
2059 * 1 == SHDOCVW.DLL issues call/message
2060 * 2 == COMCTL32.DLL issues call/message
2061 * 3 == WINE issues call/message
2064 * for LBN_SELCHANGE:
2065 * 1 CB_GETCURSEL(ComboEx)
2066 * 1 CB_GETDROPPEDSTATE(ComboEx)
2067 * 1 CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
2068 * 2 CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
2069 ** call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
2070 * 3 WM_COMMAND(ComboEx, CBN_SELENDOK)
2071 * WM_USER+49(ComboLB, 1,0) <=============!!!!!!!!!!!
2072 * 3 ShowWindow(ComboLB, SW_HIDE)
2073 * 3 RedrawWindow(Combo, RDW_UPDATENOW)
2074 * 3 WM_COMMAND(ComboEX, CBN_CLOSEUP)
2076 * 3 WM_COMMAND(ComboEx, CBN_SELCHANGE) (echo to parent)
2077 * ? LB_GETCURSEL <==|
2079 * ? LB_GETTEXT | Needs to be added to
2080 * ? WM_CTLCOLOREDIT(ComboEx) | Combo processing
2081 * ? LB_GETITEMDATA |
2082 * ? WM_DRAWITEM(ComboEx) <==|
2088 return CallWindowProcA (infoPtr->prevComboWndProc,
2089 hwnd, uMsg, wParam, lParam);
2095 static LRESULT WINAPI
2096 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2098 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2099 if (!COMBOEX_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
2100 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2104 case CBEM_DELETEITEM: /* maps to CB_DELETESTRING */
2105 return COMBOEX_DeleteItem (hwnd, wParam, lParam);
2107 case CBEM_GETCOMBOCONTROL:
2108 return COMBOEX_GetComboControl (hwnd, wParam, lParam);
2110 case CBEM_GETEDITCONTROL:
2111 return COMBOEX_GetEditControl (hwnd, wParam, lParam);
2113 case CBEM_GETEXTENDEDSTYLE:
2114 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
2116 case CBEM_GETIMAGELIST:
2117 return COMBOEX_GetImageList (hwnd, wParam, lParam);
2120 return COMBOEX_GetItemA (hwnd, wParam, lParam);
2123 return COMBOEX_GetItemW (hwnd, wParam, lParam);
2125 case CBEM_GETUNICODEFORMAT:
2126 return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
2128 case CBEM_HASEDITCHANGED:
2129 return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
2131 case CBEM_INSERTITEMA:
2132 return COMBOEX_InsertItemA (hwnd, wParam, lParam);
2134 case CBEM_INSERTITEMW:
2135 return COMBOEX_InsertItemW (hwnd, wParam, lParam);
2137 case CBEM_SETEXSTYLE: /* FIXME: obsoleted, should be the same as: */
2138 case CBEM_SETEXTENDEDSTYLE:
2139 return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
2141 case CBEM_SETIMAGELIST:
2142 return COMBOEX_SetImageList (hwnd, wParam, lParam);
2145 return COMBOEX_SetItemA (hwnd, wParam, lParam);
2148 return COMBOEX_SetItemW (hwnd, wParam, lParam);
2150 case CBEM_SETUNICODEFORMAT:
2151 return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
2154 /* Combo messages we are not sure if we need to process or just forward */
2155 case CB_GETDROPPEDCONTROLRECT:
2156 case CB_GETITEMDATA:
2157 case CB_GETITEMHEIGHT:
2159 case CB_GETLBTEXTLEN:
2160 case CB_GETEXTENDEDUI:
2162 case CB_RESETCONTENT:
2163 case CB_SELECTSTRING:
2164 case CB_SETITEMDATA:
2167 FIXME("(0x%x 0x%x 0x%lx): possible missing fucntion\n",
2168 uMsg, wParam, lParam);
2169 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
2171 /* Combo messages OK to just forward to the regular COMBO */
2174 case CB_GETDROPPEDSTATE:
2175 case CB_SETDROPPEDWIDTH:
2176 case CB_SETEXTENDEDUI:
2177 case CB_SHOWDROPDOWN:
2178 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
2180 /* Combo messages we need to process specially */
2181 case CB_FINDSTRINGEXACT:
2182 return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
2186 return COMBOEX_SetCursel (hwnd, wParam, lParam);
2188 case CB_SETITEMHEIGHT:
2189 return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
2193 /* Window messages passed to parent */
2195 return COMBOEX_Command (hwnd, wParam, lParam);
2198 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2201 /* Window messages we need to process */
2203 return COMBOEX_Create (hwnd, wParam, lParam);
2206 return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
2209 return COMBOEX_DrawItem (hwnd, wParam, lParam);
2212 return COMBOEX_Destroy (hwnd, wParam, lParam);
2214 case WM_MEASUREITEM:
2215 return COMBOEX_MeasureItem (hwnd, wParam, lParam);
2218 return COMBOEX_Size (hwnd, wParam, lParam);
2220 case WM_WINDOWPOSCHANGING:
2221 return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
2224 if (uMsg >= WM_USER)
2225 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2226 uMsg, wParam, lParam);
2227 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2234 COMBOEX_Register (void)
2238 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2239 wndClass.style = CS_GLOBALCLASS;
2240 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
2241 wndClass.cbClsExtra = 0;
2242 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
2243 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
2244 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2245 wndClass.lpszClassName = WC_COMBOBOXEXA;
2247 RegisterClassA (&wndClass);
2249 ComboExInfo = GlobalAddAtomA("CC32SubclassInfo");
2254 COMBOEX_Unregister (void)
2256 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);