comctl32: Fix TB_SETSTYLE behaviour and return value.
[wine/multimedia.git] / dlls / comctl32 / tests / comboex.c
blob172e56429d41adc19e42da61108f06c699a4f091
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 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 = SendMessage(hCombo, CBEM_GETITEMA, 0, (LPARAM)&item);
369 ok(ret != 0, "CBEM_GETITEM failed\n");
370 ok(buff[0] == 0, "\n");
372 ret = SendMessage(hCombo, CB_GETLBTEXTLEN, 0, 0);
373 ok(ret == 0, "Expected zero length\n");
375 ret = SendMessage(hCombo, CB_GETLBTEXTLEN, 0, 0);
376 ok(ret == 0, "Expected zero length\n");
378 buff[0] = 'a';
379 ret = SendMessage(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 int 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 0;
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, 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 assert(hComboExParentWnd != NULL);
509 hMainHinst = GetModuleHandleA(NULL);
510 return 1;
513 static void cleanup(void)
515 MSG msg;
517 PostMessageA(hComboExParentWnd, WM_CLOSE, 0, 0);
518 while (GetMessageA(&msg,0,0,0)) {
519 TranslateMessage(&msg);
520 DispatchMessageA(&msg);
523 DestroyWindow(hComboExParentWnd);
524 UnregisterClassA(ComboExTestClass, GetModuleHandleA(NULL));
527 static void test_comboboxex_subclass(void)
529 HWND hComboEx, hCombo, hEdit;
531 hComboEx = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
533 hCombo = (HWND)SendMessage(hComboEx, CBEM_GETCOMBOCONTROL, 0, 0);
534 ok(hCombo != NULL, "Failed to get internal combo\n");
535 hEdit = (HWND)SendMessage(hComboEx, CBEM_GETEDITCONTROL, 0, 0);
536 ok(hEdit != NULL, "Failed to get internal edit\n");
538 if (pSetWindowSubclass)
540 ok(GetPropA(hCombo, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
541 ok(GetPropA(hEdit, "CC32SubclassInfo") != NULL, "Expected CC32SubclassInfo property\n");
544 DestroyWindow(hComboEx);
547 static const struct message test_setitem_edit_seq[] = {
548 { WM_SETTEXT, sent|id, 0, 0, EDITBOX_ID },
549 { EM_SETSEL, sent|id|wparam|lparam, 0, 0, EDITBOX_ID },
550 { EM_SETSEL, sent|id|wparam|lparam, 0, -1, EDITBOX_ID },
551 { 0 }
554 static void test_get_set_item(void)
556 char textA[] = "test";
557 HWND hComboEx;
558 COMBOBOXEXITEMA item;
559 BOOL ret;
561 hComboEx = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN);
563 subclass_editbox(hComboEx);
565 flush_sequences(sequences, NUM_MSG_SEQUENCES);
567 memset(&item, 0, sizeof(item));
568 item.mask = CBEIF_TEXT;
569 item.pszText = textA;
570 item.iItem = -1;
571 ret = SendMessage(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
572 expect(TRUE, ret);
574 ok_sequence(sequences, EDITBOX_SEQ_INDEX, test_setitem_edit_seq, "set item data for edit", FALSE);
576 /* get/set lParam */
577 item.mask = CBEIF_LPARAM;
578 item.iItem = -1;
579 item.lParam = 0xdeadbeef;
580 ret = SendMessage(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
581 expect(TRUE, ret);
582 ok(item.lParam == 0, "Expected zero, got %lx\n", item.lParam);
584 item.lParam = 0x1abe11ed;
585 ret = SendMessage(hComboEx, CBEM_SETITEMA, 0, (LPARAM)&item);
586 expect(TRUE, ret);
588 item.lParam = 0;
589 ret = SendMessage(hComboEx, CBEM_GETITEMA, 0, (LPARAM)&item);
590 expect(TRUE, ret);
591 ok(item.lParam == 0x1abe11ed, "Expected 0x1abe11ed, got %lx\n", item.lParam);
593 DestroyWindow(hComboEx);
596 START_TEST(comboex)
598 if (!init())
599 return;
601 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
603 test_comboboxex();
604 test_WM_LBUTTONDOWN();
605 test_CB_GETLBTEXT();
606 test_WM_WINDOWPOSCHANGING();
607 test_comboboxex_subclass();
608 test_get_set_item();
610 cleanup();