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 (mod6)
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.
72 * 1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do
73 * WM_NOTIFY correctly based on results.
74 * 2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM.
75 * 3. Add routines to handle special cases of NMCBEENDEDIT and NMCOMBOXEX
76 * so translation to ANSI is done correctly.
77 * 4. Fix some issues with COMBOEX_DrawItem.
79 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe),
87 #include "debugtools.h"
88 #include "wine/unicode.h"
90 DEFAULT_DEBUG_CHANNEL(comboex);
92 * The following is necessary for the test done in COMBOEX_DrawItem
93 * to determine whether to dump out the DRAWITEM structure or not.
95 DECLARE_DEBUG_CHANNEL(message);
111 /* ComboBoxEx structure */
115 HWND hwndSelf; /* my own hwnd */
118 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */
119 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */
121 INT selected; /* index of selected item */
122 DWORD flags; /* WINE internal flags */
124 INT nb_items; /* Number of items */
125 BOOL bUnicode; /* TRUE if this window is Unicode */
126 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */
127 CBE_ITEMDATA *edit; /* item data for edit item */
128 CBE_ITEMDATA *items; /* Array of items */
131 /* internal flags in the COMBOEX_INFO structure */
132 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e.
133 * CBEN_BEGINEDIT issued
134 * but CBEN_ENDEDIT{A|W}
136 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */
137 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */
140 #define ID_CB_EDIT 1001
144 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
145 * the ComboEx version of the Combo Window Proc so that when the
146 * WM_DRAWITEM message is then passed to ComboEx, we know that this
147 * particular WM_DRAWITEM message is for listbox only items. Any messasges
148 * without this flag is then for the Edit control field.
150 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
151 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
153 #define ODS_COMBOEXLBOX 0x4000
157 /* Height in pixels of control over the amount of the selected font */
160 /* Indent amount per MS documentation */
161 #define CBE_INDENT 10
163 /* Offset in pixels from left side for start of image or text */
164 #define CBE_STARTOFFSET 6
166 /* Offset between image and text */
169 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
172 /* Things common to the entire DLL */
173 static ATOM ComboExInfo;
174 static LRESULT WINAPI
175 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
176 static LRESULT WINAPI
177 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
180 COMBOEX_DumpItem (CBE_ITEMDATA *item)
182 if (TRACE_ON(comboex)){
183 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
184 item, item->mask, item->pszText, item->cchTextMax,
186 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
187 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
188 if ((item->mask & CBEIF_TEXT) && item->pszText)
189 TRACE("item %p - pszText=%s\n",
190 item, debugstr_w((const WCHAR *)item->pszText));
196 COMBOEX_DumpInput (COMBOBOXEXITEMA *input, BOOL true_for_w)
198 if (TRACE_ON(comboex)){
199 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
200 input->mask, input->iItem, input->pszText, input->cchTextMax,
202 if ((input->mask & CBEIF_TEXT) && input->pszText) {
204 TRACE("input - pszText=<%s>\n",
205 debugstr_w((const WCHAR *)input->pszText));
207 TRACE("input - pszText=<%s>\n",
208 debugstr_a((const char *)input->pszText));
210 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
211 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
216 inline static LRESULT
217 COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
219 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
221 if (infoPtr->hwndCombo)
222 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
229 COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
232 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
233 hdr->hwndFrom = infoPtr->hwndSelf;
235 if (infoPtr->NtfUnicode)
236 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
239 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
245 COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr)
248 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
250 hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
251 hdr->hdr.hwndFrom = infoPtr->hwndSelf;
252 hdr->hdr.code = code;
253 if (infoPtr->NtfUnicode)
254 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
257 LPWSTR str, ostr = NULL;
260 if (hdr->ceItem.mask & CBEIF_TEXT) {
261 ostr = hdr->ceItem.pszText;
263 if (!str) str = (LPWSTR)L"";
264 len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL);
266 hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
267 WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText,
272 ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
274 if (hdr->ceItem.mask & CBEIF_TEXT) {
276 COMCTL32_Free (hdr->ceItem.pszText);
277 hdr->ceItem.pszText = ostr;
285 COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *hdr, LPWSTR itemText)
288 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
290 hdr->hdr.idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
291 hdr->hdr.hwndFrom = infoPtr->hwndSelf;
292 hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA;
293 if (infoPtr->NtfUnicode)
294 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
299 memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR));
300 ansi.fChanged = hdr->fChanged;
301 ansi.iNewSelection = hdr->iNewSelection;
302 WideCharToMultiByte (CP_ACP, 0, itemText, -1,
303 (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL);
304 ansi.iWhy = hdr->iWhy;
305 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
312 COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
317 mydc = GetDC (0); /* why the entire screen???? */
318 nfont = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
319 ofont = (HFONT) SelectObject (mydc, nfont);
320 GetTextExtentPointA (mydc, "A", 1, size);
321 SelectObject (mydc, ofont);
323 TRACE("selected font hwnd=%08x, height=%ld\n", nfont, size->cy);
328 COMBOEX_CopyItem (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
330 if (cit->mask & CBEIF_TEXT) {
331 cit->pszText = item->pszText;
332 cit->cchTextMax = item->cchTextMax;
334 if (cit->mask & CBEIF_IMAGE)
335 cit->iImage = item->iImage;
336 if (cit->mask & CBEIF_SELECTEDIMAGE)
337 cit->iSelectedImage = item->iSelectedImage;
338 if (cit->mask & CBEIF_OVERLAY)
339 cit->iOverlay = item->iOverlay;
340 if (cit->mask & CBEIF_INDENT)
341 cit->iIndent = item->iIndent;
342 if (cit->mask & CBEIF_LPARAM)
343 cit->lParam = item->lParam;
349 COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
353 INT x, y, w, h, xoff = 0;
356 if (!infoPtr->hwndEdit) return;
357 iinfo.rcImage.left = iinfo.rcImage.right = 0;
359 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
360 xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
362 GetClientRect (infoPtr->hwndCombo, &rect);
363 InflateRect (&rect, -2, -2);
364 InvalidateRect (infoPtr->hwndCombo, &rect, TRUE);
366 /* reposition the Edit control based on whether icon exists */
367 COMBOEX_GetComboFontSize (infoPtr, &mysize);
368 TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy);
369 x = xoff + CBE_STARTOFFSET + 1;
371 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
374 TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n",
375 rect.left, rect.top, rect.right, rect.bottom,
377 SetWindowPos(infoPtr->hwndEdit, HWND_TOP,
380 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
385 COMBOEX_ReSize (HWND hwnd, COMBOEX_INFO *infoPtr)
391 COMBOEX_GetComboFontSize (infoPtr, &mysize);
392 cy = mysize.cy + CBE_EXTRA;
394 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
395 cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
396 TRACE("upgraded height due to image: height=%d\n", cy);
398 SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
399 if (infoPtr->hwndCombo)
400 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
401 (WPARAM) 0, (LPARAM) cy);
406 COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
408 if (!infoPtr->hwndEdit) return;
409 /* native issues the following messages to the {Edit} control */
410 /* WM_SETTEXT (0,addr) */
411 /* EM_SETSEL32 (0,0) */
412 /* EM_SETSEL32 (0,-1) */
413 if (item->mask & CBEIF_TEXT) {
414 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
415 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
416 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
421 static CBE_ITEMDATA *
422 COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
427 if ((index > infoPtr->nb_items) || (index < -1))
430 return infoPtr->edit;
431 item = infoPtr->items;
432 i = infoPtr->nb_items - 1;
434 /* find the item in the list */
435 while (item && (i > index)) {
436 item = (CBE_ITEMDATA *)item->next;
439 if (!item || (i != index)) {
440 FIXME("COMBOBOXEX item structures broken. Please report!\n");
448 COMBOEX_WarnCallBack (CBE_ITEMDATA *item)
450 if (item->pszText == LPSTR_TEXTCALLBACKW)
451 FIXME("Callback not implemented yet for pszText\n");
452 if (item->iImage == I_IMAGECALLBACK)
453 FIXME("Callback not implemented yet for iImage\n");
454 if (item->iSelectedImage == I_IMAGECALLBACK)
455 FIXME("Callback not implemented yet for iSelectedImage\n");
456 if (item->iOverlay == I_IMAGECALLBACK)
457 FIXME("Callback not implemented yet for iOverlay\n");
458 if (item->iIndent == I_INDENTCALLBACK)
459 FIXME("Callback not implemented yet for iIndent\n");
463 /* *** CBEM_xxx message support *** */
467 COMBOEX_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
469 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
470 INT index = (INT) wParam;
473 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
475 /* if item number requested does not exist then return failure */
476 if ((index > infoPtr->nb_items) || (index < 0)) {
477 ERR("attempt to delete item that does not exist\n");
481 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
482 ERR("attempt to delete item that was not found!\n");
486 /* doing this will result in WM_DELETEITEM being issued */
487 SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0);
489 return infoPtr->nb_items;
493 inline static LRESULT
494 COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
496 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
500 return (LRESULT)infoPtr->hwndCombo;
504 inline static LRESULT
505 COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
507 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
509 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
512 TRACE("-- 0x%x\n", infoPtr->hwndEdit);
514 return (LRESULT)infoPtr->hwndEdit;
518 inline static LRESULT
519 COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
521 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
523 TRACE("-- 0x%08lx\n", infoPtr->dwExtStyle);
525 return (LRESULT)infoPtr->dwExtStyle;
529 inline static LRESULT
530 COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
532 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
534 TRACE("-- 0x%p\n", infoPtr->himl);
536 return (LRESULT)infoPtr->himl;
541 COMBOEX_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
543 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
544 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
548 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
550 /* get real index of item to insert */
553 /* if item number requested does not exist then return failure */
554 if ((index > infoPtr->nb_items) || (index < -1)) {
555 ERR("attempt to get item that does not exist\n");
559 /* if the item is the edit control and there is no edit control, skip */
561 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
564 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
565 ERR("attempt to get item that was not found!\n");
569 COMBOEX_CopyItem (infoPtr, item, cit);
575 inline static LRESULT
576 COMBOEX_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
578 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
579 COMBOBOXEXITEMW tmpcit;
582 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
584 tmpcit.mask = cit->mask;
585 tmpcit.iItem = cit->iItem;
586 COMBOEX_GetItemW (hwnd, wParam, (LPARAM) &tmpcit);
588 len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL);
590 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
591 cit->pszText, cit->cchTextMax, NULL, NULL);
593 cit->iImage = tmpcit.iImage;
594 cit->iSelectedImage = tmpcit.iSelectedImage;
595 cit->iOverlay = tmpcit.iOverlay;
596 cit->iIndent = tmpcit.iIndent;
597 cit->lParam = tmpcit.lParam;
603 inline static LRESULT
604 COMBOEX_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
606 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
608 TRACE("%s hwnd=0x%x\n",
609 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
611 return infoPtr->bUnicode;
615 inline static LRESULT
616 COMBOEX_HasEditChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
618 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
620 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
622 if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) ==
623 (WCBE_ACTEDIT | WCBE_EDITCHG))
630 COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
632 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
633 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
640 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
642 /* get real index of item to insert */
644 if (index == -1) index = infoPtr->nb_items;
645 if (index > infoPtr->nb_items) index = infoPtr->nb_items;
647 /* get space and chain it in */
648 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
650 item->pszText = NULL;
652 /* locate position to insert new item in */
653 if (index == infoPtr->nb_items) {
654 /* fast path for iItem = -1 */
655 item->next = infoPtr->items;
656 infoPtr->items = item;
659 INT i = infoPtr->nb_items-1;
660 CBE_ITEMDATA *moving = infoPtr->items;
662 while ((i > index) && moving) {
663 moving = (CBE_ITEMDATA *)moving->next;
667 FIXME("COMBOBOXEX item structures broken. Please report!\n");
671 item->next = moving->next;
675 /* fill in our hidden item structure */
676 item->mask = cit->mask;
677 if (item->mask & CBEIF_TEXT) {
682 if (!str) str = (LPWSTR) L"";
685 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
686 strcpyW (item->pszText, str);
689 item->pszText = NULL;
690 item->cchTextMax = cit->cchTextMax;
692 if (item->mask & CBEIF_IMAGE)
693 item->iImage = cit->iImage;
694 if (item->mask & CBEIF_SELECTEDIMAGE)
695 item->iSelectedImage = cit->iSelectedImage;
696 if (item->mask & CBEIF_OVERLAY)
697 item->iOverlay = cit->iOverlay;
698 if (item->mask & CBEIF_INDENT)
699 item->iIndent = cit->iIndent;
700 if (item->mask & CBEIF_LPARAM)
701 item->lParam = cit->lParam;
704 COMBOEX_WarnCallBack (item);
706 COMBOEX_DumpItem (item);
708 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
709 (WPARAM)cit->iItem, (LPARAM)item);
711 COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
712 COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit);
720 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
722 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
723 COMBOBOXEXITEMW citW;
726 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
727 if (cit->mask & CBEIF_TEXT) {
733 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
735 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
736 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
739 ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);;
741 if (cit->mask & CBEIF_TEXT)
742 COMCTL32_Free(citW.pszText);
748 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
750 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
753 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
755 dwTemp = infoPtr->dwExtStyle;
757 if (lParam & (CBES_EX_NOEDITIMAGEINDENT |
758 CBES_EX_PATHWORDBREAKPROC |
759 CBES_EX_NOSIZELIMIT |
760 CBES_EX_CASESENSITIVE))
761 FIXME("Extended style not implemented %08lx\n", lParam);
764 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
767 infoPtr->dwExtStyle = (DWORD)lParam;
770 * native does this for CBES_EX_NOEDITIMAGE state change
772 if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^
773 (dwTemp & CBES_EX_NOEDITIMAGE)) {
774 /* if state of EX_NOEDITIMAGE changes, invalidate all */
775 TRACE("EX_NOEDITIMAGE state changed to %ld\n",
776 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
777 InvalidateRect (hwnd, NULL, TRUE);
778 COMBOEX_AdjustEditPos (infoPtr);
779 if (infoPtr->hwndEdit)
780 InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
783 return (LRESULT)dwTemp;
787 inline static LRESULT
788 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
790 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
793 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
795 himlTemp = infoPtr->himl;
796 infoPtr->himl = (HIMAGELIST)lParam;
798 COMBOEX_ReSize (hwnd, infoPtr);
799 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
801 /* reposition the Edit control based on whether icon exists */
802 COMBOEX_AdjustEditPos (infoPtr);
803 return (LRESULT)himlTemp;
807 COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
809 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
810 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
814 COMBOEX_DumpInput ((COMBOBOXEXITEMA *) cit, TRUE);
816 /* get real index of item to insert */
819 /* if item number requested does not exist then return failure */
820 if ((index > infoPtr->nb_items) || (index < -1)) {
821 ERR("attempt to set item that does not exist yet!\n");
825 /* if the item is the edit control and there is no edit control, skip */
827 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
830 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
831 ERR("attempt to set item that was not found!\n");
835 /* add/change stuff to the internal item structure */
836 item->mask |= cit->mask;
837 if (cit->mask & CBEIF_TEXT) {
840 WCHAR emptystr[1] = {0};
843 if (!str) str=emptystr;
846 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
847 strcpyW(item->pszText,str);
849 item->cchTextMax = cit->cchTextMax;
851 if (cit->mask & CBEIF_IMAGE)
852 item->iImage = cit->iImage;
853 if (cit->mask & CBEIF_SELECTEDIMAGE)
854 item->iSelectedImage = cit->iSelectedImage;
855 if (cit->mask & CBEIF_OVERLAY)
856 item->iOverlay = cit->iOverlay;
857 if (cit->mask & CBEIF_INDENT)
858 item->iIndent = cit->iIndent;
859 if (cit->mask & CBEIF_LPARAM)
860 cit->lParam = cit->lParam;
862 COMBOEX_WarnCallBack (item);
864 COMBOEX_DumpItem (item);
866 /* if original request was to update edit control, do some fast foot work */
867 if (cit->iItem == -1) {
868 COMBOEX_SetEditText (infoPtr, item);
869 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
875 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
877 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
878 COMBOBOXEXITEMW citW;
881 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
882 if (cit->mask & CBEIF_TEXT) {
888 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
890 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
891 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
894 ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
896 if (cit->mask & CBEIF_TEXT)
897 COMCTL32_Free(citW.pszText);
902 inline static LRESULT
903 COMBOEX_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
905 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
906 BOOL bTemp = infoPtr->bUnicode;
908 TRACE("to %s hwnd=0x%04x, was %s\n",
909 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
910 (bTemp) ? "TRUE" : "FALSE");
912 infoPtr->bUnicode = (BOOL)wParam;
919 /* *** CB_xxx message support *** */
923 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
927 LPWSTR desired = NULL;
928 INT start = (INT) wParam;
930 i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
932 desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
933 MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
936 count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0 , 0);
938 /* now search from after starting loc and wrapping back to start */
939 for(i=start+1; i<count; i++) {
940 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
941 CB_GETITEMDATA, (WPARAM)i, 0);
942 TRACE("desired=%s, item=%s\n",
943 debugstr_w(desired), debugstr_w(item->pszText));
944 if (lstrcmpiW(item->pszText, desired) == 0) {
945 COMCTL32_Free (desired);
949 for(i=0; i<=start; i++) {
950 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
951 CB_GETITEMDATA, (WPARAM)i, 0);
952 TRACE("desired=%s, item=%s\n",
953 debugstr_w(desired), debugstr_w(item->pszText));
954 if (lstrcmpiW(item->pszText, desired) == 0) {
955 COMCTL32_Free (desired);
959 COMCTL32_Free(desired);
965 COMBOEX_GetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam)
968 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
969 CBE_ITEMDATA *item1, *item2;
972 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
974 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
975 item2 = COMBOEX_FindItem (infoPtr, index);
976 if (item2 != item1) {
977 ERR("data structures damaged!\n");
980 if (item1->mask & CBEIF_LPARAM)
981 lret = (LRESULT) item1->lParam;
982 TRACE("returning 0x%08lx\n", lret);
985 lret = (LRESULT)item1;
986 TRACE("non-valid result from combo, returning 0x%08lx\n", lret);
992 COMBOEX_SetCursel (HWND hwnd, WPARAM wParam, LPARAM lParam)
995 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
999 if (!(item = COMBOEX_FindItem(infoPtr, index))) {
1000 /* FIXME: need to clear selection */
1004 TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
1005 debugstr_w(item->pszText) : "<null>");
1006 infoPtr->selected = index;
1008 lret = SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, wParam, lParam);
1009 COMBOEX_SetEditText (infoPtr, item);
1015 COMBOEX_SetItemData (HWND hwnd, WPARAM wParam, LPARAM lParam)
1018 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1019 CBE_ITEMDATA *item1, *item2;
1021 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
1023 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
1024 item2 = COMBOEX_FindItem (infoPtr, index);
1025 if (item2 != item1) {
1026 ERR("data structures damaged!\n");
1029 item1->mask |= CBEIF_LPARAM;
1030 item1->lParam = lParam;
1031 TRACE("setting lparam to 0x%08lx\n", lParam);
1034 TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1);
1035 return (LRESULT)item1;
1040 COMBOEX_SetItemHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
1042 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1043 RECT cb_wrect, cbx_wrect, cbx_crect;
1047 /* First, lets forward the message to the normal combo control
1048 just like Windows. */
1049 if (infoPtr->hwndCombo)
1050 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
1052 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1053 GetWindowRect (hwnd, &cbx_wrect);
1054 GetClientRect (hwnd, &cbx_crect);
1055 /* the height of comboex as height of the combo + comboex border */
1056 height = cb_wrect.bottom-cb_wrect.top
1057 + cbx_wrect.bottom-cbx_wrect.top
1058 - (cbx_crect.bottom-cbx_crect.top);
1059 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
1060 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
1061 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
1062 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
1063 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
1064 cbx_wrect.right-cbx_wrect.left, height);
1065 SetWindowPos (hwnd, HWND_TOP, 0, 0,
1066 cbx_wrect.right-cbx_wrect.left,
1068 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
1074 /* *** WM_xxx message support *** */
1078 COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1080 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
1081 COMBOEX_INFO *infoPtr;
1085 RECT wnrc1, clrc1, cmbwrc;
1089 /* allocate memory for info structure */
1090 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
1091 if (infoPtr == NULL) {
1092 ERR("could not allocate info memory!\n");
1096 /* initialize info structure */
1098 infoPtr->items = NULL;
1099 infoPtr->nb_items = 0;
1100 infoPtr->hwndSelf = hwnd;
1101 infoPtr->selected = -1;
1103 infoPtr->bUnicode = IsWindowUnicode (hwnd);
1105 i = SendMessageA(GetParent (hwnd),
1106 WM_NOTIFYFORMAT, hwnd, NF_QUERY);
1107 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
1108 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
1112 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
1114 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1116 /* create combo box */
1117 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
1118 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
1120 GetWindowRect(hwnd, &wnrc1);
1121 GetClientRect(hwnd, &clrc1);
1122 TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
1123 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
1124 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
1125 TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle,
1126 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
1127 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
1128 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
1130 /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
1131 /* specified. It then creates it's own version of the EDIT control */
1132 /* and makes the ComboBox the parent. This is because a normal */
1133 /* DROPDOWNLIST does not have a EDIT control, but we need one. */
1134 /* We also need to place the edit control at the proper location */
1135 /* (allow space for the icons). */
1137 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
1138 /* following line added to match native */
1139 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
1140 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
1141 /* was base and is necessary */
1142 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
1143 cs->y, cs->x, cs->cx, cs->cy, hwnd,
1144 (HMENU) GetWindowLongA (hwnd, GWL_ID),
1145 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
1148 * native does the following at this point according to trace:
1149 * GetWindowThreadProcessId(hwndCombo,0)
1150 * GetCurrentThreadId()
1151 * GetWindowThreadProcessId(hwndCombo, &???)
1152 * GetCurrentProcessId()
1156 * Setup a property to hold the pointer to the COMBOBOXEX
1159 test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo);
1160 if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
1161 SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
1163 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo,
1164 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
1165 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1169 * Now create our own EDIT control so we can position it.
1170 * It is created only for CBS_DROPDOWN style
1172 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
1173 infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
1174 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
1175 0, 0, 0, 0, /* will set later */
1177 (HMENU) GetWindowLongA (hwnd, GWL_ID),
1178 GetWindowLongA (hwnd, GWL_HINSTANCE),
1181 /* native does the following at this point according to trace:
1182 * GetWindowThreadProcessId(hwndEdit,0)
1183 * GetCurrentThreadId()
1184 * GetWindowThreadProcessId(hwndEdit, &???)
1185 * GetCurrentProcessId()
1189 * Setup a property to hold the pointer to the COMBOBOXEX
1192 test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
1193 if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
1194 SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
1196 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
1197 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
1198 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1201 infoPtr->hwndEdit = 0;
1206 * Locate the default font if necessary and then set it in
1207 * all associated controls
1209 if (!infoPtr->font) {
1210 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
1212 infoPtr->font = CreateFontIndirectA (&mylogfont);
1214 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1215 if (infoPtr->hwndEdit) {
1216 SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1217 SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
1220 COMBOEX_ReSize (hwnd, infoPtr);
1222 /* Above is fairly certain, below is much less certain. */
1224 GetWindowRect(hwnd, &wnrc1);
1225 GetClientRect(hwnd, &clrc1);
1226 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1227 TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) CB wnd=(%d,%d)-(%d,%d)\n",
1228 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
1229 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
1230 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1231 SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
1232 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
1233 SWP_NOACTIVATE | SWP_NOREDRAW);
1235 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1236 TRACE("CB window=(%d,%d)-(%d,%d)\n",
1237 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1238 SetWindowPos(hwnd, HWND_TOP,
1239 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
1240 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
1242 COMBOEX_AdjustEditPos (infoPtr);
1245 * Create an item structure to represent the data in the
1248 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
1250 item->pszText = NULL;
1252 infoPtr->edit = item;
1258 inline static LRESULT
1259 COMBOEX_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
1262 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1263 INT command = HIWORD(wParam);
1264 CBE_ITEMDATA *item = 0;
1266 INT cursel, n, oldItem;
1267 NMCBEENDEDITW cbeend;
1270 TRACE("for command %d\n", command);
1275 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1278 * from native trace of first dropdown after typing in URL in IE4
1279 * CB_GETCURSEL(Combo)
1280 * GetWindowText(Edit)
1281 * CB_GETCURSEL(Combo)
1282 * CB_GETCOUNT(Combo)
1283 * CB_GETITEMDATA(Combo, n)
1284 * WM_NOTIFY(parent, CBEN_ENDEDITA|W)
1285 * CB_GETCURSEL(Combo)
1286 * CB_SETCURSEL(COMBOEX, n)
1288 * the rest is supposition
1290 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1292 /* find match from edit against those in Combobox */
1293 GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
1294 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
1295 for (cursel = 0; cursel < n; cursel++){
1296 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1299 if ((INT)item == CB_ERR) break;
1300 if (lstrcmpiW(item->pszText, wintext) == 0) break;
1302 if ((cursel == n) || ((INT)item == CB_ERR)) {
1303 TRACE("failed to find match??? item=%p cursel=%d\n",
1305 if (infoPtr->hwndEdit)
1306 SetFocus(infoPtr->hwndEdit);
1311 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1314 if ((INT)item == CB_ERR) {
1315 TRACE("failed to find match??? item=%p cursel=%d\n",
1317 if (infoPtr->hwndEdit)
1318 SetFocus(infoPtr->hwndEdit);
1323 /* Save flags for testing and reset them */
1324 oldflags = infoPtr->flags;
1325 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1327 if (oldflags & WCBE_ACTEDIT) {
1328 cbeend.fChanged = (oldflags & WCBE_EDITCHG);
1329 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1330 CB_GETCURSEL, 0, 0);
1331 cbeend.iWhy = CBENF_DROPDOWN;
1333 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) {
1334 /* abort the change */
1335 TRACE("Notify requested abort of change\n");
1340 /* if selection has changed the set the new current selection */
1341 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1342 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
1343 infoPtr->selected = cursel;
1344 SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
1345 SetFocus(infoPtr->hwndCombo);
1351 * CB_GETCURSEL(Combo)
1352 * CB_GETITEMDATA(Combo) < simulated by COMBOEX_FindItem
1355 * WM_GETTEXTLENGTH(Edit)
1357 * EM_SETSEL(Edit, 0,0)
1358 * WM_GETTEXTLENGTH(Edit)
1360 * EM_SETSEL(Edit, 0,len)
1361 * return WM_COMMAND to parent
1363 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1364 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1365 ERR("item %d not found. Problem!\n", oldItem);
1368 infoPtr->selected = oldItem;
1369 COMBOEX_SetEditText (infoPtr, item);
1370 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1375 * We have to change the handle since we are the control
1376 * issuing the message. IE4 depends on this.
1378 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1383 * from native trace:
1386 * WM_GETTEXT(Edit, 104)
1387 * CB_GETCURSEL(Combo) rets -1
1388 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1389 * CB_GETCURSEL(Combo)
1390 * InvalidateRect(Combo, 0, 0)
1393 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1395 if (infoPtr->flags & WCBE_ACTEDIT) {
1396 GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
1397 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1398 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1399 CB_GETCURSEL, 0, 0);
1400 cbeend.iWhy = CBENF_KILLFOCUS;
1402 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1403 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) {
1404 /* abort the change */
1405 TRACE("Notify requested abort of change\n");
1409 /* possible CB_GETCURSEL */
1410 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1416 * We have to change the handle since we are the control
1417 * issuing the message. IE4 depends on this.
1418 * We also need to set the focus back to the Edit control
1419 * after passing the command to the parent of the ComboEx.
1421 lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
1423 if (infoPtr->hwndEdit)
1424 SetFocus(infoPtr->hwndEdit);
1431 inline static LRESULT
1432 COMBOEX_WM_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1434 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1435 DELETEITEMSTRUCT *dis = (DELETEITEMSTRUCT *)lParam;
1436 CBE_ITEMDATA *item, *olditem;
1438 NMCOMBOBOXEXW nmcit;
1440 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
1441 dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
1443 if (dis->itemID >= infoPtr->nb_items) return FALSE;
1445 olditem = infoPtr->items;
1446 i = infoPtr->nb_items - 1;
1448 if (i == dis->itemID) {
1449 infoPtr->items = infoPtr->items->next;
1455 /* find the prior item in the list */
1456 while (item->next && (i > dis->itemID)) {
1457 item = (CBE_ITEMDATA *)item->next;
1460 if (!item->next || (i != dis->itemID)) {
1461 FIXME("COMBOBOXEX item structures broken. Please report!\n");
1464 olditem = item->next;
1465 item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
1467 infoPtr->nb_items--;
1469 COMBOEX_CopyItem (infoPtr, olditem, &nmcit.ceItem);
1470 COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit);
1472 if (olditem->pszText)
1473 COMCTL32_Free(olditem->pszText);
1474 COMCTL32_Free(olditem);
1481 inline static LRESULT
1482 COMBOEX_DrawItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1484 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1485 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
1486 CBE_ITEMDATA *item = 0;
1490 int drawimage, drawstate;
1492 UINT xioff = 0; /* size and spacer of image if any */
1495 COLORREF nbkc, ntxc;
1497 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
1499 /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
1500 if (!TRACE_ON(message)) {
1501 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
1502 dis->CtlType, dis->CtlID);
1503 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
1504 dis->itemID, dis->itemAction, dis->itemState);
1505 TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
1506 dis->hwndItem, dis->hDC, dis->rcItem.left,
1507 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
1512 /* "itemID - Specifies the menu item identifier for a menu */
1513 /* item or the index of the item in a list box or combo box. */
1514 /* For an empty list box or combo box, this member can be -1. */
1515 /* This allows the application to draw only the focus */
1516 /* rectangle at the coordinates specified by the rcItem */
1517 /* member even though there are no items in the control. */
1518 /* This indicates to the user whether the list box or combo */
1519 /* box has the focus. How the bits are set in the itemAction */
1520 /* member determines whether the rectangle is to be drawn as */
1521 /* though the list box or combo box has the focus. */
1522 if (dis->itemID == 0xffffffff) {
1523 if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
1524 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
1526 TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
1527 dis->rcItem.left, dis->rcItem.top,
1528 dis->rcItem.right, dis->rcItem.bottom);
1530 else if ((dis->CtlType == ODT_COMBOBOX) &&
1531 (dis->itemAction == ODA_DRAWENTIRE)) {
1532 /* draw of edit control data */
1536 RECT exrc, cbrc, edrc;
1537 GetWindowRect (hwnd, &exrc);
1538 GetWindowRect (infoPtr->hwndCombo, &cbrc);
1539 edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
1540 if (infoPtr->hwndEdit)
1541 GetWindowRect (infoPtr->hwndEdit, &edrc);
1542 TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
1543 exrc.left, exrc.top, exrc.right, exrc.bottom,
1544 cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
1545 edrc.left, edrc.top, edrc.right, edrc.bottom);
1549 ERR("NOT drawing item -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
1550 dis->rcItem.left, dis->rcItem.top,
1551 dis->rcItem.right, dis->rcItem.bottom,
1552 dis->itemAction, dis->itemState);
1557 /* If draw item is -1 (edit control) setup the item pointer */
1558 if (dis->itemID == 0xffffffff) {
1562 item = infoPtr->edit;
1564 if (infoPtr->hwndEdit) {
1566 /* free previous text of edit item */
1567 if (item->pszText) {
1568 COMCTL32_Free(item->pszText);
1570 item->mask &= ~CBEIF_TEXT;
1572 alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
1573 TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
1574 infoPtr->hwndEdit, alen, str);
1576 item->mask |= CBEIF_TEXT;
1577 wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
1579 item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
1580 MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
1586 /* if the item pointer is not set, then get the data and locate it */
1588 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
1589 CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
1590 if (item == (CBE_ITEMDATA *)CB_ERR)
1592 FIXME("invalid item for id %d \n",dis->itemID);
1597 COMBOEX_DumpItem (item);
1599 xbase = CBE_STARTOFFSET;
1600 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX))
1601 xbase += (item->iIndent * CBE_INDENT);
1602 if (item->mask & CBEIF_IMAGE) {
1603 ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
1604 xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
1607 switch (dis->itemAction) {
1609 if (dis->itemState & ODS_SELECTED /*1*/) {
1610 if ((item->mask & CBEIF_TEXT) && item->pszText) {
1613 len = strlenW (item->pszText);
1614 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
1615 rect.left = xbase + xioff - 1;
1616 rect.right = rect.left + txtsize.cx + 2;
1617 rect.top = dis->rcItem.top;
1618 rect.bottom = dis->rcItem.bottom;
1619 GetClipBox (dis->hDC, &rect2);
1620 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
1621 dis->itemID, rect.left, rect.top,
1622 rect.right, rect.bottom);
1623 TRACE(" clip=(%d,%d)-(%d,%d)\n",
1624 rect2.left, rect2.top,
1625 rect2.right, rect2.bottom);
1627 DrawFocusRect(dis->hDC, &rect);
1630 FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
1634 FIXME("ODA_FOCUS but not ODS_SELECTED\n");
1638 case ODA_DRAWENTIRE:
1640 drawstate = ILD_NORMAL;
1641 if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
1642 if (item->mask & CBEIF_IMAGE)
1643 drawimage = item->iImage;
1644 if (dis->itemState & ODS_COMBOEXLBOX) {
1645 /* drawing listbox entry */
1646 if (dis->itemState & ODS_SELECTED) {
1647 if (item->mask & CBEIF_SELECTEDIMAGE)
1648 drawimage = item->iSelectedImage;
1649 drawstate = ILD_SELECTED;
1653 /* drawing combo/edit entry */
1654 if (infoPtr->hwndEdit) {
1655 /* if we have an edit control, the slave the
1656 * selection state to the Edit focus state
1658 if (infoPtr->flags & WCBE_EDITFOCUSED) {
1659 if (item->mask & CBEIF_SELECTEDIMAGE)
1660 drawimage = item->iSelectedImage;
1661 drawstate = ILD_SELECTED;
1665 /* if we don't have an edit control, use
1666 * the requested state.
1668 if (dis->itemState & ODS_SELECTED) {
1669 if (item->mask & CBEIF_SELECTEDIMAGE)
1670 drawimage = item->iSelectedImage;
1671 drawstate = ILD_SELECTED;
1676 if (drawimage != -1) {
1677 TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
1678 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
1679 xbase, dis->rcItem.top, drawstate);
1682 /* setup pointer to text to be drawn */
1683 if ((item->mask & CBEIF_TEXT) && item->pszText)
1684 str = item->pszText;
1688 /* now draw the text */
1689 len = lstrlenW (str);
1690 GetTextExtentPointW (dis->hDC, str, len, &txtsize);
1691 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1692 COLOR_HIGHLIGHT : COLOR_WINDOW);
1693 SetBkColor (dis->hDC, nbkc);
1694 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1695 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
1696 SetTextColor (dis->hDC, ntxc);
1698 y = dis->rcItem.top +
1699 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
1701 rect.right = x + txtsize.cx;
1702 rect.top = dis->rcItem.top + 1;
1703 rect.bottom = dis->rcItem.bottom - 1;
1704 TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
1705 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1706 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
1707 &rect, str, len, 0);
1708 if (dis->itemState & ODS_FOCUS) {
1713 TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
1714 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1715 DrawFocusRect (dis->hDC, &rect);
1719 FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
1720 hwnd, wParam, lParam, dis->itemAction);
1728 COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1730 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1732 if (infoPtr->hwndCombo)
1733 DestroyWindow (infoPtr->hwndCombo);
1735 if (infoPtr->edit) {
1736 COMCTL32_Free (infoPtr->edit);
1740 if (infoPtr->items) {
1741 CBE_ITEMDATA *this, *next;
1743 this = infoPtr->items;
1745 next = (CBE_ITEMDATA *)this->next;
1746 if ((this->mask & CBEIF_TEXT) && this->pszText)
1747 COMCTL32_Free (this->pszText);
1748 COMCTL32_Free (this);
1753 DeleteObject (infoPtr->font);
1755 /* free comboex info data */
1756 COMCTL32_Free (infoPtr);
1757 SetWindowLongA (hwnd, 0, 0);
1763 COMBOEX_MeasureItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
1765 /*COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);*/
1766 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
1771 GetTextExtentPointA (hdc, "W", 1, &mysize);
1773 mis->itemHeight = mysize.cy + CBE_EXTRA;
1775 TRACE("adjusted height hwnd=%08x, height=%d\n",
1776 hwnd, mis->itemHeight);
1783 COMBOEX_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1785 /* WARNING: The COMBOEX_INFO structure is not yet created */
1786 DWORD oldstyle, newstyle;
1788 oldstyle = (DWORD)GetWindowLongA (hwnd, GWL_STYLE);
1789 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
1790 if (newstyle != oldstyle) {
1791 TRACE("req style %08lx, reseting style %08lx\n",
1792 oldstyle, newstyle);
1793 SetWindowLongA (hwnd, GWL_STYLE, newstyle);
1800 COMBOEX_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
1802 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1805 if (lParam == NF_REQUERY) {
1806 i = SendMessageA(GetParent (hwnd),
1807 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
1808 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
1809 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
1813 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
1816 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
1821 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1823 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1826 GetWindowRect (hwnd, &rect);
1827 TRACE("my rect (%d,%d)-(%d,%d)\n",
1828 rect.left, rect.top, rect.right, rect.bottom);
1830 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
1831 rect.bottom - rect.top, TRUE);
1833 COMBOEX_AdjustEditPos (infoPtr);
1840 COMBOEX_WindowPosChanging (HWND hwnd, WPARAM wParam, LPARAM lParam)
1842 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
1843 RECT cbx_wrect, cbx_crect, cb_wrect;
1845 WINDOWPOS *wp = (WINDOWPOS *)lParam;
1847 GetWindowRect (hwnd, &cbx_wrect);
1848 GetClientRect (hwnd, &cbx_crect);
1849 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1851 /* width is winpos value + border width of comboex */
1853 + (cbx_wrect.right-cbx_wrect.left)
1854 - (cbx_crect.right-cbx_crect.left);
1856 TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
1857 wp->x, wp->y, wp->cx, wp->cy, wp->flags);
1858 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
1859 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
1860 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
1861 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
1862 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
1863 width, cb_wrect.bottom-cb_wrect.top);
1865 if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
1867 cb_wrect.bottom-cb_wrect.top,
1870 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1872 /* height is combo window height plus border width of comboex */
1873 height = (cb_wrect.bottom-cb_wrect.top)
1874 + (cbx_wrect.bottom-cbx_wrect.top)
1875 - (cbx_crect.bottom-cbx_crect.top);
1876 if (wp->cy < height) wp->cy = height;
1877 if (infoPtr->hwndEdit) {
1878 COMBOEX_AdjustEditPos (infoPtr);
1879 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1886 static LRESULT WINAPI
1887 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1889 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
1890 NMCBEENDEDITW cbeend;
1891 WCHAR edit_text[260];
1892 COLORREF nbkc, obkc;
1897 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1898 hwnd, uMsg, wParam, lParam, infoPtr);
1900 if (!infoPtr) return 0;
1906 /* handle (ignore) the return character */
1907 if (wParam == VK_RETURN) return 0;
1908 /* all other characters pass into the real Edit */
1909 return CallWindowProcA (infoPtr->prevEditWndProc,
1910 hwnd, uMsg, wParam, lParam);
1914 * The following was determined by traces of the native
1917 nbkc = GetSysColor (COLOR_WINDOW);
1918 obkc = SetBkColor (hDC, nbkc);
1919 GetClientRect (hwnd, &rect);
1920 TRACE("erasing (%d,%d)-(%d,%d)\n",
1921 rect.left, rect.top, rect.right, rect.bottom);
1922 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1923 SetBkColor (hDC, obkc);
1924 return CallWindowProcA (infoPtr->prevEditWndProc,
1925 hwnd, uMsg, wParam, lParam);
1928 INT oldItem, selected;
1931 switch ((INT)wParam)
1934 /* native version seems to do following for COMBOEX */
1936 * GetWindowTextA(Edit,&?, 0x104) x
1937 * CB_GETCURSEL to Combo rets -1 x
1938 * WM_NOTIFY to COMBOEX parent (rebar) x
1939 * (CBEN_ENDEDIT{A|W}
1940 * fChanged = FALSE x
1941 * inewSelection = -1 x
1944 * CB_GETCURSEL to Combo rets -1 x
1945 * InvalidateRect(Combo, 0) x
1946 * WM_SETTEXT to Edit x
1947 * EM_SETSEL to Edit (0,0) x
1948 * EM_SETSEL to Edit (0,-1) x
1949 * RedrawWindow(Combo, 0, 0, 5) x
1951 TRACE("special code for VK_ESCAPE\n");
1953 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1955 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1956 cbeend.fChanged = FALSE;
1957 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1958 CB_GETCURSEL, 0, 0);
1959 cbeend.iWhy = CBENF_ESCAPE;
1961 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
1962 /* abort the change */
1963 TRACE("Notify requested abort of change\n");
1966 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1967 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1968 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1969 ERR("item %d not found. Problem!\n", oldItem);
1972 infoPtr->selected = oldItem;
1973 COMBOEX_SetEditText (infoPtr, item);
1974 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1979 /* native version seems to do following for COMBOEX */
1981 * GetWindowTextA(Edit,&?, 0x104) x
1982 * CB_GETCURSEL to Combo rets -1 x
1983 * CB_GETCOUNT to Combo rets 0
1985 * CB_GETITEMDATA to match
1986 * *** above 3 lines simulated by FindItem x
1987 * WM_NOTIFY to COMBOEX parent (rebar) x
1988 * (CBEN_ENDEDIT{A|W} x
1989 * fChanged = TRUE (-1) x
1990 * iNewSelection = -1 or selected x
1992 * iWhy = 2 (CBENF_RETURN) x
1993 * CB_GETCURSEL to Combo rets -1 x
1994 * if -1 send CB_SETCURSEL to Combo -1 x
1995 * InvalidateRect(Combo, 0, 0) x
1997 * CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
2000 TRACE("special code for VK_RETURN\n");
2002 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2004 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
2005 selected = SendMessageW (infoPtr->hwndCombo,
2006 CB_GETCURSEL, 0, 0);
2008 if (selected != -1) {
2009 item = COMBOEX_FindItem (infoPtr, selected);
2010 TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
2011 selected, debugstr_w(item->pszText));
2012 TRACE("handling VK_RETURN, edittext=%s\n",
2013 debugstr_w(edit_text));
2014 if (lstrcmpiW (item->pszText, edit_text)) {
2015 /* strings not equal -- indicate edit has changed */
2020 cbeend.iNewSelection = selected;
2021 cbeend.fChanged = TRUE;
2022 cbeend.iWhy = CBENF_RETURN;
2023 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
2024 /* abort the change, restore previous */
2025 TRACE("Notify requested abort of change\n");
2026 COMBOEX_SetEditText (infoPtr, infoPtr->edit);
2027 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
2031 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
2032 if (oldItem != -1) {
2033 /* if something is selected, then deselect it */
2034 SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
2037 InvalidateRect (infoPtr->hwndCombo, 0, 0);
2038 SetFocus(infoPtr->hwndEdit);
2042 return CallWindowProcA (infoPtr->prevEditWndProc,
2043 hwnd, uMsg, wParam, lParam);
2049 /* remember the focus to set state of icon */
2050 lret = CallWindowProcA (infoPtr->prevEditWndProc,
2051 hwnd, uMsg, wParam, lParam);
2052 infoPtr->flags |= WCBE_EDITFOCUSED;
2057 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
2059 infoPtr->flags &= ~WCBE_EDITFOCUSED;
2060 if (infoPtr->flags & WCBE_ACTEDIT) {
2061 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
2063 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2064 cbeend.fChanged = FALSE;
2065 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
2066 CB_GETCURSEL, 0, 0);
2067 cbeend.iWhy = CBENF_KILLFOCUS;
2069 COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
2074 return CallWindowProcA (infoPtr->prevEditWndProc,
2075 hwnd, uMsg, wParam, lParam);
2081 static LRESULT WINAPI
2082 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2084 COMBOEX_INFO *infoPtr = (COMBOEX_INFO *)GetPropA (hwnd, (LPCSTR)(LONG) ComboExInfo);
2085 NMCBEENDEDITW cbeend;
2087 COLORREF nbkc, obkc;
2091 WCHAR edit_text[260];
2093 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
2094 hwnd, uMsg, wParam, lParam, infoPtr);
2096 if (!infoPtr) return 0;
2101 case CB_FINDSTRINGEXACT:
2102 return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
2106 * The only way this message should come is from the
2107 * child Listbox issuing the message. Flag this so
2108 * that ComboEx knows this is listbox.
2110 ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
2111 return CallWindowProcA (infoPtr->prevComboWndProc,
2112 hwnd, uMsg, wParam, lParam);
2116 * The following was determined by traces of the native
2119 nbkc = GetSysColor (COLOR_WINDOW);
2120 obkc = SetBkColor (hDC, nbkc);
2121 GetClientRect (hwnd, &rect);
2122 TRACE("erasing (%d,%d)-(%d,%d)\n",
2123 rect.left, rect.top, rect.right, rect.bottom);
2124 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
2125 SetBkColor (hDC, obkc);
2126 return CallWindowProcA (infoPtr->prevComboWndProc,
2127 hwnd, uMsg, wParam, lParam);
2131 * WM_NOTIFY to comboex parent (rebar)
2132 * with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
2133 * CallWindowProc (previous)
2135 nmmse.dwItemSpec = 0;
2136 nmmse.dwItemData = 0;
2139 nmmse.dwHitInfo = lParam;
2140 COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
2141 return CallWindowProcA (infoPtr->prevComboWndProc,
2142 hwnd, uMsg, wParam, lParam);
2145 switch (HIWORD(wParam)) {
2148 /* traces show that COMBOEX does not issue CBN_EDITUPDATE
2157 * GetFocus() retns AA
2158 * GetWindowTextA(Edit)
2159 * CB_GETCURSEL(Combo) (got -1)
2160 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
2161 * CB_GETCURSEL(Combo) (got -1)
2162 * InvalidateRect(Combo, 0, 0)
2163 * WM_KILLFOCUS(Combo, AA)
2166 focusedhwnd = GetFocus();
2167 if (infoPtr->flags & WCBE_ACTEDIT) {
2168 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2169 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
2170 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
2171 CB_GETCURSEL, 0, 0);
2172 cbeend.iWhy = CBENF_KILLFOCUS;
2174 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
2175 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
2176 /* abort the change */
2177 TRACE("Notify requested abort of change\n");
2181 /* possible CB_GETCURSEL */
2182 InvalidateRect (infoPtr->hwndCombo, 0, 0);
2184 SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
2185 (WPARAM)focusedhwnd, 0);
2190 * For EN_SETFOCUS this issues the same calls and messages
2191 * as the native seems to do.
2193 * for some cases however native does the following:
2194 * (noticed after SetFocus during LBUTTONDOWN on
2195 * on dropdown arrow)
2196 * WM_GETTEXTLENGTH (Edit);
2197 * WM_GETTEXT (Edit, len+1, str);
2198 * EM_SETSEL (Edit, 0, 0);
2199 * WM_GETTEXTLENGTH (Edit);
2200 * WM_GETTEXT (Edit, len+1, str);
2201 * EM_SETSEL (Edit, 0, len);
2202 * WM_NOTIFY (parent, CBEN_BEGINEDIT)
2206 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
2207 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
2208 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
2209 infoPtr->flags |= WCBE_ACTEDIT;
2210 infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
2216 * For EN_CHANGE this issues the same calls and messages
2217 * as the native seems to do.
2219 WCHAR edit_text[260];
2224 selected = SendMessageW (infoPtr->hwndCombo,
2225 CB_GETCURSEL, 0, 0);
2227 /* lstrlenA( lastworkingURL ) */
2229 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2230 if (selected == -1) {
2231 lastwrk = infoPtr->edit->pszText;
2232 cnt = lstrlenW (lastwrk);
2233 if (cnt >= 259) cnt = 259;
2236 item = COMBOEX_FindItem (infoPtr, selected);
2237 cnt = lstrlenW (item->pszText);
2238 lastwrk = item->pszText;
2239 if (cnt >= 259) cnt = 259;
2242 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
2243 selected, debugstr_w(lastwrk));
2244 TRACE("handling EN_CHANGE, edittext=%s\n",
2245 debugstr_w(edit_text));
2247 /* lstrcmpiW is between lastworkingURL and GetWindowText */
2249 if (lstrcmpiW (lastwrk, edit_text)) {
2250 /* strings not equal -- indicate edit has changed */
2251 infoPtr->flags |= WCBE_EDITCHG;
2253 SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
2254 MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
2262 * Therefore from traces there is no additional code here
2266 * Using native COMCTL32 gets the following:
2267 * 1 == SHDOCVW.DLL issues call/message
2268 * 2 == COMCTL32.DLL issues call/message
2269 * 3 == WINE issues call/message
2272 * for LBN_SELCHANGE:
2273 * 1 CB_GETCURSEL(ComboEx)
2274 * 1 CB_GETDROPPEDSTATE(ComboEx)
2275 * 1 CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
2276 * 2 CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
2277 ** call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
2278 * 3 WM_COMMAND(ComboEx, CBN_SELENDOK)
2279 * WM_USER+49(ComboLB, 1,0) <=============!!!!!!!!!!!
2280 * 3 ShowWindow(ComboLB, SW_HIDE)
2281 * 3 RedrawWindow(Combo, RDW_UPDATENOW)
2282 * 3 WM_COMMAND(ComboEX, CBN_CLOSEUP)
2284 * 3 WM_COMMAND(ComboEx, CBN_SELCHANGE) (echo to parent)
2285 * ? LB_GETCURSEL <==|
2287 * ? LB_GETTEXT | Needs to be added to
2288 * ? WM_CTLCOLOREDIT(ComboEx) | Combo processing
2289 * ? LB_GETITEMDATA |
2290 * ? WM_DRAWITEM(ComboEx) <==|
2296 return CallWindowProcA (infoPtr->prevComboWndProc,
2297 hwnd, uMsg, wParam, lParam);
2303 static LRESULT WINAPI
2304 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2306 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
2308 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2310 if (!COMBOEX_GetInfoPtr (hwnd)) {
2311 if (uMsg == WM_CREATE)
2312 return COMBOEX_Create (hwnd, wParam, lParam);
2313 if (uMsg == WM_NCCREATE)
2314 COMBOEX_NCCreate (hwnd, wParam, lParam);
2315 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2320 case CBEM_DELETEITEM: /* maps to CB_DELETESTRING */
2321 return COMBOEX_DeleteItem (hwnd, wParam, lParam);
2323 case CBEM_GETCOMBOCONTROL:
2324 return COMBOEX_GetComboControl (hwnd, wParam, lParam);
2326 case CBEM_GETEDITCONTROL:
2327 return COMBOEX_GetEditControl (hwnd, wParam, lParam);
2329 case CBEM_GETEXTENDEDSTYLE:
2330 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
2332 case CBEM_GETIMAGELIST:
2333 return COMBOEX_GetImageList (hwnd, wParam, lParam);
2336 return COMBOEX_GetItemA (hwnd, wParam, lParam);
2339 return COMBOEX_GetItemW (hwnd, wParam, lParam);
2341 case CBEM_GETUNICODEFORMAT:
2342 return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
2344 case CBEM_HASEDITCHANGED:
2345 return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
2347 case CBEM_INSERTITEMA:
2348 return COMBOEX_InsertItemA (hwnd, wParam, lParam);
2350 case CBEM_INSERTITEMW:
2351 return COMBOEX_InsertItemW (hwnd, wParam, lParam);
2353 case CBEM_SETEXSTYLE: /* FIXME: obsoleted, should be the same as: */
2354 case CBEM_SETEXTENDEDSTYLE:
2355 return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
2357 case CBEM_SETIMAGELIST:
2358 return COMBOEX_SetImageList (hwnd, wParam, lParam);
2361 return COMBOEX_SetItemA (hwnd, wParam, lParam);
2364 return COMBOEX_SetItemW (hwnd, wParam, lParam);
2366 case CBEM_SETUNICODEFORMAT:
2367 return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
2370 /* Combo messages we are not sure if we need to process or just forward */
2371 case CB_GETDROPPEDCONTROLRECT:
2372 case CB_GETITEMHEIGHT:
2374 case CB_GETLBTEXTLEN:
2375 case CB_GETEXTENDEDUI:
2377 case CB_RESETCONTENT:
2378 case CB_SELECTSTRING:
2381 FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
2382 uMsg, wParam, lParam);
2383 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
2385 /* Combo messages OK to just forward to the regular COMBO */
2388 case CB_GETDROPPEDSTATE:
2389 case CB_SETDROPPEDWIDTH:
2390 case CB_SETEXTENDEDUI:
2391 case CB_SHOWDROPDOWN:
2392 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
2394 /* Combo messages we need to process specially */
2395 case CB_FINDSTRINGEXACT:
2396 return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
2399 case CB_GETITEMDATA:
2400 return COMBOEX_GetItemData (hwnd, wParam, lParam);
2403 return COMBOEX_SetCursel (hwnd, wParam, lParam);
2405 case CB_SETITEMDATA:
2406 return COMBOEX_SetItemData (hwnd, wParam, lParam);
2408 case CB_SETITEMHEIGHT:
2409 return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
2413 /* Window messages passed to parent */
2415 return COMBOEX_Command (hwnd, wParam, lParam);
2418 if (infoPtr->NtfUnicode)
2419 return SendMessageW (GetParent (hwnd),
2420 uMsg, wParam, lParam);
2422 return SendMessageA (GetParent (hwnd),
2423 uMsg, wParam, lParam);
2426 /* Window messages we need to process */
2428 return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
2431 return COMBOEX_DrawItem (hwnd, wParam, lParam);
2434 return COMBOEX_Destroy (hwnd, wParam, lParam);
2436 case WM_MEASUREITEM:
2437 return COMBOEX_MeasureItem (hwnd, wParam, lParam);
2439 case WM_NOTIFYFORMAT:
2440 return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
2443 return COMBOEX_Size (hwnd, wParam, lParam);
2445 case WM_WINDOWPOSCHANGING:
2446 return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
2449 if (uMsg >= WM_USER)
2450 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2451 uMsg, wParam, lParam);
2452 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2459 COMBOEX_Register (void)
2463 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2464 wndClass.style = CS_GLOBALCLASS;
2465 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
2466 wndClass.cbClsExtra = 0;
2467 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
2468 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
2469 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2470 wndClass.lpszClassName = WC_COMBOBOXEXA;
2472 RegisterClassA (&wndClass);
2474 ComboExInfo = GlobalAddAtomA("CC32SubclassInfo");
2479 COMBOEX_Unregister (void)
2481 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);