Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / comctl32 / comboex.c
blobc0099e85aa0cd1edaf09d5a3c22731bc85920c62
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 <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 "wine/debug.h"
42 #include "wine/unicode.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(comboex);
46 /* Item structure */
47 typedef struct
49 VOID *next;
50 UINT mask;
51 LPWSTR pszText;
52 LPWSTR pszTemp;
53 int cchTextMax;
54 int iImage;
55 int iSelectedImage;
56 int iOverlay;
57 int iIndent;
58 LPARAM lParam;
59 } CBE_ITEMDATA;
61 /* ComboBoxEx structure */
62 typedef struct
64 HIMAGELIST himl;
65 HWND hwndSelf; /* my own hwnd */
66 HWND hwndCombo;
67 HWND hwndEdit;
68 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */
69 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */
70 DWORD dwExtStyle;
71 INT selected; /* index of selected item */
72 DWORD flags; /* WINE internal flags */
73 HFONT defaultFont;
74 HFONT font;
75 INT nb_items; /* Number of items */
76 BOOL unicode; /* TRUE if this window is Unicode */
77 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */
78 CBE_ITEMDATA *edit; /* item data for edit item */
79 CBE_ITEMDATA *items; /* Array of items */
80 } COMBOEX_INFO;
82 /* internal flags in the COMBOEX_INFO structure */
83 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e.
84 * CBEN_BEGINEDIT issued
85 * but CBEN_ENDEDIT{A|W}
86 * not yet issued. */
87 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */
88 #define WCBE_EDITHASCHANGED (WCBE_ACTEDIT | WCBE_EDITCHG)
89 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */
90 #define WCBE_MOUSECAPTURED 0x00000008 /* Combo has captured mouse */
91 #define WCBE_MOUSEDRAGGED 0x00000010 /* User has dragged in combo */
93 #define ID_CB_EDIT 1001
97 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
98 * the ComboEx version of the Combo Window Proc so that when the
99 * WM_DRAWITEM message is then passed to ComboEx, we know that this
100 * particular WM_DRAWITEM message is for listbox only items. Any messasges
101 * without this flag is then for the Edit control field.
103 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
104 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
106 #define ODS_COMBOEXLBOX 0x4000
110 /* Height in pixels of control over the amount of the selected font */
111 #define CBE_EXTRA 3
113 /* Indent amount per MS documentation */
114 #define CBE_INDENT 10
116 /* Offset in pixels from left side for start of image or text */
117 #define CBE_STARTOFFSET 6
119 /* Offset between image and text */
120 #define CBE_SEP 4
122 #define COMBOEX_SUBCLASS_PROP "CCComboEx32SubclassInfo"
123 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongW (hwnd, 0))
126 /* Things common to the entire DLL */
127 static LRESULT WINAPI
128 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
129 static LRESULT WINAPI
130 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
131 static int CALLBACK
132 COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code);
133 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr);
134 typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR);
136 inline static BOOL is_textW(LPCWSTR str)
138 return str && str != LPSTR_TEXTCALLBACKW;
141 inline static BOOL is_textA(LPCSTR str)
143 return str && str != LPSTR_TEXTCALLBACKA;
146 inline static LPCSTR debugstr_txt(LPCWSTR str)
148 if (str == LPSTR_TEXTCALLBACKW) return "(callback)";
149 return debugstr_w(str);
152 static void COMBOEX_DumpItem (CBE_ITEMDATA *item)
154 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
155 item, item->mask, item->pszText, item->cchTextMax, item->iImage);
156 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
157 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
158 if (item->mask & CBEIF_TEXT)
159 TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText));
163 static void COMBOEX_DumpInput (COMBOBOXEXITEMW *input)
165 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
166 input->mask, input->iItem, input->pszText, input->cchTextMax,
167 input->iImage);
168 if (input->mask & CBEIF_TEXT)
169 TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText));
170 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
171 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
175 inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index)
177 return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA,
178 (WPARAM)index, 0);
181 inline static cmp_func_t get_cmp_func(COMBOEX_INFO *infoPtr)
183 return infoPtr->dwExtStyle & CBES_EX_CASESENSITIVE ? lstrcmpW : lstrcmpiW;
186 static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
188 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
189 hdr->hwndFrom = infoPtr->hwndSelf;
190 hdr->code = code;
191 if (infoPtr->NtfUnicode)
192 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
193 (LPARAM)hdr);
194 else
195 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
196 (LPARAM)hdr);
200 static INT
201 COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT 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 = (LPSTR)COMCTL32_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 if (astr) COMCTL32_Free(astr);
232 return ret;
237 static INT COMBOEX_NotifyEndEdit (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 memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR));
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(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)) COMCTL32_Free(item->pszText);
280 item->pszText = 0;
281 if (item->pszTemp) COMCTL32_Free(item->pszTemp);
282 item->pszTemp = 0;
286 static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
288 NMCOMBOBOXEXW nmce;
289 LPWSTR text, buf;
290 INT len;
292 if (item->pszText != LPSTR_TEXTCALLBACKW)
293 return item->pszText;
295 ZeroMemory(&nmce, sizeof(nmce));
296 nmce.ceItem.mask = CBEIF_TEXT;
297 nmce.ceItem.lParam = item->lParam;
298 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
300 if (is_textW(nmce.ceItem.pszText)) {
301 len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0);
302 buf = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
303 if (buf)
304 MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len);
305 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) {
306 COMBOEX_FreeText(item);
307 item->pszText = buf;
308 } else {
309 if (item->pszTemp) COMCTL32_Free(item->pszTemp);
310 item->pszTemp = buf;
312 text = buf;
313 } else
314 text = nmce.ceItem.pszText;
316 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
317 item->pszText = text;
318 return text;
322 static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
324 HFONT nfont, ofont;
325 HDC mydc;
327 mydc = GetDC (0); /* why the entire screen???? */
328 nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
329 ofont = (HFONT) SelectObject (mydc, nfont);
330 GetTextExtentPointA (mydc, "A", 1, size);
331 SelectObject (mydc, ofont);
332 ReleaseDC (0, mydc);
333 TRACE("selected font hwnd=%p, height=%ld\n", nfont, size->cy);
337 static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
339 if (cit->mask & CBEIF_TEXT) {
341 * when given a text buffer actually use that buffer
343 if (cit->pszText) {
344 if (is_textW(item->pszText))
345 lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax);
346 else
347 cit->pszText[0] = 0;
348 } else {
349 cit->pszText = item->pszText;
350 cit->cchTextMax = item->cchTextMax;
353 if (cit->mask & CBEIF_IMAGE)
354 cit->iImage = item->iImage;
355 if (cit->mask & CBEIF_SELECTEDIMAGE)
356 cit->iSelectedImage = item->iSelectedImage;
357 if (cit->mask & CBEIF_OVERLAY)
358 cit->iOverlay = item->iOverlay;
359 if (cit->mask & CBEIF_INDENT)
360 cit->iIndent = item->iIndent;
361 if (cit->mask & CBEIF_LPARAM)
362 cit->lParam = item->lParam;
366 static void COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
368 SIZE mysize;
369 INT x, y, w, h, xioff;
370 RECT rect;
372 if (!infoPtr->hwndEdit) return;
374 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
375 IMAGEINFO iinfo;
376 iinfo.rcImage.left = iinfo.rcImage.right = 0;
377 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
378 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
379 } else xioff = 0;
381 GetClientRect (infoPtr->hwndCombo, &rect);
382 InflateRect (&rect, -2, -2);
383 InvalidateRect (infoPtr->hwndCombo, &rect, TRUE);
385 /* reposition the Edit control based on whether icon exists */
386 COMBOEX_GetComboFontSize (infoPtr, &mysize);
387 TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy);
388 x = xioff + CBE_STARTOFFSET + 1;
389 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
390 h = mysize.cy + 1;
391 y = rect.bottom - h - 1;
393 TRACE("Combo client (%ld,%ld)-(%ld,%ld), setting Edit to (%d,%d)-(%d,%d)\n",
394 rect.left, rect.top, rect.right, rect.bottom, x, y, x + w, y + h);
395 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h,
396 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
400 static void COMBOEX_ReSize (COMBOEX_INFO *infoPtr)
402 SIZE mysize;
403 UINT cy;
404 IMAGEINFO iinfo;
406 COMBOEX_GetComboFontSize (infoPtr, &mysize);
407 cy = mysize.cy + CBE_EXTRA;
408 if (infoPtr->himl && ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo)) {
409 cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
410 TRACE("upgraded height due to image: height=%d\n", cy);
412 SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy);
413 if (infoPtr->hwndCombo) {
414 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
415 (WPARAM) 0, (LPARAM) cy);
416 if ( !(infoPtr->flags & CBES_EX_NOSIZELIMIT)) {
417 RECT comboRect;
418 if (GetWindowRect(infoPtr->hwndCombo, &comboRect)) {
419 RECT ourRect;
420 if (GetWindowRect(infoPtr->hwndSelf, &ourRect)) {
421 if (comboRect.bottom > ourRect.bottom) {
422 POINT pt = { ourRect.left, ourRect.top };
423 if (ScreenToClient(infoPtr->hwndSelf, &pt))
424 MoveWindow( infoPtr->hwndSelf, pt.x, pt.y, ourRect.right - ourRect.left,
425 comboRect.bottom - comboRect.top, FALSE);
434 static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
436 if (!infoPtr->hwndEdit) return;
437 /* native issues the following messages to the {Edit} control */
438 /* WM_SETTEXT (0,addr) */
439 /* EM_SETSEL32 (0,0) */
440 /* EM_SETSEL32 (0,-1) */
441 if (item->mask & CBEIF_TEXT) {
442 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item));
443 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
444 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
449 static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
451 CBE_ITEMDATA *item;
452 INT i;
454 if ((index > infoPtr->nb_items) || (index < -1))
455 return 0;
456 if (index == -1)
457 return infoPtr->edit;
458 item = infoPtr->items;
459 i = infoPtr->nb_items - 1;
461 /* find the item in the list */
462 while (item && (i > index)) {
463 item = (CBE_ITEMDATA *)item->next;
464 i--;
466 if (!item || (i != index)) {
467 ERR("COMBOBOXEX item structures broken. Please report!\n");
468 return 0;
470 return item;
474 static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr)
476 return infoPtr->hwndEdit ? TRUE : FALSE;
480 /* *** CBEM_xxx message support *** */
483 static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT index)
485 CBE_ITEMDATA *item;
487 TRACE("(index=%d)\n", index);
489 /* if item number requested does not exist then return failure */
490 if ((index > infoPtr->nb_items) || (index < 0)) return CB_ERR;
491 if (!(item = COMBOEX_FindItem(infoPtr, index))) return CB_ERR;
493 /* doing this will result in WM_DELETEITEM being issued */
494 SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0);
496 return infoPtr->nb_items;
500 static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
502 INT index = cit->iItem;
503 CBE_ITEMDATA *item;
505 TRACE("(...)\n");
507 /* if item number requested does not exist then return failure */
508 if ((index > infoPtr->nb_items) || (index < -1)) return FALSE;
510 /* if the item is the edit control and there is no edit control, skip */
511 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
513 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
515 COMBOEX_CopyItem (item, cit);
517 return TRUE;
521 static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
523 COMBOBOXEXITEMW tmpcit;
525 TRACE("(...)\n");
527 tmpcit.mask = cit->mask;
528 tmpcit.iItem = cit->iItem;
529 tmpcit.pszText = 0;
530 if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE;
532 if (is_textW(tmpcit.pszText) && cit->pszText)
533 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
534 cit->pszText, cit->cchTextMax, NULL, NULL);
535 else if (cit->pszText) cit->pszText[0] = 0;
536 else cit->pszText = (LPSTR)tmpcit.pszText;
538 cit->iImage = tmpcit.iImage;
539 cit->iSelectedImage = tmpcit.iSelectedImage;
540 cit->iOverlay = tmpcit.iOverlay;
541 cit->iIndent = tmpcit.iIndent;
542 cit->lParam = tmpcit.lParam;
544 return TRUE;
548 inline static BOOL COMBOEX_HasEditChanged (COMBOEX_INFO *infoPtr)
550 return COMBOEX_HasEdit(infoPtr) &&
551 (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED;
555 static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
557 INT index;
558 CBE_ITEMDATA *item;
559 NMCOMBOBOXEXW nmcit;
561 TRACE("\n");
563 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
565 /* get real index of item to insert */
566 index = cit->iItem;
567 if (index == -1) index = infoPtr->nb_items;
568 if (index > infoPtr->nb_items) index = infoPtr->nb_items;
570 /* get zero-filled space and chain it in */
571 if(!(item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof(*item)))) return -1;
573 /* locate position to insert new item in */
574 if (index == infoPtr->nb_items) {
575 /* fast path for iItem = -1 */
576 item->next = infoPtr->items;
577 infoPtr->items = item;
579 else {
580 INT i = infoPtr->nb_items-1;
581 CBE_ITEMDATA *moving = infoPtr->items;
583 while ((i > index) && moving) {
584 moving = (CBE_ITEMDATA *)moving->next;
585 i--;
587 if (!moving) {
588 ERR("COMBOBOXEX item structures broken. Please report!\n");
589 COMCTL32_Free(item);
590 return -1;
592 item->next = moving->next;
593 moving->next = item;
596 /* fill in our hidden item structure */
597 item->mask = cit->mask;
598 if (item->mask & CBEIF_TEXT) {
599 INT len = 0;
601 if (is_textW(cit->pszText)) len = strlenW (cit->pszText);
602 if (len > 0) {
603 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
604 if (!item->pszText) {
605 COMCTL32_Free(item);
606 return -1;
608 strcpyW (item->pszText, cit->pszText);
610 else if (cit->pszText == LPSTR_TEXTCALLBACKW)
611 item->pszText = LPSTR_TEXTCALLBACKW;
612 item->cchTextMax = cit->cchTextMax;
614 if (item->mask & CBEIF_IMAGE)
615 item->iImage = cit->iImage;
616 if (item->mask & CBEIF_SELECTEDIMAGE)
617 item->iSelectedImage = cit->iSelectedImage;
618 if (item->mask & CBEIF_OVERLAY)
619 item->iOverlay = cit->iOverlay;
620 if (item->mask & CBEIF_INDENT)
621 item->iIndent = cit->iIndent;
622 if (item->mask & CBEIF_LPARAM)
623 item->lParam = cit->lParam;
624 infoPtr->nb_items++;
626 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
628 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
629 (WPARAM)cit->iItem, (LPARAM)item);
631 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
632 COMBOEX_CopyItem (item, &nmcit.ceItem);
633 COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit);
635 return index;
640 static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
642 COMBOBOXEXITEMW citW;
643 LPWSTR wstr = NULL;
644 INT ret;
646 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
647 if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) {
648 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
649 wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
650 if (!wstr) return -1;
651 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
652 citW.pszText = wstr;
654 ret = COMBOEX_InsertItemW(infoPtr, &citW);
656 if (wstr) COMCTL32_Free(wstr);
658 return ret;
662 static DWORD
663 COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style)
665 DWORD dwTemp;
667 TRACE("(mask=x%08lx, style=0x%08lx)\n", mask, style);
669 dwTemp = infoPtr->dwExtStyle;
671 if (mask)
672 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style;
673 else
674 infoPtr->dwExtStyle = style;
676 /* see if we need to change the word break proc on the edit */
677 if ((infoPtr->dwExtStyle ^ dwTemp) & CBES_EX_PATHWORDBREAKPROC) {
678 SendMessageW(infoPtr->hwndEdit, EM_SETWORDBREAKPROC, 0,
679 (infoPtr->dwExtStyle & CBES_EX_PATHWORDBREAKPROC) ?
680 (LPARAM)COMBOEX_PathWordBreakProc : 0);
683 /* test if the control's appearance has changed */
684 mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT;
685 if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) {
686 /* if state of EX_NOEDITIMAGE changes, invalidate all */
687 TRACE("EX_NOEDITIMAGE state changed to %ld\n",
688 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
689 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
690 COMBOEX_AdjustEditPos (infoPtr);
691 if (infoPtr->hwndEdit)
692 InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
695 return dwTemp;
699 static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl)
701 HIMAGELIST himlTemp = infoPtr->himl;
703 TRACE("(...)\n");
705 infoPtr->himl = himl;
707 COMBOEX_ReSize (infoPtr);
708 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
710 /* reposition the Edit control based on whether icon exists */
711 COMBOEX_AdjustEditPos (infoPtr);
712 return himlTemp;
715 static BOOL COMBOEX_SetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
717 INT index = cit->iItem;
718 CBE_ITEMDATA *item;
720 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
722 /* if item number requested does not exist then return failure */
723 if ((index > infoPtr->nb_items) || (index < -1)) return FALSE;
725 /* if the item is the edit control and there is no edit control, skip */
726 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
728 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
730 /* add/change stuff to the internal item structure */
731 item->mask |= cit->mask;
732 if (cit->mask & CBEIF_TEXT) {
733 INT len = 0;
735 COMBOEX_FreeText(item);
736 if (is_textW(cit->pszText)) len = strlenW(cit->pszText);
737 if (len > 0) {
738 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
739 if (!item->pszText) return FALSE;
740 strcpyW(item->pszText, cit->pszText);
741 } else if (cit->pszText == LPSTR_TEXTCALLBACKW)
742 item->pszText = LPSTR_TEXTCALLBACKW;
743 item->cchTextMax = cit->cchTextMax;
745 if (cit->mask & CBEIF_IMAGE)
746 item->iImage = cit->iImage;
747 if (cit->mask & CBEIF_SELECTEDIMAGE)
748 item->iSelectedImage = cit->iSelectedImage;
749 if (cit->mask & CBEIF_OVERLAY)
750 item->iOverlay = cit->iOverlay;
751 if (cit->mask & CBEIF_INDENT)
752 item->iIndent = cit->iIndent;
753 if (cit->mask & CBEIF_LPARAM)
754 cit->lParam = cit->lParam;
756 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
758 /* if original request was to update edit control, do some fast foot work */
759 if (cit->iItem == -1) {
760 COMBOEX_SetEditText (infoPtr, item);
761 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
763 return TRUE;
766 static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
768 COMBOBOXEXITEMW citW;
769 LPWSTR wstr = NULL;
770 BOOL ret;
772 memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA));
773 if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) {
774 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
775 wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
776 if (!wstr) return FALSE;
777 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
778 citW.pszText = wstr;
780 ret = COMBOEX_SetItemW(infoPtr, &citW);
782 if (wstr) COMCTL32_Free(wstr);
784 return ret;
788 static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value)
790 BOOL bTemp = infoPtr->unicode;
792 TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE");
794 infoPtr->unicode = value;
796 return bTemp;
800 /* *** CB_xxx message support *** */
802 static INT
803 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCWSTR str)
805 INT i;
806 cmp_func_t cmptext = get_cmp_func(infoPtr);
807 INT count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
809 /* now search from after starting loc and wrapping back to start */
810 for(i=start+1; i<count; i++) {
811 CBE_ITEMDATA *item = get_item_data(infoPtr, i);
812 if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
814 for(i=0; i<=start; i++) {
815 CBE_ITEMDATA *item = get_item_data(infoPtr, i);
816 if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
818 return CB_ERR;
822 static DWORD COMBOEX_GetItemData (COMBOEX_INFO *infoPtr, INT index)
824 CBE_ITEMDATA *item1, *item2;
825 DWORD ret = 0;
827 item1 = get_item_data(infoPtr, index);
828 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
829 item2 = COMBOEX_FindItem (infoPtr, index);
830 if (item2 != item1) {
831 ERR("data structures damaged!\n");
832 return CB_ERR;
834 if (item1->mask & CBEIF_LPARAM) ret = item1->lParam;
835 TRACE("returning 0x%08lx\n", ret);
836 } else {
837 ret = (DWORD)item1;
838 TRACE("non-valid result from combo, returning 0x%08lx\n", ret);
840 return ret;
844 static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT index)
846 CBE_ITEMDATA *item;
847 INT sel;
849 if (!(item = COMBOEX_FindItem(infoPtr, index)))
850 return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
852 TRACE("selecting item %d text=%s\n", index, debugstr_txt(item->pszText));
853 infoPtr->selected = index;
855 sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
856 COMBOEX_SetEditText (infoPtr, item);
857 return sel;
861 static DWORD COMBOEX_SetItemData (COMBOEX_INFO *infoPtr, INT index, DWORD data)
863 CBE_ITEMDATA *item1, *item2;
865 item1 = get_item_data(infoPtr, index);
866 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
867 item2 = COMBOEX_FindItem (infoPtr, index);
868 if (item2 != item1) {
869 ERR("data structures damaged!\n");
870 return CB_ERR;
872 item1->mask |= CBEIF_LPARAM;
873 item1->lParam = data;
874 TRACE("setting lparam to 0x%08lx\n", data);
875 return 0;
877 TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1);
878 return (LRESULT)item1;
882 static INT COMBOEX_SetItemHeight (COMBOEX_INFO *infoPtr, INT index, UINT height)
884 RECT cb_wrect, cbx_wrect, cbx_crect;
886 /* First, lets forward the message to the normal combo control
887 just like Windows. */
888 if (infoPtr->hwndCombo)
889 if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
890 index, height) == CB_ERR) return CB_ERR;
892 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
893 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
894 GetClientRect (infoPtr->hwndSelf, &cbx_crect);
895 /* the height of comboex as height of the combo + comboex border */
896 height = cb_wrect.bottom-cb_wrect.top
897 + cbx_wrect.bottom-cbx_wrect.top
898 - (cbx_crect.bottom-cbx_crect.top);
899 TRACE("EX window=(%ld,%ld)-(%ld,%ld), client=(%ld,%ld)-(%ld,%ld)\n",
900 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
901 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
902 TRACE("CB window=(%ld,%ld)-(%ld,%ld), EX setting=(0,0)-(%ld,%d)\n",
903 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
904 cbx_wrect.right-cbx_wrect.left, height);
905 SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0,
906 cbx_wrect.right-cbx_wrect.left, height,
907 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
909 return 0;
913 /* *** WM_xxx message support *** */
916 static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs)
918 WCHAR COMBOBOX[] = { 'C', 'o', 'm', 'b', 'o', 'B', 'o', 'x', 0 };
919 WCHAR EDIT[] = { 'E', 'D', 'I', 'T', 0 };
920 WCHAR NIL[] = { 0 };
921 COMBOEX_INFO *infoPtr;
922 LOGFONTW mylogfont;
923 RECT wnrc1, clrc1, cmbwrc;
924 INT i;
926 /* allocate memory for info structure */
927 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
928 if (!infoPtr) return -1;
930 /* initialize info structure */
931 /* note that infoPtr is allocated zero-filled */
933 infoPtr->hwndSelf = hwnd;
934 infoPtr->selected = -1;
936 infoPtr->unicode = IsWindowUnicode (hwnd);
938 i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
939 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
940 WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
941 i = NFR_ANSI;
943 infoPtr->NtfUnicode = (i == NFR_UNICODE);
945 SetWindowLongW (hwnd, 0, (DWORD)infoPtr);
947 /* create combo box */
948 GetWindowRect(hwnd, &wnrc1);
949 GetClientRect(hwnd, &clrc1);
950 TRACE("EX window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld)\n",
951 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
952 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
954 /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
955 /* specified. It then creates it's own version of the EDIT control */
956 /* and makes the ComboBox the parent. This is because a normal */
957 /* DROPDOWNLIST does not have a EDIT control, but we need one. */
958 /* We also need to place the edit control at the proper location */
959 /* (allow space for the icons). */
961 infoPtr->hwndCombo = CreateWindowW (COMBOBOX, NIL,
962 /* following line added to match native */
963 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
964 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
965 /* was base and is necessary */
966 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED |
967 GetWindowLongW (hwnd, GWL_STYLE),
968 cs->y, cs->x, cs->cx, cs->cy, hwnd,
969 (HMENU) GetWindowLongW (hwnd, GWL_ID),
970 (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
973 * native does the following at this point according to trace:
974 * GetWindowThreadProcessId(hwndCombo,0)
975 * GetCurrentThreadId()
976 * GetWindowThreadProcessId(hwndCombo, &???)
977 * GetCurrentProcessId()
981 * Setup a property to hold the pointer to the COMBOBOXEX
982 * data structure.
984 SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd);
985 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo,
986 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
987 infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
991 * Now create our own EDIT control so we can position it.
992 * It is created only for CBS_DROPDOWN style
994 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
995 infoPtr->hwndEdit = CreateWindowExW (0, EDIT, NIL,
996 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
997 0, 0, 0, 0, /* will set later */
998 infoPtr->hwndCombo,
999 (HMENU) GetWindowLongW (hwnd, GWL_ID),
1000 (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
1002 /* native does the following at this point according to trace:
1003 * GetWindowThreadProcessId(hwndEdit,0)
1004 * GetCurrentThreadId()
1005 * GetWindowThreadProcessId(hwndEdit, &???)
1006 * GetCurrentProcessId()
1010 * Setup a property to hold the pointer to the COMBOBOXEX
1011 * data structure.
1013 SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd);
1014 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit,
1015 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
1016 infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1020 * Locate the default font if necessary and then set it in
1021 * all associated controls
1023 if (!infoPtr->font) {
1024 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
1025 &mylogfont, 0);
1026 infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont);
1028 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1029 if (infoPtr->hwndEdit) {
1030 SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1031 SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
1034 COMBOEX_ReSize (infoPtr);
1036 /* Above is fairly certain, below is much less certain. */
1038 GetWindowRect(hwnd, &wnrc1);
1039 GetClientRect(hwnd, &clrc1);
1040 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1041 TRACE("EX window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) CB wnd=(%ld,%ld)-(%ld,%ld)\n",
1042 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
1043 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
1044 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1045 SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
1046 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
1047 SWP_NOACTIVATE | SWP_NOREDRAW);
1049 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1050 TRACE("CB window=(%ld,%ld)-(%ld,%ld)\n",
1051 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1052 SetWindowPos(hwnd, HWND_TOP,
1053 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
1054 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
1056 COMBOEX_AdjustEditPos (infoPtr);
1059 * Create an item structure to represent the data in the
1060 * EDIT control. It is allocated zero-filled.
1062 infoPtr->edit = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
1063 if (!infoPtr->edit) {
1064 COMBOEX_Destroy(infoPtr);
1065 return -1;
1068 return 0;
1072 static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
1074 LRESULT lret;
1075 INT command = HIWORD(wParam);
1076 CBE_ITEMDATA *item = 0;
1077 WCHAR wintext[520];
1078 INT cursel, n, oldItem;
1079 NMCBEENDEDITW cbeend;
1080 DWORD oldflags;
1081 HWND parent = GetParent (infoPtr->hwndSelf);
1083 TRACE("for command %d\n", command);
1085 switch (command)
1087 case CBN_DROPDOWN:
1088 SetFocus (infoPtr->hwndCombo);
1089 ShowWindow (infoPtr->hwndEdit, SW_HIDE);
1090 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1092 case CBN_CLOSEUP:
1093 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1095 * from native trace of first dropdown after typing in URL in IE4
1096 * CB_GETCURSEL(Combo)
1097 * GetWindowText(Edit)
1098 * CB_GETCURSEL(Combo)
1099 * CB_GETCOUNT(Combo)
1100 * CB_GETITEMDATA(Combo, n)
1101 * WM_NOTIFY(parent, CBEN_ENDEDITA|W)
1102 * CB_GETCURSEL(Combo)
1103 * CB_SETCURSEL(COMBOEX, n)
1104 * SetFocus(Combo)
1105 * the rest is supposition
1107 ShowWindow (infoPtr->hwndEdit, SW_SHOW);
1108 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1109 InvalidateRect (infoPtr->hwndEdit, 0, TRUE);
1110 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1111 if (cursel == -1) {
1112 cmp_func_t cmptext = get_cmp_func(infoPtr);
1113 /* find match from edit against those in Combobox */
1114 GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
1115 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
1116 for (cursel = 0; cursel < n; cursel++){
1117 item = get_item_data(infoPtr, cursel);
1118 if ((INT)item == CB_ERR) break;
1119 if (!cmptext(COMBOEX_GetText(infoPtr, item), wintext)) break;
1121 if ((cursel == n) || ((INT)item == CB_ERR)) {
1122 TRACE("failed to find match??? item=%p cursel=%d\n",
1123 item, cursel);
1124 if (infoPtr->hwndEdit)
1125 SetFocus(infoPtr->hwndEdit);
1126 return 0;
1129 else {
1130 item = get_item_data(infoPtr, cursel);
1131 if ((INT)item == CB_ERR) {
1132 TRACE("failed to find match??? item=%p cursel=%d\n",
1133 item, cursel);
1134 if (infoPtr->hwndEdit)
1135 SetFocus(infoPtr->hwndEdit);
1136 return 0;
1140 /* Save flags for testing and reset them */
1141 oldflags = infoPtr->flags;
1142 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1144 if (oldflags & WCBE_ACTEDIT) {
1145 cbeend.fChanged = (oldflags & WCBE_EDITCHG);
1146 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1147 CB_GETCURSEL, 0, 0);
1148 cbeend.iWhy = CBENF_DROPDOWN;
1150 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0;
1153 /* if selection has changed the set the new current selection */
1154 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1155 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
1156 infoPtr->selected = cursel;
1157 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0);
1158 SetFocus(infoPtr->hwndCombo);
1160 return 0;
1162 case CBN_SELCHANGE:
1164 * CB_GETCURSEL(Combo)
1165 * CB_GETITEMDATA(Combo) < simulated by COMBOEX_FindItem
1166 * lstrlenA
1167 * WM_SETTEXT(Edit)
1168 * WM_GETTEXTLENGTH(Edit)
1169 * WM_GETTEXT(Edit)
1170 * EM_SETSEL(Edit, 0,0)
1171 * WM_GETTEXTLENGTH(Edit)
1172 * WM_GETTEXT(Edit)
1173 * EM_SETSEL(Edit, 0,len)
1174 * return WM_COMMAND to parent
1176 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1177 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1178 ERR("item %d not found. Problem!\n", oldItem);
1179 break;
1181 infoPtr->selected = oldItem;
1182 COMBOEX_SetEditText (infoPtr, item);
1183 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1185 case CBN_SELENDOK:
1187 * We have to change the handle since we are the control
1188 * issuing the message. IE4 depends on this.
1190 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1192 case CBN_KILLFOCUS:
1194 * from native trace:
1196 * pass to parent
1197 * WM_GETTEXT(Edit, 104)
1198 * CB_GETCURSEL(Combo) rets -1
1199 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1200 * CB_GETCURSEL(Combo)
1201 * InvalidateRect(Combo, 0, 0)
1202 * return 0
1204 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1205 if (infoPtr->flags & WCBE_ACTEDIT) {
1206 GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
1207 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1208 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1209 CB_GETCURSEL, 0, 0);
1210 cbeend.iWhy = CBENF_KILLFOCUS;
1212 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1213 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0;
1215 /* possible CB_GETCURSEL */
1216 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1217 return 0;
1219 default:
1221 * We have to change the handle since we are the control
1222 * issuing the message. IE4 depends on this.
1223 * We also need to set the focus back to the Edit control
1224 * after passing the command to the parent of the ComboEx.
1226 lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1227 if (infoPtr->hwndEdit)
1228 SetFocus(infoPtr->hwndEdit);
1229 return lret;
1231 return 0;
1235 static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis)
1237 CBE_ITEMDATA *item, *olditem;
1238 NMCOMBOBOXEXW nmcit;
1239 UINT i;
1241 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%p, data=%08lx\n",
1242 dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
1244 if (dis->itemID >= infoPtr->nb_items) return FALSE;
1246 olditem = infoPtr->items;
1247 i = infoPtr->nb_items - 1;
1249 if (i == dis->itemID) {
1250 infoPtr->items = infoPtr->items->next;
1252 else {
1253 item = olditem;
1254 i--;
1256 /* find the prior item in the list */
1257 while (item->next && (i > dis->itemID)) {
1258 item = (CBE_ITEMDATA *)item->next;
1259 i--;
1261 if (!item->next || (i != dis->itemID)) {
1262 ERR("COMBOBOXEX item structures broken. Please report!\n");
1263 return FALSE;
1265 olditem = item->next;
1266 item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
1268 infoPtr->nb_items--;
1270 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
1271 COMBOEX_CopyItem (olditem, &nmcit.ceItem);
1272 COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit);
1274 COMBOEX_FreeText(olditem);
1275 COMCTL32_Free(olditem);
1277 return TRUE;
1281 static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT *dis)
1283 WCHAR nil[] = { 0 };
1284 CBE_ITEMDATA *item = 0;
1285 SIZE txtsize;
1286 RECT rect;
1287 LPCWSTR str = nil;
1288 UINT xbase, x, y;
1289 INT len;
1290 COLORREF nbkc, ntxc, bkc, txc;
1291 int drawimage, drawstate, xioff;
1293 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
1295 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
1296 dis->CtlType, dis->CtlID);
1297 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
1298 dis->itemID, dis->itemAction, dis->itemState);
1299 TRACE("hWnd=%p hDC=%p (%ld,%ld)-(%ld,%ld) itemData=0x%08lx\n",
1300 dis->hwndItem, dis->hDC, dis->rcItem.left,
1301 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
1302 dis->itemData);
1304 /* MSDN says: */
1305 /* "itemID - Specifies the menu item identifier for a menu */
1306 /* item or the index of the item in a list box or combo box. */
1307 /* For an empty list box or combo box, this member can be -1. */
1308 /* This allows the application to draw only the focus */
1309 /* rectangle at the coordinates specified by the rcItem */
1310 /* member even though there are no items in the control. */
1311 /* This indicates to the user whether the list box or combo */
1312 /* box has the focus. How the bits are set in the itemAction */
1313 /* member determines whether the rectangle is to be drawn as */
1314 /* though the list box or combo box has the focus. */
1315 if (dis->itemID == 0xffffffff) {
1316 if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
1317 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
1319 TRACE("drawing item -1 special focus, rect=(%ld,%ld)-(%ld,%ld)\n",
1320 dis->rcItem.left, dis->rcItem.top,
1321 dis->rcItem.right, dis->rcItem.bottom);
1323 else if ((dis->CtlType == ODT_COMBOBOX) &&
1324 (dis->itemAction == ODA_DRAWENTIRE)) {
1325 /* draw of edit control data */
1327 /* testing */
1329 RECT exrc, cbrc, edrc;
1330 GetWindowRect (infoPtr->hwndSelf, &exrc);
1331 GetWindowRect (infoPtr->hwndCombo, &cbrc);
1332 edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
1333 if (infoPtr->hwndEdit)
1334 GetWindowRect (infoPtr->hwndEdit, &edrc);
1335 TRACE("window rects ex=(%ld,%ld)-(%ld,%ld), cb=(%ld,%ld)-(%ld,%ld), ed=(%ld,%ld)-(%ld,%ld)\n",
1336 exrc.left, exrc.top, exrc.right, exrc.bottom,
1337 cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
1338 edrc.left, edrc.top, edrc.right, edrc.bottom);
1341 else {
1342 ERR("NOT drawing item -1 special focus, rect=(%ld,%ld)-(%ld,%ld), action=%08x, state=%08x\n",
1343 dis->rcItem.left, dis->rcItem.top,
1344 dis->rcItem.right, dis->rcItem.bottom,
1345 dis->itemAction, dis->itemState);
1346 return 0;
1350 /* If draw item is -1 (edit control) setup the item pointer */
1351 if (dis->itemID == 0xffffffff) {
1352 item = infoPtr->edit;
1354 if (infoPtr->hwndEdit) {
1355 INT len;
1357 /* free previous text of edit item */
1358 COMBOEX_FreeText(item);
1359 item->mask &= ~CBEIF_TEXT;
1360 if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) {
1361 item->mask |= CBEIF_TEXT;
1362 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1363 if (item->pszText)
1364 GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1);
1366 TRACE("edit control hwndEdit=%p, text len=%d str=%s\n",
1367 infoPtr->hwndEdit, len, debugstr_txt(item->pszText));
1373 /* if the item pointer is not set, then get the data and locate it */
1374 if (!item) {
1375 item = get_item_data(infoPtr, dis->itemID);
1376 if (item == (CBE_ITEMDATA *)CB_ERR) {
1377 ERR("invalid item for id %d \n", dis->itemID);
1378 return 0;
1382 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
1384 xbase = CBE_STARTOFFSET;
1385 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) {
1386 INT indent = item->iIndent;
1387 if (indent == I_INDENTCALLBACK) {
1388 NMCOMBOBOXEXW nmce;
1389 ZeroMemory(&nmce, sizeof(nmce));
1390 nmce.ceItem.mask = CBEIF_INDENT;
1391 nmce.ceItem.lParam = item->lParam;
1392 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1393 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
1394 item->iIndent = nmce.ceItem.iIndent;
1395 indent = nmce.ceItem.iIndent;
1397 xbase += (indent * CBE_INDENT);
1400 drawimage = -2;
1401 drawstate = ILD_NORMAL;
1402 if (item->mask & CBEIF_IMAGE)
1403 drawimage = item->iImage;
1404 if (dis->itemState & ODS_COMBOEXLBOX) {
1405 /* drawing listbox entry */
1406 if (dis->itemState & ODS_SELECTED) {
1407 if (item->mask & CBEIF_SELECTEDIMAGE)
1408 drawimage = item->iSelectedImage;
1409 drawstate = ILD_SELECTED;
1411 } else {
1412 /* drawing combo/edit entry */
1413 if (IsWindowVisible(infoPtr->hwndEdit)) {
1414 /* if we have an edit control, the slave the
1415 * selection state to the Edit focus state
1417 if (infoPtr->flags & WCBE_EDITFOCUSED) {
1418 if (item->mask & CBEIF_SELECTEDIMAGE)
1419 drawimage = item->iSelectedImage;
1420 drawstate = ILD_SELECTED;
1422 } else {
1423 /* if we don't have an edit control, use
1424 * the requested state.
1426 if (dis->itemState & ODS_SELECTED) {
1427 if (item->mask & CBEIF_SELECTEDIMAGE)
1428 drawimage = item->iSelectedImage;
1429 drawstate = ILD_SELECTED;
1434 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
1435 IMAGEINFO iinfo;
1436 iinfo.rcImage.left = iinfo.rcImage.right = 0;
1437 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
1438 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
1439 } else xioff = 0;
1441 /* setup pointer to text to be drawn */
1442 str = COMBOEX_GetText(infoPtr, item);
1443 if (!str) str = nil;
1445 len = strlenW (str);
1446 GetTextExtentPoint32W (dis->hDC, str, len, &txtsize);
1448 if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) {
1449 int overlay = item->iOverlay;
1451 if (drawimage == I_IMAGECALLBACK) {
1452 NMCOMBOBOXEXW nmce;
1453 ZeroMemory(&nmce, sizeof(nmce));
1454 nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE;
1455 nmce.ceItem.lParam = item->lParam;
1456 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1457 if (drawstate == ILD_NORMAL) {
1458 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage;
1459 drawimage = nmce.ceItem.iImage;
1460 } else if (drawstate == ILD_SELECTED) {
1461 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage;
1462 drawimage = nmce.ceItem.iSelectedImage;
1463 } else ERR("Bad draw state = %d\n", drawstate);
1466 if (overlay == I_IMAGECALLBACK) {
1467 NMCOMBOBOXEXW nmce;
1468 ZeroMemory(&nmce, sizeof(nmce));
1469 nmce.ceItem.mask = CBEIF_OVERLAY;
1470 nmce.ceItem.lParam = item->lParam;
1471 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1472 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
1473 item->iOverlay = nmce.ceItem.iOverlay;
1474 overlay = nmce.ceItem.iOverlay;
1477 if (drawimage >= 0 &&
1478 !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) {
1479 if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1);
1480 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top,
1481 drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0));
1484 /* now draw the text */
1485 if (!IsWindowVisible (infoPtr->hwndEdit)) {
1486 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1487 COLOR_HIGHLIGHT : COLOR_WINDOW);
1488 bkc = SetBkColor (dis->hDC, nbkc);
1489 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1490 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
1491 txc = SetTextColor (dis->hDC, ntxc);
1492 x = xbase + xioff;
1493 y = dis->rcItem.top +
1494 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
1495 rect.left = x;
1496 rect.right = x + txtsize.cx;
1497 rect.top = dis->rcItem.top + 1;
1498 rect.bottom = dis->rcItem.bottom - 1;
1499 TRACE("drawing item %d text, rect=(%ld,%ld)-(%ld,%ld)\n",
1500 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1501 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
1502 &rect, str, len, 0);
1503 SetBkColor (dis->hDC, bkc);
1504 SetTextColor (dis->hDC, txc);
1508 if (dis->itemAction & ODA_FOCUS) {
1509 rect.left = xbase + xioff - 1;
1510 rect.right = rect.left + txtsize.cx + 2;
1511 rect.top = dis->rcItem.top;
1512 rect.bottom = dis->rcItem.bottom;
1513 DrawFocusRect(dis->hDC, &rect);
1516 return 0;
1520 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr)
1522 if (infoPtr->hwndCombo)
1523 DestroyWindow (infoPtr->hwndCombo);
1525 if (infoPtr->edit) {
1526 COMCTL32_Free (infoPtr->edit);
1527 infoPtr->edit = 0;
1530 if (infoPtr->items) {
1531 CBE_ITEMDATA *item, *next;
1533 item = infoPtr->items;
1534 while (item) {
1535 next = (CBE_ITEMDATA *)item->next;
1536 COMBOEX_FreeText (item);
1537 COMCTL32_Free (item);
1538 item = next;
1540 infoPtr->items = 0;
1543 if (infoPtr->defaultFont)
1544 DeleteObject (infoPtr->defaultFont);
1546 /* free comboex info data */
1547 COMCTL32_Free (infoPtr);
1548 SetWindowLongW (infoPtr->hwndSelf, 0, 0);
1549 return 0;
1553 static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis)
1555 SIZE mysize;
1556 HDC hdc;
1558 hdc = GetDC (0);
1559 GetTextExtentPointA (hdc, "W", 1, &mysize);
1560 ReleaseDC (0, hdc);
1561 mis->itemHeight = mysize.cy + CBE_EXTRA;
1563 TRACE("adjusted height hwnd=%p, height=%d\n",
1564 infoPtr->hwndSelf, mis->itemHeight);
1566 return 0;
1570 static LRESULT COMBOEX_NCCreate (HWND hwnd)
1572 /* WARNING: The COMBOEX_INFO structure is not yet created */
1573 DWORD oldstyle, newstyle;
1575 oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE);
1576 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
1577 if (newstyle != oldstyle) {
1578 TRACE("req style %08lx, reseting style %08lx\n",
1579 oldstyle, newstyle);
1580 SetWindowLongW (hwnd, GWL_STYLE, newstyle);
1582 return 1;
1586 static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam)
1588 if (lParam == NF_REQUERY) {
1589 INT i = SendMessageW(GetParent (infoPtr->hwndSelf),
1590 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
1591 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
1593 return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI;
1597 static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height)
1599 TRACE("(width=%d, height=%d)\n", width, height);
1601 MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE);
1603 COMBOEX_AdjustEditPos (infoPtr);
1605 return 0;
1609 static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp)
1611 RECT cbx_wrect, cbx_crect, cb_wrect;
1612 UINT width, height;
1614 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
1615 GetClientRect (infoPtr->hwndSelf, &cbx_crect);
1616 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1618 /* width is winpos value + border width of comboex */
1619 width = wp->cx
1620 + (cbx_wrect.right-cbx_wrect.left)
1621 - (cbx_crect.right-cbx_crect.left);
1623 TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
1624 wp->x, wp->y, wp->cx, wp->cy, wp->flags);
1625 TRACE("EX window=(%ld,%ld)-(%ld,%ld), client=(%ld,%ld)-(%ld,%ld)\n",
1626 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
1627 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
1628 TRACE("CB window=(%ld,%ld)-(%ld,%ld), EX setting=(0,0)-(%d,%ld)\n",
1629 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
1630 width, cb_wrect.bottom-cb_wrect.top);
1632 if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
1633 width,
1634 cb_wrect.bottom-cb_wrect.top,
1635 SWP_NOACTIVATE);
1637 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1639 /* height is combo window height plus border width of comboex */
1640 height = (cb_wrect.bottom-cb_wrect.top)
1641 + (cbx_wrect.bottom-cbx_wrect.top)
1642 - (cbx_crect.bottom-cbx_crect.top);
1643 if (wp->cy < height) wp->cy = height;
1644 if (infoPtr->hwndEdit) {
1645 COMBOEX_AdjustEditPos (infoPtr);
1646 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1649 return 0;
1652 static inline int is_delimiter(WCHAR c)
1654 switch(c) {
1655 case '/':
1656 case '\\':
1657 case '.':
1658 return TRUE;
1660 return FALSE;
1663 static int CALLBACK
1664 COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code)
1666 if (code == WB_ISDELIMITER) {
1667 return is_delimiter(lpch[ichCurrent]);
1668 } else {
1669 int dir = (code == WB_LEFT) ? -1 : 1;
1670 for(; 0 <= ichCurrent && ichCurrent < cch; ichCurrent += dir)
1671 if (is_delimiter(lpch[ichCurrent])) return ichCurrent;
1673 return ichCurrent;
1676 static LRESULT WINAPI
1677 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1679 HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP);
1680 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
1681 NMCBEENDEDITW cbeend;
1682 WCHAR edit_text[260];
1683 COLORREF obkc;
1684 HDC hDC;
1685 RECT rect;
1686 LRESULT lret;
1688 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1689 hwnd, uMsg, wParam, lParam, infoPtr);
1691 if (!infoPtr) return 0;
1693 switch (uMsg)
1696 case WM_CHAR:
1697 /* handle (ignore) the return character */
1698 if (wParam == VK_RETURN) return 0;
1699 /* all other characters pass into the real Edit */
1700 return CallWindowProcW (infoPtr->prevEditWndProc,
1701 hwnd, uMsg, wParam, lParam);
1703 case WM_ERASEBKGND:
1705 * The following was determined by traces of the native
1707 hDC = (HDC) wParam;
1708 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW));
1709 GetClientRect (hwnd, &rect);
1710 TRACE("erasing (%ld,%ld)-(%ld,%ld)\n",
1711 rect.left, rect.top, rect.right, rect.bottom);
1712 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1713 SetBkColor (hDC, obkc);
1714 return CallWindowProcW (infoPtr->prevEditWndProc,
1715 hwnd, uMsg, wParam, lParam);
1717 case WM_KEYDOWN: {
1718 INT oldItem, selected, step = 1;
1719 CBE_ITEMDATA *item;
1721 switch ((INT)wParam)
1723 case VK_ESCAPE:
1724 /* native version seems to do following for COMBOEX */
1726 * GetWindowTextA(Edit,&?, 0x104) x
1727 * CB_GETCURSEL to Combo rets -1 x
1728 * WM_NOTIFY to COMBOEX parent (rebar) x
1729 * (CBEN_ENDEDIT{A|W}
1730 * fChanged = FALSE x
1731 * inewSelection = -1 x
1732 * txt="www.hoho" x
1733 * iWhy = 3 x
1734 * CB_GETCURSEL to Combo rets -1 x
1735 * InvalidateRect(Combo, 0) x
1736 * WM_SETTEXT to Edit x
1737 * EM_SETSEL to Edit (0,0) x
1738 * EM_SETSEL to Edit (0,-1) x
1739 * RedrawWindow(Combo, 0, 0, 5) x
1741 TRACE("special code for VK_ESCAPE\n");
1743 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1745 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1746 cbeend.fChanged = FALSE;
1747 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1748 CB_GETCURSEL, 0, 0);
1749 cbeend.iWhy = CBENF_ESCAPE;
1751 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
1752 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1753 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1754 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1755 ERR("item %d not found. Problem!\n", oldItem);
1756 break;
1758 infoPtr->selected = oldItem;
1759 COMBOEX_SetEditText (infoPtr, item);
1760 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1761 RDW_INVALIDATE);
1762 break;
1764 case VK_RETURN:
1765 /* native version seems to do following for COMBOEX */
1767 * GetWindowTextA(Edit,&?, 0x104) x
1768 * CB_GETCURSEL to Combo rets -1 x
1769 * CB_GETCOUNT to Combo rets 0
1770 * if >0 loop
1771 * CB_GETITEMDATA to match
1772 * *** above 3 lines simulated by FindItem x
1773 * WM_NOTIFY to COMBOEX parent (rebar) x
1774 * (CBEN_ENDEDIT{A|W} x
1775 * fChanged = TRUE (-1) x
1776 * iNewSelection = -1 or selected x
1777 * txt= x
1778 * iWhy = 2 (CBENF_RETURN) x
1779 * CB_GETCURSEL to Combo rets -1 x
1780 * if -1 send CB_SETCURSEL to Combo -1 x
1781 * InvalidateRect(Combo, 0, 0) x
1782 * SetFocus(Edit) x
1783 * CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
1786 TRACE("special code for VK_RETURN\n");
1788 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1790 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1791 selected = SendMessageW (infoPtr->hwndCombo,
1792 CB_GETCURSEL, 0, 0);
1794 if (selected != -1) {
1795 cmp_func_t cmptext = get_cmp_func(infoPtr);
1796 item = COMBOEX_FindItem (infoPtr, selected);
1797 TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
1798 selected, debugstr_txt(item->pszText));
1799 TRACE("handling VK_RETURN, edittext=%s\n",
1800 debugstr_w(edit_text));
1801 if (cmptext (COMBOEX_GetText(infoPtr, item), edit_text)) {
1802 /* strings not equal -- indicate edit has changed */
1803 selected = -1;
1807 cbeend.iNewSelection = selected;
1808 cbeend.fChanged = TRUE;
1809 cbeend.iWhy = CBENF_RETURN;
1810 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
1811 /* abort the change, restore previous */
1812 TRACE("Notify requested abort of change\n");
1813 COMBOEX_SetEditText (infoPtr, infoPtr->edit);
1814 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1815 RDW_INVALIDATE);
1816 return 0;
1818 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1819 if (oldItem != -1) {
1820 /* if something is selected, then deselect it */
1821 SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
1822 (WPARAM)-1, 0);
1824 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1825 SetFocus(infoPtr->hwndEdit);
1826 break;
1828 case VK_UP:
1829 step = -1;
1830 case VK_DOWN:
1831 /* by default, step is 1 */
1832 oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0);
1833 if (oldItem >= 0 && oldItem + step >= 0)
1834 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0);
1835 return 0;
1836 default:
1837 return CallWindowProcW (infoPtr->prevEditWndProc,
1838 hwnd, uMsg, wParam, lParam);
1840 return 0;
1843 case WM_SETFOCUS:
1844 /* remember the focus to set state of icon */
1845 lret = CallWindowProcW (infoPtr->prevEditWndProc,
1846 hwnd, uMsg, wParam, lParam);
1847 infoPtr->flags |= WCBE_EDITFOCUSED;
1848 return lret;
1850 case WM_KILLFOCUS:
1852 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
1854 infoPtr->flags &= ~WCBE_EDITFOCUSED;
1855 if (infoPtr->flags & WCBE_ACTEDIT) {
1856 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1858 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1859 cbeend.fChanged = FALSE;
1860 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1861 CB_GETCURSEL, 0, 0);
1862 cbeend.iWhy = CBENF_KILLFOCUS;
1864 COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
1866 /* fall through */
1868 default:
1869 return CallWindowProcW (infoPtr->prevEditWndProc,
1870 hwnd, uMsg, wParam, lParam);
1872 return 0;
1876 static LRESULT WINAPI
1877 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1879 HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP);
1880 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
1881 NMCBEENDEDITW cbeend;
1882 NMMOUSE nmmse;
1883 COLORREF obkc;
1884 HDC hDC;
1885 HWND focusedhwnd;
1886 RECT rect;
1887 POINT pt;
1888 WCHAR edit_text[260];
1890 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1891 hwnd, uMsg, wParam, lParam, infoPtr);
1893 if (!infoPtr) return 0;
1895 switch (uMsg)
1898 case WM_DRAWITEM:
1900 * The only way this message should come is from the
1901 * child Listbox issuing the message. Flag this so
1902 * that ComboEx knows this is listbox.
1904 ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
1905 return CallWindowProcW (infoPtr->prevComboWndProc,
1906 hwnd, uMsg, wParam, lParam);
1908 case WM_ERASEBKGND:
1910 * The following was determined by traces of the native
1912 hDC = (HDC) wParam;
1913 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW));
1914 GetClientRect (hwnd, &rect);
1915 TRACE("erasing (%ld,%ld)-(%ld,%ld)\n",
1916 rect.left, rect.top, rect.right, rect.bottom);
1917 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1918 SetBkColor (hDC, obkc);
1919 return CallWindowProcW (infoPtr->prevComboWndProc,
1920 hwnd, uMsg, wParam, lParam);
1922 case WM_SETCURSOR:
1924 * WM_NOTIFY to comboex parent (rebar)
1925 * with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
1926 * CallWindowProc (previous)
1928 nmmse.dwItemSpec = 0;
1929 nmmse.dwItemData = 0;
1930 nmmse.pt.x = 0;
1931 nmmse.pt.y = 0;
1932 nmmse.dwHitInfo = lParam;
1933 COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
1934 return CallWindowProcW (infoPtr->prevComboWndProc,
1935 hwnd, uMsg, wParam, lParam);
1937 case WM_LBUTTONDOWN:
1938 GetClientRect (hwnd, &rect);
1939 rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf,
1940 CB_GETITEMHEIGHT, -1, 0);
1941 rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
1942 POINTSTOPOINT(pt, MAKEPOINTS(lParam));
1943 if (PtInRect(&rect, pt))
1944 return CallWindowProcW (infoPtr->prevComboWndProc,
1945 hwnd, uMsg, wParam, lParam);
1946 infoPtr->flags |= WCBE_MOUSECAPTURED;
1947 SetCapture(hwnd);
1948 break;
1950 case WM_LBUTTONUP:
1951 if (!(infoPtr->flags & WCBE_MOUSECAPTURED))
1952 return CallWindowProcW (infoPtr->prevComboWndProc,
1953 hwnd, uMsg, wParam, lParam);
1954 ReleaseCapture();
1955 infoPtr->flags &= ~WCBE_MOUSECAPTURED;
1956 if (infoPtr->flags & WCBE_MOUSEDRAGGED) {
1957 infoPtr->flags &= ~WCBE_MOUSEDRAGGED;
1958 } else {
1959 SendMessageW(hwnd, CB_SHOWDROPDOWN, TRUE, 0);
1961 break;
1963 case WM_MOUSEMOVE:
1964 if ( (infoPtr->flags & WCBE_MOUSECAPTURED) &&
1965 !(infoPtr->flags & WCBE_MOUSEDRAGGED)) {
1966 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1967 COMBOEX_NotifyDragBegin(infoPtr, edit_text);
1968 infoPtr->flags |= WCBE_MOUSEDRAGGED;
1970 return CallWindowProcW (infoPtr->prevComboWndProc,
1971 hwnd, uMsg, wParam, lParam);
1973 case WM_COMMAND:
1974 switch (HIWORD(wParam)) {
1976 case EN_UPDATE:
1977 /* traces show that COMBOEX does not issue CBN_EDITUPDATE
1978 * on the EN_UPDATE
1980 return 0;
1982 case EN_KILLFOCUS:
1984 * Native does:
1986 * GetFocus() retns AA
1987 * GetWindowTextA(Edit)
1988 * CB_GETCURSEL(Combo) (got -1)
1989 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1990 * CB_GETCURSEL(Combo) (got -1)
1991 * InvalidateRect(Combo, 0, 0)
1992 * WM_KILLFOCUS(Combo, AA)
1993 * return 0;
1995 focusedhwnd = GetFocus();
1996 if (infoPtr->flags & WCBE_ACTEDIT) {
1997 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1998 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1999 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
2000 CB_GETCURSEL, 0, 0);
2001 cbeend.iWhy = CBENF_KILLFOCUS;
2003 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
2004 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
2006 /* possible CB_GETCURSEL */
2007 InvalidateRect (infoPtr->hwndCombo, 0, 0);
2008 if (focusedhwnd)
2009 SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
2010 (WPARAM)focusedhwnd, 0);
2011 return 0;
2013 case EN_SETFOCUS: {
2015 * For EN_SETFOCUS this issues the same calls and messages
2016 * as the native seems to do.
2018 * for some cases however native does the following:
2019 * (noticed after SetFocus during LBUTTONDOWN on
2020 * on dropdown arrow)
2021 * WM_GETTEXTLENGTH (Edit);
2022 * WM_GETTEXT (Edit, len+1, str);
2023 * EM_SETSEL (Edit, 0, 0);
2024 * WM_GETTEXTLENGTH (Edit);
2025 * WM_GETTEXT (Edit, len+1, str);
2026 * EM_SETSEL (Edit, 0, len);
2027 * WM_NOTIFY (parent, CBEN_BEGINEDIT)
2029 NMHDR hdr;
2031 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
2032 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
2033 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
2034 infoPtr->flags |= WCBE_ACTEDIT;
2035 infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
2036 return 0;
2039 case EN_CHANGE: {
2041 * For EN_CHANGE this issues the same calls and messages
2042 * as the native seems to do.
2044 WCHAR edit_text[260];
2045 LPCWSTR lastwrk;
2046 cmp_func_t cmptext = get_cmp_func(infoPtr);
2048 INT selected = SendMessageW (infoPtr->hwndCombo,
2049 CB_GETCURSEL, 0, 0);
2051 /* lstrlenA( lastworkingURL ) */
2053 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2054 if (selected == -1) {
2055 lastwrk = infoPtr->edit->pszText;
2057 else {
2058 CBE_ITEMDATA *item = COMBOEX_FindItem (infoPtr, selected);
2059 lastwrk = COMBOEX_GetText(infoPtr, item);
2062 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
2063 selected, debugstr_w(lastwrk));
2064 TRACE("handling EN_CHANGE, edittext=%s\n",
2065 debugstr_w(edit_text));
2067 /* cmptext is between lastworkingURL and GetWindowText */
2068 if (cmptext (lastwrk, edit_text)) {
2069 /* strings not equal -- indicate edit has changed */
2070 infoPtr->flags |= WCBE_EDITCHG;
2072 SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
2073 MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
2074 CBN_EDITCHANGE),
2075 (LPARAM)infoPtr->hwndSelf);
2076 return 0;
2079 case LBN_SELCHANGE:
2081 * Therefore from traces there is no additional code here
2085 * Using native COMCTL32 gets the following:
2086 * 1 == SHDOCVW.DLL issues call/message
2087 * 2 == COMCTL32.DLL issues call/message
2088 * 3 == WINE issues call/message
2091 * for LBN_SELCHANGE:
2092 * 1 CB_GETCURSEL(ComboEx)
2093 * 1 CB_GETDROPPEDSTATE(ComboEx)
2094 * 1 CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
2095 * 2 CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
2096 ** call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
2097 * 3 WM_COMMAND(ComboEx, CBN_SELENDOK)
2098 * WM_USER+49(ComboLB, 1,0) <=============!!!!!!!!!!!
2099 * 3 ShowWindow(ComboLB, SW_HIDE)
2100 * 3 RedrawWindow(Combo, RDW_UPDATENOW)
2101 * 3 WM_COMMAND(ComboEX, CBN_CLOSEUP)
2102 ** end of CBRollUp
2103 * 3 WM_COMMAND(ComboEx, CBN_SELCHANGE) (echo to parent)
2104 * ? LB_GETCURSEL <==|
2105 * ? LB_GETTEXTLEN |
2106 * ? LB_GETTEXT | Needs to be added to
2107 * ? WM_CTLCOLOREDIT(ComboEx) | Combo processing
2108 * ? LB_GETITEMDATA |
2109 * ? WM_DRAWITEM(ComboEx) <==|
2111 default:
2112 break;
2113 }/* fall through */
2114 default:
2115 return CallWindowProcW (infoPtr->prevComboWndProc,
2116 hwnd, uMsg, wParam, lParam);
2118 return 0;
2122 static LRESULT WINAPI
2123 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2125 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
2127 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2129 if (!infoPtr) {
2130 if (uMsg == WM_CREATE)
2131 return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam);
2132 if (uMsg == WM_NCCREATE)
2133 COMBOEX_NCCreate (hwnd);
2134 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2137 switch (uMsg)
2139 case CBEM_DELETEITEM:
2140 return COMBOEX_DeleteItem (infoPtr, wParam);
2142 case CBEM_GETCOMBOCONTROL:
2143 return (LRESULT)infoPtr->hwndCombo;
2145 case CBEM_GETEDITCONTROL:
2146 return (LRESULT)infoPtr->hwndEdit;
2148 case CBEM_GETEXTENDEDSTYLE:
2149 return infoPtr->dwExtStyle;
2151 case CBEM_GETIMAGELIST:
2152 return (LRESULT)infoPtr->himl;
2154 case CBEM_GETITEMA:
2155 return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2157 case CBEM_GETITEMW:
2158 return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2160 case CBEM_GETUNICODEFORMAT:
2161 return infoPtr->unicode;
2163 case CBEM_HASEDITCHANGED:
2164 return COMBOEX_HasEditChanged (infoPtr);
2166 case CBEM_INSERTITEMA:
2167 return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2169 case CBEM_INSERTITEMW:
2170 return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2172 case CBEM_SETEXSTYLE:
2173 case CBEM_SETEXTENDEDSTYLE:
2174 return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam);
2176 case CBEM_SETIMAGELIST:
2177 return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam);
2179 case CBEM_SETITEMA:
2180 return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2182 case CBEM_SETITEMW:
2183 return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2185 case CBEM_SETUNICODEFORMAT:
2186 return COMBOEX_SetUnicodeFormat (infoPtr, wParam);
2188 /*case CBEM_SETWINDOWTHEME:
2189 FIXME("CBEM_SETWINDOWTHEME: stub\n");*/
2191 case WM_SETTEXT:
2192 case WM_GETTEXT:
2193 return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam);
2195 /* Combo messages we are not sure if we need to process or just forward */
2196 case CB_GETDROPPEDCONTROLRECT:
2197 case CB_GETITEMHEIGHT:
2198 case CB_GETLBTEXT:
2199 case CB_GETLBTEXTLEN:
2200 case CB_GETEXTENDEDUI:
2201 case CB_LIMITTEXT:
2202 case CB_RESETCONTENT:
2203 case CB_SELECTSTRING:
2205 /* Combo messages OK to just forward to the regular COMBO */
2206 case CB_GETCOUNT:
2207 case CB_GETCURSEL:
2208 case CB_GETDROPPEDSTATE:
2209 case CB_SETDROPPEDWIDTH:
2210 case CB_SETEXTENDEDUI:
2211 case CB_SHOWDROPDOWN:
2212 return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam);
2214 /* Combo messages we need to process specially */
2215 case CB_FINDSTRINGEXACT:
2216 return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCWSTR)lParam);
2218 case CB_GETITEMDATA:
2219 return COMBOEX_GetItemData (infoPtr, (INT)wParam);
2221 case CB_SETCURSEL:
2222 return COMBOEX_SetCursel (infoPtr, (INT)wParam);
2224 case CB_SETITEMDATA:
2225 return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD)lParam);
2227 case CB_SETITEMHEIGHT:
2228 return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam);
2232 /* Window messages passed to parent */
2233 case WM_COMMAND:
2234 return COMBOEX_Command (infoPtr, wParam, lParam);
2236 case WM_NOTIFY:
2237 if (infoPtr->NtfUnicode)
2238 return SendMessageW (GetParent (hwnd), uMsg, wParam, lParam);
2239 else
2240 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2243 /* Window messages we need to process */
2244 case WM_DELETEITEM:
2245 return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam);
2247 case WM_DRAWITEM:
2248 return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam);
2250 case WM_DESTROY:
2251 return COMBOEX_Destroy (infoPtr);
2253 case WM_MEASUREITEM:
2254 return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam);
2256 case WM_NOTIFYFORMAT:
2257 return COMBOEX_NotifyFormat (infoPtr, lParam);
2259 case WM_SIZE:
2260 return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam));
2262 case WM_WINDOWPOSCHANGING:
2263 return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam);
2265 default:
2266 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
2267 ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam);
2268 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2270 return 0;
2274 void COMBOEX_Register (void)
2276 WNDCLASSW wndClass;
2278 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
2279 wndClass.style = CS_GLOBALCLASS;
2280 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
2281 wndClass.cbClsExtra = 0;
2282 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
2283 wndClass.hCursor = LoadCursorW (0, IDC_ARROWW);
2284 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2285 wndClass.lpszClassName = WC_COMBOBOXEXW;
2287 RegisterClassW (&wndClass);
2291 void COMBOEX_Unregister (void)
2293 UnregisterClassW (WC_COMBOBOXEXW, NULL);