cryptnet: Implement getting the certificate issuer URL from a cert's authority info...
[wine/multimedia.git] / dlls / comctl32 / comboex.c
bloba2361fdda40032a22387ddfcaad4e7c078208f0d
1 /*
2 * ComboBoxEx control
4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 2000, 2001, 2002 Guy Albertelli <galberte@neo.lrun.com>
6 * Copyright 2002 Dimitrie O. Paun
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * NOTE
24 * This code was audited for completeness against the documented features
25 * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
27 * Unless otherwise noted, we believe this code to be complete, as per
28 * the specification mentioned above.
29 * If you discover missing features, or bugs, please note them below.
33 #include <stdarg.h>
34 #include <string.h>
35 #include "windef.h"
36 #include "winbase.h"
37 #include "wingdi.h"
38 #include "winuser.h"
39 #include "winnls.h"
40 #include "commctrl.h"
41 #include "comctl32.h"
42 #include "wine/debug.h"
43 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(comboex);
47 /* Item structure */
48 typedef struct _CBE_ITEMDATA
50 struct _CBE_ITEMDATA *next;
51 UINT mask;
52 LPWSTR pszText;
53 LPWSTR pszTemp;
54 int cchTextMax;
55 int iImage;
56 int iSelectedImage;
57 int iOverlay;
58 int iIndent;
59 LPARAM lParam;
60 } CBE_ITEMDATA;
62 /* ComboBoxEx structure */
63 typedef struct
65 HIMAGELIST himl;
66 HWND hwndSelf; /* my own hwnd */
67 HWND hwndNotify; /* my parent hwnd */
68 HWND hwndCombo;
69 HWND hwndEdit;
70 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */
71 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */
72 DWORD dwExtStyle;
73 INT selected; /* index of selected item */
74 DWORD flags; /* WINE internal flags */
75 HFONT defaultFont;
76 HFONT font;
77 INT nb_items; /* Number of items */
78 BOOL unicode; /* TRUE if this window is Unicode */
79 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */
80 CBE_ITEMDATA *edit; /* item data for edit item */
81 CBE_ITEMDATA *items; /* Array of items */
82 } COMBOEX_INFO;
84 /* internal flags in the COMBOEX_INFO structure */
85 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e.
86 * CBEN_BEGINEDIT issued
87 * but CBEN_ENDEDIT{A|W}
88 * not yet issued. */
89 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */
90 #define WCBE_EDITHASCHANGED (WCBE_ACTEDIT | WCBE_EDITCHG)
91 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */
92 #define WCBE_MOUSECAPTURED 0x00000008 /* Combo has captured mouse */
93 #define WCBE_MOUSEDRAGGED 0x00000010 /* User has dragged in combo */
95 #define ID_CB_EDIT 1001
99 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
100 * the ComboEx version of the Combo Window Proc so that when the
101 * WM_DRAWITEM message is then passed to ComboEx, we know that this
102 * particular WM_DRAWITEM message is for listbox only items. Any messasges
103 * without this flag is then for the Edit control field.
105 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
106 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
108 #define ODS_COMBOEXLBOX 0x4000
112 /* Height in pixels of control over the amount of the selected font */
113 #define CBE_EXTRA 3
115 /* Indent amount per MS documentation */
116 #define CBE_INDENT 10
118 /* Offset in pixels from left side for start of image or text */
119 #define CBE_STARTOFFSET 6
121 /* Offset between image and text */
122 #define CBE_SEP 4
124 static const WCHAR COMBOEX_SUBCLASS_PROP[] = {
125 'C','C','C','o','m','b','o','E','x','3','2',
126 'S','u','b','c','l','a','s','s','I','n','f','o',0
129 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongPtrW (hwnd, 0))
132 /* Things common to the entire DLL */
133 static LRESULT WINAPI COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
134 static LRESULT WINAPI COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
135 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr);
136 typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR);
138 static inline BOOL is_textW(LPCWSTR str)
140 return str && str != LPSTR_TEXTCALLBACKW;
143 static inline BOOL is_textA(LPCSTR str)
145 return str && str != LPSTR_TEXTCALLBACKA;
148 static inline LPCSTR debugstr_txt(LPCWSTR str)
150 if (str == LPSTR_TEXTCALLBACKW) return "(callback)";
151 return debugstr_w(str);
154 static void COMBOEX_DumpItem (CBE_ITEMDATA const *item)
156 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
157 item, item->mask, item->pszText, item->cchTextMax, item->iImage);
158 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
159 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
160 if (item->mask & CBEIF_TEXT)
161 TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText));
165 static void COMBOEX_DumpInput (COMBOBOXEXITEMW const *input)
167 TRACE("input - mask=%08x, iItem=%ld, pszText=%p, cchTM=%d, iImage=%d\n",
168 input->mask, input->iItem, input->pszText, input->cchTextMax,
169 input->iImage);
170 if (input->mask & CBEIF_TEXT)
171 TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText));
172 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
173 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
177 static inline CBE_ITEMDATA *get_item_data(const COMBOEX_INFO *infoPtr, INT index)
179 return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA,
180 (WPARAM)index, 0);
183 static inline cmp_func_t get_cmp_func(COMBOEX_INFO const *infoPtr)
185 return infoPtr->dwExtStyle & CBES_EX_CASESENSITIVE ? lstrcmpW : lstrcmpiW;
188 static INT COMBOEX_Notify (const COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
190 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
191 hdr->hwndFrom = infoPtr->hwndSelf;
192 hdr->code = code;
193 if (infoPtr->NtfUnicode)
194 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)hdr);
195 else
196 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)hdr);
200 static INT
201 COMBOEX_NotifyItem (const COMBOEX_INFO *infoPtr, UINT code, NMCOMBOBOXEXW *hdr)
203 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
204 if (infoPtr->NtfUnicode)
205 return COMBOEX_Notify (infoPtr, code, &hdr->hdr);
206 else {
207 LPWSTR wstr = hdr->ceItem.pszText;
208 LPSTR astr = 0;
209 INT ret, len = 0;
211 if ((hdr->ceItem.mask & CBEIF_TEXT) && is_textW(wstr)) {
212 len = WideCharToMultiByte (CP_ACP, 0, wstr, -1, 0, 0, NULL, NULL);
213 if (len > 0) {
214 astr = Alloc ((len + 1)*sizeof(CHAR));
215 if (!astr) return 0;
216 WideCharToMultiByte (CP_ACP, 0, wstr, -1, astr, len, 0, 0);
217 hdr->ceItem.pszText = (LPWSTR)astr;
221 if (code == CBEN_ENDEDITW) code = CBEN_ENDEDITA;
222 else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA;
223 else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA;
225 ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr);
227 if (astr && hdr->ceItem.pszText == (LPWSTR)astr)
228 hdr->ceItem.pszText = wstr;
230 Free(astr);
232 return ret;
237 static INT COMBOEX_NotifyEndEdit (const COMBOEX_INFO *infoPtr, NMCBEENDEDITW *neew, LPCWSTR wstr)
239 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
240 if (infoPtr->NtfUnicode) {
241 lstrcpynW(neew->szText, wstr, CBEMAXSTRLEN);
242 return COMBOEX_Notify (infoPtr, CBEN_ENDEDITW, &neew->hdr);
243 } else {
244 NMCBEENDEDITA neea;
246 neea.hdr = neew->hdr;
247 neea.fChanged = neew->fChanged;
248 neea.iNewSelection = neew->iNewSelection;
249 WideCharToMultiByte (CP_ACP, 0, wstr, -1, neea.szText, CBEMAXSTRLEN, 0, 0);
250 neea.iWhy = neew->iWhy;
252 return COMBOEX_Notify (infoPtr, CBEN_ENDEDITA, &neea.hdr);
257 static void COMBOEX_NotifyDragBegin(const COMBOEX_INFO *infoPtr, LPCWSTR wstr)
259 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
260 if (infoPtr->NtfUnicode) {
261 NMCBEDRAGBEGINW ndbw;
263 ndbw.iItemid = -1;
264 lstrcpynW(ndbw.szText, wstr, CBEMAXSTRLEN);
265 COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINW, &ndbw.hdr);
266 } else {
267 NMCBEDRAGBEGINA ndba;
269 ndba.iItemid = -1;
270 WideCharToMultiByte (CP_ACP, 0, wstr, -1, ndba.szText, CBEMAXSTRLEN, 0, 0);
272 COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINA, &ndba.hdr);
277 static void COMBOEX_FreeText (CBE_ITEMDATA *item)
279 if (is_textW(item->pszText)) Free(item->pszText);
280 item->pszText = 0;
281 Free(item->pszTemp);
282 item->pszTemp = 0;
286 static INT COMBOEX_GetIndex(COMBOEX_INFO const *infoPtr, CBE_ITEMDATA const *item)
288 CBE_ITEMDATA const *moving;
289 INT index;
291 moving = infoPtr->items;
292 index = infoPtr->nb_items - 1;
294 while (moving && (moving != item)) {
295 moving = moving->next;
296 index--;
298 if (!moving || (index < 0)) {
299 ERR("COMBOBOXEX item structures broken. Please report!\n");
300 return -1;
302 return index;
306 static LPCWSTR COMBOEX_GetText(const COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
308 NMCOMBOBOXEXW nmce;
309 LPWSTR text, buf;
310 INT len;
312 if (item->pszText != LPSTR_TEXTCALLBACKW)
313 return item->pszText;
315 ZeroMemory(&nmce, sizeof(nmce));
316 nmce.ceItem.mask = CBEIF_TEXT;
317 nmce.ceItem.lParam = item->lParam;
318 nmce.ceItem.iItem = COMBOEX_GetIndex(infoPtr, item);
319 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
321 if (is_textW(nmce.ceItem.pszText)) {
322 len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0);
323 buf = Alloc ((len + 1)*sizeof(WCHAR));
324 if (buf)
325 MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len);
326 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) {
327 COMBOEX_FreeText(item);
328 item->pszText = buf;
329 } else {
330 Free(item->pszTemp);
331 item->pszTemp = buf;
333 text = buf;
334 } else
335 text = nmce.ceItem.pszText;
337 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
338 item->pszText = text;
339 return text;
343 static void COMBOEX_GetComboFontSize (const COMBOEX_INFO *infoPtr, SIZE *size)
345 static const WCHAR strA[] = { 'A', 0 };
346 HFONT nfont, ofont;
347 HDC mydc;
349 mydc = GetDC (0); /* why the entire screen???? */
350 nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
351 ofont = SelectObject (mydc, nfont);
352 GetTextExtentPointW (mydc, strA, 1, size);
353 SelectObject (mydc, ofont);
354 ReleaseDC (0, mydc);
355 TRACE("selected font hwnd=%p, height=%d\n", nfont, size->cy);
359 static void COMBOEX_CopyItem (const CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
361 if (cit->mask & CBEIF_TEXT) {
363 * when given a text buffer actually use that buffer
365 if (cit->pszText) {
366 if (is_textW(item->pszText))
367 lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax);
368 else
369 cit->pszText[0] = 0;
370 } else {
371 cit->pszText = item->pszText;
372 cit->cchTextMax = item->cchTextMax;
375 if (cit->mask & CBEIF_IMAGE)
376 cit->iImage = item->iImage;
377 if (cit->mask & CBEIF_SELECTEDIMAGE)
378 cit->iSelectedImage = item->iSelectedImage;
379 if (cit->mask & CBEIF_OVERLAY)
380 cit->iOverlay = item->iOverlay;
381 if (cit->mask & CBEIF_INDENT)
382 cit->iIndent = item->iIndent;
383 if (cit->mask & CBEIF_LPARAM)
384 cit->lParam = item->lParam;
388 static void COMBOEX_AdjustEditPos (const COMBOEX_INFO *infoPtr)
390 SIZE mysize;
391 INT x, y, w, h, xioff;
392 RECT rect;
394 if (!infoPtr->hwndEdit) return;
396 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
397 IMAGEINFO iinfo;
398 iinfo.rcImage.left = iinfo.rcImage.right = 0;
399 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
400 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
401 } else xioff = 0;
403 GetClientRect (infoPtr->hwndCombo, &rect);
404 InflateRect (&rect, -2, -2);
405 InvalidateRect (infoPtr->hwndCombo, &rect, TRUE);
407 /* reposition the Edit control based on whether icon exists */
408 COMBOEX_GetComboFontSize (infoPtr, &mysize);
409 TRACE("Combo font x=%d, y=%d\n", mysize.cx, mysize.cy);
410 x = xioff + CBE_STARTOFFSET + 1;
411 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
412 h = mysize.cy + 1;
413 y = rect.bottom - h - 1;
415 TRACE("Combo client (%s), setting Edit to (%d,%d)-(%d,%d)\n",
416 wine_dbgstr_rect(&rect), x, y, x + w, y + h);
417 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h,
418 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
422 static void COMBOEX_ReSize (const COMBOEX_INFO *infoPtr)
424 SIZE mysize;
425 LONG cy;
426 IMAGEINFO iinfo;
428 COMBOEX_GetComboFontSize (infoPtr, &mysize);
429 cy = mysize.cy + CBE_EXTRA;
430 if (infoPtr->himl && ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo)) {
431 cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
432 TRACE("upgraded height due to image: height=%d\n", cy);
434 SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, -1, cy);
435 if (infoPtr->hwndCombo) {
436 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, 0, cy);
437 if ( !(infoPtr->flags & CBES_EX_NOSIZELIMIT)) {
438 RECT comboRect;
439 if (GetWindowRect(infoPtr->hwndCombo, &comboRect)) {
440 RECT ourRect;
441 if (GetWindowRect(infoPtr->hwndSelf, &ourRect)) {
442 if (comboRect.bottom > ourRect.bottom) {
443 POINT pt = { ourRect.left, ourRect.top };
444 if (ScreenToClient(infoPtr->hwndSelf, &pt))
445 MoveWindow( infoPtr->hwndSelf, pt.x, pt.y, ourRect.right - ourRect.left,
446 comboRect.bottom - comboRect.top, FALSE);
455 static void COMBOEX_SetEditText (const COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
457 if (!infoPtr->hwndEdit) return;
458 /* native issues the following messages to the {Edit} control */
459 /* WM_SETTEXT (0,addr) */
460 /* EM_SETSEL32 (0,0) */
461 /* EM_SETSEL32 (0,-1) */
462 if (item->mask & CBEIF_TEXT) {
463 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item));
464 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
465 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
470 static CBE_ITEMDATA * COMBOEX_FindItem(const COMBOEX_INFO *infoPtr, INT_PTR index)
472 CBE_ITEMDATA *item;
473 INT i;
475 if ((index >= infoPtr->nb_items) || (index < -1))
476 return 0;
477 if (index == -1)
478 return infoPtr->edit;
479 item = infoPtr->items;
480 i = infoPtr->nb_items - 1;
482 /* find the item in the list */
483 while (item && (i > index)) {
484 item = item->next;
485 i--;
487 if (!item || (i != index)) {
488 ERR("COMBOBOXEX item structures broken. Please report!\n");
489 return 0;
491 return item;
495 static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO const *infoPtr)
497 return infoPtr->hwndEdit ? TRUE : FALSE;
501 /* *** CBEM_xxx message support *** */
503 static UINT COMBOEX_GetListboxText(const COMBOEX_INFO *infoPtr, INT_PTR n, LPWSTR buf)
505 CBE_ITEMDATA *item;
506 LPCWSTR str;
508 item = COMBOEX_FindItem(infoPtr, n);
509 if (!item)
510 return 0;
512 str = COMBOEX_GetText(infoPtr, item);
513 if (!str)
515 if (buf)
517 if (infoPtr->unicode)
518 buf[0] = 0;
519 else
520 *((LPSTR)buf) = 0;
522 return 0;
525 if (infoPtr->unicode)
527 if (buf)
528 lstrcpyW(buf, str);
529 return lstrlenW(str);
531 else
533 UINT r;
534 r = WideCharToMultiByte(CP_ACP, 0, str, -1, (LPSTR)buf, 0x40000000, NULL, NULL);
535 if (r) r--;
536 return r;
541 static INT COMBOEX_DeleteItem (const COMBOEX_INFO *infoPtr, INT_PTR index)
543 TRACE("(index=%ld)\n", index);
545 /* if item number requested does not exist then return failure */
546 if ((index >= infoPtr->nb_items) || (index < 0)) return CB_ERR;
547 if (!COMBOEX_FindItem(infoPtr, index)) return CB_ERR;
549 /* doing this will result in WM_DELETEITEM being issued */
550 SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0);
552 return infoPtr->nb_items;
556 static BOOL COMBOEX_GetItemW (const COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
558 INT_PTR index = cit->iItem;
559 CBE_ITEMDATA *item;
561 TRACE("(...)\n");
563 /* if item number requested does not exist then return failure */
564 if ((index >= infoPtr->nb_items) || (index < -1)) return FALSE;
566 /* if the item is the edit control and there is no edit control, skip */
567 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
569 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
571 COMBOEX_CopyItem (item, cit);
573 return TRUE;
577 static BOOL COMBOEX_GetItemA (const COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
579 COMBOBOXEXITEMW tmpcit;
581 TRACE("(...)\n");
583 tmpcit.mask = cit->mask;
584 tmpcit.iItem = cit->iItem;
585 tmpcit.pszText = 0;
586 if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE;
588 if (cit->mask & CBEIF_TEXT)
590 if (is_textW(tmpcit.pszText) && cit->pszText)
591 WideCharToMultiByte(CP_ACP, 0, tmpcit.pszText, -1,
592 cit->pszText, cit->cchTextMax, NULL, NULL);
593 else if (cit->pszText) cit->pszText[0] = 0;
594 else cit->pszText = (LPSTR)tmpcit.pszText;
597 if (cit->mask & CBEIF_IMAGE)
598 cit->iImage = tmpcit.iImage;
599 if (cit->mask & CBEIF_SELECTEDIMAGE)
600 cit->iSelectedImage = tmpcit.iSelectedImage;
601 if (cit->mask & CBEIF_OVERLAY)
602 cit->iOverlay = tmpcit.iOverlay;
603 if (cit->mask & CBEIF_INDENT)
604 cit->iIndent = tmpcit.iIndent;
605 if (cit->mask & CBEIF_LPARAM)
606 cit->lParam = tmpcit.lParam;
608 return TRUE;
612 static inline BOOL COMBOEX_HasEditChanged (COMBOEX_INFO const *infoPtr)
614 return COMBOEX_HasEdit(infoPtr) &&
615 (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED;
619 static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW const *cit)
621 INT_PTR index;
622 CBE_ITEMDATA *item;
623 NMCOMBOBOXEXW nmcit;
625 TRACE("\n");
627 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
629 /* get real index of item to insert */
630 index = cit->iItem;
631 if (index == -1) index = infoPtr->nb_items;
632 if (index > infoPtr->nb_items) return -1;
634 /* get zero-filled space and chain it in */
635 if(!(item = Alloc (sizeof(*item)))) return -1;
637 /* locate position to insert new item in */
638 if (index == infoPtr->nb_items) {
639 /* fast path for iItem = -1 */
640 item->next = infoPtr->items;
641 infoPtr->items = item;
643 else {
644 INT i = infoPtr->nb_items-1;
645 CBE_ITEMDATA *moving = infoPtr->items;
647 while ((i > index) && moving) {
648 moving = moving->next;
649 i--;
651 if (!moving) {
652 ERR("COMBOBOXEX item structures broken. Please report!\n");
653 Free(item);
654 return -1;
656 item->next = moving->next;
657 moving->next = item;
660 /* fill in our hidden item structure */
661 item->mask = cit->mask;
662 if (item->mask & CBEIF_TEXT) {
663 INT len = 0;
665 if (is_textW(cit->pszText)) len = strlenW (cit->pszText);
666 if (len > 0) {
667 item->pszText = Alloc ((len + 1)*sizeof(WCHAR));
668 if (!item->pszText) {
669 Free(item);
670 return -1;
672 strcpyW (item->pszText, cit->pszText);
674 else if (cit->pszText == LPSTR_TEXTCALLBACKW)
675 item->pszText = LPSTR_TEXTCALLBACKW;
676 item->cchTextMax = cit->cchTextMax;
678 if (item->mask & CBEIF_IMAGE)
679 item->iImage = cit->iImage;
680 if (item->mask & CBEIF_SELECTEDIMAGE)
681 item->iSelectedImage = cit->iSelectedImage;
682 if (item->mask & CBEIF_OVERLAY)
683 item->iOverlay = cit->iOverlay;
684 if (item->mask & CBEIF_INDENT)
685 item->iIndent = cit->iIndent;
686 if (item->mask & CBEIF_LPARAM)
687 item->lParam = cit->lParam;
688 infoPtr->nb_items++;
690 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
692 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
693 (WPARAM)cit->iItem, (LPARAM)item);
695 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
696 COMBOEX_CopyItem (item, &nmcit.ceItem);
697 COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit);
699 return index;
704 static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA const *cit)
706 COMBOBOXEXITEMW citW;
707 LPWSTR wstr = NULL;
708 INT ret;
710 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
711 if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) {
712 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
713 wstr = Alloc ((len + 1)*sizeof(WCHAR));
714 if (!wstr) return -1;
715 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
716 citW.pszText = wstr;
718 ret = COMBOEX_InsertItemW(infoPtr, &citW);
720 Free(wstr);
722 return ret;
726 static DWORD
727 COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style)
729 DWORD dwTemp;
731 TRACE("(mask=x%08x, style=0x%08x)\n", mask, style);
733 dwTemp = infoPtr->dwExtStyle;
735 if (mask)
736 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style;
737 else
738 infoPtr->dwExtStyle = style;
740 /* see if we need to change the word break proc on the edit */
741 if ((infoPtr->dwExtStyle ^ dwTemp) & CBES_EX_PATHWORDBREAKPROC)
742 SetPathWordBreakProc(infoPtr->hwndEdit,
743 (infoPtr->dwExtStyle & CBES_EX_PATHWORDBREAKPROC) ? TRUE : FALSE);
745 /* test if the control's appearance has changed */
746 mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT;
747 if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) {
748 /* if state of EX_NOEDITIMAGE changes, invalidate all */
749 TRACE("EX_NOEDITIMAGE state changed to %d\n",
750 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
751 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
752 COMBOEX_AdjustEditPos (infoPtr);
753 if (infoPtr->hwndEdit)
754 InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
757 return dwTemp;
761 static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl)
763 HIMAGELIST himlTemp = infoPtr->himl;
765 TRACE("(...)\n");
767 infoPtr->himl = himl;
769 COMBOEX_ReSize (infoPtr);
770 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
772 /* reposition the Edit control based on whether icon exists */
773 COMBOEX_AdjustEditPos (infoPtr);
774 return himlTemp;
777 static BOOL COMBOEX_SetItemW (const COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
779 INT_PTR index = cit->iItem;
780 CBE_ITEMDATA *item;
782 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
784 /* if item number requested does not exist then return failure */
785 if ((index >= infoPtr->nb_items) || (index < -1)) return FALSE;
787 /* if the item is the edit control and there is no edit control, skip */
788 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
790 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
792 /* add/change stuff to the internal item structure */
793 item->mask |= cit->mask;
794 if (cit->mask & CBEIF_TEXT) {
795 INT len = 0;
797 COMBOEX_FreeText(item);
798 if (is_textW(cit->pszText)) len = strlenW(cit->pszText);
799 if (len > 0) {
800 item->pszText = Alloc ((len + 1)*sizeof(WCHAR));
801 if (!item->pszText) return FALSE;
802 strcpyW(item->pszText, cit->pszText);
803 } else if (cit->pszText == LPSTR_TEXTCALLBACKW)
804 item->pszText = LPSTR_TEXTCALLBACKW;
805 item->cchTextMax = cit->cchTextMax;
807 if (cit->mask & CBEIF_IMAGE)
808 item->iImage = cit->iImage;
809 if (cit->mask & CBEIF_SELECTEDIMAGE)
810 item->iSelectedImage = cit->iSelectedImage;
811 if (cit->mask & CBEIF_OVERLAY)
812 item->iOverlay = cit->iOverlay;
813 if (cit->mask & CBEIF_INDENT)
814 item->iIndent = cit->iIndent;
815 if (cit->mask & CBEIF_LPARAM)
816 cit->lParam = cit->lParam;
818 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
820 /* if original request was to update edit control, do some fast foot work */
821 if (cit->iItem == -1 && cit->mask & CBEIF_TEXT) {
822 COMBOEX_SetEditText (infoPtr, item);
823 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
825 return TRUE;
828 static BOOL COMBOEX_SetItemA (const COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA const *cit)
830 COMBOBOXEXITEMW citW;
831 LPWSTR wstr = NULL;
832 BOOL ret;
834 memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA));
835 if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) {
836 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
837 wstr = Alloc ((len + 1)*sizeof(WCHAR));
838 if (!wstr) return FALSE;
839 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
840 citW.pszText = wstr;
842 ret = COMBOEX_SetItemW(infoPtr, &citW);
844 Free(wstr);
846 return ret;
850 static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value)
852 BOOL bTemp = infoPtr->unicode;
854 TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE");
856 infoPtr->unicode = value;
858 return bTemp;
862 /* *** CB_xxx message support *** */
864 static INT
865 COMBOEX_FindStringExact (const COMBOEX_INFO *infoPtr, INT start, LPCWSTR str)
867 INT i;
868 cmp_func_t cmptext = get_cmp_func(infoPtr);
869 INT count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
871 /* now search from after starting loc and wrapping back to start */
872 for(i=start+1; i<count; i++) {
873 CBE_ITEMDATA *item = get_item_data(infoPtr, i);
874 if ((LRESULT)item == CB_ERR) continue;
875 if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
877 for(i=0; i<=start; i++) {
878 CBE_ITEMDATA *item = get_item_data(infoPtr, i);
879 if ((LRESULT)item == CB_ERR) continue;
880 if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
882 return CB_ERR;
886 static DWORD_PTR COMBOEX_GetItemData (const COMBOEX_INFO *infoPtr, INT_PTR index)
888 CBE_ITEMDATA const *item1;
889 CBE_ITEMDATA const *item2;
890 DWORD_PTR ret = 0;
892 item1 = get_item_data(infoPtr, index);
893 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
894 item2 = COMBOEX_FindItem (infoPtr, index);
895 if (item2 != item1) {
896 ERR("data structures damaged!\n");
897 return CB_ERR;
899 if (item1->mask & CBEIF_LPARAM) ret = item1->lParam;
900 TRACE("returning 0x%08lx\n", ret);
901 } else {
902 ret = (DWORD_PTR)item1;
903 TRACE("non-valid result from combo, returning 0x%08lx\n", ret);
905 return ret;
909 static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT_PTR index)
911 CBE_ITEMDATA *item;
912 INT sel;
914 if (!(item = COMBOEX_FindItem(infoPtr, index)))
915 return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
917 TRACE("selecting item %ld text=%s\n", index, debugstr_txt(item->pszText));
918 infoPtr->selected = index;
920 sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
921 COMBOEX_SetEditText (infoPtr, item);
922 return sel;
926 static DWORD_PTR COMBOEX_SetItemData (const COMBOEX_INFO *infoPtr, INT_PTR index, DWORD_PTR data)
928 CBE_ITEMDATA *item1;
929 CBE_ITEMDATA const *item2;
931 item1 = get_item_data(infoPtr, index);
932 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
933 item2 = COMBOEX_FindItem (infoPtr, index);
934 if (item2 != item1) {
935 ERR("data structures damaged!\n");
936 return CB_ERR;
938 item1->mask |= CBEIF_LPARAM;
939 item1->lParam = data;
940 TRACE("setting lparam to 0x%08lx\n", data);
941 return 0;
943 TRACE("non-valid result from combo %p\n", item1);
944 return (DWORD_PTR)item1;
948 static INT COMBOEX_SetItemHeight (COMBOEX_INFO const *infoPtr, INT index, UINT height)
950 RECT cb_wrect, cbx_wrect, cbx_crect;
952 /* First, lets forward the message to the normal combo control
953 just like Windows. */
954 if (infoPtr->hwndCombo)
955 if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
956 index, height) == CB_ERR) return CB_ERR;
958 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
959 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
960 GetClientRect (infoPtr->hwndSelf, &cbx_crect);
961 /* the height of comboex as height of the combo + comboex border */
962 height = cb_wrect.bottom-cb_wrect.top
963 + cbx_wrect.bottom-cbx_wrect.top
964 - (cbx_crect.bottom-cbx_crect.top);
965 TRACE("EX window=(%s), client=(%s)\n",
966 wine_dbgstr_rect(&cbx_wrect), wine_dbgstr_rect(&cbx_crect));
967 TRACE("CB window=(%s), EX setting=(0,0)-(%d,%d)\n",
968 wine_dbgstr_rect(&cbx_wrect), cbx_wrect.right-cbx_wrect.left, height);
969 SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0,
970 cbx_wrect.right-cbx_wrect.left, height,
971 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
973 return 0;
977 /* *** WM_xxx message support *** */
980 static LRESULT COMBOEX_Create (HWND hwnd, CREATESTRUCTA const *cs)
982 static const WCHAR NIL[] = { 0 };
983 COMBOEX_INFO *infoPtr;
984 LOGFONTW mylogfont;
985 RECT wnrc1, clrc1, cmbwrc;
986 INT i;
988 /* allocate memory for info structure */
989 infoPtr = Alloc (sizeof(COMBOEX_INFO));
990 if (!infoPtr) return -1;
992 /* initialize info structure */
993 /* note that infoPtr is allocated zero-filled */
995 infoPtr->hwndSelf = hwnd;
996 infoPtr->selected = -1;
998 infoPtr->unicode = IsWindowUnicode (hwnd);
999 infoPtr->hwndNotify = cs->hwndParent;
1001 i = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
1002 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
1003 WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
1004 i = NFR_ANSI;
1006 infoPtr->NtfUnicode = (i == NFR_UNICODE);
1008 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
1010 /* create combo box */
1011 GetWindowRect(hwnd, &wnrc1);
1012 GetClientRect(hwnd, &clrc1);
1013 TRACE("EX window=(%s), client=(%s)\n",
1014 wine_dbgstr_rect(&wnrc1), wine_dbgstr_rect(&clrc1));
1016 /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
1017 /* specified. It then creates it's own version of the EDIT control */
1018 /* and makes the ComboBox the parent. This is because a normal */
1019 /* DROPDOWNLIST does not have an EDIT control, but we need one. */
1020 /* We also need to place the edit control at the proper location */
1021 /* (allow space for the icons). */
1023 infoPtr->hwndCombo = CreateWindowW (WC_COMBOBOXW, NIL,
1024 /* following line added to match native */
1025 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
1026 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
1027 /* was base and is necessary */
1028 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED |
1029 GetWindowLongW (hwnd, GWL_STYLE),
1030 cs->y, cs->x, cs->cx, cs->cy, hwnd,
1031 (HMENU) GetWindowLongPtrW (hwnd, GWLP_ID),
1032 (HINSTANCE)GetWindowLongPtrW (hwnd, GWLP_HINSTANCE), NULL);
1035 * native does the following at this point according to trace:
1036 * GetWindowThreadProcessId(hwndCombo,0)
1037 * GetCurrentThreadId()
1038 * GetWindowThreadProcessId(hwndCombo, &???)
1039 * GetCurrentProcessId()
1043 * Setup a property to hold the pointer to the COMBOBOXEX
1044 * data structure.
1046 SetPropW(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd);
1047 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hwndCombo,
1048 GWLP_WNDPROC, (DWORD_PTR)COMBOEX_ComboWndProc);
1049 infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1053 * Now create our own EDIT control so we can position it.
1054 * It is created only for CBS_DROPDOWN style
1056 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
1057 infoPtr->hwndEdit = CreateWindowExW (0, WC_EDITW, NIL,
1058 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
1059 0, 0, 0, 0, /* will set later */
1060 infoPtr->hwndCombo,
1061 (HMENU) GetWindowLongPtrW (hwnd, GWLP_ID),
1062 (HINSTANCE)GetWindowLongPtrW (hwnd, GWLP_HINSTANCE), NULL);
1064 /* native does the following at this point according to trace:
1065 * GetWindowThreadProcessId(hwndEdit,0)
1066 * GetCurrentThreadId()
1067 * GetWindowThreadProcessId(hwndEdit, &???)
1068 * GetCurrentProcessId()
1072 * Setup a property to hold the pointer to the COMBOBOXEX
1073 * data structure.
1075 SetPropW(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd);
1076 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hwndEdit,
1077 GWLP_WNDPROC, (DWORD_PTR)COMBOEX_EditWndProc);
1078 infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1082 * Locate the default font if necessary and then set it in
1083 * all associated controls
1085 if (!infoPtr->font) {
1086 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
1087 &mylogfont, 0);
1088 infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont);
1090 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1091 if (infoPtr->hwndEdit) {
1092 SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1093 SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
1096 COMBOEX_ReSize (infoPtr);
1098 /* Above is fairly certain, below is much less certain. */
1100 GetWindowRect(hwnd, &wnrc1);
1101 GetClientRect(hwnd, &clrc1);
1102 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1103 TRACE("EX window=(%s) client=(%s) CB wnd=(%s)\n",
1104 wine_dbgstr_rect(&wnrc1), wine_dbgstr_rect(&clrc1),
1105 wine_dbgstr_rect(&cmbwrc));
1106 SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
1107 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
1108 SWP_NOACTIVATE | SWP_NOREDRAW);
1110 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1111 TRACE("CB window=(%s)\n", wine_dbgstr_rect(&cmbwrc));
1112 SetWindowPos(hwnd, HWND_TOP,
1113 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
1114 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
1116 COMBOEX_AdjustEditPos (infoPtr);
1119 * Create an item structure to represent the data in the
1120 * EDIT control. It is allocated zero-filled.
1122 infoPtr->edit = Alloc (sizeof (CBE_ITEMDATA));
1123 if (!infoPtr->edit) {
1124 COMBOEX_Destroy(infoPtr);
1125 return -1;
1128 return 0;
1132 static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam)
1134 LRESULT lret;
1135 INT command = HIWORD(wParam);
1136 CBE_ITEMDATA *item = 0;
1137 WCHAR wintext[520];
1138 INT cursel, n;
1139 INT_PTR oldItem;
1140 NMCBEENDEDITW cbeend;
1141 DWORD oldflags;
1142 HWND parent = infoPtr->hwndNotify;
1144 TRACE("for command %d\n", command);
1146 switch (command)
1148 case CBN_DROPDOWN:
1149 SetFocus (infoPtr->hwndCombo);
1150 ShowWindow (infoPtr->hwndEdit, SW_HIDE);
1151 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1153 case CBN_CLOSEUP:
1154 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1156 * from native trace of first dropdown after typing in URL in IE4
1157 * CB_GETCURSEL(Combo)
1158 * GetWindowText(Edit)
1159 * CB_GETCURSEL(Combo)
1160 * CB_GETCOUNT(Combo)
1161 * CB_GETITEMDATA(Combo, n)
1162 * WM_NOTIFY(parent, CBEN_ENDEDITA|W)
1163 * CB_GETCURSEL(Combo)
1164 * CB_SETCURSEL(COMBOEX, n)
1165 * SetFocus(Combo)
1166 * the rest is supposition
1168 ShowWindow (infoPtr->hwndEdit, SW_SHOW);
1169 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1170 InvalidateRect (infoPtr->hwndEdit, 0, TRUE);
1171 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1172 if (cursel == -1) {
1173 cmp_func_t cmptext = get_cmp_func(infoPtr);
1174 /* find match from edit against those in Combobox */
1175 GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
1176 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
1177 for (cursel = 0; cursel < n; cursel++){
1178 item = get_item_data(infoPtr, cursel);
1179 if ((INT_PTR)item == CB_ERR) break;
1180 if (!cmptext(COMBOEX_GetText(infoPtr, item), wintext)) break;
1182 if ((cursel == n) || ((INT_PTR)item == CB_ERR)) {
1183 TRACE("failed to find match??? item=%p cursel=%d\n",
1184 item, cursel);
1185 if (infoPtr->hwndEdit)
1186 SetFocus(infoPtr->hwndEdit);
1187 return 0;
1190 else {
1191 item = get_item_data(infoPtr, cursel);
1192 if ((INT_PTR)item == CB_ERR) {
1193 TRACE("failed to find match??? item=%p cursel=%d\n",
1194 item, cursel);
1195 if (infoPtr->hwndEdit)
1196 SetFocus(infoPtr->hwndEdit);
1197 return 0;
1201 /* Save flags for testing and reset them */
1202 oldflags = infoPtr->flags;
1203 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1205 if (oldflags & WCBE_ACTEDIT) {
1206 cbeend.fChanged = (oldflags & WCBE_EDITCHG);
1207 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1208 CB_GETCURSEL, 0, 0);
1209 cbeend.iWhy = CBENF_DROPDOWN;
1211 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0;
1214 /* if selection has changed the set the new current selection */
1215 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1216 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
1217 infoPtr->selected = cursel;
1218 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0);
1219 SetFocus(infoPtr->hwndCombo);
1221 return 0;
1223 case CBN_SELCHANGE:
1225 * CB_GETCURSEL(Combo)
1226 * CB_GETITEMDATA(Combo) < simulated by COMBOEX_FindItem
1227 * lstrlenA
1228 * WM_SETTEXT(Edit)
1229 * WM_GETTEXTLENGTH(Edit)
1230 * WM_GETTEXT(Edit)
1231 * EM_SETSEL(Edit, 0,0)
1232 * WM_GETTEXTLENGTH(Edit)
1233 * WM_GETTEXT(Edit)
1234 * EM_SETSEL(Edit, 0,len)
1235 * return WM_COMMAND to parent
1237 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1238 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1239 ERR("item %ld not found. Problem!\n", oldItem);
1240 break;
1242 infoPtr->selected = oldItem;
1243 COMBOEX_SetEditText (infoPtr, item);
1244 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1246 case CBN_SELENDOK:
1247 case CBN_SELENDCANCEL:
1249 * We have to change the handle since we are the control
1250 * issuing the message. IE4 depends on this.
1252 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1254 case CBN_KILLFOCUS:
1256 * from native trace:
1258 * pass to parent
1259 * WM_GETTEXT(Edit, 104)
1260 * CB_GETCURSEL(Combo) rets -1
1261 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1262 * CB_GETCURSEL(Combo)
1263 * InvalidateRect(Combo, 0, 0)
1264 * return 0
1266 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1267 if (infoPtr->flags & WCBE_ACTEDIT) {
1268 GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
1269 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1270 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1271 CB_GETCURSEL, 0, 0);
1272 cbeend.iWhy = CBENF_KILLFOCUS;
1274 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1275 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0;
1277 /* possible CB_GETCURSEL */
1278 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1279 return 0;
1281 case CBN_SETFOCUS:
1282 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1284 default:
1286 * We have to change the handle since we are the control
1287 * issuing the message. IE4 depends on this.
1288 * We also need to set the focus back to the Edit control
1289 * after passing the command to the parent of the ComboEx.
1291 lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1292 if (infoPtr->hwndEdit)
1293 SetFocus(infoPtr->hwndEdit);
1294 return lret;
1296 return 0;
1300 static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT const *dis)
1302 CBE_ITEMDATA *item, *olditem;
1303 NMCOMBOBOXEXW nmcit;
1304 UINT i;
1306 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%p, data=%08lx\n",
1307 dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
1309 if (dis->itemID >= infoPtr->nb_items) return FALSE;
1311 olditem = infoPtr->items;
1312 i = infoPtr->nb_items - 1;
1314 if (i == dis->itemID) {
1315 infoPtr->items = infoPtr->items->next;
1317 else {
1318 item = olditem;
1319 i--;
1321 /* find the prior item in the list */
1322 while (item->next && (i > dis->itemID)) {
1323 item = item->next;
1324 i--;
1326 if (!item->next || (i != dis->itemID)) {
1327 ERR("COMBOBOXEX item structures broken. Please report!\n");
1328 return FALSE;
1330 olditem = item->next;
1331 item->next = item->next->next;
1333 infoPtr->nb_items--;
1335 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
1336 COMBOEX_CopyItem (olditem, &nmcit.ceItem);
1337 COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit);
1339 COMBOEX_FreeText(olditem);
1340 Free(olditem);
1342 return TRUE;
1346 static LRESULT COMBOEX_DrawItem (const COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT const *dis)
1348 static const WCHAR nil[] = { 0 };
1349 CBE_ITEMDATA *item = 0;
1350 SIZE txtsize;
1351 RECT rect;
1352 LPCWSTR str = nil;
1353 UINT xbase, x, y;
1354 INT len;
1355 COLORREF nbkc, ntxc, bkc, txc;
1356 int drawimage, drawstate, xioff;
1358 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
1360 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
1361 dis->CtlType, dis->CtlID);
1362 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
1363 dis->itemID, dis->itemAction, dis->itemState);
1364 TRACE("hWnd=%p hDC=%p (%s) itemData=0x%08lx\n",
1365 dis->hwndItem, dis->hDC, wine_dbgstr_rect(&dis->rcItem), dis->itemData);
1367 /* MSDN says: */
1368 /* "itemID - Specifies the menu item identifier for a menu */
1369 /* item or the index of the item in a list box or combo box. */
1370 /* For an empty list box or combo box, this member can be -1. */
1371 /* This allows the application to draw only the focus */
1372 /* rectangle at the coordinates specified by the rcItem */
1373 /* member even though there are no items in the control. */
1374 /* This indicates to the user whether the list box or combo */
1375 /* box has the focus. How the bits are set in the itemAction */
1376 /* member determines whether the rectangle is to be drawn as */
1377 /* though the list box or combo box has the focus. */
1378 if (dis->itemID == 0xffffffff) {
1379 if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
1380 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
1382 TRACE("drawing item -1 special focus, rect=(%s)\n",
1383 wine_dbgstr_rect(&dis->rcItem));
1385 else if ((dis->CtlType == ODT_COMBOBOX) &&
1386 (dis->itemAction == ODA_DRAWENTIRE)) {
1387 /* draw of edit control data */
1389 /* testing */
1391 RECT exrc, cbrc, edrc;
1392 GetWindowRect (infoPtr->hwndSelf, &exrc);
1393 GetWindowRect (infoPtr->hwndCombo, &cbrc);
1394 edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
1395 if (infoPtr->hwndEdit)
1396 GetWindowRect (infoPtr->hwndEdit, &edrc);
1397 TRACE("window rects ex=(%s), cb=(%s), ed=(%s)\n",
1398 wine_dbgstr_rect(&exrc), wine_dbgstr_rect(&cbrc),
1399 wine_dbgstr_rect(&edrc));
1402 else {
1403 ERR("NOT drawing item -1 special focus, rect=(%s), action=%08x, state=%08x\n",
1404 wine_dbgstr_rect(&dis->rcItem),
1405 dis->itemAction, dis->itemState);
1406 return 0;
1410 /* If draw item is -1 (edit control) setup the item pointer */
1411 if (dis->itemID == 0xffffffff) {
1412 item = infoPtr->edit;
1414 if (infoPtr->hwndEdit) {
1415 INT len;
1417 /* free previous text of edit item */
1418 COMBOEX_FreeText(item);
1419 item->mask &= ~CBEIF_TEXT;
1420 if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) {
1421 item->mask |= CBEIF_TEXT;
1422 item->pszText = Alloc ((len + 1)*sizeof(WCHAR));
1423 if (item->pszText)
1424 GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1);
1426 TRACE("edit control hwndEdit=%p, text len=%d str=%s\n",
1427 infoPtr->hwndEdit, len, debugstr_txt(item->pszText));
1433 /* if the item pointer is not set, then get the data and locate it */
1434 if (!item) {
1435 item = get_item_data(infoPtr, dis->itemID);
1436 if (item == (CBE_ITEMDATA *)CB_ERR) {
1437 ERR("invalid item for id %d\n", dis->itemID);
1438 return 0;
1442 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
1444 xbase = CBE_STARTOFFSET;
1445 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) {
1446 INT indent = item->iIndent;
1447 if (indent == I_INDENTCALLBACK) {
1448 NMCOMBOBOXEXW nmce;
1449 ZeroMemory(&nmce, sizeof(nmce));
1450 nmce.ceItem.mask = CBEIF_INDENT;
1451 nmce.ceItem.lParam = item->lParam;
1452 nmce.ceItem.iItem = dis->itemID;
1453 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1454 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
1455 item->iIndent = nmce.ceItem.iIndent;
1456 indent = nmce.ceItem.iIndent;
1458 xbase += (indent * CBE_INDENT);
1461 drawimage = -2;
1462 drawstate = ILD_NORMAL;
1463 if (item->mask & CBEIF_IMAGE)
1464 drawimage = item->iImage;
1465 if (dis->itemState & ODS_COMBOEXLBOX) {
1466 /* drawing listbox entry */
1467 if (dis->itemState & ODS_SELECTED) {
1468 if (item->mask & CBEIF_SELECTEDIMAGE)
1469 drawimage = item->iSelectedImage;
1470 drawstate = ILD_SELECTED;
1472 } else {
1473 /* drawing combo/edit entry */
1474 if (IsWindowVisible(infoPtr->hwndEdit)) {
1475 /* if we have an edit control, the slave the
1476 * selection state to the Edit focus state
1478 if (infoPtr->flags & WCBE_EDITFOCUSED) {
1479 if (item->mask & CBEIF_SELECTEDIMAGE)
1480 drawimage = item->iSelectedImage;
1481 drawstate = ILD_SELECTED;
1483 } else {
1484 /* if we don't have an edit control, use
1485 * the requested state.
1487 if (dis->itemState & ODS_SELECTED) {
1488 if (item->mask & CBEIF_SELECTEDIMAGE)
1489 drawimage = item->iSelectedImage;
1490 drawstate = ILD_SELECTED;
1495 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
1496 IMAGEINFO iinfo;
1497 iinfo.rcImage.left = iinfo.rcImage.right = 0;
1498 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
1499 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
1500 } else xioff = 0;
1502 /* setup pointer to text to be drawn */
1503 str = COMBOEX_GetText(infoPtr, item);
1504 if (!str) str = nil;
1506 len = strlenW (str);
1507 GetTextExtentPoint32W (dis->hDC, str, len, &txtsize);
1509 if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) {
1510 int overlay = item->iOverlay;
1512 if (drawimage == I_IMAGECALLBACK) {
1513 NMCOMBOBOXEXW nmce;
1514 ZeroMemory(&nmce, sizeof(nmce));
1515 nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE;
1516 nmce.ceItem.lParam = item->lParam;
1517 nmce.ceItem.iItem = dis->itemID;
1518 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1519 if (drawstate == ILD_NORMAL) {
1520 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage;
1521 drawimage = nmce.ceItem.iImage;
1522 } else if (drawstate == ILD_SELECTED) {
1523 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage;
1524 drawimage = nmce.ceItem.iSelectedImage;
1525 } else ERR("Bad draw state = %d\n", drawstate);
1528 if (overlay == I_IMAGECALLBACK) {
1529 NMCOMBOBOXEXW nmce;
1530 ZeroMemory(&nmce, sizeof(nmce));
1531 nmce.ceItem.mask = CBEIF_OVERLAY;
1532 nmce.ceItem.lParam = item->lParam;
1533 nmce.ceItem.iItem = dis->itemID;
1534 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1535 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
1536 item->iOverlay = nmce.ceItem.iOverlay;
1537 overlay = nmce.ceItem.iOverlay;
1540 if (drawimage >= 0 &&
1541 !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) {
1542 if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1);
1543 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top,
1544 drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0));
1547 /* now draw the text */
1548 if (!IsWindowVisible (infoPtr->hwndEdit)) {
1549 nbkc = (dis->itemState & ODS_SELECTED) ?
1550 comctl32_color.clrHighlight : comctl32_color.clrWindow;
1551 bkc = SetBkColor (dis->hDC, nbkc);
1552 ntxc = (dis->itemState & ODS_SELECTED) ?
1553 comctl32_color.clrHighlightText : comctl32_color.clrWindowText;
1554 txc = SetTextColor (dis->hDC, ntxc);
1555 x = xbase + xioff;
1556 y = dis->rcItem.top +
1557 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
1558 rect.left = x;
1559 rect.right = x + txtsize.cx;
1560 rect.top = dis->rcItem.top + 1;
1561 rect.bottom = dis->rcItem.bottom - 1;
1562 TRACE("drawing item %d text, rect=(%s)\n",
1563 dis->itemID, wine_dbgstr_rect(&rect));
1564 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
1565 &rect, str, len, 0);
1566 SetBkColor (dis->hDC, bkc);
1567 SetTextColor (dis->hDC, txc);
1571 if (dis->itemAction & ODA_FOCUS) {
1572 rect.left = xbase + xioff - 1;
1573 rect.right = rect.left + txtsize.cx + 2;
1574 rect.top = dis->rcItem.top;
1575 rect.bottom = dis->rcItem.bottom;
1576 DrawFocusRect(dis->hDC, &rect);
1579 return 0;
1583 static void COMBOEX_ResetContent (COMBOEX_INFO *infoPtr)
1585 if (infoPtr->items)
1587 CBE_ITEMDATA *item, *next;
1589 item = infoPtr->items;
1590 while (item) {
1591 next = item->next;
1592 COMBOEX_FreeText (item);
1593 Free (item);
1594 item = next;
1596 infoPtr->items = 0;
1599 infoPtr->selected = -1;
1600 infoPtr->nb_items = 0;
1604 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr)
1606 if (infoPtr->hwndCombo)
1607 DestroyWindow (infoPtr->hwndCombo);
1609 Free (infoPtr->edit);
1610 infoPtr->edit = 0;
1612 COMBOEX_ResetContent (infoPtr);
1614 if (infoPtr->defaultFont)
1615 DeleteObject (infoPtr->defaultFont);
1617 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
1619 /* free comboex info data */
1620 Free (infoPtr);
1622 return 0;
1626 static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO const *infoPtr, MEASUREITEMSTRUCT *mis)
1628 static const WCHAR strW[] = { 'W', 0 };
1629 SIZE mysize;
1630 HDC hdc;
1632 hdc = GetDC (0);
1633 GetTextExtentPointW (hdc, strW, 1, &mysize);
1634 ReleaseDC (0, hdc);
1635 mis->itemHeight = mysize.cy + CBE_EXTRA;
1637 TRACE("adjusted height hwnd=%p, height=%d\n",
1638 infoPtr->hwndSelf, mis->itemHeight);
1640 return 0;
1644 static LRESULT COMBOEX_NCCreate (HWND hwnd)
1646 /* WARNING: The COMBOEX_INFO structure is not yet created */
1647 DWORD oldstyle, newstyle;
1649 oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE);
1650 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL | WS_BORDER);
1651 if (newstyle != oldstyle) {
1652 TRACE("req style %08x, resetting style %08x\n",
1653 oldstyle, newstyle);
1654 SetWindowLongW (hwnd, GWL_STYLE, newstyle);
1656 return 1;
1660 static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam)
1662 if (lParam == NF_REQUERY) {
1663 INT i = SendMessageW(infoPtr->hwndNotify,
1664 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
1665 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
1667 return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI;
1671 static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height)
1673 TRACE("(width=%d, height=%d)\n", width, height);
1675 MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE);
1677 COMBOEX_AdjustEditPos (infoPtr);
1679 return 0;
1683 static LRESULT COMBOEX_SetRedraw(const COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
1685 LRESULT ret = DefWindowProcW( infoPtr->hwndSelf, WM_SETREDRAW, wParam, lParam );
1686 if (wParam) RedrawWindow( infoPtr->hwndSelf, NULL, 0, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN );
1687 return ret;
1691 static LRESULT COMBOEX_WindowPosChanging (const COMBOEX_INFO *infoPtr, WINDOWPOS *wp)
1693 RECT cbx_wrect, cbx_crect, cb_wrect;
1694 INT width, height;
1696 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
1697 GetClientRect (infoPtr->hwndSelf, &cbx_crect);
1698 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1700 /* width is winpos value + border width of comboex */
1701 width = wp->cx
1702 + (cbx_wrect.right-cbx_wrect.left)
1703 - (cbx_crect.right-cbx_crect.left);
1705 TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
1706 wp->x, wp->y, wp->cx, wp->cy, wp->flags);
1707 TRACE("EX window=(%s), client=(%s)\n",
1708 wine_dbgstr_rect(&cbx_wrect), wine_dbgstr_rect(&cbx_crect));
1709 TRACE("CB window=(%s), EX setting=(0,0)-(%d,%d)\n",
1710 wine_dbgstr_rect(&cbx_wrect), width, cb_wrect.bottom-cb_wrect.top);
1712 if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
1713 width,
1714 cb_wrect.bottom-cb_wrect.top,
1715 SWP_NOACTIVATE);
1717 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1719 /* height is combo window height plus border width of comboex */
1720 height = (cb_wrect.bottom-cb_wrect.top)
1721 + (cbx_wrect.bottom-cbx_wrect.top)
1722 - (cbx_crect.bottom-cbx_crect.top);
1723 if (wp->cy < height) wp->cy = height;
1724 if (infoPtr->hwndEdit) {
1725 COMBOEX_AdjustEditPos (infoPtr);
1726 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1729 return 0;
1732 static LRESULT WINAPI
1733 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1735 HWND hwndComboex = GetPropW(hwnd, COMBOEX_SUBCLASS_PROP);
1736 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
1737 NMCBEENDEDITW cbeend;
1738 WCHAR edit_text[260];
1739 COLORREF obkc;
1740 HDC hDC;
1741 RECT rect;
1742 LRESULT lret;
1744 TRACE("hwnd=%p msg=%x wparam=%lx lParam=%lx, info_ptr=%p\n",
1745 hwnd, uMsg, wParam, lParam, infoPtr);
1747 if (!infoPtr) return 0;
1749 switch (uMsg)
1752 case WM_CHAR:
1753 /* handle (ignore) the return character */
1754 if (wParam == VK_RETURN) return 0;
1755 /* all other characters pass into the real Edit */
1756 return CallWindowProcW (infoPtr->prevEditWndProc,
1757 hwnd, uMsg, wParam, lParam);
1759 case WM_ERASEBKGND:
1761 * The following was determined by traces of the native
1763 hDC = (HDC) wParam;
1764 obkc = SetBkColor (hDC, comctl32_color.clrWindow);
1765 GetClientRect (hwnd, &rect);
1766 TRACE("erasing (%s)\n", wine_dbgstr_rect(&rect));
1767 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1768 SetBkColor (hDC, obkc);
1769 return CallWindowProcW (infoPtr->prevEditWndProc,
1770 hwnd, uMsg, wParam, lParam);
1772 case WM_KEYDOWN: {
1773 INT_PTR oldItem, selected, step = 1;
1774 CBE_ITEMDATA *item;
1776 switch ((INT)wParam)
1778 case VK_ESCAPE:
1779 /* native version seems to do following for COMBOEX */
1781 * GetWindowTextW(Edit,&?, 0x104) x
1782 * CB_GETCURSEL to Combo rets -1 x
1783 * WM_NOTIFY to COMBOEX parent (rebar) x
1784 * (CBEN_ENDEDIT{A|W}
1785 * fChanged = FALSE x
1786 * inewSelection = -1 x
1787 * txt="www.hoho" x
1788 * iWhy = 3 x
1789 * CB_GETCURSEL to Combo rets -1 x
1790 * InvalidateRect(Combo, 0) x
1791 * WM_SETTEXT to Edit x
1792 * EM_SETSEL to Edit (0,0) x
1793 * EM_SETSEL to Edit (0,-1) x
1794 * RedrawWindow(Combo, 0, 0, 5) x
1796 TRACE("special code for VK_ESCAPE\n");
1798 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1800 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1801 cbeend.fChanged = FALSE;
1802 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1803 CB_GETCURSEL, 0, 0);
1804 cbeend.iWhy = CBENF_ESCAPE;
1806 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
1807 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1808 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1809 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1810 ERR("item %ld not found. Problem!\n", oldItem);
1811 break;
1813 infoPtr->selected = oldItem;
1814 COMBOEX_SetEditText (infoPtr, item);
1815 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1816 RDW_INVALIDATE);
1817 break;
1819 case VK_RETURN:
1820 /* native version seems to do following for COMBOEX */
1822 * GetWindowTextW(Edit,&?, 0x104) x
1823 * CB_GETCURSEL to Combo rets -1 x
1824 * CB_GETCOUNT to Combo rets 0
1825 * if >0 loop
1826 * CB_GETITEMDATA to match
1827 * *** above 3 lines simulated by FindItem x
1828 * WM_NOTIFY to COMBOEX parent (rebar) x
1829 * (CBEN_ENDEDIT{A|W} x
1830 * fChanged = TRUE (-1) x
1831 * iNewSelection = -1 or selected x
1832 * txt= x
1833 * iWhy = 2 (CBENF_RETURN) x
1834 * CB_GETCURSEL to Combo rets -1 x
1835 * if -1 send CB_SETCURSEL to Combo -1 x
1836 * InvalidateRect(Combo, 0, 0) x
1837 * SetFocus(Edit) x
1838 * CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
1841 TRACE("special code for VK_RETURN\n");
1843 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1845 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1846 selected = SendMessageW (infoPtr->hwndCombo,
1847 CB_GETCURSEL, 0, 0);
1849 if (selected != -1) {
1850 cmp_func_t cmptext = get_cmp_func(infoPtr);
1851 item = COMBOEX_FindItem (infoPtr, selected);
1852 TRACE("handling VK_RETURN, selected = %ld, selected_text=%s\n",
1853 selected, debugstr_txt(item->pszText));
1854 TRACE("handling VK_RETURN, edittext=%s\n",
1855 debugstr_w(edit_text));
1856 if (cmptext (COMBOEX_GetText(infoPtr, item), edit_text)) {
1857 /* strings not equal -- indicate edit has changed */
1858 selected = -1;
1862 cbeend.iNewSelection = selected;
1863 cbeend.fChanged = TRUE;
1864 cbeend.iWhy = CBENF_RETURN;
1865 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
1866 /* abort the change, restore previous */
1867 TRACE("Notify requested abort of change\n");
1868 COMBOEX_SetEditText (infoPtr, infoPtr->edit);
1869 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1870 RDW_INVALIDATE);
1871 return 0;
1873 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1874 if (oldItem != -1) {
1875 /* if something is selected, then deselect it */
1876 SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
1877 (WPARAM)-1, 0);
1879 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1880 SetFocus(infoPtr->hwndEdit);
1881 break;
1883 case VK_UP:
1884 step = -1;
1885 case VK_DOWN:
1886 /* by default, step is 1 */
1887 oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0);
1888 if (oldItem >= 0 && oldItem + step >= 0)
1889 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0);
1890 return 0;
1891 default:
1892 return CallWindowProcW (infoPtr->prevEditWndProc,
1893 hwnd, uMsg, wParam, lParam);
1895 return 0;
1898 case WM_SETFOCUS:
1899 /* remember the focus to set state of icon */
1900 lret = CallWindowProcW (infoPtr->prevEditWndProc,
1901 hwnd, uMsg, wParam, lParam);
1902 infoPtr->flags |= WCBE_EDITFOCUSED;
1903 return lret;
1905 case WM_KILLFOCUS:
1907 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
1909 infoPtr->flags &= ~WCBE_EDITFOCUSED;
1910 if (infoPtr->flags & WCBE_ACTEDIT) {
1911 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1913 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1914 cbeend.fChanged = FALSE;
1915 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1916 CB_GETCURSEL, 0, 0);
1917 cbeend.iWhy = CBENF_KILLFOCUS;
1919 COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
1921 /* fall through */
1923 default:
1924 return CallWindowProcW (infoPtr->prevEditWndProc,
1925 hwnd, uMsg, wParam, lParam);
1930 static LRESULT WINAPI
1931 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1933 HWND hwndComboex = GetPropW(hwnd, COMBOEX_SUBCLASS_PROP);
1934 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
1935 NMCBEENDEDITW cbeend;
1936 NMMOUSE nmmse;
1937 COLORREF obkc;
1938 HDC hDC;
1939 HWND focusedhwnd;
1940 RECT rect;
1941 POINT pt;
1942 WCHAR edit_text[260];
1944 TRACE("hwnd=%p msg=%x wparam=%lx lParam=%lx, info_ptr=%p\n",
1945 hwnd, uMsg, wParam, lParam, infoPtr);
1947 if (!infoPtr) return 0;
1949 switch (uMsg)
1952 case WM_DRAWITEM:
1954 * The only way this message should come is from the
1955 * child Listbox issuing the message. Flag this so
1956 * that ComboEx knows this is listbox.
1958 ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
1959 return CallWindowProcW (infoPtr->prevComboWndProc,
1960 hwnd, uMsg, wParam, lParam);
1962 case WM_ERASEBKGND:
1964 * The following was determined by traces of the native
1966 hDC = (HDC) wParam;
1967 obkc = SetBkColor (hDC, comctl32_color.clrWindow);
1968 GetClientRect (hwnd, &rect);
1969 TRACE("erasing (%s)\n", wine_dbgstr_rect(&rect));
1970 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1971 SetBkColor (hDC, obkc);
1972 return CallWindowProcW (infoPtr->prevComboWndProc,
1973 hwnd, uMsg, wParam, lParam);
1975 case WM_SETCURSOR:
1977 * WM_NOTIFY to comboex parent (rebar)
1978 * with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
1979 * CallWindowProc (previous)
1981 nmmse.dwItemSpec = 0;
1982 nmmse.dwItemData = 0;
1983 nmmse.pt.x = 0;
1984 nmmse.pt.y = 0;
1985 nmmse.dwHitInfo = lParam;
1986 COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
1987 return CallWindowProcW (infoPtr->prevComboWndProc,
1988 hwnd, uMsg, wParam, lParam);
1990 case WM_LBUTTONDOWN:
1991 GetClientRect (hwnd, &rect);
1992 rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf,
1993 CB_GETITEMHEIGHT, -1, 0);
1994 rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
1995 pt.x = (short)LOWORD(lParam);
1996 pt.y = (short)HIWORD(lParam);
1997 if (PtInRect(&rect, pt))
1998 return CallWindowProcW (infoPtr->prevComboWndProc,
1999 hwnd, uMsg, wParam, lParam);
2000 infoPtr->flags |= WCBE_MOUSECAPTURED;
2001 SetCapture(hwnd);
2002 break;
2004 case WM_LBUTTONUP:
2005 if (!(infoPtr->flags & WCBE_MOUSECAPTURED))
2006 return CallWindowProcW (infoPtr->prevComboWndProc,
2007 hwnd, uMsg, wParam, lParam);
2008 ReleaseCapture();
2009 infoPtr->flags &= ~WCBE_MOUSECAPTURED;
2010 if (infoPtr->flags & WCBE_MOUSEDRAGGED) {
2011 infoPtr->flags &= ~WCBE_MOUSEDRAGGED;
2012 } else {
2013 SendMessageW(hwnd, CB_SHOWDROPDOWN, TRUE, 0);
2015 break;
2017 case WM_MOUSEMOVE:
2018 if ( (infoPtr->flags & WCBE_MOUSECAPTURED) &&
2019 !(infoPtr->flags & WCBE_MOUSEDRAGGED)) {
2020 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2021 COMBOEX_NotifyDragBegin(infoPtr, edit_text);
2022 infoPtr->flags |= WCBE_MOUSEDRAGGED;
2024 return CallWindowProcW (infoPtr->prevComboWndProc,
2025 hwnd, uMsg, wParam, lParam);
2027 case WM_COMMAND:
2028 switch (HIWORD(wParam)) {
2030 case EN_UPDATE:
2031 /* traces show that COMBOEX does not issue CBN_EDITUPDATE
2032 * on the EN_UPDATE
2034 return 0;
2036 case EN_KILLFOCUS:
2038 * Native does:
2040 * GetFocus() retns AA
2041 * GetWindowTextW(Edit)
2042 * CB_GETCURSEL(Combo) (got -1)
2043 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
2044 * CB_GETCURSEL(Combo) (got -1)
2045 * InvalidateRect(Combo, 0, 0)
2046 * WM_KILLFOCUS(Combo, AA)
2047 * return 0;
2049 focusedhwnd = GetFocus();
2050 if (infoPtr->flags & WCBE_ACTEDIT) {
2051 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2052 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
2053 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
2054 CB_GETCURSEL, 0, 0);
2055 cbeend.iWhy = CBENF_KILLFOCUS;
2057 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
2058 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
2060 /* possible CB_GETCURSEL */
2061 InvalidateRect (infoPtr->hwndCombo, 0, 0);
2062 if (focusedhwnd)
2063 SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
2064 (WPARAM)focusedhwnd, 0);
2065 return 0;
2067 case EN_SETFOCUS: {
2069 * For EN_SETFOCUS this issues the same calls and messages
2070 * as the native seems to do.
2072 * for some cases however native does the following:
2073 * (noticed after SetFocus during LBUTTONDOWN on
2074 * on dropdown arrow)
2075 * WM_GETTEXTLENGTH (Edit);
2076 * WM_GETTEXT (Edit, len+1, str);
2077 * EM_SETSEL (Edit, 0, 0);
2078 * WM_GETTEXTLENGTH (Edit);
2079 * WM_GETTEXT (Edit, len+1, str);
2080 * EM_SETSEL (Edit, 0, len);
2081 * WM_NOTIFY (parent, CBEN_BEGINEDIT)
2083 NMHDR hdr;
2085 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
2086 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
2087 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
2088 infoPtr->flags |= WCBE_ACTEDIT;
2089 infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
2090 return 0;
2093 case EN_CHANGE: {
2095 * For EN_CHANGE this issues the same calls and messages
2096 * as the native seems to do.
2098 WCHAR edit_text[260];
2099 LPCWSTR lastwrk;
2100 cmp_func_t cmptext = get_cmp_func(infoPtr);
2102 INT_PTR selected = SendMessageW (infoPtr->hwndCombo,
2103 CB_GETCURSEL, 0, 0);
2105 /* lstrlenW( lastworkingURL ) */
2107 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2108 if (selected == -1) {
2109 lastwrk = infoPtr->edit->pszText;
2111 else {
2112 CBE_ITEMDATA *item = COMBOEX_FindItem (infoPtr, selected);
2113 lastwrk = COMBOEX_GetText(infoPtr, item);
2116 TRACE("handling EN_CHANGE, selected = %ld, selected_text=%s\n",
2117 selected, debugstr_w(lastwrk));
2118 TRACE("handling EN_CHANGE, edittext=%s\n",
2119 debugstr_w(edit_text));
2121 /* cmptext is between lastworkingURL and GetWindowText */
2122 if (cmptext (lastwrk, edit_text)) {
2123 /* strings not equal -- indicate edit has changed */
2124 infoPtr->flags |= WCBE_EDITCHG;
2126 SendMessageW ( infoPtr->hwndNotify, WM_COMMAND,
2127 MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
2128 CBN_EDITCHANGE),
2129 (LPARAM)infoPtr->hwndSelf);
2130 return 0;
2133 case LBN_SELCHANGE:
2135 * Therefore from traces there is no additional code here
2139 * Using native COMCTL32 gets the following:
2140 * 1 == SHDOCVW.DLL issues call/message
2141 * 2 == COMCTL32.DLL issues call/message
2142 * 3 == WINE issues call/message
2145 * for LBN_SELCHANGE:
2146 * 1 CB_GETCURSEL(ComboEx)
2147 * 1 CB_GETDROPPEDSTATE(ComboEx)
2148 * 1 CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
2149 * 2 CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
2150 ** call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
2151 * 3 WM_COMMAND(ComboEx, CBN_SELENDOK)
2152 * WM_USER+49(ComboLB, 1,0) <=============!!!!!!!!!!!
2153 * 3 ShowWindow(ComboLB, SW_HIDE)
2154 * 3 RedrawWindow(Combo, RDW_UPDATENOW)
2155 * 3 WM_COMMAND(ComboEX, CBN_CLOSEUP)
2156 ** end of CBRollUp
2157 * 3 WM_COMMAND(ComboEx, CBN_SELCHANGE) (echo to parent)
2158 * ? LB_GETCURSEL <==|
2159 * ? LB_GETTEXTLEN |
2160 * ? LB_GETTEXT | Needs to be added to
2161 * ? WM_CTLCOLOREDIT(ComboEx) | Combo processing
2162 * ? LB_GETITEMDATA |
2163 * ? WM_DRAWITEM(ComboEx) <==|
2165 default:
2166 break;
2167 }/* fall through */
2168 default:
2169 return CallWindowProcW (infoPtr->prevComboWndProc,
2170 hwnd, uMsg, wParam, lParam);
2172 return 0;
2176 static LRESULT WINAPI
2177 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2179 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
2181 TRACE("hwnd=%p msg=%x wparam=%lx lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2183 if (!infoPtr) {
2184 if (uMsg == WM_CREATE)
2185 return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam);
2186 if (uMsg == WM_NCCREATE)
2187 COMBOEX_NCCreate (hwnd);
2188 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2191 switch (uMsg)
2193 case CBEM_DELETEITEM:
2194 return COMBOEX_DeleteItem (infoPtr, wParam);
2196 case CBEM_GETCOMBOCONTROL:
2197 return (LRESULT)infoPtr->hwndCombo;
2199 case CBEM_GETEDITCONTROL:
2200 return (LRESULT)infoPtr->hwndEdit;
2202 case CBEM_GETEXTENDEDSTYLE:
2203 return infoPtr->dwExtStyle;
2205 case CBEM_GETIMAGELIST:
2206 return (LRESULT)infoPtr->himl;
2208 case CBEM_GETITEMA:
2209 return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2211 case CBEM_GETITEMW:
2212 return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2214 case CBEM_GETUNICODEFORMAT:
2215 return infoPtr->unicode;
2217 case CBEM_HASEDITCHANGED:
2218 return COMBOEX_HasEditChanged (infoPtr);
2220 case CBEM_INSERTITEMA:
2221 return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2223 case CBEM_INSERTITEMW:
2224 return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2226 case CBEM_SETEXSTYLE:
2227 case CBEM_SETEXTENDEDSTYLE:
2228 return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam);
2230 case CBEM_SETIMAGELIST:
2231 return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam);
2233 case CBEM_SETITEMA:
2234 return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2236 case CBEM_SETITEMW:
2237 return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2239 case CBEM_SETUNICODEFORMAT:
2240 return COMBOEX_SetUnicodeFormat (infoPtr, wParam);
2242 /*case CBEM_SETWINDOWTHEME:
2243 FIXME("CBEM_SETWINDOWTHEME: stub\n");*/
2245 case WM_SETTEXT:
2246 case WM_GETTEXT:
2247 case WM_GETTEXTLENGTH:
2248 return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam);
2250 case CB_GETLBTEXT:
2251 return COMBOEX_GetListboxText(infoPtr, wParam, (LPWSTR)lParam);
2253 case CB_GETLBTEXTLEN:
2254 return COMBOEX_GetListboxText(infoPtr, wParam, NULL);
2256 case CB_RESETCONTENT:
2257 COMBOEX_ResetContent(infoPtr);
2258 /* fall through */
2260 /* Combo messages we are not sure if we need to process or just forward */
2261 case CB_GETDROPPEDCONTROLRECT:
2262 case CB_GETITEMHEIGHT:
2263 case CB_GETEXTENDEDUI:
2264 case CB_LIMITTEXT:
2265 case CB_SELECTSTRING:
2267 /* Combo messages OK to just forward to the regular COMBO */
2268 case CB_GETCOUNT:
2269 case CB_GETCURSEL:
2270 case CB_GETDROPPEDSTATE:
2271 case CB_SETDROPPEDWIDTH:
2272 case CB_SETEXTENDEDUI:
2273 case CB_SHOWDROPDOWN:
2274 return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam);
2276 /* Combo messages we need to process specially */
2277 case CB_FINDSTRINGEXACT:
2278 return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCWSTR)lParam);
2280 case CB_GETITEMDATA:
2281 return COMBOEX_GetItemData (infoPtr, (INT)wParam);
2283 case CB_SETCURSEL:
2284 return COMBOEX_SetCursel (infoPtr, (INT)wParam);
2286 case CB_SETITEMDATA:
2287 return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD_PTR)lParam);
2289 case CB_SETITEMHEIGHT:
2290 return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam);
2294 /* Window messages passed to parent */
2295 case WM_COMMAND:
2296 return COMBOEX_Command (infoPtr, wParam);
2298 case WM_NOTIFY:
2299 if (infoPtr->NtfUnicode)
2300 return SendMessageW (infoPtr->hwndNotify, uMsg, wParam, lParam);
2301 else
2302 return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
2305 /* Window messages we need to process */
2306 case WM_DELETEITEM:
2307 return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam);
2309 case WM_DRAWITEM:
2310 return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam);
2312 case WM_DESTROY:
2313 return COMBOEX_Destroy (infoPtr);
2315 case WM_MEASUREITEM:
2316 return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam);
2318 case WM_NOTIFYFORMAT:
2319 return COMBOEX_NotifyFormat (infoPtr, lParam);
2321 case WM_SIZE:
2322 return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam));
2324 case WM_SETREDRAW:
2325 return COMBOEX_SetRedraw(infoPtr, wParam, lParam);
2327 case WM_WINDOWPOSCHANGING:
2328 return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam);
2330 case WM_SETFOCUS:
2331 SetFocus(infoPtr->hwndCombo);
2332 return 0;
2334 case WM_SYSCOLORCHANGE:
2335 COMCTL32_RefreshSysColors();
2336 return 0;
2338 default:
2339 if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
2340 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",uMsg,wParam,lParam);
2341 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2346 void COMBOEX_Register (void)
2348 WNDCLASSW wndClass;
2350 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
2351 wndClass.style = CS_GLOBALCLASS;
2352 wndClass.lpfnWndProc = COMBOEX_WindowProc;
2353 wndClass.cbClsExtra = 0;
2354 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
2355 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
2356 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2357 wndClass.lpszClassName = WC_COMBOBOXEXW;
2359 RegisterClassW (&wndClass);
2363 void COMBOEX_Unregister (void)
2365 UnregisterClassW (WC_COMBOBOXEXW, NULL);