ntdll: Add a test for NtNotifyChangeDirectoryFile.
[wine/multimedia.git] / dlls / comctl32 / comboex.c
blobb2ed2ac69d8c421a4314e0567591a6b4b8f575e5
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 believe this code to be complete, as per
28 * the specification mentioned above.
29 * If you discover missing features, or bugs, please note them below.
33 #include <stdarg.h>
34 #include <string.h>
35 #include "windef.h"
36 #include "winbase.h"
37 #include "wingdi.h"
38 #include "winuser.h"
39 #include "winnls.h"
40 #include "commctrl.h"
41 #include "comctl32.h"
42 #include "wine/debug.h"
43 #include "wine/unicode.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(comboex);
47 /* Item structure */
48 typedef struct _CBE_ITEMDATA
50 struct _CBE_ITEMDATA *next;
51 UINT mask;
52 LPWSTR pszText;
53 LPWSTR pszTemp;
54 int cchTextMax;
55 int iImage;
56 int iSelectedImage;
57 int iOverlay;
58 int iIndent;
59 LPARAM lParam;
60 } CBE_ITEMDATA;
62 /* ComboBoxEx structure */
63 typedef struct
65 HIMAGELIST himl;
66 HWND hwndSelf; /* my own hwnd */
67 HWND hwndNotify; /* my parent hwnd */
68 HWND hwndCombo;
69 HWND hwndEdit;
70 WNDPROC prevEditWndProc; /* previous Edit WNDPROC value */
71 WNDPROC prevComboWndProc; /* previous Combo WNDPROC value */
72 DWORD dwExtStyle;
73 INT selected; /* index of selected item */
74 DWORD flags; /* WINE internal flags */
75 HFONT defaultFont;
76 HFONT font;
77 INT nb_items; /* Number of items */
78 BOOL unicode; /* TRUE if this window is Unicode */
79 BOOL NtfUnicode; /* TRUE if parent wants notify in Unicode */
80 CBE_ITEMDATA *edit; /* item data for edit item */
81 CBE_ITEMDATA *items; /* Array of items */
82 } COMBOEX_INFO;
84 /* internal flags in the COMBOEX_INFO structure */
85 #define WCBE_ACTEDIT 0x00000001 /* Edit active i.e.
86 * CBEN_BEGINEDIT issued
87 * but CBEN_ENDEDIT{A|W}
88 * not yet issued. */
89 #define WCBE_EDITCHG 0x00000002 /* Edit issued EN_CHANGE */
90 #define WCBE_EDITHASCHANGED (WCBE_ACTEDIT | WCBE_EDITCHG)
91 #define WCBE_EDITFOCUSED 0x00000004 /* Edit control has focus */
92 #define WCBE_MOUSECAPTURED 0x00000008 /* Combo has captured mouse */
93 #define WCBE_MOUSEDRAGGED 0x00000010 /* User has dragged in combo */
95 #define ID_CB_EDIT 1001
99 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
100 * the ComboEx version of the Combo Window Proc so that when the
101 * WM_DRAWITEM message is then passed to ComboEx, we know that this
102 * particular WM_DRAWITEM message is for listbox only items. Any messasges
103 * without this flag is then for the Edit control field.
105 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
106 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
108 #define ODS_COMBOEXLBOX 0x4000
112 /* Height in pixels of control over the amount of the selected font */
113 #define CBE_EXTRA 3
115 /* Indent amount per MS documentation */
116 #define CBE_INDENT 10
118 /* Offset in pixels from left side for start of image or text */
119 #define CBE_STARTOFFSET 6
121 /* Offset between image and text */
122 #define CBE_SEP 4
124 static const WCHAR COMBOEX_SUBCLASS_PROP[] = {
125 'C','C','C','o','m','b','o','E','x','3','2',
126 'S','u','b','c','l','a','s','s','I','n','f','o',0
129 #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongPtrW (hwnd, 0))
132 /* Things common to the entire DLL */
133 static LRESULT WINAPI COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
134 static LRESULT WINAPI COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
135 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr);
136 typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR);
138 inline static BOOL is_textW(LPCWSTR str)
140 return str && str != LPSTR_TEXTCALLBACKW;
143 inline static BOOL is_textA(LPCSTR str)
145 return str && str != LPSTR_TEXTCALLBACKA;
148 inline static LPCSTR debugstr_txt(LPCWSTR str)
150 if (str == LPSTR_TEXTCALLBACKW) return "(callback)";
151 return debugstr_w(str);
154 static void COMBOEX_DumpItem (CBE_ITEMDATA *item)
156 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
157 item, item->mask, item->pszText, item->cchTextMax, item->iImage);
158 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
159 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
160 if (item->mask & CBEIF_TEXT)
161 TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText));
165 static void COMBOEX_DumpInput (COMBOBOXEXITEMW *input)
167 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
168 input->mask, input->iItem, input->pszText, input->cchTextMax,
169 input->iImage);
170 if (input->mask & CBEIF_TEXT)
171 TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText));
172 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
173 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
177 inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index)
179 return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA,
180 (WPARAM)index, 0);
183 inline static cmp_func_t get_cmp_func(COMBOEX_INFO *infoPtr)
185 return infoPtr->dwExtStyle & CBES_EX_CASESENSITIVE ? lstrcmpW : lstrcmpiW;
188 static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
190 hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
191 hdr->hwndFrom = infoPtr->hwndSelf;
192 hdr->code = code;
193 if (infoPtr->NtfUnicode)
194 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)hdr);
195 else
196 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 0, (LPARAM)hdr);
200 static INT
201 COMBOEX_NotifyItem (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)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) 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)) Free(item->pszText);
280 item->pszText = 0;
281 if (item->pszTemp) Free(item->pszTemp);
282 item->pszTemp = 0;
286 static INT COMBOEX_GetIndex(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
288 CBE_ITEMDATA *moving;
289 INT index;
291 moving = infoPtr->items;
292 index = infoPtr->nb_items - 1;
294 while (moving && (moving != item)) {
295 moving = moving->next;
296 index--;
298 if (!moving || (index < 0)) {
299 ERR("COMBOBOXEX item structures broken. Please report!\n");
300 return -1;
302 return index;
306 static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
308 NMCOMBOBOXEXW nmce;
309 LPWSTR text, buf;
310 INT len;
312 if (item->pszText != LPSTR_TEXTCALLBACKW)
313 return item->pszText;
315 ZeroMemory(&nmce, sizeof(nmce));
316 nmce.ceItem.mask = CBEIF_TEXT;
317 nmce.ceItem.lParam = item->lParam;
318 nmce.ceItem.iItem = COMBOEX_GetIndex(infoPtr, item);
319 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
321 if (is_textW(nmce.ceItem.pszText)) {
322 len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0);
323 buf = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
324 if (buf)
325 MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len);
326 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) {
327 COMBOEX_FreeText(item);
328 item->pszText = buf;
329 } else {
330 if (item->pszTemp) Free(item->pszTemp);
331 item->pszTemp = buf;
333 text = buf;
334 } else
335 text = nmce.ceItem.pszText;
337 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
338 item->pszText = text;
339 return text;
343 static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size)
345 static const WCHAR strA[] = { 'A', 0 };
346 HFONT nfont, ofont;
347 HDC mydc;
349 mydc = GetDC (0); /* why the entire screen???? */
350 nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
351 ofont = (HFONT) SelectObject (mydc, nfont);
352 GetTextExtentPointW (mydc, strA, 1, size);
353 SelectObject (mydc, ofont);
354 ReleaseDC (0, mydc);
355 TRACE("selected font hwnd=%p, height=%ld\n", nfont, size->cy);
359 static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit)
361 if (cit->mask & CBEIF_TEXT) {
363 * when given a text buffer actually use that buffer
365 if (cit->pszText) {
366 if (is_textW(item->pszText))
367 lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax);
368 else
369 cit->pszText[0] = 0;
370 } else {
371 cit->pszText = item->pszText;
372 cit->cchTextMax = item->cchTextMax;
375 if (cit->mask & CBEIF_IMAGE)
376 cit->iImage = item->iImage;
377 if (cit->mask & CBEIF_SELECTEDIMAGE)
378 cit->iSelectedImage = item->iSelectedImage;
379 if (cit->mask & CBEIF_OVERLAY)
380 cit->iOverlay = item->iOverlay;
381 if (cit->mask & CBEIF_INDENT)
382 cit->iIndent = item->iIndent;
383 if (cit->mask & CBEIF_LPARAM)
384 cit->lParam = item->lParam;
388 static void COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr)
390 SIZE mysize;
391 INT x, y, w, h, xioff;
392 RECT rect;
394 if (!infoPtr->hwndEdit) return;
396 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
397 IMAGEINFO iinfo;
398 iinfo.rcImage.left = iinfo.rcImage.right = 0;
399 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
400 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
401 } else xioff = 0;
403 GetClientRect (infoPtr->hwndCombo, &rect);
404 InflateRect (&rect, -2, -2);
405 InvalidateRect (infoPtr->hwndCombo, &rect, TRUE);
407 /* reposition the Edit control based on whether icon exists */
408 COMBOEX_GetComboFontSize (infoPtr, &mysize);
409 TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy);
410 x = xioff + CBE_STARTOFFSET + 1;
411 w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1;
412 h = mysize.cy + 1;
413 y = rect.bottom - h - 1;
415 TRACE("Combo client (%ld,%ld)-(%ld,%ld), setting Edit to (%d,%d)-(%d,%d)\n",
416 rect.left, rect.top, rect.right, rect.bottom, x, y, x + w, y + h);
417 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h,
418 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
422 static void COMBOEX_ReSize (COMBOEX_INFO *infoPtr)
424 SIZE mysize;
425 LONG cy;
426 IMAGEINFO iinfo;
428 COMBOEX_GetComboFontSize (infoPtr, &mysize);
429 cy = mysize.cy + CBE_EXTRA;
430 if (infoPtr->himl && ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo)) {
431 cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
432 TRACE("upgraded height due to image: height=%ld\n", cy);
434 SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy);
435 if (infoPtr->hwndCombo) {
436 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
437 (WPARAM) 0, (LPARAM) cy);
438 if ( !(infoPtr->flags & CBES_EX_NOSIZELIMIT)) {
439 RECT comboRect;
440 if (GetWindowRect(infoPtr->hwndCombo, &comboRect)) {
441 RECT ourRect;
442 if (GetWindowRect(infoPtr->hwndSelf, &ourRect)) {
443 if (comboRect.bottom > ourRect.bottom) {
444 POINT pt = { ourRect.left, ourRect.top };
445 if (ScreenToClient(infoPtr->hwndSelf, &pt))
446 MoveWindow( infoPtr->hwndSelf, pt.x, pt.y, ourRect.right - ourRect.left,
447 comboRect.bottom - comboRect.top, FALSE);
456 static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
458 if (!infoPtr->hwndEdit) return;
459 /* native issues the following messages to the {Edit} control */
460 /* WM_SETTEXT (0,addr) */
461 /* EM_SETSEL32 (0,0) */
462 /* EM_SETSEL32 (0,-1) */
463 if (item->mask & CBEIF_TEXT) {
464 SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item));
465 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
466 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
471 static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
473 CBE_ITEMDATA *item;
474 INT i;
476 if ((index >= infoPtr->nb_items) || (index < -1))
477 return 0;
478 if (index == -1)
479 return infoPtr->edit;
480 item = infoPtr->items;
481 i = infoPtr->nb_items - 1;
483 /* find the item in the list */
484 while (item && (i > index)) {
485 item = item->next;
486 i--;
488 if (!item || (i != index)) {
489 ERR("COMBOBOXEX item structures broken. Please report!\n");
490 return 0;
492 return item;
496 static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr)
498 return infoPtr->hwndEdit ? TRUE : FALSE;
502 /* *** CBEM_xxx message support *** */
505 static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT index)
507 CBE_ITEMDATA *item;
509 TRACE("(index=%d)\n", index);
511 /* if item number requested does not exist then return failure */
512 if ((index >= infoPtr->nb_items) || (index < 0)) return CB_ERR;
513 if (!(item = COMBOEX_FindItem(infoPtr, index))) return CB_ERR;
515 /* doing this will result in WM_DELETEITEM being issued */
516 SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0);
518 return infoPtr->nb_items;
522 static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
524 INT index = cit->iItem;
525 CBE_ITEMDATA *item;
527 TRACE("(...)\n");
529 /* if item number requested does not exist then return failure */
530 if ((index >= infoPtr->nb_items) || (index < -1)) return FALSE;
532 /* if the item is the edit control and there is no edit control, skip */
533 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
535 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
537 COMBOEX_CopyItem (item, cit);
539 return TRUE;
543 static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
545 COMBOBOXEXITEMW tmpcit;
547 TRACE("(...)\n");
549 tmpcit.mask = cit->mask;
550 tmpcit.iItem = cit->iItem;
551 tmpcit.pszText = 0;
552 if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE;
554 if (is_textW(tmpcit.pszText) && cit->pszText)
555 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
556 cit->pszText, cit->cchTextMax, NULL, NULL);
557 else if (cit->pszText) cit->pszText[0] = 0;
558 else cit->pszText = (LPSTR)tmpcit.pszText;
560 cit->iImage = tmpcit.iImage;
561 cit->iSelectedImage = tmpcit.iSelectedImage;
562 cit->iOverlay = tmpcit.iOverlay;
563 cit->iIndent = tmpcit.iIndent;
564 cit->lParam = tmpcit.lParam;
566 return TRUE;
570 inline static BOOL COMBOEX_HasEditChanged (COMBOEX_INFO *infoPtr)
572 return COMBOEX_HasEdit(infoPtr) &&
573 (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED;
577 static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
579 INT index;
580 CBE_ITEMDATA *item;
581 NMCOMBOBOXEXW nmcit;
583 TRACE("\n");
585 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
587 /* get real index of item to insert */
588 index = cit->iItem;
589 if (index == -1) index = infoPtr->nb_items;
590 if (index > infoPtr->nb_items) return -1;
592 /* get zero-filled space and chain it in */
593 if(!(item = (CBE_ITEMDATA *)Alloc (sizeof(*item)))) return -1;
595 /* locate position to insert new item in */
596 if (index == infoPtr->nb_items) {
597 /* fast path for iItem = -1 */
598 item->next = infoPtr->items;
599 infoPtr->items = item;
601 else {
602 INT i = infoPtr->nb_items-1;
603 CBE_ITEMDATA *moving = infoPtr->items;
605 while ((i > index) && moving) {
606 moving = moving->next;
607 i--;
609 if (!moving) {
610 ERR("COMBOBOXEX item structures broken. Please report!\n");
611 Free(item);
612 return -1;
614 item->next = moving->next;
615 moving->next = item;
618 /* fill in our hidden item structure */
619 item->mask = cit->mask;
620 if (item->mask & CBEIF_TEXT) {
621 INT len = 0;
623 if (is_textW(cit->pszText)) len = strlenW (cit->pszText);
624 if (len > 0) {
625 item->pszText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
626 if (!item->pszText) {
627 Free(item);
628 return -1;
630 strcpyW (item->pszText, cit->pszText);
632 else if (cit->pszText == LPSTR_TEXTCALLBACKW)
633 item->pszText = LPSTR_TEXTCALLBACKW;
634 item->cchTextMax = cit->cchTextMax;
636 if (item->mask & CBEIF_IMAGE)
637 item->iImage = cit->iImage;
638 if (item->mask & CBEIF_SELECTEDIMAGE)
639 item->iSelectedImage = cit->iSelectedImage;
640 if (item->mask & CBEIF_OVERLAY)
641 item->iOverlay = cit->iOverlay;
642 if (item->mask & CBEIF_INDENT)
643 item->iIndent = cit->iIndent;
644 if (item->mask & CBEIF_LPARAM)
645 item->lParam = cit->lParam;
646 infoPtr->nb_items++;
648 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
650 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
651 (WPARAM)cit->iItem, (LPARAM)item);
653 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
654 COMBOEX_CopyItem (item, &nmcit.ceItem);
655 COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit);
657 return index;
662 static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
664 COMBOBOXEXITEMW citW;
665 LPWSTR wstr = NULL;
666 INT ret;
668 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
669 if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) {
670 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
671 wstr = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
672 if (!wstr) return -1;
673 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
674 citW.pszText = wstr;
676 ret = COMBOEX_InsertItemW(infoPtr, &citW);
678 if (wstr) Free(wstr);
680 return ret;
684 static DWORD
685 COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style)
687 DWORD dwTemp;
689 TRACE("(mask=x%08lx, style=0x%08lx)\n", mask, style);
691 dwTemp = infoPtr->dwExtStyle;
693 if (mask)
694 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style;
695 else
696 infoPtr->dwExtStyle = style;
698 /* see if we need to change the word break proc on the edit */
699 if ((infoPtr->dwExtStyle ^ dwTemp) & CBES_EX_PATHWORDBREAKPROC)
700 SetPathWordBreakProc(infoPtr->hwndEdit,
701 (infoPtr->dwExtStyle & CBES_EX_PATHWORDBREAKPROC) ? TRUE : FALSE);
703 /* test if the control's appearance has changed */
704 mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT;
705 if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) {
706 /* if state of EX_NOEDITIMAGE changes, invalidate all */
707 TRACE("EX_NOEDITIMAGE state changed to %ld\n",
708 infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
709 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
710 COMBOEX_AdjustEditPos (infoPtr);
711 if (infoPtr->hwndEdit)
712 InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
715 return dwTemp;
719 static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl)
721 HIMAGELIST himlTemp = infoPtr->himl;
723 TRACE("(...)\n");
725 infoPtr->himl = himl;
727 COMBOEX_ReSize (infoPtr);
728 InvalidateRect (infoPtr->hwndCombo, NULL, TRUE);
730 /* reposition the Edit control based on whether icon exists */
731 COMBOEX_AdjustEditPos (infoPtr);
732 return himlTemp;
735 static BOOL COMBOEX_SetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit)
737 INT index = cit->iItem;
738 CBE_ITEMDATA *item;
740 if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit);
742 /* if item number requested does not exist then return failure */
743 if ((index >= infoPtr->nb_items) || (index < -1)) return FALSE;
745 /* if the item is the edit control and there is no edit control, skip */
746 if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE;
748 if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
750 /* add/change stuff to the internal item structure */
751 item->mask |= cit->mask;
752 if (cit->mask & CBEIF_TEXT) {
753 INT len = 0;
755 COMBOEX_FreeText(item);
756 if (is_textW(cit->pszText)) len = strlenW(cit->pszText);
757 if (len > 0) {
758 item->pszText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
759 if (!item->pszText) return FALSE;
760 strcpyW(item->pszText, cit->pszText);
761 } else if (cit->pszText == LPSTR_TEXTCALLBACKW)
762 item->pszText = LPSTR_TEXTCALLBACKW;
763 item->cchTextMax = cit->cchTextMax;
765 if (cit->mask & CBEIF_IMAGE)
766 item->iImage = cit->iImage;
767 if (cit->mask & CBEIF_SELECTEDIMAGE)
768 item->iSelectedImage = cit->iSelectedImage;
769 if (cit->mask & CBEIF_OVERLAY)
770 item->iOverlay = cit->iOverlay;
771 if (cit->mask & CBEIF_INDENT)
772 item->iIndent = cit->iIndent;
773 if (cit->mask & CBEIF_LPARAM)
774 cit->lParam = cit->lParam;
776 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
778 /* if original request was to update edit control, do some fast foot work */
779 if (cit->iItem == -1) {
780 COMBOEX_SetEditText (infoPtr, item);
781 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
783 return TRUE;
786 static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit)
788 COMBOBOXEXITEMW citW;
789 LPWSTR wstr = NULL;
790 BOOL ret;
792 memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA));
793 if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) {
794 INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0);
795 wstr = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
796 if (!wstr) return FALSE;
797 MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len);
798 citW.pszText = wstr;
800 ret = COMBOEX_SetItemW(infoPtr, &citW);
802 if (wstr) Free(wstr);
804 return ret;
808 static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value)
810 BOOL bTemp = infoPtr->unicode;
812 TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE");
814 infoPtr->unicode = value;
816 return bTemp;
820 /* *** CB_xxx message support *** */
822 static INT
823 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCWSTR str)
825 INT i;
826 cmp_func_t cmptext = get_cmp_func(infoPtr);
827 INT count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
829 /* now search from after starting loc and wrapping back to start */
830 for(i=start+1; i<count; i++) {
831 CBE_ITEMDATA *item = get_item_data(infoPtr, i);
832 if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
834 for(i=0; i<=start; i++) {
835 CBE_ITEMDATA *item = get_item_data(infoPtr, i);
836 if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
838 return CB_ERR;
842 static DWORD_PTR COMBOEX_GetItemData (COMBOEX_INFO *infoPtr, INT index)
844 CBE_ITEMDATA *item1, *item2;
845 DWORD_PTR ret = 0;
847 item1 = get_item_data(infoPtr, index);
848 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
849 item2 = COMBOEX_FindItem (infoPtr, index);
850 if (item2 != item1) {
851 ERR("data structures damaged!\n");
852 return CB_ERR;
854 if (item1->mask & CBEIF_LPARAM) ret = item1->lParam;
855 TRACE("returning 0x%08lx\n", ret);
856 } else {
857 ret = (DWORD_PTR)item1;
858 TRACE("non-valid result from combo, returning 0x%08lx\n", ret);
860 return ret;
864 static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT index)
866 CBE_ITEMDATA *item;
867 INT sel;
869 if (!(item = COMBOEX_FindItem(infoPtr, index)))
870 return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
872 TRACE("selecting item %d text=%s\n", index, debugstr_txt(item->pszText));
873 infoPtr->selected = index;
875 sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0);
876 COMBOEX_SetEditText (infoPtr, item);
877 return sel;
881 static DWORD_PTR COMBOEX_SetItemData (COMBOEX_INFO *infoPtr, INT index, DWORD_PTR data)
883 CBE_ITEMDATA *item1, *item2;
885 item1 = get_item_data(infoPtr, index);
886 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
887 item2 = COMBOEX_FindItem (infoPtr, index);
888 if (item2 != item1) {
889 ERR("data structures damaged!\n");
890 return CB_ERR;
892 item1->mask |= CBEIF_LPARAM;
893 item1->lParam = data;
894 TRACE("setting lparam to 0x%08lx\n", data);
895 return 0;
897 TRACE("non-valid result from combo %p\n", item1);
898 return (DWORD_PTR)item1;
902 static INT COMBOEX_SetItemHeight (COMBOEX_INFO *infoPtr, INT index, UINT height)
904 RECT cb_wrect, cbx_wrect, cbx_crect;
906 /* First, lets forward the message to the normal combo control
907 just like Windows. */
908 if (infoPtr->hwndCombo)
909 if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
910 index, height) == CB_ERR) return CB_ERR;
912 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
913 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
914 GetClientRect (infoPtr->hwndSelf, &cbx_crect);
915 /* the height of comboex as height of the combo + comboex border */
916 height = cb_wrect.bottom-cb_wrect.top
917 + cbx_wrect.bottom-cbx_wrect.top
918 - (cbx_crect.bottom-cbx_crect.top);
919 TRACE("EX window=(%ld,%ld)-(%ld,%ld), client=(%ld,%ld)-(%ld,%ld)\n",
920 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
921 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
922 TRACE("CB window=(%ld,%ld)-(%ld,%ld), EX setting=(0,0)-(%ld,%d)\n",
923 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
924 cbx_wrect.right-cbx_wrect.left, height);
925 SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0,
926 cbx_wrect.right-cbx_wrect.left, height,
927 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
929 return 0;
933 /* *** WM_xxx message support *** */
936 static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs)
938 static const WCHAR COMBOBOX[] = { 'C', 'o', 'm', 'b', 'o', 'B', 'o', 'x', 0 };
939 static const WCHAR EDIT[] = { 'E', 'D', 'I', 'T', 0 };
940 static const WCHAR NIL[] = { 0 };
941 COMBOEX_INFO *infoPtr;
942 LOGFONTW mylogfont;
943 RECT wnrc1, clrc1, cmbwrc;
944 INT i;
946 /* allocate memory for info structure */
947 infoPtr = (COMBOEX_INFO *)Alloc (sizeof(COMBOEX_INFO));
948 if (!infoPtr) return -1;
950 /* initialize info structure */
951 /* note that infoPtr is allocated zero-filled */
953 infoPtr->hwndSelf = hwnd;
954 infoPtr->selected = -1;
956 infoPtr->unicode = IsWindowUnicode (hwnd);
957 infoPtr->hwndNotify = cs->hwndParent;
959 i = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
960 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
961 WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
962 i = NFR_ANSI;
964 infoPtr->NtfUnicode = (i == NFR_UNICODE);
966 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
968 /* create combo box */
969 GetWindowRect(hwnd, &wnrc1);
970 GetClientRect(hwnd, &clrc1);
971 TRACE("EX window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld)\n",
972 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
973 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
975 /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
976 /* specified. It then creates it's own version of the EDIT control */
977 /* and makes the ComboBox the parent. This is because a normal */
978 /* DROPDOWNLIST does not have an EDIT control, but we need one. */
979 /* We also need to place the edit control at the proper location */
980 /* (allow space for the icons). */
982 infoPtr->hwndCombo = CreateWindowW (COMBOBOX, NIL,
983 /* following line added to match native */
984 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
985 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
986 /* was base and is necessary */
987 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED |
988 GetWindowLongW (hwnd, GWL_STYLE),
989 cs->y, cs->x, cs->cx, cs->cy, hwnd,
990 (HMENU) GetWindowLongPtrW (hwnd, GWLP_ID),
991 (HINSTANCE)GetWindowLongPtrW (hwnd, GWLP_HINSTANCE), NULL);
994 * native does the following at this point according to trace:
995 * GetWindowThreadProcessId(hwndCombo,0)
996 * GetCurrentThreadId()
997 * GetWindowThreadProcessId(hwndCombo, &???)
998 * GetCurrentProcessId()
1002 * Setup a property to hold the pointer to the COMBOBOXEX
1003 * data structure.
1005 SetPropW(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd);
1006 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hwndCombo,
1007 GWLP_WNDPROC, (DWORD_PTR)COMBOEX_ComboWndProc);
1008 infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1012 * Now create our own EDIT control so we can position it.
1013 * It is created only for CBS_DROPDOWN style
1015 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
1016 infoPtr->hwndEdit = CreateWindowExW (0, EDIT, NIL,
1017 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
1018 0, 0, 0, 0, /* will set later */
1019 infoPtr->hwndCombo,
1020 (HMENU) GetWindowLongPtrW (hwnd, GWLP_ID),
1021 (HINSTANCE)GetWindowLongPtrW (hwnd, GWLP_HINSTANCE), NULL);
1023 /* native does the following at this point according to trace:
1024 * GetWindowThreadProcessId(hwndEdit,0)
1025 * GetCurrentThreadId()
1026 * GetWindowThreadProcessId(hwndEdit, &???)
1027 * GetCurrentProcessId()
1031 * Setup a property to hold the pointer to the COMBOBOXEX
1032 * data structure.
1034 SetPropW(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd);
1035 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hwndEdit,
1036 GWLP_WNDPROC, (DWORD_PTR)COMBOEX_EditWndProc);
1037 infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0);
1041 * Locate the default font if necessary and then set it in
1042 * all associated controls
1044 if (!infoPtr->font) {
1045 SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
1046 &mylogfont, 0);
1047 infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont);
1049 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1050 if (infoPtr->hwndEdit) {
1051 SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
1052 SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
1055 COMBOEX_ReSize (infoPtr);
1057 /* Above is fairly certain, below is much less certain. */
1059 GetWindowRect(hwnd, &wnrc1);
1060 GetClientRect(hwnd, &clrc1);
1061 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1062 TRACE("EX window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) CB wnd=(%ld,%ld)-(%ld,%ld)\n",
1063 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
1064 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
1065 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1066 SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
1067 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
1068 SWP_NOACTIVATE | SWP_NOREDRAW);
1070 GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
1071 TRACE("CB window=(%ld,%ld)-(%ld,%ld)\n",
1072 cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
1073 SetWindowPos(hwnd, HWND_TOP,
1074 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
1075 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
1077 COMBOEX_AdjustEditPos (infoPtr);
1080 * Create an item structure to represent the data in the
1081 * EDIT control. It is allocated zero-filled.
1083 infoPtr->edit = (CBE_ITEMDATA *)Alloc (sizeof (CBE_ITEMDATA));
1084 if (!infoPtr->edit) {
1085 COMBOEX_Destroy(infoPtr);
1086 return -1;
1089 return 0;
1093 static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
1095 LRESULT lret;
1096 INT command = HIWORD(wParam);
1097 CBE_ITEMDATA *item = 0;
1098 WCHAR wintext[520];
1099 INT cursel, n, oldItem;
1100 NMCBEENDEDITW cbeend;
1101 DWORD oldflags;
1102 HWND parent = infoPtr->hwndNotify;
1104 TRACE("for command %d\n", command);
1106 switch (command)
1108 case CBN_DROPDOWN:
1109 SetFocus (infoPtr->hwndCombo);
1110 ShowWindow (infoPtr->hwndEdit, SW_HIDE);
1111 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1113 case CBN_CLOSEUP:
1114 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1116 * from native trace of first dropdown after typing in URL in IE4
1117 * CB_GETCURSEL(Combo)
1118 * GetWindowText(Edit)
1119 * CB_GETCURSEL(Combo)
1120 * CB_GETCOUNT(Combo)
1121 * CB_GETITEMDATA(Combo, n)
1122 * WM_NOTIFY(parent, CBEN_ENDEDITA|W)
1123 * CB_GETCURSEL(Combo)
1124 * CB_SETCURSEL(COMBOEX, n)
1125 * SetFocus(Combo)
1126 * the rest is supposition
1128 ShowWindow (infoPtr->hwndEdit, SW_SHOW);
1129 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1130 InvalidateRect (infoPtr->hwndEdit, 0, TRUE);
1131 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1132 if (cursel == -1) {
1133 cmp_func_t cmptext = get_cmp_func(infoPtr);
1134 /* find match from edit against those in Combobox */
1135 GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
1136 n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
1137 for (cursel = 0; cursel < n; cursel++){
1138 item = get_item_data(infoPtr, cursel);
1139 if ((INT_PTR)item == CB_ERR) break;
1140 if (!cmptext(COMBOEX_GetText(infoPtr, item), wintext)) break;
1142 if ((cursel == n) || ((INT_PTR)item == CB_ERR)) {
1143 TRACE("failed to find match??? item=%p cursel=%d\n",
1144 item, cursel);
1145 if (infoPtr->hwndEdit)
1146 SetFocus(infoPtr->hwndEdit);
1147 return 0;
1150 else {
1151 item = get_item_data(infoPtr, cursel);
1152 if ((INT_PTR)item == CB_ERR) {
1153 TRACE("failed to find match??? item=%p cursel=%d\n",
1154 item, cursel);
1155 if (infoPtr->hwndEdit)
1156 SetFocus(infoPtr->hwndEdit);
1157 return 0;
1161 /* Save flags for testing and reset them */
1162 oldflags = infoPtr->flags;
1163 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1165 if (oldflags & WCBE_ACTEDIT) {
1166 cbeend.fChanged = (oldflags & WCBE_EDITCHG);
1167 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1168 CB_GETCURSEL, 0, 0);
1169 cbeend.iWhy = CBENF_DROPDOWN;
1171 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0;
1174 /* if selection has changed the set the new current selection */
1175 cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1176 if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
1177 infoPtr->selected = cursel;
1178 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0);
1179 SetFocus(infoPtr->hwndCombo);
1181 return 0;
1183 case CBN_SELCHANGE:
1185 * CB_GETCURSEL(Combo)
1186 * CB_GETITEMDATA(Combo) < simulated by COMBOEX_FindItem
1187 * lstrlenA
1188 * WM_SETTEXT(Edit)
1189 * WM_GETTEXTLENGTH(Edit)
1190 * WM_GETTEXT(Edit)
1191 * EM_SETSEL(Edit, 0,0)
1192 * WM_GETTEXTLENGTH(Edit)
1193 * WM_GETTEXT(Edit)
1194 * EM_SETSEL(Edit, 0,len)
1195 * return WM_COMMAND to parent
1197 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1198 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1199 ERR("item %d not found. Problem!\n", oldItem);
1200 break;
1202 infoPtr->selected = oldItem;
1203 COMBOEX_SetEditText (infoPtr, item);
1204 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1206 case CBN_SELENDOK:
1208 * We have to change the handle since we are the control
1209 * issuing the message. IE4 depends on this.
1211 return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1213 case CBN_KILLFOCUS:
1215 * from native trace:
1217 * pass to parent
1218 * WM_GETTEXT(Edit, 104)
1219 * CB_GETCURSEL(Combo) rets -1
1220 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1221 * CB_GETCURSEL(Combo)
1222 * InvalidateRect(Combo, 0, 0)
1223 * return 0
1225 SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1226 if (infoPtr->flags & WCBE_ACTEDIT) {
1227 GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
1228 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
1229 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1230 CB_GETCURSEL, 0, 0);
1231 cbeend.iWhy = CBENF_KILLFOCUS;
1233 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1234 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0;
1236 /* possible CB_GETCURSEL */
1237 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1238 return 0;
1240 default:
1242 * We have to change the handle since we are the control
1243 * issuing the message. IE4 depends on this.
1244 * We also need to set the focus back to the Edit control
1245 * after passing the command to the parent of the ComboEx.
1247 lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
1248 if (infoPtr->hwndEdit)
1249 SetFocus(infoPtr->hwndEdit);
1250 return lret;
1252 return 0;
1256 static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis)
1258 CBE_ITEMDATA *item, *olditem;
1259 NMCOMBOBOXEXW nmcit;
1260 UINT i;
1262 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%p, data=%08lx\n",
1263 dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
1265 if (dis->itemID >= infoPtr->nb_items) return FALSE;
1267 olditem = infoPtr->items;
1268 i = infoPtr->nb_items - 1;
1270 if (i == dis->itemID) {
1271 infoPtr->items = infoPtr->items->next;
1273 else {
1274 item = olditem;
1275 i--;
1277 /* find the prior item in the list */
1278 while (item->next && (i > dis->itemID)) {
1279 item = item->next;
1280 i--;
1282 if (!item->next || (i != dis->itemID)) {
1283 ERR("COMBOBOXEX item structures broken. Please report!\n");
1284 return FALSE;
1286 olditem = item->next;
1287 item->next = item->next->next;
1289 infoPtr->nb_items--;
1291 memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem));
1292 COMBOEX_CopyItem (olditem, &nmcit.ceItem);
1293 COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit);
1295 COMBOEX_FreeText(olditem);
1296 Free(olditem);
1298 return TRUE;
1302 static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT *dis)
1304 static const WCHAR nil[] = { 0 };
1305 CBE_ITEMDATA *item = 0;
1306 SIZE txtsize;
1307 RECT rect;
1308 LPCWSTR str = nil;
1309 UINT xbase, x, y;
1310 INT len;
1311 COLORREF nbkc, ntxc, bkc, txc;
1312 int drawimage, drawstate, xioff;
1314 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
1316 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
1317 dis->CtlType, dis->CtlID);
1318 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
1319 dis->itemID, dis->itemAction, dis->itemState);
1320 TRACE("hWnd=%p hDC=%p (%ld,%ld)-(%ld,%ld) itemData=0x%08lx\n",
1321 dis->hwndItem, dis->hDC, dis->rcItem.left,
1322 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
1323 dis->itemData);
1325 /* MSDN says: */
1326 /* "itemID - Specifies the menu item identifier for a menu */
1327 /* item or the index of the item in a list box or combo box. */
1328 /* For an empty list box or combo box, this member can be -1. */
1329 /* This allows the application to draw only the focus */
1330 /* rectangle at the coordinates specified by the rcItem */
1331 /* member even though there are no items in the control. */
1332 /* This indicates to the user whether the list box or combo */
1333 /* box has the focus. How the bits are set in the itemAction */
1334 /* member determines whether the rectangle is to be drawn as */
1335 /* though the list box or combo box has the focus. */
1336 if (dis->itemID == 0xffffffff) {
1337 if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
1338 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
1340 TRACE("drawing item -1 special focus, rect=(%ld,%ld)-(%ld,%ld)\n",
1341 dis->rcItem.left, dis->rcItem.top,
1342 dis->rcItem.right, dis->rcItem.bottom);
1344 else if ((dis->CtlType == ODT_COMBOBOX) &&
1345 (dis->itemAction == ODA_DRAWENTIRE)) {
1346 /* draw of edit control data */
1348 /* testing */
1350 RECT exrc, cbrc, edrc;
1351 GetWindowRect (infoPtr->hwndSelf, &exrc);
1352 GetWindowRect (infoPtr->hwndCombo, &cbrc);
1353 edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
1354 if (infoPtr->hwndEdit)
1355 GetWindowRect (infoPtr->hwndEdit, &edrc);
1356 TRACE("window rects ex=(%ld,%ld)-(%ld,%ld), cb=(%ld,%ld)-(%ld,%ld), ed=(%ld,%ld)-(%ld,%ld)\n",
1357 exrc.left, exrc.top, exrc.right, exrc.bottom,
1358 cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
1359 edrc.left, edrc.top, edrc.right, edrc.bottom);
1362 else {
1363 ERR("NOT drawing item -1 special focus, rect=(%ld,%ld)-(%ld,%ld), action=%08x, state=%08x\n",
1364 dis->rcItem.left, dis->rcItem.top,
1365 dis->rcItem.right, dis->rcItem.bottom,
1366 dis->itemAction, dis->itemState);
1367 return 0;
1371 /* If draw item is -1 (edit control) setup the item pointer */
1372 if (dis->itemID == 0xffffffff) {
1373 item = infoPtr->edit;
1375 if (infoPtr->hwndEdit) {
1376 INT len;
1378 /* free previous text of edit item */
1379 COMBOEX_FreeText(item);
1380 item->mask &= ~CBEIF_TEXT;
1381 if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) {
1382 item->mask |= CBEIF_TEXT;
1383 item->pszText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
1384 if (item->pszText)
1385 GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1);
1387 TRACE("edit control hwndEdit=%p, text len=%d str=%s\n",
1388 infoPtr->hwndEdit, len, debugstr_txt(item->pszText));
1394 /* if the item pointer is not set, then get the data and locate it */
1395 if (!item) {
1396 item = get_item_data(infoPtr, dis->itemID);
1397 if (item == (CBE_ITEMDATA *)CB_ERR) {
1398 ERR("invalid item for id %d\n", dis->itemID);
1399 return 0;
1403 if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
1405 xbase = CBE_STARTOFFSET;
1406 if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) {
1407 INT indent = item->iIndent;
1408 if (indent == I_INDENTCALLBACK) {
1409 NMCOMBOBOXEXW nmce;
1410 ZeroMemory(&nmce, sizeof(nmce));
1411 nmce.ceItem.mask = CBEIF_INDENT;
1412 nmce.ceItem.lParam = item->lParam;
1413 nmce.ceItem.iItem = dis->itemID;
1414 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1415 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
1416 item->iIndent = nmce.ceItem.iIndent;
1417 indent = nmce.ceItem.iIndent;
1419 xbase += (indent * CBE_INDENT);
1422 drawimage = -2;
1423 drawstate = ILD_NORMAL;
1424 if (item->mask & CBEIF_IMAGE)
1425 drawimage = item->iImage;
1426 if (dis->itemState & ODS_COMBOEXLBOX) {
1427 /* drawing listbox entry */
1428 if (dis->itemState & ODS_SELECTED) {
1429 if (item->mask & CBEIF_SELECTEDIMAGE)
1430 drawimage = item->iSelectedImage;
1431 drawstate = ILD_SELECTED;
1433 } else {
1434 /* drawing combo/edit entry */
1435 if (IsWindowVisible(infoPtr->hwndEdit)) {
1436 /* if we have an edit control, the slave the
1437 * selection state to the Edit focus state
1439 if (infoPtr->flags & WCBE_EDITFOCUSED) {
1440 if (item->mask & CBEIF_SELECTEDIMAGE)
1441 drawimage = item->iSelectedImage;
1442 drawstate = ILD_SELECTED;
1444 } else {
1445 /* if we don't have an edit control, use
1446 * the requested state.
1448 if (dis->itemState & ODS_SELECTED) {
1449 if (item->mask & CBEIF_SELECTEDIMAGE)
1450 drawimage = item->iSelectedImage;
1451 drawstate = ILD_SELECTED;
1456 if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) {
1457 IMAGEINFO iinfo;
1458 iinfo.rcImage.left = iinfo.rcImage.right = 0;
1459 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
1460 xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
1461 } else xioff = 0;
1463 /* setup pointer to text to be drawn */
1464 str = COMBOEX_GetText(infoPtr, item);
1465 if (!str) str = nil;
1467 len = strlenW (str);
1468 GetTextExtentPoint32W (dis->hDC, str, len, &txtsize);
1470 if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) {
1471 int overlay = item->iOverlay;
1473 if (drawimage == I_IMAGECALLBACK) {
1474 NMCOMBOBOXEXW nmce;
1475 ZeroMemory(&nmce, sizeof(nmce));
1476 nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE;
1477 nmce.ceItem.lParam = item->lParam;
1478 nmce.ceItem.iItem = dis->itemID;
1479 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1480 if (drawstate == ILD_NORMAL) {
1481 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage;
1482 drawimage = nmce.ceItem.iImage;
1483 } else if (drawstate == ILD_SELECTED) {
1484 if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage;
1485 drawimage = nmce.ceItem.iSelectedImage;
1486 } else ERR("Bad draw state = %d\n", drawstate);
1489 if (overlay == I_IMAGECALLBACK) {
1490 NMCOMBOBOXEXW nmce;
1491 ZeroMemory(&nmce, sizeof(nmce));
1492 nmce.ceItem.mask = CBEIF_OVERLAY;
1493 nmce.ceItem.lParam = item->lParam;
1494 nmce.ceItem.iItem = dis->itemID;
1495 COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
1496 if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
1497 item->iOverlay = nmce.ceItem.iOverlay;
1498 overlay = nmce.ceItem.iOverlay;
1501 if (drawimage >= 0 &&
1502 !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) {
1503 if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1);
1504 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top,
1505 drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0));
1508 /* now draw the text */
1509 if (!IsWindowVisible (infoPtr->hwndEdit)) {
1510 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1511 COLOR_HIGHLIGHT : COLOR_WINDOW);
1512 bkc = SetBkColor (dis->hDC, nbkc);
1513 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
1514 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
1515 txc = SetTextColor (dis->hDC, ntxc);
1516 x = xbase + xioff;
1517 y = dis->rcItem.top +
1518 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
1519 rect.left = x;
1520 rect.right = x + txtsize.cx;
1521 rect.top = dis->rcItem.top + 1;
1522 rect.bottom = dis->rcItem.bottom - 1;
1523 TRACE("drawing item %d text, rect=(%ld,%ld)-(%ld,%ld)\n",
1524 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
1525 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
1526 &rect, str, len, 0);
1527 SetBkColor (dis->hDC, bkc);
1528 SetTextColor (dis->hDC, txc);
1532 if (dis->itemAction & ODA_FOCUS) {
1533 rect.left = xbase + xioff - 1;
1534 rect.right = rect.left + txtsize.cx + 2;
1535 rect.top = dis->rcItem.top;
1536 rect.bottom = dis->rcItem.bottom;
1537 DrawFocusRect(dis->hDC, &rect);
1540 return 0;
1544 static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr)
1546 if (infoPtr->hwndCombo)
1547 DestroyWindow (infoPtr->hwndCombo);
1549 if (infoPtr->edit) {
1550 Free (infoPtr->edit);
1551 infoPtr->edit = 0;
1554 if (infoPtr->items) {
1555 CBE_ITEMDATA *item, *next;
1557 item = infoPtr->items;
1558 while (item) {
1559 next = item->next;
1560 COMBOEX_FreeText (item);
1561 Free (item);
1562 item = next;
1564 infoPtr->items = 0;
1567 if (infoPtr->defaultFont)
1568 DeleteObject (infoPtr->defaultFont);
1570 /* free comboex info data */
1571 Free (infoPtr);
1572 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
1573 return 0;
1577 static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis)
1579 static const WCHAR strW[] = { 'W', 0 };
1580 SIZE mysize;
1581 HDC hdc;
1583 hdc = GetDC (0);
1584 GetTextExtentPointW (hdc, strW, 1, &mysize);
1585 ReleaseDC (0, hdc);
1586 mis->itemHeight = mysize.cy + CBE_EXTRA;
1588 TRACE("adjusted height hwnd=%p, height=%d\n",
1589 infoPtr->hwndSelf, mis->itemHeight);
1591 return 0;
1595 static LRESULT COMBOEX_NCCreate (HWND hwnd)
1597 /* WARNING: The COMBOEX_INFO structure is not yet created */
1598 DWORD oldstyle, newstyle;
1600 oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE);
1601 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL | WS_BORDER);
1602 if (newstyle != oldstyle) {
1603 TRACE("req style %08lx, reseting style %08lx\n",
1604 oldstyle, newstyle);
1605 SetWindowLongW (hwnd, GWL_STYLE, newstyle);
1607 return 1;
1611 static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam)
1613 if (lParam == NF_REQUERY) {
1614 INT i = SendMessageW(infoPtr->hwndNotify,
1615 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
1616 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
1618 return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI;
1622 static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height)
1624 TRACE("(width=%d, height=%d)\n", width, height);
1626 MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE);
1628 COMBOEX_AdjustEditPos (infoPtr);
1630 return 0;
1634 static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp)
1636 RECT cbx_wrect, cbx_crect, cb_wrect;
1637 INT width, height;
1639 GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
1640 GetClientRect (infoPtr->hwndSelf, &cbx_crect);
1641 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1643 /* width is winpos value + border width of comboex */
1644 width = wp->cx
1645 + (cbx_wrect.right-cbx_wrect.left)
1646 - (cbx_crect.right-cbx_crect.left);
1648 TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
1649 wp->x, wp->y, wp->cx, wp->cy, wp->flags);
1650 TRACE("EX window=(%ld,%ld)-(%ld,%ld), client=(%ld,%ld)-(%ld,%ld)\n",
1651 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
1652 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
1653 TRACE("CB window=(%ld,%ld)-(%ld,%ld), EX setting=(0,0)-(%d,%ld)\n",
1654 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
1655 width, cb_wrect.bottom-cb_wrect.top);
1657 if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
1658 width,
1659 cb_wrect.bottom-cb_wrect.top,
1660 SWP_NOACTIVATE);
1662 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
1664 /* height is combo window height plus border width of comboex */
1665 height = (cb_wrect.bottom-cb_wrect.top)
1666 + (cbx_wrect.bottom-cbx_wrect.top)
1667 - (cbx_crect.bottom-cbx_crect.top);
1668 if (wp->cy < height) wp->cy = height;
1669 if (infoPtr->hwndEdit) {
1670 COMBOEX_AdjustEditPos (infoPtr);
1671 InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
1674 return 0;
1677 static LRESULT WINAPI
1678 COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1680 HWND hwndComboex = (HWND)GetPropW(hwnd, COMBOEX_SUBCLASS_PROP);
1681 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex);
1682 NMCBEENDEDITW cbeend;
1683 WCHAR edit_text[260];
1684 COLORREF obkc;
1685 HDC hDC;
1686 RECT rect;
1687 LRESULT lret;
1689 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
1690 hwnd, uMsg, wParam, lParam, infoPtr);
1692 if (!infoPtr) return 0;
1694 switch (uMsg)
1697 case WM_CHAR:
1698 /* handle (ignore) the return character */
1699 if (wParam == VK_RETURN) return 0;
1700 /* all other characters pass into the real Edit */
1701 return CallWindowProcW (infoPtr->prevEditWndProc,
1702 hwnd, uMsg, wParam, lParam);
1704 case WM_ERASEBKGND:
1706 * The following was determined by traces of the native
1708 hDC = (HDC) wParam;
1709 obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW));
1710 GetClientRect (hwnd, &rect);
1711 TRACE("erasing (%ld,%ld)-(%ld,%ld)\n",
1712 rect.left, rect.top, rect.right, rect.bottom);
1713 ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
1714 SetBkColor (hDC, obkc);
1715 return CallWindowProcW (infoPtr->prevEditWndProc,
1716 hwnd, uMsg, wParam, lParam);
1718 case WM_KEYDOWN: {
1719 INT oldItem, selected, step = 1;
1720 CBE_ITEMDATA *item;
1722 switch ((INT)wParam)
1724 case VK_ESCAPE:
1725 /* native version seems to do following for COMBOEX */
1727 * GetWindowTextW(Edit,&?, 0x104) x
1728 * CB_GETCURSEL to Combo rets -1 x
1729 * WM_NOTIFY to COMBOEX parent (rebar) x
1730 * (CBEN_ENDEDIT{A|W}
1731 * fChanged = FALSE x
1732 * inewSelection = -1 x
1733 * txt="www.hoho" x
1734 * iWhy = 3 x
1735 * CB_GETCURSEL to Combo rets -1 x
1736 * InvalidateRect(Combo, 0) x
1737 * WM_SETTEXT to Edit x
1738 * EM_SETSEL to Edit (0,0) x
1739 * EM_SETSEL to Edit (0,-1) x
1740 * RedrawWindow(Combo, 0, 0, 5) x
1742 TRACE("special code for VK_ESCAPE\n");
1744 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1746 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1747 cbeend.fChanged = FALSE;
1748 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1749 CB_GETCURSEL, 0, 0);
1750 cbeend.iWhy = CBENF_ESCAPE;
1752 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
1753 oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
1754 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1755 if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
1756 ERR("item %d not found. Problem!\n", oldItem);
1757 break;
1759 infoPtr->selected = oldItem;
1760 COMBOEX_SetEditText (infoPtr, item);
1761 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1762 RDW_INVALIDATE);
1763 break;
1765 case VK_RETURN:
1766 /* native version seems to do following for COMBOEX */
1768 * GetWindowTextW(Edit,&?, 0x104) x
1769 * CB_GETCURSEL to Combo rets -1 x
1770 * CB_GETCOUNT to Combo rets 0
1771 * if >0 loop
1772 * CB_GETITEMDATA to match
1773 * *** above 3 lines simulated by FindItem x
1774 * WM_NOTIFY to COMBOEX parent (rebar) x
1775 * (CBEN_ENDEDIT{A|W} x
1776 * fChanged = TRUE (-1) x
1777 * iNewSelection = -1 or selected x
1778 * txt= x
1779 * iWhy = 2 (CBENF_RETURN) x
1780 * CB_GETCURSEL to Combo rets -1 x
1781 * if -1 send CB_SETCURSEL to Combo -1 x
1782 * InvalidateRect(Combo, 0, 0) x
1783 * SetFocus(Edit) x
1784 * CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
1787 TRACE("special code for VK_RETURN\n");
1789 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1791 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1792 selected = SendMessageW (infoPtr->hwndCombo,
1793 CB_GETCURSEL, 0, 0);
1795 if (selected != -1) {
1796 cmp_func_t cmptext = get_cmp_func(infoPtr);
1797 item = COMBOEX_FindItem (infoPtr, selected);
1798 TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
1799 selected, debugstr_txt(item->pszText));
1800 TRACE("handling VK_RETURN, edittext=%s\n",
1801 debugstr_w(edit_text));
1802 if (cmptext (COMBOEX_GetText(infoPtr, item), edit_text)) {
1803 /* strings not equal -- indicate edit has changed */
1804 selected = -1;
1808 cbeend.iNewSelection = selected;
1809 cbeend.fChanged = TRUE;
1810 cbeend.iWhy = CBENF_RETURN;
1811 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
1812 /* abort the change, restore previous */
1813 TRACE("Notify requested abort of change\n");
1814 COMBOEX_SetEditText (infoPtr, infoPtr->edit);
1815 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
1816 RDW_INVALIDATE);
1817 return 0;
1819 oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
1820 if (oldItem != -1) {
1821 /* if something is selected, then deselect it */
1822 SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
1823 (WPARAM)-1, 0);
1825 InvalidateRect (infoPtr->hwndCombo, 0, 0);
1826 SetFocus(infoPtr->hwndEdit);
1827 break;
1829 case VK_UP:
1830 step = -1;
1831 case VK_DOWN:
1832 /* by default, step is 1 */
1833 oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0);
1834 if (oldItem >= 0 && oldItem + step >= 0)
1835 SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0);
1836 return 0;
1837 default:
1838 return CallWindowProcW (infoPtr->prevEditWndProc,
1839 hwnd, uMsg, wParam, lParam);
1841 return 0;
1844 case WM_SETFOCUS:
1845 /* remember the focus to set state of icon */
1846 lret = CallWindowProcW (infoPtr->prevEditWndProc,
1847 hwnd, uMsg, wParam, lParam);
1848 infoPtr->flags |= WCBE_EDITFOCUSED;
1849 return lret;
1851 case WM_KILLFOCUS:
1853 * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
1855 infoPtr->flags &= ~WCBE_EDITFOCUSED;
1856 if (infoPtr->flags & WCBE_ACTEDIT) {
1857 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
1859 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1860 cbeend.fChanged = FALSE;
1861 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
1862 CB_GETCURSEL, 0, 0);
1863 cbeend.iWhy = CBENF_KILLFOCUS;
1865 COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
1867 /* fall through */
1869 default:
1870 return CallWindowProcW (infoPtr->prevEditWndProc,
1871 hwnd, uMsg, wParam, lParam);
1876 static LRESULT WINAPI
1877 COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1879 HWND hwndComboex = (HWND)GetPropW(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 pt.x = (short)LOWORD(lParam);
1943 pt.y = (short)HIWORD(lParam);
1944 if (PtInRect(&rect, pt))
1945 return CallWindowProcW (infoPtr->prevComboWndProc,
1946 hwnd, uMsg, wParam, lParam);
1947 infoPtr->flags |= WCBE_MOUSECAPTURED;
1948 SetCapture(hwnd);
1949 break;
1951 case WM_LBUTTONUP:
1952 if (!(infoPtr->flags & WCBE_MOUSECAPTURED))
1953 return CallWindowProcW (infoPtr->prevComboWndProc,
1954 hwnd, uMsg, wParam, lParam);
1955 ReleaseCapture();
1956 infoPtr->flags &= ~WCBE_MOUSECAPTURED;
1957 if (infoPtr->flags & WCBE_MOUSEDRAGGED) {
1958 infoPtr->flags &= ~WCBE_MOUSEDRAGGED;
1959 } else {
1960 SendMessageW(hwnd, CB_SHOWDROPDOWN, TRUE, 0);
1962 break;
1964 case WM_MOUSEMOVE:
1965 if ( (infoPtr->flags & WCBE_MOUSECAPTURED) &&
1966 !(infoPtr->flags & WCBE_MOUSEDRAGGED)) {
1967 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1968 COMBOEX_NotifyDragBegin(infoPtr, edit_text);
1969 infoPtr->flags |= WCBE_MOUSEDRAGGED;
1971 return CallWindowProcW (infoPtr->prevComboWndProc,
1972 hwnd, uMsg, wParam, lParam);
1974 case WM_COMMAND:
1975 switch (HIWORD(wParam)) {
1977 case EN_UPDATE:
1978 /* traces show that COMBOEX does not issue CBN_EDITUPDATE
1979 * on the EN_UPDATE
1981 return 0;
1983 case EN_KILLFOCUS:
1985 * Native does:
1987 * GetFocus() retns AA
1988 * GetWindowTextW(Edit)
1989 * CB_GETCURSEL(Combo) (got -1)
1990 * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
1991 * CB_GETCURSEL(Combo) (got -1)
1992 * InvalidateRect(Combo, 0, 0)
1993 * WM_KILLFOCUS(Combo, AA)
1994 * return 0;
1996 focusedhwnd = GetFocus();
1997 if (infoPtr->flags & WCBE_ACTEDIT) {
1998 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
1999 cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
2000 cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
2001 CB_GETCURSEL, 0, 0);
2002 cbeend.iWhy = CBENF_KILLFOCUS;
2004 infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
2005 if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0;
2007 /* possible CB_GETCURSEL */
2008 InvalidateRect (infoPtr->hwndCombo, 0, 0);
2009 if (focusedhwnd)
2010 SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
2011 (WPARAM)focusedhwnd, 0);
2012 return 0;
2014 case EN_SETFOCUS: {
2016 * For EN_SETFOCUS this issues the same calls and messages
2017 * as the native seems to do.
2019 * for some cases however native does the following:
2020 * (noticed after SetFocus during LBUTTONDOWN on
2021 * on dropdown arrow)
2022 * WM_GETTEXTLENGTH (Edit);
2023 * WM_GETTEXT (Edit, len+1, str);
2024 * EM_SETSEL (Edit, 0, 0);
2025 * WM_GETTEXTLENGTH (Edit);
2026 * WM_GETTEXT (Edit, len+1, str);
2027 * EM_SETSEL (Edit, 0, len);
2028 * WM_NOTIFY (parent, CBEN_BEGINEDIT)
2030 NMHDR hdr;
2032 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
2033 SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
2034 COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
2035 infoPtr->flags |= WCBE_ACTEDIT;
2036 infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
2037 return 0;
2040 case EN_CHANGE: {
2042 * For EN_CHANGE this issues the same calls and messages
2043 * as the native seems to do.
2045 WCHAR edit_text[260];
2046 LPCWSTR lastwrk;
2047 cmp_func_t cmptext = get_cmp_func(infoPtr);
2049 INT selected = SendMessageW (infoPtr->hwndCombo,
2050 CB_GETCURSEL, 0, 0);
2052 /* lstrlenW( lastworkingURL ) */
2054 GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
2055 if (selected == -1) {
2056 lastwrk = infoPtr->edit->pszText;
2058 else {
2059 CBE_ITEMDATA *item = COMBOEX_FindItem (infoPtr, selected);
2060 lastwrk = COMBOEX_GetText(infoPtr, item);
2063 TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
2064 selected, debugstr_w(lastwrk));
2065 TRACE("handling EN_CHANGE, edittext=%s\n",
2066 debugstr_w(edit_text));
2068 /* cmptext is between lastworkingURL and GetWindowText */
2069 if (cmptext (lastwrk, edit_text)) {
2070 /* strings not equal -- indicate edit has changed */
2071 infoPtr->flags |= WCBE_EDITCHG;
2073 SendMessageW ( infoPtr->hwndNotify, WM_COMMAND,
2074 MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
2075 CBN_EDITCHANGE),
2076 (LPARAM)infoPtr->hwndSelf);
2077 return 0;
2080 case LBN_SELCHANGE:
2082 * Therefore from traces there is no additional code here
2086 * Using native COMCTL32 gets the following:
2087 * 1 == SHDOCVW.DLL issues call/message
2088 * 2 == COMCTL32.DLL issues call/message
2089 * 3 == WINE issues call/message
2092 * for LBN_SELCHANGE:
2093 * 1 CB_GETCURSEL(ComboEx)
2094 * 1 CB_GETDROPPEDSTATE(ComboEx)
2095 * 1 CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
2096 * 2 CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
2097 ** call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
2098 * 3 WM_COMMAND(ComboEx, CBN_SELENDOK)
2099 * WM_USER+49(ComboLB, 1,0) <=============!!!!!!!!!!!
2100 * 3 ShowWindow(ComboLB, SW_HIDE)
2101 * 3 RedrawWindow(Combo, RDW_UPDATENOW)
2102 * 3 WM_COMMAND(ComboEX, CBN_CLOSEUP)
2103 ** end of CBRollUp
2104 * 3 WM_COMMAND(ComboEx, CBN_SELCHANGE) (echo to parent)
2105 * ? LB_GETCURSEL <==|
2106 * ? LB_GETTEXTLEN |
2107 * ? LB_GETTEXT | Needs to be added to
2108 * ? WM_CTLCOLOREDIT(ComboEx) | Combo processing
2109 * ? LB_GETITEMDATA |
2110 * ? WM_DRAWITEM(ComboEx) <==|
2112 default:
2113 break;
2114 }/* fall through */
2115 default:
2116 return CallWindowProcW (infoPtr->prevComboWndProc,
2117 hwnd, uMsg, wParam, lParam);
2119 return 0;
2123 static LRESULT WINAPI
2124 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2126 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
2128 TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
2130 if (!infoPtr) {
2131 if (uMsg == WM_CREATE)
2132 return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam);
2133 if (uMsg == WM_NCCREATE)
2134 COMBOEX_NCCreate (hwnd);
2135 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2138 switch (uMsg)
2140 case CBEM_DELETEITEM:
2141 return COMBOEX_DeleteItem (infoPtr, wParam);
2143 case CBEM_GETCOMBOCONTROL:
2144 return (LRESULT)infoPtr->hwndCombo;
2146 case CBEM_GETEDITCONTROL:
2147 return (LRESULT)infoPtr->hwndEdit;
2149 case CBEM_GETEXTENDEDSTYLE:
2150 return infoPtr->dwExtStyle;
2152 case CBEM_GETIMAGELIST:
2153 return (LRESULT)infoPtr->himl;
2155 case CBEM_GETITEMA:
2156 return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2158 case CBEM_GETITEMW:
2159 return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2161 case CBEM_GETUNICODEFORMAT:
2162 return infoPtr->unicode;
2164 case CBEM_HASEDITCHANGED:
2165 return COMBOEX_HasEditChanged (infoPtr);
2167 case CBEM_INSERTITEMA:
2168 return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2170 case CBEM_INSERTITEMW:
2171 return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2173 case CBEM_SETEXSTYLE:
2174 case CBEM_SETEXTENDEDSTYLE:
2175 return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam);
2177 case CBEM_SETIMAGELIST:
2178 return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam);
2180 case CBEM_SETITEMA:
2181 return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam);
2183 case CBEM_SETITEMW:
2184 return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam);
2186 case CBEM_SETUNICODEFORMAT:
2187 return COMBOEX_SetUnicodeFormat (infoPtr, wParam);
2189 /*case CBEM_SETWINDOWTHEME:
2190 FIXME("CBEM_SETWINDOWTHEME: stub\n");*/
2192 case WM_SETTEXT:
2193 case WM_GETTEXT:
2194 return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam);
2196 /* Combo messages we are not sure if we need to process or just forward */
2197 case CB_GETDROPPEDCONTROLRECT:
2198 case CB_GETITEMHEIGHT:
2199 case CB_GETLBTEXT:
2200 case CB_GETLBTEXTLEN:
2201 case CB_GETEXTENDEDUI:
2202 case CB_LIMITTEXT:
2203 case CB_RESETCONTENT:
2204 case CB_SELECTSTRING:
2206 /* Combo messages OK to just forward to the regular COMBO */
2207 case CB_GETCOUNT:
2208 case CB_GETCURSEL:
2209 case CB_GETDROPPEDSTATE:
2210 case CB_SETDROPPEDWIDTH:
2211 case CB_SETEXTENDEDUI:
2212 case CB_SHOWDROPDOWN:
2213 return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam);
2215 /* Combo messages we need to process specially */
2216 case CB_FINDSTRINGEXACT:
2217 return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCWSTR)lParam);
2219 case CB_GETITEMDATA:
2220 return COMBOEX_GetItemData (infoPtr, (INT)wParam);
2222 case CB_SETCURSEL:
2223 return COMBOEX_SetCursel (infoPtr, (INT)wParam);
2225 case CB_SETITEMDATA:
2226 return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD_PTR)lParam);
2228 case CB_SETITEMHEIGHT:
2229 return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam);
2233 /* Window messages passed to parent */
2234 case WM_COMMAND:
2235 return COMBOEX_Command (infoPtr, wParam, lParam);
2237 case WM_NOTIFY:
2238 if (infoPtr->NtfUnicode)
2239 return SendMessageW (infoPtr->hwndNotify, uMsg, wParam, lParam);
2240 else
2241 return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
2244 /* Window messages we need to process */
2245 case WM_DELETEITEM:
2246 return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam);
2248 case WM_DRAWITEM:
2249 return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam);
2251 case WM_DESTROY:
2252 return COMBOEX_Destroy (infoPtr);
2254 case WM_MEASUREITEM:
2255 return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam);
2257 case WM_NOTIFYFORMAT:
2258 return COMBOEX_NotifyFormat (infoPtr, lParam);
2260 case WM_SIZE:
2261 return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam));
2263 case WM_WINDOWPOSCHANGING:
2264 return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam);
2266 case WM_SETFOCUS:
2267 SetFocus(infoPtr->hwndCombo);
2268 return 0;
2270 default:
2271 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
2272 ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam);
2273 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
2278 void COMBOEX_Register (void)
2280 WNDCLASSW wndClass;
2282 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
2283 wndClass.style = CS_GLOBALCLASS;
2284 wndClass.lpfnWndProc = COMBOEX_WindowProc;
2285 wndClass.cbClsExtra = 0;
2286 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
2287 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
2288 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2289 wndClass.lpszClassName = WC_COMBOBOXEXW;
2291 RegisterClassW (&wndClass);
2295 void COMBOEX_Unregister (void)
2297 UnregisterClassW (WC_COMBOBOXEXW, NULL);