4 * Copyright 1998, 1999 Eric Kohl
7 * This is just a dummy control. An author is needed! Any volunteers?
8 * I will only improve this control once in a while.
9 * Eric <ekohl@abo.rhein-zeitung.de>
13 * - All notifications.
16 * - should include "combo.h"
18 * Changes Guy Albertelli <galberte@neo.lrun.com>
19 * 1. Implemented message CB_SETITEMHEIGHT
20 * 2. Implemented message WM_WINDOWPOSCHANGING
21 * 3. Implemented message WM_MEASUREITEM
22 * 4. Add code to WM_CREATE processing to set font of COMBOBOX and
23 * issue the CB_SETITEMHEIGHT to start the correct sizing process.
24 * The above 4 changes allow the window rect for the comboboxex
25 * to be set properly, which in turn allows the height of the
26 * rebar control it *may* be imbeded in to be correct.
27 * 5. Rewrite CBEM_INSERTITEMA to save the information.
28 * 6. Implemented message WM_DRAWITEM. The code will handle images
29 * but not "overlays" yet.
30 * 7. Fixed code in CBEM_SETIMAGELIST to resize control.
31 * 8. Add debugging code.
33 * Test vehicals were the ControlSpy modules (rebar.exe and comboboxex.exe)
39 #include "debugtools.h"
40 #include "wine/unicode.h"
42 DEFAULT_DEBUG_CHANNEL(comboex);
43 DECLARE_DEBUG_CHANNEL(message);
59 /* ComboBoxEx structure */
66 INT nb_items; /* Number of items */
67 CBE_ITEMDATA *items; /* Array of items */
70 #define ID_CB_EDIT 1001
72 /* Height in pixels of control over the amount of the selected font */
75 /* Indent amount per MS documentation */
78 /* Offset in pixels from left side for start of image or text */
79 #define CBE_STARTOFFSET 6
81 /* Offset between image and text */
84 #define COMBOEX_GetInfoPtr(wndPtr) ((COMBOEX_INFO *)GetWindowLongA (hwnd, 0))
88 COMBOEX_DumpItem (CBE_ITEMDATA *item)
90 if (TRACE_ON(comboex)){
91 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
92 item, item->mask, item->pszText, item->cchTextMax,
94 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
95 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
100 inline static LRESULT
101 COMBOEX_Forward (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
103 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
105 FIXME("(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam);
107 if (infoPtr->hwndCombo)
108 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
115 COMBOEX_ReSize (HWND hwnd, COMBOEX_INFO *infoPtr)
123 mydc = GetDC (0); /* why the entire screen???? */
124 nfont = SendMessageA (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
125 ofont = (HFONT) SelectObject (mydc, nfont);
126 GetTextExtentPointA (mydc, "A", 1, &mysize);
127 SelectObject (mydc, ofont);
129 cy = mysize.cy + CBE_EXTRA;
131 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
132 cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
134 TRACE("selected font hwnd=%08x, height=%d\n", nfont, cy);
135 SendMessageA (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
136 if (infoPtr->hwndCombo)
137 SendMessageA (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
138 (WPARAM) 0, (LPARAM) cy);
142 /* *** CBEM_xxx message support *** */
145 /* << COMBOEX_DeleteItem >> */
148 inline static LRESULT
149 COMBOEX_GetComboControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
151 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
155 return (LRESULT)infoPtr->hwndCombo;
159 inline static LRESULT
160 COMBOEX_GetEditControl (HWND hwnd, WPARAM wParam, LPARAM lParam)
162 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
164 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
167 TRACE("-- 0x%x\n", GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT));
169 return (LRESULT)GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT);
173 inline static LRESULT
174 COMBOEX_GetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
176 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
178 return (LRESULT)infoPtr->dwExtStyle;
182 inline static LRESULT
183 COMBOEX_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
185 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
187 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
189 return (LRESULT)infoPtr->himl;
193 /* << COMBOEX_GetItemA >> */
195 /* << COMBOEX_GetItemW >> */
197 /* << COMBOEX_GetUniCodeFormat >> */
199 /* << COMBOEX_HasEditChanged >> */
203 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
205 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
206 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
211 /* get real index of item to insert */
213 if (index == -1) index = infoPtr->nb_items;
214 if (index > infoPtr->nb_items) index = infoPtr->nb_items;
216 /* get space and chain it in */
217 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
219 item->pszText = NULL;
221 /* locate position to insert new item in */
222 if (index == infoPtr->nb_items) {
223 /* fast path for iItem = -1 */
224 item->next = infoPtr->items;
225 infoPtr->items = item;
228 int i = infoPtr->nb_items-1;
229 CBE_ITEMDATA *moving = infoPtr->items;
231 while (i > index && moving) {
232 moving = (CBE_ITEMDATA *)moving->next;
235 FIXME("COMBOBOXEX item structures broken. Please report!\n");
239 item->next = moving->next;
243 /* fill in our hidden item structure */
244 item->mask = cit->mask;
245 if (item->mask & CBEIF_TEXT) {
251 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
253 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
254 MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, len);
256 item->cchTextMax = cit->cchTextMax;
258 if (item->mask & CBEIF_IMAGE)
259 item->iImage = cit->iImage;
260 if (item->mask & CBEIF_SELECTEDIMAGE)
261 item->iSelectedImage = cit->iSelectedImage;
262 if (item->mask & CBEIF_OVERLAY)
263 item->iOverlay = cit->iOverlay;
264 if (item->mask & CBEIF_INDENT)
265 item->iIndent = cit->iIndent;
266 if (item->mask & CBEIF_LPARAM)
267 item->lParam = cit->lParam;
270 COMBOEX_DumpItem (item);
272 SendMessageA (infoPtr->hwndCombo, CB_INSERTSTRING,
273 (WPARAM)cit->iItem, (LPARAM)item);
281 COMBOEX_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
283 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
284 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
288 /* get real index of item to insert */
290 if (index == -1) index = infoPtr->nb_items;
291 if (index > infoPtr->nb_items) index = infoPtr->nb_items;
293 /* get space and chain it in */
294 item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA));
296 item->pszText = NULL;
298 /* locate position to insert new item in */
299 if (index == infoPtr->nb_items) {
300 /* fast path for iItem = -1 */
301 item->next = infoPtr->items;
302 infoPtr->items = item;
305 INT i = infoPtr->nb_items-1;
306 CBE_ITEMDATA *moving = infoPtr->items;
308 while ((i > index) && moving) {
309 moving = (CBE_ITEMDATA *)moving->next;
313 FIXME("COMBOBOXEX item structures broken. Please report!\n");
317 item->next = moving->next;
321 /* fill in our hidden item structure */
322 item->mask = cit->mask;
323 if (item->mask & CBEIF_TEXT) {
328 if (!str) str = (LPWSTR) L"";
331 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
332 strcpyW (item->pszText, str);
334 item->cchTextMax = cit->cchTextMax;
336 if (item->mask & CBEIF_IMAGE)
337 item->iImage = cit->iImage;
338 if (item->mask & CBEIF_SELECTEDIMAGE)
339 item->iSelectedImage = cit->iSelectedImage;
340 if (item->mask & CBEIF_OVERLAY)
341 item->iOverlay = cit->iOverlay;
342 if (item->mask & CBEIF_INDENT)
343 item->iIndent = cit->iIndent;
344 if (item->mask & CBEIF_LPARAM)
345 item->lParam = cit->lParam;
348 COMBOEX_DumpItem (item);
350 SendMessageA (infoPtr->hwndCombo, CB_INSERTSTRING,
351 (WPARAM)cit->iItem, (LPARAM)item);
359 COMBOEX_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
361 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
364 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
366 dwTemp = infoPtr->dwExtStyle;
369 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
372 infoPtr->dwExtStyle = (DWORD)lParam;
374 /* FIXME: repaint?? */
376 return (LRESULT)dwTemp;
380 inline static LRESULT
381 COMBOEX_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
383 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
386 TRACE("(0x%08x 0x%08lx)\n", wParam, lParam);
388 himlTemp = infoPtr->himl;
389 infoPtr->himl = (HIMAGELIST)lParam;
391 COMBOEX_ReSize (hwnd, infoPtr);
392 InvalidateRect (hwnd, NULL, TRUE);
394 return (LRESULT)himlTemp;
398 COMBOEX_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
400 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
401 COMBOBOXEXITEMW *cit = (COMBOBOXEXITEMW *) lParam;
406 /* get real index of item to insert */
409 FIXME("NYI setting data for item in edit control\n");
413 /* if item number requested does not exist then return failure */
414 if ((index > infoPtr->nb_items) || (index < 0)) return 0;
416 /* find the item in the list */
417 item = infoPtr->items;
418 i = infoPtr->nb_items - 1;
419 while (item && (i > index)) {
420 item = (CBE_ITEMDATA *)item->next;
423 if (!item || (i != index)) {
424 FIXME("COMBOBOXEX item structures broken. Please report!\n");
428 /* add/change stuff to the internal item structure */
429 item->mask |= cit->mask;
430 if (cit->mask & CBEIF_TEXT) {
433 WCHAR emptystr[1] = {0};
436 if (!str) str=emptystr;
439 item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
440 strcpyW(item->pszText,str);
442 item->cchTextMax = cit->cchTextMax;
444 if (cit->mask & CBEIF_IMAGE)
445 item->iImage = cit->iImage;
446 if (cit->mask & CBEIF_SELECTEDIMAGE)
447 item->iSelectedImage = cit->iSelectedImage;
448 if (cit->mask & CBEIF_OVERLAY)
449 item->iOverlay = cit->iOverlay;
450 if (cit->mask & CBEIF_INDENT)
451 item->iIndent = cit->iIndent;
452 if (cit->mask & CBEIF_LPARAM)
453 cit->lParam = cit->lParam;
455 COMBOEX_DumpItem (item);
461 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
463 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
464 COMBOBOXEXITEMW citW;
467 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
468 if (cit->mask & CBEIF_TEXT) {
474 len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
476 citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
477 MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
480 ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
482 if (cit->mask & CBEIF_TEXT)
483 COMCTL32_Free(citW.pszText);
488 /* << COMBOEX_SetUniCodeFormat >> */
491 /* *** CB_xxx message support *** */
495 COMBOEX_SetItemHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
497 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
498 RECT cb_wrect, cbx_wrect, cbx_crect;
502 /* First, lets forward the message to the normal combo control
503 just like Windows. */
504 if (infoPtr->hwndCombo)
505 SendMessageA (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
508 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
509 GetWindowRect (hwnd, &cbx_wrect);
510 GetClientRect (hwnd, &cbx_crect);
511 /* the height of comboex as height of the combo + comboex border */
512 height = cb_wrect.bottom-cb_wrect.top
513 + cbx_wrect.bottom-cbx_wrect.top
514 - (cbx_crect.bottom-cbx_crect.top);
515 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
516 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
517 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
518 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
519 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
520 cbx_wrect.right-cbx_wrect.left, height);
521 SetWindowPos (hwnd, HWND_TOP, 0, 0,
522 cbx_wrect.right-cbx_wrect.left,
524 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
525 /* *** end new *** */
531 /* *** WM_xxx message support *** */
535 COMBOEX_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
537 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
538 COMBOEX_INFO *infoPtr;
542 /* allocate memory for info structure */
543 infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
544 if (infoPtr == NULL) {
545 ERR("could not allocate info memory!\n");
548 infoPtr->items = NULL;
549 infoPtr->nb_items = 0;
551 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
554 /* initialize info structure */
557 /* create combo box */
558 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
559 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
561 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
562 /* following line added to match native */
563 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | CBS_NOINTEGRALHEIGHT |
564 /* was base and is necessary */
565 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
566 cs->y, cs->x, cs->cx, cs->cy, hwnd, (HMENU)0,
567 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
570 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), &mylogfont, 0);
571 infoPtr->font = CreateFontIndirectA (&mylogfont);
572 SendMessageA (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
573 COMBOEX_ReSize (hwnd, infoPtr);
574 /* *** end new *** */
580 inline static LRESULT
581 COMBOEX_DrawItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
583 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
584 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
591 UINT xioff = 0; /* size and spacer of image if any */
595 if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
598 /* "itemID - Specifies the menu item identifier for a menu */
599 /* item or the index of the item in a list box or combo box. */
600 /* For an empty list box or combo box, this member can be -1. */
601 /* This allows the application to draw only the focus */
602 /* rectangle at the coordinates specified by the rcItem */
603 /* member even though there are no items in the control. */
604 /* This indicates to the user whether the list box or combo */
605 /* box has the focus. How the bits are set in the itemAction */
606 /* member determines whether the rectangle is to be drawn as */
607 /* though the list box or combo box has the focus. */
608 if (dis->itemID == 0xffffffff) {
609 if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
610 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
611 TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
612 dis->rcItem.left, dis->rcItem.top,
613 dis->rcItem.right, dis->rcItem.bottom);
614 DrawFocusRect(dis->hDC, &dis->rcItem);
618 TRACE("NOT drawing item -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
619 dis->rcItem.left, dis->rcItem.top,
620 dis->rcItem.right, dis->rcItem.bottom,
621 dis->itemAction, dis->itemState);
626 item = (CBE_ITEMDATA *)SendMessageA (infoPtr->hwndCombo, CB_GETITEMDATA,
627 (WPARAM)dis->itemID, 0);
628 if (item == (CBE_ITEMDATA *)CB_ERR)
630 FIXME("invalid item for id %d \n",dis->itemID);
633 if (!TRACE_ON(message)) {
634 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
635 dis->CtlType, dis->CtlID);
636 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
637 dis->itemID, dis->itemAction, dis->itemState);
638 TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
639 dis->hwndItem, dis->hDC, dis->rcItem.left,
640 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
643 COMBOEX_DumpItem (item);
645 xbase = CBE_STARTOFFSET;
646 if (item->mask & CBEIF_INDENT)
647 xbase += (item->iIndent * CBE_INDENT);
648 if (item->mask & CBEIF_IMAGE) {
649 ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
650 xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
653 switch (dis->itemAction) {
655 if (dis->itemState & ODS_SELECTED /*1*/) {
656 if ((item->mask & CBEIF_TEXT) && item->pszText) {
657 len = strlenW (item->pszText);
658 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
659 rect.left = xbase + xioff - 1;
660 rect.top = dis->rcItem.top - 1 +
661 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
662 rect.right = rect.left + txtsize.cx + 2;
663 rect.bottom = rect.top + txtsize.cy + 2;
664 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
665 dis->itemID, rect.left, rect.top,
666 rect.right, rect.bottom);
667 DrawFocusRect(dis->hDC, &rect);
674 if (item->mask & CBEIF_IMAGE) drawimage = item->iImage;
675 if ((dis->itemState & ODS_SELECTED) &&
676 (item->mask & CBEIF_SELECTEDIMAGE))
677 drawimage = item->iSelectedImage;
678 if (drawimage != -1) {
679 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
680 xbase, dis->rcItem.top,
681 (dis->itemState & ODS_SELECTED) ?
682 ILD_SELECTED : ILD_NORMAL);
684 if ((item->mask & CBEIF_TEXT) && item->pszText) {
685 len = strlenW (item->pszText);
686 GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
687 nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
688 COLOR_HIGHLIGHT : COLOR_WINDOW);
689 SetBkColor (dis->hDC, nbkc);
690 ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
691 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
692 SetTextColor (dis->hDC, ntxc);
694 y = dis->rcItem.top +
695 (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
697 rect.right = x + txtsize.cx;
699 rect.bottom = y + txtsize.cy;
700 TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
701 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
702 ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
703 &rect, item->pszText, len, 0);
704 if (dis->itemState & ODS_FOCUS) {
709 TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
710 dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
711 DrawFocusRect (dis->hDC, &rect);
716 FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
717 hwnd, wParam, lParam, dis->itemAction);
725 COMBOEX_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
727 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
729 if (infoPtr->hwndCombo)
730 DestroyWindow (infoPtr->hwndCombo);
732 if (infoPtr->items) {
733 CBE_ITEMDATA *this, *next;
735 this = infoPtr->items;
737 next = (CBE_ITEMDATA *)this->next;
738 if ((this->mask & CBEIF_TEXT) && this->pszText)
739 COMCTL32_Free (this->pszText);
740 COMCTL32_Free (this);
745 DeleteObject (infoPtr->font);
747 /* free comboex info data */
748 COMCTL32_Free (infoPtr);
749 SetWindowLongA (hwnd, 0, 0);
755 COMBOEX_MeasureItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
757 /*COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);*/
758 MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
763 GetTextExtentPointA (hdc, "W", 1, &mysize);
765 mis->itemHeight = mysize.cy + CBE_EXTRA;
767 TRACE("adjusted height hwnd=%08x, height=%d\n",
768 hwnd, mis->itemHeight);
775 COMBOEX_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
777 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
780 GetClientRect (hwnd, &rect);
782 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
783 rect.bottom - rect.top, TRUE);
790 COMBOEX_WindowPosChanging (HWND hwnd, WPARAM wParam, LPARAM lParam)
792 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
794 RECT cbx_wrect, cbx_crect, cb_wrect;
796 WINDOWPOS *wp = (WINDOWPOS *)lParam;
798 ret = DefWindowProcA (hwnd, WM_WINDOWPOSCHANGING, wParam, lParam);
799 GetWindowRect (hwnd, &cbx_wrect);
800 GetClientRect (hwnd, &cbx_crect);
801 GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
803 /* width is winpos value + border width of comboex */
805 + cbx_wrect.right-cbx_wrect.left
806 - (cbx_crect.right - cbx_crect.left);
808 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
809 cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
810 cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
811 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
812 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
813 width, cb_wrect.bottom-cb_wrect.top);
815 SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
817 cb_wrect.bottom-cb_wrect.top,
824 static LRESULT WINAPI
825 COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
827 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
828 if (!COMBOEX_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
829 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
833 /* case CBEM_DELETEITEM: */
835 case CBEM_GETCOMBOCONTROL:
836 return COMBOEX_GetComboControl (hwnd, wParam, lParam);
838 case CBEM_GETEDITCONTROL:
839 return COMBOEX_GetEditControl (hwnd, wParam, lParam);
841 case CBEM_GETEXTENDEDSTYLE:
842 return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
844 case CBEM_GETIMAGELIST:
845 return COMBOEX_GetImageList (hwnd, wParam, lParam);
847 /* case CBEM_GETITEMA:
849 case CBEM_GETUNICODEFORMAT:
850 case CBEM_HASEDITCHANGED:
853 case CBEM_INSERTITEMA:
854 return COMBOEX_InsertItemA (hwnd, wParam, lParam);
856 case CBEM_INSERTITEMW:
857 return COMBOEX_InsertItemW (hwnd, wParam, lParam);
859 case CBEM_SETEXSTYLE: /* FIXME: obsoleted, should be the same as: */
860 case CBEM_SETEXTENDEDSTYLE:
861 return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
863 case CBEM_SETIMAGELIST:
864 return COMBOEX_SetImageList (hwnd, wParam, lParam);
867 return COMBOEX_SetItemA (hwnd, wParam, lParam);
870 return COMBOEX_SetItemW (hwnd, wParam, lParam);
872 /* case CBEM_SETUNICODEFORMAT:
875 case CB_DELETESTRING:
876 case CB_FINDSTRINGEXACT:
879 case CB_GETDROPPEDCONTROLRECT:
880 case CB_GETDROPPEDSTATE:
882 case CB_GETITEMHEIGHT:
884 case CB_GETLBTEXTLEN:
885 case CB_GETEXTENDEDUI:
887 case CB_RESETCONTENT:
888 case CB_SELECTSTRING:
890 case CB_SETDROPPEDWIDTH:
891 case CB_SETEXTENDEDUI:
893 case CB_SHOWDROPDOWN:
896 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
898 case CB_SETITEMHEIGHT:
899 return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
902 /* Messages passed to parent */
905 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
909 return COMBOEX_Create (hwnd, wParam, lParam);
912 return COMBOEX_DrawItem (hwnd, wParam, lParam);
915 return COMBOEX_Destroy (hwnd, wParam, lParam);
918 return COMBOEX_MeasureItem (hwnd, wParam, lParam);
921 return COMBOEX_Size (hwnd, wParam, lParam);
923 case WM_WINDOWPOSCHANGING:
924 return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
928 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
929 uMsg, wParam, lParam);
930 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
937 COMBOEX_Register (void)
941 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
942 wndClass.style = CS_GLOBALCLASS;
943 wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc;
944 wndClass.cbClsExtra = 0;
945 wndClass.cbWndExtra = sizeof(COMBOEX_INFO *);
946 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
947 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
948 wndClass.lpszClassName = WC_COMBOBOXEXA;
950 RegisterClassA (&wndClass);
955 COMBOEX_Unregister (void)
957 UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);