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