| 1 | /* | 
|---|
| 2 | * ComboBoxEx control | 
|---|
| 3 | * | 
|---|
| 4 | * Copyright 1998, 1999 Eric Kohl | 
|---|
| 5 | * Copyright 2000, 2001, 2002 Guy Albertelli <galberte@neo.lrun.com> | 
|---|
| 6 | * Copyright 2002 Dimitrie O. Paun | 
|---|
| 7 | * | 
|---|
| 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. | 
|---|
| 12 | * | 
|---|
| 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. | 
|---|
| 17 | * | 
|---|
| 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 | 
|---|
| 21 | * | 
|---|
| 22 | * NOTE | 
|---|
| 23 | * | 
|---|
| 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. | 
|---|
| 26 | * | 
|---|
| 27 | * Unless otherwise noted, we belive this code to be complete, as per | 
|---|
| 28 | * the specification mentioned above. | 
|---|
| 29 | * If you discover missing features, or bugs, please note them below. | 
|---|
| 30 | * | 
|---|
| 31 | */ | 
|---|
| 32 |  | 
|---|
| 33 | #include <string.h> | 
|---|
| 34 | #include "winbase.h" | 
|---|
| 35 | #include "commctrl.h" | 
|---|
| 36 | #include "wine/debug.h" | 
|---|
| 37 | #include "wine/unicode.h" | 
|---|
| 38 |  | 
|---|
| 39 | WINE_DEFAULT_DEBUG_CHANNEL(comboex); | 
|---|
| 40 |  | 
|---|
| 41 | /* Item structure */ | 
|---|
| 42 | typedef struct | 
|---|
| 43 | { | 
|---|
| 44 | VOID         *next; | 
|---|
| 45 | UINT         mask; | 
|---|
| 46 | LPWSTR       pszText; | 
|---|
| 47 | LPWSTR       pszTemp; | 
|---|
| 48 | int          cchTextMax; | 
|---|
| 49 | int          iImage; | 
|---|
| 50 | int          iSelectedImage; | 
|---|
| 51 | int          iOverlay; | 
|---|
| 52 | int          iIndent; | 
|---|
| 53 | LPARAM       lParam; | 
|---|
| 54 | } CBE_ITEMDATA; | 
|---|
| 55 |  | 
|---|
| 56 | /* ComboBoxEx structure */ | 
|---|
| 57 | typedef struct | 
|---|
| 58 | { | 
|---|
| 59 | HIMAGELIST   himl; | 
|---|
| 60 | HWND         hwndSelf;         /* my own hwnd */ | 
|---|
| 61 | HWND         hwndCombo; | 
|---|
| 62 | HWND         hwndEdit; | 
|---|
| 63 | WNDPROC      prevEditWndProc;  /* previous Edit WNDPROC value */ | 
|---|
| 64 | WNDPROC      prevComboWndProc; /* previous Combo WNDPROC value */ | 
|---|
| 65 | DWORD        dwExtStyle; | 
|---|
| 66 | INT          selected;         /* index of selected item */ | 
|---|
| 67 | DWORD        flags;            /* WINE internal flags */ | 
|---|
| 68 | HFONT        defaultFont; | 
|---|
| 69 | HFONT        font; | 
|---|
| 70 | INT          nb_items;         /* Number of items */ | 
|---|
| 71 | BOOL         unicode;          /* TRUE if this window is Unicode   */ | 
|---|
| 72 | BOOL         NtfUnicode;       /* TRUE if parent wants notify in Unicode */ | 
|---|
| 73 | CBE_ITEMDATA *edit;            /* item data for edit item */ | 
|---|
| 74 | CBE_ITEMDATA *items;           /* Array of items */ | 
|---|
| 75 | } COMBOEX_INFO; | 
|---|
| 76 |  | 
|---|
| 77 | /* internal flags in the COMBOEX_INFO structure */ | 
|---|
| 78 | #define  WCBE_ACTEDIT           0x00000001  /* Edit active i.e. | 
|---|
| 79 | * CBEN_BEGINEDIT issued | 
|---|
| 80 | * but CBEN_ENDEDIT{A|W} | 
|---|
| 81 | * not yet issued. */ | 
|---|
| 82 | #define  WCBE_EDITCHG           0x00000002  /* Edit issued EN_CHANGE */ | 
|---|
| 83 | #define  WCBE_EDITHASCHANGED    (WCBE_ACTEDIT | WCBE_EDITCHG) | 
|---|
| 84 | #define  WCBE_EDITFOCUSED       0x00000004  /* Edit control has focus */ | 
|---|
| 85 | #define  WCBE_MOUSECAPTURED     0x00000008  /* Combo has captured mouse */ | 
|---|
| 86 | #define  WCBE_MOUSEDRAGGED      0x00000010  /* User has dragged in combo */ | 
|---|
| 87 |  | 
|---|
| 88 | #define ID_CB_EDIT              1001 | 
|---|
| 89 |  | 
|---|
| 90 |  | 
|---|
| 91 | /* | 
|---|
| 92 | * Special flag set in DRAWITEMSTRUCT itemState field. It is set by | 
|---|
| 93 | * the ComboEx version of the Combo Window Proc so that when the | 
|---|
| 94 | * WM_DRAWITEM message is then passed to ComboEx, we know that this | 
|---|
| 95 | * particular WM_DRAWITEM message is for listbox only items. Any messasges | 
|---|
| 96 | * without this flag is then for the Edit control field. | 
|---|
| 97 | * | 
|---|
| 98 | * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that | 
|---|
| 99 | * only version 4.0 applications will have ODS_COMBOBOXEDIT set. | 
|---|
| 100 | */ | 
|---|
| 101 | #define ODS_COMBOEXLBOX         0x4000 | 
|---|
| 102 |  | 
|---|
| 103 |  | 
|---|
| 104 |  | 
|---|
| 105 | /* Height in pixels of control over the amount of the selected font */ | 
|---|
| 106 | #define CBE_EXTRA               3 | 
|---|
| 107 |  | 
|---|
| 108 | /* Indent amount per MS documentation */ | 
|---|
| 109 | #define CBE_INDENT              10 | 
|---|
| 110 |  | 
|---|
| 111 | /* Offset in pixels from left side for start of image or text */ | 
|---|
| 112 | #define CBE_STARTOFFSET         6 | 
|---|
| 113 |  | 
|---|
| 114 | /* Offset between image and text */ | 
|---|
| 115 | #define CBE_SEP                 4 | 
|---|
| 116 |  | 
|---|
| 117 | #define COMBOEX_SUBCLASS_PROP   "CCComboEx32SubclassInfo" | 
|---|
| 118 | #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongW (hwnd, 0)) | 
|---|
| 119 |  | 
|---|
| 120 |  | 
|---|
| 121 | /* Things common to the entire DLL */ | 
|---|
| 122 | static LRESULT WINAPI | 
|---|
| 123 | COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); | 
|---|
| 124 | static LRESULT WINAPI | 
|---|
| 125 | COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); | 
|---|
| 126 | static int CALLBACK | 
|---|
| 127 | COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code); | 
|---|
| 128 | static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr); | 
|---|
| 129 |  | 
|---|
| 130 | #ifdef __WIN32OS2__ | 
|---|
| 131 | #undef inline | 
|---|
| 132 | #define inline | 
|---|
| 133 |  | 
|---|
| 134 | typedef INT (* WINAPI cmp_func_t)(LPCWSTR, LPCWSTR); | 
|---|
| 135 | #else | 
|---|
| 136 | typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR); | 
|---|
| 137 | #endif | 
|---|
| 138 |  | 
|---|
| 139 | inline static BOOL is_textW(LPCWSTR str) | 
|---|
| 140 | { | 
|---|
| 141 | return str && str != LPSTR_TEXTCALLBACKW; | 
|---|
| 142 | } | 
|---|
| 143 |  | 
|---|
| 144 | inline static BOOL is_textA(LPCSTR str) | 
|---|
| 145 | { | 
|---|
| 146 | return str && str != LPSTR_TEXTCALLBACKA; | 
|---|
| 147 | } | 
|---|
| 148 |  | 
|---|
| 149 | inline static LPCSTR debugstr_txt(LPCWSTR str) | 
|---|
| 150 | { | 
|---|
| 151 | if (str == LPSTR_TEXTCALLBACKW) return "(callback)"; | 
|---|
| 152 | return debugstr_w(str); | 
|---|
| 153 | } | 
|---|
| 154 |  | 
|---|
| 155 | static void COMBOEX_DumpItem (CBE_ITEMDATA *item) | 
|---|
| 156 | { | 
|---|
| 157 | TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n", | 
|---|
| 158 | item, item->mask, item->pszText, item->cchTextMax, item->iImage); | 
|---|
| 159 | TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", | 
|---|
| 160 | item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam); | 
|---|
| 161 | if (item->mask & CBEIF_TEXT) | 
|---|
| 162 | TRACE("item %p - pszText=%s\n", item, debugstr_txt(item->pszText)); | 
|---|
| 163 | } | 
|---|
| 164 |  | 
|---|
| 165 |  | 
|---|
| 166 | static void COMBOEX_DumpInput (COMBOBOXEXITEMW *input) | 
|---|
| 167 | { | 
|---|
| 168 | TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n", | 
|---|
| 169 | input->mask, input->iItem, input->pszText, input->cchTextMax, | 
|---|
| 170 | input->iImage); | 
|---|
| 171 | if (input->mask & CBEIF_TEXT) | 
|---|
| 172 | TRACE("input - pszText=<%s>\n", debugstr_txt(input->pszText)); | 
|---|
| 173 | TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", | 
|---|
| 174 | input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam); | 
|---|
| 175 | } | 
|---|
| 176 |  | 
|---|
| 177 |  | 
|---|
| 178 | inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index) | 
|---|
| 179 | { | 
|---|
| 180 | return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA, | 
|---|
| 181 | (WPARAM)index, 0); | 
|---|
| 182 | } | 
|---|
| 183 |  | 
|---|
| 184 | inline static cmp_func_t get_cmp_func(COMBOEX_INFO *infoPtr) | 
|---|
| 185 | { | 
|---|
| 186 | return infoPtr->dwExtStyle & CBES_EX_CASESENSITIVE ? lstrcmpW : lstrcmpiW; | 
|---|
| 187 | } | 
|---|
| 188 |  | 
|---|
| 189 | static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr) | 
|---|
| 190 | { | 
|---|
| 191 | hdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf); | 
|---|
| 192 | hdr->hwndFrom = infoPtr->hwndSelf; | 
|---|
| 193 | hdr->code = code; | 
|---|
| 194 | if (infoPtr->NtfUnicode) | 
|---|
| 195 | return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, | 
|---|
| 196 | (LPARAM)hdr); | 
|---|
| 197 | else | 
|---|
| 198 | return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, | 
|---|
| 199 | (LPARAM)hdr); | 
|---|
| 200 | } | 
|---|
| 201 |  | 
|---|
| 202 |  | 
|---|
| 203 | static INT | 
|---|
| 204 | COMBOEX_NotifyItem (COMBOEX_INFO *infoPtr, INT code, NMCOMBOBOXEXW *hdr) | 
|---|
| 205 | { | 
|---|
| 206 | /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ | 
|---|
| 207 | if (infoPtr->NtfUnicode) | 
|---|
| 208 | return COMBOEX_Notify (infoPtr, code, &hdr->hdr); | 
|---|
| 209 | else { | 
|---|
| 210 | LPWSTR wstr = hdr->ceItem.pszText; | 
|---|
| 211 | LPSTR astr = 0; | 
|---|
| 212 | INT ret, len = 0; | 
|---|
| 213 |  | 
|---|
| 214 | if ((hdr->ceItem.mask & CBEIF_TEXT) && is_textW(wstr)) { | 
|---|
| 215 | len = WideCharToMultiByte (CP_ACP, 0, wstr, -1, 0, 0, NULL, NULL); | 
|---|
| 216 | if (len > 0) { | 
|---|
| 217 | astr = (LPSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR)); | 
|---|
| 218 | if (!astr) return 0; | 
|---|
| 219 | WideCharToMultiByte (CP_ACP, 0, wstr, -1, astr, len, 0, 0); | 
|---|
| 220 | hdr->ceItem.pszText = (LPWSTR)astr; | 
|---|
| 221 | } | 
|---|
| 222 | } | 
|---|
| 223 |  | 
|---|
| 224 | if (code == CBEN_ENDEDITW) code = CBEN_ENDEDITA; | 
|---|
| 225 | else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA; | 
|---|
| 226 | else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA; | 
|---|
| 227 |  | 
|---|
| 228 | ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr); | 
|---|
| 229 |  | 
|---|
| 230 | if (astr && hdr->ceItem.pszText == (LPWSTR)astr) | 
|---|
| 231 | hdr->ceItem.pszText = wstr; | 
|---|
| 232 |  | 
|---|
| 233 | if (astr) COMCTL32_Free(astr); | 
|---|
| 234 |  | 
|---|
| 235 | return ret; | 
|---|
| 236 | } | 
|---|
| 237 | } | 
|---|
| 238 |  | 
|---|
| 239 |  | 
|---|
| 240 | static INT COMBOEX_NotifyEndEdit (COMBOEX_INFO *infoPtr, NMCBEENDEDITW *neew, LPCWSTR wstr) | 
|---|
| 241 | { | 
|---|
| 242 | /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ | 
|---|
| 243 | if (infoPtr->NtfUnicode) { | 
|---|
| 244 | lstrcpynW(neew->szText, wstr, CBEMAXSTRLEN); | 
|---|
| 245 | return COMBOEX_Notify (infoPtr, CBEN_ENDEDITW, &neew->hdr); | 
|---|
| 246 | } else { | 
|---|
| 247 | NMCBEENDEDITA neea; | 
|---|
| 248 |  | 
|---|
| 249 | memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR)); | 
|---|
| 250 | neea.fChanged = neew->fChanged; | 
|---|
| 251 | neea.iNewSelection = neew->iNewSelection; | 
|---|
| 252 | WideCharToMultiByte (CP_ACP, 0, wstr, -1, neea.szText, CBEMAXSTRLEN, 0, 0); | 
|---|
| 253 | neea.iWhy = neew->iWhy; | 
|---|
| 254 |  | 
|---|
| 255 | return COMBOEX_Notify (infoPtr, CBEN_ENDEDITA, &neea.hdr); | 
|---|
| 256 | } | 
|---|
| 257 | } | 
|---|
| 258 |  | 
|---|
| 259 |  | 
|---|
| 260 | static void COMBOEX_NotifyDragBegin(COMBOEX_INFO *infoPtr, LPCWSTR wstr) | 
|---|
| 261 | { | 
|---|
| 262 | /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */ | 
|---|
| 263 | if (infoPtr->NtfUnicode) { | 
|---|
| 264 | NMCBEDRAGBEGINW ndbw; | 
|---|
| 265 |  | 
|---|
| 266 | ndbw.iItemid = -1; | 
|---|
| 267 | lstrcpynW(ndbw.szText, wstr, CBEMAXSTRLEN); | 
|---|
| 268 | COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINW, &ndbw.hdr); | 
|---|
| 269 | } else { | 
|---|
| 270 | NMCBEDRAGBEGINA ndba; | 
|---|
| 271 |  | 
|---|
| 272 | ndba.iItemid = -1; | 
|---|
| 273 | WideCharToMultiByte (CP_ACP, 0, wstr, -1, ndba.szText, CBEMAXSTRLEN, 0, 0); | 
|---|
| 274 |  | 
|---|
| 275 | COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINA, &ndba.hdr); | 
|---|
| 276 | } | 
|---|
| 277 | } | 
|---|
| 278 |  | 
|---|
| 279 |  | 
|---|
| 280 | static void COMBOEX_FreeText (CBE_ITEMDATA *item) | 
|---|
| 281 | { | 
|---|
| 282 | if (is_textW(item->pszText)) COMCTL32_Free(item->pszText); | 
|---|
| 283 | item->pszText = 0; | 
|---|
| 284 | if (item->pszTemp) COMCTL32_Free(item->pszTemp); | 
|---|
| 285 | item->pszTemp = 0; | 
|---|
| 286 | } | 
|---|
| 287 |  | 
|---|
| 288 |  | 
|---|
| 289 | static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) | 
|---|
| 290 | { | 
|---|
| 291 | NMCOMBOBOXEXW nmce; | 
|---|
| 292 | LPWSTR text, buf; | 
|---|
| 293 | INT len; | 
|---|
| 294 |  | 
|---|
| 295 | if (item->pszText != LPSTR_TEXTCALLBACKW) | 
|---|
| 296 | return item->pszText; | 
|---|
| 297 |  | 
|---|
| 298 | ZeroMemory(&nmce, sizeof(nmce)); | 
|---|
| 299 | nmce.ceItem.mask = CBEIF_TEXT; | 
|---|
| 300 | nmce.ceItem.lParam = item->lParam; | 
|---|
| 301 | COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); | 
|---|
| 302 |  | 
|---|
| 303 | if (is_textW(nmce.ceItem.pszText)) { | 
|---|
| 304 | len = MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, NULL, 0); | 
|---|
| 305 | buf = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); | 
|---|
| 306 | if (buf) | 
|---|
| 307 | MultiByteToWideChar (CP_ACP, 0, (LPSTR)nmce.ceItem.pszText, -1, buf, len); | 
|---|
| 308 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) { | 
|---|
| 309 | COMBOEX_FreeText(item); | 
|---|
| 310 | item->pszText = buf; | 
|---|
| 311 | } else { | 
|---|
| 312 | if (item->pszTemp) COMCTL32_Free(item->pszTemp); | 
|---|
| 313 | item->pszTemp = buf; | 
|---|
| 314 | } | 
|---|
| 315 | text = buf; | 
|---|
| 316 | } else | 
|---|
| 317 | text = nmce.ceItem.pszText; | 
|---|
| 318 |  | 
|---|
| 319 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) | 
|---|
| 320 | item->pszText = text; | 
|---|
| 321 | return text; | 
|---|
| 322 | } | 
|---|
| 323 |  | 
|---|
| 324 |  | 
|---|
| 325 | static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size) | 
|---|
| 326 | { | 
|---|
| 327 | HFONT nfont, ofont; | 
|---|
| 328 | HDC mydc; | 
|---|
| 329 |  | 
|---|
| 330 | mydc = GetDC (0); /* why the entire screen???? */ | 
|---|
| 331 | nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); | 
|---|
| 332 | ofont = (HFONT) SelectObject (mydc, nfont); | 
|---|
| 333 | GetTextExtentPointA (mydc, "A", 1, size); | 
|---|
| 334 | SelectObject (mydc, ofont); | 
|---|
| 335 | ReleaseDC (0, mydc); | 
|---|
| 336 | TRACE("selected font hwnd=%p, height=%ld\n", nfont, size->cy); | 
|---|
| 337 | } | 
|---|
| 338 |  | 
|---|
| 339 |  | 
|---|
| 340 | static void COMBOEX_CopyItem (CBE_ITEMDATA *item, COMBOBOXEXITEMW *cit) | 
|---|
| 341 | { | 
|---|
| 342 | if (cit->mask & CBEIF_TEXT) { | 
|---|
| 343 | /* | 
|---|
| 344 | * when given a text buffer actually use that buffer | 
|---|
| 345 | */ | 
|---|
| 346 | if (cit->pszText) { | 
|---|
| 347 | if (is_textW(item->pszText)) | 
|---|
| 348 | lstrcpynW(cit->pszText, item->pszText, cit->cchTextMax); | 
|---|
| 349 | else | 
|---|
| 350 | cit->pszText[0] = 0; | 
|---|
| 351 | } else { | 
|---|
| 352 | cit->pszText        = item->pszText; | 
|---|
| 353 | cit->cchTextMax     = item->cchTextMax; | 
|---|
| 354 | } | 
|---|
| 355 | } | 
|---|
| 356 | if (cit->mask & CBEIF_IMAGE) | 
|---|
| 357 | cit->iImage         = item->iImage; | 
|---|
| 358 | if (cit->mask & CBEIF_SELECTEDIMAGE) | 
|---|
| 359 | cit->iSelectedImage = item->iSelectedImage; | 
|---|
| 360 | if (cit->mask & CBEIF_OVERLAY) | 
|---|
| 361 | cit->iOverlay       = item->iOverlay; | 
|---|
| 362 | if (cit->mask & CBEIF_INDENT) | 
|---|
| 363 | cit->iIndent        = item->iIndent; | 
|---|
| 364 | if (cit->mask & CBEIF_LPARAM) | 
|---|
| 365 | cit->lParam         = item->lParam; | 
|---|
| 366 | } | 
|---|
| 367 |  | 
|---|
| 368 |  | 
|---|
| 369 | static void COMBOEX_AdjustEditPos (COMBOEX_INFO *infoPtr) | 
|---|
| 370 | { | 
|---|
| 371 | SIZE mysize; | 
|---|
| 372 | INT x, y, w, h, xioff; | 
|---|
| 373 | RECT rect; | 
|---|
| 374 |  | 
|---|
| 375 | if (!infoPtr->hwndEdit) return; | 
|---|
| 376 |  | 
|---|
| 377 | if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) { | 
|---|
| 378 | IMAGEINFO iinfo; | 
|---|
| 379 | iinfo.rcImage.left = iinfo.rcImage.right = 0; | 
|---|
| 380 | ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); | 
|---|
| 381 | xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; | 
|---|
| 382 | }  else xioff = 0; | 
|---|
| 383 |  | 
|---|
| 384 | GetClientRect (infoPtr->hwndCombo, &rect); | 
|---|
| 385 | InflateRect (&rect, -2, -2); | 
|---|
| 386 | InvalidateRect (infoPtr->hwndCombo, &rect, TRUE); | 
|---|
| 387 |  | 
|---|
| 388 | /* reposition the Edit control based on whether icon exists */ | 
|---|
| 389 | COMBOEX_GetComboFontSize (infoPtr, &mysize); | 
|---|
| 390 | TRACE("Combo font x=%ld, y=%ld\n", mysize.cx, mysize.cy); | 
|---|
| 391 | x = xioff + CBE_STARTOFFSET + 1; | 
|---|
| 392 | w = rect.right-rect.left - x - GetSystemMetrics(SM_CXVSCROLL) - 1; | 
|---|
| 393 | h = mysize.cy + 1; | 
|---|
| 394 | y = rect.bottom - h - 1; | 
|---|
| 395 |  | 
|---|
| 396 | TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n", | 
|---|
| 397 | rect.left, rect.top, rect.right, rect.bottom, x, y, x + w, y + h); | 
|---|
| 398 | SetWindowPos(infoPtr->hwndEdit, HWND_TOP, x, y, w, h, | 
|---|
| 399 | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); | 
|---|
| 400 | } | 
|---|
| 401 |  | 
|---|
| 402 |  | 
|---|
| 403 | static void COMBOEX_ReSize (COMBOEX_INFO *infoPtr) | 
|---|
| 404 | { | 
|---|
| 405 | SIZE mysize; | 
|---|
| 406 | UINT cy; | 
|---|
| 407 | IMAGEINFO iinfo; | 
|---|
| 408 |  | 
|---|
| 409 | COMBOEX_GetComboFontSize (infoPtr, &mysize); | 
|---|
| 410 | cy = mysize.cy + CBE_EXTRA; | 
|---|
| 411 | if (infoPtr->himl) { | 
|---|
| 412 | ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); | 
|---|
| 413 | cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy); | 
|---|
| 414 | TRACE("upgraded height due to image:  height=%d\n", cy); | 
|---|
| 415 | } | 
|---|
| 416 | SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy); | 
|---|
| 417 | if (infoPtr->hwndCombo) { | 
|---|
| 418 | SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, | 
|---|
| 419 | (WPARAM) 0, (LPARAM) cy); | 
|---|
| 420 | if ( !(infoPtr->flags & CBES_EX_NOSIZELIMIT)) { | 
|---|
| 421 | RECT comboRect; | 
|---|
| 422 | if (GetWindowRect(infoPtr->hwndCombo, &comboRect)) { | 
|---|
| 423 | RECT ourRect; | 
|---|
| 424 | if (GetWindowRect(infoPtr->hwndSelf, &ourRect)) { | 
|---|
| 425 | if (comboRect.bottom > ourRect.bottom) { | 
|---|
| 426 | POINT pt = { ourRect.left, ourRect.top }; | 
|---|
| 427 | if (ScreenToClient(infoPtr->hwndSelf, &pt)) | 
|---|
| 428 | MoveWindow( infoPtr->hwndSelf, pt.x, pt.y, ourRect.right - ourRect.left, | 
|---|
| 429 | comboRect.bottom - comboRect.top, FALSE); | 
|---|
| 430 | } | 
|---|
| 431 | } | 
|---|
| 432 | } | 
|---|
| 433 | } | 
|---|
| 434 | } | 
|---|
| 435 | } | 
|---|
| 436 |  | 
|---|
| 437 |  | 
|---|
| 438 | static void COMBOEX_SetEditText (COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) | 
|---|
| 439 | { | 
|---|
| 440 | if (!infoPtr->hwndEdit) return; | 
|---|
| 441 | /* native issues the following messages to the {Edit} control */ | 
|---|
| 442 | /*      WM_SETTEXT (0,addr)     */ | 
|---|
| 443 | /*      EM_SETSEL32 (0,0)       */ | 
|---|
| 444 | /*      EM_SETSEL32 (0,-1)      */ | 
|---|
| 445 | if (item->mask & CBEIF_TEXT) { | 
|---|
| 446 | SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)COMBOEX_GetText(infoPtr, item)); | 
|---|
| 447 | SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0); | 
|---|
| 448 | SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1); | 
|---|
| 449 | } | 
|---|
| 450 | } | 
|---|
| 451 |  | 
|---|
| 452 |  | 
|---|
| 453 | static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index) | 
|---|
| 454 | { | 
|---|
| 455 | CBE_ITEMDATA *item; | 
|---|
| 456 | INT i; | 
|---|
| 457 |  | 
|---|
| 458 | if ((index > infoPtr->nb_items) || (index < -1)) | 
|---|
| 459 | return 0; | 
|---|
| 460 | if (index == -1) | 
|---|
| 461 | return infoPtr->edit; | 
|---|
| 462 | item = infoPtr->items; | 
|---|
| 463 | i = infoPtr->nb_items - 1; | 
|---|
| 464 |  | 
|---|
| 465 | /* find the item in the list */ | 
|---|
| 466 | while (item && (i > index)) { | 
|---|
| 467 | item = (CBE_ITEMDATA *)item->next; | 
|---|
| 468 | i--; | 
|---|
| 469 | } | 
|---|
| 470 | if (!item || (i != index)) { | 
|---|
| 471 | ERR("COMBOBOXEX item structures broken. Please report!\n"); | 
|---|
| 472 | return 0; | 
|---|
| 473 | } | 
|---|
| 474 | return item; | 
|---|
| 475 | } | 
|---|
| 476 |  | 
|---|
| 477 |  | 
|---|
| 478 | static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr) | 
|---|
| 479 | { | 
|---|
| 480 | return infoPtr->hwndEdit ? TRUE : FALSE; | 
|---|
| 481 | } | 
|---|
| 482 |  | 
|---|
| 483 |  | 
|---|
| 484 | /* ***  CBEM_xxx message support  *** */ | 
|---|
| 485 |  | 
|---|
| 486 |  | 
|---|
| 487 | static INT COMBOEX_DeleteItem (COMBOEX_INFO *infoPtr, INT index) | 
|---|
| 488 | { | 
|---|
| 489 | CBE_ITEMDATA *item; | 
|---|
| 490 |  | 
|---|
| 491 | TRACE("(index=%d)\n", index); | 
|---|
| 492 |  | 
|---|
| 493 | /* if item number requested does not exist then return failure */ | 
|---|
| 494 | if ((index > infoPtr->nb_items) || (index < 0)) return CB_ERR; | 
|---|
| 495 | if (!(item = COMBOEX_FindItem(infoPtr, index))) return CB_ERR; | 
|---|
| 496 |  | 
|---|
| 497 | /* doing this will result in WM_DELETEITEM being issued */ | 
|---|
| 498 | SendMessageW (infoPtr->hwndCombo, CB_DELETESTRING, (WPARAM)index, 0); | 
|---|
| 499 |  | 
|---|
| 500 | return infoPtr->nb_items; | 
|---|
| 501 | } | 
|---|
| 502 |  | 
|---|
| 503 |  | 
|---|
| 504 | static BOOL COMBOEX_GetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) | 
|---|
| 505 | { | 
|---|
| 506 | INT index = cit->iItem; | 
|---|
| 507 | CBE_ITEMDATA *item; | 
|---|
| 508 |  | 
|---|
| 509 | TRACE("(...)\n"); | 
|---|
| 510 |  | 
|---|
| 511 | /* if item number requested does not exist then return failure */ | 
|---|
| 512 | if ((index > infoPtr->nb_items) || (index < -1)) return FALSE; | 
|---|
| 513 |  | 
|---|
| 514 | /* if the item is the edit control and there is no edit control, skip */ | 
|---|
| 515 | if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE; | 
|---|
| 516 |  | 
|---|
| 517 | if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE; | 
|---|
| 518 |  | 
|---|
| 519 | COMBOEX_CopyItem (item, cit); | 
|---|
| 520 |  | 
|---|
| 521 | return TRUE; | 
|---|
| 522 | } | 
|---|
| 523 |  | 
|---|
| 524 |  | 
|---|
| 525 | static BOOL COMBOEX_GetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) | 
|---|
| 526 | { | 
|---|
| 527 | COMBOBOXEXITEMW tmpcit; | 
|---|
| 528 |  | 
|---|
| 529 | TRACE("(...)\n"); | 
|---|
| 530 |  | 
|---|
| 531 | tmpcit.mask = cit->mask; | 
|---|
| 532 | tmpcit.iItem = cit->iItem; | 
|---|
| 533 | tmpcit.pszText = 0; | 
|---|
| 534 | if(!COMBOEX_GetItemW (infoPtr, &tmpcit)) return FALSE; | 
|---|
| 535 |  | 
|---|
| 536 | if (is_textW(tmpcit.pszText) && cit->pszText) | 
|---|
| 537 | WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, | 
|---|
| 538 | cit->pszText, cit->cchTextMax, NULL, NULL); | 
|---|
| 539 | else if (cit->pszText) cit->pszText[0] = 0; | 
|---|
| 540 | else cit->pszText = (LPSTR)tmpcit.pszText; | 
|---|
| 541 |  | 
|---|
| 542 | cit->iImage = tmpcit.iImage; | 
|---|
| 543 | cit->iSelectedImage = tmpcit.iSelectedImage; | 
|---|
| 544 | cit->iOverlay = tmpcit.iOverlay; | 
|---|
| 545 | cit->iIndent = tmpcit.iIndent; | 
|---|
| 546 | cit->lParam = tmpcit.lParam; | 
|---|
| 547 |  | 
|---|
| 548 | return TRUE; | 
|---|
| 549 | } | 
|---|
| 550 |  | 
|---|
| 551 |  | 
|---|
| 552 | inline static BOOL COMBOEX_HasEditChanged (COMBOEX_INFO *infoPtr) | 
|---|
| 553 | { | 
|---|
| 554 | return COMBOEX_HasEdit(infoPtr) && | 
|---|
| 555 | (infoPtr->flags & WCBE_EDITHASCHANGED) == WCBE_EDITHASCHANGED; | 
|---|
| 556 | } | 
|---|
| 557 |  | 
|---|
| 558 |  | 
|---|
| 559 | static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) | 
|---|
| 560 | { | 
|---|
| 561 | INT index; | 
|---|
| 562 | CBE_ITEMDATA *item; | 
|---|
| 563 | NMCOMBOBOXEXW nmcit; | 
|---|
| 564 |  | 
|---|
| 565 | TRACE("\n"); | 
|---|
| 566 |  | 
|---|
| 567 | if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit); | 
|---|
| 568 |  | 
|---|
| 569 | /* get real index of item to insert */ | 
|---|
| 570 | index = cit->iItem; | 
|---|
| 571 | if (index == -1) index = infoPtr->nb_items; | 
|---|
| 572 | if (index > infoPtr->nb_items) index = infoPtr->nb_items; | 
|---|
| 573 |  | 
|---|
| 574 | /* get zero-filled space and chain it in */ | 
|---|
| 575 | if(!(item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof(*item)))) return -1; | 
|---|
| 576 |  | 
|---|
| 577 | /* locate position to insert new item in */ | 
|---|
| 578 | if (index == infoPtr->nb_items) { | 
|---|
| 579 | /* fast path for iItem = -1 */ | 
|---|
| 580 | item->next = infoPtr->items; | 
|---|
| 581 | infoPtr->items = item; | 
|---|
| 582 | } | 
|---|
| 583 | else { | 
|---|
| 584 | INT i = infoPtr->nb_items-1; | 
|---|
| 585 | CBE_ITEMDATA *moving = infoPtr->items; | 
|---|
| 586 |  | 
|---|
| 587 | while ((i > index) && moving) { | 
|---|
| 588 | moving = (CBE_ITEMDATA *)moving->next; | 
|---|
| 589 | i--; | 
|---|
| 590 | } | 
|---|
| 591 | if (!moving) { | 
|---|
| 592 | ERR("COMBOBOXEX item structures broken. Please report!\n"); | 
|---|
| 593 | COMCTL32_Free(item); | 
|---|
| 594 | return -1; | 
|---|
| 595 | } | 
|---|
| 596 | item->next = moving->next; | 
|---|
| 597 | moving->next = item; | 
|---|
| 598 | } | 
|---|
| 599 |  | 
|---|
| 600 | /* fill in our hidden item structure */ | 
|---|
| 601 | item->mask = cit->mask; | 
|---|
| 602 | if (item->mask & CBEIF_TEXT) { | 
|---|
| 603 | INT len = 0; | 
|---|
| 604 |  | 
|---|
| 605 | if (is_textW(cit->pszText)) len = strlenW (cit->pszText); | 
|---|
| 606 | if (len > 0) { | 
|---|
| 607 | item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); | 
|---|
| 608 | if (!item->pszText) { | 
|---|
| 609 | COMCTL32_Free(item); | 
|---|
| 610 | return -1; | 
|---|
| 611 | } | 
|---|
| 612 | strcpyW (item->pszText, cit->pszText); | 
|---|
| 613 | } | 
|---|
| 614 | else if (cit->pszText == LPSTR_TEXTCALLBACKW) | 
|---|
| 615 | item->pszText = LPSTR_TEXTCALLBACKW; | 
|---|
| 616 | item->cchTextMax = cit->cchTextMax; | 
|---|
| 617 | } | 
|---|
| 618 | if (item->mask & CBEIF_IMAGE) | 
|---|
| 619 | item->iImage = cit->iImage; | 
|---|
| 620 | if (item->mask & CBEIF_SELECTEDIMAGE) | 
|---|
| 621 | item->iSelectedImage = cit->iSelectedImage; | 
|---|
| 622 | if (item->mask & CBEIF_OVERLAY) | 
|---|
| 623 | item->iOverlay = cit->iOverlay; | 
|---|
| 624 | if (item->mask & CBEIF_INDENT) | 
|---|
| 625 | item->iIndent = cit->iIndent; | 
|---|
| 626 | if (item->mask & CBEIF_LPARAM) | 
|---|
| 627 | item->lParam = cit->lParam; | 
|---|
| 628 | infoPtr->nb_items++; | 
|---|
| 629 |  | 
|---|
| 630 | if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); | 
|---|
| 631 |  | 
|---|
| 632 | SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, | 
|---|
| 633 | (WPARAM)cit->iItem, (LPARAM)item); | 
|---|
| 634 |  | 
|---|
| 635 | memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem)); | 
|---|
| 636 | COMBOEX_CopyItem (item, &nmcit.ceItem); | 
|---|
| 637 | COMBOEX_NotifyItem (infoPtr, CBEN_INSERTITEM, &nmcit); | 
|---|
| 638 |  | 
|---|
| 639 | return index; | 
|---|
| 640 |  | 
|---|
| 641 | } | 
|---|
| 642 |  | 
|---|
| 643 |  | 
|---|
| 644 | static INT COMBOEX_InsertItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) | 
|---|
| 645 | { | 
|---|
| 646 | COMBOBOXEXITEMW citW; | 
|---|
| 647 | LPWSTR wstr = NULL; | 
|---|
| 648 | INT ret; | 
|---|
| 649 |  | 
|---|
| 650 | memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA)); | 
|---|
| 651 | if (cit->mask & CBEIF_TEXT && is_textA(cit->pszText)) { | 
|---|
| 652 | INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0); | 
|---|
| 653 | wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); | 
|---|
| 654 | if (!wstr) return -1; | 
|---|
| 655 | MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len); | 
|---|
| 656 | citW.pszText = wstr; | 
|---|
| 657 | } | 
|---|
| 658 | ret = COMBOEX_InsertItemW(infoPtr, &citW); | 
|---|
| 659 |  | 
|---|
| 660 | if (wstr) COMCTL32_Free(wstr); | 
|---|
| 661 |  | 
|---|
| 662 | return ret; | 
|---|
| 663 | } | 
|---|
| 664 |  | 
|---|
| 665 |  | 
|---|
| 666 | static DWORD | 
|---|
| 667 | COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style) | 
|---|
| 668 | { | 
|---|
| 669 | DWORD dwTemp; | 
|---|
| 670 |  | 
|---|
| 671 | TRACE("(mask=x%08lx, style=0x%08lx)\n", mask, style); | 
|---|
| 672 |  | 
|---|
| 673 | dwTemp = infoPtr->dwExtStyle; | 
|---|
| 674 |  | 
|---|
| 675 | if (mask) | 
|---|
| 676 | infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~mask) | style; | 
|---|
| 677 | else | 
|---|
| 678 | infoPtr->dwExtStyle = style; | 
|---|
| 679 |  | 
|---|
| 680 | /* see if we need to change the word break proc on the edit */ | 
|---|
| 681 | if ((infoPtr->dwExtStyle ^ dwTemp) & CBES_EX_PATHWORDBREAKPROC) { | 
|---|
| 682 | SendMessageW(infoPtr->hwndEdit, EM_SETWORDBREAKPROC, 0, | 
|---|
| 683 | (infoPtr->dwExtStyle & CBES_EX_PATHWORDBREAKPROC) ? | 
|---|
| 684 | (LPARAM)COMBOEX_PathWordBreakProc : 0); | 
|---|
| 685 | } | 
|---|
| 686 |  | 
|---|
| 687 | /* test if the control's appearance has changed */ | 
|---|
| 688 | mask = CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT; | 
|---|
| 689 | if ((infoPtr->dwExtStyle & mask) != (dwTemp & mask)) { | 
|---|
| 690 | /* if state of EX_NOEDITIMAGE changes, invalidate all */ | 
|---|
| 691 | TRACE("EX_NOEDITIMAGE state changed to %ld\n", | 
|---|
| 692 | infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE); | 
|---|
| 693 | InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); | 
|---|
| 694 | COMBOEX_AdjustEditPos (infoPtr); | 
|---|
| 695 | if (infoPtr->hwndEdit) | 
|---|
| 696 | InvalidateRect (infoPtr->hwndEdit, NULL, TRUE); | 
|---|
| 697 | } | 
|---|
| 698 |  | 
|---|
| 699 | return dwTemp; | 
|---|
| 700 | } | 
|---|
| 701 |  | 
|---|
| 702 |  | 
|---|
| 703 | static HIMAGELIST COMBOEX_SetImageList (COMBOEX_INFO *infoPtr, HIMAGELIST himl) | 
|---|
| 704 | { | 
|---|
| 705 | HIMAGELIST himlTemp = infoPtr->himl; | 
|---|
| 706 |  | 
|---|
| 707 | TRACE("(...)\n"); | 
|---|
| 708 |  | 
|---|
| 709 | infoPtr->himl = himl; | 
|---|
| 710 |  | 
|---|
| 711 | COMBOEX_ReSize (infoPtr); | 
|---|
| 712 | InvalidateRect (infoPtr->hwndCombo, NULL, TRUE); | 
|---|
| 713 |  | 
|---|
| 714 | /* reposition the Edit control based on whether icon exists */ | 
|---|
| 715 | COMBOEX_AdjustEditPos (infoPtr); | 
|---|
| 716 | return himlTemp; | 
|---|
| 717 | } | 
|---|
| 718 |  | 
|---|
| 719 | static BOOL COMBOEX_SetItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) | 
|---|
| 720 | { | 
|---|
| 721 | INT index = cit->iItem; | 
|---|
| 722 | CBE_ITEMDATA *item; | 
|---|
| 723 |  | 
|---|
| 724 | if (TRACE_ON(comboex)) COMBOEX_DumpInput (cit); | 
|---|
| 725 |  | 
|---|
| 726 | /* if item number requested does not exist then return failure */ | 
|---|
| 727 | if ((index > infoPtr->nb_items) || (index < -1)) return FALSE; | 
|---|
| 728 |  | 
|---|
| 729 | /* if the item is the edit control and there is no edit control, skip */ | 
|---|
| 730 | if ((index == -1) && !COMBOEX_HasEdit(infoPtr)) return FALSE; | 
|---|
| 731 |  | 
|---|
| 732 | if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE; | 
|---|
| 733 |  | 
|---|
| 734 | /* add/change stuff to the internal item structure */ | 
|---|
| 735 | item->mask |= cit->mask; | 
|---|
| 736 | if (cit->mask & CBEIF_TEXT) { | 
|---|
| 737 | INT len = 0; | 
|---|
| 738 |  | 
|---|
| 739 | COMBOEX_FreeText(item); | 
|---|
| 740 | if (is_textW(cit->pszText)) len = strlenW(cit->pszText); | 
|---|
| 741 | if (len > 0) { | 
|---|
| 742 | item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); | 
|---|
| 743 | if (!item->pszText) return FALSE; | 
|---|
| 744 | strcpyW(item->pszText, cit->pszText); | 
|---|
| 745 | } else if (cit->pszText == LPSTR_TEXTCALLBACKW) | 
|---|
| 746 | item->pszText = LPSTR_TEXTCALLBACKW; | 
|---|
| 747 | item->cchTextMax = cit->cchTextMax; | 
|---|
| 748 | } | 
|---|
| 749 | if (cit->mask & CBEIF_IMAGE) | 
|---|
| 750 | item->iImage = cit->iImage; | 
|---|
| 751 | if (cit->mask & CBEIF_SELECTEDIMAGE) | 
|---|
| 752 | item->iSelectedImage = cit->iSelectedImage; | 
|---|
| 753 | if (cit->mask & CBEIF_OVERLAY) | 
|---|
| 754 | item->iOverlay = cit->iOverlay; | 
|---|
| 755 | if (cit->mask & CBEIF_INDENT) | 
|---|
| 756 | item->iIndent = cit->iIndent; | 
|---|
| 757 | if (cit->mask & CBEIF_LPARAM) | 
|---|
| 758 | cit->lParam = cit->lParam; | 
|---|
| 759 |  | 
|---|
| 760 | if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); | 
|---|
| 761 |  | 
|---|
| 762 | /* if original request was to update edit control, do some fast foot work */ | 
|---|
| 763 | if (cit->iItem == -1) { | 
|---|
| 764 | COMBOEX_SetEditText (infoPtr, item); | 
|---|
| 765 | RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE); | 
|---|
| 766 | } | 
|---|
| 767 | return TRUE; | 
|---|
| 768 | } | 
|---|
| 769 |  | 
|---|
| 770 | static BOOL COMBOEX_SetItemA (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMA *cit) | 
|---|
| 771 | { | 
|---|
| 772 | COMBOBOXEXITEMW citW; | 
|---|
| 773 | LPWSTR wstr = NULL; | 
|---|
| 774 | BOOL ret; | 
|---|
| 775 |  | 
|---|
| 776 | memcpy(&citW, cit, sizeof(COMBOBOXEXITEMA)); | 
|---|
| 777 | if ((cit->mask & CBEIF_TEXT) && is_textA(cit->pszText)) { | 
|---|
| 778 | INT len = MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, NULL, 0); | 
|---|
| 779 | wstr = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); | 
|---|
| 780 | if (!wstr) return FALSE; | 
|---|
| 781 | MultiByteToWideChar (CP_ACP, 0, cit->pszText, -1, wstr, len); | 
|---|
| 782 | citW.pszText = wstr; | 
|---|
| 783 | } | 
|---|
| 784 | ret = COMBOEX_SetItemW(infoPtr, &citW); | 
|---|
| 785 |  | 
|---|
| 786 | if (wstr) COMCTL32_Free(wstr); | 
|---|
| 787 |  | 
|---|
| 788 | return ret; | 
|---|
| 789 | } | 
|---|
| 790 |  | 
|---|
| 791 |  | 
|---|
| 792 | static BOOL COMBOEX_SetUnicodeFormat (COMBOEX_INFO *infoPtr, BOOL value) | 
|---|
| 793 | { | 
|---|
| 794 | BOOL bTemp = infoPtr->unicode; | 
|---|
| 795 |  | 
|---|
| 796 | TRACE("to %s, was %s\n", value ? "TRUE":"FALSE", bTemp ? "TRUE":"FALSE"); | 
|---|
| 797 |  | 
|---|
| 798 | infoPtr->unicode = value; | 
|---|
| 799 |  | 
|---|
| 800 | return bTemp; | 
|---|
| 801 | } | 
|---|
| 802 |  | 
|---|
| 803 |  | 
|---|
| 804 | /* ***  CB_xxx message support  *** */ | 
|---|
| 805 |  | 
|---|
| 806 | static INT | 
|---|
| 807 | COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCWSTR str) | 
|---|
| 808 | { | 
|---|
| 809 | INT i; | 
|---|
| 810 | cmp_func_t cmptext = get_cmp_func(infoPtr); | 
|---|
| 811 | INT count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0); | 
|---|
| 812 |  | 
|---|
| 813 | /* now search from after starting loc and wrapping back to start */ | 
|---|
| 814 | for(i=start+1; i<count; i++) { | 
|---|
| 815 | CBE_ITEMDATA *item = get_item_data(infoPtr, i); | 
|---|
| 816 | if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i; | 
|---|
| 817 | } | 
|---|
| 818 | for(i=0; i<=start; i++) { | 
|---|
| 819 | CBE_ITEMDATA *item = get_item_data(infoPtr, i); | 
|---|
| 820 | if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i; | 
|---|
| 821 | } | 
|---|
| 822 | return CB_ERR; | 
|---|
| 823 | } | 
|---|
| 824 |  | 
|---|
| 825 |  | 
|---|
| 826 | static DWORD COMBOEX_GetItemData (COMBOEX_INFO *infoPtr, INT index) | 
|---|
| 827 | { | 
|---|
| 828 | CBE_ITEMDATA *item1, *item2; | 
|---|
| 829 | DWORD ret = 0; | 
|---|
| 830 |  | 
|---|
| 831 | item1 = get_item_data(infoPtr, index); | 
|---|
| 832 | if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { | 
|---|
| 833 | item2 = COMBOEX_FindItem (infoPtr, index); | 
|---|
| 834 | if (item2 != item1) { | 
|---|
| 835 | ERR("data structures damaged!\n"); | 
|---|
| 836 | return CB_ERR; | 
|---|
| 837 | } | 
|---|
| 838 | if (item1->mask & CBEIF_LPARAM) ret = item1->lParam; | 
|---|
| 839 | TRACE("returning 0x%08lx\n", ret); | 
|---|
| 840 | } else { | 
|---|
| 841 | ret = (DWORD)item1; | 
|---|
| 842 | TRACE("non-valid result from combo, returning 0x%08lx\n", ret); | 
|---|
| 843 | } | 
|---|
| 844 | return ret; | 
|---|
| 845 | } | 
|---|
| 846 |  | 
|---|
| 847 |  | 
|---|
| 848 | static INT COMBOEX_SetCursel (COMBOEX_INFO *infoPtr, INT index) | 
|---|
| 849 | { | 
|---|
| 850 | CBE_ITEMDATA *item; | 
|---|
| 851 | INT sel; | 
|---|
| 852 |  | 
|---|
| 853 | if (!(item = COMBOEX_FindItem(infoPtr, index))) | 
|---|
| 854 | return SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0); | 
|---|
| 855 |  | 
|---|
| 856 | TRACE("selecting item %d text=%s\n", index, debugstr_txt(item->pszText)); | 
|---|
| 857 | infoPtr->selected = index; | 
|---|
| 858 |  | 
|---|
| 859 | sel = (INT)SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, index, 0); | 
|---|
| 860 | COMBOEX_SetEditText (infoPtr, item); | 
|---|
| 861 | return sel; | 
|---|
| 862 | } | 
|---|
| 863 |  | 
|---|
| 864 |  | 
|---|
| 865 | static DWORD COMBOEX_SetItemData (COMBOEX_INFO *infoPtr, INT index, DWORD data) | 
|---|
| 866 | { | 
|---|
| 867 | CBE_ITEMDATA *item1, *item2; | 
|---|
| 868 |  | 
|---|
| 869 | item1 = get_item_data(infoPtr, index); | 
|---|
| 870 | if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { | 
|---|
| 871 | item2 = COMBOEX_FindItem (infoPtr, index); | 
|---|
| 872 | if (item2 != item1) { | 
|---|
| 873 | ERR("data structures damaged!\n"); | 
|---|
| 874 | return CB_ERR; | 
|---|
| 875 | } | 
|---|
| 876 | item1->mask |= CBEIF_LPARAM; | 
|---|
| 877 | item1->lParam = data; | 
|---|
| 878 | TRACE("setting lparam to 0x%08lx\n", data); | 
|---|
| 879 | return 0; | 
|---|
| 880 | } | 
|---|
| 881 | TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1); | 
|---|
| 882 | return (LRESULT)item1; | 
|---|
| 883 | } | 
|---|
| 884 |  | 
|---|
| 885 |  | 
|---|
| 886 | static INT COMBOEX_SetItemHeight (COMBOEX_INFO *infoPtr, INT index, UINT height) | 
|---|
| 887 | { | 
|---|
| 888 | RECT cb_wrect, cbx_wrect, cbx_crect; | 
|---|
| 889 |  | 
|---|
| 890 | /* First, lets forward the message to the normal combo control | 
|---|
| 891 | just like Windows.     */ | 
|---|
| 892 | if (infoPtr->hwndCombo) | 
|---|
| 893 | if (SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, | 
|---|
| 894 | index, height) == CB_ERR) return CB_ERR; | 
|---|
| 895 |  | 
|---|
| 896 | GetWindowRect (infoPtr->hwndCombo, &cb_wrect); | 
|---|
| 897 | GetWindowRect (infoPtr->hwndSelf, &cbx_wrect); | 
|---|
| 898 | GetClientRect (infoPtr->hwndSelf, &cbx_crect); | 
|---|
| 899 | /* the height of comboex as height of the combo + comboex border */ | 
|---|
| 900 | height = cb_wrect.bottom-cb_wrect.top | 
|---|
| 901 | + cbx_wrect.bottom-cbx_wrect.top | 
|---|
| 902 | - (cbx_crect.bottom-cbx_crect.top); | 
|---|
| 903 | TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n", | 
|---|
| 904 | cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom, | 
|---|
| 905 | cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom); | 
|---|
| 906 | TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n", | 
|---|
| 907 | cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom, | 
|---|
| 908 | cbx_wrect.right-cbx_wrect.left, height); | 
|---|
| 909 | SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0, | 
|---|
| 910 | cbx_wrect.right-cbx_wrect.left, height, | 
|---|
| 911 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); | 
|---|
| 912 |  | 
|---|
| 913 | return 0; | 
|---|
| 914 | } | 
|---|
| 915 |  | 
|---|
| 916 |  | 
|---|
| 917 | /* ***  WM_xxx message support  *** */ | 
|---|
| 918 |  | 
|---|
| 919 |  | 
|---|
| 920 | static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs) | 
|---|
| 921 | { | 
|---|
| 922 | WCHAR COMBOBOX[] = { 'C', 'o', 'm', 'b', 'o', 'B', 'o', 'x', 0 }; | 
|---|
| 923 | WCHAR EDIT[] = { 'E', 'D', 'I', 'T', 0 }; | 
|---|
| 924 | WCHAR NIL[] = { 0 }; | 
|---|
| 925 | COMBOEX_INFO *infoPtr; | 
|---|
| 926 | LOGFONTW mylogfont; | 
|---|
| 927 | RECT wnrc1, clrc1, cmbwrc; | 
|---|
| 928 | INT i; | 
|---|
| 929 |  | 
|---|
| 930 | /* allocate memory for info structure */ | 
|---|
| 931 | infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO)); | 
|---|
| 932 | if (!infoPtr) return -1; | 
|---|
| 933 |  | 
|---|
| 934 | /* initialize info structure */ | 
|---|
| 935 | /* note that infoPtr is allocated zero-filled */ | 
|---|
| 936 |  | 
|---|
| 937 | infoPtr->hwndSelf = hwnd; | 
|---|
| 938 | infoPtr->selected = -1; | 
|---|
| 939 |  | 
|---|
| 940 | infoPtr->unicode = IsWindowUnicode (hwnd); | 
|---|
| 941 |  | 
|---|
| 942 | i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY); | 
|---|
| 943 | if ((i != NFR_ANSI) && (i != NFR_UNICODE)) { | 
|---|
| 944 | WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i); | 
|---|
| 945 | i = NFR_ANSI; | 
|---|
| 946 | } | 
|---|
| 947 | infoPtr->NtfUnicode = (i == NFR_UNICODE); | 
|---|
| 948 |  | 
|---|
| 949 | SetWindowLongW (hwnd, 0, (DWORD)infoPtr); | 
|---|
| 950 |  | 
|---|
| 951 | /* create combo box */ | 
|---|
| 952 | GetWindowRect(hwnd, &wnrc1); | 
|---|
| 953 | GetClientRect(hwnd, &clrc1); | 
|---|
| 954 | TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n", | 
|---|
| 955 | wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, | 
|---|
| 956 | clrc1.left, clrc1.top, clrc1.right, clrc1.bottom); | 
|---|
| 957 |  | 
|---|
| 958 | /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */ | 
|---|
| 959 | /* specified. It then creates it's own version of the EDIT control  */ | 
|---|
| 960 | /* and makes the ComboBox the parent. This is because a normal      */ | 
|---|
| 961 | /* DROPDOWNLIST does not have a EDIT control, but we need one.      */ | 
|---|
| 962 | /* We also need to place the edit control at the proper location    */ | 
|---|
| 963 | /* (allow space for the icons).                                     */ | 
|---|
| 964 |  | 
|---|
| 965 | infoPtr->hwndCombo = CreateWindowW (COMBOBOX, NIL, | 
|---|
| 966 | /* following line added to match native */ | 
|---|
| 967 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | | 
|---|
| 968 | CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | | 
|---|
| 969 | /* was base and is necessary */ | 
|---|
| 970 | WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | | 
|---|
| 971 | GetWindowLongW (hwnd, GWL_STYLE), | 
|---|
| 972 | cs->y, cs->x, cs->cx, cs->cy, hwnd, | 
|---|
| 973 | (HMENU) GetWindowLongW (hwnd, GWL_ID), | 
|---|
| 974 | (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL); | 
|---|
| 975 |  | 
|---|
| 976 | /* | 
|---|
| 977 | * native does the following at this point according to trace: | 
|---|
| 978 | *  GetWindowThreadProcessId(hwndCombo,0) | 
|---|
| 979 | *  GetCurrentThreadId() | 
|---|
| 980 | *  GetWindowThreadProcessId(hwndCombo, &???) | 
|---|
| 981 | *  GetCurrentProcessId() | 
|---|
| 982 | */ | 
|---|
| 983 |  | 
|---|
| 984 | /* | 
|---|
| 985 | * Setup a property to hold the pointer to the COMBOBOXEX | 
|---|
| 986 | * data structure. | 
|---|
| 987 | */ | 
|---|
| 988 | SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd); | 
|---|
| 989 | infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo, | 
|---|
| 990 | GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc); | 
|---|
| 991 | infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); | 
|---|
| 992 |  | 
|---|
| 993 |  | 
|---|
| 994 | /* | 
|---|
| 995 | * Now create our own EDIT control so we can position it. | 
|---|
| 996 | * It is created only for CBS_DROPDOWN style | 
|---|
| 997 | */ | 
|---|
| 998 | if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) { | 
|---|
| 999 | infoPtr->hwndEdit = CreateWindowExW (0, EDIT, NIL, | 
|---|
| 1000 | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL, | 
|---|
| 1001 | 0, 0, 0, 0,  /* will set later */ | 
|---|
| 1002 | infoPtr->hwndCombo, | 
|---|
| 1003 | (HMENU) GetWindowLongW (hwnd, GWL_ID), | 
|---|
| 1004 | (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL); | 
|---|
| 1005 |  | 
|---|
| 1006 | /* native does the following at this point according to trace: | 
|---|
| 1007 | *  GetWindowThreadProcessId(hwndEdit,0) | 
|---|
| 1008 | *  GetCurrentThreadId() | 
|---|
| 1009 | *  GetWindowThreadProcessId(hwndEdit, &???) | 
|---|
| 1010 | *  GetCurrentProcessId() | 
|---|
| 1011 | */ | 
|---|
| 1012 |  | 
|---|
| 1013 | /* | 
|---|
| 1014 | * Setup a property to hold the pointer to the COMBOBOXEX | 
|---|
| 1015 | * data structure. | 
|---|
| 1016 | */ | 
|---|
| 1017 | SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd); | 
|---|
| 1018 | infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit, | 
|---|
| 1019 | GWL_WNDPROC, (LONG)COMBOEX_EditWndProc); | 
|---|
| 1020 | infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0); | 
|---|
| 1021 | } | 
|---|
| 1022 |  | 
|---|
| 1023 | /* | 
|---|
| 1024 | * Locate the default font if necessary and then set it in | 
|---|
| 1025 | * all associated controls | 
|---|
| 1026 | */ | 
|---|
| 1027 | if (!infoPtr->font) { | 
|---|
| 1028 | SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), | 
|---|
| 1029 | &mylogfont, 0); | 
|---|
| 1030 | infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont); | 
|---|
| 1031 | } | 
|---|
| 1032 | SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0); | 
|---|
| 1033 | if (infoPtr->hwndEdit) { | 
|---|
| 1034 | SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0); | 
|---|
| 1035 | SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0); | 
|---|
| 1036 | } | 
|---|
| 1037 |  | 
|---|
| 1038 | COMBOEX_ReSize (infoPtr); | 
|---|
| 1039 |  | 
|---|
| 1040 | /* Above is fairly certain, below is much less certain. */ | 
|---|
| 1041 |  | 
|---|
| 1042 | GetWindowRect(hwnd, &wnrc1); | 
|---|
| 1043 | GetClientRect(hwnd, &clrc1); | 
|---|
| 1044 | GetWindowRect(infoPtr->hwndCombo, &cmbwrc); | 
|---|
| 1045 | TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) CB wnd=(%d,%d)-(%d,%d)\n", | 
|---|
| 1046 | wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, | 
|---|
| 1047 | clrc1.left, clrc1.top, clrc1.right, clrc1.bottom, | 
|---|
| 1048 | cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom); | 
|---|
| 1049 | SetWindowPos(infoPtr->hwndCombo, HWND_TOP, | 
|---|
| 1050 | 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top, | 
|---|
| 1051 | SWP_NOACTIVATE | SWP_NOREDRAW); | 
|---|
| 1052 |  | 
|---|
| 1053 | GetWindowRect(infoPtr->hwndCombo, &cmbwrc); | 
|---|
| 1054 | TRACE("CB window=(%d,%d)-(%d,%d)\n", | 
|---|
| 1055 | cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom); | 
|---|
| 1056 | SetWindowPos(hwnd, HWND_TOP, | 
|---|
| 1057 | 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top, | 
|---|
| 1058 | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); | 
|---|
| 1059 |  | 
|---|
| 1060 | COMBOEX_AdjustEditPos (infoPtr); | 
|---|
| 1061 |  | 
|---|
| 1062 | /* | 
|---|
| 1063 | * Create an item structure to represent the data in the | 
|---|
| 1064 | * EDIT control. It is allocated zero-filled. | 
|---|
| 1065 | */ | 
|---|
| 1066 | infoPtr->edit = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof (CBE_ITEMDATA)); | 
|---|
| 1067 | if (!infoPtr->edit) { | 
|---|
| 1068 | COMBOEX_Destroy(infoPtr); | 
|---|
| 1069 | return -1; | 
|---|
| 1070 | } | 
|---|
| 1071 |  | 
|---|
| 1072 | return 0; | 
|---|
| 1073 | } | 
|---|
| 1074 |  | 
|---|
| 1075 |  | 
|---|
| 1076 | static LRESULT COMBOEX_Command (COMBOEX_INFO *infoPtr, WPARAM wParam, LPARAM lParam) | 
|---|
| 1077 | { | 
|---|
| 1078 | LRESULT lret; | 
|---|
| 1079 | INT command = HIWORD(wParam); | 
|---|
| 1080 | CBE_ITEMDATA *item = 0; | 
|---|
| 1081 | WCHAR wintext[520]; | 
|---|
| 1082 | INT cursel, n, oldItem; | 
|---|
| 1083 | NMCBEENDEDITW cbeend; | 
|---|
| 1084 | DWORD oldflags; | 
|---|
| 1085 | HWND parent = GetParent (infoPtr->hwndSelf); | 
|---|
| 1086 |  | 
|---|
| 1087 | TRACE("for command %d\n", command); | 
|---|
| 1088 |  | 
|---|
| 1089 | switch (command) | 
|---|
| 1090 | { | 
|---|
| 1091 | case CBN_DROPDOWN: | 
|---|
| 1092 | SetFocus (infoPtr->hwndCombo); | 
|---|
| 1093 | ShowWindow (infoPtr->hwndEdit, SW_HIDE); | 
|---|
| 1094 | return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); | 
|---|
| 1095 |  | 
|---|
| 1096 | case CBN_CLOSEUP: | 
|---|
| 1097 | SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); | 
|---|
| 1098 | /* | 
|---|
| 1099 | * from native trace of first dropdown after typing in URL in IE4 | 
|---|
| 1100 | *  CB_GETCURSEL(Combo) | 
|---|
| 1101 | *  GetWindowText(Edit) | 
|---|
| 1102 | *  CB_GETCURSEL(Combo) | 
|---|
| 1103 | *  CB_GETCOUNT(Combo) | 
|---|
| 1104 | *  CB_GETITEMDATA(Combo, n) | 
|---|
| 1105 | *  WM_NOTIFY(parent, CBEN_ENDEDITA|W) | 
|---|
| 1106 | *  CB_GETCURSEL(Combo) | 
|---|
| 1107 | *  CB_SETCURSEL(COMBOEX, n) | 
|---|
| 1108 | *  SetFocus(Combo) | 
|---|
| 1109 | * the rest is supposition | 
|---|
| 1110 | */ | 
|---|
| 1111 | ShowWindow (infoPtr->hwndEdit, SW_SHOW); | 
|---|
| 1112 | InvalidateRect (infoPtr->hwndCombo, 0, TRUE); | 
|---|
| 1113 | InvalidateRect (infoPtr->hwndEdit, 0, TRUE); | 
|---|
| 1114 | cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); | 
|---|
| 1115 | if (cursel == -1) { | 
|---|
| 1116 | cmp_func_t cmptext = get_cmp_func(infoPtr); | 
|---|
| 1117 | /* find match from edit against those in Combobox */ | 
|---|
| 1118 | GetWindowTextW (infoPtr->hwndEdit, wintext, 520); | 
|---|
| 1119 | n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0); | 
|---|
| 1120 | for (cursel = 0; cursel < n; cursel++){ | 
|---|
| 1121 | item = get_item_data(infoPtr, cursel); | 
|---|
| 1122 | if ((INT)item == CB_ERR) break; | 
|---|
| 1123 | if (!cmptext(COMBOEX_GetText(infoPtr, item), wintext)) break; | 
|---|
| 1124 | } | 
|---|
| 1125 | if ((cursel == n) || ((INT)item == CB_ERR)) { | 
|---|
| 1126 | TRACE("failed to find match??? item=%p cursel=%d\n", | 
|---|
| 1127 | item, cursel); | 
|---|
| 1128 | if (infoPtr->hwndEdit) | 
|---|
| 1129 | SetFocus(infoPtr->hwndEdit); | 
|---|
| 1130 | return 0; | 
|---|
| 1131 | } | 
|---|
| 1132 | } | 
|---|
| 1133 | else { | 
|---|
| 1134 | item = get_item_data(infoPtr, cursel); | 
|---|
| 1135 | if ((INT)item == CB_ERR) { | 
|---|
| 1136 | TRACE("failed to find match??? item=%p cursel=%d\n", | 
|---|
| 1137 | item, cursel); | 
|---|
| 1138 | if (infoPtr->hwndEdit) | 
|---|
| 1139 | SetFocus(infoPtr->hwndEdit); | 
|---|
| 1140 | return 0; | 
|---|
| 1141 | } | 
|---|
| 1142 | } | 
|---|
| 1143 |  | 
|---|
| 1144 | /* Save flags for testing and reset them */ | 
|---|
| 1145 | oldflags = infoPtr->flags; | 
|---|
| 1146 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); | 
|---|
| 1147 |  | 
|---|
| 1148 | if (oldflags & WCBE_ACTEDIT) { | 
|---|
| 1149 | cbeend.fChanged = (oldflags & WCBE_EDITCHG); | 
|---|
| 1150 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, | 
|---|
| 1151 | CB_GETCURSEL, 0, 0); | 
|---|
| 1152 | cbeend.iWhy = CBENF_DROPDOWN; | 
|---|
| 1153 |  | 
|---|
| 1154 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, COMBOEX_GetText(infoPtr, item))) return 0; | 
|---|
| 1155 | } | 
|---|
| 1156 |  | 
|---|
| 1157 | /* if selection has changed the set the new current selection */ | 
|---|
| 1158 | cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); | 
|---|
| 1159 | if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) { | 
|---|
| 1160 | infoPtr->selected = cursel; | 
|---|
| 1161 | SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, cursel, 0); | 
|---|
| 1162 | SetFocus(infoPtr->hwndCombo); | 
|---|
| 1163 | } | 
|---|
| 1164 | return 0; | 
|---|
| 1165 |  | 
|---|
| 1166 | case CBN_SELCHANGE: | 
|---|
| 1167 | /* | 
|---|
| 1168 | * CB_GETCURSEL(Combo) | 
|---|
| 1169 | * CB_GETITEMDATA(Combo)   < simulated by COMBOEX_FindItem | 
|---|
| 1170 | * lstrlenA | 
|---|
| 1171 | * WM_SETTEXT(Edit) | 
|---|
| 1172 | * WM_GETTEXTLENGTH(Edit) | 
|---|
| 1173 | * WM_GETTEXT(Edit) | 
|---|
| 1174 | * EM_SETSEL(Edit, 0,0) | 
|---|
| 1175 | * WM_GETTEXTLENGTH(Edit) | 
|---|
| 1176 | * WM_GETTEXT(Edit) | 
|---|
| 1177 | * EM_SETSEL(Edit, 0,len) | 
|---|
| 1178 | * return WM_COMMAND to parent | 
|---|
| 1179 | */ | 
|---|
| 1180 | oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); | 
|---|
| 1181 | if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) { | 
|---|
| 1182 | ERR("item %d not found. Problem!\n", oldItem); | 
|---|
| 1183 | break; | 
|---|
| 1184 | } | 
|---|
| 1185 | infoPtr->selected = oldItem; | 
|---|
| 1186 | COMBOEX_SetEditText (infoPtr, item); | 
|---|
| 1187 | return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); | 
|---|
| 1188 |  | 
|---|
| 1189 | case CBN_SELENDOK: | 
|---|
| 1190 | /* | 
|---|
| 1191 | * We have to change the handle since we are the control | 
|---|
| 1192 | * issuing the message. IE4 depends on this. | 
|---|
| 1193 | */ | 
|---|
| 1194 | return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); | 
|---|
| 1195 |  | 
|---|
| 1196 | case CBN_KILLFOCUS: | 
|---|
| 1197 | /* | 
|---|
| 1198 | * from native trace: | 
|---|
| 1199 | * | 
|---|
| 1200 | *  pass to parent | 
|---|
| 1201 | *  WM_GETTEXT(Edit, 104) | 
|---|
| 1202 | *  CB_GETCURSEL(Combo) rets -1 | 
|---|
| 1203 | *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS | 
|---|
| 1204 | *  CB_GETCURSEL(Combo) | 
|---|
| 1205 | *  InvalidateRect(Combo, 0, 0) | 
|---|
| 1206 | *  return 0 | 
|---|
| 1207 | */ | 
|---|
| 1208 | SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); | 
|---|
| 1209 | if (infoPtr->flags & WCBE_ACTEDIT) { | 
|---|
| 1210 | GetWindowTextW (infoPtr->hwndEdit, wintext, 260); | 
|---|
| 1211 | cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG); | 
|---|
| 1212 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, | 
|---|
| 1213 | CB_GETCURSEL, 0, 0); | 
|---|
| 1214 | cbeend.iWhy = CBENF_KILLFOCUS; | 
|---|
| 1215 |  | 
|---|
| 1216 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); | 
|---|
| 1217 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) return 0; | 
|---|
| 1218 | } | 
|---|
| 1219 | /* possible CB_GETCURSEL */ | 
|---|
| 1220 | InvalidateRect (infoPtr->hwndCombo, 0, 0); | 
|---|
| 1221 | return 0; | 
|---|
| 1222 |  | 
|---|
| 1223 | default: | 
|---|
| 1224 | /* | 
|---|
| 1225 | * We have to change the handle since we are the control | 
|---|
| 1226 | * issuing the message. IE4 depends on this. | 
|---|
| 1227 | * We also need to set the focus back to the Edit control | 
|---|
| 1228 | * after passing the command to the parent of the ComboEx. | 
|---|
| 1229 | */ | 
|---|
| 1230 | lret = SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf); | 
|---|
| 1231 | if (infoPtr->hwndEdit) | 
|---|
| 1232 | SetFocus(infoPtr->hwndEdit); | 
|---|
| 1233 | return lret; | 
|---|
| 1234 | } | 
|---|
| 1235 | return 0; | 
|---|
| 1236 | } | 
|---|
| 1237 |  | 
|---|
| 1238 |  | 
|---|
| 1239 | static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis) | 
|---|
| 1240 | { | 
|---|
| 1241 | CBE_ITEMDATA *item, *olditem; | 
|---|
| 1242 | NMCOMBOBOXEXW nmcit; | 
|---|
| 1243 | INT i; | 
|---|
| 1244 |  | 
|---|
| 1245 | TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%p, data=%08lx\n", | 
|---|
| 1246 | dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData); | 
|---|
| 1247 |  | 
|---|
| 1248 | if (dis->itemID >= infoPtr->nb_items) return FALSE; | 
|---|
| 1249 |  | 
|---|
| 1250 | olditem = infoPtr->items; | 
|---|
| 1251 | i = infoPtr->nb_items - 1; | 
|---|
| 1252 |  | 
|---|
| 1253 | if (i == dis->itemID) { | 
|---|
| 1254 | infoPtr->items = infoPtr->items->next; | 
|---|
| 1255 | } | 
|---|
| 1256 | else { | 
|---|
| 1257 | item = olditem; | 
|---|
| 1258 | i--; | 
|---|
| 1259 |  | 
|---|
| 1260 | /* find the prior item in the list */ | 
|---|
| 1261 | while (item->next && (i > dis->itemID)) { | 
|---|
| 1262 | item = (CBE_ITEMDATA *)item->next; | 
|---|
| 1263 | i--; | 
|---|
| 1264 | } | 
|---|
| 1265 | if (!item->next || (i != dis->itemID)) { | 
|---|
| 1266 | ERR("COMBOBOXEX item structures broken. Please report!\n"); | 
|---|
| 1267 | return FALSE; | 
|---|
| 1268 | } | 
|---|
| 1269 | olditem = item->next; | 
|---|
| 1270 | item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next; | 
|---|
| 1271 | } | 
|---|
| 1272 | infoPtr->nb_items--; | 
|---|
| 1273 |  | 
|---|
| 1274 | memset (&nmcit.ceItem, 0, sizeof(nmcit.ceItem)); | 
|---|
| 1275 | COMBOEX_CopyItem (olditem, &nmcit.ceItem); | 
|---|
| 1276 | COMBOEX_NotifyItem (infoPtr, CBEN_DELETEITEM, &nmcit); | 
|---|
| 1277 |  | 
|---|
| 1278 | COMBOEX_FreeText(olditem); | 
|---|
| 1279 | COMCTL32_Free(olditem); | 
|---|
| 1280 |  | 
|---|
| 1281 | return TRUE; | 
|---|
| 1282 | } | 
|---|
| 1283 |  | 
|---|
| 1284 |  | 
|---|
| 1285 | static LRESULT COMBOEX_DrawItem (COMBOEX_INFO *infoPtr, DRAWITEMSTRUCT *dis) | 
|---|
| 1286 | { | 
|---|
| 1287 | WCHAR nil[] = { 0 }; | 
|---|
| 1288 | CBE_ITEMDATA *item = 0; | 
|---|
| 1289 | SIZE txtsize; | 
|---|
| 1290 | RECT rect; | 
|---|
| 1291 | LPCWSTR str = nil; | 
|---|
| 1292 | UINT xbase, x, y; | 
|---|
| 1293 | INT len; | 
|---|
| 1294 | COLORREF nbkc, ntxc, bkc, txc; | 
|---|
| 1295 | int drawimage, drawstate, xioff; | 
|---|
| 1296 |  | 
|---|
| 1297 | if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0; | 
|---|
| 1298 |  | 
|---|
| 1299 | TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", | 
|---|
| 1300 | dis->CtlType, dis->CtlID); | 
|---|
| 1301 | TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", | 
|---|
| 1302 | dis->itemID, dis->itemAction, dis->itemState); | 
|---|
| 1303 | TRACE("hWnd=%p hDC=%p (%d,%d)-(%d,%d) itemData=0x%08lx\n", | 
|---|
| 1304 | dis->hwndItem, dis->hDC, dis->rcItem.left, | 
|---|
| 1305 | dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, | 
|---|
| 1306 | dis->itemData); | 
|---|
| 1307 |  | 
|---|
| 1308 | /* MSDN says:                                                       */ | 
|---|
| 1309 | /*     "itemID - Specifies the menu item identifier for a menu      */ | 
|---|
| 1310 | /*      item or the index of the item in a list box or combo box.   */ | 
|---|
| 1311 | /*      For an empty list box or combo box, this member can be -1.  */ | 
|---|
| 1312 | /*      This allows the application to draw only the focus          */ | 
|---|
| 1313 | /*      rectangle at the coordinates specified by the rcItem        */ | 
|---|
| 1314 | /*      member even though there are no items in the control.       */ | 
|---|
| 1315 | /*      This indicates to the user whether the list box or combo    */ | 
|---|
| 1316 | /*      box has the focus. How the bits are set in the itemAction   */ | 
|---|
| 1317 | /*      member determines whether the rectangle is to be drawn as   */ | 
|---|
| 1318 | /*      though the list box or combo box has the focus.             */ | 
|---|
| 1319 | if (dis->itemID == 0xffffffff) { | 
|---|
| 1320 | if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) || | 
|---|
| 1321 | ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) { | 
|---|
| 1322 |  | 
|---|
| 1323 | TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n", | 
|---|
| 1324 | dis->rcItem.left, dis->rcItem.top, | 
|---|
| 1325 | dis->rcItem.right, dis->rcItem.bottom); | 
|---|
| 1326 | } | 
|---|
| 1327 | else if ((dis->CtlType == ODT_COMBOBOX) && | 
|---|
| 1328 | (dis->itemAction == ODA_DRAWENTIRE)) { | 
|---|
| 1329 | /* draw of edit control data */ | 
|---|
| 1330 |  | 
|---|
| 1331 | /* testing */ | 
|---|
| 1332 | { | 
|---|
| 1333 | RECT exrc, cbrc, edrc; | 
|---|
| 1334 | GetWindowRect (infoPtr->hwndSelf, &exrc); | 
|---|
| 1335 | GetWindowRect (infoPtr->hwndCombo, &cbrc); | 
|---|
| 1336 | edrc.left=edrc.top=edrc.right=edrc.bottom=-1; | 
|---|
| 1337 | if (infoPtr->hwndEdit) | 
|---|
| 1338 | GetWindowRect (infoPtr->hwndEdit, &edrc); | 
|---|
| 1339 | TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n", | 
|---|
| 1340 | exrc.left, exrc.top, exrc.right, exrc.bottom, | 
|---|
| 1341 | cbrc.left, cbrc.top, cbrc.right, cbrc.bottom, | 
|---|
| 1342 | edrc.left, edrc.top, edrc.right, edrc.bottom); | 
|---|
| 1343 | } | 
|---|
| 1344 | } | 
|---|
| 1345 | else { | 
|---|
| 1346 | ERR("NOT drawing item  -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n", | 
|---|
| 1347 | dis->rcItem.left, dis->rcItem.top, | 
|---|
| 1348 | dis->rcItem.right, dis->rcItem.bottom, | 
|---|
| 1349 | dis->itemAction, dis->itemState); | 
|---|
| 1350 | return 0; | 
|---|
| 1351 | } | 
|---|
| 1352 | } | 
|---|
| 1353 |  | 
|---|
| 1354 | /* If draw item is -1 (edit control) setup the item pointer */ | 
|---|
| 1355 | if (dis->itemID == 0xffffffff) { | 
|---|
| 1356 | item = infoPtr->edit; | 
|---|
| 1357 |  | 
|---|
| 1358 | if (infoPtr->hwndEdit) { | 
|---|
| 1359 | INT len; | 
|---|
| 1360 |  | 
|---|
| 1361 | /* free previous text of edit item */ | 
|---|
| 1362 | COMBOEX_FreeText(item); | 
|---|
| 1363 | item->mask &= ~CBEIF_TEXT; | 
|---|
| 1364 | if( (len = GetWindowTextLengthW(infoPtr->hwndEdit)) ) { | 
|---|
| 1365 | item->mask |= CBEIF_TEXT; | 
|---|
| 1366 | item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); | 
|---|
| 1367 | if (item->pszText) | 
|---|
| 1368 | GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1); | 
|---|
| 1369 |  | 
|---|
| 1370 | TRACE("edit control hwndEdit=%p, text len=%d str=%s\n", | 
|---|
| 1371 | infoPtr->hwndEdit, len, debugstr_txt(item->pszText)); | 
|---|
| 1372 | } | 
|---|
| 1373 | } | 
|---|
| 1374 | } | 
|---|
| 1375 |  | 
|---|
| 1376 |  | 
|---|
| 1377 | /* if the item pointer is not set, then get the data and locate it */ | 
|---|
| 1378 | if (!item) { | 
|---|
| 1379 | item = get_item_data(infoPtr, dis->itemID); | 
|---|
| 1380 | if (item == (CBE_ITEMDATA *)CB_ERR) { | 
|---|
| 1381 | ERR("invalid item for id %d \n", dis->itemID); | 
|---|
| 1382 | return 0; | 
|---|
| 1383 | } | 
|---|
| 1384 | } | 
|---|
| 1385 |  | 
|---|
| 1386 | if (TRACE_ON(comboex)) COMBOEX_DumpItem (item); | 
|---|
| 1387 |  | 
|---|
| 1388 | xbase = CBE_STARTOFFSET; | 
|---|
| 1389 | if ((item->mask & CBEIF_INDENT) && (dis->itemState & ODS_COMBOEXLBOX)) { | 
|---|
| 1390 | INT indent = item->iIndent; | 
|---|
| 1391 | if (indent == I_INDENTCALLBACK) { | 
|---|
| 1392 | NMCOMBOBOXEXW nmce; | 
|---|
| 1393 | ZeroMemory(&nmce, sizeof(nmce)); | 
|---|
| 1394 | nmce.ceItem.mask = CBEIF_INDENT; | 
|---|
| 1395 | nmce.ceItem.lParam = item->lParam; | 
|---|
| 1396 | COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); | 
|---|
| 1397 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) | 
|---|
| 1398 | item->iIndent = nmce.ceItem.iIndent; | 
|---|
| 1399 | indent = nmce.ceItem.iIndent; | 
|---|
| 1400 | } | 
|---|
| 1401 | xbase += (indent * CBE_INDENT); | 
|---|
| 1402 | } | 
|---|
| 1403 |  | 
|---|
| 1404 | drawimage = -2; | 
|---|
| 1405 | drawstate = ILD_NORMAL; | 
|---|
| 1406 | if (item->mask & CBEIF_IMAGE) | 
|---|
| 1407 | drawimage = item->iImage; | 
|---|
| 1408 | if (dis->itemState & ODS_COMBOEXLBOX) { | 
|---|
| 1409 | /* drawing listbox entry */ | 
|---|
| 1410 | if (dis->itemState & ODS_SELECTED) { | 
|---|
| 1411 | if (item->mask & CBEIF_SELECTEDIMAGE) | 
|---|
| 1412 | drawimage = item->iSelectedImage; | 
|---|
| 1413 | drawstate = ILD_SELECTED; | 
|---|
| 1414 | } | 
|---|
| 1415 | } else { | 
|---|
| 1416 | /* drawing combo/edit entry */ | 
|---|
| 1417 | if (IsWindowVisible(infoPtr->hwndEdit)) { | 
|---|
| 1418 | /* if we have an edit control, the slave the | 
|---|
| 1419 | * selection state to the Edit focus state | 
|---|
| 1420 | */ | 
|---|
| 1421 | if (infoPtr->flags & WCBE_EDITFOCUSED) { | 
|---|
| 1422 | if (item->mask & CBEIF_SELECTEDIMAGE) | 
|---|
| 1423 | drawimage = item->iSelectedImage; | 
|---|
| 1424 | drawstate = ILD_SELECTED; | 
|---|
| 1425 | } | 
|---|
| 1426 | } else { | 
|---|
| 1427 | /* if we don't have an edit control, use | 
|---|
| 1428 | * the requested state. | 
|---|
| 1429 | */ | 
|---|
| 1430 | if (dis->itemState & ODS_SELECTED) { | 
|---|
| 1431 | if (item->mask & CBEIF_SELECTEDIMAGE) | 
|---|
| 1432 | drawimage = item->iSelectedImage; | 
|---|
| 1433 | drawstate = ILD_SELECTED; | 
|---|
| 1434 | } | 
|---|
| 1435 | } | 
|---|
| 1436 | } | 
|---|
| 1437 |  | 
|---|
| 1438 | if (infoPtr->himl && !(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGEINDENT)) { | 
|---|
| 1439 | IMAGEINFO iinfo; | 
|---|
| 1440 | iinfo.rcImage.left = iinfo.rcImage.right = 0; | 
|---|
| 1441 | ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); | 
|---|
| 1442 | xioff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; | 
|---|
| 1443 | }  else xioff = 0; | 
|---|
| 1444 |  | 
|---|
| 1445 | /* setup pointer to text to be drawn */ | 
|---|
| 1446 | str = COMBOEX_GetText(infoPtr, item); | 
|---|
| 1447 | if (!str) str = nil; | 
|---|
| 1448 |  | 
|---|
| 1449 | len = strlenW (str); | 
|---|
| 1450 | GetTextExtentPoint32W (dis->hDC, str, len, &txtsize); | 
|---|
| 1451 |  | 
|---|
| 1452 | if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) { | 
|---|
| 1453 | int overlay = item->iOverlay; | 
|---|
| 1454 |  | 
|---|
| 1455 | if (drawimage == I_IMAGECALLBACK) { | 
|---|
| 1456 | NMCOMBOBOXEXW nmce; | 
|---|
| 1457 | ZeroMemory(&nmce, sizeof(nmce)); | 
|---|
| 1458 | nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE; | 
|---|
| 1459 | nmce.ceItem.lParam = item->lParam; | 
|---|
| 1460 | COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); | 
|---|
| 1461 | if (drawstate == ILD_NORMAL) { | 
|---|
| 1462 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage; | 
|---|
| 1463 | drawimage = nmce.ceItem.iImage; | 
|---|
| 1464 | } else if (drawstate == ILD_SELECTED) { | 
|---|
| 1465 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iSelectedImage = nmce.ceItem.iSelectedImage; | 
|---|
| 1466 | drawimage =  nmce.ceItem.iSelectedImage; | 
|---|
| 1467 | } else ERR("Bad draw state = %d\n", drawstate); | 
|---|
| 1468 | } | 
|---|
| 1469 |  | 
|---|
| 1470 | if (overlay == I_IMAGECALLBACK) { | 
|---|
| 1471 | NMCOMBOBOXEXW nmce; | 
|---|
| 1472 | ZeroMemory(&nmce, sizeof(nmce)); | 
|---|
| 1473 | nmce.ceItem.mask = CBEIF_OVERLAY; | 
|---|
| 1474 | nmce.ceItem.lParam = item->lParam; | 
|---|
| 1475 | COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce); | 
|---|
| 1476 | if (nmce.ceItem.mask & CBEIF_DI_SETITEM) | 
|---|
| 1477 | item->iOverlay = nmce.ceItem.iOverlay; | 
|---|
| 1478 | overlay = nmce.ceItem.iOverlay; | 
|---|
| 1479 | } | 
|---|
| 1480 |  | 
|---|
| 1481 | if (drawimage >= 0 && | 
|---|
| 1482 | !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) { | 
|---|
| 1483 | if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1); | 
|---|
| 1484 | ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top, | 
|---|
| 1485 | drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0)); | 
|---|
| 1486 | } | 
|---|
| 1487 |  | 
|---|
| 1488 | /* now draw the text */ | 
|---|
| 1489 | if (!IsWindowVisible (infoPtr->hwndEdit)) { | 
|---|
| 1490 | nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ? | 
|---|
| 1491 | COLOR_HIGHLIGHT : COLOR_WINDOW); | 
|---|
| 1492 | bkc = SetBkColor (dis->hDC, nbkc); | 
|---|
| 1493 | ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ? | 
|---|
| 1494 | COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT); | 
|---|
| 1495 | txc = SetTextColor (dis->hDC, ntxc); | 
|---|
| 1496 | x = xbase + xioff; | 
|---|
| 1497 | y = dis->rcItem.top + | 
|---|
| 1498 | (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2; | 
|---|
| 1499 | rect.left = x; | 
|---|
| 1500 | rect.right = x + txtsize.cx; | 
|---|
| 1501 | rect.top = dis->rcItem.top + 1; | 
|---|
| 1502 | rect.bottom = dis->rcItem.bottom - 1; | 
|---|
| 1503 | TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n", | 
|---|
| 1504 | dis->itemID, rect.left, rect.top, rect.right, rect.bottom); | 
|---|
| 1505 | ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED, | 
|---|
| 1506 | &rect, str, len, 0); | 
|---|
| 1507 | SetBkColor (dis->hDC, bkc); | 
|---|
| 1508 | SetTextColor (dis->hDC, txc); | 
|---|
| 1509 | } | 
|---|
| 1510 | } | 
|---|
| 1511 |  | 
|---|
| 1512 | if (dis->itemAction & ODA_FOCUS) { | 
|---|
| 1513 | rect.left = xbase + xioff - 1; | 
|---|
| 1514 | rect.right = rect.left + txtsize.cx + 2; | 
|---|
| 1515 | rect.top = dis->rcItem.top; | 
|---|
| 1516 | rect.bottom = dis->rcItem.bottom; | 
|---|
| 1517 | DrawFocusRect(dis->hDC, &rect); | 
|---|
| 1518 | } | 
|---|
| 1519 |  | 
|---|
| 1520 | return 0; | 
|---|
| 1521 | } | 
|---|
| 1522 |  | 
|---|
| 1523 |  | 
|---|
| 1524 | static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr) | 
|---|
| 1525 | { | 
|---|
| 1526 | if (infoPtr->hwndCombo) | 
|---|
| 1527 | DestroyWindow (infoPtr->hwndCombo); | 
|---|
| 1528 |  | 
|---|
| 1529 | if (infoPtr->edit) { | 
|---|
| 1530 | COMCTL32_Free (infoPtr->edit); | 
|---|
| 1531 | infoPtr->edit = 0; | 
|---|
| 1532 | } | 
|---|
| 1533 |  | 
|---|
| 1534 | if (infoPtr->items) { | 
|---|
| 1535 | CBE_ITEMDATA *item, *next; | 
|---|
| 1536 |  | 
|---|
| 1537 | item = infoPtr->items; | 
|---|
| 1538 | while (item) { | 
|---|
| 1539 | next = (CBE_ITEMDATA *)item->next; | 
|---|
| 1540 | COMBOEX_FreeText (item); | 
|---|
| 1541 | COMCTL32_Free (item); | 
|---|
| 1542 | item = next; | 
|---|
| 1543 | } | 
|---|
| 1544 | infoPtr->items = 0; | 
|---|
| 1545 | } | 
|---|
| 1546 |  | 
|---|
| 1547 | if (infoPtr->defaultFont) | 
|---|
| 1548 | DeleteObject (infoPtr->defaultFont); | 
|---|
| 1549 |  | 
|---|
| 1550 | /* free comboex info data */ | 
|---|
| 1551 | COMCTL32_Free (infoPtr); | 
|---|
| 1552 | SetWindowLongW (infoPtr->hwndSelf, 0, 0); | 
|---|
| 1553 | return 0; | 
|---|
| 1554 | } | 
|---|
| 1555 |  | 
|---|
| 1556 |  | 
|---|
| 1557 | static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis) | 
|---|
| 1558 | { | 
|---|
| 1559 | SIZE mysize; | 
|---|
| 1560 | HDC hdc; | 
|---|
| 1561 |  | 
|---|
| 1562 | hdc = GetDC (0); | 
|---|
| 1563 | GetTextExtentPointA (hdc, "W", 1, &mysize); | 
|---|
| 1564 | ReleaseDC (0, hdc); | 
|---|
| 1565 | mis->itemHeight = mysize.cy + CBE_EXTRA; | 
|---|
| 1566 |  | 
|---|
| 1567 | TRACE("adjusted height hwnd=%p, height=%d\n", | 
|---|
| 1568 | infoPtr->hwndSelf, mis->itemHeight); | 
|---|
| 1569 |  | 
|---|
| 1570 | return 0; | 
|---|
| 1571 | } | 
|---|
| 1572 |  | 
|---|
| 1573 |  | 
|---|
| 1574 | static LRESULT COMBOEX_NCCreate (HWND hwnd) | 
|---|
| 1575 | { | 
|---|
| 1576 | /* WARNING: The COMBOEX_INFO structure is not yet created */ | 
|---|
| 1577 | DWORD oldstyle, newstyle; | 
|---|
| 1578 |  | 
|---|
| 1579 | oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE); | 
|---|
| 1580 | newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL); | 
|---|
| 1581 | if (newstyle != oldstyle) { | 
|---|
| 1582 | TRACE("req style %08lx, reseting style %08lx\n", | 
|---|
| 1583 | oldstyle, newstyle); | 
|---|
| 1584 | SetWindowLongW (hwnd, GWL_STYLE, newstyle); | 
|---|
| 1585 | } | 
|---|
| 1586 | return 1; | 
|---|
| 1587 | } | 
|---|
| 1588 |  | 
|---|
| 1589 |  | 
|---|
| 1590 | static LRESULT COMBOEX_NotifyFormat (COMBOEX_INFO *infoPtr, LPARAM lParam) | 
|---|
| 1591 | { | 
|---|
| 1592 | if (lParam == NF_REQUERY) { | 
|---|
| 1593 | INT i = SendMessageW(GetParent (infoPtr->hwndSelf), | 
|---|
| 1594 | WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY); | 
|---|
| 1595 | infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; | 
|---|
| 1596 | } | 
|---|
| 1597 | return infoPtr->NtfUnicode ? NFR_UNICODE : NFR_ANSI; | 
|---|
| 1598 | } | 
|---|
| 1599 |  | 
|---|
| 1600 |  | 
|---|
| 1601 | static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height) | 
|---|
| 1602 | { | 
|---|
| 1603 | TRACE("(width=%d, height=%d)\n", width, height); | 
|---|
| 1604 |  | 
|---|
| 1605 | MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE); | 
|---|
| 1606 |  | 
|---|
| 1607 | COMBOEX_AdjustEditPos (infoPtr); | 
|---|
| 1608 |  | 
|---|
| 1609 | return 0; | 
|---|
| 1610 | } | 
|---|
| 1611 |  | 
|---|
| 1612 |  | 
|---|
| 1613 | static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp) | 
|---|
| 1614 | { | 
|---|
| 1615 | RECT cbx_wrect, cbx_crect, cb_wrect; | 
|---|
| 1616 | UINT width, height; | 
|---|
| 1617 |  | 
|---|
| 1618 | GetWindowRect (infoPtr->hwndSelf, &cbx_wrect); | 
|---|
| 1619 | GetClientRect (infoPtr->hwndSelf, &cbx_crect); | 
|---|
| 1620 | GetWindowRect (infoPtr->hwndCombo, &cb_wrect); | 
|---|
| 1621 |  | 
|---|
| 1622 | /* width is winpos value + border width of comboex */ | 
|---|
| 1623 | width = wp->cx | 
|---|
| 1624 | + (cbx_wrect.right-cbx_wrect.left) | 
|---|
| 1625 | - (cbx_crect.right-cbx_crect.left); | 
|---|
| 1626 |  | 
|---|
| 1627 | TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n", | 
|---|
| 1628 | wp->x, wp->y, wp->cx, wp->cy, wp->flags); | 
|---|
| 1629 | TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n", | 
|---|
| 1630 | cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom, | 
|---|
| 1631 | cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom); | 
|---|
| 1632 | TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n", | 
|---|
| 1633 | cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom, | 
|---|
| 1634 | width, cb_wrect.bottom-cb_wrect.top); | 
|---|
| 1635 |  | 
|---|
| 1636 | if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0, | 
|---|
| 1637 | width, | 
|---|
| 1638 | cb_wrect.bottom-cb_wrect.top, | 
|---|
| 1639 | SWP_NOACTIVATE); | 
|---|
| 1640 |  | 
|---|
| 1641 | GetWindowRect (infoPtr->hwndCombo, &cb_wrect); | 
|---|
| 1642 |  | 
|---|
| 1643 | /* height is combo window height plus border width of comboex */ | 
|---|
| 1644 | height =   (cb_wrect.bottom-cb_wrect.top) | 
|---|
| 1645 | + (cbx_wrect.bottom-cbx_wrect.top) | 
|---|
| 1646 | - (cbx_crect.bottom-cbx_crect.top); | 
|---|
| 1647 | if (wp->cy < height) wp->cy = height; | 
|---|
| 1648 | if (infoPtr->hwndEdit) { | 
|---|
| 1649 | COMBOEX_AdjustEditPos (infoPtr); | 
|---|
| 1650 | InvalidateRect (infoPtr->hwndCombo, 0, TRUE); | 
|---|
| 1651 | } | 
|---|
| 1652 |  | 
|---|
| 1653 | return 0; | 
|---|
| 1654 | } | 
|---|
| 1655 |  | 
|---|
| 1656 | static inline int is_delimiter(WCHAR c) | 
|---|
| 1657 | { | 
|---|
| 1658 | switch(c) { | 
|---|
| 1659 | case '/': | 
|---|
| 1660 | case '\\': | 
|---|
| 1661 | case '.': | 
|---|
| 1662 | return TRUE; | 
|---|
| 1663 | } | 
|---|
| 1664 | return FALSE; | 
|---|
| 1665 | } | 
|---|
| 1666 |  | 
|---|
| 1667 | static int CALLBACK | 
|---|
| 1668 | COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code) | 
|---|
| 1669 | { | 
|---|
| 1670 | if (code == WB_ISDELIMITER) { | 
|---|
| 1671 | return is_delimiter(lpch[ichCurrent]); | 
|---|
| 1672 | } else { | 
|---|
| 1673 | int dir = (code == WB_LEFT) ? -1 : 1; | 
|---|
| 1674 | for(; 0 <= ichCurrent && ichCurrent < cch; ichCurrent += dir) | 
|---|
| 1675 | if (is_delimiter(lpch[ichCurrent])) return ichCurrent; | 
|---|
| 1676 | } | 
|---|
| 1677 | return ichCurrent; | 
|---|
| 1678 | } | 
|---|
| 1679 |  | 
|---|
| 1680 | static LRESULT WINAPI | 
|---|
| 1681 | COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1682 | { | 
|---|
| 1683 | HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); | 
|---|
| 1684 | COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); | 
|---|
| 1685 | NMCBEENDEDITW cbeend; | 
|---|
| 1686 | WCHAR edit_text[260]; | 
|---|
| 1687 | COLORREF obkc; | 
|---|
| 1688 | HDC hDC; | 
|---|
| 1689 | RECT rect; | 
|---|
| 1690 | LRESULT lret; | 
|---|
| 1691 |  | 
|---|
| 1692 | TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", | 
|---|
| 1693 | hwnd, uMsg, wParam, lParam, infoPtr); | 
|---|
| 1694 |  | 
|---|
| 1695 | if (!infoPtr) return 0; | 
|---|
| 1696 |  | 
|---|
| 1697 | switch (uMsg) | 
|---|
| 1698 | { | 
|---|
| 1699 |  | 
|---|
| 1700 | case WM_CHAR: | 
|---|
| 1701 | /* handle (ignore) the return character */ | 
|---|
| 1702 | if (wParam == VK_RETURN) return 0; | 
|---|
| 1703 | /* all other characters pass into the real Edit */ | 
|---|
| 1704 | return CallWindowProcW (infoPtr->prevEditWndProc, | 
|---|
| 1705 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1706 |  | 
|---|
| 1707 | case WM_ERASEBKGND: | 
|---|
| 1708 | /* | 
|---|
| 1709 | * The following was determined by traces of the native | 
|---|
| 1710 | */ | 
|---|
| 1711 | hDC = (HDC) wParam; | 
|---|
| 1712 | obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW)); | 
|---|
| 1713 | GetClientRect (hwnd, &rect); | 
|---|
| 1714 | TRACE("erasing (%d,%d)-(%d,%d)\n", | 
|---|
| 1715 | rect.left, rect.top, rect.right, rect.bottom); | 
|---|
| 1716 | ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); | 
|---|
| 1717 | SetBkColor (hDC, obkc); | 
|---|
| 1718 | return CallWindowProcW (infoPtr->prevEditWndProc, | 
|---|
| 1719 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1720 |  | 
|---|
| 1721 | case WM_KEYDOWN: { | 
|---|
| 1722 | INT oldItem, selected, step = 1; | 
|---|
| 1723 | CBE_ITEMDATA *item; | 
|---|
| 1724 |  | 
|---|
| 1725 | switch ((INT)wParam) | 
|---|
| 1726 | { | 
|---|
| 1727 | case VK_ESCAPE: | 
|---|
| 1728 | /* native version seems to do following for COMBOEX */ | 
|---|
| 1729 | /* | 
|---|
| 1730 | *   GetWindowTextA(Edit,&?, 0x104)             x | 
|---|
| 1731 | *   CB_GETCURSEL to Combo rets -1              x | 
|---|
| 1732 | *   WM_NOTIFY to COMBOEX parent (rebar)        x | 
|---|
| 1733 | *     (CBEN_ENDEDIT{A|W} | 
|---|
| 1734 | *      fChanged = FALSE                        x | 
|---|
| 1735 | *      inewSelection = -1                      x | 
|---|
| 1736 | *      txt="www.hoho"                          x | 
|---|
| 1737 | *      iWhy = 3                                x | 
|---|
| 1738 | *   CB_GETCURSEL to Combo rets -1              x | 
|---|
| 1739 | *   InvalidateRect(Combo, 0)                   x | 
|---|
| 1740 | *   WM_SETTEXT to Edit                         x | 
|---|
| 1741 | *   EM_SETSEL to Edit (0,0)                    x | 
|---|
| 1742 | *   EM_SETSEL to Edit (0,-1)                   x | 
|---|
| 1743 | *   RedrawWindow(Combo, 0, 0, 5)               x | 
|---|
| 1744 | */ | 
|---|
| 1745 | TRACE("special code for VK_ESCAPE\n"); | 
|---|
| 1746 |  | 
|---|
| 1747 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); | 
|---|
| 1748 |  | 
|---|
| 1749 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); | 
|---|
| 1750 | cbeend.fChanged = FALSE; | 
|---|
| 1751 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, | 
|---|
| 1752 | CB_GETCURSEL, 0, 0); | 
|---|
| 1753 | cbeend.iWhy = CBENF_ESCAPE; | 
|---|
| 1754 |  | 
|---|
| 1755 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0; | 
|---|
| 1756 | oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); | 
|---|
| 1757 | InvalidateRect (infoPtr->hwndCombo, 0, 0); | 
|---|
| 1758 | if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) { | 
|---|
| 1759 | ERR("item %d not found. Problem!\n", oldItem); | 
|---|
| 1760 | break; | 
|---|
| 1761 | } | 
|---|
| 1762 | infoPtr->selected = oldItem; | 
|---|
| 1763 | COMBOEX_SetEditText (infoPtr, item); | 
|---|
| 1764 | RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | | 
|---|
| 1765 | RDW_INVALIDATE); | 
|---|
| 1766 | break; | 
|---|
| 1767 |  | 
|---|
| 1768 | case VK_RETURN: | 
|---|
| 1769 | /* native version seems to do following for COMBOEX */ | 
|---|
| 1770 | /* | 
|---|
| 1771 | *   GetWindowTextA(Edit,&?, 0x104)             x | 
|---|
| 1772 | *   CB_GETCURSEL to Combo  rets -1             x | 
|---|
| 1773 | *   CB_GETCOUNT to Combo  rets 0 | 
|---|
| 1774 | *   if >0 loop | 
|---|
| 1775 | *       CB_GETITEMDATA to match | 
|---|
| 1776 | * *** above 3 lines simulated by FindItem      x | 
|---|
| 1777 | *   WM_NOTIFY to COMBOEX parent (rebar)        x | 
|---|
| 1778 | *     (CBEN_ENDEDIT{A|W}                       x | 
|---|
| 1779 | *        fChanged = TRUE (-1)                  x | 
|---|
| 1780 | *        iNewSelection = -1 or selected        x | 
|---|
| 1781 | *        txt=                                  x | 
|---|
| 1782 | *        iWhy = 2 (CBENF_RETURN)               x | 
|---|
| 1783 | *   CB_GETCURSEL to Combo  rets -1             x | 
|---|
| 1784 | *   if -1 send CB_SETCURSEL to Combo -1        x | 
|---|
| 1785 | *   InvalidateRect(Combo, 0, 0)                x | 
|---|
| 1786 | *   SetFocus(Edit)                             x | 
|---|
| 1787 | *   CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001) | 
|---|
| 1788 | */ | 
|---|
| 1789 |  | 
|---|
| 1790 | TRACE("special code for VK_RETURN\n"); | 
|---|
| 1791 |  | 
|---|
| 1792 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); | 
|---|
| 1793 |  | 
|---|
| 1794 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); | 
|---|
| 1795 | selected = SendMessageW (infoPtr->hwndCombo, | 
|---|
| 1796 | CB_GETCURSEL, 0, 0); | 
|---|
| 1797 |  | 
|---|
| 1798 | if (selected != -1) { | 
|---|
| 1799 | cmp_func_t cmptext = get_cmp_func(infoPtr); | 
|---|
| 1800 | item = COMBOEX_FindItem (infoPtr, selected); | 
|---|
| 1801 | TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n", | 
|---|
| 1802 | selected, debugstr_txt(item->pszText)); | 
|---|
| 1803 | TRACE("handling VK_RETURN, edittext=%s\n", | 
|---|
| 1804 | debugstr_w(edit_text)); | 
|---|
| 1805 | if (cmptext (COMBOEX_GetText(infoPtr, item), edit_text)) { | 
|---|
| 1806 | /* strings not equal -- indicate edit has changed */ | 
|---|
| 1807 | selected = -1; | 
|---|
| 1808 | } | 
|---|
| 1809 | } | 
|---|
| 1810 |  | 
|---|
| 1811 | cbeend.iNewSelection = selected; | 
|---|
| 1812 | cbeend.fChanged = TRUE; | 
|---|
| 1813 | cbeend.iWhy = CBENF_RETURN; | 
|---|
| 1814 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) { | 
|---|
| 1815 | /* abort the change, restore previous */ | 
|---|
| 1816 | TRACE("Notify requested abort of change\n"); | 
|---|
| 1817 | COMBOEX_SetEditText (infoPtr, infoPtr->edit); | 
|---|
| 1818 | RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | | 
|---|
| 1819 | RDW_INVALIDATE); | 
|---|
| 1820 | return 0; | 
|---|
| 1821 | } | 
|---|
| 1822 | oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0); | 
|---|
| 1823 | if (oldItem != -1) { | 
|---|
| 1824 | /* if something is selected, then deselect it */ | 
|---|
| 1825 | SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, | 
|---|
| 1826 | (WPARAM)-1, 0); | 
|---|
| 1827 | } | 
|---|
| 1828 | InvalidateRect (infoPtr->hwndCombo, 0, 0); | 
|---|
| 1829 | SetFocus(infoPtr->hwndEdit); | 
|---|
| 1830 | break; | 
|---|
| 1831 |  | 
|---|
| 1832 | case VK_UP: | 
|---|
| 1833 | step = -1; | 
|---|
| 1834 | case VK_DOWN: | 
|---|
| 1835 | /* by default, step is 1 */ | 
|---|
| 1836 | oldItem = SendMessageW (infoPtr->hwndSelf, CB_GETCURSEL, 0, 0); | 
|---|
| 1837 | if (oldItem >= 0 && oldItem + step >= 0) | 
|---|
| 1838 | SendMessageW (infoPtr->hwndSelf, CB_SETCURSEL, oldItem + step, 0); | 
|---|
| 1839 | return 0; | 
|---|
| 1840 | default: | 
|---|
| 1841 | return CallWindowProcW (infoPtr->prevEditWndProc, | 
|---|
| 1842 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1843 | } | 
|---|
| 1844 | return 0; | 
|---|
| 1845 | } | 
|---|
| 1846 |  | 
|---|
| 1847 | case WM_SETFOCUS: | 
|---|
| 1848 | /* remember the focus to set state of icon */ | 
|---|
| 1849 | lret = CallWindowProcW (infoPtr->prevEditWndProc, | 
|---|
| 1850 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1851 | infoPtr->flags |= WCBE_EDITFOCUSED; | 
|---|
| 1852 | return lret; | 
|---|
| 1853 |  | 
|---|
| 1854 | case WM_KILLFOCUS: | 
|---|
| 1855 | /* | 
|---|
| 1856 | * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS | 
|---|
| 1857 | */ | 
|---|
| 1858 | infoPtr->flags &= ~WCBE_EDITFOCUSED; | 
|---|
| 1859 | if (infoPtr->flags & WCBE_ACTEDIT) { | 
|---|
| 1860 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); | 
|---|
| 1861 |  | 
|---|
| 1862 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); | 
|---|
| 1863 | cbeend.fChanged = FALSE; | 
|---|
| 1864 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, | 
|---|
| 1865 | CB_GETCURSEL, 0, 0); | 
|---|
| 1866 | cbeend.iWhy = CBENF_KILLFOCUS; | 
|---|
| 1867 |  | 
|---|
| 1868 | COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text); | 
|---|
| 1869 | } | 
|---|
| 1870 | /* fall through */ | 
|---|
| 1871 |  | 
|---|
| 1872 | default: | 
|---|
| 1873 | return CallWindowProcW (infoPtr->prevEditWndProc, | 
|---|
| 1874 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1875 | } | 
|---|
| 1876 | return 0; | 
|---|
| 1877 | } | 
|---|
| 1878 |  | 
|---|
| 1879 |  | 
|---|
| 1880 | static LRESULT WINAPI | 
|---|
| 1881 | COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | 
|---|
| 1882 | { | 
|---|
| 1883 | HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); | 
|---|
| 1884 | COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); | 
|---|
| 1885 | NMCBEENDEDITW cbeend; | 
|---|
| 1886 | NMMOUSE nmmse; | 
|---|
| 1887 | COLORREF obkc; | 
|---|
| 1888 | HDC hDC; | 
|---|
| 1889 | HWND focusedhwnd; | 
|---|
| 1890 | RECT rect; | 
|---|
| 1891 | POINT pt; | 
|---|
| 1892 | WCHAR edit_text[260]; | 
|---|
| 1893 |  | 
|---|
| 1894 | TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", | 
|---|
| 1895 | hwnd, uMsg, wParam, lParam, infoPtr); | 
|---|
| 1896 |  | 
|---|
| 1897 | if (!infoPtr) return 0; | 
|---|
| 1898 |  | 
|---|
| 1899 | switch (uMsg) | 
|---|
| 1900 | { | 
|---|
| 1901 |  | 
|---|
| 1902 | case WM_DRAWITEM: | 
|---|
| 1903 | /* | 
|---|
| 1904 | * The only way this message should come is from the | 
|---|
| 1905 | * child Listbox issuing the message. Flag this so | 
|---|
| 1906 | * that ComboEx knows this is listbox. | 
|---|
| 1907 | */ | 
|---|
| 1908 | ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX; | 
|---|
| 1909 | return CallWindowProcW (infoPtr->prevComboWndProc, | 
|---|
| 1910 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1911 |  | 
|---|
| 1912 | case WM_ERASEBKGND: | 
|---|
| 1913 | /* | 
|---|
| 1914 | * The following was determined by traces of the native | 
|---|
| 1915 | */ | 
|---|
| 1916 | hDC = (HDC) wParam; | 
|---|
| 1917 | obkc = SetBkColor (hDC, GetSysColor (COLOR_WINDOW)); | 
|---|
| 1918 | GetClientRect (hwnd, &rect); | 
|---|
| 1919 | TRACE("erasing (%d,%d)-(%d,%d)\n", | 
|---|
| 1920 | rect.left, rect.top, rect.right, rect.bottom); | 
|---|
| 1921 | ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); | 
|---|
| 1922 | SetBkColor (hDC, obkc); | 
|---|
| 1923 | return CallWindowProcW (infoPtr->prevComboWndProc, | 
|---|
| 1924 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1925 |  | 
|---|
| 1926 | case WM_SETCURSOR: | 
|---|
| 1927 | /* | 
|---|
| 1928 | *  WM_NOTIFY to comboex parent (rebar) | 
|---|
| 1929 | *   with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001 | 
|---|
| 1930 | *  CallWindowProc (previous) | 
|---|
| 1931 | */ | 
|---|
| 1932 | nmmse.dwItemSpec = 0; | 
|---|
| 1933 | nmmse.dwItemData = 0; | 
|---|
| 1934 | nmmse.pt.x = 0; | 
|---|
| 1935 | nmmse.pt.y = 0; | 
|---|
| 1936 | nmmse.dwHitInfo = lParam; | 
|---|
| 1937 | COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse); | 
|---|
| 1938 | return CallWindowProcW (infoPtr->prevComboWndProc, | 
|---|
| 1939 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1940 |  | 
|---|
| 1941 | case WM_LBUTTONDOWN: | 
|---|
| 1942 | GetClientRect (hwnd, &rect); | 
|---|
| 1943 | rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf, | 
|---|
| 1944 | CB_GETITEMHEIGHT, -1, 0); | 
|---|
| 1945 | rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL); | 
|---|
| 1946 | POINTSTOPOINT(pt, MAKEPOINTS(lParam)); | 
|---|
| 1947 | if (PtInRect(&rect, pt)) | 
|---|
| 1948 | return CallWindowProcW (infoPtr->prevComboWndProc, | 
|---|
| 1949 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1950 | infoPtr->flags |= WCBE_MOUSECAPTURED; | 
|---|
| 1951 | SetCapture(hwnd); | 
|---|
| 1952 | break; | 
|---|
| 1953 |  | 
|---|
| 1954 | case WM_LBUTTONUP: | 
|---|
| 1955 | if (!(infoPtr->flags & WCBE_MOUSECAPTURED)) | 
|---|
| 1956 | return CallWindowProcW (infoPtr->prevComboWndProc, | 
|---|
| 1957 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1958 | ReleaseCapture(); | 
|---|
| 1959 | infoPtr->flags &= ~WCBE_MOUSECAPTURED; | 
|---|
| 1960 | if (infoPtr->flags & WCBE_MOUSEDRAGGED) { | 
|---|
| 1961 | infoPtr->flags &= ~WCBE_MOUSEDRAGGED; | 
|---|
| 1962 | } else { | 
|---|
| 1963 | SendMessageW(hwnd, CB_SHOWDROPDOWN, TRUE, 0); | 
|---|
| 1964 | } | 
|---|
| 1965 | break; | 
|---|
| 1966 |  | 
|---|
| 1967 | case WM_MOUSEMOVE: | 
|---|
| 1968 | if ( (infoPtr->flags & WCBE_MOUSECAPTURED) && | 
|---|
| 1969 | !(infoPtr->flags & WCBE_MOUSEDRAGGED)) { | 
|---|
| 1970 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); | 
|---|
| 1971 | COMBOEX_NotifyDragBegin(infoPtr, edit_text); | 
|---|
| 1972 | infoPtr->flags |= WCBE_MOUSEDRAGGED; | 
|---|
| 1973 | } | 
|---|
| 1974 | return CallWindowProcW (infoPtr->prevComboWndProc, | 
|---|
| 1975 | hwnd, uMsg, wParam, lParam); | 
|---|
| 1976 |  | 
|---|
| 1977 | case WM_COMMAND: | 
|---|
| 1978 | switch (HIWORD(wParam)) { | 
|---|
| 1979 |  | 
|---|
| 1980 | case EN_UPDATE: | 
|---|
| 1981 | /* traces show that COMBOEX does not issue CBN_EDITUPDATE | 
|---|
| 1982 | * on the EN_UPDATE | 
|---|
| 1983 | */ | 
|---|
| 1984 | return 0; | 
|---|
| 1985 |  | 
|---|
| 1986 | case EN_KILLFOCUS: | 
|---|
| 1987 | /* | 
|---|
| 1988 | * Native does: | 
|---|
| 1989 | * | 
|---|
| 1990 | *  GetFocus() retns AA | 
|---|
| 1991 | *  GetWindowTextA(Edit) | 
|---|
| 1992 | *  CB_GETCURSEL(Combo) (got -1) | 
|---|
| 1993 | *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS | 
|---|
| 1994 | *  CB_GETCURSEL(Combo) (got -1) | 
|---|
| 1995 | *  InvalidateRect(Combo, 0, 0) | 
|---|
| 1996 | *  WM_KILLFOCUS(Combo, AA) | 
|---|
| 1997 | *  return 0; | 
|---|
| 1998 | */ | 
|---|
| 1999 | focusedhwnd = GetFocus(); | 
|---|
| 2000 | if (infoPtr->flags & WCBE_ACTEDIT) { | 
|---|
| 2001 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); | 
|---|
| 2002 | cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG); | 
|---|
| 2003 | cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo, | 
|---|
| 2004 | CB_GETCURSEL, 0, 0); | 
|---|
| 2005 | cbeend.iWhy = CBENF_KILLFOCUS; | 
|---|
| 2006 |  | 
|---|
| 2007 | infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG); | 
|---|
| 2008 | if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) return 0; | 
|---|
| 2009 | } | 
|---|
| 2010 | /* possible CB_GETCURSEL */ | 
|---|
| 2011 | InvalidateRect (infoPtr->hwndCombo, 0, 0); | 
|---|
| 2012 | if (focusedhwnd) | 
|---|
| 2013 | SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS, | 
|---|
| 2014 | (WPARAM)focusedhwnd, 0); | 
|---|
| 2015 | return 0; | 
|---|
| 2016 |  | 
|---|
| 2017 | case EN_SETFOCUS: { | 
|---|
| 2018 | /* | 
|---|
| 2019 | * For EN_SETFOCUS this issues the same calls and messages | 
|---|
| 2020 | *  as the native seems to do. | 
|---|
| 2021 | * | 
|---|
| 2022 | * for some cases however native does the following: | 
|---|
| 2023 | *   (noticed after SetFocus during LBUTTONDOWN on | 
|---|
| 2024 | *    on dropdown arrow) | 
|---|
| 2025 | *  WM_GETTEXTLENGTH (Edit); | 
|---|
| 2026 | *  WM_GETTEXT (Edit, len+1, str); | 
|---|
| 2027 | *  EM_SETSEL (Edit, 0, 0); | 
|---|
| 2028 | *  WM_GETTEXTLENGTH (Edit); | 
|---|
| 2029 | *  WM_GETTEXT (Edit, len+1, str); | 
|---|
| 2030 | *  EM_SETSEL (Edit, 0, len); | 
|---|
| 2031 | *  WM_NOTIFY (parent, CBEN_BEGINEDIT) | 
|---|
| 2032 | */ | 
|---|
| 2033 | NMHDR hdr; | 
|---|
| 2034 |  | 
|---|
| 2035 | SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0); | 
|---|
| 2036 | SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1); | 
|---|
| 2037 | COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr); | 
|---|
| 2038 | infoPtr->flags |= WCBE_ACTEDIT; | 
|---|
| 2039 | infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */ | 
|---|
| 2040 | return 0; | 
|---|
| 2041 | } | 
|---|
| 2042 |  | 
|---|
| 2043 | case EN_CHANGE: { | 
|---|
| 2044 | /* | 
|---|
| 2045 | * For EN_CHANGE this issues the same calls and messages | 
|---|
| 2046 | *  as the native seems to do. | 
|---|
| 2047 | */ | 
|---|
| 2048 | WCHAR edit_text[260]; | 
|---|
| 2049 | LPCWSTR lastwrk; | 
|---|
| 2050 | cmp_func_t cmptext = get_cmp_func(infoPtr); | 
|---|
| 2051 |  | 
|---|
| 2052 | INT selected = SendMessageW (infoPtr->hwndCombo, | 
|---|
| 2053 | CB_GETCURSEL, 0, 0); | 
|---|
| 2054 |  | 
|---|
| 2055 | /* lstrlenA( lastworkingURL ) */ | 
|---|
| 2056 |  | 
|---|
| 2057 | GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); | 
|---|
| 2058 | if (selected == -1) { | 
|---|
| 2059 | lastwrk = infoPtr->edit->pszText; | 
|---|
| 2060 | } | 
|---|
| 2061 | else { | 
|---|
| 2062 | CBE_ITEMDATA *item = COMBOEX_FindItem (infoPtr, selected); | 
|---|
| 2063 | lastwrk = COMBOEX_GetText(infoPtr, item); | 
|---|
| 2064 | } | 
|---|
| 2065 |  | 
|---|
| 2066 | TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n", | 
|---|
| 2067 | selected, debugstr_w(lastwrk)); | 
|---|
| 2068 | TRACE("handling EN_CHANGE, edittext=%s\n", | 
|---|
| 2069 | debugstr_w(edit_text)); | 
|---|
| 2070 |  | 
|---|
| 2071 | /* cmptext is between lastworkingURL and GetWindowText */ | 
|---|
| 2072 | if (cmptext (lastwrk, edit_text)) { | 
|---|
| 2073 | /* strings not equal -- indicate edit has changed */ | 
|---|
| 2074 | infoPtr->flags |= WCBE_EDITCHG; | 
|---|
| 2075 | } | 
|---|
| 2076 | SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND, | 
|---|
| 2077 | MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf), | 
|---|
| 2078 | CBN_EDITCHANGE), | 
|---|
| 2079 | (LPARAM)infoPtr->hwndSelf); | 
|---|
| 2080 | return 0; | 
|---|
| 2081 | } | 
|---|
| 2082 |  | 
|---|
| 2083 | case LBN_SELCHANGE: | 
|---|
| 2084 | /* | 
|---|
| 2085 | * Therefore from traces there is no additional code here | 
|---|
| 2086 | */ | 
|---|
| 2087 |  | 
|---|
| 2088 | /* | 
|---|
| 2089 | * Using native COMCTL32 gets the following: | 
|---|
| 2090 | *  1 == SHDOCVW.DLL  issues call/message | 
|---|
| 2091 | *  2 == COMCTL32.DLL  issues call/message | 
|---|
| 2092 | *  3 == WINE  issues call/message | 
|---|
| 2093 | * | 
|---|
| 2094 | * | 
|---|
| 2095 | * for LBN_SELCHANGE: | 
|---|
| 2096 | *    1  CB_GETCURSEL(ComboEx) | 
|---|
| 2097 | *    1  CB_GETDROPPEDSTATE(ComboEx) | 
|---|
| 2098 | *    1  CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE) | 
|---|
| 2099 | *    2  CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE) | 
|---|
| 2100 | **   call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE) | 
|---|
| 2101 | *    3  WM_COMMAND(ComboEx, CBN_SELENDOK) | 
|---|
| 2102 | *      WM_USER+49(ComboLB, 1,0)  <=============!!!!!!!!!!! | 
|---|
| 2103 | *    3  ShowWindow(ComboLB, SW_HIDE) | 
|---|
| 2104 | *    3  RedrawWindow(Combo,  RDW_UPDATENOW) | 
|---|
| 2105 | *    3  WM_COMMAND(ComboEX, CBN_CLOSEUP) | 
|---|
| 2106 | **   end of CBRollUp | 
|---|
| 2107 | *    3  WM_COMMAND(ComboEx, CBN_SELCHANGE)  (echo to parent) | 
|---|
| 2108 | *    ?  LB_GETCURSEL              <==| | 
|---|
| 2109 | *    ?  LB_GETTEXTLEN                | | 
|---|
| 2110 | *    ?  LB_GETTEXT                   | Needs to be added to | 
|---|
| 2111 | *    ?  WM_CTLCOLOREDIT(ComboEx)     | Combo processing | 
|---|
| 2112 | *    ?  LB_GETITEMDATA               | | 
|---|
| 2113 | *    ?  WM_DRAWITEM(ComboEx)      <==| | 
|---|
| 2114 | */ | 
|---|
| 2115 | default: | 
|---|
| 2116 | break; | 
|---|
| 2117 | }/* fall through */ | 
|---|
| 2118 | default: | 
|---|
| 2119 | return CallWindowProcW (infoPtr->prevComboWndProc, | 
|---|
| 2120 | hwnd, uMsg, wParam, lParam); | 
|---|
| 2121 | } | 
|---|
| 2122 | return 0; | 
|---|
| 2123 | } | 
|---|
| 2124 |  | 
|---|
| 2125 |  | 
|---|
| 2126 | static LRESULT WINAPI | 
|---|
| 2127 | COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) | 
|---|
| 2128 | { | 
|---|
| 2129 | COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); | 
|---|
| 2130 |  | 
|---|
| 2131 | TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam); | 
|---|
| 2132 |  | 
|---|
| 2133 | if (!infoPtr) { | 
|---|
| 2134 | if (uMsg == WM_CREATE) | 
|---|
| 2135 | return COMBOEX_Create (hwnd, (LPCREATESTRUCTA)lParam); | 
|---|
| 2136 | if (uMsg == WM_NCCREATE) | 
|---|
| 2137 | COMBOEX_NCCreate (hwnd); | 
|---|
| 2138 | return DefWindowProcW (hwnd, uMsg, wParam, lParam); | 
|---|
| 2139 | } | 
|---|
| 2140 |  | 
|---|
| 2141 | switch (uMsg) | 
|---|
| 2142 | { | 
|---|
| 2143 | case CBEM_DELETEITEM: | 
|---|
| 2144 | return COMBOEX_DeleteItem (infoPtr, wParam); | 
|---|
| 2145 |  | 
|---|
| 2146 | case CBEM_GETCOMBOCONTROL: | 
|---|
| 2147 | return (LRESULT)infoPtr->hwndCombo; | 
|---|
| 2148 |  | 
|---|
| 2149 | case CBEM_GETEDITCONTROL: | 
|---|
| 2150 | return (LRESULT)infoPtr->hwndEdit; | 
|---|
| 2151 |  | 
|---|
| 2152 | case CBEM_GETEXTENDEDSTYLE: | 
|---|
| 2153 | return infoPtr->dwExtStyle; | 
|---|
| 2154 |  | 
|---|
| 2155 | case CBEM_GETIMAGELIST: | 
|---|
| 2156 | return (LRESULT)infoPtr->himl; | 
|---|
| 2157 |  | 
|---|
| 2158 | case CBEM_GETITEMA: | 
|---|
| 2159 | return (LRESULT)COMBOEX_GetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); | 
|---|
| 2160 |  | 
|---|
| 2161 | case CBEM_GETITEMW: | 
|---|
| 2162 | return (LRESULT)COMBOEX_GetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); | 
|---|
| 2163 |  | 
|---|
| 2164 | case CBEM_GETUNICODEFORMAT: | 
|---|
| 2165 | return infoPtr->unicode; | 
|---|
| 2166 |  | 
|---|
| 2167 | case CBEM_HASEDITCHANGED: | 
|---|
| 2168 | return COMBOEX_HasEditChanged (infoPtr); | 
|---|
| 2169 |  | 
|---|
| 2170 | case CBEM_INSERTITEMA: | 
|---|
| 2171 | return COMBOEX_InsertItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); | 
|---|
| 2172 |  | 
|---|
| 2173 | case CBEM_INSERTITEMW: | 
|---|
| 2174 | return COMBOEX_InsertItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); | 
|---|
| 2175 |  | 
|---|
| 2176 | case CBEM_SETEXSTYLE: | 
|---|
| 2177 | case CBEM_SETEXTENDEDSTYLE: | 
|---|
| 2178 | return COMBOEX_SetExtendedStyle (infoPtr, (DWORD)wParam, (DWORD)lParam); | 
|---|
| 2179 |  | 
|---|
| 2180 | case CBEM_SETIMAGELIST: | 
|---|
| 2181 | return (LRESULT)COMBOEX_SetImageList (infoPtr, (HIMAGELIST)lParam); | 
|---|
| 2182 |  | 
|---|
| 2183 | case CBEM_SETITEMA: | 
|---|
| 2184 | return COMBOEX_SetItemA (infoPtr, (COMBOBOXEXITEMA *)lParam); | 
|---|
| 2185 |  | 
|---|
| 2186 | case CBEM_SETITEMW: | 
|---|
| 2187 | return COMBOEX_SetItemW (infoPtr, (COMBOBOXEXITEMW *)lParam); | 
|---|
| 2188 |  | 
|---|
| 2189 | case CBEM_SETUNICODEFORMAT: | 
|---|
| 2190 | return COMBOEX_SetUnicodeFormat (infoPtr, wParam); | 
|---|
| 2191 |  | 
|---|
| 2192 | /*case CBEM_SETWINDOWTHEME: | 
|---|
| 2193 | FIXME("CBEM_SETWINDOWTHEME: stub\n");*/ | 
|---|
| 2194 |  | 
|---|
| 2195 | case WM_SETTEXT: | 
|---|
| 2196 | case WM_GETTEXT: | 
|---|
| 2197 | return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam); | 
|---|
| 2198 |  | 
|---|
| 2199 | /*   Combo messages we are not sure if we need to process or just forward */ | 
|---|
| 2200 | case CB_GETDROPPEDCONTROLRECT: | 
|---|
| 2201 | case CB_GETITEMHEIGHT: | 
|---|
| 2202 | case CB_GETLBTEXT: | 
|---|
| 2203 | case CB_GETLBTEXTLEN: | 
|---|
| 2204 | case CB_GETEXTENDEDUI: | 
|---|
| 2205 | case CB_LIMITTEXT: | 
|---|
| 2206 | case CB_RESETCONTENT: | 
|---|
| 2207 | case CB_SELECTSTRING: | 
|---|
| 2208 |  | 
|---|
| 2209 | /*   Combo messages OK to just forward to the regular COMBO */ | 
|---|
| 2210 | case CB_GETCOUNT: | 
|---|
| 2211 | case CB_GETCURSEL: | 
|---|
| 2212 | case CB_GETDROPPEDSTATE: | 
|---|
| 2213 | case CB_SETDROPPEDWIDTH: | 
|---|
| 2214 | case CB_SETEXTENDEDUI: | 
|---|
| 2215 | case CB_SHOWDROPDOWN: | 
|---|
| 2216 | return SendMessageW (infoPtr->hwndCombo, uMsg, wParam, lParam); | 
|---|
| 2217 |  | 
|---|
| 2218 | /*   Combo messages we need to process specially */ | 
|---|
| 2219 | case CB_FINDSTRINGEXACT: | 
|---|
| 2220 | return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCWSTR)lParam); | 
|---|
| 2221 |  | 
|---|
| 2222 | case CB_GETITEMDATA: | 
|---|
| 2223 | return COMBOEX_GetItemData (infoPtr, (INT)wParam); | 
|---|
| 2224 |  | 
|---|
| 2225 | case CB_SETCURSEL: | 
|---|
| 2226 | return COMBOEX_SetCursel (infoPtr, (INT)wParam); | 
|---|
| 2227 |  | 
|---|
| 2228 | case CB_SETITEMDATA: | 
|---|
| 2229 | return COMBOEX_SetItemData (infoPtr, (INT)wParam, (DWORD)lParam); | 
|---|
| 2230 |  | 
|---|
| 2231 | case CB_SETITEMHEIGHT: | 
|---|
| 2232 | return COMBOEX_SetItemHeight (infoPtr, (INT)wParam, (UINT)lParam); | 
|---|
| 2233 |  | 
|---|
| 2234 |  | 
|---|
| 2235 |  | 
|---|
| 2236 | /*   Window messages passed to parent */ | 
|---|
| 2237 | case WM_COMMAND: | 
|---|
| 2238 | return COMBOEX_Command (infoPtr, wParam, lParam); | 
|---|
| 2239 |  | 
|---|
| 2240 | case WM_NOTIFY: | 
|---|
| 2241 | if (infoPtr->NtfUnicode) | 
|---|
| 2242 | return SendMessageW (GetParent (hwnd), uMsg, wParam, lParam); | 
|---|
| 2243 | else | 
|---|
| 2244 | return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); | 
|---|
| 2245 |  | 
|---|
| 2246 |  | 
|---|
| 2247 | /*   Window messages we need to process */ | 
|---|
| 2248 | case WM_DELETEITEM: | 
|---|
| 2249 | return COMBOEX_WM_DeleteItem (infoPtr, (DELETEITEMSTRUCT *)lParam); | 
|---|
| 2250 |  | 
|---|
| 2251 | case WM_DRAWITEM: | 
|---|
| 2252 | return COMBOEX_DrawItem (infoPtr, (DRAWITEMSTRUCT *)lParam); | 
|---|
| 2253 |  | 
|---|
| 2254 | case WM_DESTROY: | 
|---|
| 2255 | return COMBOEX_Destroy (infoPtr); | 
|---|
| 2256 |  | 
|---|
| 2257 | case WM_MEASUREITEM: | 
|---|
| 2258 | return COMBOEX_MeasureItem (infoPtr, (MEASUREITEMSTRUCT *)lParam); | 
|---|
| 2259 |  | 
|---|
| 2260 | case WM_NOTIFYFORMAT: | 
|---|
| 2261 | return COMBOEX_NotifyFormat (infoPtr, lParam); | 
|---|
| 2262 |  | 
|---|
| 2263 | case WM_SIZE: | 
|---|
| 2264 | return COMBOEX_Size (infoPtr, LOWORD(lParam), HIWORD(lParam)); | 
|---|
| 2265 |  | 
|---|
| 2266 | case WM_WINDOWPOSCHANGING: | 
|---|
| 2267 | return COMBOEX_WindowPosChanging (infoPtr, (WINDOWPOS *)lParam); | 
|---|
| 2268 |  | 
|---|
| 2269 | default: | 
|---|
| 2270 | if ((uMsg >= WM_USER) && (uMsg < WM_APP)) | 
|---|
| 2271 | ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam); | 
|---|
| 2272 | return DefWindowProcW (hwnd, uMsg, wParam, lParam); | 
|---|
| 2273 | } | 
|---|
| 2274 | return 0; | 
|---|
| 2275 | } | 
|---|
| 2276 |  | 
|---|
| 2277 |  | 
|---|
| 2278 | void COMBOEX_Register (void) | 
|---|
| 2279 | { | 
|---|
| 2280 | WNDCLASSW wndClass; | 
|---|
| 2281 |  | 
|---|
| 2282 | ZeroMemory (&wndClass, sizeof(WNDCLASSW)); | 
|---|
| 2283 | wndClass.style         = CS_GLOBALCLASS; | 
|---|
| 2284 | wndClass.lpfnWndProc   = (WNDPROC)COMBOEX_WindowProc; | 
|---|
| 2285 | wndClass.cbClsExtra    = 0; | 
|---|
| 2286 | wndClass.cbWndExtra    = sizeof(COMBOEX_INFO *); | 
|---|
| 2287 | wndClass.hCursor       = LoadCursorW (0, IDC_ARROWW); | 
|---|
| 2288 | wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); | 
|---|
| 2289 | wndClass.lpszClassName = WC_COMBOBOXEXW; | 
|---|
| 2290 |  | 
|---|
| 2291 | RegisterClassW (&wndClass); | 
|---|
| 2292 | } | 
|---|
| 2293 |  | 
|---|
| 2294 |  | 
|---|
| 2295 | void COMBOEX_Unregister (void) | 
|---|
| 2296 | { | 
|---|
| 2297 | UnregisterClassW (WC_COMBOBOXEXW, (HINSTANCE)NULL); | 
|---|
| 2298 | } | 
|---|