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