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 (mod5)
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.
62 * 1. Add support for CB_GETITEMDATA to a Comboex. Returns the LPARAM
63 * passed during insert of item.
64 * 2. Remember selected item and don't issue CB_SETCURSEL unless needed.
65 * 3. Add initial support for WM_NCCREATE to remove unwanted window styles
66 * (Currently just WS_VSCROLL and WS_HSCROLL, but probably should be
68 * 4. Improve some traces.
69 * 5. Add support for CB_SETITEMDATA sets LPARAM value from item.
71 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe),
79 #include "debugtools.h"
80 #include "wine/unicode.h"
82 DEFAULT_DEBUG_CHANNEL(comboex);
84 * The following is necessary for the test done in COMBOEX_DrawItem
85 * to determine whether to dump out the DRAWITEM structure or not.
87 DECLARE_DEBUG_CHANNEL(message);
103 /* ComboBoxEx structure */
107 HWND hwndSelf; /* my own hwnd */
110 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */
111 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */
113 INT selected; /* index of selected item */
114 DWORD flags; /* WINE internal flags */
116 INT nb_items; /* Number of items */
117 BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
118 CBE_ITEMDATA *edit; /* item data for edit item */
119 CBE_ITEMDATA *items; /* Array of items */
122 /* internal flags in the COMBOEX_INFO structure */
123 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e.
124 * CBEN_BEGINEDIT issued
125 * but CBEN_ENDEDIT{A|W}
127 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */
128 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */
131 #define ID_CB_EDIT 1001
135 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
136 * the ComboEx version of the Combo Window Proc so that when the
137 * WM_DRAWITEM message is then passed to ComboEx, we know that this
138 * particular WM_DRAWITEM message is for listbox only items. Any messasges
139 * without this flag is then for the Edit control field.
141 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
142 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
144 #define ODS_COMBOEXLBOX 0x4000
148 /* Height in pixels of control over the amount of the selected font */
151 /* Indent amount per MS documentation */
152 #define CBE_INDENT 10
154 /* Offset in pixels from left side for start of image or text */
155 #define CBE_STARTOFFSET 6
157 /* Offset between image and text */
160 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
163 /* Things common to the entire DLL */
164 static ATOM ComboExInfo;
165 static LRESULT WINAPI
166 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
167 static LRESULT WINAPI
168 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
171 COMBOEX_DumpItem (CBE_ITEMDATA *item)
173 if (TRACE_ON(comboex)){
174 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
175 item, item->mask, item->pszText, item->cchTextMax,
177 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
178 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
179 if ((item->mask & CBEIF_TEXT) && item->pszText)
180 TRACE("item %p - pszText=%s\n",
181 item, debugstr_w((const WCHAR *)item->pszText));
187 COMBOEX_DumpInput (COMBOBOXEXITEMA *input, BOOL true_for_w)
189 if (TRACE_ON(comboex)){
190 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
191 input->mask, input->iItem, input->pszText, input->cchTextMax,
193 if ((input->mask & CBEIF_TEXT) && input->pszText) {
195 TRACE("input - pszText=<%s>\n",
196 debugstr_w((const WCHAR *)input->pszText));
198 TRACE("input - pszText=<%s>\n",
199 debugstr_a((const char *)input->pszText));
201 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
202 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
207 inline static LRESULT
208 COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
210 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
212 if (infoPtr->hwndCombo)
213 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
220 COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr, BOOL doW)
223 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
224 hdr->hwndFrom = infoPtr->hwndSelf;
227 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
230 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
236 COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
241 mydc = GetDC (0); /* why the entire screen???? */
242 nfont = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
243 ofont = (HFONT) SelectObject (mydc, nfont);
244 GetTextExtentPointA (mydc, "A", 1, size);
245 SelectObject (mydc, ofont);
247 TRACE("selected font hwnd=%08x, height=%ld\n", nfont, size->cy);
252 COMBOEX_CopyItem (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
254 if (cit->mask & CBEIF_TEXT) {
255 cit->pszText = item->pszText;
256 cit->cchTextMax = item->cchTextMax;
258 if (cit->mask & CBEIF_IMAGE)
259 cit->iImage = item->iImage;
260 if (cit->mask & CBEIF_SELECTEDIMAGE)
261 cit->iSelectedImage = item->iSelectedImage;
262 if (cit->mask & CBEIF_OVERLAY)
263 cit->iOverlay = item->iOverlay;
264 if (cit->mask & CBEIF_INDENT)
265 cit->iIndent = item->iIndent;
266 if (cit->mask & CBEIF_LPARAM)
267 cit->lParam = item->lParam;
273 COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
277 INT x, y, w, h, xoff = 0;
280 if (!infoPtr->hwndEdit) return;
281 iinfo.rcImage.left = iinfo.rcImage.right = 0;
283 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
284 xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
286 GetClientRect (infoPtr->hwndCombo, &rect);
287 InflateRect (&rect, -2, -2);
288 InvalidateRect (infoPtr->hwndCombo, &rect, TRUE);
290 /* reposition the Edit control based on whether icon exists */
291 COMBOEX_GetComboFontSize (infoPtr, &mysize);
292 TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy);
293 x = xoff + CBE_STARTOFFSET + 1;
295 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
298 TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n",
299 rect.left, rect.top, rect.right, rect.bottom,
301 SetWindowPos(infoPtr->hwndEdit, HWND_TOP,
304 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
309 COMBOEX_ReSize (HWND hwnd, COMBOEX_INFO *infoPtr)
315 COMBOEX_GetComboFontSize (infoPtr, &mysize);
316 cy = mysize.cy + CBE_EXTRA;
318 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
319 cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
320 TRACE("upgraded height due to image: height=%d\n", cy);
322 SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
323 if (infoPtr->hwndCombo)
324 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
325 (WPARAM) 0, (LPARAM) cy);
330 COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
332 if (!infoPtr->hwndEdit) return;
333 /* native issues the following messages to the {Edit} control */
334 /* WM_SETTEXT (0,addr) */
335 /* EM_SETSEL32 (0,0) */
336 /* EM_SETSEL32 (0,-1) */
337 if (item->mask & CBEIF_TEXT) {
338 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
339 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
340 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
345 static CBE_ITEMDATA *
346 COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
351 if ((index > infoPtr->nb_items) || (index < -1))
354 return infoPtr->edit;
355 item = infoPtr->items;
356 i = infoPtr->nb_items - 1;
358 /* find the item in the list */
359 while (item && (i > index)) {
360 item = (CBE_ITEMDATA *)item->next;
363 if (!item || (i != index)) {
364 FIXME("COMBOBOXEX item structures broken. Please report!\n");
372 COMBOEX_WarnCallBack (CBE_ITEMDATA *item)
374 if (item->pszText == LPSTR_TEXTCALLBACKW)
375 FIXME("Callback not implemented yet for pszText\n");
376 if (item->iImage == I_IMAGECALLBACK)
377 FIXME("Callback not implemented yet for iImage\n");
378 if (item->iSelectedImage == I_IMAGECALLBACK)
379 FIXME("Callback not implemented yet for iSelectedImage\n");
380 if (item->iOverlay == I_IMAGECALLBACK)
381 FIXME("Callback not implemented yet for iOverlay\n");
382 if (item->iIndent == I_INDENTCALLBACK)
383 FIXME("Callback not implemented yet for iIndent\n");
387 /* *** CBEM_xxx message support *** */
391 COMBOEX_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
393 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
394 INT index = (INT) wParam;
397 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
399 /* if item number requested does not exist then return failure */
400 if ((index > infoPtr->nb_items) || (index < 0)) {
401 ERR("attempt to delete item that does not exist\n");
405 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
406 ERR("attempt to delete item that was not found!\n");
410 /* doing this will result in WM_DELETEITEM being issued */
411 SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0);
413 return infoPtr->nb_items;
417 inline static LRESULT
418 COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
420 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
424 return (LRESULT)infoPtr->hwndCombo;
428 inline static LRESULT
429 COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
431 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
433 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
436 TRACE("-- 0x%x\n", infoPtr->hwndEdit);
438 return (LRESULT)infoPtr->hwndEdit;
442 inline static LRESULT
443 COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
445 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
447 TRACE("-- 0x%08lx\n", infoPtr->dwExtStyle);
449 return (LRESULT)infoPtr->dwExtStyle;
453 inline static LRESULT
454 COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
456 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
458 TRACE("-- 0x%p\n", infoPtr->himl);
460 return (LRESULT)infoPtr->himl;
465 COMBOEX_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
467 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
468 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
472 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
474 /* get real index of item to insert */
477 /* if item number requested does not exist then return failure */
478 if ((index > infoPtr->nb_items) || (index < -1)) {
479 ERR("attempt to get item that does not exist\n");
483 /* if the item is the edit control and there is no edit control, skip */
485 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
488 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
489 ERR("attempt to get item that was not found!\n");
493 COMBOEX_CopyItem (infoPtr, item, cit);
499 inline static LRESULT
500 COMBOEX_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
502 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
503 COMBOBOXEXITEMW tmpcit;
506 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
508 tmpcit.mask = cit->mask;
509 tmpcit.iItem = cit->iItem;
510 COMBOEX_GetItemW (hwnd, wParam, (LPARAM) &tmpcit);
512 len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL);
514 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
515 cit->pszText, cit->cchTextMax, NULL, NULL);
517 cit->iImage = tmpcit.iImage;
518 cit->iSelectedImage = tmpcit.iSelectedImage;
519 cit->iOverlay = tmpcit.iOverlay;
520 cit->iIndent = tmpcit.iIndent;
521 cit->lParam = tmpcit.lParam;
527 inline static LRESULT
528 COMBOEX_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
530 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
532 TRACE("%s hwnd=0x%x stub!\n",
533 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
535 return infoPtr->bUnicode;
539 inline static LRESULT
540 COMBOEX_HasEditChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
542 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
544 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
546 if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) ==
547 (WCBE_ACTEDIT | WCBE_EDITCHG))
554 COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
556 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
557 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
564 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
566 /* get real index of item to insert */
568 if (index == -1) index = infoPtr->nb_items;
569 if (index > infoPtr->nb_items) index = infoPtr->nb_items;
571 /* get space and chain it in */
572 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
574 item->pszText = NULL;
576 /* locate position to insert new item in */
577 if (index == infoPtr->nb_items) {
578 /* fast path for iItem = -1 */
579 item->next = infoPtr->items;
580 infoPtr->items = item;
583 INT i = infoPtr->nb_items-1;
584 CBE_ITEMDATA *moving = infoPtr->items;
586 while ((i > index) && moving) {
587 moving = (CBE_ITEMDATA *)moving->next;
591 FIXME("COMBOBOXEX item structures broken. Please report!\n");
595 item->next = moving->next;
599 /* fill in our hidden item structure */
600 item->mask = cit->mask;
601 if (item->mask & CBEIF_TEXT) {
606 if (!str) str = (LPWSTR) L"";
609 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
610 strcpyW (item->pszText, str);
612 item->cchTextMax = cit->cchTextMax;
614 if (item->mask & CBEIF_IMAGE)
615 item->iImage = cit->iImage;
616 if (item->mask & CBEIF_SELECTEDIMAGE)
617 item->iSelectedImage = cit->iSelectedImage;
618 if (item->mask & CBEIF_OVERLAY)
619 item->iOverlay = cit->iOverlay;
620 if (item->mask & CBEIF_INDENT)
621 item->iIndent = cit->iIndent;
622 if (item->mask & CBEIF_LPARAM)
623 item->lParam = cit->lParam;
626 COMBOEX_WarnCallBack (item);
628 COMBOEX_DumpItem (item);
630 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
631 (WPARAM)cit->iItem, (LPARAM)item);
633 COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
634 COMBOEX_Notify (infoPtr, CBEN_INSERTITEM, (NMHDR *)&nmcit, TRUE);
642 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
644 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
645 COMBOBOXEXITEMW citW;
648 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
649 if (cit->mask & CBEIF_TEXT) {
655 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
657 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
658 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
661 ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);;
663 if (cit->mask & CBEIF_TEXT)
664 COMCTL32_Free(citW.pszText);
670 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
672 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
675 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
677 dwTemp = infoPtr->dwExtStyle;
679 if (lParam & (CBES_EX_NOEDITIMAGEINDENT |
680 CBES_EX_PATHWORDBREAKPROC |
681 CBES_EX_NOSIZELIMIT |
682 CBES_EX_CASESENSITIVE))
683 FIXME("Extended style not implemented %08lx\n", lParam);
686 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
689 infoPtr->dwExtStyle = (DWORD)lParam;
692 * native does this for CBES_EX_NOEDITIMAGE state change
694 if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^
695 (dwTemp & CBES_EX_NOEDITIMAGE)) {
696 /* if state of EX_NOEDITIMAGE changes, invalidate all */
697 TRACE("EX_NOEDITIMAGE state changed to %ld\n",
698 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
699 InvalidateRect (hwnd, NULL, TRUE);
700 COMBOEX_AdjustEditPos (infoPtr);
701 if (infoPtr->hwndEdit)
702 InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
705 return (LRESULT)dwTemp;
709 inline static LRESULT
710 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
712 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
715 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
717 himlTemp = infoPtr->himl;
718 infoPtr->himl = (HIMAGELIST)lParam;
720 COMBOEX_ReSize (hwnd, infoPtr);
721 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
723 /* reposition the Edit control based on whether icon exists */
724 COMBOEX_AdjustEditPos (infoPtr);
725 return (LRESULT)himlTemp;
729 COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
731 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
732 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
736 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
738 /* get real index of item to insert */
741 /* if item number requested does not exist then return failure */
742 if ((index > infoPtr->nb_items) || (index < -1)) {
743 ERR("attempt to set item that does not exist yet!\n");
747 /* if the item is the edit control and there is no edit control, skip */
749 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
752 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
753 ERR("attempt to set item that was not found!\n");
757 /* add/change stuff to the internal item structure */
758 item->mask |= cit->mask;
759 if (cit->mask & CBEIF_TEXT) {
762 WCHAR emptystr[1] = {0};
765 if (!str) str=emptystr;
768 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
769 strcpyW(item->pszText,str);
771 item->cchTextMax = cit->cchTextMax;
773 if (cit->mask & CBEIF_IMAGE)
774 item->iImage = cit->iImage;
775 if (cit->mask & CBEIF_SELECTEDIMAGE)
776 item->iSelectedImage = cit->iSelectedImage;
777 if (cit->mask & CBEIF_OVERLAY)
778 item->iOverlay = cit->iOverlay;
779 if (cit->mask & CBEIF_INDENT)
780 item->iIndent = cit->iIndent;
781 if (cit->mask & CBEIF_LPARAM)
782 cit->lParam = cit->lParam;
784 COMBOEX_WarnCallBack (item);
786 COMBOEX_DumpItem (item);
788 /* if original request was to update edit control, do some fast foot work */
789 if (cit->iItem == -1) {
790 COMBOEX_SetEditText (infoPtr, item);
791 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
797 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
799 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
800 COMBOBOXEXITEMW citW;
803 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
804 if (cit->mask & CBEIF_TEXT) {
810 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
812 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
813 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
816 ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
818 if (cit->mask & CBEIF_TEXT)
819 COMCTL32_Free(citW.pszText);
824 inline static LRESULT
825 COMBOEX_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
827 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
830 TRACE("%s hwnd=0x%04x stub!\n",
831 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
833 bTemp = infoPtr->bUnicode;
834 infoPtr->bUnicode = (BOOL)wParam;
841 /* *** CB_xxx message support *** */
845 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
849 LPWSTR desired = NULL;
850 INT start = (INT) wParam;
852 i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
854 desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
855 MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
858 count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0 , 0);
860 /* now search from after starting loc and wrapping back to start */
861 for(i=start+1; i<count; i++) {
862 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
863 CB_GETITEMDATA, (WPARAM)i, 0);
864 TRACE("desired=%s, item=%s\n",
865 debugstr_w(desired), debugstr_w(item->pszText));
866 if (lstrcmpiW(item->pszText, desired) == 0) {
867 COMCTL32_Free (desired);
871 for(i=0; i<=start; i++) {
872 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
873 CB_GETITEMDATA, (WPARAM)i, 0);
874 TRACE("desired=%s, item=%s\n",
875 debugstr_w(desired), debugstr_w(item->pszText));
876 if (lstrcmpiW(item->pszText, desired) == 0) {
877 COMCTL32_Free (desired);
881 COMCTL32_Free(desired);
887 COMBOEX_GetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam)
890 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
891 CBE_ITEMDATA *item1, *item2;
894 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
896 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
897 item2 = COMBOEX_FindItem (infoPtr, index);
898 if (item2 != item1) {
899 ERR("data structures damaged!\n");
902 if (item1->mask & CBEIF_LPARAM)
903 lret = (LRESULT) item1->lParam;
904 TRACE("returning 0x%08lx\n", lret);
907 lret = (LRESULT)item1;
908 TRACE("non-valid result from combo, returning 0x%08lx\n", lret);
914 COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam)
917 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
921 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
922 /* FIXME: need to clear selection */
926 TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
927 debugstr_w(item->pszText) : "<null>");
928 infoPtr->selected = index;
930 lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam);
931 COMBOEX_SetEditText (infoPtr, item);
937 COMBOEX_SetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam)
940 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
941 CBE_ITEMDATA *item1, *item2;
943 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
945 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
946 item2 = COMBOEX_FindItem (infoPtr, index);
947 if (item2 != item1) {
948 ERR("data structures damaged!\n");
951 item1->mask |= CBEIF_LPARAM;
952 item1->lParam = lParam;
953 TRACE("setting lparam to 0x%08lx\n", lParam);
956 TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1);
957 return (LRESULT)item1;
962 COMBOEX_SetItemHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
964 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
965 RECT cb_wrect, cbx_wrect, cbx_crect;
969 /* First, lets forward the message to the normal combo control
970 just like Windows. */
971 if (infoPtr->hwndCombo)
972 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
974 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
975 GetWindowRect (hwnd, &cbx_wrect);
976 GetClientRect (hwnd, &cbx_crect);
977 /* the height of comboex as height of the combo + comboex border */
978 height = cb_wrect.bottom-cb_wrect.top
979 + cbx_wrect.bottom-cbx_wrect.top
980 - (cbx_crect.bottom-cbx_crect.top);
981 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
982 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
983 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
984 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
985 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
986 cbx_wrect.right-cbx_wrect.left, height);
987 SetWindowPos (hwnd, HWND_TOP, 0, 0,
988 cbx_wrect.right-cbx_wrect.left,
990 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
996 /* *** WM_xxx message support *** */
1000 COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1002 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
1003 COMBOEX_INFO *infoPtr;
1007 RECT wnrc1, clrc1, cmbwrc;
1010 /* allocate memory for info structure */
1011 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
1012 if (infoPtr == NULL) {
1013 ERR("could not allocate info memory!\n");
1017 /* initialize info structure */
1019 infoPtr->items = NULL;
1020 infoPtr->nb_items = 0;
1021 infoPtr->hwndSelf = hwnd;
1022 infoPtr->selected = -1;
1024 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1026 /* create combo box */
1027 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
1028 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
1030 GetWindowRect(hwnd, &wnrc1);
1031 GetClientRect(hwnd, &clrc1);
1032 TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
1033 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
1034 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
1035 TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle,
1036 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
1037 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
1038 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
1040 /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
1041 /* specified. It then creates it's own version of the EDIT control */
1042 /* and makes the ComboBox the parent. This is because a normal */
1043 /* DROPDOWNLIST does not have a EDIT control, but we need one. */
1044 /* We also need to place the edit control at the proper location */
1045 /* (allow space for the icons). */
1047 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
1048 /* following line added to match native */
1049 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
1050 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
1051 /* was base and is necessary */
1052 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
1053 cs->y, cs->x, cs->cx, cs->cy, hwnd,
1054 (HMENU) GetWindowLongA (hwnd, GWL_ID),
1055 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
1058 * native does the following at this point according to trace:
1059 * GetWindowThreadProcessId(hwndCombo,0)
1060 * GetCurrentThreadId()
1061 * GetWindowThreadProcessId(hwndCombo, &???)
1062 * GetCurrentProcessId()
1066 * Setup a property to hold the pointer to the COMBOBOXEX
1069 test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo);
1070 if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
1071 SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
1073 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo,
1074 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
1075 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1079 * Now create our own EDIT control so we can position it.
1080 * It is created only for CBS_DROPDOWN style
1082 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
1083 infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
1084 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
1085 0, 0, 0, 0, /* will set later */
1087 (HMENU) GetWindowLongA (hwnd, GWL_ID),
1088 GetWindowLongA (hwnd, GWL_HINSTANCE),
1091 /* native does the following at this point according to trace:
1092 * GetWindowThreadProcessId(hwndEdit,0)
1093 * GetCurrentThreadId()
1094 * GetWindowThreadProcessId(hwndEdit, &???)
1095 * GetCurrentProcessId()
1099 * Setup a property to hold the pointer to the COMBOBOXEX
1102 test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
1103 if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
1104 SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
1106 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
1107 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
1108 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1111 infoPtr->hwndEdit = 0;
1116 * Locate the default font if necessary and then set it in
1117 * all associated controls
1119 if (!infoPtr->font) {
1120 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
1122 infoPtr->font = CreateFontIndirectA (&mylogfont);
1124 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1125 if (infoPtr->hwndEdit) {
1126 SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1127 SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
1130 COMBOEX_ReSize (hwnd, infoPtr);
1132 /* Above is fairly certain, below is much less certain. */
1134 GetWindowRect(hwnd, &wnrc1);
1135 GetClientRect(hwnd, &clrc1);
1136 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1137 TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) CB wnd=(%d,%d)-(%d,%d)\n",
1138 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
1139 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
1140 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1141 SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
1142 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
1143 SWP_NOACTIVATE | SWP_NOREDRAW);
1145 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1146 TRACE("CB window=(%d,%d)-(%d,%d)\n",
1147 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1148 SetWindowPos(hwnd, HWND_TOP,
1149 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
1150 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
1152 COMBOEX_AdjustEditPos (infoPtr);
1155 * Create an item structure to represent the data in the
1158 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
1160 item->pszText = NULL;
1162 infoPtr->edit = item;
1168 inline static LRESULT
1169 COMBOEX_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
1172 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1173 INT command = HIWORD(wParam);
1174 CBE_ITEMDATA *item = 0;
1176 INT cursel, n, oldItem;
1177 NMCBEENDEDITA cbeend;
1180 TRACE("for command %d\n", command);
1185 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1188 * from native trace of first dropdown after typing in URL in IE4
1189 * CB_GETCURSEL(Combo)
1190 * GetWindowText(Edit)
1191 * CB_GETCURSEL(Combo)
1192 * CB_GETCOUNT(Combo)
1193 * CB_GETITEMDATA(Combo, n)
1194 * WM_NOTIFY(parent, CBEN_ENDEDITA|W)
1195 * CB_GETCURSEL(Combo)
1196 * CB_SETCURSEL(COMBOEX, n)
1198 * the rest is supposition
1200 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1202 /* find match from edit against those in Combobox */
1203 GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
1204 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
1205 for (cursel = 0; cursel < n; cursel++){
1206 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1209 if ((INT)item == CB_ERR) break;
1210 if (lstrcmpiW(item->pszText, wintext) == 0) break;
1212 if ((cursel == n) || ((INT)item == CB_ERR)) {
1213 TRACE("failed to find match??? item=%p cursel=%d\n",
1215 if (infoPtr->hwndEdit)
1216 SetFocus(infoPtr->hwndEdit);
1221 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1224 if ((INT)item == CB_ERR) {
1225 TRACE("failed to find match??? item=%p cursel=%d\n",
1227 if (infoPtr->hwndEdit)
1228 SetFocus(infoPtr->hwndEdit);
1233 /* Save flags for testing and reset them */
1234 oldflags = infoPtr->flags;
1235 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1237 if (oldflags & WCBE_ACTEDIT) {
1238 WideCharToMultiByte (CP_ACP, 0, item->pszText, -1,
1239 cbeend.szText, sizeof(cbeend.szText),
1241 cbeend.fChanged = (oldflags & WCBE_EDITCHG);
1242 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1243 CB_GETCURSEL, 0, 0);
1244 cbeend.iWhy = CBENF_DROPDOWN;
1246 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1247 (NMHDR *)&cbeend, FALSE)) {
1248 /* abort the change */
1249 TRACE("Notify requested abort of change\n");
1254 /* if selection has changed the set the new current selection */
1255 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1256 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
1257 infoPtr->selected = cursel;
1258 SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
1259 SetFocus(infoPtr->hwndCombo);
1265 * CB_GETCURSEL(Combo)
1266 * CB_GETITEMDATA(Combo) < simulated by COMBOEX_FindItem
1269 * WM_GETTEXTLENGTH(Edit)
1271 * EM_SETSEL(Edit, 0,0)
1272 * WM_GETTEXTLENGTH(Edit)
1274 * EM_SETSEL(Edit, 0,len)
1275 * return WM_COMMAND to parent
1277 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1278 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1279 ERR("item %d not found. Problem!\n", oldItem);
1282 infoPtr->selected = oldItem;
1283 COMBOEX_SetEditText (infoPtr, item);
1284 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1289 * We have to change the handle since we are the control
1290 * issuing the message. IE4 depends on this.
1292 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1297 * from native trace:
1300 * WM_GETTEXT(Edit, 104)
1301 * CB_GETCURSEL(Combo) rets -1
1302 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1303 * CB_GETCURSEL(Combo)
1304 * InvalidateRect(Combo, 0, 0)
1307 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1309 if (infoPtr->flags & WCBE_ACTEDIT) {
1310 GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
1311 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1312 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1313 CB_GETCURSEL, 0, 0);
1314 cbeend.iWhy = CBENF_KILLFOCUS;
1316 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1317 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1318 (NMHDR *)&cbeend, FALSE)) {
1319 /* abort the change */
1320 TRACE("Notify requested abort of change\n");
1324 /* possible CB_GETCURSEL */
1325 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1331 * We have to change the handle since we are the control
1332 * issuing the message. IE4 depends on this.
1333 * We also need to set the focus back to the Edit control
1334 * after passing the command to the parent of the ComboEx.
1336 lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1338 if (infoPtr->hwndEdit)
1339 SetFocus(infoPtr->hwndEdit);
1346 inline static LRESULT
1347 COMBOEX_WM_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1349 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1350 DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)lParam;
1351 CBE_ITEMDATA *item, *olditem;
1353 NMCOMBOBOXEXW nmcit;
1355 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
1356 dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
1358 if ((dis->itemID >= infoPtr->nb_items) || (dis->itemID < 0)) return FALSE;
1360 olditem = infoPtr->items;
1361 i = infoPtr->nb_items - 1;
1363 if (i == dis->itemID) {
1364 infoPtr->items = infoPtr->items->next;
1370 /* find the prior item in the list */
1371 while (item->next && (i > dis->itemID)) {
1372 item = (CBE_ITEMDATA *)item->next;
1375 if (!item->next || (i != dis->itemID)) {
1376 FIXME("COMBOBOXEX item structures broken. Please report!\n");
1379 olditem = item->next;
1380 item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
1382 infoPtr->nb_items--;
1384 COMBOEX_CopyItem (infoPtr, olditem, &nmcit.ceItem);
1385 COMBOEX_Notify (infoPtr, CBEN_DELETEITEM, (NMHDR *)&nmcit, TRUE);
1387 COMCTL32_Free(olditem);
1394 inline static LRESULT
1395 COMBOEX_DrawItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1397 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1398 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
1399 CBE_ITEMDATA *item = 0;
1402 int drawimage, drawstate;
1404 UINT xioff = 0; /* size and spacer of image if any */
1408 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
1411 /* "itemID - Specifies the menu item identifier for a menu */
1412 /* item or the index of the item in a list box or combo box. */
1413 /* For an empty list box or combo box, this member can be -1. */
1414 /* This allows the application to draw only the focus */
1415 /* rectangle at the coordinates specified by the rcItem */
1416 /* member even though there are no items in the control. */
1417 /* This indicates to the user whether the list box or combo */
1418 /* box has the focus. How the bits are set in the itemAction */
1419 /* member determines whether the rectangle is to be drawn as */
1420 /* though the list box or combo box has the focus. */
1421 if (dis->itemID == 0xffffffff) {
1422 if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
1423 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
1425 TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
1426 dis->rcItem.left, dis->rcItem.top,
1427 dis->rcItem.right, dis->rcItem.bottom);
1429 else if ((dis->CtlType == ODT_COMBOBOX) &&
1430 (dis->itemAction == ODA_DRAWENTIRE)) {
1431 /* draw of edit control data */
1435 RECT exrc, cbrc, edrc;
1436 GetWindowRect (hwnd, &exrc);
1437 GetWindowRect (infoPtr->hwndCombo, &cbrc);
1438 edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
1439 if (infoPtr->hwndEdit)
1440 GetWindowRect (infoPtr->hwndEdit, &edrc);
1441 TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
1442 exrc.left, exrc.top, exrc.right, exrc.bottom,
1443 cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
1444 edrc.left, edrc.top, edrc.right, edrc.bottom);
1448 ERR("NOT drawing item -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
1449 dis->rcItem.left, dis->rcItem.top,
1450 dis->rcItem.right, dis->rcItem.bottom,
1451 dis->itemAction, dis->itemState);
1456 /* If draw item is -1 (edit control) setup the item pointer */
1457 if (dis->itemID == 0xffffffff) {
1461 if (!infoPtr->hwndEdit) {
1462 ERR("request to draw edit item, but no edit control exists!\n");
1466 item = infoPtr->edit;
1467 /* free previous text of edit item */
1468 if (item->pszText) {
1469 COMCTL32_Free(item->pszText);
1471 item->mask &= ~CBEIF_TEXT;
1473 alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
1474 TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
1475 infoPtr->hwndEdit, alen, str);
1477 item->mask |= CBEIF_TEXT;
1478 wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
1480 item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
1481 MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
1486 /* if the item pointer is not set, then get the data and locate it */
1488 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1489 CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
1490 if (item == (CBE_ITEMDATA *)CB_ERR)
1492 FIXME("invalid item for id %d \n",dis->itemID);
1497 /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
1498 if (!TRACE_ON(message)) {
1499 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
1500 dis->CtlType, dis->CtlID);
1501 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
1502 dis->itemID, dis->itemAction, dis->itemState);
1503 TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
1504 dis->hwndItem, dis->hDC, dis->rcItem.left,
1505 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
1508 COMBOEX_DumpItem (item);
1510 xbase = CBE_STARTOFFSET;
1511 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX))
1512 xbase += (item->iIndent * CBE_INDENT);
1513 if (item->mask & CBEIF_IMAGE) {
1514 ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
1515 xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
1518 switch (dis->itemAction) {
1520 if (dis->itemState & ODS_SELECTED /*1*/) {
1521 if ((item->mask & CBEIF_TEXT) && item->pszText) {
1524 len = strlenW (item->pszText);
1525 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
1526 rect.left = xbase + xioff - 1;
1527 rect.right = rect.left + txtsize.cx + 2;
1528 rect.top = dis->rcItem.top;
1529 rect.bottom = dis->rcItem.bottom;
1530 GetClipBox (dis->hDC, &rect2);
1531 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
1532 dis->itemID, rect.left, rect.top,
1533 rect.right, rect.bottom);
1534 TRACE(" clip=(%d,%d)-(%d,%d)\n",
1535 rect2.left, rect2.top,
1536 rect2.right, rect2.bottom);
1538 DrawFocusRect(dis->hDC, &rect);
1541 FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
1545 FIXME("ODA_FOCUS but not ODS_SELECTED\n");
1549 case ODA_DRAWENTIRE:
1551 drawstate = ILD_NORMAL;
1552 if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
1553 if (item->mask & CBEIF_IMAGE)
1554 drawimage = item->iImage;
1555 if (dis->itemState & ODS_COMBOEXLBOX) {
1556 /* drawing listbox entry */
1557 if (dis->itemState & ODS_SELECTED) {
1558 if (item->mask & CBEIF_SELECTEDIMAGE)
1559 drawimage = item->iSelectedImage;
1560 drawstate = ILD_SELECTED;
1564 /* drawing combo/edit entry */
1565 if (infoPtr->hwndEdit) {
1566 /* if we have an edit control, the slave the
1567 * selection state to the Edit focus state
1569 if (infoPtr->flags & WCBE_EDITFOCUSED) {
1570 if (item->mask & CBEIF_SELECTEDIMAGE)
1571 drawimage = item->iSelectedImage;
1572 drawstate = ILD_SELECTED;
1576 /* if we don't have an edit control, use
1577 * the requested state.
1579 if (dis->itemState & ODS_SELECTED) {
1580 if (item->mask & CBEIF_SELECTEDIMAGE)
1581 drawimage = item->iSelectedImage;
1582 drawstate = ILD_SELECTED;
1587 if (drawimage != -1) {
1588 TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
1589 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
1590 xbase, dis->rcItem.top, drawstate);
1592 if ((item->mask & CBEIF_TEXT) && item->pszText) {
1594 COLORREF nbkc, ntxc;
1596 len = lstrlenW (item->pszText);
1597 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
1598 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1599 COLOR_HIGHLIGHT : COLOR_WINDOW);
1600 SetBkColor (dis->hDC, nbkc);
1601 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1602 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
1603 SetTextColor (dis->hDC, ntxc);
1605 y = dis->rcItem.top +
1606 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
1608 rect.right = x + txtsize.cx;
1609 rect.top = dis->rcItem.top + 1;
1610 rect.bottom = dis->rcItem.bottom - 1;
1611 TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
1612 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1613 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
1614 &rect, item->pszText, len, 0);
1615 if (dis->itemState & ODS_FOCUS) {
1620 TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
1621 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1622 DrawFocusRect (dis->hDC, &rect);
1627 FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
1628 hwnd, wParam, lParam, dis->itemAction);
1636 COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1638 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1640 if (infoPtr->hwndCombo)
1641 DestroyWindow (infoPtr->hwndCombo);
1643 if (infoPtr->edit) {
1644 COMCTL32_Free (infoPtr->edit);
1648 if (infoPtr->items) {
1649 CBE_ITEMDATA *this, *next;
1651 this = infoPtr->items;
1653 next = (CBE_ITEMDATA *)this->next;
1654 if ((this->mask & CBEIF_TEXT) && this->pszText)
1655 COMCTL32_Free (this->pszText);
1656 COMCTL32_Free (this);
1661 DeleteObject (infoPtr->font);
1663 /* free comboex info data */
1664 COMCTL32_Free (infoPtr);
1665 SetWindowLongA (hwnd, 0, 0);
1671 COMBOEX_MeasureItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1673 /*COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);*/
1674 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
1679 GetTextExtentPointA (hdc, "W", 1, &mysize);
1681 mis->itemHeight = mysize.cy + CBE_EXTRA;
1683 TRACE("adjusted height hwnd=%08x, height=%d\n",
1684 hwnd, mis->itemHeight);
1691 COMBOEX_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1693 /* WARNING: The COMBOEX_INFO structure is not yet created */
1694 DWORD oldstyle, newstyle;
1696 oldstyle = (DWORD)GetWindowLongA (hwnd, GWL_STYLE);
1697 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
1698 if (newstyle != oldstyle) {
1699 TRACE("req style %08lx, reseting style %08lx\n",
1700 oldstyle, newstyle);
1701 SetWindowLongA (hwnd, GWL_STYLE, newstyle);
1708 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1710 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1713 GetWindowRect (hwnd, &rect);
1714 TRACE("my rect (%d,%d)-(%d,%d)\n",
1715 rect.left, rect.top, rect.right, rect.bottom);
1717 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
1718 rect.bottom - rect.top, TRUE);
1720 COMBOEX_AdjustEditPos (infoPtr);
1727 COMBOEX_WindowPosChanging (HWND hwnd, WPARAM wParam, LPARAM lParam)
1729 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1731 RECT cbx_wrect, cbx_crect, cb_wrect;
1733 WINDOWPOS *wp = (WINDOWPOS *)lParam;
1735 ret = DefWindowProcA (hwnd, WM_WINDOWPOSCHANGING, wParam, lParam);
1736 GetWindowRect (hwnd, &cbx_wrect);
1737 GetClientRect (hwnd, &cbx_crect);
1738 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1740 /* width is winpos value + border width of comboex */
1742 + (cbx_wrect.right-cbx_wrect.left)
1743 - (cbx_crect.right-cbx_crect.left);
1745 TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
1746 wp->x, wp->y, wp->cx, wp->cy, wp->flags);
1747 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
1748 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
1749 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
1750 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
1751 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
1752 width, cb_wrect.bottom-cb_wrect.top);
1754 if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
1756 cb_wrect.bottom-cb_wrect.top,
1759 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1761 /* height is combo window height plus border width of comboex */
1762 height = (cb_wrect.bottom-cb_wrect.top)
1763 + (cbx_wrect.bottom-cbx_wrect.top)
1764 - (cbx_crect.bottom-cbx_crect.top);
1765 if (wp->cy < height) wp->cy = height;
1766 if (infoPtr->hwndEdit) {
1767 COMBOEX_AdjustEditPos (infoPtr);
1768 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1775 static LRESULT WINAPI
1776 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1778 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
1779 NMCBEENDEDITA cbeend;
1780 COLORREF nbkc, obkc;
1785 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1786 hwnd, uMsg, wParam, lParam, infoPtr);
1788 if (!infoPtr) return 0;
1794 /* handle (ignore) the return character */
1795 if (wParam == VK_RETURN) return 0;
1796 /* all other characters pass into the real Edit */
1797 return CallWindowProcA (infoPtr->prevEditWndProc,
1798 hwnd, uMsg, wParam, lParam);
1802 * The following was determined by traces of the native
1805 nbkc = GetSysColor (COLOR_WINDOW);
1806 obkc = SetBkColor (hDC, nbkc);
1807 GetClientRect (hwnd, &rect);
1808 TRACE("erasing (%d,%d)-(%d,%d)\n",
1809 rect.left, rect.top, rect.right, rect.bottom);
1810 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1811 SetBkColor (hDC, obkc);
1812 return CallWindowProcA (infoPtr->prevEditWndProc,
1813 hwnd, uMsg, wParam, lParam);
1816 INT oldItem, selected;
1818 WCHAR edit_text[260];
1820 switch ((INT)wParam)
1823 /* native version seems to do following for COMBOEX */
1825 * GetWindowTextA(Edit,&?, 0x104) x
1826 * CB_GETCURSEL to Combo rets -1 x
1827 * WM_NOTIFY to COMBOEX parent (rebar) x
1828 * (CBEN_ENDEDIT{A|W}
1829 * fChanged = FALSE x
1830 * inewSelection = -1 x
1833 * CB_GETCURSEL to Combo rets -1 x
1834 * InvalidateRect(Combo, 0) x
1835 * WM_SETTEXT to Edit x
1836 * EM_SETSEL to Edit (0,0) x
1837 * EM_SETSEL to Edit (0,-1) x
1838 * RedrawWindow(Combo, 0, 0, 5) x
1840 TRACE("special code for VK_ESCAPE\n");
1842 GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
1844 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1845 cbeend.fChanged = FALSE;
1846 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1847 CB_GETCURSEL, 0, 0);
1848 cbeend.iWhy = CBENF_ESCAPE;
1850 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1851 (NMHDR *)&cbeend, FALSE)) {
1852 /* abort the change */
1853 TRACE("Notify requested abort of change\n");
1856 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1857 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1858 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1859 ERR("item %d not found. Problem!\n", oldItem);
1862 infoPtr->selected = oldItem;
1863 COMBOEX_SetEditText (infoPtr, item);
1864 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1869 /* native version seems to do following for COMBOEX */
1871 * GetWindowTextA(Edit,&?, 0x104) x
1872 * CB_GETCURSEL to Combo rets -1 x
1873 * CB_GETCOUNT to Combo rets 0
1875 * CB_GETITEMDATA to match
1876 * *** above 3 lines simulated by FindItem x
1877 * WM_NOTIFY to COMBOEX parent (rebar) x
1878 * (CBEN_ENDEDIT{A|W} x
1879 * fChanged = TRUE (-1) x
1880 * iNewSelection = -1 or selected x
1882 * iWhy = 2 (CBENF_RETURN) x
1883 * CB_GETCURSEL to Combo rets -1 x
1884 * if -1 send CB_SETCURSEL to Combo -1 x
1885 * InvalidateRect(Combo, 0, 0) x
1887 * CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
1890 TRACE("special code for VK_RETURN\n");
1892 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1894 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1895 selected = SendMessageW (infoPtr->hwndCombo,
1896 CB_GETCURSEL, 0, 0);
1898 if (selected != -1) {
1899 item = COMBOEX_FindItem (infoPtr, selected);
1900 TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
1901 selected, debugstr_w(item->pszText));
1902 TRACE("handling VK_RETURN, edittext=%s\n",
1903 debugstr_w(edit_text));
1904 if (lstrcmpiW (item->pszText, edit_text)) {
1905 /* strings not equal -- indicate edit has changed */
1910 cbeend.iNewSelection = selected;
1911 cbeend.fChanged = TRUE;
1912 cbeend.iWhy = CBENF_RETURN;
1913 WideCharToMultiByte (CP_ACP, 0, edit_text, -1,
1914 cbeend.szText, sizeof(cbeend.szText),
1917 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1918 (NMHDR *)&cbeend, FALSE)) {
1919 /* abort the change, restore previous */
1920 TRACE("Notify requested abort of change\n");
1921 COMBOEX_SetEditText (infoPtr, infoPtr->edit);
1922 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1926 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1927 if (oldItem != -1) {
1928 /* if something is selected, then deselect it */
1929 SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
1932 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1933 SetFocus(infoPtr->hwndEdit);
1937 return CallWindowProcA (infoPtr->prevEditWndProc,
1938 hwnd, uMsg, wParam, lParam);
1944 /* remember the focus to set state of icon */
1945 lret = CallWindowProcA (infoPtr->prevEditWndProc,
1946 hwnd, uMsg, wParam, lParam);
1947 infoPtr->flags |= WCBE_EDITFOCUSED;
1952 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
1954 infoPtr->flags &= ~WCBE_EDITFOCUSED;
1955 if (infoPtr->flags & WCBE_ACTEDIT) {
1956 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1957 cbeend.fChanged = FALSE;
1958 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1959 CB_GETCURSEL, 0, 0);
1960 cbeend.iWhy = CBENF_KILLFOCUS;
1962 COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
1963 (NMHDR *)&cbeend, FALSE);
1968 return CallWindowProcA (infoPtr->prevEditWndProc,
1969 hwnd, uMsg, wParam, lParam);
1975 static LRESULT WINAPI
1976 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1978 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
1979 NMCBEENDEDITA cbeend;
1981 COLORREF nbkc, obkc;
1986 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1987 hwnd, uMsg, wParam, lParam, infoPtr);
1989 if (!infoPtr) return 0;
1994 case CB_FINDSTRINGEXACT:
1995 return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
1999 * The only way this message should come is from the
2000 * child Listbox issuing the message. Flag this so
2001 * that ComboEx knows this is listbox.
2003 ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
2004 return CallWindowProcA (infoPtr->prevComboWndProc,
2005 hwnd, uMsg, wParam, lParam);
2009 * The following was determined by traces of the native
2012 nbkc = GetSysColor (COLOR_WINDOW);
2013 obkc = SetBkColor (hDC, nbkc);
2014 GetClientRect (hwnd, &rect);
2015 TRACE("erasing (%d,%d)-(%d,%d)\n",
2016 rect.left, rect.top, rect.right, rect.bottom);
2017 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
2018 SetBkColor (hDC, obkc);
2019 return CallWindowProcA (infoPtr->prevComboWndProc,
2020 hwnd, uMsg, wParam, lParam);
2024 * WM_NOTIFY to comboex parent (rebar)
2025 * with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
2026 * CallWindowProc (previous)
2028 nmmse.dwItemSpec = 0;
2029 nmmse.dwItemData = 0;
2032 nmmse.dwHitInfo = lParam;
2033 COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse, FALSE);
2034 return CallWindowProcA (infoPtr->prevComboWndProc,
2035 hwnd, uMsg, wParam, lParam);
2038 switch (HIWORD(wParam)) {
2041 /* traces show that COMBOEX does not issue CBN_EDITUPDATE
2050 * GetFocus() retns AA
2051 * GetWindowTextA(Edit)
2052 * CB_GETCURSEL(Combo) (got -1)
2053 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
2054 * CB_GETCURSEL(Combo) (got -1)
2055 * InvalidateRect(Combo, 0, 0)
2056 * WM_KILLFOCUS(Combo, AA)
2059 focusedhwnd = GetFocus();
2060 if (infoPtr->flags & WCBE_ACTEDIT) {
2061 GetWindowTextA (infoPtr->hwndEdit, cbeend.szText, 260);
2062 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
2063 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
2064 CB_GETCURSEL, 0, 0);
2065 cbeend.iWhy = CBENF_KILLFOCUS;
2067 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
2068 if (COMBOEX_Notify (infoPtr, CBEN_ENDEDITA,
2069 (NMHDR *)&cbeend, FALSE)) {
2070 /* abort the change */
2071 TRACE("Notify requested abort of change\n");
2075 /* possible CB_GETCURSEL */
2076 InvalidateRect (infoPtr->hwndCombo, 0, 0);
2078 SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
2079 (WPARAM)focusedhwnd, 0);
2084 * For EN_SETFOCUS this issues the same calls and messages
2085 * as the native seems to do.
2087 * for some cases however native does the following:
2088 * (noticed after SetFocus during LBUTTONDOWN on
2089 * on dropdown arrow)
2090 * WM_GETTEXTLENGTH (Edit);
2091 * WM_GETTEXT (Edit, len+1, str);
2092 * EM_SETSEL (Edit, 0, 0);
2093 * WM_GETTEXTLENGTH (Edit);
2094 * WM_GETTEXT (Edit, len+1, str);
2095 * EM_SETSEL (Edit, 0, len);
2096 * WM_NOTIFY (parent, CBEN_BEGINEDIT)
2100 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
2101 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
2102 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr, FALSE);
2103 infoPtr->flags |= WCBE_ACTEDIT;
2104 infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
2110 * For EN_CHANGE this issues the same calls and messages
2111 * as the native seems to do.
2113 WCHAR edit_text[260];
2118 selected = SendMessageW (infoPtr->hwndCombo,
2119 CB_GETCURSEL, 0, 0);
2121 /* lstrlenA( lastworkingURL ) */
2123 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2124 if (selected == -1) {
2125 lastwrk = infoPtr->edit->pszText;
2126 cnt = lstrlenW (lastwrk);
2127 if (cnt >= 259) cnt = 259;
2130 item = COMBOEX_FindItem (infoPtr, selected);
2131 cnt = lstrlenW (item->pszText);
2132 lastwrk = item->pszText;
2133 if (cnt >= 259) cnt = 259;
2136 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
2137 selected, debugstr_w(lastwrk));
2138 TRACE("handling EN_CHANGE, edittext=%s\n",
2139 debugstr_w(edit_text));
2141 /* lstrcmpiW is between lastworkingURL and GetWindowText */
2143 if (lstrcmpiW (lastwrk, edit_text)) {
2144 /* strings not equal -- indicate edit has changed */
2145 infoPtr->flags |= WCBE_EDITCHG;
2147 SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
2148 MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
2156 * Therefore from traces there is no additional code here
2160 * Using native COMCTL32 gets the following:
2161 * 1 == SHDOCVW.DLL issues call/message
2162 * 2 == COMCTL32.DLL issues call/message
2163 * 3 == WINE issues call/message
2166 * for LBN_SELCHANGE:
2167 * 1 CB_GETCURSEL(ComboEx)
2168 * 1 CB_GETDROPPEDSTATE(ComboEx)
2169 * 1 CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
2170 * 2 CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
2171 ** call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
2172 * 3 WM_COMMAND(ComboEx, CBN_SELENDOK)
2173 * WM_USER+49(ComboLB, 1,0) <=============!!!!!!!!!!!
2174 * 3 ShowWindow(ComboLB, SW_HIDE)
2175 * 3 RedrawWindow(Combo, RDW_UPDATENOW)
2176 * 3 WM_COMMAND(ComboEX, CBN_CLOSEUP)
2178 * 3 WM_COMMAND(ComboEx, CBN_SELCHANGE) (echo to parent)
2179 * ? LB_GETCURSEL <==|
2181 * ? LB_GETTEXT | Needs to be added to
2182 * ? WM_CTLCOLOREDIT(ComboEx) | Combo processing
2183 * ? LB_GETITEMDATA |
2184 * ? WM_DRAWITEM(ComboEx) <==|
2190 return CallWindowProcA (infoPtr->prevComboWndProc,
2191 hwnd, uMsg, wParam, lParam);
2197 static LRESULT WINAPI
2198 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2200 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2202 if (!COMBOEX_GetInfoPtr (hwnd)) {
2203 if (uMsg == WM_CREATE)
2204 return COMBOEX_Create (hwnd, wParam, lParam);
2205 if (uMsg == WM_NCCREATE)
2206 COMBOEX_NCCreate (hwnd, wParam, lParam);
2207 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2212 case CBEM_DELETEITEM: /* maps to CB_DELETESTRING */
2213 return COMBOEX_DeleteItem (hwnd, wParam, lParam);
2215 case CBEM_GETCOMBOCONTROL:
2216 return COMBOEX_GetComboControl (hwnd, wParam, lParam);
2218 case CBEM_GETEDITCONTROL:
2219 return COMBOEX_GetEditControl (hwnd, wParam, lParam);
2221 case CBEM_GETEXTENDEDSTYLE:
2222 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
2224 case CBEM_GETIMAGELIST:
2225 return COMBOEX_GetImageList (hwnd, wParam, lParam);
2228 return COMBOEX_GetItemA (hwnd, wParam, lParam);
2231 return COMBOEX_GetItemW (hwnd, wParam, lParam);
2233 case CBEM_GETUNICODEFORMAT:
2234 return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
2236 case CBEM_HASEDITCHANGED:
2237 return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
2239 case CBEM_INSERTITEMA:
2240 return COMBOEX_InsertItemA (hwnd, wParam, lParam);
2242 case CBEM_INSERTITEMW:
2243 return COMBOEX_InsertItemW (hwnd, wParam, lParam);
2245 case CBEM_SETEXSTYLE: /* FIXME: obsoleted, should be the same as: */
2246 case CBEM_SETEXTENDEDSTYLE:
2247 return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
2249 case CBEM_SETIMAGELIST:
2250 return COMBOEX_SetImageList (hwnd, wParam, lParam);
2253 return COMBOEX_SetItemA (hwnd, wParam, lParam);
2256 return COMBOEX_SetItemW (hwnd, wParam, lParam);
2258 case CBEM_SETUNICODEFORMAT:
2259 return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
2262 /* Combo messages we are not sure if we need to process or just forward */
2263 case CB_GETDROPPEDCONTROLRECT:
2264 case CB_GETITEMHEIGHT:
2266 case CB_GETLBTEXTLEN:
2267 case CB_GETEXTENDEDUI:
2269 case CB_RESETCONTENT:
2270 case CB_SELECTSTRING:
2273 FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
2274 uMsg, wParam, lParam);
2275 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
2277 /* Combo messages OK to just forward to the regular COMBO */
2280 case CB_GETDROPPEDSTATE:
2281 case CB_SETDROPPEDWIDTH:
2282 case CB_SETEXTENDEDUI:
2283 case CB_SHOWDROPDOWN:
2284 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
2286 /* Combo messages we need to process specially */
2287 case CB_FINDSTRINGEXACT:
2288 return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
2291 case CB_GETITEMDATA:
2292 return COMBOEX_GetItemData (hwnd, wParam, lParam);
2295 return COMBOEX_SetCursel (hwnd, wParam, lParam);
2297 case CB_SETITEMDATA:
2298 return COMBOEX_SetItemData (hwnd, wParam, lParam);
2300 case CB_SETITEMHEIGHT:
2301 return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
2305 /* Window messages passed to parent */
2307 return COMBOEX_Command (hwnd, wParam, lParam);
2310 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2313 /* Window messages we need to process */
2315 return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
2318 return COMBOEX_DrawItem (hwnd, wParam, lParam);
2321 return COMBOEX_Destroy (hwnd, wParam, lParam);
2323 case WM_MEASUREITEM:
2324 return COMBOEX_MeasureItem (hwnd, wParam, lParam);
2327 return COMBOEX_Size (hwnd, wParam, lParam);
2329 case WM_WINDOWPOSCHANGING:
2330 return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
2333 if (uMsg >= WM_USER)
2334 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2335 uMsg, wParam, lParam);
2336 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2343 COMBOEX_Register (void)
2347 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2348 wndClass.style = CS_GLOBALCLASS;
2349 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
2350 wndClass.cbClsExtra = 0;
2351 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
2352 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
2353 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2354 wndClass.lpszClassName = WC_COMBOBOXEXA;
2356 RegisterClassA (&wndClass);
2358 ComboExInfo = GlobalAddAtomA("CC32SubclassInfo");
2363 COMBOEX_Unregister (void)
2365 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);