Release 20030408.
[wine/gsoc-2012-control.git] / dlls / comctl32 / comboex.c
blob235a8396c3b3f649981987f8ab1d86e1e212288c
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 belive 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 <string.h>
34 #include "winbase.h"
35 #include "commctrl.h"
36 #include "wine/debug.h"
37 #include "wine/unicode.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(comboex);
41 /* Item structure */
42 typedef struct
44 VOID *next;
45 UINT mask;
46 LPWSTR pszText;
47 LPWSTR pszTemp;
48 int cchTextMax;
49 int iImage;
50 int iSelectedImage;
51 int iOverlay;
52 int iIndent;
53 LPARAM lParam;
54 } CBE_ITEMDATA;
56 /* ComboBoxEx structure */
57 typedef struct
59 HIMAGELIST himl;
60 HWND hwndSelf; /* my own hwnd */
61 HWND hwndCombo;
62 HWND hwndEdit;
63 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */
64 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */
65 DWORD dwExtStyle;
66 INT selected; /* index of selected item */
67 DWORD flags; /* WINE internal flags */
68 HFONT defaultFont;
69 HFONT font;
70 INT nb_items; /* Number of items */
71 BOOL unicode; /* TRUE if this window is Unicode */
72 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */
73 CBE_ITEMDATA *edit; /* item data for edit item */
74 CBE_ITEMDATA *items; /* Array of items */
75 } COMBOEX_INFO;
77 /* internal flags in the COMBOEX_INFO structure */
78 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e.
79 * CBEN_BEGINEDIT issued
80 * but CBEN_ENDEDIT{A|W}
81 * not yet issued. */
82 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */
83 #define WCBE_EDITHASCHANGED (WCBE_ACTEDIT | WCBE_EDITCHG)
84 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */
85 #define WCBE_MOUSECAPTURED 0x00000008 /* Combo has captured mouse */
86 #define WCBE_MOUSEDRAGGED 0x00000010 /* User has dragged in combo */
88 #define ID_CB_EDIT 1001
92 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
93 * the ComboEx version of the Combo Window Proc so that when the
94 * WM_DRAWITEM message is then passed to ComboEx, we know that this
95 * particular WM_DRAWITEM message is for listbox only items. Any messasges
96 * without this flag is then for the Edit control field.
98 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
99 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
101 #define ODS_COMBOEXLBOX 0x4000
105 /* Height in pixels of control over the amount of the selected font */
106 #define CBE_EXTRA 3
108 /* Indent amount per MS documentation */
109 #define CBE_INDENT 10
111 /* Offset in pixels from left side for start of image or text */
112 #define CBE_STARTOFFSET 6
114 /* Offset between image and text */
115 #define CBE_SEP 4
117 #define COMBOEX_SUBCLASS_PROP "CCComboEx32SubclassInfo"
118 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongW (hwnd, 0))
121 /* Things common to the entire DLL */
122 static LRESULT WINAPI
123 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
124 static LRESULT WINAPI
125 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
126 static int CALLBACK
127 COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code);
128 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr);
129 typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR);
131 inline static BOOL is_textW(LPCWSTR str)
133 return str && str != LPSTR_TEXTCALLBACKW;
136 inline static BOOL is_textA(LPCSTR str)
138 return str && str != LPSTR_TEXTCALLBACKA;
141 inline static LPCSTR debugstr_txt(LPCWSTR str)
143 if (str == LPSTR_TEXTCALLBACKW) return "(callback)";
144 return debugstr_w(str);
147 static void COMBOEX_DumpItem (CBE_ITEMDATA *item)
149 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
150 item, item->mask, item->pszText, item->cchTextMax, item->iImage);
151 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
152 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
153 if (item->mask & CBEIF_TEXT)
154 TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText));
158 static void COMBOEX_DumpInput (COMBOBOXEXITEMW *input)
160 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
161 input->mask, input->iItem, input->pszText, input->cchTextMax,
162 input->iImage);
163 if (input->mask & CBEIF_TEXT)
164 TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText));
165 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
166 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
170 inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index)
172 return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA,
173 (WPARAM)index, 0);
176 inline static cmp_func_t get_cmp_func(COMBOEX_INFO *infoPtr)
178 return infoPtr->dwExtStyle & CBES_EX_CASESENSITIVE ? lstrcmpW : lstrcmpiW;
181 static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
183 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
184 hdr->hwndFrom = infoPtr->hwndSelf;
185 hdr->code = code;
186 if (infoPtr->NtfUnicode)
187 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
188 (LPARAM)hdr);
189 else
190 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
191 (LPARAM)hdr);
195 static INT
196 COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr)
198 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
199 if (infoPtr->NtfUnicode)
200 return COMBOEX_Notify (infoPtr, code, &hdr->hdr);
201 else {
202 LPWSTR wstr = hdr->ceItem.pszText;
203 LPSTR astr = 0;
204 INT ret, len = 0;
206 if ((hdr->ceItem.mask & CBEIF_TEXT) && is_textW(wstr)) {
207 len = WideCharToMultiByte (CP_ACP, 0, wstr, -1, 0, 0, NULL, NULL);
208 if (len > 0) {
209 astr = (LPSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
210 if (!astr) return 0;
211 WideCharToMultiByte (CP_ACP, 0, wstr, -1, astr, len, 0, 0);
212 hdr->ceItem.pszText = (LPWSTR)astr;
216 if (code == CBEN_ENDEDITW) code = CBEN_ENDEDITA;
217 else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA;
218 else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA;
220 ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr);
222 if (astr && hdr->ceItem.pszText == (LPWSTR)astr)
223 hdr->ceItem.pszText = wstr;
225 if (astr) COMCTL32_Free(astr);
227 return ret;
232 static INT COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *neew, LPCWSTR wstr)
234 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
235 if (infoPtr->NtfUnicode) {
236 lstrcpynW(neew->szText, wstr, CBEMAXSTRLEN);
237 return COMBOEX_Notify (infoPtr, CBEN_ENDEDITW, &neew->hdr);
238 } else {
239 NMCBEENDEDITA neea;
241 memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR));
242 neea.fChanged = neew->fChanged;
243 neea.iNewSelection = neew->iNewSelection;
244 WideCharToMultiByte (CP_ACP, 0, wstr, -1, neea.szText, CBEMAXSTRLEN, 0, 0);
245 neea.iWhy = neew->iWhy;
247 return COMBOEX_Notify (infoPtr, CBEN_ENDEDITA, &neea.hdr);
252 static void COMBOEX_NotifyDragBegin(COMBOEX_INFO *infoPtr, LPCWSTR wstr)
254 /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
255 if (infoPtr->NtfUnicode) {
256 NMCBEDRAGBEGINW ndbw;
258 ndbw.iItemid = -1;
259 lstrcpynW(ndbw.szText, wstr, CBEMAXSTRLEN);
260 COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINW, &ndbw.hdr);
261 } else {
262 NMCBEDRAGBEGINA ndba;
264 ndba.iItemid = -1;
265 WideCharToMultiByte (CP_ACP, 0, wstr, -1, ndba.szText, CBEMAXSTRLEN, 0, 0);
267 COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINA, &ndba.hdr);
272 static void COMBOEX_FreeText (CBE_ITEMDATA *item)
274 if (is_textW(item->pszText)) COMCTL32_Free(item->pszText);
275 item->pszText = 0;
276 if (item->pszTemp) COMCTL32_Free(item->pszTemp);
277 item->pszTemp = 0;
281 static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
283 NMCOMBOBOXEXW nmce;
284 LPWSTR text, buf;
285 INT len;
287 if (item->pszText != LPSTR_TEXTCALLBACKW)
288 return item->pszText;
290 ZeroMemory(&nmce, sizeof(nmce));
291 nmce.ceItem.mask = CBEIF_TEXT;
292 nmce.ceItem.lParam = item->lParam;
293 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
295 if (is_textW(nmce.ceItem.pszText)) {
296 len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0);
297 buf = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
298 if (buf)
299 MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len);
300 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) {
301 COMBOEX_FreeText(item);
302 item->pszText = buf;
303 } else {
304 if (item->pszTemp) COMCTL32_Free(item->pszTemp);
305 item->pszTemp = buf;
307 text = buf;
308 } else
309 text = nmce.ceItem.pszText;
311 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
312 item->pszText = text;
313 return text;
317 static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
319 HFONT nfont, ofont;
320 HDC mydc;
322 mydc = GetDC (0); /* why the entire screen???? */
323 nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
324 ofont = (HFONT) SelectObject (mydc, nfont);
325 GetTextExtentPointA (mydc, "A", 1, size);
326 SelectObject (mydc, ofont);
327 ReleaseDC (0, mydc);
328 TRACE("selected font hwnd=%p, height=%ld\n", nfont, size->cy);
332 static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
334 if (cit->mask & CBEIF_TEXT) {
336 * when given a text buffer actually use that buffer
338 if (cit->pszText) {
339 if (is_textW(item->pszText))
340 lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax);
341 else
342 cit->pszText[0] = 0;
343 } else {
344 cit->pszText = item->pszText;
345 cit->cchTextMax = item->cchTextMax;
348 if (cit->mask & CBEIF_IMAGE)
349 cit->iImage = item->iImage;
350 if (cit->mask & CBEIF_SELECTEDIMAGE)
351 cit->iSelectedImage = item->iSelectedImage;
352 if (cit->mask & CBEIF_OVERLAY)
353 cit->iOverlay = item->iOverlay;
354 if (cit->mask & CBEIF_INDENT)
355 cit->iIndent = item->iIndent;
356 if (cit->mask & CBEIF_LPARAM)
357 cit->lParam = item->lParam;
361 static void COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
363 SIZE mysize;
364 INT x, y, w, h, xioff;
365 RECT rect;
367 if (!infoPtr->hwndEdit) return;
369 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
370 IMAGEINFO iinfo;
371 iinfo.rcImage.left = iinfo.rcImage.right = 0;
372 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
373 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
374 } else xioff = 0;
376 GetClientRect (infoPtr->hwndCombo, &rect);
377 InflateRect (&rect, -2, -2);
378 InvalidateRect (infoPtr->hwndCombo, &rect, TRUE);
380 /* reposition the Edit control based on whether icon exists */
381 COMBOEX_GetComboFontSize (infoPtr, &mysize);
382 TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy);
383 x = xioff + CBE_STARTOFFSET + 1;
384 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
385 h = mysize.cy + 1;
386 y = rect.bottom - h - 1;
388 TRACE("Combo client (%ld,%ld)-(%ld,%ld), setting Edit to (%d,%d)-(%d,%d)\n",
389 rect.left, rect.top, rect.right, rect.bottom, x, y, x + w, y + h);
390 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h,
391 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
395 static void COMBOEX_ReSize (COMBOEX_INFO *infoPtr)
397 SIZE mysize;
398 UINT cy;
399 IMAGEINFO iinfo;
401 COMBOEX_GetComboFontSize (infoPtr, &mysize);
402 cy = mysize.cy + CBE_EXTRA;
403 if (infoPtr->himl && ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo)) {
404 cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
405 TRACE("upgraded height due to image: height=%d\n", cy);
407 SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy);
408 if (infoPtr->hwndCombo) {
409 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
410 (WPARAM) 0, (LPARAM) cy);
411 if ( !(infoPtr->flags & CBES_EX_NOSIZELIMIT)) {
412 RECT comboRect;
413 if (GetWindowRect(infoPtr->hwndCombo, &comboRect)) {
414 RECT ourRect;
415 if (GetWindowRect(infoPtr->hwndSelf, &ourRect)) {
416 if (comboRect.bottom > ourRect.bottom) {
417 POINT pt = { ourRect.left, ourRect.top };
418 if (ScreenToClient(infoPtr->hwndSelf, &pt))
419 MoveWindow( infoPtr->hwndSelf, pt.x, pt.y, ourRect.right - ourRect.left,
420 comboRect.bottom - comboRect.top, FALSE);
429 static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
431 if (!infoPtr->hwndEdit) return;
432 /* native issues the following messages to the {Edit} control */
433 /* WM_SETTEXT (0,addr) */
434 /* EM_SETSEL32 (0,0) */
435 /* EM_SETSEL32 (0,-1) */
436 if (item->mask & CBEIF_TEXT) {
437 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item));
438 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
439 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
444 static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
446 CBE_ITEMDATA *item;
447 INT i;
449 if ((index > infoPtr->nb_items) || (index < -1))
450 return 0;
451 if (index == -1)
452 return infoPtr->edit;
453 item = infoPtr->items;
454 i = infoPtr->nb_items - 1;
456 /* find the item in the list */
457 while (item && (i > index)) {
458 item = (CBE_ITEMDATA *)item->next;
459 i--;
461 if (!item || (i != index)) {
462 ERR("COMBOBOXEX item structures broken. Please report!\n");
463 return 0;
465 return item;
469 static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr)
471 return infoPtr->hwndEdit ? TRUE : FALSE;
475 /* *** CBEM_xxx message support *** */
478 static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT index)
480 CBE_ITEMDATA *item;
482 TRACE("(index=%d)\n", index);
484 /* if item number requested does not exist then return failure */
485 if ((index > infoPtr->nb_items) || (index < 0)) return CB_ERR;
486 if (!(item = COMBOEX_FindItem(infoPtr, index))) return CB_ERR;
488 /* doing this will result in WM_DELETEITEM being issued */
489 SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0);
491 return infoPtr->nb_items;
495 static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
497 INT index = cit->iItem;
498 CBE_ITEMDATA *item;
500 TRACE("(...)\n");
502 /* if item number requested does not exist then return failure */
503 if ((index > infoPtr->nb_items) || (index < -1)) return FALSE;
505 /* if the item is the edit control and there is no edit control, skip */
506 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
508 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
510 COMBOEX_CopyItem (item, cit);
512 return TRUE;
516 static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
518 COMBOBOXEXITEMW tmpcit;
520 TRACE("(...)\n");
522 tmpcit.mask = cit->mask;
523 tmpcit.iItem = cit->iItem;
524 tmpcit.pszText = 0;
525 if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE;
527 if (is_textW(tmpcit.pszText) && cit->pszText)
528 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
529 cit->pszText, cit->cchTextMax, NULL, NULL);
530 else if (cit->pszText) cit->pszText[0] = 0;
531 else cit->pszText = (LPSTR)tmpcit.pszText;
533 cit->iImage = tmpcit.iImage;
534 cit->iSelectedImage = tmpcit.iSelectedImage;
535 cit->iOverlay = tmpcit.iOverlay;
536 cit->iIndent = tmpcit.iIndent;
537 cit->lParam = tmpcit.lParam;
539 return TRUE;
543 inline static BOOL COMBOEX_HasEditChanged (COMBOEX_INFO *infoPtr)
545 return COMBOEX_HasEdit(infoPtr) &&
546 (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED;
550 static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
552 INT index;
553 CBE_ITEMDATA *item;
554 NMCOMBOBOXEXW nmcit;
556 TRACE("\n");
558 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
560 /* get real index of item to insert */
561 index = cit->iItem;
562 if (index == -1) index = infoPtr->nb_items;
563 if (index > infoPtr->nb_items) index = infoPtr->nb_items;
565 /* get zero-filled space and chain it in */
566 if(!(item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof(*item)))) return -1;
568 /* locate position to insert new item in */
569 if (index == infoPtr->nb_items) {
570 /* fast path for iItem = -1 */
571 item->next = infoPtr->items;
572 infoPtr->items = item;
574 else {
575 INT i = infoPtr->nb_items-1;
576 CBE_ITEMDATA *moving = infoPtr->items;
578 while ((i > index) && moving) {
579 moving = (CBE_ITEMDATA *)moving->next;
580 i--;
582 if (!moving) {
583 ERR("COMBOBOXEX item structures broken. Please report!\n");
584 COMCTL32_Free(item);
585 return -1;
587 item->next = moving->next;
588 moving->next = item;
591 /* fill in our hidden item structure */
592 item->mask = cit->mask;
593 if (item->mask & CBEIF_TEXT) {
594 INT len = 0;
596 if (is_textW(cit->pszText)) len = strlenW (cit->pszText);
597 if (len > 0) {
598 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
599 if (!item->pszText) {
600 COMCTL32_Free(item);
601 return -1;
603 strcpyW (item->pszText, cit->pszText);
605 else if (cit->pszText == LPSTR_TEXTCALLBACKW)
606 item->pszText = LPSTR_TEXTCALLBACKW;
607 item->cchTextMax = cit->cchTextMax;
609 if (item->mask & CBEIF_IMAGE)
610 item->iImage = cit->iImage;
611 if (item->mask & CBEIF_SELECTEDIMAGE)
612 item->iSelectedImage = cit->iSelectedImage;
613 if (item->mask & CBEIF_OVERLAY)
614 item->iOverlay = cit->iOverlay;
615 if (item->mask & CBEIF_INDENT)
616 item->iIndent = cit->iIndent;
617 if (item->mask & CBEIF_LPARAM)
618 item->lParam = cit->lParam;
619 infoPtr->nb_items++;
621 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
623 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
624 (WPARAM)cit->iItem, (LPARAM)item);
626 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
627 COMBOEX_CopyItem (item, &nmcit.ceItem);
628 COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit);
630 return index;
635 static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
637 COMBOBOXEXITEMW citW;
638 LPWSTR wstr = NULL;
639 INT ret;
641 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
642 if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) {
643 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
644 wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
645 if (!wstr) return -1;
646 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
647 citW.pszText = wstr;
649 ret = COMBOEX_InsertItemW(infoPtr, &citW);
651 if (wstr) COMCTL32_Free(wstr);
653 return ret;
657 static DWORD
658 COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style)
660 DWORD dwTemp;
662 TRACE("(mask=x%08lx, style=0x%08lx)\n", mask, style);
664 dwTemp = infoPtr->dwExtStyle;
666 if (mask)
667 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style;
668 else
669 infoPtr->dwExtStyle = style;
671 /* see if we need to change the word break proc on the edit */
672 if ((infoPtr->dwExtStyle ^ dwTemp) & CBES_EX_PATHWORDBREAKPROC) {
673 SendMessageW(infoPtr->hwndEdit, EM_SETWORDBREAKPROC, 0,
674 (infoPtr->dwExtStyle & CBES_EX_PATHWORDBREAKPROC) ?
675 (LPARAM)COMBOEX_PathWordBreakProc : 0);
678 /* test if the control's appearance has changed */
679 mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT;
680 if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) {
681 /* if state of EX_NOEDITIMAGE changes, invalidate all */
682 TRACE("EX_NOEDITIMAGE state changed to %ld\n",
683 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
684 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
685 COMBOEX_AdjustEditPos (infoPtr);
686 if (infoPtr->hwndEdit)
687 InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
690 return dwTemp;
694 static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl)
696 HIMAGELIST himlTemp = infoPtr->himl;
698 TRACE("(...)\n");
700 infoPtr->himl = himl;
702 COMBOEX_ReSize (infoPtr);
703 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
705 /* reposition the Edit control based on whether icon exists */
706 COMBOEX_AdjustEditPos (infoPtr);
707 return himlTemp;
710 static BOOL COMBOEX_SetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
712 INT index = cit->iItem;
713 CBE_ITEMDATA *item;
715 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
717 /* if item number requested does not exist then return failure */
718 if ((index > infoPtr->nb_items) || (index < -1)) return FALSE;
720 /* if the item is the edit control and there is no edit control, skip */
721 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
723 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
725 /* add/change stuff to the internal item structure */
726 item->mask |= cit->mask;
727 if (cit->mask & CBEIF_TEXT) {
728 INT len = 0;
730 COMBOEX_FreeText(item);
731 if (is_textW(cit->pszText)) len = strlenW(cit->pszText);
732 if (len > 0) {
733 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
734 if (!item->pszText) return FALSE;
735 strcpyW(item->pszText, cit->pszText);
736 } else if (cit->pszText == LPSTR_TEXTCALLBACKW)
737 item->pszText = LPSTR_TEXTCALLBACKW;
738 item->cchTextMax = cit->cchTextMax;
740 if (cit->mask & CBEIF_IMAGE)
741 item->iImage = cit->iImage;
742 if (cit->mask & CBEIF_SELECTEDIMAGE)
743 item->iSelectedImage = cit->iSelectedImage;
744 if (cit->mask & CBEIF_OVERLAY)
745 item->iOverlay = cit->iOverlay;
746 if (cit->mask & CBEIF_INDENT)
747 item->iIndent = cit->iIndent;
748 if (cit->mask & CBEIF_LPARAM)
749 cit->lParam = cit->lParam;
751 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
753 /* if original request was to update edit control, do some fast foot work */
754 if (cit->iItem == -1) {
755 COMBOEX_SetEditText (infoPtr, item);
756 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
758 return TRUE;
761 static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
763 COMBOBOXEXITEMW citW;
764 LPWSTR wstr = NULL;
765 BOOL ret;
767 memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA));
768 if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) {
769 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
770 wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
771 if (!wstr) return FALSE;
772 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
773 citW.pszText = wstr;
775 ret = COMBOEX_SetItemW(infoPtr, &citW);
777 if (wstr) COMCTL32_Free(wstr);
779 return ret;
783 static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value)
785 BOOL bTemp = infoPtr->unicode;
787 TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE");
789 infoPtr->unicode = value;
791 return bTemp;
795 /* *** CB_xxx message support *** */
797 static INT
798 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCWSTR str)
800 INT i;
801 cmp_func_t cmptext = get_cmp_func(infoPtr);
802 INT count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
804 /* now search from after starting loc and wrapping back to start */
805 for(i=start+1; i<count; i++) {
806 CBE_ITEMDATA *item = get_item_data(infoPtr, i);
807 if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
809 for(i=0; i<=start; i++) {
810 CBE_ITEMDATA *item = get_item_data(infoPtr, i);
811 if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
813 return CB_ERR;
817 static DWORD COMBOEX_GetItemData (COMBOEX_INFO *infoPtr, INT index)
819 CBE_ITEMDATA *item1, *item2;
820 DWORD ret = 0;
822 item1 = get_item_data(infoPtr, index);
823 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
824 item2 = COMBOEX_FindItem (infoPtr, index);
825 if (item2 != item1) {
826 ERR("data structures damaged!\n");
827 return CB_ERR;
829 if (item1->mask & CBEIF_LPARAM) ret = item1->lParam;
830 TRACE("returning 0x%08lx\n", ret);
831 } else {
832 ret = (DWORD)item1;
833 TRACE("non-valid result from combo, returning 0x%08lx\n", ret);
835 return ret;
839 static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT index)
841 CBE_ITEMDATA *item;
842 INT sel;
844 if (!(item = COMBOEX_FindItem(infoPtr, index)))
845 return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
847 TRACE("selecting item %d text=%s\n", index, debugstr_txt(item->pszText));
848 infoPtr->selected = index;
850 sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
851 COMBOEX_SetEditText (infoPtr, item);
852 return sel;
856 static DWORD COMBOEX_SetItemData (COMBOEX_INFO *infoPtr, INT index, DWORD data)
858 CBE_ITEMDATA *item1, *item2;
860 item1 = get_item_data(infoPtr, index);
861 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
862 item2 = COMBOEX_FindItem (infoPtr, index);
863 if (item2 != item1) {
864 ERR("data structures damaged!\n");
865 return CB_ERR;
867 item1->mask |= CBEIF_LPARAM;
868 item1->lParam = data;
869 TRACE("setting lparam to 0x%08lx\n", data);
870 return 0;
872 TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1);
873 return (LRESULT)item1;
877 static INT COMBOEX_SetItemHeight (COMBOEX_INFO *infoPtr, INT index, UINT height)
879 RECT cb_wrect, cbx_wrect, cbx_crect;
881 /* First, lets forward the message to the normal combo control
882 just like Windows. */
883 if (infoPtr->hwndCombo)
884 if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
885 index, height) == CB_ERR) return CB_ERR;
887 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
888 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
889 GetClientRect (infoPtr->hwndSelf, &cbx_crect);
890 /* the height of comboex as height of the combo + comboex border */
891 height = cb_wrect.bottom-cb_wrect.top
892 + cbx_wrect.bottom-cbx_wrect.top
893 - (cbx_crect.bottom-cbx_crect.top);
894 TRACE("EX window=(%ld,%ld)-(%ld,%ld), client=(%ld,%ld)-(%ld,%ld)\n",
895 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
896 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
897 TRACE("CB window=(%ld,%ld)-(%ld,%ld), EX setting=(0,0)-(%ld,%d)\n",
898 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
899 cbx_wrect.right-cbx_wrect.left, height);
900 SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0,
901 cbx_wrect.right-cbx_wrect.left, height,
902 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
904 return 0;
908 /* *** WM_xxx message support *** */
911 static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs)
913 WCHAR COMBOBOX[] = { 'C', 'o', 'm', 'b', 'o', 'B', 'o', 'x', 0 };
914 WCHAR EDIT[] = { 'E', 'D', 'I', 'T', 0 };
915 WCHAR NIL[] = { 0 };
916 COMBOEX_INFO *infoPtr;
917 LOGFONTW mylogfont;
918 RECT wnrc1, clrc1, cmbwrc;
919 INT i;
921 /* allocate memory for info structure */
922 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
923 if (!infoPtr) return -1;
925 /* initialize info structure */
926 /* note that infoPtr is allocated zero-filled */
928 infoPtr->hwndSelf = hwnd;
929 infoPtr->selected = -1;
931 infoPtr->unicode = IsWindowUnicode (hwnd);
933 i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
934 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
935 WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
936 i = NFR_ANSI;
938 infoPtr->NtfUnicode = (i == NFR_UNICODE);
940 SetWindowLongW (hwnd, 0, (DWORD)infoPtr);
942 /* create combo box */
943 GetWindowRect(hwnd, &wnrc1);
944 GetClientRect(hwnd, &clrc1);
945 TRACE("EX window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld)\n",
946 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
947 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
949 /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
950 /* specified. It then creates it's own version of the EDIT control */
951 /* and makes the ComboBox the parent. This is because a normal */
952 /* DROPDOWNLIST does not have a EDIT control, but we need one. */
953 /* We also need to place the edit control at the proper location */
954 /* (allow space for the icons). */
956 infoPtr->hwndCombo = CreateWindowW (COMBOBOX, NIL,
957 /* following line added to match native */
958 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
959 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
960 /* was base and is necessary */
961 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED |
962 GetWindowLongW (hwnd, GWL_STYLE),
963 cs->y, cs->x, cs->cx, cs->cy, hwnd,
964 (HMENU) GetWindowLongW (hwnd, GWL_ID),
965 (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
968 * native does the following at this point according to trace:
969 * GetWindowThreadProcessId(hwndCombo,0)
970 * GetCurrentThreadId()
971 * GetWindowThreadProcessId(hwndCombo, &???)
972 * GetCurrentProcessId()
976 * Setup a property to hold the pointer to the COMBOBOXEX
977 * data structure.
979 SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd);
980 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo,
981 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
982 infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
986 * Now create our own EDIT control so we can position it.
987 * It is created only for CBS_DROPDOWN style
989 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
990 infoPtr->hwndEdit = CreateWindowExW (0, EDIT, NIL,
991 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
992 0, 0, 0, 0, /* will set later */
993 infoPtr->hwndCombo,
994 (HMENU) GetWindowLongW (hwnd, GWL_ID),
995 (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
997 /* native does the following at this point according to trace:
998 * GetWindowThreadProcessId(hwndEdit,0)
999 * GetCurrentThreadId()
1000 * GetWindowThreadProcessId(hwndEdit, &???)
1001 * GetCurrentProcessId()
1005 * Setup a property to hold the pointer to the COMBOBOXEX
1006 * data structure.
1008 SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd);
1009 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit,
1010 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
1011 infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1015 * Locate the default font if necessary and then set it in
1016 * all associated controls
1018 if (!infoPtr->font) {
1019 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
1020 &mylogfont, 0);
1021 infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont);
1023 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1024 if (infoPtr->hwndEdit) {
1025 SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1026 SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
1029 COMBOEX_ReSize (infoPtr);
1031 /* Above is fairly certain, below is much less certain. */
1033 GetWindowRect(hwnd, &wnrc1);
1034 GetClientRect(hwnd, &clrc1);
1035 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1036 TRACE("EX window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) CB wnd=(%ld,%ld)-(%ld,%ld)\n",
1037 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
1038 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
1039 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1040 SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
1041 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
1042 SWP_NOACTIVATE | SWP_NOREDRAW);
1044 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1045 TRACE("CB window=(%ld,%ld)-(%ld,%ld)\n",
1046 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1047 SetWindowPos(hwnd, HWND_TOP,
1048 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
1049 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
1051 COMBOEX_AdjustEditPos (infoPtr);
1054 * Create an item structure to represent the data in the
1055 * EDIT control. It is allocated zero-filled.
1057 infoPtr->edit = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
1058 if (!infoPtr->edit) {
1059 COMBOEX_Destroy(infoPtr);
1060 return -1;
1063 return 0;
1067 static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
1069 LRESULT lret;
1070 INT command = HIWORD(wParam);
1071 CBE_ITEMDATA *item = 0;
1072 WCHAR wintext[520];
1073 INT cursel, n, oldItem;
1074 NMCBEENDEDITW cbeend;
1075 DWORD oldflags;
1076 HWND parent = GetParent (infoPtr->hwndSelf);
1078 TRACE("for command %d\n", command);
1080 switch (command)
1082 case CBN_DROPDOWN:
1083 SetFocus (infoPtr->hwndCombo);
1084 ShowWindow (infoPtr->hwndEdit, SW_HIDE);
1085 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1087 case CBN_CLOSEUP:
1088 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1090 * from native trace of first dropdown after typing in URL in IE4
1091 * CB_GETCURSEL(Combo)
1092 * GetWindowText(Edit)
1093 * CB_GETCURSEL(Combo)
1094 * CB_GETCOUNT(Combo)
1095 * CB_GETITEMDATA(Combo, n)
1096 * WM_NOTIFY(parent, CBEN_ENDEDITA|W)
1097 * CB_GETCURSEL(Combo)
1098 * CB_SETCURSEL(COMBOEX, n)
1099 * SetFocus(Combo)
1100 * the rest is supposition
1102 ShowWindow (infoPtr->hwndEdit, SW_SHOW);
1103 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1104 InvalidateRect (infoPtr->hwndEdit, 0, TRUE);
1105 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1106 if (cursel == -1) {
1107 cmp_func_t cmptext = get_cmp_func(infoPtr);
1108 /* find match from edit against those in Combobox */
1109 GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
1110 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
1111 for (cursel = 0; cursel < n; cursel++){
1112 item = get_item_data(infoPtr, cursel);
1113 if ((INT)item == CB_ERR) break;
1114 if (!cmptext(COMBOEX_GetText(infoPtr, item), wintext)) break;
1116 if ((cursel == n) || ((INT)item == CB_ERR)) {
1117 TRACE("failed to find match??? item=%p cursel=%d\n",
1118 item, cursel);
1119 if (infoPtr->hwndEdit)
1120 SetFocus(infoPtr->hwndEdit);
1121 return 0;
1124 else {
1125 item = get_item_data(infoPtr, cursel);
1126 if ((INT)item == CB_ERR) {
1127 TRACE("failed to find match??? item=%p cursel=%d\n",
1128 item, cursel);
1129 if (infoPtr->hwndEdit)
1130 SetFocus(infoPtr->hwndEdit);
1131 return 0;
1135 /* Save flags for testing and reset them */
1136 oldflags = infoPtr->flags;
1137 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1139 if (oldflags & WCBE_ACTEDIT) {
1140 cbeend.fChanged = (oldflags & WCBE_EDITCHG);
1141 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1142 CB_GETCURSEL, 0, 0);
1143 cbeend.iWhy = CBENF_DROPDOWN;
1145 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0;
1148 /* if selection has changed the set the new current selection */
1149 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1150 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
1151 infoPtr->selected = cursel;
1152 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0);
1153 SetFocus(infoPtr->hwndCombo);
1155 return 0;
1157 case CBN_SELCHANGE:
1159 * CB_GETCURSEL(Combo)
1160 * CB_GETITEMDATA(Combo) < simulated by COMBOEX_FindItem
1161 * lstrlenA
1162 * WM_SETTEXT(Edit)
1163 * WM_GETTEXTLENGTH(Edit)
1164 * WM_GETTEXT(Edit)
1165 * EM_SETSEL(Edit, 0,0)
1166 * WM_GETTEXTLENGTH(Edit)
1167 * WM_GETTEXT(Edit)
1168 * EM_SETSEL(Edit, 0,len)
1169 * return WM_COMMAND to parent
1171 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1172 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1173 ERR("item %d not found. Problem!\n", oldItem);
1174 break;
1176 infoPtr->selected = oldItem;
1177 COMBOEX_SetEditText (infoPtr, item);
1178 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1180 case CBN_SELENDOK:
1182 * We have to change the handle since we are the control
1183 * issuing the message. IE4 depends on this.
1185 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1187 case CBN_KILLFOCUS:
1189 * from native trace:
1191 * pass to parent
1192 * WM_GETTEXT(Edit, 104)
1193 * CB_GETCURSEL(Combo) rets -1
1194 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1195 * CB_GETCURSEL(Combo)
1196 * InvalidateRect(Combo, 0, 0)
1197 * return 0
1199 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1200 if (infoPtr->flags & WCBE_ACTEDIT) {
1201 GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
1202 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1203 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1204 CB_GETCURSEL, 0, 0);
1205 cbeend.iWhy = CBENF_KILLFOCUS;
1207 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1208 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0;
1210 /* possible CB_GETCURSEL */
1211 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1212 return 0;
1214 default:
1216 * We have to change the handle since we are the control
1217 * issuing the message. IE4 depends on this.
1218 * We also need to set the focus back to the Edit control
1219 * after passing the command to the parent of the ComboEx.
1221 lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1222 if (infoPtr->hwndEdit)
1223 SetFocus(infoPtr->hwndEdit);
1224 return lret;
1226 return 0;
1230 static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis)
1232 CBE_ITEMDATA *item, *olditem;
1233 NMCOMBOBOXEXW nmcit;
1234 UINT i;
1236 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%p, data=%08lx\n",
1237 dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
1239 if (dis->itemID >= infoPtr->nb_items) return FALSE;
1241 olditem = infoPtr->items;
1242 i = infoPtr->nb_items - 1;
1244 if (i == dis->itemID) {
1245 infoPtr->items = infoPtr->items->next;
1247 else {
1248 item = olditem;
1249 i--;
1251 /* find the prior item in the list */
1252 while (item->next && (i > dis->itemID)) {
1253 item = (CBE_ITEMDATA *)item->next;
1254 i--;
1256 if (!item->next || (i != dis->itemID)) {
1257 ERR("COMBOBOXEX item structures broken. Please report!\n");
1258 return FALSE;
1260 olditem = item->next;
1261 item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
1263 infoPtr->nb_items--;
1265 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
1266 COMBOEX_CopyItem (olditem, &nmcit.ceItem);
1267 COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit);
1269 COMBOEX_FreeText(olditem);
1270 COMCTL32_Free(olditem);
1272 return TRUE;
1276 static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT *dis)
1278 WCHAR nil[] = { 0 };
1279 CBE_ITEMDATA *item = 0;
1280 SIZE txtsize;
1281 RECT rect;
1282 LPCWSTR str = nil;
1283 UINT xbase, x, y;
1284 INT len;
1285 COLORREF nbkc, ntxc, bkc, txc;
1286 int drawimage, drawstate, xioff;
1288 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
1290 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
1291 dis->CtlType, dis->CtlID);
1292 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
1293 dis->itemID, dis->itemAction, dis->itemState);
1294 TRACE("hWnd=%p hDC=%p (%ld,%ld)-(%ld,%ld) itemData=0x%08lx\n",
1295 dis->hwndItem, dis->hDC, dis->rcItem.left,
1296 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
1297 dis->itemData);
1299 /* MSDN says: */
1300 /* "itemID - Specifies the menu item identifier for a menu */
1301 /* item or the index of the item in a list box or combo box. */
1302 /* For an empty list box or combo box, this member can be -1. */
1303 /* This allows the application to draw only the focus */
1304 /* rectangle at the coordinates specified by the rcItem */
1305 /* member even though there are no items in the control. */
1306 /* This indicates to the user whether the list box or combo */
1307 /* box has the focus. How the bits are set in the itemAction */
1308 /* member determines whether the rectangle is to be drawn as */
1309 /* though the list box or combo box has the focus. */
1310 if (dis->itemID == 0xffffffff) {
1311 if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
1312 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
1314 TRACE("drawing item -1 special focus, rect=(%ld,%ld)-(%ld,%ld)\n",
1315 dis->rcItem.left, dis->rcItem.top,
1316 dis->rcItem.right, dis->rcItem.bottom);
1318 else if ((dis->CtlType == ODT_COMBOBOX) &&
1319 (dis->itemAction == ODA_DRAWENTIRE)) {
1320 /* draw of edit control data */
1322 /* testing */
1324 RECT exrc, cbrc, edrc;
1325 GetWindowRect (infoPtr->hwndSelf, &exrc);
1326 GetWindowRect (infoPtr->hwndCombo, &cbrc);
1327 edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
1328 if (infoPtr->hwndEdit)
1329 GetWindowRect (infoPtr->hwndEdit, &edrc);
1330 TRACE("window rects ex=(%ld,%ld)-(%ld,%ld), cb=(%ld,%ld)-(%ld,%ld), ed=(%ld,%ld)-(%ld,%ld)\n",
1331 exrc.left, exrc.top, exrc.right, exrc.bottom,
1332 cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
1333 edrc.left, edrc.top, edrc.right, edrc.bottom);
1336 else {
1337 ERR("NOT drawing item -1 special focus, rect=(%ld,%ld)-(%ld,%ld), action=%08x, state=%08x\n",
1338 dis->rcItem.left, dis->rcItem.top,
1339 dis->rcItem.right, dis->rcItem.bottom,
1340 dis->itemAction, dis->itemState);
1341 return 0;
1345 /* If draw item is -1 (edit control) setup the item pointer */
1346 if (dis->itemID == 0xffffffff) {
1347 item = infoPtr->edit;
1349 if (infoPtr->hwndEdit) {
1350 INT len;
1352 /* free previous text of edit item */
1353 COMBOEX_FreeText(item);
1354 item->mask &= ~CBEIF_TEXT;
1355 if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) {
1356 item->mask |= CBEIF_TEXT;
1357 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1358 if (item->pszText)
1359 GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1);
1361 TRACE("edit control hwndEdit=%p, text len=%d str=%s\n",
1362 infoPtr->hwndEdit, len, debugstr_txt(item->pszText));
1368 /* if the item pointer is not set, then get the data and locate it */
1369 if (!item) {
1370 item = get_item_data(infoPtr, dis->itemID);
1371 if (item == (CBE_ITEMDATA *)CB_ERR) {
1372 ERR("invalid item for id %d \n", dis->itemID);
1373 return 0;
1377 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
1379 xbase = CBE_STARTOFFSET;
1380 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) {
1381 INT indent = item->iIndent;
1382 if (indent == I_INDENTCALLBACK) {
1383 NMCOMBOBOXEXW nmce;
1384 ZeroMemory(&nmce, sizeof(nmce));
1385 nmce.ceItem.mask = CBEIF_INDENT;
1386 nmce.ceItem.lParam = item->lParam;
1387 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1388 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
1389 item->iIndent = nmce.ceItem.iIndent;
1390 indent = nmce.ceItem.iIndent;
1392 xbase += (indent * CBE_INDENT);
1395 drawimage = -2;
1396 drawstate = ILD_NORMAL;
1397 if (item->mask & CBEIF_IMAGE)
1398 drawimage = item->iImage;
1399 if (dis->itemState & ODS_COMBOEXLBOX) {
1400 /* drawing listbox entry */
1401 if (dis->itemState & ODS_SELECTED) {
1402 if (item->mask & CBEIF_SELECTEDIMAGE)
1403 drawimage = item->iSelectedImage;
1404 drawstate = ILD_SELECTED;
1406 } else {
1407 /* drawing combo/edit entry */
1408 if (IsWindowVisible(infoPtr->hwndEdit)) {
1409 /* if we have an edit control, the slave the
1410 * selection state to the Edit focus state
1412 if (infoPtr->flags & WCBE_EDITFOCUSED) {
1413 if (item->mask & CBEIF_SELECTEDIMAGE)
1414 drawimage = item->iSelectedImage;
1415 drawstate = ILD_SELECTED;
1417 } else {
1418 /* if we don't have an edit control, use
1419 * the requested state.
1421 if (dis->itemState & ODS_SELECTED) {
1422 if (item->mask & CBEIF_SELECTEDIMAGE)
1423 drawimage = item->iSelectedImage;
1424 drawstate = ILD_SELECTED;
1429 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
1430 IMAGEINFO iinfo;
1431 iinfo.rcImage.left = iinfo.rcImage.right = 0;
1432 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
1433 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
1434 } else xioff = 0;
1436 /* setup pointer to text to be drawn */
1437 str = COMBOEX_GetText(infoPtr, item);
1438 if (!str) str = nil;
1440 len = strlenW (str);
1441 GetTextExtentPoint32W (dis->hDC, str, len, &txtsize);
1443 if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) {
1444 int overlay = item->iOverlay;
1446 if (drawimage == I_IMAGECALLBACK) {
1447 NMCOMBOBOXEXW nmce;
1448 ZeroMemory(&nmce, sizeof(nmce));
1449 nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE;
1450 nmce.ceItem.lParam = item->lParam;
1451 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1452 if (drawstate == ILD_NORMAL) {
1453 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage;
1454 drawimage = nmce.ceItem.iImage;
1455 } else if (drawstate == ILD_SELECTED) {
1456 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage;
1457 drawimage = nmce.ceItem.iSelectedImage;
1458 } else ERR("Bad draw state = %d\n", drawstate);
1461 if (overlay == I_IMAGECALLBACK) {
1462 NMCOMBOBOXEXW nmce;
1463 ZeroMemory(&nmce, sizeof(nmce));
1464 nmce.ceItem.mask = CBEIF_OVERLAY;
1465 nmce.ceItem.lParam = item->lParam;
1466 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1467 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
1468 item->iOverlay = nmce.ceItem.iOverlay;
1469 overlay = nmce.ceItem.iOverlay;
1472 if (drawimage >= 0 &&
1473 !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) {
1474 if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1);
1475 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top,
1476 drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0));
1479 /* now draw the text */
1480 if (!IsWindowVisible (infoPtr->hwndEdit)) {
1481 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1482 COLOR_HIGHLIGHT : COLOR_WINDOW);
1483 bkc = SetBkColor (dis->hDC, nbkc);
1484 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1485 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
1486 txc = SetTextColor (dis->hDC, ntxc);
1487 x = xbase + xioff;
1488 y = dis->rcItem.top +
1489 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
1490 rect.left = x;
1491 rect.right = x + txtsize.cx;
1492 rect.top = dis->rcItem.top + 1;
1493 rect.bottom = dis->rcItem.bottom - 1;
1494 TRACE("drawing item %d text, rect=(%ld,%ld)-(%ld,%ld)\n",
1495 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1496 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
1497 &rect, str, len, 0);
1498 SetBkColor (dis->hDC, bkc);
1499 SetTextColor (dis->hDC, txc);
1503 if (dis->itemAction & ODA_FOCUS) {
1504 rect.left = xbase + xioff - 1;
1505 rect.right = rect.left + txtsize.cx + 2;
1506 rect.top = dis->rcItem.top;
1507 rect.bottom = dis->rcItem.bottom;
1508 DrawFocusRect(dis->hDC, &rect);
1511 return 0;
1515 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr)
1517 if (infoPtr->hwndCombo)
1518 DestroyWindow (infoPtr->hwndCombo);
1520 if (infoPtr->edit) {
1521 COMCTL32_Free (infoPtr->edit);
1522 infoPtr->edit = 0;
1525 if (infoPtr->items) {
1526 CBE_ITEMDATA *item, *next;
1528 item = infoPtr->items;
1529 while (item) {
1530 next = (CBE_ITEMDATA *)item->next;
1531 COMBOEX_FreeText (item);
1532 COMCTL32_Free (item);
1533 item = next;
1535 infoPtr->items = 0;
1538 if (infoPtr->defaultFont)
1539 DeleteObject (infoPtr->defaultFont);
1541 /* free comboex info data */
1542 COMCTL32_Free (infoPtr);
1543 SetWindowLongW (infoPtr->hwndSelf, 0, 0);
1544 return 0;
1548 static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis)
1550 SIZE mysize;
1551 HDC hdc;
1553 hdc = GetDC (0);
1554 GetTextExtentPointA (hdc, "W", 1, &mysize);
1555 ReleaseDC (0, hdc);
1556 mis->itemHeight = mysize.cy + CBE_EXTRA;
1558 TRACE("adjusted height hwnd=%p, height=%d\n",
1559 infoPtr->hwndSelf, mis->itemHeight);
1561 return 0;
1565 static LRESULT COMBOEX_NCCreate (HWND hwnd)
1567 /* WARNING: The COMBOEX_INFO structure is not yet created */
1568 DWORD oldstyle, newstyle;
1570 oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE);
1571 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
1572 if (newstyle != oldstyle) {
1573 TRACE("req style %08lx, reseting style %08lx\n",
1574 oldstyle, newstyle);
1575 SetWindowLongW (hwnd, GWL_STYLE, newstyle);
1577 return 1;
1581 static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam)
1583 if (lParam == NF_REQUERY) {
1584 INT i = SendMessageW(GetParent (infoPtr->hwndSelf),
1585 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
1586 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
1588 return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI;
1592 static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height)
1594 TRACE("(width=%d, height=%d)\n", width, height);
1596 MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE);
1598 COMBOEX_AdjustEditPos (infoPtr);
1600 return 0;
1604 static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp)
1606 RECT cbx_wrect, cbx_crect, cb_wrect;
1607 UINT width, height;
1609 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
1610 GetClientRect (infoPtr->hwndSelf, &cbx_crect);
1611 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1613 /* width is winpos value + border width of comboex */
1614 width = wp->cx
1615 + (cbx_wrect.right-cbx_wrect.left)
1616 - (cbx_crect.right-cbx_crect.left);
1618 TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
1619 wp->x, wp->y, wp->cx, wp->cy, wp->flags);
1620 TRACE("EX window=(%ld,%ld)-(%ld,%ld), client=(%ld,%ld)-(%ld,%ld)\n",
1621 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
1622 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
1623 TRACE("CB window=(%ld,%ld)-(%ld,%ld), EX setting=(0,0)-(%d,%ld)\n",
1624 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
1625 width, cb_wrect.bottom-cb_wrect.top);
1627 if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
1628 width,
1629 cb_wrect.bottom-cb_wrect.top,
1630 SWP_NOACTIVATE);
1632 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1634 /* height is combo window height plus border width of comboex */
1635 height = (cb_wrect.bottom-cb_wrect.top)
1636 + (cbx_wrect.bottom-cbx_wrect.top)
1637 - (cbx_crect.bottom-cbx_crect.top);
1638 if (wp->cy < height) wp->cy = height;
1639 if (infoPtr->hwndEdit) {
1640 COMBOEX_AdjustEditPos (infoPtr);
1641 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1644 return 0;
1647 static inline int is_delimiter(WCHAR c)
1649 switch(c) {
1650 case '/':
1651 case '\\':
1652 case '.':
1653 return TRUE;
1655 return FALSE;
1658 static int CALLBACK
1659 COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code)
1661 if (code == WB_ISDELIMITER) {
1662 return is_delimiter(lpch[ichCurrent]);
1663 } else {
1664 int dir = (code == WB_LEFT) ? -1 : 1;
1665 for(; 0 <= ichCurrent && ichCurrent < cch; ichCurrent += dir)
1666 if (is_delimiter(lpch[ichCurrent])) return ichCurrent;
1668 return ichCurrent;
1671 static LRESULT WINAPI
1672 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1674 HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP);
1675 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
1676 NMCBEENDEDITW cbeend;
1677 WCHAR edit_text[260];
1678 COLORREF obkc;
1679 HDC hDC;
1680 RECT rect;
1681 LRESULT lret;
1683 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1684 hwnd, uMsg, wParam, lParam, infoPtr);
1686 if (!infoPtr) return 0;
1688 switch (uMsg)
1691 case WM_CHAR:
1692 /* handle (ignore) the return character */
1693 if (wParam == VK_RETURN) return 0;
1694 /* all other characters pass into the real Edit */
1695 return CallWindowProcW (infoPtr->prevEditWndProc,
1696 hwnd, uMsg, wParam, lParam);
1698 case WM_ERASEBKGND:
1700 * The following was determined by traces of the native
1702 hDC = (HDC) wParam;
1703 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW));
1704 GetClientRect (hwnd, &rect);
1705 TRACE("erasing (%ld,%ld)-(%ld,%ld)\n",
1706 rect.left, rect.top, rect.right, rect.bottom);
1707 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1708 SetBkColor (hDC, obkc);
1709 return CallWindowProcW (infoPtr->prevEditWndProc,
1710 hwnd, uMsg, wParam, lParam);
1712 case WM_KEYDOWN: {
1713 INT oldItem, selected, step = 1;
1714 CBE_ITEMDATA *item;
1716 switch ((INT)wParam)
1718 case VK_ESCAPE:
1719 /* native version seems to do following for COMBOEX */
1721 * GetWindowTextA(Edit,&?, 0x104) x
1722 * CB_GETCURSEL to Combo rets -1 x
1723 * WM_NOTIFY to COMBOEX parent (rebar) x
1724 * (CBEN_ENDEDIT{A|W}
1725 * fChanged = FALSE x
1726 * inewSelection = -1 x
1727 * txt="www.hoho" x
1728 * iWhy = 3 x
1729 * CB_GETCURSEL to Combo rets -1 x
1730 * InvalidateRect(Combo, 0) x
1731 * WM_SETTEXT to Edit x
1732 * EM_SETSEL to Edit (0,0) x
1733 * EM_SETSEL to Edit (0,-1) x
1734 * RedrawWindow(Combo, 0, 0, 5) x
1736 TRACE("special code for VK_ESCAPE\n");
1738 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1740 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1741 cbeend.fChanged = FALSE;
1742 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1743 CB_GETCURSEL, 0, 0);
1744 cbeend.iWhy = CBENF_ESCAPE;
1746 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
1747 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1748 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1749 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1750 ERR("item %d not found. Problem!\n", oldItem);
1751 break;
1753 infoPtr->selected = oldItem;
1754 COMBOEX_SetEditText (infoPtr, item);
1755 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1756 RDW_INVALIDATE);
1757 break;
1759 case VK_RETURN:
1760 /* native version seems to do following for COMBOEX */
1762 * GetWindowTextA(Edit,&?, 0x104) x
1763 * CB_GETCURSEL to Combo rets -1 x
1764 * CB_GETCOUNT to Combo rets 0
1765 * if >0 loop
1766 * CB_GETITEMDATA to match
1767 * *** above 3 lines simulated by FindItem x
1768 * WM_NOTIFY to COMBOEX parent (rebar) x
1769 * (CBEN_ENDEDIT{A|W} x
1770 * fChanged = TRUE (-1) x
1771 * iNewSelection = -1 or selected x
1772 * txt= x
1773 * iWhy = 2 (CBENF_RETURN) x
1774 * CB_GETCURSEL to Combo rets -1 x
1775 * if -1 send CB_SETCURSEL to Combo -1 x
1776 * InvalidateRect(Combo, 0, 0) x
1777 * SetFocus(Edit) x
1778 * CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
1781 TRACE("special code for VK_RETURN\n");
1783 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1785 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1786 selected = SendMessageW (infoPtr->hwndCombo,
1787 CB_GETCURSEL, 0, 0);
1789 if (selected != -1) {
1790 cmp_func_t cmptext = get_cmp_func(infoPtr);
1791 item = COMBOEX_FindItem (infoPtr, selected);
1792 TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
1793 selected, debugstr_txt(item->pszText));
1794 TRACE("handling VK_RETURN, edittext=%s\n",
1795 debugstr_w(edit_text));
1796 if (cmptext (COMBOEX_GetText(infoPtr, item), edit_text)) {
1797 /* strings not equal -- indicate edit has changed */
1798 selected = -1;
1802 cbeend.iNewSelection = selected;
1803 cbeend.fChanged = TRUE;
1804 cbeend.iWhy = CBENF_RETURN;
1805 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
1806 /* abort the change, restore previous */
1807 TRACE("Notify requested abort of change\n");
1808 COMBOEX_SetEditText (infoPtr, infoPtr->edit);
1809 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1810 RDW_INVALIDATE);
1811 return 0;
1813 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1814 if (oldItem != -1) {
1815 /* if something is selected, then deselect it */
1816 SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
1817 (WPARAM)-1, 0);
1819 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1820 SetFocus(infoPtr->hwndEdit);
1821 break;
1823 case VK_UP:
1824 step = -1;
1825 case VK_DOWN:
1826 /* by default, step is 1 */
1827 oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0);
1828 if (oldItem >= 0 && oldItem + step >= 0)
1829 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0);
1830 return 0;
1831 default:
1832 return CallWindowProcW (infoPtr->prevEditWndProc,
1833 hwnd, uMsg, wParam, lParam);
1835 return 0;
1838 case WM_SETFOCUS:
1839 /* remember the focus to set state of icon */
1840 lret = CallWindowProcW (infoPtr->prevEditWndProc,
1841 hwnd, uMsg, wParam, lParam);
1842 infoPtr->flags |= WCBE_EDITFOCUSED;
1843 return lret;
1845 case WM_KILLFOCUS:
1847 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
1849 infoPtr->flags &= ~WCBE_EDITFOCUSED;
1850 if (infoPtr->flags & WCBE_ACTEDIT) {
1851 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1853 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1854 cbeend.fChanged = FALSE;
1855 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1856 CB_GETCURSEL, 0, 0);
1857 cbeend.iWhy = CBENF_KILLFOCUS;
1859 COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
1861 /* fall through */
1863 default:
1864 return CallWindowProcW (infoPtr->prevEditWndProc,
1865 hwnd, uMsg, wParam, lParam);
1867 return 0;
1871 static LRESULT WINAPI
1872 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1874 HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP);
1875 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
1876 NMCBEENDEDITW cbeend;
1877 NMMOUSE nmmse;
1878 COLORREF obkc;
1879 HDC hDC;
1880 HWND focusedhwnd;
1881 RECT rect;
1882 POINT pt;
1883 WCHAR edit_text[260];
1885 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1886 hwnd, uMsg, wParam, lParam, infoPtr);
1888 if (!infoPtr) return 0;
1890 switch (uMsg)
1893 case WM_DRAWITEM:
1895 * The only way this message should come is from the
1896 * child Listbox issuing the message. Flag this so
1897 * that ComboEx knows this is listbox.
1899 ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
1900 return CallWindowProcW (infoPtr->prevComboWndProc,
1901 hwnd, uMsg, wParam, lParam);
1903 case WM_ERASEBKGND:
1905 * The following was determined by traces of the native
1907 hDC = (HDC) wParam;
1908 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW));
1909 GetClientRect (hwnd, &rect);
1910 TRACE("erasing (%ld,%ld)-(%ld,%ld)\n",
1911 rect.left, rect.top, rect.right, rect.bottom);
1912 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1913 SetBkColor (hDC, obkc);
1914 return CallWindowProcW (infoPtr->prevComboWndProc,
1915 hwnd, uMsg, wParam, lParam);
1917 case WM_SETCURSOR:
1919 * WM_NOTIFY to comboex parent (rebar)
1920 * with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
1921 * CallWindowProc (previous)
1923 nmmse.dwItemSpec = 0;
1924 nmmse.dwItemData = 0;
1925 nmmse.pt.x = 0;
1926 nmmse.pt.y = 0;
1927 nmmse.dwHitInfo = lParam;
1928 COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
1929 return CallWindowProcW (infoPtr->prevComboWndProc,
1930 hwnd, uMsg, wParam, lParam);
1932 case WM_LBUTTONDOWN:
1933 GetClientRect (hwnd, &rect);
1934 rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf,
1935 CB_GETITEMHEIGHT, -1, 0);
1936 rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
1937 POINTSTOPOINT(pt, MAKEPOINTS(lParam));
1938 if (PtInRect(&rect, pt))
1939 return CallWindowProcW (infoPtr->prevComboWndProc,
1940 hwnd, uMsg, wParam, lParam);
1941 infoPtr->flags |= WCBE_MOUSECAPTURED;
1942 SetCapture(hwnd);
1943 break;
1945 case WM_LBUTTONUP:
1946 if (!(infoPtr->flags & WCBE_MOUSECAPTURED))
1947 return CallWindowProcW (infoPtr->prevComboWndProc,
1948 hwnd, uMsg, wParam, lParam);
1949 ReleaseCapture();
1950 infoPtr->flags &= ~WCBE_MOUSECAPTURED;
1951 if (infoPtr->flags & WCBE_MOUSEDRAGGED) {
1952 infoPtr->flags &= ~WCBE_MOUSEDRAGGED;
1953 } else {
1954 SendMessageW(hwnd, CB_SHOWDROPDOWN, TRUE, 0);
1956 break;
1958 case WM_MOUSEMOVE:
1959 if ( (infoPtr->flags & WCBE_MOUSECAPTURED) &&
1960 !(infoPtr->flags & WCBE_MOUSEDRAGGED)) {
1961 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1962 COMBOEX_NotifyDragBegin(infoPtr, edit_text);
1963 infoPtr->flags |= WCBE_MOUSEDRAGGED;
1965 return CallWindowProcW (infoPtr->prevComboWndProc,
1966 hwnd, uMsg, wParam, lParam);
1968 case WM_COMMAND:
1969 switch (HIWORD(wParam)) {
1971 case EN_UPDATE:
1972 /* traces show that COMBOEX does not issue CBN_EDITUPDATE
1973 * on the EN_UPDATE
1975 return 0;
1977 case EN_KILLFOCUS:
1979 * Native does:
1981 * GetFocus() retns AA
1982 * GetWindowTextA(Edit)
1983 * CB_GETCURSEL(Combo) (got -1)
1984 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1985 * CB_GETCURSEL(Combo) (got -1)
1986 * InvalidateRect(Combo, 0, 0)
1987 * WM_KILLFOCUS(Combo, AA)
1988 * return 0;
1990 focusedhwnd = GetFocus();
1991 if (infoPtr->flags & WCBE_ACTEDIT) {
1992 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1993 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1994 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1995 CB_GETCURSEL, 0, 0);
1996 cbeend.iWhy = CBENF_KILLFOCUS;
1998 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1999 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
2001 /* possible CB_GETCURSEL */
2002 InvalidateRect (infoPtr->hwndCombo, 0, 0);
2003 if (focusedhwnd)
2004 SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
2005 (WPARAM)focusedhwnd, 0);
2006 return 0;
2008 case EN_SETFOCUS: {
2010 * For EN_SETFOCUS this issues the same calls and messages
2011 * as the native seems to do.
2013 * for some cases however native does the following:
2014 * (noticed after SetFocus during LBUTTONDOWN on
2015 * on dropdown arrow)
2016 * WM_GETTEXTLENGTH (Edit);
2017 * WM_GETTEXT (Edit, len+1, str);
2018 * EM_SETSEL (Edit, 0, 0);
2019 * WM_GETTEXTLENGTH (Edit);
2020 * WM_GETTEXT (Edit, len+1, str);
2021 * EM_SETSEL (Edit, 0, len);
2022 * WM_NOTIFY (parent, CBEN_BEGINEDIT)
2024 NMHDR hdr;
2026 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
2027 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
2028 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
2029 infoPtr->flags |= WCBE_ACTEDIT;
2030 infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
2031 return 0;
2034 case EN_CHANGE: {
2036 * For EN_CHANGE this issues the same calls and messages
2037 * as the native seems to do.
2039 WCHAR edit_text[260];
2040 LPCWSTR lastwrk;
2041 cmp_func_t cmptext = get_cmp_func(infoPtr);
2043 INT selected = SendMessageW (infoPtr->hwndCombo,
2044 CB_GETCURSEL, 0, 0);
2046 /* lstrlenA( lastworkingURL ) */
2048 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2049 if (selected == -1) {
2050 lastwrk = infoPtr->edit->pszText;
2052 else {
2053 CBE_ITEMDATA *item = COMBOEX_FindItem (infoPtr, selected);
2054 lastwrk = COMBOEX_GetText(infoPtr, item);
2057 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
2058 selected, debugstr_w(lastwrk));
2059 TRACE("handling EN_CHANGE, edittext=%s\n",
2060 debugstr_w(edit_text));
2062 /* cmptext is between lastworkingURL and GetWindowText */
2063 if (cmptext (lastwrk, edit_text)) {
2064 /* strings not equal -- indicate edit has changed */
2065 infoPtr->flags |= WCBE_EDITCHG;
2067 SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
2068 MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
2069 CBN_EDITCHANGE),
2070 (LPARAM)infoPtr->hwndSelf);
2071 return 0;
2074 case LBN_SELCHANGE:
2076 * Therefore from traces there is no additional code here
2080 * Using native COMCTL32 gets the following:
2081 * 1 == SHDOCVW.DLL issues call/message
2082 * 2 == COMCTL32.DLL issues call/message
2083 * 3 == WINE issues call/message
2086 * for LBN_SELCHANGE:
2087 * 1 CB_GETCURSEL(ComboEx)
2088 * 1 CB_GETDROPPEDSTATE(ComboEx)
2089 * 1 CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
2090 * 2 CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
2091 ** call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
2092 * 3 WM_COMMAND(ComboEx, CBN_SELENDOK)
2093 * WM_USER+49(ComboLB, 1,0) <=============!!!!!!!!!!!
2094 * 3 ShowWindow(ComboLB, SW_HIDE)
2095 * 3 RedrawWindow(Combo, RDW_UPDATENOW)
2096 * 3 WM_COMMAND(ComboEX, CBN_CLOSEUP)
2097 ** end of CBRollUp
2098 * 3 WM_COMMAND(ComboEx, CBN_SELCHANGE) (echo to parent)
2099 * ? LB_GETCURSEL <==|
2100 * ? LB_GETTEXTLEN |
2101 * ? LB_GETTEXT | Needs to be added to
2102 * ? WM_CTLCOLOREDIT(ComboEx) | Combo processing
2103 * ? LB_GETITEMDATA |
2104 * ? WM_DRAWITEM(ComboEx) <==|
2106 default:
2107 break;
2108 }/* fall through */
2109 default:
2110 return CallWindowProcW (infoPtr->prevComboWndProc,
2111 hwnd, uMsg, wParam, lParam);
2113 return 0;
2117 static LRESULT WINAPI
2118 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2120 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
2122 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2124 if (!infoPtr) {
2125 if (uMsg == WM_CREATE)
2126 return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam);
2127 if (uMsg == WM_NCCREATE)
2128 COMBOEX_NCCreate (hwnd);
2129 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2132 switch (uMsg)
2134 case CBEM_DELETEITEM:
2135 return COMBOEX_DeleteItem (infoPtr, wParam);
2137 case CBEM_GETCOMBOCONTROL:
2138 return (LRESULT)infoPtr->hwndCombo;
2140 case CBEM_GETEDITCONTROL:
2141 return (LRESULT)infoPtr->hwndEdit;
2143 case CBEM_GETEXTENDEDSTYLE:
2144 return infoPtr->dwExtStyle;
2146 case CBEM_GETIMAGELIST:
2147 return (LRESULT)infoPtr->himl;
2149 case CBEM_GETITEMA:
2150 return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2152 case CBEM_GETITEMW:
2153 return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2155 case CBEM_GETUNICODEFORMAT:
2156 return infoPtr->unicode;
2158 case CBEM_HASEDITCHANGED:
2159 return COMBOEX_HasEditChanged (infoPtr);
2161 case CBEM_INSERTITEMA:
2162 return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2164 case CBEM_INSERTITEMW:
2165 return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2167 case CBEM_SETEXSTYLE:
2168 case CBEM_SETEXTENDEDSTYLE:
2169 return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam);
2171 case CBEM_SETIMAGELIST:
2172 return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam);
2174 case CBEM_SETITEMA:
2175 return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2177 case CBEM_SETITEMW:
2178 return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2180 case CBEM_SETUNICODEFORMAT:
2181 return COMBOEX_SetUnicodeFormat (infoPtr, wParam);
2183 /*case CBEM_SETWINDOWTHEME:
2184 FIXME("CBEM_SETWINDOWTHEME: stub\n");*/
2186 case WM_SETTEXT:
2187 case WM_GETTEXT:
2188 return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam);
2190 /* Combo messages we are not sure if we need to process or just forward */
2191 case CB_GETDROPPEDCONTROLRECT:
2192 case CB_GETITEMHEIGHT:
2193 case CB_GETLBTEXT:
2194 case CB_GETLBTEXTLEN:
2195 case CB_GETEXTENDEDUI:
2196 case CB_LIMITTEXT:
2197 case CB_RESETCONTENT:
2198 case CB_SELECTSTRING:
2200 /* Combo messages OK to just forward to the regular COMBO */
2201 case CB_GETCOUNT:
2202 case CB_GETCURSEL:
2203 case CB_GETDROPPEDSTATE:
2204 case CB_SETDROPPEDWIDTH:
2205 case CB_SETEXTENDEDUI:
2206 case CB_SHOWDROPDOWN:
2207 return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam);
2209 /* Combo messages we need to process specially */
2210 case CB_FINDSTRINGEXACT:
2211 return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCWSTR)lParam);
2213 case CB_GETITEMDATA:
2214 return COMBOEX_GetItemData (infoPtr, (INT)wParam);
2216 case CB_SETCURSEL:
2217 return COMBOEX_SetCursel (infoPtr, (INT)wParam);
2219 case CB_SETITEMDATA:
2220 return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD)lParam);
2222 case CB_SETITEMHEIGHT:
2223 return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam);
2227 /* Window messages passed to parent */
2228 case WM_COMMAND:
2229 return COMBOEX_Command (infoPtr, wParam, lParam);
2231 case WM_NOTIFY:
2232 if (infoPtr->NtfUnicode)
2233 return SendMessageW (GetParent (hwnd), uMsg, wParam, lParam);
2234 else
2235 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2238 /* Window messages we need to process */
2239 case WM_DELETEITEM:
2240 return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam);
2242 case WM_DRAWITEM:
2243 return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam);
2245 case WM_DESTROY:
2246 return COMBOEX_Destroy (infoPtr);
2248 case WM_MEASUREITEM:
2249 return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam);
2251 case WM_NOTIFYFORMAT:
2252 return COMBOEX_NotifyFormat (infoPtr, lParam);
2254 case WM_SIZE:
2255 return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam));
2257 case WM_WINDOWPOSCHANGING:
2258 return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam);
2260 default:
2261 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
2262 ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam);
2263 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2265 return 0;
2269 void COMBOEX_Register (void)
2271 WNDCLASSW wndClass;
2273 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
2274 wndClass.style = CS_GLOBALCLASS;
2275 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
2276 wndClass.cbClsExtra = 0;
2277 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
2278 wndClass.hCursor = LoadCursorW (0, IDC_ARROWW);
2279 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2280 wndClass.lpszClassName = WC_COMBOBOXEXW;
2282 RegisterClassW (&wndClass);
2286 void COMBOEX_Unregister (void)
2288 UnregisterClassW (WC_COMBOBOXEXW, NULL);