comctl32: Forward the focus to the edit control if it exists.
[wine/testsucceed.git] / dlls / comctl32 / tests / comboex.c
blob7cddbafdf08d17eb3a0afc43bd94bb98069746a6
1 /* Unit test suite for comboex control.
3 * Copyright 2005 Jason Edmeades
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <assert.h>
21 #include <windows.h>
22 #include <commctrl.h>
24 #include "wine/test.h"
25 #include "msg.h"
27 #define EDITBOX_SEQ_INDEX 0
28 #define NUM_MSG_SEQUENCES 1
30 #define EDITBOX_ID 0
32 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
34 static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
36 static HWND hComboExParentWnd;
37 static HINSTANCE hMainHinst;
38 static const char ComboExTestClass[] = "ComboExTestClass";
40 static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
42 #define MAX_CHARS 100
43 static char *textBuffer = NULL;
45 static BOOL received_end_edit = FALSE;
47 static HWND createComboEx(DWORD style) {
48 return CreateWindowExA(0, WC_COMBOBOXEXA, NULL, style, 0, 0, 300, 300,
49 hComboExParentWnd, NULL, hMainHinst, NULL);
52 static LONG addItem(HWND cbex, int idx, LPTSTR text) {
53 COMBOBOXEXITEM cbexItem;
54 memset(&cbexItem, 0x00, sizeof(cbexItem));
55 cbexItem.mask = CBEIF_TEXT;
56 cbexItem.iItem = idx;
57 cbexItem.pszText = text;
58 cbexItem.cchTextMax = 0;
59 return SendMessage(cbex, CBEM_INSERTITEM, 0, (LPARAM)&cbexItem);
62 static LONG setItem(HWND cbex, int idx, LPTSTR text) {
63 COMBOBOXEXITEM cbexItem;
64 memset(&cbexItem, 0x00, sizeof(cbexItem));
65 cbexItem.mask = CBEIF_TEXT;
66 cbexItem.iItem = idx;
67 cbexItem.pszText = text;
68 cbexItem.cchTextMax = 0;
69 return SendMessage(cbex, CBEM_SETITEM, 0, (LPARAM)&cbexItem);
72 static LONG delItem(HWND cbex, int idx) {
73 return SendMessage(cbex, CBEM_DELETEITEM, idx, 0);
76 static LONG getItem(HWND cbex, int idx, COMBOBOXEXITEM *cbItem) {
77 memset(cbItem, 0x00, sizeof(COMBOBOXEXITEM));
78 cbItem->mask = CBEIF_TEXT;
79 cbItem->pszText = textBuffer;
80 cbItem->iItem = idx;
81 cbItem->cchTextMax = 100;
82 return SendMessage(cbex, CBEM_GETITEM, 0, (LPARAM)cbItem);
85 static LRESULT WINAPI editbox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
87 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
88 static LONG defwndproc_counter = 0;
89 LRESULT ret;
90 struct message msg;
92 msg.message = message;
93 msg.flags = sent|wparam|lparam;
94 if (defwndproc_counter) msg.flags |= defwinproc;
95 msg.wParam = wParam;
96 msg.lParam = lParam;
97 msg.id = EDITBOX_ID;
99 if (message != WM_PAINT &&
100 message != WM_ERASEBKGND &&
101 message != WM_NCPAINT &&
102 message != WM_NCHITTEST &&
103 message != WM_GETTEXT &&
104 message != WM_GETICON &&
105 message != WM_DEVICECHANGE)
107 add_message(sequences, EDITBOX_SEQ_INDEX, &msg);
110 defwndproc_counter++;
111 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
112 defwndproc_counter--;
113 return ret;
116 static HWND subclass_editbox(HWND hwndComboEx)
118 WNDPROC oldproc;
119 HWND hwnd;
121 hwnd = (HWND)SendMessage(hwndComboEx, CBEM_GETEDITCONTROL, 0, 0);
122 oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
123 (LONG_PTR)editbox_subclass_proc);
124 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
126 return hwnd;
129 static void test_comboboxex(void) {
130 HWND myHwnd = 0;
131 LONG res = -1;
132 COMBOBOXEXITEM cbexItem;
133 static TCHAR first_item[] = {'F','i','r','s','t',' ','I','t','e','m',0},
134 second_item[] = {'S','e','c','o','n','d',' ','I','t','e','m',0},
135 third_item[] = {'T','h','i','r','d',' ','I','t','e','m',0},
136 middle_item[] = {'B','e','t','w','e','e','n',' ','F','i','r','s','t',' ','a','n','d',' ',
137 'S','e','c','o','n','d',' ','I','t','e','m','s',0},
138 replacement_item[] = {'B','e','t','w','e','e','n',' ','F','i','r','s','t',' ','a','n','d',' ',
139 'S','e','c','o','n','d',' ','I','t','e','m','s',0},
140 out_of_range_item[] = {'O','u','t',' ','o','f',' ','R','a','n','g','e',' ','I','t','e','m',0};
142 /* Allocate space for result */
143 textBuffer = HeapAlloc(GetProcessHeap(), 0, MAX_CHARS);
145 /* Basic comboboxex test */
146 myHwnd = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
148 /* Add items onto the end of the combobox */
149 res = addItem(myHwnd, -1, first_item);
150 ok(res == 0, "Adding simple item failed (%d)\n", res);
151 res = addItem(myHwnd, -1, second_item);
152 ok(res == 1, "Adding simple item failed (%d)\n", res);
153 res = addItem(myHwnd, 2, third_item);
154 ok(res == 2, "Adding simple item failed (%d)\n", res);
155 res = addItem(myHwnd, 1, middle_item);
156 ok(res == 1, "Inserting simple item failed (%d)\n", res);
158 /* Add an item completely out of range */
159 res = addItem(myHwnd, 99, out_of_range_item);
160 ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
161 res = addItem(myHwnd, 5, out_of_range_item);
162 ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
163 /* Removed: Causes traps on Windows XP
164 res = addItem(myHwnd, -2, "Out Of Range Item");
165 ok(res == -1, "Adding out of range worked unexpectedly (%ld)\n", res);
168 /* Get an item completely out of range */
169 res = getItem(myHwnd, 99, &cbexItem);
170 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
171 res = getItem(myHwnd, 4, &cbexItem);
172 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
173 res = getItem(myHwnd, -2, &cbexItem);
174 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
176 /* Get an item in range */
177 res = getItem(myHwnd, 0, &cbexItem);
178 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
179 ok(strcmp(first_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
181 res = getItem(myHwnd, 1, &cbexItem);
182 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
183 ok(strcmp(middle_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
185 res = getItem(myHwnd, 2, &cbexItem);
186 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
187 ok(strcmp(second_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
189 res = getItem(myHwnd, 3, &cbexItem);
190 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
191 ok(strcmp(third_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
193 /* Set an item completely out of range */
194 res = setItem(myHwnd, 99, replacement_item);
195 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
196 res = setItem(myHwnd, 4, replacement_item);
197 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
198 res = setItem(myHwnd, -2, replacement_item);
199 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
201 /* Set an item in range */
202 res = setItem(myHwnd, 0, replacement_item);
203 ok(res != 0, "Setting first item failed (%d)\n", res);
204 res = setItem(myHwnd, 3, replacement_item);
205 ok(res != 0, "Setting last item failed (%d)\n", res);
207 /* Remove items completely out of range (4 items in control at this point) */
208 res = delItem(myHwnd, -1);
209 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
210 res = delItem(myHwnd, 4);
211 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
213 /* Remove items in range (4 items in control at this point) */
214 res = delItem(myHwnd, 3);
215 ok(res == 3, "Deleting using out of range index failed (%d)\n", res);
216 res = delItem(myHwnd, 0);
217 ok(res == 2, "Deleting using out of range index failed (%d)\n", res);
218 res = delItem(myHwnd, 0);
219 ok(res == 1, "Deleting using out of range index failed (%d)\n", res);
220 res = delItem(myHwnd, 0);
221 ok(res == 0, "Deleting using out of range index failed (%d)\n", res);
223 /* Remove from an empty box */
224 res = delItem(myHwnd, 0);
225 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
228 /* Cleanup */
229 HeapFree(GetProcessHeap(), 0, textBuffer);
230 DestroyWindow(myHwnd);
233 static void test_WM_LBUTTONDOWN(void)
235 HWND hComboEx, hCombo, hEdit, hList;
236 COMBOBOXINFO cbInfo;
237 UINT x, y, item_height;
238 LRESULT result;
239 UINT i;
240 int idx;
241 RECT rect;
242 WCHAR buffer[3];
243 static const UINT choices[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
244 static const WCHAR stringFormat[] = {'%','2','d','\0'};
245 BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO);
247 pGetComboBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo");
248 if (!pGetComboBoxInfo){
249 win_skip("GetComboBoxInfo is not available\n");
250 return;
253 hComboEx = CreateWindowExA(0, WC_COMBOBOXEXA, NULL,
254 WS_VISIBLE|WS_CHILD|CBS_DROPDOWN, 0, 0, 200, 150,
255 hComboExParentWnd, NULL, hMainHinst, NULL);
257 for (i = 0; i < sizeof(choices)/sizeof(UINT); i++){
258 COMBOBOXEXITEMW cbexItem;
259 wsprintfW(buffer, stringFormat, choices[i]);
261 memset(&cbexItem, 0x00, sizeof(cbexItem));
262 cbexItem.mask = CBEIF_TEXT;
263 cbexItem.iItem = i;
264 cbexItem.pszText = buffer;
265 cbexItem.cchTextMax = 0;
266 ok(SendMessageW(hComboEx, CBEM_INSERTITEMW, 0, (LPARAM)&cbexItem) >= 0,
267 "Failed to add item %d\n", i);
270 hCombo = (HWND)SendMessage(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
271 hEdit = (HWND)SendMessage(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
273 cbInfo.cbSize = sizeof(COMBOBOXINFO);
274 result = pGetComboBoxInfo(hCombo, &cbInfo);
275 ok(result, "Failed to get combobox info structure. LastError=%d\n",
276 GetLastError());
277 hList = cbInfo.hwndList;
279 trace("hWnd=%p, hComboEx=%p, hCombo=%p, hList=%p, hEdit=%p\n",
280 hComboExParentWnd, hComboEx, hCombo, hList, hEdit);
281 ok(GetFocus() == hComboExParentWnd,
282 "Focus not on Main Window, instead on %p\n", GetFocus());
284 /* Click on the button to drop down the list */
285 x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
286 y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
287 result = SendMessage(hCombo, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
288 ok(result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
289 GetLastError());
290 ok(GetFocus() == hCombo ||
291 broken(GetFocus() != hCombo), /* win98 */
292 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
293 GetFocus());
294 ok(SendMessage(hComboEx, CB_GETDROPPEDSTATE, 0, 0),
295 "The dropdown list should have appeared after clicking the button.\n");
296 idx = SendMessage(hCombo, CB_GETTOPINDEX, 0, 0);
297 ok(idx == 0, "For TopIndex expected %d, got %d\n", 0, idx);
299 result = SendMessage(hCombo, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
300 ok(result, "WM_LBUTTONUP was not processed. LastError=%d\n",
301 GetLastError());
302 ok(GetFocus() == hCombo ||
303 broken(GetFocus() != hCombo), /* win98 */
304 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
305 GetFocus());
307 /* Click on the 5th item in the list */
308 item_height = SendMessage(hCombo, CB_GETITEMHEIGHT, 0, 0);
309 ok(GetClientRect(hList, &rect), "Failed to get list's client rect.\n");
310 x = rect.left + (rect.right-rect.left)/2;
311 y = item_height/2 + item_height*4;
312 result = SendMessage(hList, WM_MOUSEMOVE, 0, MAKELPARAM(x, y));
313 ok(!result, "WM_MOUSEMOVE was not processed. LastError=%d\n",
314 GetLastError());
315 ok(GetFocus() == hCombo ||
316 broken(GetFocus() != hCombo), /* win98 */
317 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
318 GetFocus());
320 result = SendMessage(hList, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
321 ok(!result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
322 GetLastError());
323 ok(GetFocus() == hCombo ||
324 broken(GetFocus() != hCombo), /* win98 */
325 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
326 GetFocus());
327 ok(SendMessage(hComboEx, CB_GETDROPPEDSTATE, 0, 0),
328 "The dropdown list should still be visible.\n");
330 result = SendMessage(hList, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
331 ok(!result, "WM_LBUTTONUP was not processed. LastError=%d\n",
332 GetLastError());
333 todo_wine ok(GetFocus() == hEdit ||
334 broken(GetFocus() == hCombo), /* win98 */
335 "Focus not on ComboBoxEx's Edit Control, instead on %p\n",
336 GetFocus());
338 result = SendMessage(hCombo, CB_GETDROPPEDSTATE, 0, 0);
339 ok(!result ||
340 broken(result != 0), /* win98 */
341 "The dropdown list should have been rolled up.\n");
342 idx = SendMessage(hComboEx, CB_GETCURSEL, 0, 0);
343 ok(idx == 4 ||
344 broken(idx == -1), /* win98 */
345 "Current Selection: expected %d, got %d\n", 4, idx);
346 ok(received_end_edit, "Expected to receive a CBEN_ENDEDIT message\n");
348 SetFocus( hComboExParentWnd );
349 ok( GetFocus() == hComboExParentWnd, "got %p\n", GetFocus() );
350 SetFocus( hComboEx );
351 ok( GetFocus() == hEdit, "got %p\n", GetFocus() );
353 DestroyWindow(hComboEx);
356 static void test_CB_GETLBTEXT(void)
358 HWND hCombo;
359 CHAR buff[1];
360 COMBOBOXEXITEMA item;
361 LRESULT ret;
363 hCombo = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
365 /* set text to null */
366 addItem(hCombo, 0, NULL);
368 buff[0] = 'a';
369 item.mask = CBEIF_TEXT;
370 item.iItem = 0;
371 item.pszText = buff;
372 item.cchTextMax = 1;
373 ret = SendMessage(hCombo, CBEM_GETITEMA, 0, (LPARAM)&item);
374 ok(ret != 0, "CBEM_GETITEM failed\n");
375 ok(buff[0] == 0, "\n");
377 ret = SendMessage(hCombo, CB_GETLBTEXTLEN, 0, 0);
378 ok(ret == 0, "Expected zero length\n");
380 ret = SendMessage(hCombo, CB_GETLBTEXTLEN, 0, 0);
381 ok(ret == 0, "Expected zero length\n");
383 buff[0] = 'a';
384 ret = SendMessage(hCombo, CB_GETLBTEXT, 0, (LPARAM)buff);
385 ok(ret == 0, "Expected zero length\n");
386 ok(buff[0] == 0, "Expected null terminator as a string, got %s\n", buff);
388 DestroyWindow(hCombo);
391 static void test_WM_WINDOWPOSCHANGING(void)
393 HWND hCombo;
394 WINDOWPOS wp;
395 RECT rect;
396 int combo_height;
397 int ret;
399 hCombo = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
400 ok(hCombo != NULL, "createComboEx failed\n");
401 ret = GetWindowRect(hCombo, &rect);
402 ok(ret, "GetWindowRect failed\n");
403 combo_height = rect.bottom - rect.top;
404 ok(combo_height > 0, "wrong combo height\n");
406 /* Test height > combo_height */
407 wp.x = rect.left;
408 wp.y = rect.top;
409 wp.cx = (rect.right - rect.left);
410 wp.cy = combo_height * 2;
411 wp.flags = 0;
412 wp.hwnd = hCombo;
413 wp.hwndInsertAfter = NULL;
415 ret = SendMessageA(hCombo, WM_WINDOWPOSCHANGING, 0, (LPARAM)&wp);
416 ok(ret == 0, "expected 0, got %x\n", ret);
417 ok(wp.cy == combo_height,
418 "Expected height %d, got %d\n", combo_height, wp.cy);
420 /* Test height < combo_height */
421 wp.x = rect.left;
422 wp.y = rect.top;
423 wp.cx = (rect.right - rect.left);
424 wp.cy = combo_height / 2;
425 wp.flags = 0;
426 wp.hwnd = hCombo;
427 wp.hwndInsertAfter = NULL;
429 ret = SendMessageA(hCombo, WM_WINDOWPOSCHANGING, 0, (LPARAM)&wp);
430 ok(ret == 0, "expected 0, got %x\n", ret);
431 ok(wp.cy == combo_height,
432 "Expected height %d, got %d\n", combo_height, wp.cy);
434 ret = DestroyWindow(hCombo);
435 ok(ret, "DestroyWindow failed\n");
438 static LRESULT ComboExTestOnNotify(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
440 NMHDR *hdr = (NMHDR*)lParam;
441 switch(hdr->code){
442 case CBEN_ENDEDITA:
444 NMCBEENDEDITA *edit_info = (NMCBEENDEDITA*)hdr;
445 if(edit_info->iWhy==CBENF_DROPDOWN){
446 received_end_edit = TRUE;
448 break;
450 case CBEN_ENDEDITW:
452 NMCBEENDEDITW *edit_info = (NMCBEENDEDITW*)hdr;
453 if(edit_info->iWhy==CBENF_DROPDOWN){
454 received_end_edit = TRUE;
456 break;
459 return 0;
462 static LRESULT CALLBACK ComboExTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
464 switch(msg) {
466 case WM_DESTROY:
467 PostQuitMessage(0);
468 break;
469 case WM_NOTIFY:
470 return ComboExTestOnNotify(hWnd,msg,wParam,lParam);
471 default:
472 return DefWindowProcA(hWnd, msg, wParam, lParam);
475 return 0L;
478 static int init(void)
480 HMODULE hComctl32;
481 BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
482 WNDCLASSA wc;
483 INITCOMMONCONTROLSEX iccex;
485 hComctl32 = GetModuleHandleA("comctl32.dll");
486 pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
487 if (!pInitCommonControlsEx)
489 win_skip("InitCommonControlsEx() is missing. Skipping the tests\n");
490 return 0;
492 iccex.dwSize = sizeof(iccex);
493 iccex.dwICC = ICC_USEREX_CLASSES;
494 pInitCommonControlsEx(&iccex);
496 pSetWindowSubclass = (void*)GetProcAddress(hComctl32, (LPSTR)410);
498 wc.style = CS_HREDRAW | CS_VREDRAW;
499 wc.cbClsExtra = 0;
500 wc.cbWndExtra = 0;
501 wc.hInstance = GetModuleHandleA(NULL);
502 wc.hIcon = NULL;
503 wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
504 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
505 wc.lpszMenuName = NULL;
506 wc.lpszClassName = ComboExTestClass;
507 wc.lpfnWndProc = ComboExTestWndProc;
508 RegisterClassA(&wc);
510 hComboExParentWnd = CreateWindowExA(0, ComboExTestClass, "ComboEx test", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
511 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
512 assert(hComboExParentWnd != NULL);
514 hMainHinst = GetModuleHandleA(NULL);
515 return 1;
518 static void cleanup(void)
520 MSG msg;
522 PostMessageA(hComboExParentWnd, WM_CLOSE, 0, 0);
523 while (GetMessageA(&msg,0,0,0)) {
524 TranslateMessage(&msg);
525 DispatchMessageA(&msg);
528 DestroyWindow(hComboExParentWnd);
529 UnregisterClassA(ComboExTestClass, GetModuleHandleA(NULL));
532 static void test_comboboxex_subclass(void)
534 HWND hComboEx, hCombo, hEdit;
536 hComboEx = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
538 hCombo = (HWND)SendMessage(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
539 ok(hCombo != NULL, "Failed to get internal combo\n");
540 hEdit = (HWND)SendMessage(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
541 ok(hEdit != NULL, "Failed to get internal edit\n");
543 if (pSetWindowSubclass)
545 ok(GetPropA(hCombo, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
546 ok(GetPropA(hEdit, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
549 DestroyWindow(hComboEx);
552 static const struct message test_setitem_edit_seq[] = {
553 { WM_SETTEXT, sent|id, 0, 0, EDITBOX_ID },
554 { EM_SETSEL, sent|id|wparam|lparam, 0, 0, EDITBOX_ID },
555 { EM_SETSEL, sent|id|wparam|lparam, 0, -1, EDITBOX_ID },
556 { 0 }
559 static void test_get_set_item(void)
561 char textA[] = "test";
562 HWND hComboEx;
563 COMBOBOXEXITEMA item;
564 BOOL ret;
566 hComboEx = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
568 subclass_editbox(hComboEx);
570 flush_sequences(sequences, NUM_MSG_SEQUENCES);
572 memset(&item, 0, sizeof(item));
573 item.mask = CBEIF_TEXT;
574 item.pszText = textA;
575 item.iItem = -1;
576 ret = SendMessage(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
577 expect(TRUE, ret);
579 ok_sequence(sequences, EDITBOX_SEQ_INDEX, test_setitem_edit_seq, "set item data for edit", FALSE);
581 /* get/set lParam */
582 item.mask = CBEIF_LPARAM;
583 item.iItem = -1;
584 item.lParam = 0xdeadbeef;
585 ret = SendMessage(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
586 expect(TRUE, ret);
587 ok(item.lParam == 0, "Expected zero, got %lx\n", item.lParam);
589 item.lParam = 0x1abe11ed;
590 ret = SendMessage(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
591 expect(TRUE, ret);
593 item.lParam = 0;
594 ret = SendMessage(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
595 expect(TRUE, ret);
596 ok(item.lParam == 0x1abe11ed, "Expected 0x1abe11ed, got %lx\n", item.lParam);
598 DestroyWindow(hComboEx);
601 START_TEST(comboex)
603 if (!init())
604 return;
606 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
608 test_comboboxex();
609 test_WM_LBUTTONDOWN();
610 test_CB_GETLBTEXT();
611 test_WM_WINDOWPOSCHANGING();
612 test_comboboxex_subclass();
613 test_get_set_item();
615 cleanup();