4 * Copyright 2006 Mike McCormack for CodeWeavers
5 * Copyright 2007 George Gov
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
29 #define PARENT_SEQ_INDEX 0
30 #define PARENT_FULL_SEQ_INDEX 1
31 #define LISTVIEW_SEQ_INDEX 2
32 #define NUM_MSG_SEQUENCES 3
37 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
38 #define expect2(expected1, expected2, got1, got2) ok(expected1 == got1 && expected2 == got2, \
39 "expected (%d,%d), got (%d,%d)\n", expected1, expected2, got1, got2)
43 static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
45 static const struct message create_parent_wnd_seq[] = {
46 { WM_GETMINMAXINFO, sent },
47 { WM_NCCREATE, sent },
48 { WM_NCCALCSIZE, sent|wparam, 0 },
50 { WM_SHOWWINDOW, sent|wparam, 1 },
51 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
52 { WM_QUERYNEWPALETTE, sent|optional },
53 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
54 { WM_WINDOWPOSCHANGED, sent|optional },
55 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
56 { WM_ACTIVATEAPP, sent|wparam, 1 },
57 { WM_NCACTIVATE, sent|wparam, 1 },
58 { WM_ACTIVATE, sent|wparam, 1 },
59 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
60 { WM_IME_NOTIFY, sent|defwinproc|optional },
61 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
62 /* Win9x adds SWP_NOZORDER below */
63 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
64 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
70 static const struct message redraw_listview_seq[] = {
71 { WM_PAINT, sent|id, 0, 0, LISTVIEW_ID },
72 { WM_PAINT, sent|id, 0, 0, HEADER_ID },
73 { WM_NCPAINT, sent|id|defwinproc, 0, 0, HEADER_ID },
74 { WM_ERASEBKGND, sent|id|defwinproc, 0, 0, HEADER_ID },
75 { WM_NOTIFY, sent|id|defwinproc, 0, 0, LISTVIEW_ID },
76 { WM_NCPAINT, sent|id|defwinproc, 0, 0, LISTVIEW_ID },
77 { WM_ERASEBKGND, sent|id|defwinproc, 0, 0, LISTVIEW_ID },
81 static const struct message listview_icon_spacing_seq[] = {
82 { LVM_SETICONSPACING, sent|lparam, 0, MAKELPARAM(20, 30) },
83 { LVM_SETICONSPACING, sent|lparam, 0, MAKELPARAM(25, 35) },
84 { LVM_SETICONSPACING, sent|lparam, 0, MAKELPARAM(-1, -1) },
88 static const struct message listview_color_seq[] = {
89 { LVM_SETBKCOLOR, sent|lparam, 0, RGB(0,0,0) },
90 { LVM_GETBKCOLOR, sent },
91 { LVM_SETTEXTCOLOR, sent|lparam, 0, RGB(0,0,0) },
92 { LVM_GETTEXTCOLOR, sent },
93 { LVM_SETTEXTBKCOLOR, sent|lparam, 0, RGB(0,0,0) },
94 { LVM_GETTEXTBKCOLOR, sent },
96 { LVM_SETBKCOLOR, sent|lparam, 0, RGB(100,50,200) },
97 { LVM_GETBKCOLOR, sent },
98 { LVM_SETTEXTCOLOR, sent|lparam, 0, RGB(100,50,200) },
99 { LVM_GETTEXTCOLOR, sent },
100 { LVM_SETTEXTBKCOLOR, sent|lparam, 0, RGB(100,50,200) },
101 { LVM_GETTEXTBKCOLOR, sent },
103 { LVM_SETBKCOLOR, sent|lparam, 0, CLR_NONE },
104 { LVM_GETBKCOLOR, sent },
105 { LVM_SETTEXTCOLOR, sent|lparam, 0, CLR_NONE },
106 { LVM_GETTEXTCOLOR, sent },
107 { LVM_SETTEXTBKCOLOR, sent|lparam, 0, CLR_NONE },
108 { LVM_GETTEXTBKCOLOR, sent },
110 { LVM_SETBKCOLOR, sent|lparam, 0, RGB(255,255,255) },
111 { LVM_GETBKCOLOR, sent },
112 { LVM_SETTEXTCOLOR, sent|lparam, 0, RGB(255,255,255) },
113 { LVM_GETTEXTCOLOR, sent },
114 { LVM_SETTEXTBKCOLOR, sent|lparam, 0, RGB(255,255,255) },
115 { LVM_GETTEXTBKCOLOR, sent },
119 static const struct message listview_item_count_seq[] = {
120 { LVM_GETITEMCOUNT, sent },
121 { LVM_INSERTITEM, sent },
122 { LVM_INSERTITEM, sent },
123 { LVM_INSERTITEM, sent },
124 { LVM_GETITEMCOUNT, sent },
125 { LVM_DELETEITEM, sent|wparam, 2 },
126 { LVM_GETITEMCOUNT, sent },
127 { LVM_DELETEALLITEMS, sent },
128 { LVM_GETITEMCOUNT, sent },
129 { LVM_INSERTITEM, sent },
130 { LVM_INSERTITEM, sent },
131 { LVM_GETITEMCOUNT, sent },
132 { LVM_INSERTITEM, sent },
133 { LVM_GETITEMCOUNT, sent },
137 static const struct message listview_itempos_seq[] = {
138 { LVM_INSERTITEM, sent },
139 { LVM_INSERTITEM, sent },
140 { LVM_INSERTITEM, sent },
141 { LVM_SETITEMPOSITION, sent|wparam|lparam, 1, MAKELPARAM(10,5) },
142 { LVM_GETITEMPOSITION, sent|wparam, 1 },
143 { LVM_SETITEMPOSITION, sent|wparam|lparam, 2, MAKELPARAM(0,0) },
144 { LVM_GETITEMPOSITION, sent|wparam, 2 },
145 { LVM_SETITEMPOSITION, sent|wparam|lparam, 0, MAKELPARAM(20,20) },
146 { LVM_GETITEMPOSITION, sent|wparam, 0 },
150 static const struct message listview_ownerdata_switchto_seq[] = {
151 { WM_STYLECHANGING, sent },
152 { WM_STYLECHANGED, sent },
156 static const struct message listview_getorderarray_seq[] = {
157 { LVM_GETCOLUMNORDERARRAY, sent|id|wparam, 2, 0, LISTVIEW_ID },
158 { HDM_GETORDERARRAY, sent|id|wparam, 2, 0, HEADER_ID },
162 static const struct message empty_seq[] = {
166 static const struct message forward_erasebkgnd_parent_seq[] = {
167 { WM_ERASEBKGND, sent },
171 static const struct message ownderdata_select_focus_parent_seq[] = {
172 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
173 { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
177 static const struct message textcallback_set_again_parent_seq[] = {
178 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
179 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
183 static const struct message single_getdispinfo_parent_seq[] = {
184 { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
188 static const struct message getitemposition_seq1[] = {
189 { LVM_GETITEMPOSITION, sent|id, 0, 0, LISTVIEW_ID },
193 static const struct message getitemposition_seq2[] = {
194 { LVM_GETITEMPOSITION, sent|id, 0, 0, LISTVIEW_ID },
195 { HDM_GETITEMRECT, sent|id, 0, 0, HEADER_ID },
204 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
206 static LONG defwndproc_counter = 0;
210 msg.message = message;
211 msg.flags = sent|wparam|lparam;
212 if (defwndproc_counter) msg.flags |= defwinproc;
215 if (message == WM_NOTIFY && lParam) msg.id = ((NMHDR*)lParam)->code;
217 /* log system messages, except for painting */
218 if (message < WM_USER &&
219 message != WM_PAINT &&
220 message != WM_ERASEBKGND &&
221 message != WM_NCPAINT &&
222 message != WM_NCHITTEST &&
223 message != WM_GETTEXT &&
224 message != WM_GETICON &&
225 message != WM_DEVICECHANGE)
227 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
229 add_message(sequences, PARENT_SEQ_INDEX, &msg);
231 add_message(sequences, PARENT_FULL_SEQ_INDEX, &msg);
233 /* always accept new item text */
234 if (message == WM_NOTIFY && lParam && ((NMHDR*)lParam)->code == LVN_ENDLABELEDIT)
237 defwndproc_counter++;
238 ret = DefWindowProcA(hwnd, message, wParam, lParam);
239 defwndproc_counter--;
244 static BOOL register_parent_wnd_class(void)
249 cls.lpfnWndProc = parent_wnd_proc;
252 cls.hInstance = GetModuleHandleA(NULL);
254 cls.hCursor = LoadCursorA(0, IDC_ARROW);
255 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
256 cls.lpszMenuName = NULL;
257 cls.lpszClassName = "Listview test parent class";
258 return RegisterClassA(&cls);
261 static HWND create_parent_window(void)
263 if (!register_parent_wnd_class())
266 return CreateWindowEx(0, "Listview test parent class",
267 "Listview test parent window",
268 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
269 WS_MAXIMIZEBOX | WS_VISIBLE,
271 GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
274 static LRESULT WINAPI listview_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
276 struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
277 static LONG defwndproc_counter = 0;
281 trace("listview: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
283 /* some debug output for style changing */
284 if ((message == WM_STYLECHANGING ||
285 message == WM_STYLECHANGED) && lParam)
287 STYLESTRUCT *style = (STYLESTRUCT*)lParam;
288 trace("\told style: 0x%08x, new style: 0x%08x\n", style->styleOld, style->styleNew);
291 msg.message = message;
292 msg.flags = sent|wparam|lparam;
293 if (defwndproc_counter) msg.flags |= defwinproc;
296 msg.id = LISTVIEW_ID;
297 add_message(sequences, LISTVIEW_SEQ_INDEX, &msg);
299 defwndproc_counter++;
300 ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam);
301 defwndproc_counter--;
305 static HWND create_listview_control(DWORD style)
307 struct subclass_info *info;
311 info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info));
315 GetClientRect(hwndparent, &rect);
316 hwnd = CreateWindowExA(0, WC_LISTVIEW, "foo",
317 WS_CHILD | WS_BORDER | WS_VISIBLE | LVS_REPORT | style,
318 0, 0, rect.right, rect.bottom,
319 hwndparent, NULL, GetModuleHandleA(NULL), NULL);
320 ok(hwnd != NULL, "gle=%d\n", GetLastError());
324 HeapFree(GetProcessHeap(), 0, info);
328 info->oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
329 (LONG_PTR)listview_subclass_proc);
330 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)info);
335 static HWND create_custom_listview_control(DWORD style)
337 struct subclass_info *info;
341 info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info));
345 GetClientRect(hwndparent, &rect);
346 hwnd = CreateWindowExA(0, WC_LISTVIEW, "foo",
347 WS_CHILD | WS_BORDER | WS_VISIBLE | style,
348 0, 0, rect.right, rect.bottom,
349 hwndparent, NULL, GetModuleHandleA(NULL), NULL);
350 ok(hwnd != NULL, "gle=%d\n", GetLastError());
354 HeapFree(GetProcessHeap(), 0, info);
358 info->oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
359 (LONG_PTR)listview_subclass_proc);
360 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)info);
365 static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
367 struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
368 static LONG defwndproc_counter = 0;
372 trace("header: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
374 msg.message = message;
375 msg.flags = sent|wparam|lparam;
376 if (defwndproc_counter) msg.flags |= defwinproc;
380 add_message(sequences, LISTVIEW_SEQ_INDEX, &msg);
382 defwndproc_counter++;
383 ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam);
384 defwndproc_counter--;
388 static HWND subclass_header(HWND hwndListview)
390 struct subclass_info *info;
393 info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info));
397 hwnd = ListView_GetHeader(hwndListview);
398 info->oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
399 (LONG_PTR)header_subclass_proc);
400 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)info);
405 /* Performs a single LVM_HITTEST test */
406 static void test_lvm_hittest(HWND hwnd, INT x, INT y, INT item, UINT flags,
407 BOOL todo_item, BOOL todo_flags, int line)
416 trace("hittesting pt=(%d,%d)\n", lpht.pt.x, lpht.pt.y);
417 ret = SendMessage(hwnd, LVM_HITTEST, 0, (LPARAM)&lpht);
423 ok_(__FILE__, line)(ret == item, "Expected %d item, got %d\n", item, ret);
424 ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
425 ok_(__FILE__, line)(lpht.iSubItem == 10, "Expected subitem not overwrited\n");
430 ok_(__FILE__, line)(ret == item, "Expected %d item, got %d\n", item, ret);
431 ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
432 ok_(__FILE__, line)(lpht.iSubItem == 10, "Expected subitem not overwrited\n");
438 ok_(__FILE__, line)(lpht.flags == flags, "Expected flags %x, got %x\n", flags, lpht.flags);
441 ok_(__FILE__, line)(lpht.flags == flags, "Expected flags %x, got %x\n", flags, lpht.flags);
444 /* Performs a single LVM_SUBITEMHITTEST test */
445 static void test_lvm_subitemhittest(HWND hwnd, INT x, INT y, INT item, INT subitem, UINT flags,
446 BOOL todo_item, BOOL todo_subitem, BOOL todo_flags, int line)
454 trace("subhittesting pt=(%d,%d)\n", lpht.pt.x, lpht.pt.y);
455 ret = SendMessage(hwnd, LVM_SUBITEMHITTEST, 0, (LPARAM)&lpht);
461 ok_(__FILE__, line)(ret == item, "Expected %d item, got %d\n", item, ret);
462 ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
467 ok_(__FILE__, line)(ret == item, "Expected %d item, got %d\n", item, ret);
468 ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
474 ok_(__FILE__, line)(lpht.iSubItem == subitem, "Expected subitem %d, got %d\n", subitem, lpht.iSubItem);
477 ok_(__FILE__, line)(lpht.iSubItem == subitem, "Expected subitem %d, got %d\n", subitem, lpht.iSubItem);
482 ok_(__FILE__, line)(lpht.flags == flags, "Expected flags %x, got %x\n", flags, lpht.flags);
485 ok_(__FILE__, line)(lpht.flags == flags, "Expected flags %x, got %x\n", flags, lpht.flags);
488 static void test_images(void)
496 static CHAR hello[] = "hello";
498 himl = ImageList_Create(40, 40, 0, 4, 4);
499 ok(himl != NULL, "failed to create imagelist\n");
501 hbmp = CreateBitmap(40, 40, 1, 1, NULL);
502 ok(hbmp != NULL, "failed to create bitmap\n");
504 r = ImageList_Add(himl, hbmp, 0);
505 ok(r == 0, "should be zero\n");
507 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_OWNERDRAWFIXED,
508 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
509 ok(hwnd != NULL, "failed to create listview window\n");
511 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
512 LVS_EX_UNDERLINEHOT | LVS_EX_FLATSB | LVS_EX_ONECLICKACTIVATE);
514 ok(r == 0, "should return zero\n");
516 r = SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
517 ok(r == 0, "should return zero\n");
519 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELONG(100,50));
520 /* returns dimensions */
522 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
523 ok(r == 0, "should be zero items\n");
525 item.mask = LVIF_IMAGE | LVIF_TEXT;
530 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
531 ok(r == -1, "should fail\n");
534 item.pszText = hello;
535 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
536 ok(r == 0, "should not fail\n");
538 memset(&r1, 0, sizeof r1);
540 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r1);
542 r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
543 ok(r == TRUE, "should not fail\n");
546 item.pszText = hello;
547 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
548 ok(r == 0, "should not fail\n");
550 memset(&r2, 0, sizeof r2);
552 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r2);
554 ok(!memcmp(&r1, &r2, sizeof r1), "rectangle should be the same\n");
559 static void test_checkboxes(void)
564 static CHAR text[] = "Text",
568 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT,
569 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
570 ok(hwnd != NULL, "failed to create listview window\n");
572 /* first without LVS_EX_CHECKBOXES set and an item and check that state is preserved */
573 item.mask = LVIF_TEXT | LVIF_STATE;
574 item.stateMask = 0xffff;
579 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
580 ok(r == 0, "ret %d\n", r);
583 item.mask = LVIF_STATE;
584 item.stateMask = 0xffff;
585 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
586 ok(item.state == 0xfccc, "state %x\n", item.state);
588 /* Don't set LVIF_STATE */
589 item.mask = LVIF_TEXT;
590 item.stateMask = 0xffff;
595 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
596 ok(r == 1, "ret %d\n", r);
599 item.mask = LVIF_STATE;
600 item.stateMask = 0xffff;
601 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
602 ok(item.state == 0, "state %x\n", item.state);
604 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
605 ok(r == 0, "should return zero\n");
607 /* Having turned on checkboxes, check that all existing items are set to 0x1000 (unchecked) */
609 item.mask = LVIF_STATE;
610 item.stateMask = 0xffff;
611 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
612 ok(item.state == 0x1ccc, "state %x\n", item.state);
614 /* Now add an item without specifying a state and check that its state goes to 0x1000 */
616 item.mask = LVIF_TEXT;
618 item.pszText = text2;
619 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
620 ok(r == 2, "ret %d\n", r);
623 item.mask = LVIF_STATE;
624 item.stateMask = 0xffff;
625 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
626 ok(item.state == 0x1000, "state %x\n", item.state);
628 /* Add a further item this time specifying a state and still its state goes to 0x1000 */
630 item.mask = LVIF_TEXT | LVIF_STATE;
631 item.stateMask = 0xffff;
633 item.pszText = text3;
634 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
635 ok(r == 3, "ret %d\n", r);
638 item.mask = LVIF_STATE;
639 item.stateMask = 0xffff;
640 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
641 ok(item.state == 0x1aaa, "state %x\n", item.state);
643 /* Set an item's state to checked */
645 item.mask = LVIF_STATE;
646 item.stateMask = 0xf000;
648 r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
651 item.mask = LVIF_STATE;
652 item.stateMask = 0xffff;
653 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
654 ok(item.state == 0x2aaa, "state %x\n", item.state);
656 /* Check that only the bits we asked for are returned,
657 * and that all the others are set to zero
660 item.mask = LVIF_STATE;
661 item.stateMask = 0xf000;
663 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
664 ok(item.state == 0x2000, "state %x\n", item.state);
666 /* Set the style again and check that doesn't change an item's state */
667 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
668 ok(r == LVS_EX_CHECKBOXES, "ret %x\n", r);
671 item.mask = LVIF_STATE;
672 item.stateMask = 0xffff;
673 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
674 ok(item.state == 0x2aaa, "state %x\n", item.state);
676 /* Unsetting the checkbox extended style doesn't change an item's state */
677 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, 0);
678 ok(r == LVS_EX_CHECKBOXES, "ret %x\n", r);
681 item.mask = LVIF_STATE;
682 item.stateMask = 0xffff;
683 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
684 ok(item.state == 0x2aaa, "state %x\n", item.state);
686 /* Now setting the style again will change an item's state */
687 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
688 ok(r == 0, "ret %x\n", r);
691 item.mask = LVIF_STATE;
692 item.stateMask = 0xffff;
693 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
694 ok(item.state == 0x1aaa, "state %x\n", item.state);
696 /* Toggle checkbox tests (bug 9934) */
697 memset (&item, 0xcc, sizeof(item));
698 item.mask = LVIF_STATE;
701 item.state = LVIS_FOCUSED;
702 item.stateMask = LVIS_FOCUSED;
703 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM) &item);
707 item.mask = LVIF_STATE;
708 item.stateMask = 0xffff;
709 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
710 ok(item.state == 0x1aab, "state %x\n", item.state);
712 r = SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0);
714 r = SendMessage(hwnd, WM_KEYUP, VK_SPACE, 0);
718 item.mask = LVIF_STATE;
719 item.stateMask = 0xffff;
720 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
721 ok(item.state == 0x2aab, "state %x\n", item.state);
723 r = SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0);
725 r = SendMessage(hwnd, WM_KEYUP, VK_SPACE, 0);
729 item.mask = LVIF_STATE;
730 item.stateMask = 0xffff;
731 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
732 ok(item.state == 0x1aab, "state %x\n", item.state);
737 static void insert_column(HWND hwnd, int idx)
742 memset(&column, 0xcc, sizeof(column));
743 column.mask = LVCF_SUBITEM;
744 column.iSubItem = idx;
746 rc = ListView_InsertColumn(hwnd, idx, &column);
750 static void insert_item(HWND hwnd, int idx)
752 static CHAR text[] = "foo";
757 memset(&item, 0xcc, sizeof (item));
758 item.mask = LVIF_TEXT;
763 rc = ListView_InsertItem(hwnd, &item);
767 static void test_items(void)
769 const LPARAM lparamTest = 0x42;
773 static CHAR text[] = "Text";
775 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT,
776 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
777 ok(hwnd != NULL, "failed to create listview window\n");
780 * Test setting/getting item params
783 /* Set up two columns */
784 insert_column(hwnd, 0);
785 insert_column(hwnd, 1);
787 /* LVIS_SELECTED with zero stateMask */
789 memset (&item, 0, sizeof (item));
790 item.mask = LVIF_STATE;
791 item.state = LVIS_SELECTED;
795 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
796 ok(r == 0, "ret %d\n", r);
798 memset (&item, 0xcc, sizeof (item));
799 item.mask = LVIF_STATE;
800 item.stateMask = LVIS_SELECTED;
804 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
805 ok(r != 0, "ret %d\n", r);
806 ok(item.state & LVIS_SELECTED, "Expected LVIS_SELECTED\n");
807 SendMessage(hwnd, LVM_DELETEITEM, 0, 0);
809 /* LVIS_SELECTED with zero stateMask */
811 memset (&item, 0, sizeof (item));
812 item.mask = LVIF_STATE;
813 item.state = LVIS_FOCUSED;
817 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
818 ok(r == 0, "ret %d\n", r);
820 memset (&item, 0xcc, sizeof (item));
821 item.mask = LVIF_STATE;
822 item.stateMask = LVIS_FOCUSED;
826 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
827 ok(r != 0, "ret %d\n", r);
828 ok(item.state & LVIS_FOCUSED, "Expected LVIS_FOCUSED\n");
829 SendMessage(hwnd, LVM_DELETEITEM, 0, 0);
831 /* LVIS_CUT with LVIS_FOCUSED stateMask */
833 memset (&item, 0, sizeof (item));
834 item.mask = LVIF_STATE;
835 item.state = LVIS_CUT;
836 item.stateMask = LVIS_FOCUSED;
839 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
840 ok(r == 0, "ret %d\n", r);
842 memset (&item, 0xcc, sizeof (item));
843 item.mask = LVIF_STATE;
844 item.stateMask = LVIS_CUT;
848 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
849 ok(r != 0, "ret %d\n", r);
850 ok(item.state & LVIS_CUT, "Expected LVIS_CUT\n");
851 SendMessage(hwnd, LVM_DELETEITEM, 0, 0);
853 /* Insert an item with just a param */
854 memset (&item, 0xcc, sizeof (item));
855 item.mask = LVIF_PARAM;
858 item.lParam = lparamTest;
859 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
860 ok(r == 0, "ret %d\n", r);
862 /* Test getting of the param */
863 memset (&item, 0xcc, sizeof (item));
864 item.mask = LVIF_PARAM;
867 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
868 ok(r != 0, "ret %d\n", r);
869 ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
871 /* Set up a subitem */
872 memset (&item, 0xcc, sizeof (item));
873 item.mask = LVIF_TEXT;
877 r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
878 ok(r != 0, "ret %d\n", r);
880 /* Query param from subitem: returns main item param */
881 memset (&item, 0xcc, sizeof (item));
882 item.mask = LVIF_PARAM;
885 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
886 ok(r != 0, "ret %d\n", r);
887 ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
889 /* Set up param on first subitem: no effect */
890 memset (&item, 0xcc, sizeof (item));
891 item.mask = LVIF_PARAM;
894 item.lParam = lparamTest+1;
895 r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
896 ok(r == 0, "ret %d\n", r);
898 /* Query param from subitem again: should still return main item param */
899 memset (&item, 0xcc, sizeof (item));
900 item.mask = LVIF_PARAM;
903 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
904 ok(r != 0, "ret %d\n", r);
905 ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
907 /**** Some tests of state highlighting ****/
908 memset (&item, 0xcc, sizeof (item));
909 item.mask = LVIF_STATE;
912 item.state = LVIS_SELECTED;
913 item.stateMask = LVIS_SELECTED | LVIS_DROPHILITED;
914 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM) &item);
915 ok(r != 0, "ret %d\n", r);
917 item.state = LVIS_DROPHILITED;
918 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM) &item);
919 ok(r != 0, "ret %d\n", r);
921 memset (&item, 0xcc, sizeof (item));
922 item.mask = LVIF_STATE;
926 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
927 ok(r != 0, "ret %d\n", r);
928 ok(item.state == LVIS_SELECTED, "got state %x, expected %x\n", item.state, LVIS_SELECTED);
930 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
931 ok(r != 0, "ret %d\n", r);
932 todo_wine ok(item.state == LVIS_DROPHILITED, "got state %x, expected %x\n", item.state, LVIS_DROPHILITED);
934 /* some notnull but meaningless masks */
935 memset (&item, 0, sizeof(item));
936 item.mask = LVIF_NORECOMPUTE;
939 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
940 ok(r != 0, "ret %d\n", r);
941 memset (&item, 0, sizeof(item));
942 item.mask = LVIF_DI_SETITEM;
945 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
946 ok(r != 0, "ret %d\n", r);
948 /* set text to callback value already having it */
949 r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
951 memset (&item, 0, sizeof (item));
952 item.mask = LVIF_TEXT;
953 item.pszText = LPSTR_TEXTCALLBACK;
955 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
956 ok(r == 0, "ret %d\n", r);
957 memset (&item, 0, sizeof (item));
959 flush_sequences(sequences, NUM_MSG_SEQUENCES);
961 item.pszText = LPSTR_TEXTCALLBACK;
962 r = SendMessage(hwnd, LVM_SETITEMTEXT, 0 , (LPARAM) &item);
965 ok_sequence(sequences, PARENT_SEQ_INDEX, textcallback_set_again_parent_seq,
966 "check callback text comparison rule", TRUE);
971 static void test_columns(void)
973 HWND hwnd, hwndheader;
978 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT,
979 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
980 ok(hwnd != NULL, "failed to create listview window\n");
982 /* Add a column with no mask */
983 memset(&column, 0xcc, sizeof(column));
985 rc = ListView_InsertColumn(hwnd, 0, &column);
986 ok(rc==0, "Inserting column with no mask failed with %d\n", rc);
988 /* Check its width */
989 rc = ListView_GetColumnWidth(hwnd, 0);
991 broken(rc==0), /* win9x */
992 "Inserting column with no mask failed to set width to 10 with %d\n", rc);
996 /* LVM_GETCOLUMNORDERARRAY */
997 hwnd = create_listview_control(0);
998 hwndheader = subclass_header(hwnd);
1000 memset(&column, 0, sizeof(column));
1001 column.mask = LVCF_WIDTH;
1003 rc = ListView_InsertColumn(hwnd, 0, &column);
1004 ok(rc == 0, "Inserting column failed with %d\n", rc);
1007 rc = ListView_InsertColumn(hwnd, 1, &column);
1008 ok(rc == 1, "Inserting column failed with %d\n", rc);
1010 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1012 rc = SendMessage(hwnd, LVM_GETCOLUMNORDERARRAY, 2, (LPARAM)&order);
1013 ok(rc != 0, "Expected LVM_GETCOLUMNORDERARRAY to succeed\n");
1014 ok(order[0] == 0, "Expected order 0, got %d\n", order[0]);
1015 ok(order[1] == 1, "Expected order 1, got %d\n", order[1]);
1017 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_getorderarray_seq, "get order array", FALSE);
1019 DestroyWindow(hwnd);
1021 /* test setting imagelist between WM_NCCREATE and WM_CREATE */
1022 static WNDPROC listviewWndProc;
1023 static HIMAGELIST test_create_imagelist;
1025 static LRESULT CALLBACK create_test_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1029 if (uMsg == WM_CREATE)
1031 LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
1032 lpcs->style |= LVS_REPORT;
1034 ret = CallWindowProc(listviewWndProc, hwnd, uMsg, wParam, lParam);
1035 if (uMsg == WM_CREATE) SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)test_create_imagelist);
1039 static void test_create(void)
1048 cls.cbSize = sizeof(WNDCLASSEX);
1049 ok(GetClassInfoEx(GetModuleHandle(NULL), "SysListView32", &cls), "GetClassInfoEx failed\n");
1050 listviewWndProc = cls.lpfnWndProc;
1051 cls.lpfnWndProc = create_test_wndproc;
1052 cls.lpszClassName = "MyListView32";
1053 ok(RegisterClassEx(&cls), "RegisterClassEx failed\n");
1055 test_create_imagelist = ImageList_Create(16, 16, 0, 5, 10);
1056 hList = CreateWindow("MyListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), 0);
1057 ok((HIMAGELIST)SendMessage(hList, LVM_GETIMAGELIST, 0, 0) == test_create_imagelist, "Image list not obtained\n");
1058 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1059 ok(IsWindow(hHeader) && IsWindowVisible(hHeader), "Listview not in report mode\n");
1060 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1061 DestroyWindow(hList);
1063 /* header isn't created on LVS_ICON and LVS_LIST styles */
1064 hList = CreateWindow("SysListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL,
1065 GetModuleHandle(NULL), 0);
1066 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1067 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1068 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1070 memset(&col, 0, sizeof(LVCOLUMNA));
1071 col.mask = LVCF_WIDTH;
1073 r = SendMessage(hList, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
1074 ok(r == 0, "Expected 0 column's inserted\n");
1075 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1076 ok(IsWindow(hHeader), "Header should be created\n");
1077 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1078 DestroyWindow(hList);
1080 hList = CreateWindow("SysListView32", "Test", WS_VISIBLE|LVS_LIST, 0, 0, 100, 100, NULL, NULL,
1081 GetModuleHandle(NULL), 0);
1082 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1083 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1084 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1086 memset(&col, 0, sizeof(LVCOLUMNA));
1087 col.mask = LVCF_WIDTH;
1089 r = SendMessage(hList, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
1090 ok(r == 0, "Expected 0 column's inserted\n");
1091 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1092 ok(IsWindow(hHeader), "Header should be created\n");
1093 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1094 DestroyWindow(hList);
1096 /* try to switch LVS_ICON -> LVS_REPORT and back LVS_ICON -> LVS_REPORT */
1097 hList = CreateWindow("SysListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL,
1098 GetModuleHandle(NULL), 0);
1099 ret = SetWindowLongPtr(hList, GWL_STYLE, GetWindowLongPtr(hList, GWL_STYLE) | LVS_REPORT);
1100 ok(ret & WS_VISIBLE, "Style wrong, should have WS_VISIBLE\n");
1101 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1102 ok(IsWindow(hHeader), "Header should be created\n");
1103 ret = SetWindowLongPtr(hList, GWL_STYLE, GetWindowLong(hList, GWL_STYLE) & ~LVS_REPORT);
1104 ok((ret & WS_VISIBLE) && (ret & LVS_REPORT), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1105 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1106 ok(IsWindow(hHeader), "Header should be created\n");
1107 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1108 DestroyWindow(hList);
1110 /* try to switch LVS_LIST -> LVS_REPORT and back LVS_LIST -> LVS_REPORT */
1111 hList = CreateWindow("SysListView32", "Test", WS_VISIBLE|LVS_LIST, 0, 0, 100, 100, NULL, NULL,
1112 GetModuleHandle(NULL), 0);
1113 ret = SetWindowLongPtr(hList, GWL_STYLE,
1114 (GetWindowLongPtr(hList, GWL_STYLE) & ~LVS_LIST) | LVS_REPORT);
1115 ok(((ret & WS_VISIBLE) && (ret & LVS_LIST)), "Style wrong, should have WS_VISIBLE|LVS_LIST\n");
1116 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1117 ok(IsWindow(hHeader), "Header should be created\n");
1118 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1119 ret = SetWindowLongPtr(hList, GWL_STYLE,
1120 (GetWindowLongPtr(hList, GWL_STYLE) & ~LVS_REPORT) | LVS_LIST);
1121 ok(((ret & WS_VISIBLE) && (ret & LVS_REPORT)), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1122 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1123 ok(IsWindow(hHeader), "Header should be created\n");
1124 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1125 DestroyWindow(hList);
1127 /* LVS_REPORT without WS_VISIBLE */
1128 hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1129 GetModuleHandle(NULL), 0);
1130 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1131 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1132 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1134 memset(&col, 0, sizeof(LVCOLUMNA));
1135 col.mask = LVCF_WIDTH;
1137 r = SendMessage(hList, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
1138 ok(r == 0, "Expected 0 column's inserted\n");
1139 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1140 ok(IsWindow(hHeader), "Header should be created\n");
1141 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1142 DestroyWindow(hList);
1144 /* LVS_REPORT without WS_VISIBLE, try to show it */
1145 hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1146 GetModuleHandle(NULL), 0);
1147 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1148 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1149 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1150 ShowWindow(hList, SW_SHOW);
1151 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1152 ok(IsWindow(hHeader), "Header should be created\n");
1153 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1154 DestroyWindow(hList);
1156 /* LVS_REPORT with LVS_NOCOLUMNHEADER */
1157 hList = CreateWindow("SysListView32", "Test", LVS_REPORT|LVS_NOCOLUMNHEADER|WS_VISIBLE,
1158 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), 0);
1159 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1160 ok(IsWindow(hHeader), "Header should be created\n");
1161 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1162 /* HDS_DRAGDROP set by default */
1163 ok(GetWindowLongPtr(hHeader, GWL_STYLE) & HDS_DRAGDROP, "Expected header to have HDS_DRAGDROP\n");
1164 DestroyWindow(hList);
1166 /* setting LVS_EX_HEADERDRAGDROP creates header */
1167 hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1168 GetModuleHandle(NULL), 0);
1169 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1170 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1171 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1172 SendMessage(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_HEADERDRAGDROP);
1173 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1174 ok(IsWindow(hHeader), "Header should be created\n");
1175 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1176 DestroyWindow(hList);
1178 /* not report style accepts LVS_EX_HEADERDRAGDROP too */
1179 hList = create_custom_listview_control(0);
1180 SendMessage(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_HEADERDRAGDROP);
1181 r = SendMessage(hList, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
1182 ok(r & LVS_EX_HEADERDRAGDROP, "Expected LVS_EX_HEADERDRAGDROP to be set\n");
1183 DestroyWindow(hList);
1185 /* requesting header info with LVM_GETSUBITEMRECT doesn't create it */
1186 hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1187 GetModuleHandle(NULL), 0);
1188 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1189 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1191 rect.left = LVIR_BOUNDS;
1193 rect.right = rect.bottom = -10;
1194 r = SendMessage(hList, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
1195 ok(r != 0, "Expected not-null LRESULT\n");
1197 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1198 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1199 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1201 DestroyWindow(hList);
1204 static void test_redraw(void)
1206 HWND hwnd, hwndheader;
1211 hwnd = create_listview_control(0);
1212 hwndheader = subclass_header(hwnd);
1214 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1216 trace("invalidate & update\n");
1217 InvalidateRect(hwnd, NULL, TRUE);
1219 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, redraw_listview_seq, "redraw listview", FALSE);
1221 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1223 /* forward WM_ERASEBKGND to parent on CLR_NONE background color */
1224 /* 1. Without backbuffer */
1225 res = ListView_SetBkColor(hwnd, CLR_NONE);
1228 hdc = GetWindowDC(hwndparent);
1230 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1231 r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1232 ok(r != 0, "Expected not zero result\n");
1233 ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, forward_erasebkgnd_parent_seq,
1234 "forward WM_ERASEBKGND on CLR_NONE", FALSE);
1236 res = ListView_SetBkColor(hwnd, CLR_DEFAULT);
1239 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1240 r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1241 ok(r != 0, "Expected not zero result\n");
1242 ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, empty_seq,
1243 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE);
1245 /* 2. With backbuffer */
1246 SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_DOUBLEBUFFER,
1247 LVS_EX_DOUBLEBUFFER);
1248 res = ListView_SetBkColor(hwnd, CLR_NONE);
1251 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1252 r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1253 ok(r != 0, "Expected not zero result\n");
1254 ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, forward_erasebkgnd_parent_seq,
1255 "forward WM_ERASEBKGND on CLR_NONE", FALSE);
1257 res = ListView_SetBkColor(hwnd, CLR_DEFAULT);
1260 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1261 r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1262 todo_wine ok(r != 0, "Expected not zero result\n");
1263 ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, empty_seq,
1264 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE);
1266 ReleaseDC(hwndparent, hdc);
1268 DestroyWindow(hwnd);
1271 static LRESULT WINAPI cd_wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
1273 COLORREF clr, c0ffee = RGB(0xc0, 0xff, 0xee);
1275 if(msg == WM_NOTIFY) {
1276 NMHDR *nmhdr = (PVOID)lp;
1277 if(nmhdr->code == NM_CUSTOMDRAW) {
1278 NMLVCUSTOMDRAW *nmlvcd = (PVOID)nmhdr;
1279 trace("NMCUSTOMDRAW (0x%.8x)\n", nmlvcd->nmcd.dwDrawStage);
1280 switch(nmlvcd->nmcd.dwDrawStage) {
1282 SetBkColor(nmlvcd->nmcd.hdc, c0ffee);
1283 return CDRF_NOTIFYITEMDRAW;
1284 case CDDS_ITEMPREPAINT:
1285 nmlvcd->clrTextBk = CLR_DEFAULT;
1286 return CDRF_NOTIFYSUBITEMDRAW;
1287 case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
1288 clr = GetBkColor(nmlvcd->nmcd.hdc);
1289 todo_wine ok(clr == c0ffee, "clr=%.8x\n", clr);
1290 return CDRF_NOTIFYPOSTPAINT;
1291 case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
1292 clr = GetBkColor(nmlvcd->nmcd.hdc);
1293 todo_wine ok(clr == c0ffee, "clr=%.8x\n", clr);
1294 return CDRF_DODEFAULT;
1296 return CDRF_DODEFAULT;
1300 return DefWindowProcA(hwnd, msg, wp, lp);
1303 static void test_customdraw(void)
1308 hwnd = create_listview_control(0);
1310 insert_column(hwnd, 0);
1311 insert_column(hwnd, 1);
1312 insert_item(hwnd, 0);
1314 oldwndproc = (WNDPROC)SetWindowLongPtr(hwndparent, GWLP_WNDPROC,
1315 (LONG_PTR)cd_wndproc);
1317 InvalidateRect(hwnd, NULL, TRUE);
1320 SetWindowLongPtr(hwndparent, GWLP_WNDPROC, (LONG_PTR)oldwndproc);
1322 DestroyWindow(hwnd);
1325 static void test_icon_spacing(void)
1327 /* LVM_SETICONSPACING */
1328 /* note: LVM_SETICONSPACING returns the previous icon spacing if successful */
1334 hwnd = create_custom_listview_control(LVS_ICON);
1335 ok(hwnd != NULL, "failed to create a listview window\n");
1337 r = SendMessage(hwnd, WM_NOTIFYFORMAT, (WPARAM)hwndparent, (LPARAM)NF_REQUERY);
1338 expect(NFR_ANSI, r);
1340 /* reset the icon spacing to defaults */
1341 SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1, -1));
1343 /* now we can request what the defaults are */
1344 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1, -1));
1348 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1350 trace("test icon spacing\n");
1352 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(20, 30));
1353 ok(r == MAKELONG(w, h) ||
1354 broken(r == MAKELONG(w, w)), /* win98 */
1355 "Expected %d, got %d\n", MAKELONG(w, h), r);
1357 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(25, 35));
1358 expect(MAKELONG(20,30), r);
1360 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1,-1));
1361 expect(MAKELONG(25,35), r);
1363 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_icon_spacing_seq, "test icon spacing seq", FALSE);
1365 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1366 DestroyWindow(hwnd);
1369 static void test_color(void)
1371 /* SETBKCOLOR/GETBKCOLOR, SETTEXTCOLOR/GETTEXTCOLOR, SETTEXTBKCOLOR/GETTEXTBKCOLOR */
1378 COLORREF colors[4] = {RGB(0,0,0), RGB(100,50,200), CLR_NONE, RGB(255,255,255)};
1380 hwnd = create_listview_control(0);
1381 ok(hwnd != NULL, "failed to create a listview window\n");
1383 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1385 trace("test color seq\n");
1386 for (i = 0; i < 4; i++)
1390 r = SendMessage(hwnd, LVM_SETBKCOLOR, 0, color);
1392 r = SendMessage(hwnd, LVM_GETBKCOLOR, 0, color);
1395 r = SendMessage(hwnd, LVM_SETTEXTCOLOR, 0, color);
1397 r = SendMessage(hwnd, LVM_GETTEXTCOLOR, 0, color);
1400 r = SendMessage(hwnd, LVM_SETTEXTBKCOLOR, 0, color);
1402 r = SendMessage(hwnd, LVM_GETTEXTBKCOLOR, 0, color);
1406 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_color_seq, "test color seq", FALSE);
1408 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1409 DestroyWindow(hwnd);
1412 static void test_item_count(void)
1414 /* LVM_INSERTITEM, LVM_DELETEITEM, LVM_DELETEALLITEMS, LVM_GETITEMCOUNT */
1422 static CHAR item0text[] = "item0";
1423 static CHAR item1text[] = "item1";
1424 static CHAR item2text[] = "item2";
1426 hwnd = create_listview_control(0);
1427 ok(hwnd != NULL, "failed to create a listview window\n");
1429 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1431 trace("test item count\n");
1433 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1437 item0.mask = LVIF_TEXT;
1440 item0.pszText = item0text;
1441 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item0);
1444 /* [item0, item1] */
1445 item1.mask = LVIF_TEXT;
1448 item1.pszText = item1text;
1449 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item1);
1452 /* [item0, item1, item2] */
1453 item2.mask = LVIF_TEXT;
1456 item2.pszText = item2text;
1457 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item2);
1460 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1463 /* [item0, item1] */
1464 r = SendMessage(hwnd, LVM_DELETEITEM, 2, 0);
1467 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1471 r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
1474 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1478 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item1);
1481 /* [item0, item1] */
1482 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item1);
1485 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1488 /* [item0, item1, item2] */
1489 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item2);
1492 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1495 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_item_count_seq, "test item count seq", FALSE);
1497 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1498 DestroyWindow(hwnd);
1501 static void test_item_position(void)
1503 /* LVM_SETITEMPOSITION/LVM_GETITEMPOSITION */
1512 static CHAR item0text[] = "item0";
1513 static CHAR item1text[] = "item1";
1514 static CHAR item2text[] = "item2";
1516 hwnd = create_custom_listview_control(LVS_ICON);
1517 ok(hwnd != NULL, "failed to create a listview window\n");
1519 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1521 trace("test item position\n");
1524 item0.mask = LVIF_TEXT;
1527 item0.pszText = item0text;
1528 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item0);
1531 /* [item0, item1] */
1532 item1.mask = LVIF_TEXT;
1535 item1.pszText = item1text;
1536 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item1);
1539 /* [item0, item1, item2] */
1540 item2.mask = LVIF_TEXT;
1543 item2.pszText = item2text;
1544 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item2);
1547 r = SendMessage(hwnd, LVM_SETITEMPOSITION, 1, MAKELPARAM(10,5));
1549 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 1, (LPARAM) &position);
1551 expect2(10, 5, position.x, position.y);
1553 r = SendMessage(hwnd, LVM_SETITEMPOSITION, 2, MAKELPARAM(0,0));
1555 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 2, (LPARAM) &position);
1557 expect2(0, 0, position.x, position.y);
1559 r = SendMessage(hwnd, LVM_SETITEMPOSITION, 0, MAKELPARAM(20,20));
1561 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM) &position);
1563 expect2(20, 20, position.x, position.y);
1565 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_itempos_seq, "test item position seq", TRUE);
1567 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1568 DestroyWindow(hwnd);
1571 static void test_getorigin(void)
1579 position.x = position.y = 0;
1581 hwnd = create_custom_listview_control(LVS_ICON);
1582 ok(hwnd != NULL, "failed to create a listview window\n");
1583 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1584 trace("test get origin results\n");
1585 r = SendMessage(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
1587 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1588 DestroyWindow(hwnd);
1590 hwnd = create_custom_listview_control(LVS_SMALLICON);
1591 ok(hwnd != NULL, "failed to create a listview window\n");
1592 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1593 trace("test get origin results\n");
1594 r = SendMessage(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
1596 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1597 DestroyWindow(hwnd);
1599 hwnd = create_custom_listview_control(LVS_LIST);
1600 ok(hwnd != NULL, "failed to create a listview window\n");
1601 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1602 trace("test get origin results\n");
1603 r = SendMessage(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
1605 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1606 DestroyWindow(hwnd);
1608 hwnd = create_custom_listview_control(LVS_REPORT);
1609 ok(hwnd != NULL, "failed to create a listview window\n");
1610 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1611 trace("test get origin results\n");
1612 r = SendMessage(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
1614 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1615 DestroyWindow(hwnd);
1619 static void test_multiselect(void)
1621 typedef struct t_select_task
1632 int i,j,item_count,selected_count;
1633 static const int items=5;
1639 static struct t_select_task task_list[] = {
1640 { "using VK_DOWN", 0, VK_DOWN, -1, -1 },
1641 { "using VK_UP", -1, VK_UP, -1, -1 },
1642 { "using VK_END", 0, VK_END, 1, -1 },
1643 { "using VK_HOME", -1, VK_HOME, 1, -1 }
1647 hwnd = create_listview_control(0);
1649 for (i=0;i<items;i++) {
1650 insert_item(hwnd, 0);
1653 item_count = (int)SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1655 expect(items,item_count);
1658 task = task_list[i];
1660 /* deselect all items */
1661 ListView_SetItemState(hwnd, -1, 0, LVIS_SELECTED);
1662 SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, -1);
1664 /* set initial position */
1665 SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, (task.initPos == -1 ? item_count -1 : task.initPos));
1666 ListView_SetItemState(hwnd,(task.initPos == -1 ? item_count -1 : task.initPos),LVIS_SELECTED ,LVIS_SELECTED);
1668 selected_count = (int)SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1670 ok(selected_count == 1, "There should be only one selected item at the beginning (is %d)\n",selected_count);
1672 /* Set SHIFT key pressed */
1673 GetKeyboardState(kstate);
1674 kstate[VK_SHIFT]=0x80;
1675 SetKeyboardState(kstate);
1677 for (j=1;j<=(task.count == -1 ? item_count : task.count);j++) {
1678 r = SendMessage(hwnd, WM_KEYDOWN, task.loopVK, 0);
1680 r = SendMessage(hwnd, WM_KEYUP, task.loopVK, 0);
1684 selected_count = (int)SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1686 ok((task.result == -1 ? item_count : task.result) == selected_count, "Failed multiple selection %s. There should be %d selected items (is %d)\n", task.descr, item_count, selected_count);
1688 /* Set SHIFT key released */
1689 GetKeyboardState(kstate);
1690 kstate[VK_SHIFT]=0x00;
1691 SetKeyboardState(kstate);
1693 DestroyWindow(hwnd);
1695 /* make multiple selection, then switch to LVS_SINGLESEL */
1696 hwnd = create_listview_control(0);
1697 for (i=0;i<items;i++) {
1698 insert_item(hwnd, 0);
1700 item_count = (int)SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1701 expect(items,item_count);
1702 /* deselect all items */
1703 ListView_SetItemState(hwnd, -1, 0, LVIS_SELECTED);
1704 SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, -1);
1706 ListView_SetItemState(hwnd, i, LVIS_SELECTED, LVIS_SELECTED);
1709 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1711 r = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
1715 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
1716 ok(!(style & LVS_SINGLESEL), "LVS_SINGLESEL isn't expected\n");
1717 SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SINGLESEL);
1718 /* check that style is accepted */
1719 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
1720 ok(style & LVS_SINGLESEL, "LVS_SINGLESEL expected\n");
1723 r = ListView_GetItemState(hwnd, i, LVIS_SELECTED);
1724 ok(r & LVIS_SELECTED, "Expected item %d to be selected\n", i);
1726 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1728 SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
1731 /* select one more */
1732 ListView_SetItemState(hwnd, 3, LVIS_SELECTED, LVIS_SELECTED);
1735 r = ListView_GetItemState(hwnd, i, LVIS_SELECTED);
1736 ok(!(r & LVIS_SELECTED), "Expected item %d to be unselected\n", i);
1738 r = ListView_GetItemState(hwnd, 3, LVIS_SELECTED);
1739 ok(r & LVIS_SELECTED, "Expected item %d to be selected\n", i);
1741 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1743 r = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
1747 /* try to select all on LVS_SINGLESEL */
1748 memset(&item, 0, sizeof(item));
1749 item.stateMask = LVIS_SELECTED;
1750 r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
1752 SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, -1);
1754 item.stateMask = LVIS_SELECTED;
1755 item.state = LVIS_SELECTED;
1756 r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
1759 r = ListView_GetSelectedCount(hwnd);
1761 r = ListView_GetSelectionMark(hwnd);
1764 /* try to deselect all on LVS_SINGLESEL */
1765 item.stateMask = LVIS_SELECTED;
1766 item.state = LVIS_SELECTED;
1767 r = SendMessage(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
1770 item.stateMask = LVIS_SELECTED;
1772 r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
1774 r = ListView_GetSelectedCount(hwnd);
1777 DestroyWindow(hwnd);
1780 static void test_subitem_rect(void)
1787 /* test LVM_GETSUBITEMRECT for header */
1788 hwnd = create_listview_control(0);
1789 ok(hwnd != NULL, "failed to create a listview window\n");
1790 /* add some columns */
1791 memset(&col, 0, sizeof(LVCOLUMN));
1792 col.mask = LVCF_WIDTH;
1795 r = SendMessage(hwnd, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
1799 r = SendMessage(hwnd, LVM_INSERTCOLUMN, 1, (LPARAM)&col);
1803 r = SendMessage(hwnd, LVM_INSERTCOLUMN, 2, (LPARAM)&col);
1805 /* item = -1 means header, subitem index is 1 based */
1806 rect.left = LVIR_BOUNDS;
1808 rect.right = rect.bottom = 0;
1809 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
1812 rect.left = LVIR_BOUNDS;
1814 rect.right = rect.bottom = 0;
1815 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
1817 ok(r != 0, "Expected not-null LRESULT\n");
1818 expect(100, rect.left);
1819 expect(250, rect.right);
1821 expect(3, rect.top);
1823 rect.left = LVIR_BOUNDS;
1825 rect.right = rect.bottom = 0;
1826 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
1828 ok(r != 0, "Expected not-null LRESULT\n");
1829 expect(250, rect.left);
1830 expect(450, rect.right);
1832 expect(3, rect.top);
1834 /* item LVS_REPORT padding isn't applied to subitems */
1835 insert_item(hwnd, 0);
1837 rect.left = LVIR_BOUNDS;
1839 rect.right = rect.bottom = 0;
1840 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
1841 ok(r != 0, "Expected not-null LRESULT\n");
1842 expect(100, rect.left);
1843 expect(250, rect.right);
1845 rect.left = LVIR_ICON;
1847 rect.right = rect.bottom = 0;
1848 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
1849 ok(r != 0, "Expected not-null LRESULT\n");
1850 /* no icon attached - zero width rectangle, with no left padding */
1851 expect(100, rect.left);
1852 expect(100, rect.right);
1854 rect.left = LVIR_LABEL;
1856 rect.right = rect.bottom = 0;
1857 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
1858 ok(r != 0, "Expected not-null LRESULT\n");
1859 /* same as full LVIR_BOUNDS */
1860 expect(100, rect.left);
1861 expect(250, rect.right);
1863 DestroyWindow(hwnd);
1865 /* try it for non LVS_REPORT style */
1866 hwnd = CreateWindow("SysListView32", "Test", LVS_ICON, 0, 0, 100, 100, NULL, NULL,
1867 GetModuleHandle(NULL), 0);
1868 rect.left = LVIR_BOUNDS;
1870 rect.right = rect.bottom = -10;
1871 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
1872 ok(r == 0, "Expected not-null LRESULT\n");
1873 /* rect is unchanged */
1874 expect(0, rect.left);
1875 expect(-10, rect.right);
1876 expect(1, rect.top);
1877 expect(-10, rect.bottom);
1878 DestroyWindow(hwnd);
1881 /* comparison callback for test_sorting */
1882 static INT WINAPI test_CallBackCompare(LPARAM first, LPARAM second, LPARAM lParam)
1884 if (first == second) return 0;
1885 return (first > second ? 1 : -1);
1888 static void test_sorting(void)
1894 static CHAR names[][5] = {"A", "B", "C", "D", "0"};
1897 hwnd = create_listview_control(0);
1898 ok(hwnd != NULL, "failed to create a listview window\n");
1900 /* insert some items */
1901 item.mask = LVIF_PARAM | LVIF_STATE;
1902 item.state = LVIS_SELECTED;
1906 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
1909 item.mask = LVIF_PARAM;
1913 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
1916 item.mask = LVIF_STATE | LVIF_PARAM;
1917 item.state = LVIS_SELECTED;
1921 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
1924 r = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
1927 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1930 r = SendMessage(hwnd, LVM_SORTITEMS, 0, (LPARAM)test_CallBackCompare);
1933 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1935 r = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
1937 r = SendMessage(hwnd, LVM_GETITEMSTATE, 0, LVIS_SELECTED);
1939 r = SendMessage(hwnd, LVM_GETITEMSTATE, 1, LVIS_SELECTED);
1940 expect(LVIS_SELECTED, r);
1941 r = SendMessage(hwnd, LVM_GETITEMSTATE, 2, LVIS_SELECTED);
1942 expect(LVIS_SELECTED, r);
1944 DestroyWindow(hwnd);
1946 /* switch to LVS_SORTASCENDING when some items added */
1947 hwnd = create_listview_control(0);
1948 ok(hwnd != NULL, "failed to create a listview window\n");
1950 item.mask = LVIF_TEXT;
1953 item.pszText = names[1];
1954 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
1957 item.mask = LVIF_TEXT;
1960 item.pszText = names[2];
1961 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
1964 item.mask = LVIF_TEXT;
1967 item.pszText = names[0];
1968 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
1971 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
1972 SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTASCENDING);
1973 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
1974 ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
1976 /* no sorting performed when switched to LVS_SORTASCENDING */
1977 item.mask = LVIF_TEXT;
1979 item.pszText = buff;
1980 item.cchTextMax = sizeof(buff);
1981 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
1983 ok(lstrcmp(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
1986 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
1988 ok(lstrcmp(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
1991 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
1993 ok(lstrcmp(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
1995 /* adding new item doesn't resort list */
1996 item.mask = LVIF_TEXT;
1999 item.pszText = names[3];
2000 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2003 item.mask = LVIF_TEXT;
2005 item.pszText = buff;
2006 item.cchTextMax = sizeof(buff);
2007 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2009 ok(lstrcmp(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
2012 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2014 ok(lstrcmp(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
2017 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2019 ok(lstrcmp(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
2022 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2024 ok(lstrcmp(buff, names[3]) == 0, "Expected '%s', got '%s'\n", names[3], buff);
2026 /* corner case - item should be placed at first position */
2027 item.mask = LVIF_TEXT;
2030 item.pszText = names[4];
2031 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2035 item.pszText = buff;
2036 item.cchTextMax = sizeof(buff);
2037 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2039 ok(lstrcmp(buff, names[4]) == 0, "Expected '%s', got '%s'\n", names[4], buff);
2042 item.pszText = buff;
2043 item.cchTextMax = sizeof(buff);
2044 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2046 ok(lstrcmp(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
2049 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2051 ok(lstrcmp(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
2054 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2056 ok(lstrcmp(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
2059 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2061 ok(lstrcmp(buff, names[3]) == 0, "Expected '%s', got '%s'\n", names[3], buff);
2063 DestroyWindow(hwnd);
2066 static void test_ownerdata(void)
2069 LONG_PTR style, ret;
2073 /* it isn't possible to set LVS_OWNERDATA after creation */
2074 hwnd = create_listview_control(0);
2075 ok(hwnd != NULL, "failed to create a listview window\n");
2076 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2077 ok(!(style & LVS_OWNERDATA) && style, "LVS_OWNERDATA isn't expected\n");
2079 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2081 ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_OWNERDATA);
2082 ok(ret == style, "Expected set GWL_STYLE to succeed\n");
2083 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
2084 "try to switch to LVS_OWNERDATA seq", FALSE);
2086 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2087 ok(!(style & LVS_OWNERDATA), "LVS_OWNERDATA isn't expected\n");
2088 DestroyWindow(hwnd);
2090 /* try to set LVS_OWNERDATA after creation just having it */
2091 hwnd = create_listview_control(LVS_OWNERDATA);
2092 ok(hwnd != NULL, "failed to create a listview window\n");
2093 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2094 ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
2096 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2098 ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_OWNERDATA);
2099 ok(ret == style, "Expected set GWL_STYLE to succeed\n");
2100 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
2101 "try to switch to LVS_OWNERDATA seq", FALSE);
2102 DestroyWindow(hwnd);
2104 /* try to remove LVS_OWNERDATA after creation just having it */
2105 hwnd = create_listview_control(LVS_OWNERDATA);
2106 ok(hwnd != NULL, "failed to create a listview window\n");
2107 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2108 ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
2110 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2112 ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_OWNERDATA);
2113 ok(ret == style, "Expected set GWL_STYLE to succeed\n");
2114 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
2115 "try to switch to LVS_OWNERDATA seq", FALSE);
2116 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2117 ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
2118 DestroyWindow(hwnd);
2120 /* try select an item */
2121 hwnd = create_listview_control(LVS_OWNERDATA);
2122 ok(hwnd != NULL, "failed to create a listview window\n");
2123 res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
2124 ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2125 res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2127 memset(&item, 0, sizeof(item));
2128 item.stateMask = LVIS_SELECTED;
2129 item.state = LVIS_SELECTED;
2130 res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2132 res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2134 res = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2136 DestroyWindow(hwnd);
2138 /* LVM_SETITEM is unsupported on LVS_OWNERDATA */
2139 hwnd = create_listview_control(LVS_OWNERDATA);
2140 ok(hwnd != NULL, "failed to create a listview window\n");
2141 res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
2142 ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2143 res = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2145 memset(&item, 0, sizeof(item));
2146 item.mask = LVIF_STATE;
2148 item.stateMask = LVIS_SELECTED;
2149 item.state = LVIS_SELECTED;
2150 res = SendMessageA(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2152 DestroyWindow(hwnd);
2154 /* check notifications after focused/selected changed */
2155 hwnd = create_listview_control(LVS_OWNERDATA);
2156 ok(hwnd != NULL, "failed to create a listview window\n");
2157 res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
2158 ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2160 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2162 memset(&item, 0, sizeof(item));
2163 item.stateMask = LVIS_SELECTED;
2164 item.state = LVIS_SELECTED;
2165 res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2168 ok_sequence(sequences, PARENT_SEQ_INDEX, ownderdata_select_focus_parent_seq,
2169 "ownerdata select notification", TRUE);
2171 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2173 memset(&item, 0, sizeof(item));
2174 item.stateMask = LVIS_FOCUSED;
2175 item.state = LVIS_FOCUSED;
2176 res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2179 ok_sequence(sequences, PARENT_SEQ_INDEX, ownderdata_select_focus_parent_seq,
2180 "ownerdata focus notification", TRUE);
2181 DestroyWindow(hwnd);
2183 /* check notifications on LVM_GETITEM */
2184 /* zero callback mask */
2185 hwnd = create_listview_control(LVS_OWNERDATA);
2186 ok(hwnd != NULL, "failed to create a listview window\n");
2187 res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
2188 ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2190 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2192 memset(&item, 0, sizeof(item));
2193 item.stateMask = LVIS_SELECTED;
2194 item.mask = LVIF_STATE;
2195 res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
2198 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
2199 "ownerdata getitem selected state 1", FALSE);
2201 /* non zero callback mask but not we asking for */
2202 res = SendMessageA(hwnd, LVM_SETCALLBACKMASK, LVIS_OVERLAYMASK, 0);
2205 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2207 memset(&item, 0, sizeof(item));
2208 item.stateMask = LVIS_SELECTED;
2209 item.mask = LVIF_STATE;
2210 res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
2213 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
2214 "ownerdata getitem selected state 2", FALSE);
2216 /* LVIS_OVERLAYMASK callback mask, asking for index */
2217 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2219 memset(&item, 0, sizeof(item));
2220 item.stateMask = LVIS_OVERLAYMASK;
2221 item.mask = LVIF_STATE;
2222 res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
2225 ok_sequence(sequences, PARENT_SEQ_INDEX, single_getdispinfo_parent_seq,
2226 "ownerdata getitem selected state 2", FALSE);
2228 DestroyWindow(hwnd);
2230 /* LVS_SORTASCENDING/LVS_SORTDESCENDING aren't compatible with LVS_OWNERDATA */
2231 hwnd = create_listview_control(LVS_OWNERDATA | LVS_SORTASCENDING);
2232 ok(hwnd != NULL, "failed to create a listview window\n");
2233 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2234 ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
2235 ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
2236 SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_SORTASCENDING);
2237 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2238 ok(!(style & LVS_SORTASCENDING), "Expected LVS_SORTASCENDING not set\n");
2239 DestroyWindow(hwnd);
2240 /* apparently it's allowed to switch these style on after creation */
2241 hwnd = create_listview_control(LVS_OWNERDATA);
2242 ok(hwnd != NULL, "failed to create a listview window\n");
2243 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2244 ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
2245 SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTASCENDING);
2246 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2247 ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
2248 DestroyWindow(hwnd);
2250 hwnd = create_listview_control(LVS_OWNERDATA);
2251 ok(hwnd != NULL, "failed to create a listview window\n");
2252 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2253 ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
2254 SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTDESCENDING);
2255 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2256 ok(style & LVS_SORTDESCENDING, "Expected LVS_SORTDESCENDING to be set\n");
2257 DestroyWindow(hwnd);
2260 static void test_norecompute(void)
2262 static CHAR testA[] = "test";
2268 /* self containing control */
2269 hwnd = create_listview_control(0);
2270 ok(hwnd != NULL, "failed to create a listview window\n");
2271 memset(&item, 0, sizeof(item));
2272 item.mask = LVIF_TEXT | LVIF_STATE;
2274 item.stateMask = LVIS_SELECTED;
2275 item.state = LVIS_SELECTED;
2276 item.pszText = testA;
2277 res = SendMessageA(hwnd, LVM_INSERTITEM, 0, (LPARAM)&item);
2279 /* retrieve with LVIF_NORECOMPUTE */
2280 item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
2282 item.pszText = buff;
2283 item.cchTextMax = sizeof(buff)/sizeof(CHAR);
2284 res = SendMessageA(hwnd, LVM_GETITEM, 0, (LPARAM)&item);
2286 ok(lstrcmp(buff, testA) == 0, "Expected (%s), got (%s)\n", testA, buff);
2288 item.mask = LVIF_TEXT;
2290 item.pszText = LPSTR_TEXTCALLBACK;
2291 res = SendMessageA(hwnd, LVM_INSERTITEM, 0, (LPARAM)&item);
2294 item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
2296 item.pszText = buff;
2297 item.cchTextMax = sizeof(buff)/sizeof(CHAR);
2299 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2300 res = SendMessageA(hwnd, LVM_GETITEM, 0, (LPARAM)&item);
2302 ok(item.pszText == LPSTR_TEXTCALLBACK, "Expected (%p), got (%p)\n",
2303 LPSTR_TEXTCALLBACK, (VOID*)item.pszText);
2304 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "retrieve with LVIF_NORECOMPUTE seq", FALSE);
2306 DestroyWindow(hwnd);
2309 hwnd = create_listview_control(LVS_OWNERDATA);
2310 ok(hwnd != NULL, "failed to create a listview window\n");
2312 item.mask = LVIF_STATE;
2313 item.stateMask = LVIS_SELECTED;
2314 item.state = LVIS_SELECTED;
2316 res = SendMessageA(hwnd, LVM_INSERTITEM, 0, (LPARAM)&item);
2319 item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
2321 item.pszText = buff;
2322 item.cchTextMax = sizeof(buff)/sizeof(CHAR);
2323 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2324 res = SendMessageA(hwnd, LVM_GETITEM, 0, (LPARAM)&item);
2326 ok(item.pszText == LPSTR_TEXTCALLBACK, "Expected (%p), got (%p)\n",
2327 LPSTR_TEXTCALLBACK, (VOID*)item.pszText);
2328 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "retrieve with LVIF_NORECOMPUTE seq 2", FALSE);
2330 DestroyWindow(hwnd);
2333 static void test_nosortheader(void)
2338 hwnd = create_listview_control(0);
2339 ok(hwnd != NULL, "failed to create a listview window\n");
2341 header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
2342 ok(IsWindow(header), "header expected\n");
2344 style = GetWindowLongPtr(header, GWL_STYLE);
2345 ok(style & HDS_BUTTONS, "expected header to have HDS_BUTTONS\n");
2347 style = GetWindowLongPtr(hwnd, GWL_STYLE);
2348 SetWindowLongPtr(hwnd, GWL_STYLE, style | LVS_NOSORTHEADER);
2349 /* HDS_BUTTONS retained */
2350 style = GetWindowLongPtr(header, GWL_STYLE);
2351 ok(style & HDS_BUTTONS, "expected header to retain HDS_BUTTONS\n");
2353 DestroyWindow(hwnd);
2355 /* create with LVS_NOSORTHEADER */
2356 hwnd = create_listview_control(LVS_NOSORTHEADER);
2357 ok(hwnd != NULL, "failed to create a listview window\n");
2359 header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
2360 ok(IsWindow(header), "header expected\n");
2362 style = GetWindowLongPtr(header, GWL_STYLE);
2363 ok(!(style & HDS_BUTTONS), "expected header to have no HDS_BUTTONS\n");
2365 style = GetWindowLongPtr(hwnd, GWL_STYLE);
2366 SetWindowLongPtr(hwnd, GWL_STYLE, style & ~LVS_NOSORTHEADER);
2367 /* not changed here */
2368 style = GetWindowLongPtr(header, GWL_STYLE);
2369 ok(!(style & HDS_BUTTONS), "expected header to have no HDS_BUTTONS\n");
2371 DestroyWindow(hwnd);
2374 static void test_setredraw(void)
2380 hwnd = create_listview_control(0);
2381 ok(hwnd != NULL, "failed to create a listview window\n");
2383 /* Passing WM_SETREDRAW to DefWinProc removes WS_VISIBLE.
2384 ListView seems to handle it internally without DefWinProc */
2386 /* default value first */
2387 ret = SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
2390 style = GetWindowLongPtr(hwnd, GWL_STYLE);
2391 ok(style & WS_VISIBLE, "Expected WS_VISIBLE to be set\n");
2392 ret = SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
2394 style = GetWindowLongPtr(hwnd, GWL_STYLE);
2395 ok(style & WS_VISIBLE, "Expected WS_VISIBLE to be set\n");
2397 DestroyWindow(hwnd);
2400 static void test_hittest(void)
2406 static CHAR text[] = "1234567890ABCDEFGHIJKLMNOPQRST";
2409 HIMAGELIST himl, himl2;
2412 hwnd = create_listview_control(0);
2413 ok(hwnd != NULL, "failed to create a listview window\n");
2415 /* LVS_REPORT with a single subitem (2 columns) */
2416 insert_column(hwnd, 0);
2417 insert_column(hwnd, 1);
2418 insert_item(hwnd, 0);
2421 /* the only purpose of that line is to be as long as a half item rect */
2422 item.pszText = text;
2423 r = SendMessage(hwnd, LVM_SETITEMTEXT, 0, (LPARAM)&item);
2426 r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0));
2428 r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(100, 0));
2431 memset(&bounds, 0, sizeof(bounds));
2432 bounds.left = LVIR_BOUNDS;
2433 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&bounds);
2434 ok(bounds.bottom - bounds.top > 0, "Expected non zero item height\n");
2435 ok(bounds.right - bounds.left > 0, "Expected non zero item width\n");
2436 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pos);
2439 /* LVS_EX_FULLROWSELECT not set, no icons attached */
2440 x = pos.x + 50; /* column half width */
2441 y = pos.y + (bounds.bottom - bounds.top) / 2;
2442 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMLABEL, FALSE, FALSE, __LINE__);
2443 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2444 x = pos.x + 150; /* outside column */
2445 y = pos.y + (bounds.bottom - bounds.top) / 2;
2446 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
2447 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, TRUE, TRUE, TRUE, __LINE__);
2448 /* parent client area is 100x100 by default */
2449 MoveWindow(hwnd, 0, 0, 300, 100, FALSE);
2450 x = pos.x + 150; /* outside column */
2451 y = pos.y + (bounds.bottom - bounds.top) / 2;
2452 test_lvm_hittest(hwnd, x, y, -1, LVHT_NOWHERE, FALSE, FALSE, __LINE__);
2453 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2454 /* the same with LVS_EX_FULLROWSELECT */
2455 SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);
2456 x = pos.x + 150; /* outside column */
2457 y = pos.y + (bounds.bottom - bounds.top) / 2;
2458 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEM, FALSE, FALSE, __LINE__);
2459 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2460 MoveWindow(hwnd, 0, 0, 100, 100, FALSE);
2461 x = pos.x + 150; /* outside column */
2462 y = pos.y + (bounds.bottom - bounds.top) / 2;
2463 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
2464 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, TRUE, TRUE, TRUE, __LINE__);
2465 /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
2466 himl = ImageList_Create(16, 16, 0, 4, 4);
2467 ok(himl != NULL, "failed to create imagelist\n");
2468 hbmp = CreateBitmap(16, 16, 1, 1, NULL);
2469 ok(hbmp != NULL, "failed to create bitmap\n");
2470 r = ImageList_Add(himl, hbmp, 0);
2471 ok(r == 0, "should be zero\n");
2472 hbmp = CreateBitmap(16, 16, 1, 1, NULL);
2473 ok(hbmp != NULL, "failed to create bitmap\n");
2474 r = ImageList_Add(himl, hbmp, 0);
2475 ok(r == 1, "should be one\n");
2477 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl);
2478 ok(r == 0, "should return zero\n");
2480 item.mask = LVIF_IMAGE;
2484 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2488 y = pos.y + (bounds.bottom - bounds.top) / 2;
2489 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, __LINE__);
2490 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__);
2492 /* state icons indices are 1 based, check with valid index */
2493 item.mask = LVIF_STATE;
2494 item.state = INDEXTOSTATEIMAGEMASK(1);
2495 item.stateMask = LVIS_STATEIMAGEMASK;
2498 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2502 y = pos.y + (bounds.bottom - bounds.top) / 2;
2503 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, __LINE__);
2504 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__);
2506 himl2 = (HIMAGELIST)SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)NULL);
2507 ok(himl2 == himl, "should return handle\n");
2509 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl);
2510 ok(r == 0, "should return zero\n");
2513 y = pos.y + (bounds.bottom - bounds.top) / 2;
2514 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMICON, FALSE, FALSE, __LINE__);
2515 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMICON, FALSE, FALSE, FALSE, __LINE__);
2517 DestroyWindow(hwnd);
2520 static void test_getviewrect(void)
2527 hwnd = create_listview_control(0);
2528 ok(hwnd != NULL, "failed to create a listview window\n");
2531 r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
2534 insert_column(hwnd, 0);
2535 insert_column(hwnd, 1);
2537 memset(&item, 0, sizeof(item));
2540 SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
2542 r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0));
2544 r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(120, 0));
2547 rect.left = rect.right = rect.top = rect.bottom = -1;
2548 r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
2550 /* left is set to (2e31-1) - XP SP2 */
2551 expect(0, rect.right);
2552 expect(0, rect.top);
2553 expect(0, rect.bottom);
2555 /* switch to LVS_ICON */
2556 SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~LVS_REPORT);
2558 rect.left = rect.right = rect.top = rect.bottom = -1;
2559 r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
2561 expect(0, rect.left);
2562 expect(0, rect.top);
2563 /* precise value differs for 2k, XP and Vista */
2564 ok(rect.bottom > 0, "Expected positive bottom value, got %d\n", rect.bottom);
2565 ok(rect.right > 0, "Expected positive right value, got %d\n", rect.right);
2567 DestroyWindow(hwnd);
2570 static void test_getitemposition(void)
2577 hwnd = create_listview_control(0);
2578 ok(hwnd != NULL, "failed to create a listview window\n");
2579 header = subclass_header(hwnd);
2581 /* LVS_REPORT, single item, no columns added */
2582 insert_item(hwnd, 0);
2584 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2587 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
2589 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getitemposition_seq1, "get item position 1", FALSE);
2591 /* LVS_REPORT, single item, single column */
2592 insert_column(hwnd, 0);
2594 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2597 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
2599 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getitemposition_seq2, "get item position 2", TRUE);
2601 memset(&rect, 0, sizeof(rect));
2602 SendMessage(header, HDM_GETITEMRECT, 0, (LPARAM)&rect);
2605 /* offset by header height */
2606 expect(rect.bottom - rect.top, pt.y);
2608 DestroyWindow(hwnd);
2611 static void test_columnscreation(void)
2616 hwnd = create_listview_control(0);
2617 ok(hwnd != NULL, "failed to create a listview window\n");
2619 insert_item(hwnd, 0);
2621 /* headers columns aren't created automatically */
2622 header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0);
2623 ok(IsWindow(header), "Expected header handle\n");
2624 r = SendMessage(header, HDM_GETITEMCOUNT, 0, 0);
2627 DestroyWindow(hwnd);
2630 static void test_getitemrect(void)
2642 hwnd = create_listview_control(0);
2643 ok(hwnd != NULL, "failed to create a listview window\n");
2646 memset(&item, 0, sizeof(item));
2649 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
2652 rect.left = LVIR_BOUNDS;
2653 rect.right = rect.top = rect.bottom = -1;
2654 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2657 /* zero width rectangle with no padding */
2658 expect(0, rect.left);
2659 todo_wine expect(0, rect.right);
2661 insert_column(hwnd, 0);
2662 insert_column(hwnd, 1);
2664 col.mask = LVCF_WIDTH;
2666 r = SendMessage(hwnd, LVM_SETCOLUMN, 0, (LPARAM)&col);
2669 col.mask = LVCF_WIDTH;
2671 r = SendMessage(hwnd, LVM_SETCOLUMN, 1, (LPARAM)&col);
2674 rect.left = LVIR_BOUNDS;
2675 rect.right = rect.top = rect.bottom = -1;
2676 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2679 /* still no left padding */
2680 expect(0, rect.left);
2681 expect(150, rect.right);
2683 rect.left = LVIR_SELECTBOUNDS;
2684 rect.right = rect.top = rect.bottom = -1;
2685 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2688 expect(2, rect.left);
2690 rect.left = LVIR_LABEL;
2691 rect.right = rect.top = rect.bottom = -1;
2692 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2694 /* padding, column width */
2695 expect(2, rect.left);
2696 expect(50, rect.right);
2698 /* no icons attached */
2699 rect.left = LVIR_ICON;
2700 rect.right = rect.top = rect.bottom = -1;
2701 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2704 expect(2, rect.left);
2705 expect(2, rect.right);
2708 order[0] = 1; order[1] = 0;
2709 r = SendMessage(hwnd, LVM_SETCOLUMNORDERARRAY, 2, (LPARAM)&order);
2712 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
2714 /* 1 indexed column width + padding */
2715 todo_wine expect(102, pt.x);
2716 /* rect is at zero too */
2717 rect.left = LVIR_BOUNDS;
2718 rect.right = rect.top = rect.bottom = -1;
2719 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2721 expect(0, rect.left);
2722 /* just width sum */
2723 expect(150, rect.right);
2725 rect.left = LVIR_SELECTBOUNDS;
2726 rect.right = rect.top = rect.bottom = -1;
2727 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2729 /* column width + padding */
2730 todo_wine expect(102, rect.left);
2732 /* back to initial order */
2733 order[0] = 0; order[1] = 1;
2734 r = SendMessage(hwnd, LVM_SETCOLUMNORDERARRAY, 2, (LPARAM)&order);
2738 himl = ImageList_Create(16, 16, 0, 2, 2);
2739 ok(himl != NULL, "failed to create imagelist\n");
2740 hbm = CreateBitmap(16, 16, 1, 1, NULL);
2741 ok(hbm != NULL, "failed to create bitmap\n");
2742 r = ImageList_Add(himl, hbm, 0);
2743 ok(r == 0, "should be zero\n");
2744 hbm = CreateBitmap(16, 16, 1, 1, NULL);
2745 ok(hbm != NULL, "failed to create bitmap\n");
2746 r = ImageList_Add(himl, hbm, 0);
2747 ok(r == 1, "should be one\n");
2749 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl);
2750 ok(r == 0, "should return zero\n");
2752 item.mask = LVIF_STATE;
2753 item.state = INDEXTOSTATEIMAGEMASK(1);
2754 item.stateMask = LVIS_STATEIMAGEMASK;
2757 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2761 rect.left = LVIR_ICON;
2762 rect.right = rect.top = rect.bottom = -1;
2763 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2765 /* padding + stateicon width */
2766 expect(18, rect.left);
2767 expect(18, rect.right);
2769 rect.left = LVIR_LABEL;
2770 rect.right = rect.top = rect.bottom = -1;
2771 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2773 /* padding + stateicon width -> column width */
2774 expect(18, rect.left);
2775 expect(50, rect.right);
2777 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)NULL);
2778 ok(r != 0, "should return current list handle\n");
2780 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl);
2781 ok(r == 0, "should return zero\n");
2783 item.mask = LVIF_STATE | LVIF_IMAGE;
2786 item.stateMask = ~0;
2789 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2793 rect.left = LVIR_ICON;
2794 rect.right = rect.top = rect.bottom = -1;
2795 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2797 /* padding, icon width */
2798 expect(2, rect.left);
2799 expect(18, rect.right);
2801 rect.left = LVIR_LABEL;
2802 rect.right = rect.top = rect.bottom = -1;
2803 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2805 /* padding + icon width -> column width */
2806 expect(18, rect.left);
2807 expect(50, rect.right);
2810 rect.left = LVIR_SELECTBOUNDS;
2811 rect.right = rect.top = rect.bottom = -1;
2812 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2814 /* padding, column width */
2815 expect(2, rect.left);
2816 todo_wine expect(50, rect.right);
2818 /* try with indentation */
2819 item.mask = LVIF_INDENT;
2823 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2827 rect.left = LVIR_BOUNDS;
2828 rect.right = rect.top = rect.bottom = -1;
2829 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2831 /* padding + 1 icon width, column width */
2832 expect(0, rect.left);
2833 expect(150, rect.right);
2836 rect.left = LVIR_SELECTBOUNDS;
2837 rect.right = rect.top = rect.bottom = -1;
2838 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2840 /* padding + 1 icon width, column width */
2841 expect(2 + 16, rect.left);
2842 todo_wine expect(50, rect.right);
2845 rect.left = LVIR_LABEL;
2846 rect.right = rect.top = rect.bottom = -1;
2847 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2849 /* padding + 2 icon widths, column width */
2850 expect(2 + 16*2, rect.left);
2851 expect(50, rect.right);
2854 rect.left = LVIR_ICON;
2855 rect.right = rect.top = rect.bottom = -1;
2856 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
2858 /* padding + 1 icon width indentation, icon width */
2859 expect(2 + 16, rect.left);
2860 expect(34, rect.right);
2863 DestroyWindow(hwnd);
2866 static void test_editbox(void)
2868 HWND hwnd, hwndedit, hwndedit2;
2871 static CHAR testitemA[] = "testitem";
2872 static CHAR testitem1A[] = "testitem1";
2873 static CHAR buffer[10];
2875 hwnd = create_listview_control(LVS_EDITLABELS);
2876 ok(hwnd != NULL, "failed to create a listview window\n");
2878 insert_column(hwnd, 0);
2880 memset(&item, 0, sizeof(item));
2881 item.mask = LVIF_TEXT;
2882 item.pszText = testitemA;
2885 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
2888 /* setting focus is necessary */
2890 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
2891 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
2893 /* modify initial string */
2894 r = SendMessage(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem1A);
2896 /* return focus to listview */
2899 memset(&item, 0, sizeof(item));
2900 item.mask = LVIF_TEXT;
2901 item.pszText = buffer;
2902 item.cchTextMax = 10;
2905 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
2908 ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
2910 /* send LVM_EDITLABEL on already created edit */
2912 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
2913 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
2914 /* focus will be set to edit */
2915 ok(GetFocus() == hwndedit, "Expected Edit window to be focused\n");
2916 hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
2917 ok(IsWindow(hwndedit2), "Expected Edit window to be created\n");
2919 /* creating label disabled when control isn't focused */
2921 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
2922 todo_wine ok(hwndedit == NULL, "Expected Edit window not to be created\n");
2924 /* check EN_KILLFOCUS handling */
2925 memset(&item, 0, sizeof(item));
2926 item.pszText = testitemA;
2929 r = SendMessage(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&item);
2933 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
2934 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
2935 /* modify edit and notify control that it lost focus */
2936 r = SendMessage(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem1A);
2938 r = SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit);
2940 memset(&item, 0, sizeof(item));
2941 item.pszText = buffer;
2942 item.cchTextMax = 10;
2945 r = SendMessage(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
2946 expect(lstrlen(item.pszText), r);
2947 ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
2948 /* end edit without saving */
2949 r = SendMessage(hwndedit, WM_KEYDOWN, VK_ESCAPE, 0);
2951 memset(&item, 0, sizeof(item));
2952 item.pszText = buffer;
2953 item.cchTextMax = 10;
2956 r = SendMessage(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
2957 expect(lstrlen(item.pszText), r);
2958 ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
2960 /* LVM_EDITLABEL with -1 destroys current edit */
2961 hwndedit = (HWND)SendMessage(hwnd, LVM_GETEDITCONTROL, 0, 0);
2962 ok(hwndedit == NULL, "Expected Edit window not to be created\n");
2963 /* no edit present */
2964 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -1, 0);
2965 ok(hwndedit == NULL, "Expected Edit window not to be created\n");
2966 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
2967 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
2969 ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
2970 hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -1, 0);
2971 ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
2972 ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
2973 ok(GetFocus() == hwnd, "Expected List to be focused\n");
2974 /* check another negative value */
2975 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
2976 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
2977 ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
2978 hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -2, 0);
2979 ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
2980 ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
2981 ok(GetFocus() == hwnd, "Expected List to be focused\n");
2982 /* and value greater then max item index */
2983 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
2984 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
2985 ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
2986 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
2987 hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, r, 0);
2988 ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
2989 ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
2990 ok(GetFocus() == hwnd, "Expected List to be focused\n");
2992 DestroyWindow(hwnd);
2995 START_TEST(listview)
2998 BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
3000 hComctl32 = GetModuleHandleA("comctl32.dll");
3001 pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
3002 if (pInitCommonControlsEx)
3004 INITCOMMONCONTROLSEX iccex;
3005 iccex.dwSize = sizeof(iccex);
3006 iccex.dwICC = ICC_LISTVIEW_CLASSES;
3007 pInitCommonControlsEx(&iccex);
3010 InitCommonControls();
3012 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
3014 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3015 hwndparent = create_parent_window();
3016 ok_sequence(sequences, PARENT_SEQ_INDEX, create_parent_wnd_seq, "create parent window", TRUE);
3017 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3025 test_icon_spacing();
3028 test_item_position();
3033 test_subitem_rect();
3037 test_nosortheader();
3041 test_getitemposition();
3042 test_columnscreation();
3045 DestroyWindow(hwndparent);