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