shell32/tests: Use SetRect instead of open coding it.
[wine.git] / dlls / comctl32 / tests / comboex.c
blobfaa32a3727bb6574428ca7da786a377a6a8d0961
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 <windows.h>
21 #include <commctrl.h>
23 #include "wine/test.h"
24 #include "msg.h"
26 #define EDITBOX_SEQ_INDEX 0
27 #define NUM_MSG_SEQUENCES 1
29 #define EDITBOX_ID 0
31 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
33 static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
35 static HWND hComboExParentWnd;
36 static HINSTANCE hMainHinst;
37 static const char ComboExTestClass[] = "ComboExTestClass";
39 static BOOL (WINAPI *pSetWindowSubclass)(HWND, SUBCLASSPROC, UINT_PTR, DWORD_PTR);
41 #define MAX_CHARS 100
42 static char *textBuffer = NULL;
44 static BOOL received_end_edit = FALSE;
46 static HWND createComboEx(DWORD style) {
47 return CreateWindowExA(0, WC_COMBOBOXEXA, NULL, style, 0, 0, 300, 300,
48 hComboExParentWnd, NULL, hMainHinst, NULL);
51 static LONG addItem(HWND cbex, int idx, const char *text) {
52 COMBOBOXEXITEMA cbexItem;
53 memset(&cbexItem, 0x00, sizeof(cbexItem));
54 cbexItem.mask = CBEIF_TEXT;
55 cbexItem.iItem = idx;
56 cbexItem.pszText = (char*)text;
57 cbexItem.cchTextMax = 0;
58 return SendMessageA(cbex, CBEM_INSERTITEMA, 0, (LPARAM)&cbexItem);
61 static LONG setItem(HWND cbex, int idx, const char *text) {
62 COMBOBOXEXITEMA cbexItem;
63 memset(&cbexItem, 0x00, sizeof(cbexItem));
64 cbexItem.mask = CBEIF_TEXT;
65 cbexItem.iItem = idx;
66 cbexItem.pszText = (char*)text;
67 cbexItem.cchTextMax = 0;
68 return SendMessageA(cbex, CBEM_SETITEMA, 0, (LPARAM)&cbexItem);
71 static LONG delItem(HWND cbex, int idx) {
72 return SendMessageA(cbex, CBEM_DELETEITEM, idx, 0);
75 static LONG getItem(HWND cbex, int idx, COMBOBOXEXITEMA *cbItem) {
76 memset(cbItem, 0x00, sizeof(COMBOBOXEXITEMA));
77 cbItem->mask = CBEIF_TEXT;
78 cbItem->pszText = textBuffer;
79 cbItem->iItem = idx;
80 cbItem->cchTextMax = 100;
81 return SendMessageA(cbex, CBEM_GETITEMA, 0, (LPARAM)cbItem);
84 static LRESULT WINAPI editbox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
86 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
87 static LONG defwndproc_counter = 0;
88 LRESULT ret;
89 struct message msg;
91 msg.message = message;
92 msg.flags = sent|wparam|lparam;
93 if (defwndproc_counter) msg.flags |= defwinproc;
94 msg.wParam = wParam;
95 msg.lParam = lParam;
96 msg.id = EDITBOX_ID;
98 if (message != WM_PAINT &&
99 message != WM_ERASEBKGND &&
100 message != WM_NCPAINT &&
101 message != WM_NCHITTEST &&
102 message != WM_GETTEXT &&
103 message != WM_GETICON &&
104 message != WM_DEVICECHANGE)
106 add_message(sequences, EDITBOX_SEQ_INDEX, &msg);
109 defwndproc_counter++;
110 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
111 defwndproc_counter--;
112 return ret;
115 static HWND subclass_editbox(HWND hwndComboEx)
117 WNDPROC oldproc;
118 HWND hwnd;
120 hwnd = (HWND)SendMessageA(hwndComboEx, CBEM_GETEDITCONTROL, 0, 0);
121 oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
122 (LONG_PTR)editbox_subclass_proc);
123 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
125 return hwnd;
128 static void test_comboboxex(void) {
129 HWND myHwnd = 0;
130 LONG res;
131 COMBOBOXEXITEMA cbexItem;
132 static const char *first_item = "First Item",
133 *second_item = "Second Item",
134 *third_item = "Third Item",
135 *middle_item = "Between First and Second Items",
136 *replacement_item = "Between First and Second Items",
137 *out_of_range_item = "Out of Range Item";
139 /* Allocate space for result */
140 textBuffer = HeapAlloc(GetProcessHeap(), 0, MAX_CHARS);
142 /* Basic comboboxex test */
143 myHwnd = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
145 /* Add items onto the end of the combobox */
146 res = addItem(myHwnd, -1, first_item);
147 ok(res == 0, "Adding simple item failed (%d)\n", res);
148 res = addItem(myHwnd, -1, second_item);
149 ok(res == 1, "Adding simple item failed (%d)\n", res);
150 res = addItem(myHwnd, 2, third_item);
151 ok(res == 2, "Adding simple item failed (%d)\n", res);
152 res = addItem(myHwnd, 1, middle_item);
153 ok(res == 1, "Inserting simple item failed (%d)\n", res);
155 /* Add an item completely out of range */
156 res = addItem(myHwnd, 99, out_of_range_item);
157 ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
158 res = addItem(myHwnd, 5, out_of_range_item);
159 ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res);
160 /* Removed: Causes traps on Windows XP
161 res = addItem(myHwnd, -2, "Out Of Range Item");
162 ok(res == -1, "Adding out of range worked unexpectedly (%ld)\n", res);
165 /* Get an item completely out of range */
166 res = getItem(myHwnd, 99, &cbexItem);
167 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
168 res = getItem(myHwnd, 4, &cbexItem);
169 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
170 res = getItem(myHwnd, -2, &cbexItem);
171 ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText);
173 /* Get an item in range */
174 res = getItem(myHwnd, 0, &cbexItem);
175 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
176 ok(strcmp(first_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
178 res = getItem(myHwnd, 1, &cbexItem);
179 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
180 ok(strcmp(middle_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
182 res = getItem(myHwnd, 2, &cbexItem);
183 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
184 ok(strcmp(second_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
186 res = getItem(myHwnd, 3, &cbexItem);
187 ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res);
188 ok(strcmp(third_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText);
190 /* Set an item completely out of range */
191 res = setItem(myHwnd, 99, replacement_item);
192 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
193 res = setItem(myHwnd, 4, replacement_item);
194 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
195 res = setItem(myHwnd, -2, replacement_item);
196 ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res);
198 /* Set an item in range */
199 res = setItem(myHwnd, 0, replacement_item);
200 ok(res != 0, "Setting first item failed (%d)\n", res);
201 res = setItem(myHwnd, 3, replacement_item);
202 ok(res != 0, "Setting last item failed (%d)\n", res);
204 /* Remove items completely out of range (4 items in control at this point) */
205 res = delItem(myHwnd, -1);
206 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
207 res = delItem(myHwnd, 4);
208 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
210 /* Remove items in range (4 items in control at this point) */
211 res = delItem(myHwnd, 3);
212 ok(res == 3, "Deleting using out of range index failed (%d)\n", res);
213 res = delItem(myHwnd, 0);
214 ok(res == 2, "Deleting using out of range index failed (%d)\n", res);
215 res = delItem(myHwnd, 0);
216 ok(res == 1, "Deleting using out of range index failed (%d)\n", res);
217 res = delItem(myHwnd, 0);
218 ok(res == 0, "Deleting using out of range index failed (%d)\n", res);
220 /* Remove from an empty box */
221 res = delItem(myHwnd, 0);
222 ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res);
225 /* Cleanup */
226 HeapFree(GetProcessHeap(), 0, textBuffer);
227 DestroyWindow(myHwnd);
230 static void test_WM_LBUTTONDOWN(void)
232 HWND hComboEx, hCombo, hEdit, hList;
233 COMBOBOXINFO cbInfo;
234 UINT x, y, item_height;
235 LRESULT result;
236 UINT i;
237 int idx;
238 RECT rect;
239 WCHAR buffer[3];
240 static const UINT choices[] = {8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72};
241 static const WCHAR stringFormat[] = {'%','2','d','\0'};
242 BOOL (WINAPI *pGetComboBoxInfo)(HWND, PCOMBOBOXINFO);
244 pGetComboBoxInfo = (void*)GetProcAddress(GetModuleHandleA("user32.dll"), "GetComboBoxInfo");
245 if (!pGetComboBoxInfo){
246 win_skip("GetComboBoxInfo is not available\n");
247 return;
250 hComboEx = CreateWindowExA(0, WC_COMBOBOXEXA, NULL,
251 WS_VISIBLE|WS_CHILD|CBS_DROPDOWN, 0, 0, 200, 150,
252 hComboExParentWnd, NULL, hMainHinst, NULL);
254 for (i = 0; i < sizeof(choices)/sizeof(UINT); i++){
255 COMBOBOXEXITEMW cbexItem;
256 wsprintfW(buffer, stringFormat, choices[i]);
258 memset(&cbexItem, 0x00, sizeof(cbexItem));
259 cbexItem.mask = CBEIF_TEXT;
260 cbexItem.iItem = i;
261 cbexItem.pszText = buffer;
262 cbexItem.cchTextMax = 0;
263 ok(SendMessageW(hComboEx, CBEM_INSERTITEMW, 0, (LPARAM)&cbexItem) >= 0,
264 "Failed to add item %d\n", i);
267 hCombo = (HWND)SendMessageA(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
268 hEdit = (HWND)SendMessageA(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
270 cbInfo.cbSize = sizeof(COMBOBOXINFO);
271 result = pGetComboBoxInfo(hCombo, &cbInfo);
272 ok(result, "Failed to get combobox info structure. LastError=%d\n",
273 GetLastError());
274 hList = cbInfo.hwndList;
276 ok(GetFocus() == hComboExParentWnd,
277 "Focus not on Main Window, instead on %p\n", GetFocus());
279 /* Click on the button to drop down the list */
280 x = cbInfo.rcButton.left + (cbInfo.rcButton.right-cbInfo.rcButton.left)/2;
281 y = cbInfo.rcButton.top + (cbInfo.rcButton.bottom-cbInfo.rcButton.top)/2;
282 result = SendMessageA(hCombo, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
283 ok(result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
284 GetLastError());
285 ok(GetFocus() == hCombo ||
286 broken(GetFocus() != hCombo), /* win98 */
287 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
288 GetFocus());
289 ok(SendMessageA(hComboEx, CB_GETDROPPEDSTATE, 0, 0),
290 "The dropdown list should have appeared after clicking the button.\n");
291 idx = SendMessageA(hCombo, CB_GETTOPINDEX, 0, 0);
292 ok(idx == 0, "For TopIndex expected %d, got %d\n", 0, idx);
294 result = SendMessageA(hCombo, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
295 ok(result, "WM_LBUTTONUP was not processed. LastError=%d\n",
296 GetLastError());
297 ok(GetFocus() == hCombo ||
298 broken(GetFocus() != hCombo), /* win98 */
299 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
300 GetFocus());
302 /* Click on the 5th item in the list */
303 item_height = SendMessageA(hCombo, CB_GETITEMHEIGHT, 0, 0);
304 ok(GetClientRect(hList, &rect), "Failed to get list's client rect.\n");
305 x = rect.left + (rect.right-rect.left)/2;
306 y = item_height/2 + item_height*4;
307 result = SendMessageA(hList, WM_MOUSEMOVE, 0, MAKELPARAM(x, y));
308 ok(!result, "WM_MOUSEMOVE was not processed. LastError=%d\n",
309 GetLastError());
310 ok(GetFocus() == hCombo ||
311 broken(GetFocus() != hCombo), /* win98 */
312 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
313 GetFocus());
315 result = SendMessageA(hList, WM_LBUTTONDOWN, 0, MAKELPARAM(x, y));
316 ok(!result, "WM_LBUTTONDOWN was not processed. LastError=%d\n",
317 GetLastError());
318 ok(GetFocus() == hCombo ||
319 broken(GetFocus() != hCombo), /* win98 */
320 "Focus not on ComboBoxEx's ComboBox Control, instead on %p\n",
321 GetFocus());
322 ok(SendMessageA(hComboEx, CB_GETDROPPEDSTATE, 0, 0),
323 "The dropdown list should still be visible.\n");
325 result = SendMessageA(hList, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
326 ok(!result, "WM_LBUTTONUP was not processed. LastError=%d\n",
327 GetLastError());
328 todo_wine ok(GetFocus() == hEdit ||
329 broken(GetFocus() == hCombo), /* win98 */
330 "Focus not on ComboBoxEx's Edit Control, instead on %p\n",
331 GetFocus());
333 result = SendMessageA(hCombo, CB_GETDROPPEDSTATE, 0, 0);
334 ok(!result ||
335 broken(result != 0), /* win98 */
336 "The dropdown list should have been rolled up.\n");
337 idx = SendMessageA(hComboEx, CB_GETCURSEL, 0, 0);
338 ok(idx == 4 ||
339 broken(idx == -1), /* win98 */
340 "Current Selection: expected %d, got %d\n", 4, idx);
341 ok(received_end_edit, "Expected to receive a CBEN_ENDEDIT message\n");
343 SetFocus( hComboExParentWnd );
344 ok( GetFocus() == hComboExParentWnd, "got %p\n", GetFocus() );
345 SetFocus( hComboEx );
346 ok( GetFocus() == hEdit, "got %p\n", GetFocus() );
348 DestroyWindow(hComboEx);
351 static void test_CB_GETLBTEXT(void)
353 HWND hCombo;
354 CHAR buff[1];
355 COMBOBOXEXITEMA item;
356 LRESULT ret;
358 hCombo = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
360 /* set text to null */
361 addItem(hCombo, 0, NULL);
363 buff[0] = 'a';
364 item.mask = CBEIF_TEXT;
365 item.iItem = 0;
366 item.pszText = buff;
367 item.cchTextMax = 1;
368 ret = SendMessageA(hCombo, CBEM_GETITEMA, 0, (LPARAM)&item);
369 ok(ret != 0, "CBEM_GETITEM failed\n");
370 ok(buff[0] == 0, "\n");
372 ret = SendMessageA(hCombo, CB_GETLBTEXTLEN, 0, 0);
373 ok(ret == 0, "Expected zero length\n");
375 ret = SendMessageA(hCombo, CB_GETLBTEXTLEN, 0, 0);
376 ok(ret == 0, "Expected zero length\n");
378 buff[0] = 'a';
379 ret = SendMessageA(hCombo, CB_GETLBTEXT, 0, (LPARAM)buff);
380 ok(ret == 0, "Expected zero length\n");
381 ok(buff[0] == 0, "Expected null terminator as a string, got %s\n", buff);
383 DestroyWindow(hCombo);
386 static void test_WM_WINDOWPOSCHANGING(void)
388 HWND hCombo;
389 WINDOWPOS wp;
390 RECT rect;
391 int combo_height;
392 int ret;
394 hCombo = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
395 ok(hCombo != NULL, "createComboEx failed\n");
396 ret = GetWindowRect(hCombo, &rect);
397 ok(ret, "GetWindowRect failed\n");
398 combo_height = rect.bottom - rect.top;
399 ok(combo_height > 0, "wrong combo height\n");
401 /* Test height > combo_height */
402 wp.x = rect.left;
403 wp.y = rect.top;
404 wp.cx = (rect.right - rect.left);
405 wp.cy = combo_height * 2;
406 wp.flags = 0;
407 wp.hwnd = hCombo;
408 wp.hwndInsertAfter = NULL;
410 ret = SendMessageA(hCombo, WM_WINDOWPOSCHANGING, 0, (LPARAM)&wp);
411 ok(ret == 0, "expected 0, got %x\n", ret);
412 ok(wp.cy == combo_height,
413 "Expected height %d, got %d\n", combo_height, wp.cy);
415 /* Test height < combo_height */
416 wp.x = rect.left;
417 wp.y = rect.top;
418 wp.cx = (rect.right - rect.left);
419 wp.cy = combo_height / 2;
420 wp.flags = 0;
421 wp.hwnd = hCombo;
422 wp.hwndInsertAfter = NULL;
424 ret = SendMessageA(hCombo, WM_WINDOWPOSCHANGING, 0, (LPARAM)&wp);
425 ok(ret == 0, "expected 0, got %x\n", ret);
426 ok(wp.cy == combo_height,
427 "Expected height %d, got %d\n", combo_height, wp.cy);
429 ret = DestroyWindow(hCombo);
430 ok(ret, "DestroyWindow failed\n");
433 static LRESULT ComboExTestOnNotify(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
435 NMHDR *hdr = (NMHDR*)lParam;
436 switch(hdr->code){
437 case CBEN_ENDEDITA:
439 NMCBEENDEDITA *edit_info = (NMCBEENDEDITA*)hdr;
440 if(edit_info->iWhy==CBENF_DROPDOWN){
441 received_end_edit = TRUE;
443 break;
445 case CBEN_ENDEDITW:
447 NMCBEENDEDITW *edit_info = (NMCBEENDEDITW*)hdr;
448 if(edit_info->iWhy==CBENF_DROPDOWN){
449 received_end_edit = TRUE;
451 break;
454 return 0;
457 static LRESULT CALLBACK ComboExTestWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
459 switch(msg) {
461 case WM_DESTROY:
462 PostQuitMessage(0);
463 break;
464 case WM_NOTIFY:
465 return ComboExTestOnNotify(hWnd,msg,wParam,lParam);
466 default:
467 return DefWindowProcA(hWnd, msg, wParam, lParam);
470 return 0L;
473 static BOOL init(void)
475 HMODULE hComctl32;
476 BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
477 WNDCLASSA wc;
478 INITCOMMONCONTROLSEX iccex;
480 hComctl32 = GetModuleHandleA("comctl32.dll");
481 pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
482 if (!pInitCommonControlsEx)
484 win_skip("InitCommonControlsEx() is missing. Skipping the tests\n");
485 return FALSE;
487 iccex.dwSize = sizeof(iccex);
488 iccex.dwICC = ICC_USEREX_CLASSES;
489 pInitCommonControlsEx(&iccex);
491 pSetWindowSubclass = (void*)GetProcAddress(hComctl32, (LPSTR)410);
493 wc.style = CS_HREDRAW | CS_VREDRAW;
494 wc.cbClsExtra = 0;
495 wc.cbWndExtra = 0;
496 wc.hInstance = GetModuleHandleA(NULL);
497 wc.hIcon = NULL;
498 wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
499 wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
500 wc.lpszMenuName = NULL;
501 wc.lpszClassName = ComboExTestClass;
502 wc.lpfnWndProc = ComboExTestWndProc;
503 RegisterClassA(&wc);
505 hComboExParentWnd = CreateWindowExA(0, ComboExTestClass, "ComboEx test", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
506 CW_USEDEFAULT, CW_USEDEFAULT, 680, 260, NULL, NULL, GetModuleHandleA(NULL), 0);
507 ok(hComboExParentWnd != NULL, "failed to create parent window\n");
509 hMainHinst = GetModuleHandleA(NULL);
511 return hComboExParentWnd != NULL;
514 static void cleanup(void)
516 MSG msg;
518 PostMessageA(hComboExParentWnd, WM_CLOSE, 0, 0);
519 while (GetMessageA(&msg,0,0,0)) {
520 TranslateMessage(&msg);
521 DispatchMessageA(&msg);
524 DestroyWindow(hComboExParentWnd);
525 UnregisterClassA(ComboExTestClass, GetModuleHandleA(NULL));
528 static void test_comboboxex_subclass(void)
530 HWND hComboEx, hCombo, hEdit;
532 hComboEx = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
534 hCombo = (HWND)SendMessageA(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
535 ok(hCombo != NULL, "Failed to get internal combo\n");
536 hEdit = (HWND)SendMessageA(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
537 ok(hEdit != NULL, "Failed to get internal edit\n");
539 if (pSetWindowSubclass)
541 ok(GetPropA(hCombo, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
542 ok(GetPropA(hEdit, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
545 DestroyWindow(hComboEx);
548 static const struct message test_setitem_edit_seq[] = {
549 { WM_SETTEXT, sent|id, 0, 0, EDITBOX_ID },
550 { EM_SETSEL, sent|id|wparam|lparam, 0, 0, EDITBOX_ID },
551 { EM_SETSEL, sent|id|wparam|lparam, 0, -1, EDITBOX_ID },
552 { 0 }
555 static void test_get_set_item(void)
557 char textA[] = "test";
558 HWND hComboEx;
559 COMBOBOXEXITEMA item;
560 BOOL ret;
562 hComboEx = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
564 subclass_editbox(hComboEx);
566 flush_sequences(sequences, NUM_MSG_SEQUENCES);
568 memset(&item, 0, sizeof(item));
569 item.mask = CBEIF_TEXT;
570 item.pszText = textA;
571 item.iItem = -1;
572 ret = SendMessageA(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
573 expect(TRUE, ret);
575 ok_sequence(sequences, EDITBOX_SEQ_INDEX, test_setitem_edit_seq, "set item data for edit", FALSE);
577 /* get/set lParam */
578 item.mask = CBEIF_LPARAM;
579 item.iItem = -1;
580 item.lParam = 0xdeadbeef;
581 ret = SendMessageA(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
582 expect(TRUE, ret);
583 ok(item.lParam == 0, "Expected zero, got %lx\n", item.lParam);
585 item.lParam = 0x1abe11ed;
586 ret = SendMessageA(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
587 expect(TRUE, ret);
589 item.lParam = 0;
590 ret = SendMessageA(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
591 expect(TRUE, ret);
592 ok(item.lParam == 0x1abe11ed, "Expected 0x1abe11ed, got %lx\n", item.lParam);
594 DestroyWindow(hComboEx);
597 START_TEST(comboex)
599 if (!init())
600 return;
602 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
604 test_comboboxex();
605 test_WM_LBUTTONDOWN();
606 test_CB_GETLBTEXT();
607 test_WM_WINDOWPOSCHANGING();
608 test_comboboxex_subclass();
609 test_get_set_item();
611 cleanup();