4 * Copyright 2006 Mike McCormack for CodeWeavers
5 * Copyright 2007 George Gov
6 * Copyright 2009 Nikolay Sivov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
31 #define PARENT_SEQ_INDEX 0
32 #define PARENT_FULL_SEQ_INDEX 1
33 #define LISTVIEW_SEQ_INDEX 2
34 #define EDITBOX_SEQ_INDEX 3
35 #define NUM_MSG_SEQUENCES 4
40 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
41 #define expect2(expected1, expected2, got1, got2) ok(expected1 == got1 && expected2 == got2, \
42 "expected (%d,%d), got (%d,%d)\n", expected1, expected2, got1, got2)
44 static const WCHAR testparentclassW[] =
45 {'L','i','s','t','v','i','e','w',' ','t','e','s','t',' ','p','a','r','e','n','t','W', 0};
47 HWND hwndparent, hwndparentW;
48 /* prevents edit box creation, LVN_BEGINLABELEDIT return value */
50 /* dumps LVN_ITEMCHANGED message data */
51 static BOOL g_dump_itemchanged;
52 /* format reported to control:
53 -1 falls to defproc, anything else returned */
55 /* indicates we're running < 5.80 version */
58 static HWND subclass_editbox(HWND hwndListview);
60 static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
62 static const struct message create_ownerdrawfixed_parent_seq[] = {
63 { WM_NOTIFYFORMAT, sent },
64 { WM_QUERYUISTATE, sent|optional }, /* Win2K and higher */
65 { WM_MEASUREITEM, sent },
66 { WM_PARENTNOTIFY, sent },
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|optional, 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|optional, 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 { WM_NCPAINT, sent|optional },
127 { WM_ERASEBKGND, sent|optional },
128 { LVM_GETITEMCOUNT, sent },
129 { LVM_DELETEALLITEMS, sent },
130 { LVM_GETITEMCOUNT, sent },
131 { LVM_INSERTITEM, sent },
132 { LVM_INSERTITEM, sent },
133 { LVM_GETITEMCOUNT, sent },
134 { LVM_INSERTITEM, sent },
135 { LVM_GETITEMCOUNT, sent },
139 static const struct message listview_itempos_seq[] = {
140 { LVM_INSERTITEM, sent },
141 { LVM_INSERTITEM, sent },
142 { LVM_INSERTITEM, sent },
143 { LVM_SETITEMPOSITION, sent|wparam|lparam, 1, MAKELPARAM(10,5) },
144 { WM_NCPAINT, sent|optional },
145 { WM_ERASEBKGND, sent|optional },
146 { LVM_GETITEMPOSITION, sent|wparam, 1 },
147 { LVM_SETITEMPOSITION, sent|wparam|lparam, 2, MAKELPARAM(0,0) },
148 { LVM_GETITEMPOSITION, sent|wparam, 2 },
149 { LVM_SETITEMPOSITION, sent|wparam|lparam, 0, MAKELPARAM(20,20) },
150 { LVM_GETITEMPOSITION, sent|wparam, 0 },
154 static const struct message listview_ownerdata_switchto_seq[] = {
155 { WM_STYLECHANGING, sent },
156 { WM_STYLECHANGED, sent },
160 static const struct message listview_getorderarray_seq[] = {
161 { LVM_GETCOLUMNORDERARRAY, sent|id|wparam, 2, 0, LISTVIEW_ID },
162 { HDM_GETORDERARRAY, sent|id|wparam, 2, 0, HEADER_ID },
166 static const struct message empty_seq[] = {
170 static const struct message forward_erasebkgnd_parent_seq[] = {
171 { WM_ERASEBKGND, sent },
175 static const struct message ownderdata_select_focus_parent_seq[] = {
176 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
177 { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
178 { WM_NOTIFY, sent|id|optional, 0, 0, LVN_GETDISPINFOA }, /* version 4.7x */
182 static const struct message ownerdata_setstate_all_parent_seq[] = {
183 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
187 static const struct message ownerdata_defocus_all_parent_seq[] = {
188 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
189 { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
190 { WM_NOTIFY, sent|id|optional, 0, 0, LVN_GETDISPINFOA },
191 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
195 static const struct message ownerdata_deselect_all_parent_seq[] = {
196 { WM_NOTIFY, sent|id, 0, 0, LVN_ODCACHEHINT },
197 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
201 static const struct message select_all_parent_seq[] = {
202 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
203 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
205 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
206 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
208 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
209 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
211 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
212 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
214 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
215 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
219 static const struct message textcallback_set_again_parent_seq[] = {
220 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
221 { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
225 static const struct message single_getdispinfo_parent_seq[] = {
226 { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
230 static const struct message getitemposition_seq1[] = {
231 { LVM_GETITEMPOSITION, sent|id, 0, 0, LISTVIEW_ID },
235 static const struct message getitemposition_seq2[] = {
236 { LVM_GETITEMPOSITION, sent|id, 0, 0, LISTVIEW_ID },
237 { HDM_GETITEMRECT, sent|id, 0, 0, HEADER_ID },
241 static const struct message editbox_create_pos[] = {
242 /* sequence sent after LVN_BEGINLABELEDIT */
243 /* next two are 4.7x specific */
244 { WM_WINDOWPOSCHANGING, sent },
245 { WM_WINDOWPOSCHANGED, sent|optional },
247 { WM_WINDOWPOSCHANGING, sent|optional },
248 { WM_NCCALCSIZE, sent },
249 { WM_WINDOWPOSCHANGED, sent },
250 { WM_MOVE, sent|defwinproc },
251 { WM_SIZE, sent|defwinproc },
252 /* the rest is todo, skipped in 4.7x */
253 { WM_WINDOWPOSCHANGING, sent|optional },
254 { WM_WINDOWPOSCHANGED, sent|optional },
258 static const struct message scroll_parent_seq[] = {
259 { WM_NOTIFY, sent|id, 0, 0, LVN_BEGINSCROLL },
260 { WM_NOTIFY, sent|id, 0, 0, LVN_ENDSCROLL },
264 static const struct message setredraw_seq[] = {
265 { WM_SETREDRAW, sent|id|wparam, FALSE, 0, LISTVIEW_ID },
269 static const struct message lvs_ex_transparentbkgnd_seq[] = {
270 { WM_PRINTCLIENT, sent|lparam, 0, PRF_ERASEBKGND },
274 static const struct message edit_end_nochange[] = {
275 { WM_NOTIFY, sent|id, 0, 0, LVN_ENDLABELEDITA },
276 { WM_NOTIFY, sent|id, 0, 0, NM_CUSTOMDRAW }, /* todo */
277 { WM_NOTIFY, sent|id, 0, 0, NM_SETFOCUS },
281 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
283 static LONG defwndproc_counter = 0;
287 msg.message = message;
288 msg.flags = sent|wparam|lparam;
289 if (defwndproc_counter) msg.flags |= defwinproc;
292 if (message == WM_NOTIFY && lParam) msg.id = ((NMHDR*)lParam)->code;
294 /* log system messages, except for painting */
295 if (message < WM_USER &&
296 message != WM_PAINT &&
297 message != WM_ERASEBKGND &&
298 message != WM_NCPAINT &&
299 message != WM_NCHITTEST &&
300 message != WM_GETTEXT &&
301 message != WM_GETICON &&
302 message != WM_DEVICECHANGE)
304 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
306 add_message(sequences, PARENT_SEQ_INDEX, &msg);
308 add_message(sequences, PARENT_FULL_SEQ_INDEX, &msg);
314 switch (((NMHDR*)lParam)->code)
316 case LVN_BEGINLABELEDIT:
317 /* subclass edit box */
319 subclass_editbox(((NMHDR*)lParam)->hwndFrom);
323 case LVN_ENDLABELEDIT:
325 /* always accept new item text */
326 NMLVDISPINFO *di = (NMLVDISPINFO*)lParam;
327 trace("LVN_ENDLABELEDIT: text=%s\n", di->item.pszText);
330 case LVN_BEGINSCROLL:
333 NMLVSCROLL *pScroll = (NMLVSCROLL*)lParam;
335 trace("LVN_%sSCROLL: (%d,%d)\n", pScroll->hdr.code == LVN_BEGINSCROLL ?
336 "BEGIN" : "END", pScroll->dx, pScroll->dy);
339 case LVN_ITEMCHANGED:
340 if (g_dump_itemchanged)
342 NMLISTVIEW *nmlv = (NMLISTVIEW*)lParam;
343 trace("LVN_ITEMCHANGED: item=%d,new=%x,old=%x,changed=%x\n",
344 nmlv->iItem, nmlv->uNewState, nmlv->uOldState, nmlv->uChanged);
350 case WM_NOTIFYFORMAT:
352 /* force to return format */
353 if (lParam == NF_QUERY && notifyFormat != -1) return notifyFormat;
358 defwndproc_counter++;
359 ret = DefWindowProcA(hwnd, message, wParam, lParam);
360 defwndproc_counter--;
365 static BOOL register_parent_wnd_class(BOOL Unicode)
373 clsW.lpfnWndProc = parent_wnd_proc;
376 clsW.hInstance = GetModuleHandleW(NULL);
378 clsW.hCursor = LoadCursorA(0, IDC_ARROW);
379 clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
380 clsW.lpszMenuName = NULL;
381 clsW.lpszClassName = testparentclassW;
386 clsA.lpfnWndProc = parent_wnd_proc;
389 clsA.hInstance = GetModuleHandleA(NULL);
391 clsA.hCursor = LoadCursorA(0, IDC_ARROW);
392 clsA.hbrBackground = GetStockObject(WHITE_BRUSH);
393 clsA.lpszMenuName = NULL;
394 clsA.lpszClassName = "Listview test parent class";
397 return Unicode ? RegisterClassW(&clsW) : RegisterClassA(&clsA);
400 static HWND create_parent_window(BOOL Unicode)
402 static const WCHAR nameW[] = {'t','e','s','t','p','a','r','e','n','t','n','a','m','e','W'};
405 if (!register_parent_wnd_class(Unicode))
412 hwnd = CreateWindowExW(0, testparentclassW, nameW,
413 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
414 WS_MAXIMIZEBOX | WS_VISIBLE,
416 GetDesktopWindow(), NULL, GetModuleHandleW(NULL), NULL);
418 hwnd = CreateWindowExA(0, "Listview test parent class",
419 "Listview test parent window",
420 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
421 WS_MAXIMIZEBOX | WS_VISIBLE,
423 GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
424 SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
428 static LRESULT WINAPI listview_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
430 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
431 static LONG defwndproc_counter = 0;
435 trace("listview: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
437 /* some debug output for style changing */
438 if ((message == WM_STYLECHANGING ||
439 message == WM_STYLECHANGED) && lParam)
441 STYLESTRUCT *style = (STYLESTRUCT*)lParam;
442 trace("\told style: 0x%08x, new style: 0x%08x\n", style->styleOld, style->styleNew);
445 msg.message = message;
446 msg.flags = sent|wparam|lparam;
447 if (defwndproc_counter) msg.flags |= defwinproc;
450 msg.id = LISTVIEW_ID;
451 add_message(sequences, LISTVIEW_SEQ_INDEX, &msg);
453 defwndproc_counter++;
454 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
455 defwndproc_counter--;
459 static HWND create_listview_control(DWORD style)
465 GetClientRect(hwndparent, &rect);
466 hwnd = CreateWindowExA(0, WC_LISTVIEW, "foo",
467 WS_CHILD | WS_BORDER | WS_VISIBLE | LVS_REPORT | style,
468 0, 0, rect.right, rect.bottom,
469 hwndparent, NULL, GetModuleHandleA(NULL), NULL);
470 ok(hwnd != NULL, "gle=%d\n", GetLastError());
472 if (!hwnd) return NULL;
474 oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
475 (LONG_PTR)listview_subclass_proc);
476 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
481 /* unicode listview window with specified parent */
482 static HWND create_listview_controlW(DWORD style, HWND parent)
487 static const WCHAR nameW[] = {'f','o','o',0};
489 GetClientRect(parent, &rect);
490 hwnd = CreateWindowExW(0, WC_LISTVIEWW, nameW,
491 WS_CHILD | WS_BORDER | WS_VISIBLE | LVS_REPORT | style,
492 0, 0, rect.right, rect.bottom,
493 parent, NULL, GetModuleHandleW(NULL), NULL);
494 ok(hwnd != NULL, "gle=%d\n", GetLastError());
496 if (!hwnd) return NULL;
498 oldproc = (WNDPROC)SetWindowLongPtrW(hwnd, GWLP_WNDPROC,
499 (LONG_PTR)listview_subclass_proc);
500 SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
505 static HWND create_custom_listview_control(DWORD style)
511 GetClientRect(hwndparent, &rect);
512 hwnd = CreateWindowExA(0, WC_LISTVIEW, "foo",
513 WS_CHILD | WS_BORDER | WS_VISIBLE | style,
514 0, 0, rect.right, rect.bottom,
515 hwndparent, NULL, GetModuleHandleA(NULL), NULL);
516 ok(hwnd != NULL, "gle=%d\n", GetLastError());
518 if (!hwnd) return NULL;
520 oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
521 (LONG_PTR)listview_subclass_proc);
522 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
527 static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
529 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
530 static LONG defwndproc_counter = 0;
534 trace("header: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
536 msg.message = message;
537 msg.flags = sent|wparam|lparam;
538 if (defwndproc_counter) msg.flags |= defwinproc;
542 add_message(sequences, LISTVIEW_SEQ_INDEX, &msg);
544 defwndproc_counter++;
545 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
546 defwndproc_counter--;
550 static HWND subclass_header(HWND hwndListview)
555 hwnd = ListView_GetHeader(hwndListview);
556 oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
557 (LONG_PTR)header_subclass_proc);
558 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
563 static LRESULT WINAPI editbox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
565 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
566 static LONG defwndproc_counter = 0;
570 msg.message = message;
571 msg.flags = sent|wparam|lparam;
572 if (defwndproc_counter) msg.flags |= defwinproc;
576 /* all we need is sizing */
577 if (message == WM_WINDOWPOSCHANGING ||
578 message == WM_NCCALCSIZE ||
579 message == WM_WINDOWPOSCHANGED ||
580 message == WM_MOVE ||
583 add_message(sequences, EDITBOX_SEQ_INDEX, &msg);
586 defwndproc_counter++;
587 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
588 defwndproc_counter--;
592 static HWND subclass_editbox(HWND hwndListview)
597 hwnd = (HWND)SendMessage(hwndListview, LVM_GETEDITCONTROL, 0, 0);
598 oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
599 (LONG_PTR)editbox_subclass_proc);
600 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
605 /* Performs a single LVM_HITTEST test */
606 static void test_lvm_hittest(HWND hwnd, INT x, INT y, INT item, UINT flags, UINT broken_flags,
607 BOOL todo_item, BOOL todo_flags, int line)
616 trace("hittesting pt=(%d,%d)\n", lpht.pt.x, lpht.pt.y);
617 ret = SendMessage(hwnd, LVM_HITTEST, 0, (LPARAM)&lpht);
623 ok_(__FILE__, line)(ret == item, "Expected %d item, got %d\n", item, ret);
624 ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
625 ok_(__FILE__, line)(lpht.iSubItem == 10, "Expected subitem not overwrited\n");
630 ok_(__FILE__, line)(ret == item, "Expected %d item, got %d\n", item, ret);
631 ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
632 ok_(__FILE__, line)(lpht.iSubItem == 10, "Expected subitem not overwrited\n");
638 ok_(__FILE__, line)(lpht.flags == flags, "Expected flags %x, got %x\n", flags, lpht.flags);
640 else if (broken_flags)
641 ok_(__FILE__, line)(lpht.flags == flags || broken(lpht.flags == broken_flags),
642 "Expected flags %x, got %x\n", flags, lpht.flags);
644 ok_(__FILE__, line)(lpht.flags == flags, "Expected flags %x, got %x\n", flags, lpht.flags);
647 /* Performs a single LVM_SUBITEMHITTEST test */
648 static void test_lvm_subitemhittest(HWND hwnd, INT x, INT y, INT item, INT subitem, UINT flags,
649 BOOL todo_item, BOOL todo_subitem, BOOL todo_flags, int line)
657 trace("subhittesting pt=(%d,%d)\n", lpht.pt.x, lpht.pt.y);
658 ret = SendMessage(hwnd, LVM_SUBITEMHITTEST, 0, (LPARAM)&lpht);
664 ok_(__FILE__, line)(ret == item, "Expected %d item, got %d\n", item, ret);
665 ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
670 ok_(__FILE__, line)(ret == item, "Expected %d item, got %d\n", item, ret);
671 ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
677 ok_(__FILE__, line)(lpht.iSubItem == subitem, "Expected subitem %d, got %d\n", subitem, lpht.iSubItem);
680 ok_(__FILE__, line)(lpht.iSubItem == subitem, "Expected subitem %d, got %d\n", subitem, lpht.iSubItem);
685 ok_(__FILE__, line)(lpht.flags == flags, "Expected flags %x, got %x\n", flags, lpht.flags);
688 ok_(__FILE__, line)(lpht.flags == flags, "Expected flags %x, got %x\n", flags, lpht.flags);
691 static void test_images(void)
699 static CHAR hello[] = "hello";
701 himl = ImageList_Create(40, 40, 0, 4, 4);
702 ok(himl != NULL, "failed to create imagelist\n");
704 hbmp = CreateBitmap(40, 40, 1, 1, NULL);
705 ok(hbmp != NULL, "failed to create bitmap\n");
707 r = ImageList_Add(himl, hbmp, 0);
708 ok(r == 0, "should be zero\n");
710 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_OWNERDRAWFIXED,
711 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
712 ok(hwnd != NULL, "failed to create listview window\n");
714 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
715 LVS_EX_UNDERLINEHOT | LVS_EX_FLATSB | LVS_EX_ONECLICKACTIVATE);
717 ok(r == 0, "should return zero\n");
719 r = SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
720 ok(r == 0, "should return zero\n");
722 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELONG(100,50));
723 /* returns dimensions */
725 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
726 ok(r == 0, "should be zero items\n");
728 item.mask = LVIF_IMAGE | LVIF_TEXT;
733 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
734 ok(r == -1, "should fail\n");
737 item.pszText = hello;
738 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
739 ok(r == 0, "should not fail\n");
741 memset(&r1, 0, sizeof r1);
743 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r1);
745 r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
746 ok(r == TRUE, "should not fail\n");
749 item.pszText = hello;
750 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
751 ok(r == 0, "should not fail\n");
753 memset(&r2, 0, sizeof r2);
755 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r2);
757 ok(!memcmp(&r1, &r2, sizeof r1), "rectangle should be the same\n");
762 static void test_checkboxes(void)
767 static CHAR text[] = "Text",
771 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT,
772 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
773 ok(hwnd != NULL, "failed to create listview window\n");
775 /* first without LVS_EX_CHECKBOXES set and an item and check that state is preserved */
776 item.mask = LVIF_TEXT | LVIF_STATE;
777 item.stateMask = 0xffff;
782 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
783 ok(r == 0, "ret %d\n", r);
786 item.mask = LVIF_STATE;
787 item.stateMask = 0xffff;
788 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
789 ok(item.state == 0xfccc, "state %x\n", item.state);
791 /* Don't set LVIF_STATE */
792 item.mask = LVIF_TEXT;
793 item.stateMask = 0xffff;
798 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
799 ok(r == 1, "ret %d\n", r);
802 item.mask = LVIF_STATE;
803 item.stateMask = 0xffff;
804 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
805 ok(item.state == 0, "state %x\n", item.state);
807 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
808 ok(r == 0, "should return zero\n");
810 /* Having turned on checkboxes, check that all existing items are set to 0x1000 (unchecked) */
812 item.mask = LVIF_STATE;
813 item.stateMask = 0xffff;
814 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
815 if (item.state != 0x1ccc)
817 win_skip("LVS_EX_CHECKBOXES style is unavailable. Skipping.\n");
822 /* Now add an item without specifying a state and check that its state goes to 0x1000 */
824 item.mask = LVIF_TEXT;
826 item.pszText = text2;
827 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
828 ok(r == 2, "ret %d\n", r);
831 item.mask = LVIF_STATE;
832 item.stateMask = 0xffff;
833 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
834 ok(item.state == 0x1000, "state %x\n", item.state);
836 /* Add a further item this time specifying a state and still its state goes to 0x1000 */
838 item.mask = LVIF_TEXT | LVIF_STATE;
839 item.stateMask = 0xffff;
841 item.pszText = text3;
842 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
843 ok(r == 3, "ret %d\n", r);
846 item.mask = LVIF_STATE;
847 item.stateMask = 0xffff;
848 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
849 ok(item.state == 0x1aaa, "state %x\n", item.state);
851 /* Set an item's state to checked */
853 item.mask = LVIF_STATE;
854 item.stateMask = 0xf000;
856 r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
859 item.mask = LVIF_STATE;
860 item.stateMask = 0xffff;
861 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
862 ok(item.state == 0x2aaa, "state %x\n", item.state);
864 /* Check that only the bits we asked for are returned,
865 * and that all the others are set to zero
868 item.mask = LVIF_STATE;
869 item.stateMask = 0xf000;
871 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
872 ok(item.state == 0x2000, "state %x\n", item.state);
874 /* Set the style again and check that doesn't change an item's state */
875 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
876 ok(r == LVS_EX_CHECKBOXES, "ret %x\n", r);
879 item.mask = LVIF_STATE;
880 item.stateMask = 0xffff;
881 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
882 ok(item.state == 0x2aaa, "state %x\n", item.state);
884 /* Unsetting the checkbox extended style doesn't change an item's state */
885 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, 0);
886 ok(r == LVS_EX_CHECKBOXES, "ret %x\n", r);
889 item.mask = LVIF_STATE;
890 item.stateMask = 0xffff;
891 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
892 ok(item.state == 0x2aaa, "state %x\n", item.state);
894 /* Now setting the style again will change an item's state */
895 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
896 ok(r == 0, "ret %x\n", r);
899 item.mask = LVIF_STATE;
900 item.stateMask = 0xffff;
901 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
902 ok(item.state == 0x1aaa, "state %x\n", item.state);
904 /* Toggle checkbox tests (bug 9934) */
905 memset (&item, 0xcc, sizeof(item));
906 item.mask = LVIF_STATE;
909 item.state = LVIS_FOCUSED;
910 item.stateMask = LVIS_FOCUSED;
911 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM) &item);
915 item.mask = LVIF_STATE;
916 item.stateMask = 0xffff;
917 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
918 ok(item.state == 0x1aab, "state %x\n", item.state);
920 r = SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0);
922 r = SendMessage(hwnd, WM_KEYUP, VK_SPACE, 0);
926 item.mask = LVIF_STATE;
927 item.stateMask = 0xffff;
928 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
929 ok(item.state == 0x2aab, "state %x\n", item.state);
931 r = SendMessage(hwnd, WM_KEYDOWN, VK_SPACE, 0);
933 r = SendMessage(hwnd, WM_KEYUP, VK_SPACE, 0);
937 item.mask = LVIF_STATE;
938 item.stateMask = 0xffff;
939 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
940 ok(item.state == 0x1aab, "state %x\n", item.state);
945 static void insert_column(HWND hwnd, int idx)
950 memset(&column, 0xcc, sizeof(column));
951 column.mask = LVCF_SUBITEM;
952 column.iSubItem = idx;
954 rc = ListView_InsertColumn(hwnd, idx, &column);
958 static void insert_item(HWND hwnd, int idx)
960 static CHAR text[] = "foo";
965 memset(&item, 0xcc, sizeof (item));
966 item.mask = LVIF_TEXT;
971 rc = ListView_InsertItem(hwnd, &item);
975 static void test_items(void)
977 const LPARAM lparamTest = 0x42;
981 static CHAR text[] = "Text";
983 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT,
984 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
985 ok(hwnd != NULL, "failed to create listview window\n");
988 * Test setting/getting item params
991 /* Set up two columns */
992 insert_column(hwnd, 0);
993 insert_column(hwnd, 1);
995 /* LVIS_SELECTED with zero stateMask */
997 memset (&item, 0, sizeof (item));
998 item.mask = LVIF_STATE;
999 item.state = LVIS_SELECTED;
1003 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1004 ok(r == 0, "ret %d\n", r);
1006 memset (&item, 0xcc, sizeof (item));
1007 item.mask = LVIF_STATE;
1008 item.stateMask = LVIS_SELECTED;
1012 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1013 ok(r != 0, "ret %d\n", r);
1014 ok(item.state & LVIS_SELECTED, "Expected LVIS_SELECTED\n");
1015 SendMessage(hwnd, LVM_DELETEITEM, 0, 0);
1017 /* LVIS_SELECTED with zero stateMask */
1019 memset (&item, 0, sizeof (item));
1020 item.mask = LVIF_STATE;
1021 item.state = LVIS_FOCUSED;
1025 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1026 ok(r == 0, "ret %d\n", r);
1028 memset (&item, 0xcc, sizeof (item));
1029 item.mask = LVIF_STATE;
1030 item.stateMask = LVIS_FOCUSED;
1034 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1035 ok(r != 0, "ret %d\n", r);
1036 ok(item.state & LVIS_FOCUSED, "Expected LVIS_FOCUSED\n");
1037 SendMessage(hwnd, LVM_DELETEITEM, 0, 0);
1039 /* LVIS_CUT with LVIS_FOCUSED stateMask */
1041 memset (&item, 0, sizeof (item));
1042 item.mask = LVIF_STATE;
1043 item.state = LVIS_CUT;
1044 item.stateMask = LVIS_FOCUSED;
1047 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1048 ok(r == 0, "ret %d\n", r);
1050 memset (&item, 0xcc, sizeof (item));
1051 item.mask = LVIF_STATE;
1052 item.stateMask = LVIS_CUT;
1056 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1057 ok(r != 0, "ret %d\n", r);
1058 ok(item.state & LVIS_CUT, "Expected LVIS_CUT\n");
1059 SendMessage(hwnd, LVM_DELETEITEM, 0, 0);
1061 /* Insert an item with just a param */
1062 memset (&item, 0xcc, sizeof (item));
1063 item.mask = LVIF_PARAM;
1066 item.lParam = lparamTest;
1067 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1068 ok(r == 0, "ret %d\n", r);
1070 /* Test getting of the param */
1071 memset (&item, 0xcc, sizeof (item));
1072 item.mask = LVIF_PARAM;
1075 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1076 ok(r != 0, "ret %d\n", r);
1077 ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
1079 /* Set up a subitem */
1080 memset (&item, 0xcc, sizeof (item));
1081 item.mask = LVIF_TEXT;
1084 item.pszText = text;
1085 r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1086 ok(r != 0, "ret %d\n", r);
1088 /* Query param from subitem: returns main item param */
1089 memset (&item, 0xcc, sizeof (item));
1090 item.mask = LVIF_PARAM;
1093 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1094 ok(r != 0, "ret %d\n", r);
1095 ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
1097 /* Set up param on first subitem: no effect */
1098 memset (&item, 0xcc, sizeof (item));
1099 item.mask = LVIF_PARAM;
1102 item.lParam = lparamTest+1;
1103 r = SendMessage(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1104 ok(r == 0, "ret %d\n", r);
1106 /* Query param from subitem again: should still return main item param */
1107 memset (&item, 0xcc, sizeof (item));
1108 item.mask = LVIF_PARAM;
1111 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1112 ok(r != 0, "ret %d\n", r);
1113 ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
1115 /**** Some tests of state highlighting ****/
1116 memset (&item, 0xcc, sizeof (item));
1117 item.mask = LVIF_STATE;
1120 item.state = LVIS_SELECTED;
1121 item.stateMask = LVIS_SELECTED | LVIS_DROPHILITED;
1122 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM) &item);
1123 ok(r != 0, "ret %d\n", r);
1125 item.state = LVIS_DROPHILITED;
1126 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM) &item);
1127 ok(r != 0, "ret %d\n", r);
1129 memset (&item, 0xcc, sizeof (item));
1130 item.mask = LVIF_STATE;
1133 item.stateMask = -1;
1134 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
1135 ok(r != 0, "ret %d\n", r);
1136 ok(item.state == LVIS_SELECTED, "got state %x, expected %x\n", item.state, LVIS_SELECTED);
1138 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
1139 ok(r != 0, "ret %d\n", r);
1140 todo_wine ok(item.state == LVIS_DROPHILITED, "got state %x, expected %x\n", item.state, LVIS_DROPHILITED);
1142 /* some notnull but meaningless masks */
1143 memset (&item, 0, sizeof(item));
1144 item.mask = LVIF_NORECOMPUTE;
1147 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1148 ok(r != 0, "ret %d\n", r);
1149 memset (&item, 0, sizeof(item));
1150 item.mask = LVIF_DI_SETITEM;
1153 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1154 ok(r != 0, "ret %d\n", r);
1156 /* set text to callback value already having it */
1157 r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
1159 memset (&item, 0, sizeof (item));
1160 item.mask = LVIF_TEXT;
1161 item.pszText = LPSTR_TEXTCALLBACK;
1163 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1164 ok(r == 0, "ret %d\n", r);
1165 memset (&item, 0, sizeof (item));
1167 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1169 item.pszText = LPSTR_TEXTCALLBACK;
1170 r = SendMessage(hwnd, LVM_SETITEMTEXT, 0 , (LPARAM) &item);
1173 ok_sequence(sequences, PARENT_SEQ_INDEX, textcallback_set_again_parent_seq,
1174 "check callback text comparison rule", FALSE);
1176 DestroyWindow(hwnd);
1179 static void test_columns(void)
1181 HWND hwnd, hwndheader;
1186 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT,
1187 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
1188 ok(hwnd != NULL, "failed to create listview window\n");
1190 /* Add a column with no mask */
1191 memset(&column, 0xcc, sizeof(column));
1193 rc = ListView_InsertColumn(hwnd, 0, &column);
1194 ok(rc==0, "Inserting column with no mask failed with %d\n", rc);
1196 /* Check its width */
1197 rc = ListView_GetColumnWidth(hwnd, 0);
1199 broken(rc==0), /* win9x */
1200 "Inserting column with no mask failed to set width to 10 with %d\n", rc);
1202 DestroyWindow(hwnd);
1204 /* LVM_GETCOLUMNORDERARRAY */
1205 hwnd = create_listview_control(0);
1206 hwndheader = subclass_header(hwnd);
1208 memset(&column, 0, sizeof(column));
1209 column.mask = LVCF_WIDTH;
1211 rc = ListView_InsertColumn(hwnd, 0, &column);
1212 ok(rc == 0, "Inserting column failed with %d\n", rc);
1215 rc = ListView_InsertColumn(hwnd, 1, &column);
1216 ok(rc == 1, "Inserting column failed with %d\n", rc);
1218 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1220 rc = SendMessage(hwnd, LVM_GETCOLUMNORDERARRAY, 2, (LPARAM)&order);
1221 ok(rc != 0, "Expected LVM_GETCOLUMNORDERARRAY to succeed\n");
1222 ok(order[0] == 0, "Expected order 0, got %d\n", order[0]);
1223 ok(order[1] == 1, "Expected order 1, got %d\n", order[1]);
1225 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_getorderarray_seq, "get order array", FALSE);
1227 DestroyWindow(hwnd);
1229 /* test setting imagelist between WM_NCCREATE and WM_CREATE */
1230 static WNDPROC listviewWndProc;
1231 static HIMAGELIST test_create_imagelist;
1233 static LRESULT CALLBACK create_test_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1237 if (uMsg == WM_CREATE)
1239 LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
1240 lpcs->style |= LVS_REPORT;
1242 ret = CallWindowProc(listviewWndProc, hwnd, uMsg, wParam, lParam);
1243 if (uMsg == WM_CREATE) SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)test_create_imagelist);
1247 static void test_create(void)
1256 cls.cbSize = sizeof(WNDCLASSEX);
1257 ok(GetClassInfoEx(GetModuleHandle(NULL), "SysListView32", &cls), "GetClassInfoEx failed\n");
1258 listviewWndProc = cls.lpfnWndProc;
1259 cls.lpfnWndProc = create_test_wndproc;
1260 cls.lpszClassName = "MyListView32";
1261 ok(RegisterClassEx(&cls), "RegisterClassEx failed\n");
1263 test_create_imagelist = ImageList_Create(16, 16, 0, 5, 10);
1264 hList = CreateWindow("MyListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), 0);
1265 ok((HIMAGELIST)SendMessage(hList, LVM_GETIMAGELIST, 0, 0) == test_create_imagelist, "Image list not obtained\n");
1266 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1268 if (!IsWindow(hHeader))
1271 win_skip("LVM_GETHEADER not implemented. Skipping.\n");
1272 DestroyWindow(hList);
1276 ok(IsWindow(hHeader) && IsWindowVisible(hHeader), "Listview not in report mode\n");
1277 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1278 DestroyWindow(hList);
1280 /* header isn't created on LVS_ICON and LVS_LIST styles */
1281 hList = CreateWindow("SysListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL,
1282 GetModuleHandle(NULL), 0);
1283 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1284 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1285 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1287 memset(&col, 0, sizeof(LVCOLUMNA));
1288 col.mask = LVCF_WIDTH;
1290 r = SendMessage(hList, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
1291 ok(r == 0, "Expected 0 column's inserted\n");
1292 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1293 ok(IsWindow(hHeader), "Header should be created\n");
1294 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1295 DestroyWindow(hList);
1297 hList = CreateWindow("SysListView32", "Test", WS_VISIBLE|LVS_LIST, 0, 0, 100, 100, NULL, NULL,
1298 GetModuleHandle(NULL), 0);
1299 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1300 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1301 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1303 memset(&col, 0, sizeof(LVCOLUMNA));
1304 col.mask = LVCF_WIDTH;
1306 r = SendMessage(hList, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
1307 ok(r == 0, "Expected 0 column's inserted\n");
1308 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1309 ok(IsWindow(hHeader), "Header should be created\n");
1310 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1311 DestroyWindow(hList);
1313 /* try to switch LVS_ICON -> LVS_REPORT and back LVS_ICON -> LVS_REPORT */
1314 hList = CreateWindow("SysListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL,
1315 GetModuleHandle(NULL), 0);
1316 ret = SetWindowLongPtr(hList, GWL_STYLE, GetWindowLongPtr(hList, GWL_STYLE) | LVS_REPORT);
1317 ok(ret & WS_VISIBLE, "Style wrong, should have WS_VISIBLE\n");
1318 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1319 ok(IsWindow(hHeader), "Header should be created\n");
1320 ret = SetWindowLongPtr(hList, GWL_STYLE, GetWindowLong(hList, GWL_STYLE) & ~LVS_REPORT);
1321 ok((ret & WS_VISIBLE) && (ret & LVS_REPORT), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1322 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1323 ok(IsWindow(hHeader), "Header should be created\n");
1324 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1325 DestroyWindow(hList);
1327 /* try to switch LVS_LIST -> LVS_REPORT and back LVS_LIST -> LVS_REPORT */
1328 hList = CreateWindow("SysListView32", "Test", WS_VISIBLE|LVS_LIST, 0, 0, 100, 100, NULL, NULL,
1329 GetModuleHandle(NULL), 0);
1330 ret = SetWindowLongPtr(hList, GWL_STYLE,
1331 (GetWindowLongPtr(hList, GWL_STYLE) & ~LVS_LIST) | LVS_REPORT);
1332 ok(((ret & WS_VISIBLE) && (ret & LVS_LIST)), "Style wrong, should have WS_VISIBLE|LVS_LIST\n");
1333 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1334 ok(IsWindow(hHeader), "Header should be created\n");
1335 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1336 ret = SetWindowLongPtr(hList, GWL_STYLE,
1337 (GetWindowLongPtr(hList, GWL_STYLE) & ~LVS_REPORT) | LVS_LIST);
1338 ok(((ret & WS_VISIBLE) && (ret & LVS_REPORT)), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1339 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1340 ok(IsWindow(hHeader), "Header should be created\n");
1341 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1342 DestroyWindow(hList);
1344 /* LVS_REPORT without WS_VISIBLE */
1345 hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1346 GetModuleHandle(NULL), 0);
1347 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1348 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1349 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1351 memset(&col, 0, sizeof(LVCOLUMNA));
1352 col.mask = LVCF_WIDTH;
1354 r = SendMessage(hList, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
1355 ok(r == 0, "Expected 0 column's inserted\n");
1356 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1357 ok(IsWindow(hHeader), "Header should be created\n");
1358 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1359 DestroyWindow(hList);
1361 /* LVS_REPORT without WS_VISIBLE, try to show it */
1362 hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1363 GetModuleHandle(NULL), 0);
1364 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1365 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1366 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1367 ShowWindow(hList, SW_SHOW);
1368 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1369 ok(IsWindow(hHeader), "Header should be created\n");
1370 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1371 DestroyWindow(hList);
1373 /* LVS_REPORT with LVS_NOCOLUMNHEADER */
1374 hList = CreateWindow("SysListView32", "Test", LVS_REPORT|LVS_NOCOLUMNHEADER|WS_VISIBLE,
1375 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), 0);
1376 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1377 ok(IsWindow(hHeader), "Header should be created\n");
1378 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1379 /* HDS_DRAGDROP set by default */
1380 ok(GetWindowLongPtr(hHeader, GWL_STYLE) & HDS_DRAGDROP, "Expected header to have HDS_DRAGDROP\n");
1381 DestroyWindow(hList);
1383 /* setting LVS_EX_HEADERDRAGDROP creates header */
1384 hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1385 GetModuleHandle(NULL), 0);
1386 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1387 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1388 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1389 SendMessage(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_HEADERDRAGDROP);
1390 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1391 ok(IsWindow(hHeader) ||
1392 broken(!IsWindow(hHeader)), /* 4.7x common controls */
1393 "Header should be created\n");
1394 ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1395 DestroyWindow(hList);
1397 /* not report style accepts LVS_EX_HEADERDRAGDROP too */
1398 hList = create_custom_listview_control(0);
1399 SendMessage(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_HEADERDRAGDROP);
1400 r = SendMessage(hList, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
1401 ok(r & LVS_EX_HEADERDRAGDROP, "Expected LVS_EX_HEADERDRAGDROP to be set\n");
1402 DestroyWindow(hList);
1404 /* requesting header info with LVM_GETSUBITEMRECT doesn't create it */
1405 hList = CreateWindow("SysListView32", "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1406 GetModuleHandle(NULL), 0);
1407 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1408 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1410 rect.left = LVIR_BOUNDS;
1412 rect.right = rect.bottom = -10;
1413 r = SendMessage(hList, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
1414 ok(r != 0, "Expected not-null LRESULT\n");
1416 hHeader = (HWND)SendMessage(hList, LVM_GETHEADER, 0, 0);
1417 ok(!IsWindow(hHeader), "Header shouldn't be created\n");
1418 ok(NULL == GetDlgItem(hList, 0), "NULL dialog item expected\n");
1420 DestroyWindow(hList);
1422 /* WM_MEASUREITEM should be sent when created with LVS_OWNERDRAWFIXED */
1423 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1424 hList = create_listview_control(LVS_OWNERDRAWFIXED);
1425 ok_sequence(sequences, PARENT_SEQ_INDEX, create_ownerdrawfixed_parent_seq,
1426 "created with LVS_OWNERDRAWFIXED|LVS_REPORT - parent seq", FALSE);
1427 DestroyWindow(hList);
1430 static void test_redraw(void)
1432 HWND hwnd, hwndheader;
1437 hwnd = create_listview_control(0);
1438 hwndheader = subclass_header(hwnd);
1440 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1442 trace("invalidate & update\n");
1443 InvalidateRect(hwnd, NULL, TRUE);
1445 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, redraw_listview_seq, "redraw listview", FALSE);
1447 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1449 /* forward WM_ERASEBKGND to parent on CLR_NONE background color */
1450 /* 1. Without backbuffer */
1451 res = ListView_SetBkColor(hwnd, CLR_NONE);
1454 hdc = GetWindowDC(hwndparent);
1456 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1457 r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1458 ok(r != 0, "Expected not zero result\n");
1459 ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, forward_erasebkgnd_parent_seq,
1460 "forward WM_ERASEBKGND on CLR_NONE", FALSE);
1462 res = ListView_SetBkColor(hwnd, CLR_DEFAULT);
1465 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1466 r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1467 ok(r != 0, "Expected not zero result\n");
1468 ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, empty_seq,
1469 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE);
1471 /* 2. With backbuffer */
1472 SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_DOUBLEBUFFER,
1473 LVS_EX_DOUBLEBUFFER);
1474 res = ListView_SetBkColor(hwnd, CLR_NONE);
1477 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1478 r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1479 ok(r != 0, "Expected not zero result\n");
1480 ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, forward_erasebkgnd_parent_seq,
1481 "forward WM_ERASEBKGND on CLR_NONE", FALSE);
1483 res = ListView_SetBkColor(hwnd, CLR_DEFAULT);
1486 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1487 r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1488 todo_wine ok(r != 0, "Expected not zero result\n");
1489 ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, empty_seq,
1490 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE);
1492 ReleaseDC(hwndparent, hdc);
1494 DestroyWindow(hwnd);
1497 static LRESULT WINAPI cd_wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
1499 COLORREF clr, c0ffee = RGB(0xc0, 0xff, 0xee);
1501 if(msg == WM_NOTIFY) {
1502 NMHDR *nmhdr = (PVOID)lp;
1503 if(nmhdr->code == NM_CUSTOMDRAW) {
1504 NMLVCUSTOMDRAW *nmlvcd = (PVOID)nmhdr;
1505 trace("NMCUSTOMDRAW (0x%.8x)\n", nmlvcd->nmcd.dwDrawStage);
1506 switch(nmlvcd->nmcd.dwDrawStage) {
1508 SetBkColor(nmlvcd->nmcd.hdc, c0ffee);
1509 return CDRF_NOTIFYITEMDRAW;
1510 case CDDS_ITEMPREPAINT:
1511 nmlvcd->clrTextBk = CLR_DEFAULT;
1512 return CDRF_NOTIFYSUBITEMDRAW;
1513 case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
1514 clr = GetBkColor(nmlvcd->nmcd.hdc);
1515 todo_wine ok(clr == c0ffee, "clr=%.8x\n", clr);
1516 return CDRF_NOTIFYPOSTPAINT;
1517 case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
1518 clr = GetBkColor(nmlvcd->nmcd.hdc);
1519 todo_wine ok(clr == c0ffee, "clr=%.8x\n", clr);
1520 return CDRF_DODEFAULT;
1522 return CDRF_DODEFAULT;
1526 return DefWindowProcA(hwnd, msg, wp, lp);
1529 static void test_customdraw(void)
1534 hwnd = create_listview_control(0);
1536 insert_column(hwnd, 0);
1537 insert_column(hwnd, 1);
1538 insert_item(hwnd, 0);
1540 oldwndproc = (WNDPROC)SetWindowLongPtr(hwndparent, GWLP_WNDPROC,
1541 (LONG_PTR)cd_wndproc);
1543 InvalidateRect(hwnd, NULL, TRUE);
1546 SetWindowLongPtr(hwndparent, GWLP_WNDPROC, (LONG_PTR)oldwndproc);
1548 DestroyWindow(hwnd);
1551 static void test_icon_spacing(void)
1553 /* LVM_SETICONSPACING */
1554 /* note: LVM_SETICONSPACING returns the previous icon spacing if successful */
1560 hwnd = create_custom_listview_control(LVS_ICON);
1561 ok(hwnd != NULL, "failed to create a listview window\n");
1563 r = SendMessage(hwnd, WM_NOTIFYFORMAT, (WPARAM)hwndparent, (LPARAM)NF_REQUERY);
1564 expect(NFR_ANSI, r);
1566 /* reset the icon spacing to defaults */
1567 SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1, -1));
1569 /* now we can request what the defaults are */
1570 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1, -1));
1574 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1576 trace("test icon spacing\n");
1578 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(20, 30));
1579 ok(r == MAKELONG(w, h) ||
1580 broken(r == MAKELONG(w, w)), /* win98 */
1581 "Expected %d, got %d\n", MAKELONG(w, h), r);
1583 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(25, 35));
1587 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
1588 DestroyWindow(hwnd);
1591 expect(MAKELONG(20,30), r);
1593 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1,-1));
1594 expect(MAKELONG(25,35), r);
1596 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_icon_spacing_seq, "test icon spacing seq", FALSE);
1598 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1599 DestroyWindow(hwnd);
1602 static void test_color(void)
1604 /* SETBKCOLOR/GETBKCOLOR, SETTEXTCOLOR/GETTEXTCOLOR, SETTEXTBKCOLOR/GETTEXTBKCOLOR */
1611 COLORREF colors[4] = {RGB(0,0,0), RGB(100,50,200), CLR_NONE, RGB(255,255,255)};
1613 hwnd = create_listview_control(0);
1614 ok(hwnd != NULL, "failed to create a listview window\n");
1616 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1618 trace("test color seq\n");
1619 for (i = 0; i < 4; i++)
1623 r = SendMessage(hwnd, LVM_SETBKCOLOR, 0, color);
1625 r = SendMessage(hwnd, LVM_GETBKCOLOR, 0, color);
1628 r = SendMessage(hwnd, LVM_SETTEXTCOLOR, 0, color);
1630 r = SendMessage(hwnd, LVM_GETTEXTCOLOR, 0, color);
1633 r = SendMessage(hwnd, LVM_SETTEXTBKCOLOR, 0, color);
1635 r = SendMessage(hwnd, LVM_GETTEXTBKCOLOR, 0, color);
1639 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_color_seq, "test color seq", FALSE);
1641 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1642 DestroyWindow(hwnd);
1645 static void test_item_count(void)
1647 /* LVM_INSERTITEM, LVM_DELETEITEM, LVM_DELETEALLITEMS, LVM_GETITEMCOUNT */
1660 static CHAR item0text[] = "item0";
1661 static CHAR item1text[] = "item1";
1662 static CHAR item2text[] = "item2";
1664 hwnd = create_listview_control(0);
1665 ok(hwnd != NULL, "failed to create a listview window\n");
1667 /* resize in dpiaware manner to fit all 3 items added */
1669 hOldFont = SelectObject(hdc, GetStockObject(SYSTEM_FONT));
1670 GetTextMetricsA(hdc, &tm);
1671 /* 2 extra pixels for bounds and header border */
1672 height = tm.tmHeight + 2;
1673 SelectObject(hdc, hOldFont);
1676 GetWindowRect(hwnd, &rect);
1677 /* 3 items + 1 header + 1 to be sure */
1678 MoveWindow(hwnd, 0, 0, rect.right - rect.left, 5 * height, FALSE);
1680 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1682 trace("test item count\n");
1684 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1688 item0.mask = LVIF_TEXT;
1691 item0.pszText = item0text;
1692 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item0);
1695 /* [item0, item1] */
1696 item1.mask = LVIF_TEXT;
1699 item1.pszText = item1text;
1700 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item1);
1703 /* [item0, item1, item2] */
1704 item2.mask = LVIF_TEXT;
1707 item2.pszText = item2text;
1708 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item2);
1711 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1714 /* [item0, item1] */
1715 r = SendMessage(hwnd, LVM_DELETEITEM, 2, 0);
1718 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1722 r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
1725 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1729 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item1);
1732 /* [item0, item1] */
1733 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item1);
1736 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1739 /* [item0, item1, item2] */
1740 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item2);
1743 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1746 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_item_count_seq, "test item count seq", FALSE);
1748 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1749 DestroyWindow(hwnd);
1752 static void test_item_position(void)
1754 /* LVM_SETITEMPOSITION/LVM_GETITEMPOSITION */
1763 static CHAR item0text[] = "item0";
1764 static CHAR item1text[] = "item1";
1765 static CHAR item2text[] = "item2";
1767 hwnd = create_custom_listview_control(LVS_ICON);
1768 ok(hwnd != NULL, "failed to create a listview window\n");
1770 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1772 trace("test item position\n");
1775 item0.mask = LVIF_TEXT;
1778 item0.pszText = item0text;
1779 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item0);
1782 /* [item0, item1] */
1783 item1.mask = LVIF_TEXT;
1786 item1.pszText = item1text;
1787 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item1);
1790 /* [item0, item1, item2] */
1791 item2.mask = LVIF_TEXT;
1794 item2.pszText = item2text;
1795 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item2);
1798 r = SendMessage(hwnd, LVM_SETITEMPOSITION, 1, MAKELPARAM(10,5));
1800 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 1, (LPARAM) &position);
1802 expect2(10, 5, position.x, position.y);
1804 r = SendMessage(hwnd, LVM_SETITEMPOSITION, 2, MAKELPARAM(0,0));
1806 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 2, (LPARAM) &position);
1808 expect2(0, 0, position.x, position.y);
1810 r = SendMessage(hwnd, LVM_SETITEMPOSITION, 0, MAKELPARAM(20,20));
1812 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM) &position);
1814 expect2(20, 20, position.x, position.y);
1816 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_itempos_seq, "test item position seq", TRUE);
1818 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1819 DestroyWindow(hwnd);
1822 static void test_getorigin(void)
1830 position.x = position.y = 0;
1832 hwnd = create_custom_listview_control(LVS_ICON);
1833 ok(hwnd != NULL, "failed to create a listview window\n");
1834 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1835 trace("test get origin results\n");
1836 r = SendMessage(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
1838 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1839 DestroyWindow(hwnd);
1841 hwnd = create_custom_listview_control(LVS_SMALLICON);
1842 ok(hwnd != NULL, "failed to create a listview window\n");
1843 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1844 trace("test get origin results\n");
1845 r = SendMessage(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
1847 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1848 DestroyWindow(hwnd);
1850 hwnd = create_custom_listview_control(LVS_LIST);
1851 ok(hwnd != NULL, "failed to create a listview window\n");
1852 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1853 trace("test get origin results\n");
1854 r = SendMessage(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
1856 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1857 DestroyWindow(hwnd);
1859 hwnd = create_custom_listview_control(LVS_REPORT);
1860 ok(hwnd != NULL, "failed to create a listview window\n");
1861 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1862 trace("test get origin results\n");
1863 r = SendMessage(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
1865 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1866 DestroyWindow(hwnd);
1870 static void test_multiselect(void)
1872 typedef struct t_select_task
1883 int i,j,item_count,selected_count;
1884 static const int items=5;
1890 static struct t_select_task task_list[] = {
1891 { "using VK_DOWN", 0, VK_DOWN, -1, -1 },
1892 { "using VK_UP", -1, VK_UP, -1, -1 },
1893 { "using VK_END", 0, VK_END, 1, -1 },
1894 { "using VK_HOME", -1, VK_HOME, 1, -1 }
1898 hwnd = create_listview_control(0);
1900 for (i=0;i<items;i++) {
1901 insert_item(hwnd, 0);
1904 item_count = (int)SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1906 expect(items,item_count);
1909 task = task_list[i];
1911 /* deselect all items */
1912 ListView_SetItemState(hwnd, -1, 0, LVIS_SELECTED);
1913 SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, -1);
1915 /* set initial position */
1916 SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, (task.initPos == -1 ? item_count -1 : task.initPos));
1917 ListView_SetItemState(hwnd,(task.initPos == -1 ? item_count -1 : task.initPos),LVIS_SELECTED ,LVIS_SELECTED);
1919 selected_count = (int)SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1921 ok(selected_count == 1, "There should be only one selected item at the beginning (is %d)\n",selected_count);
1923 /* Set SHIFT key pressed */
1924 GetKeyboardState(kstate);
1925 kstate[VK_SHIFT]=0x80;
1926 SetKeyboardState(kstate);
1928 for (j=1;j<=(task.count == -1 ? item_count : task.count);j++) {
1929 r = SendMessage(hwnd, WM_KEYDOWN, task.loopVK, 0);
1931 r = SendMessage(hwnd, WM_KEYUP, task.loopVK, 0);
1935 selected_count = (int)SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1937 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);
1939 /* Set SHIFT key released */
1940 GetKeyboardState(kstate);
1941 kstate[VK_SHIFT]=0x00;
1942 SetKeyboardState(kstate);
1944 DestroyWindow(hwnd);
1946 /* make multiple selection, then switch to LVS_SINGLESEL */
1947 hwnd = create_listview_control(0);
1948 for (i=0;i<items;i++) {
1949 insert_item(hwnd, 0);
1951 item_count = (int)SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
1952 expect(items,item_count);
1954 /* try with NULL pointer */
1955 r = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)NULL);
1958 /* select all, check notifications */
1959 ListView_SetItemState(hwnd, -1, 0, LVIS_SELECTED);
1961 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1963 item.stateMask = LVIS_SELECTED;
1964 item.state = LVIS_SELECTED;
1965 r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
1968 ok_sequence(sequences, PARENT_SEQ_INDEX, select_all_parent_seq,
1969 "select all notification", FALSE);
1971 /* deselect all items */
1972 ListView_SetItemState(hwnd, -1, 0, LVIS_SELECTED);
1973 SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, -1);
1975 ListView_SetItemState(hwnd, i, LVIS_SELECTED, LVIS_SELECTED);
1978 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1980 r = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
1983 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
1984 ok(!(style & LVS_SINGLESEL), "LVS_SINGLESEL isn't expected\n");
1985 SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SINGLESEL);
1986 /* check that style is accepted */
1987 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
1988 ok(style & LVS_SINGLESEL, "LVS_SINGLESEL expected\n");
1991 r = ListView_GetItemState(hwnd, i, LVIS_SELECTED);
1992 ok(r & LVIS_SELECTED, "Expected item %d to be selected\n", i);
1994 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
1996 SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
1999 /* select one more */
2000 ListView_SetItemState(hwnd, 3, LVIS_SELECTED, LVIS_SELECTED);
2003 r = ListView_GetItemState(hwnd, i, LVIS_SELECTED);
2004 ok(!(r & LVIS_SELECTED), "Expected item %d to be unselected\n", i);
2006 r = ListView_GetItemState(hwnd, 3, LVIS_SELECTED);
2007 ok(r & LVIS_SELECTED, "Expected item %d to be selected\n", i);
2009 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2011 r = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2014 /* try to select all on LVS_SINGLESEL */
2015 memset(&item, 0, sizeof(item));
2016 item.stateMask = LVIS_SELECTED;
2017 r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2019 SendMessage(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2021 item.stateMask = LVIS_SELECTED;
2022 item.state = LVIS_SELECTED;
2023 r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2026 r = ListView_GetSelectedCount(hwnd);
2028 r = ListView_GetSelectionMark(hwnd);
2031 /* try to deselect all on LVS_SINGLESEL */
2032 item.stateMask = LVIS_SELECTED;
2033 item.state = LVIS_SELECTED;
2034 r = SendMessage(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2037 item.stateMask = LVIS_SELECTED;
2039 r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2041 r = ListView_GetSelectedCount(hwnd);
2044 DestroyWindow(hwnd);
2047 static void test_subitem_rect(void)
2054 /* test LVM_GETSUBITEMRECT for header */
2055 hwnd = create_listview_control(0);
2056 ok(hwnd != NULL, "failed to create a listview window\n");
2057 /* add some columns */
2058 memset(&col, 0, sizeof(LVCOLUMN));
2059 col.mask = LVCF_WIDTH;
2062 r = SendMessage(hwnd, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
2066 r = SendMessage(hwnd, LVM_INSERTCOLUMN, 1, (LPARAM)&col);
2070 r = SendMessage(hwnd, LVM_INSERTCOLUMN, 2, (LPARAM)&col);
2072 /* item = -1 means header, subitem index is 1 based */
2073 rect.left = LVIR_BOUNDS;
2075 rect.right = rect.bottom = 0;
2076 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2079 rect.left = LVIR_BOUNDS;
2081 rect.right = rect.bottom = 0;
2082 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2084 ok(r != 0, "Expected not-null LRESULT\n");
2085 expect(100, rect.left);
2086 expect(250, rect.right);
2088 expect(3, rect.top);
2090 rect.left = LVIR_BOUNDS;
2092 rect.right = rect.bottom = 0;
2093 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2095 ok(r != 0, "Expected not-null LRESULT\n");
2096 expect(250, rect.left);
2097 expect(450, rect.right);
2099 expect(3, rect.top);
2101 /* item LVS_REPORT padding isn't applied to subitems */
2102 insert_item(hwnd, 0);
2104 rect.left = LVIR_BOUNDS;
2106 rect.right = rect.bottom = 0;
2107 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2108 ok(r != 0, "Expected not-null LRESULT\n");
2109 expect(100, rect.left);
2110 expect(250, rect.right);
2112 rect.left = LVIR_ICON;
2114 rect.right = rect.bottom = 0;
2115 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2116 ok(r != 0, "Expected not-null LRESULT\n");
2117 /* no icon attached - zero width rectangle, with no left padding */
2118 expect(100, rect.left);
2119 expect(100, rect.right);
2121 rect.left = LVIR_LABEL;
2123 rect.right = rect.bottom = 0;
2124 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2125 ok(r != 0, "Expected not-null LRESULT\n");
2126 /* same as full LVIR_BOUNDS */
2127 expect(100, rect.left);
2128 expect(250, rect.right);
2130 DestroyWindow(hwnd);
2132 /* try it for non LVS_REPORT style */
2133 hwnd = CreateWindow("SysListView32", "Test", LVS_ICON, 0, 0, 100, 100, NULL, NULL,
2134 GetModuleHandle(NULL), 0);
2135 rect.left = LVIR_BOUNDS;
2137 rect.right = rect.bottom = -10;
2138 r = SendMessage(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2139 ok(r == 0, "Expected not-null LRESULT\n");
2140 /* rect is unchanged */
2141 expect(0, rect.left);
2142 expect(-10, rect.right);
2143 expect(1, rect.top);
2144 expect(-10, rect.bottom);
2145 DestroyWindow(hwnd);
2148 /* comparison callback for test_sorting */
2149 static INT WINAPI test_CallBackCompare(LPARAM first, LPARAM second, LPARAM lParam)
2151 if (first == second) return 0;
2152 return (first > second ? 1 : -1);
2155 static void test_sorting(void)
2161 static CHAR names[][5] = {"A", "B", "C", "D", "0"};
2164 hwnd = create_listview_control(0);
2165 ok(hwnd != NULL, "failed to create a listview window\n");
2167 /* insert some items */
2168 item.mask = LVIF_PARAM | LVIF_STATE;
2169 item.state = LVIS_SELECTED;
2173 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2176 item.mask = LVIF_PARAM;
2180 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2183 item.mask = LVIF_STATE | LVIF_PARAM;
2184 item.state = LVIS_SELECTED;
2188 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2191 r = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2194 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2197 r = SendMessage(hwnd, LVM_SORTITEMS, 0, (LPARAM)test_CallBackCompare);
2200 r = SendMessage(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2202 r = SendMessage(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2204 r = SendMessage(hwnd, LVM_GETITEMSTATE, 0, LVIS_SELECTED);
2206 r = SendMessage(hwnd, LVM_GETITEMSTATE, 1, LVIS_SELECTED);
2207 expect(LVIS_SELECTED, r);
2208 r = SendMessage(hwnd, LVM_GETITEMSTATE, 2, LVIS_SELECTED);
2209 expect(LVIS_SELECTED, r);
2211 DestroyWindow(hwnd);
2213 /* switch to LVS_SORTASCENDING when some items added */
2214 hwnd = create_listview_control(0);
2215 ok(hwnd != NULL, "failed to create a listview window\n");
2217 item.mask = LVIF_TEXT;
2220 item.pszText = names[1];
2221 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2224 item.mask = LVIF_TEXT;
2227 item.pszText = names[2];
2228 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2231 item.mask = LVIF_TEXT;
2234 item.pszText = names[0];
2235 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2238 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2239 SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTASCENDING);
2240 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2241 ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
2243 /* no sorting performed when switched to LVS_SORTASCENDING */
2244 item.mask = LVIF_TEXT;
2246 item.pszText = buff;
2247 item.cchTextMax = sizeof(buff);
2248 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2250 ok(lstrcmp(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
2253 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2255 ok(lstrcmp(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
2258 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2260 ok(lstrcmp(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
2262 /* adding new item doesn't resort list */
2263 item.mask = LVIF_TEXT;
2266 item.pszText = names[3];
2267 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2270 item.mask = LVIF_TEXT;
2272 item.pszText = buff;
2273 item.cchTextMax = sizeof(buff);
2274 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2276 ok(lstrcmp(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
2279 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2281 ok(lstrcmp(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
2284 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2286 ok(lstrcmp(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
2289 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2291 ok(lstrcmp(buff, names[3]) == 0, "Expected '%s', got '%s'\n", names[3], buff);
2293 /* corner case - item should be placed at first position */
2294 item.mask = LVIF_TEXT;
2297 item.pszText = names[4];
2298 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
2302 item.pszText = buff;
2303 item.cchTextMax = sizeof(buff);
2304 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2306 ok(lstrcmp(buff, names[4]) == 0, "Expected '%s', got '%s'\n", names[4], buff);
2309 item.pszText = buff;
2310 item.cchTextMax = sizeof(buff);
2311 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2313 ok(lstrcmp(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
2316 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2318 ok(lstrcmp(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
2321 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2323 ok(lstrcmp(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
2326 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
2328 ok(lstrcmp(buff, names[3]) == 0, "Expected '%s', got '%s'\n", names[3], buff);
2330 DestroyWindow(hwnd);
2333 static void test_ownerdata(void)
2336 LONG_PTR style, ret;
2340 /* it isn't possible to set LVS_OWNERDATA after creation */
2343 win_skip("set LVS_OWNERDATA after creation leads to crash on < 5.80\n");
2347 hwnd = create_listview_control(0);
2348 ok(hwnd != NULL, "failed to create a listview window\n");
2349 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2350 ok(!(style & LVS_OWNERDATA) && style, "LVS_OWNERDATA isn't expected\n");
2352 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2354 ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_OWNERDATA);
2355 ok(ret == style, "Expected set GWL_STYLE to succeed\n");
2356 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
2357 "try to switch to LVS_OWNERDATA seq", FALSE);
2359 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2360 ok(!(style & LVS_OWNERDATA), "LVS_OWNERDATA isn't expected\n");
2361 DestroyWindow(hwnd);
2364 /* try to set LVS_OWNERDATA after creation just having it */
2365 hwnd = create_listview_control(LVS_OWNERDATA);
2366 ok(hwnd != NULL, "failed to create a listview window\n");
2367 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2368 ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
2370 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2372 ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_OWNERDATA);
2373 ok(ret == style, "Expected set GWL_STYLE to succeed\n");
2374 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
2375 "try to switch to LVS_OWNERDATA seq", FALSE);
2376 DestroyWindow(hwnd);
2378 /* try to remove LVS_OWNERDATA after creation just having it */
2381 win_skip("remove LVS_OWNERDATA after creation leads to crash on < 5.80\n");
2385 hwnd = create_listview_control(LVS_OWNERDATA);
2386 ok(hwnd != NULL, "failed to create a listview window\n");
2387 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2388 ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
2390 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2392 ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_OWNERDATA);
2393 ok(ret == style, "Expected set GWL_STYLE to succeed\n");
2394 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
2395 "try to switch to LVS_OWNERDATA seq", FALSE);
2396 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2397 ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
2398 DestroyWindow(hwnd);
2401 /* try select an item */
2402 hwnd = create_listview_control(LVS_OWNERDATA);
2403 ok(hwnd != NULL, "failed to create a listview window\n");
2404 res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
2405 ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2406 res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2408 memset(&item, 0, sizeof(item));
2409 item.stateMask = LVIS_SELECTED;
2410 item.state = LVIS_SELECTED;
2411 res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2413 res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2415 res = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2417 DestroyWindow(hwnd);
2419 /* LVM_SETITEM is unsupported on LVS_OWNERDATA */
2420 hwnd = create_listview_control(LVS_OWNERDATA);
2421 ok(hwnd != NULL, "failed to create a listview window\n");
2422 res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
2423 ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2424 res = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2426 memset(&item, 0, sizeof(item));
2427 item.mask = LVIF_STATE;
2429 item.stateMask = LVIS_SELECTED;
2430 item.state = LVIS_SELECTED;
2431 res = SendMessageA(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2433 DestroyWindow(hwnd);
2435 /* check notifications after focused/selected changed */
2436 hwnd = create_listview_control(LVS_OWNERDATA);
2437 ok(hwnd != NULL, "failed to create a listview window\n");
2438 res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 20, 0);
2439 ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2441 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2443 memset(&item, 0, sizeof(item));
2444 item.stateMask = LVIS_SELECTED;
2445 item.state = LVIS_SELECTED;
2446 res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2449 ok_sequence(sequences, PARENT_SEQ_INDEX, ownderdata_select_focus_parent_seq,
2450 "ownerdata select notification", TRUE);
2452 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2454 memset(&item, 0, sizeof(item));
2455 item.stateMask = LVIS_FOCUSED;
2456 item.state = LVIS_FOCUSED;
2457 res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2460 ok_sequence(sequences, PARENT_SEQ_INDEX, ownderdata_select_focus_parent_seq,
2461 "ownerdata focus notification", TRUE);
2463 /* select all, check notifications */
2464 item.stateMask = LVIS_SELECTED;
2466 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2469 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2471 item.stateMask = LVIS_SELECTED;
2472 item.state = LVIS_SELECTED;
2474 g_dump_itemchanged = TRUE;
2475 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2477 g_dump_itemchanged = FALSE;
2479 ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_setstate_all_parent_seq,
2480 "ownerdata select all notification", TRUE);
2482 /* select all again, note that all items are selected already */
2483 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2484 item.stateMask = LVIS_SELECTED;
2485 item.state = LVIS_SELECTED;
2486 g_dump_itemchanged = TRUE;
2487 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2489 g_dump_itemchanged = FALSE;
2490 ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_setstate_all_parent_seq,
2491 "ownerdata select all notification", TRUE);
2493 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2494 item.stateMask = LVIS_SELECTED;
2496 g_dump_itemchanged = TRUE;
2497 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2499 g_dump_itemchanged = FALSE;
2500 ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_deselect_all_parent_seq,
2501 "ownerdata deselect all notification", TRUE);
2503 /* select one, then deselect all */
2504 item.stateMask = LVIS_SELECTED;
2505 item.state = LVIS_SELECTED;
2506 res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2508 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2509 item.stateMask = LVIS_SELECTED;
2511 g_dump_itemchanged = TRUE;
2512 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2514 g_dump_itemchanged = FALSE;
2515 ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_deselect_all_parent_seq,
2516 "ownerdata select all notification", TRUE);
2518 /* remove focused, try to focus all */
2519 item.stateMask = LVIS_FOCUSED;
2520 item.state = LVIS_FOCUSED;
2521 res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2523 item.stateMask = LVIS_FOCUSED;
2525 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2527 item.stateMask = LVIS_FOCUSED;
2528 res = SendMessageA(hwnd, LVM_GETITEMSTATE, 0, LVIS_FOCUSED);
2530 /* setting all to focused returns failure value */
2531 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2532 item.stateMask = LVIS_FOCUSED;
2533 item.state = LVIS_FOCUSED;
2534 g_dump_itemchanged = TRUE;
2535 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2537 g_dump_itemchanged = FALSE;
2538 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
2539 "ownerdata focus all notification", FALSE);
2540 /* focus single item, remove all */
2541 item.stateMask = LVIS_FOCUSED;
2542 item.state = LVIS_FOCUSED;
2543 res = SendMessage(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2545 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2546 item.stateMask = LVIS_FOCUSED;
2548 g_dump_itemchanged = TRUE;
2549 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2551 g_dump_itemchanged = FALSE;
2552 ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_defocus_all_parent_seq,
2553 "ownerdata remove focus all notification", TRUE);
2555 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2556 item.stateMask = LVIS_CUT;
2557 item.state = LVIS_CUT;
2558 g_dump_itemchanged = TRUE;
2559 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2561 g_dump_itemchanged = FALSE;
2562 ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_setstate_all_parent_seq,
2563 "ownerdata cut all notification", TRUE);
2564 /* all marked cut, try again */
2565 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2566 item.stateMask = LVIS_CUT;
2567 item.state = LVIS_CUT;
2568 g_dump_itemchanged = TRUE;
2569 res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2571 g_dump_itemchanged = FALSE;
2572 ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_setstate_all_parent_seq,
2573 "ownerdata cut all notification #2", TRUE);
2575 DestroyWindow(hwnd);
2577 /* check notifications on LVM_GETITEM */
2578 /* zero callback mask */
2579 hwnd = create_listview_control(LVS_OWNERDATA);
2580 ok(hwnd != NULL, "failed to create a listview window\n");
2581 res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
2582 ok(res != 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2584 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2586 memset(&item, 0, sizeof(item));
2587 item.stateMask = LVIS_SELECTED;
2588 item.mask = LVIF_STATE;
2589 res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
2592 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
2593 "ownerdata getitem selected state 1", FALSE);
2595 /* non zero callback mask but not we asking for */
2596 res = SendMessageA(hwnd, LVM_SETCALLBACKMASK, LVIS_OVERLAYMASK, 0);
2599 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2601 memset(&item, 0, sizeof(item));
2602 item.stateMask = LVIS_SELECTED;
2603 item.mask = LVIF_STATE;
2604 res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
2607 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
2608 "ownerdata getitem selected state 2", FALSE);
2610 /* LVIS_OVERLAYMASK callback mask, asking for index */
2611 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2613 memset(&item, 0, sizeof(item));
2614 item.stateMask = LVIS_OVERLAYMASK;
2615 item.mask = LVIF_STATE;
2616 res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
2619 ok_sequence(sequences, PARENT_SEQ_INDEX, single_getdispinfo_parent_seq,
2620 "ownerdata getitem selected state 2", FALSE);
2622 DestroyWindow(hwnd);
2624 /* LVS_SORTASCENDING/LVS_SORTDESCENDING aren't compatible with LVS_OWNERDATA */
2625 hwnd = create_listview_control(LVS_OWNERDATA | LVS_SORTASCENDING);
2626 ok(hwnd != NULL, "failed to create a listview window\n");
2627 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2628 ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
2629 ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
2630 SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_SORTASCENDING);
2631 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2632 ok(!(style & LVS_SORTASCENDING), "Expected LVS_SORTASCENDING not set\n");
2633 DestroyWindow(hwnd);
2634 /* apparently it's allowed to switch these style on after creation */
2635 hwnd = create_listview_control(LVS_OWNERDATA);
2636 ok(hwnd != NULL, "failed to create a listview window\n");
2637 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2638 ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
2639 SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTASCENDING);
2640 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2641 ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
2642 DestroyWindow(hwnd);
2644 hwnd = create_listview_control(LVS_OWNERDATA);
2645 ok(hwnd != NULL, "failed to create a listview window\n");
2646 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2647 ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
2648 SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTDESCENDING);
2649 style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2650 ok(style & LVS_SORTDESCENDING, "Expected LVS_SORTDESCENDING to be set\n");
2651 DestroyWindow(hwnd);
2654 static void test_norecompute(void)
2656 static CHAR testA[] = "test";
2662 /* self containing control */
2663 hwnd = create_listview_control(0);
2664 ok(hwnd != NULL, "failed to create a listview window\n");
2665 memset(&item, 0, sizeof(item));
2666 item.mask = LVIF_TEXT | LVIF_STATE;
2668 item.stateMask = LVIS_SELECTED;
2669 item.state = LVIS_SELECTED;
2670 item.pszText = testA;
2671 res = SendMessageA(hwnd, LVM_INSERTITEM, 0, (LPARAM)&item);
2673 /* retrieve with LVIF_NORECOMPUTE */
2674 item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
2676 item.pszText = buff;
2677 item.cchTextMax = sizeof(buff)/sizeof(CHAR);
2678 res = SendMessageA(hwnd, LVM_GETITEM, 0, (LPARAM)&item);
2680 ok(lstrcmp(buff, testA) == 0, "Expected (%s), got (%s)\n", testA, buff);
2682 item.mask = LVIF_TEXT;
2684 item.pszText = LPSTR_TEXTCALLBACK;
2685 res = SendMessageA(hwnd, LVM_INSERTITEM, 0, (LPARAM)&item);
2688 item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
2690 item.pszText = buff;
2691 item.cchTextMax = sizeof(buff)/sizeof(CHAR);
2693 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2694 res = SendMessageA(hwnd, LVM_GETITEM, 0, (LPARAM)&item);
2696 ok(item.pszText == LPSTR_TEXTCALLBACK, "Expected (%p), got (%p)\n",
2697 LPSTR_TEXTCALLBACK, (VOID*)item.pszText);
2698 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "retrieve with LVIF_NORECOMPUTE seq", FALSE);
2700 DestroyWindow(hwnd);
2703 hwnd = create_listview_control(LVS_OWNERDATA);
2704 ok(hwnd != NULL, "failed to create a listview window\n");
2706 item.mask = LVIF_STATE;
2707 item.stateMask = LVIS_SELECTED;
2708 item.state = LVIS_SELECTED;
2710 res = SendMessageA(hwnd, LVM_INSERTITEM, 0, (LPARAM)&item);
2713 item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
2715 item.pszText = buff;
2716 item.cchTextMax = sizeof(buff)/sizeof(CHAR);
2717 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2718 res = SendMessageA(hwnd, LVM_GETITEM, 0, (LPARAM)&item);
2720 ok(item.pszText == LPSTR_TEXTCALLBACK, "Expected (%p), got (%p)\n",
2721 LPSTR_TEXTCALLBACK, (VOID*)item.pszText);
2722 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "retrieve with LVIF_NORECOMPUTE seq 2", FALSE);
2724 DestroyWindow(hwnd);
2727 static void test_nosortheader(void)
2732 hwnd = create_listview_control(0);
2733 ok(hwnd != NULL, "failed to create a listview window\n");
2735 header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
2736 ok(IsWindow(header), "header expected\n");
2738 style = GetWindowLongPtr(header, GWL_STYLE);
2739 ok(style & HDS_BUTTONS, "expected header to have HDS_BUTTONS\n");
2741 style = GetWindowLongPtr(hwnd, GWL_STYLE);
2742 SetWindowLongPtr(hwnd, GWL_STYLE, style | LVS_NOSORTHEADER);
2743 /* HDS_BUTTONS retained */
2744 style = GetWindowLongPtr(header, GWL_STYLE);
2745 ok(style & HDS_BUTTONS, "expected header to retain HDS_BUTTONS\n");
2747 DestroyWindow(hwnd);
2749 /* create with LVS_NOSORTHEADER */
2750 hwnd = create_listview_control(LVS_NOSORTHEADER);
2751 ok(hwnd != NULL, "failed to create a listview window\n");
2753 header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
2754 ok(IsWindow(header), "header expected\n");
2756 style = GetWindowLongPtr(header, GWL_STYLE);
2757 ok(!(style & HDS_BUTTONS), "expected header to have no HDS_BUTTONS\n");
2759 style = GetWindowLongPtr(hwnd, GWL_STYLE);
2760 SetWindowLongPtr(hwnd, GWL_STYLE, style & ~LVS_NOSORTHEADER);
2761 /* not changed here */
2762 style = GetWindowLongPtr(header, GWL_STYLE);
2763 ok(!(style & HDS_BUTTONS), "expected header to have no HDS_BUTTONS\n");
2765 DestroyWindow(hwnd);
2768 static void test_setredraw(void)
2776 hwnd = create_listview_control(LVS_OWNERDATA);
2777 ok(hwnd != NULL, "failed to create a listview window\n");
2779 /* Passing WM_SETREDRAW to DefWinProc removes WS_VISIBLE.
2780 ListView seems to handle it internally without DefWinProc */
2782 /* default value first */
2783 ret = SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
2786 style = GetWindowLongPtr(hwnd, GWL_STYLE);
2787 ok(style & WS_VISIBLE, "Expected WS_VISIBLE to be set\n");
2788 ret = SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
2790 style = GetWindowLongPtr(hwnd, GWL_STYLE);
2791 ok(style & WS_VISIBLE, "Expected WS_VISIBLE to be set\n");
2792 ret = SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
2795 /* check update rect after redrawing */
2796 ret = SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
2798 InvalidateRect(hwnd, NULL, FALSE);
2799 RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW);
2800 rect.right = rect.bottom = 1;
2801 GetUpdateRect(hwnd, &rect, FALSE);
2802 expect(0, rect.right);
2803 expect(0, rect.bottom);
2806 hdc = GetWindowDC(hwndparent);
2807 ret = SendMessage(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
2809 ret = SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
2811 ret = SendMessage(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
2813 ret = SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
2815 ReleaseDC(hwndparent, hdc);
2817 /* check notification messages to show that repainting is disabled */
2818 ret = SendMessage(hwnd, LVM_SETITEMCOUNT, 1, 0);
2820 ret = SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
2822 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2824 InvalidateRect(hwnd, NULL, TRUE);
2826 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
2827 "redraw after WM_SETREDRAW (FALSE)", FALSE);
2829 ret = SendMessage(hwnd, LVM_SETBKCOLOR, 0, CLR_NONE);
2831 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2832 InvalidateRect(hwnd, NULL, TRUE);
2834 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
2835 "redraw after WM_SETREDRAW (FALSE) with CLR_NONE bkgnd", FALSE);
2837 /* message isn't forwarded to header */
2838 subclass_header(hwnd);
2839 flush_sequences(sequences, NUM_MSG_SEQUENCES);
2840 ret = SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
2842 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, setredraw_seq,
2843 "WM_SETREDRAW: not forwarded to header", FALSE);
2845 DestroyWindow(hwnd);
2848 static void test_hittest(void)
2854 static CHAR text[] = "1234567890ABCDEFGHIJKLMNOPQRST";
2857 HIMAGELIST himl, himl2;
2860 hwnd = create_listview_control(0);
2861 ok(hwnd != NULL, "failed to create a listview window\n");
2863 /* LVS_REPORT with a single subitem (2 columns) */
2864 insert_column(hwnd, 0);
2865 insert_column(hwnd, 1);
2866 insert_item(hwnd, 0);
2869 /* the only purpose of that line is to be as long as a half item rect */
2870 item.pszText = text;
2871 r = SendMessage(hwnd, LVM_SETITEMTEXT, 0, (LPARAM)&item);
2874 r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0));
2876 r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(100, 0));
2879 memset(&bounds, 0, sizeof(bounds));
2880 bounds.left = LVIR_BOUNDS;
2881 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&bounds);
2882 ok(bounds.bottom - bounds.top > 0, "Expected non zero item height\n");
2883 ok(bounds.right - bounds.left > 0, "Expected non zero item width\n");
2884 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pos);
2887 /* LVS_EX_FULLROWSELECT not set, no icons attached */
2888 x = pos.x + 50; /* column half width */
2889 y = pos.y + (bounds.bottom - bounds.top) / 2;
2890 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMLABEL, 0, FALSE, FALSE, __LINE__);
2891 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2892 x = pos.x + 150; /* outside column */
2893 y = pos.y + (bounds.bottom - bounds.top) / 2;
2894 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, FALSE, __LINE__);
2895 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2896 y = (bounds.bottom - bounds.top) / 2;
2897 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, TRUE, __LINE__);
2898 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2899 /* outside possible client rectangle (to right) */
2901 y = pos.y + (bounds.bottom - bounds.top) / 2;
2902 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, FALSE, __LINE__);
2903 test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE, __LINE__);
2904 y = (bounds.bottom - bounds.top) / 2;
2905 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, TRUE, __LINE__);
2906 test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE, __LINE__);
2907 /* subitem returned with -1 item too */
2910 test_lvm_subitemhittest(hwnd, x, y, -1, 1, LVHT_NOWHERE, FALSE, FALSE, FALSE, __LINE__);
2911 /* parent client area is 100x100 by default */
2912 MoveWindow(hwnd, 0, 0, 300, 100, FALSE);
2913 x = pos.x + 150; /* outside column */
2914 y = pos.y + (bounds.bottom - bounds.top) / 2;
2915 test_lvm_hittest(hwnd, x, y, -1, LVHT_NOWHERE, 0, FALSE, FALSE, __LINE__);
2916 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2917 y = (bounds.bottom - bounds.top) / 2;
2918 test_lvm_hittest(hwnd, x, y, -1, LVHT_NOWHERE, 0, FALSE, TRUE, __LINE__);
2919 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2920 /* the same with LVS_EX_FULLROWSELECT */
2921 SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);
2922 x = pos.x + 150; /* outside column */
2923 y = pos.y + (bounds.bottom - bounds.top) / 2;
2924 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEM, LVHT_ONITEMLABEL, FALSE, FALSE, __LINE__);
2925 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2926 y = (bounds.bottom - bounds.top) / 2;
2927 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2928 MoveWindow(hwnd, 0, 0, 100, 100, FALSE);
2929 x = pos.x + 150; /* outside column */
2930 y = pos.y + (bounds.bottom - bounds.top) / 2;
2931 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, FALSE, __LINE__);
2932 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2933 y = (bounds.bottom - bounds.top) / 2;
2934 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, TRUE, __LINE__);
2935 test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE, __LINE__);
2936 /* outside possible client rectangle (to right) */
2938 y = pos.y + (bounds.bottom - bounds.top) / 2;
2939 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, FALSE, __LINE__);
2940 test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE, __LINE__);
2941 y = (bounds.bottom - bounds.top) / 2;
2942 test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, TRUE, __LINE__);
2943 test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE, __LINE__);
2944 /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
2945 himl = ImageList_Create(16, 16, 0, 4, 4);
2946 ok(himl != NULL, "failed to create imagelist\n");
2947 hbmp = CreateBitmap(16, 16, 1, 1, NULL);
2948 ok(hbmp != NULL, "failed to create bitmap\n");
2949 r = ImageList_Add(himl, hbmp, 0);
2950 ok(r == 0, "should be zero\n");
2951 hbmp = CreateBitmap(16, 16, 1, 1, NULL);
2952 ok(hbmp != NULL, "failed to create bitmap\n");
2953 r = ImageList_Add(himl, hbmp, 0);
2954 ok(r == 1, "should be one\n");
2956 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl);
2957 ok(r == 0, "should return zero\n");
2959 item.mask = LVIF_IMAGE;
2963 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2967 y = pos.y + (bounds.bottom - bounds.top) / 2;
2968 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, 0, FALSE, FALSE, __LINE__);
2969 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__);
2970 y = (bounds.bottom - bounds.top) / 2;
2971 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__);
2973 /* state icons indices are 1 based, check with valid index */
2974 item.mask = LVIF_STATE;
2975 item.state = INDEXTOSTATEIMAGEMASK(1);
2976 item.stateMask = LVIS_STATEIMAGEMASK;
2979 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
2983 y = pos.y + (bounds.bottom - bounds.top) / 2;
2984 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, 0, FALSE, FALSE, __LINE__);
2985 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__);
2986 y = (bounds.bottom - bounds.top) / 2;
2987 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__);
2989 himl2 = (HIMAGELIST)SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)NULL);
2990 ok(himl2 == himl, "should return handle\n");
2992 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl);
2993 ok(r == 0, "should return zero\n");
2996 y = pos.y + (bounds.bottom - bounds.top) / 2;
2997 test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMICON, 0, FALSE, FALSE, __LINE__);
2998 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMICON, FALSE, FALSE, FALSE, __LINE__);
2999 y = (bounds.bottom - bounds.top) / 2;
3000 test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMICON, FALSE, FALSE, FALSE, __LINE__);
3002 DestroyWindow(hwnd);
3005 static void test_getviewrect(void)
3012 hwnd = create_listview_control(0);
3013 ok(hwnd != NULL, "failed to create a listview window\n");
3016 r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
3019 insert_column(hwnd, 0);
3020 insert_column(hwnd, 1);
3022 memset(&item, 0, sizeof(item));
3025 SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
3027 r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0));
3029 r = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(120, 0));
3032 rect.left = rect.right = rect.top = rect.bottom = -1;
3033 r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
3035 /* left is set to (2e31-1) - XP SP2 */
3036 expect(0, rect.right);
3037 expect(0, rect.top);
3038 expect(0, rect.bottom);
3040 /* switch to LVS_ICON */
3041 SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~LVS_REPORT);
3043 rect.left = rect.right = rect.top = rect.bottom = -1;
3044 r = SendMessage(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
3046 expect(0, rect.left);
3047 expect(0, rect.top);
3048 /* precise value differs for 2k, XP and Vista */
3049 ok(rect.bottom > 0, "Expected positive bottom value, got %d\n", rect.bottom);
3050 ok(rect.right > 0, "Expected positive right value, got %d\n", rect.right);
3052 DestroyWindow(hwnd);
3055 static void test_getitemposition(void)
3062 hwnd = create_listview_control(0);
3063 ok(hwnd != NULL, "failed to create a listview window\n");
3064 header = subclass_header(hwnd);
3066 /* LVS_REPORT, single item, no columns added */
3067 insert_item(hwnd, 0);
3069 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3072 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
3074 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getitemposition_seq1, "get item position 1", FALSE);
3076 /* LVS_REPORT, single item, single column */
3077 insert_column(hwnd, 0);
3079 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3082 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
3084 ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getitemposition_seq2, "get item position 2", TRUE);
3086 memset(&rect, 0, sizeof(rect));
3087 SendMessage(header, HDM_GETITEMRECT, 0, (LPARAM)&rect);
3090 /* offset by header height */
3091 expect(rect.bottom - rect.top, pt.y);
3093 DestroyWindow(hwnd);
3096 static void test_columnscreation(void)
3101 hwnd = create_listview_control(0);
3102 ok(hwnd != NULL, "failed to create a listview window\n");
3104 insert_item(hwnd, 0);
3106 /* headers columns aren't created automatically */
3107 header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0);
3108 ok(IsWindow(header), "Expected header handle\n");
3109 r = SendMessage(header, HDM_GETITEMCOUNT, 0, 0);
3112 DestroyWindow(hwnd);
3115 static void test_getitemrect(void)
3127 hwnd = create_listview_control(0);
3128 ok(hwnd != NULL, "failed to create a listview window\n");
3131 memset(&item, 0, sizeof(item));
3134 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
3137 rect.left = LVIR_BOUNDS;
3138 rect.right = rect.top = rect.bottom = -1;
3139 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3142 /* zero width rectangle with no padding */
3143 expect(0, rect.left);
3144 expect(0, rect.right);
3146 insert_column(hwnd, 0);
3147 insert_column(hwnd, 1);
3149 col.mask = LVCF_WIDTH;
3151 r = SendMessage(hwnd, LVM_SETCOLUMN, 0, (LPARAM)&col);
3154 col.mask = LVCF_WIDTH;
3156 r = SendMessage(hwnd, LVM_SETCOLUMN, 1, (LPARAM)&col);
3159 rect.left = LVIR_BOUNDS;
3160 rect.right = rect.top = rect.bottom = -1;
3161 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3164 /* still no left padding */
3165 expect(0, rect.left);
3166 expect(150, rect.right);
3168 rect.left = LVIR_SELECTBOUNDS;
3169 rect.right = rect.top = rect.bottom = -1;
3170 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3173 expect(2, rect.left);
3175 rect.left = LVIR_LABEL;
3176 rect.right = rect.top = rect.bottom = -1;
3177 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3179 /* padding, column width */
3180 expect(2, rect.left);
3181 expect(50, rect.right);
3183 /* no icons attached */
3184 rect.left = LVIR_ICON;
3185 rect.right = rect.top = rect.bottom = -1;
3186 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3189 expect(2, rect.left);
3190 expect(2, rect.right);
3193 order[0] = 1; order[1] = 0;
3194 r = SendMessage(hwnd, LVM_SETCOLUMNORDERARRAY, 2, (LPARAM)&order);
3197 r = SendMessage(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
3199 /* 1 indexed column width + padding */
3201 /* rect is at zero too */
3202 rect.left = LVIR_BOUNDS;
3203 rect.right = rect.top = rect.bottom = -1;
3204 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3206 expect(0, rect.left);
3207 /* just width sum */
3208 expect(150, rect.right);
3210 rect.left = LVIR_SELECTBOUNDS;
3211 rect.right = rect.top = rect.bottom = -1;
3212 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3214 /* column width + padding */
3215 expect(102, rect.left);
3217 /* back to initial order */
3218 order[0] = 0; order[1] = 1;
3219 r = SendMessage(hwnd, LVM_SETCOLUMNORDERARRAY, 2, (LPARAM)&order);
3223 himl = ImageList_Create(16, 16, 0, 2, 2);
3224 ok(himl != NULL, "failed to create imagelist\n");
3225 hbm = CreateBitmap(16, 16, 1, 1, NULL);
3226 ok(hbm != NULL, "failed to create bitmap\n");
3227 r = ImageList_Add(himl, hbm, 0);
3228 ok(r == 0, "should be zero\n");
3229 hbm = CreateBitmap(16, 16, 1, 1, NULL);
3230 ok(hbm != NULL, "failed to create bitmap\n");
3231 r = ImageList_Add(himl, hbm, 0);
3232 ok(r == 1, "should be one\n");
3234 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl);
3235 ok(r == 0, "should return zero\n");
3237 item.mask = LVIF_STATE;
3238 item.state = INDEXTOSTATEIMAGEMASK(1);
3239 item.stateMask = LVIS_STATEIMAGEMASK;
3242 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
3246 rect.left = LVIR_ICON;
3247 rect.right = rect.top = rect.bottom = -1;
3248 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3250 /* padding + stateicon width */
3251 expect(18, rect.left);
3252 expect(18, rect.right);
3254 rect.left = LVIR_LABEL;
3255 rect.right = rect.top = rect.bottom = -1;
3256 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3258 /* padding + stateicon width -> column width */
3259 expect(18, rect.left);
3260 expect(50, rect.right);
3262 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)NULL);
3263 ok(r != 0, "should return current list handle\n");
3265 r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl);
3266 ok(r == 0, "should return zero\n");
3268 item.mask = LVIF_STATE | LVIF_IMAGE;
3271 item.stateMask = ~0;
3274 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
3278 rect.left = LVIR_ICON;
3279 rect.right = rect.top = rect.bottom = -1;
3280 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3282 /* padding, icon width */
3283 expect(2, rect.left);
3284 expect(18, rect.right);
3286 rect.left = LVIR_LABEL;
3287 rect.right = rect.top = rect.bottom = -1;
3288 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3290 /* padding + icon width -> column width */
3291 expect(18, rect.left);
3292 expect(50, rect.right);
3295 rect.left = LVIR_SELECTBOUNDS;
3296 rect.right = rect.top = rect.bottom = -1;
3297 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3299 /* padding, column width */
3300 expect(2, rect.left);
3301 expect(50, rect.right);
3303 /* try with indentation */
3304 item.mask = LVIF_INDENT;
3308 r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
3312 rect.left = LVIR_BOUNDS;
3313 rect.right = rect.top = rect.bottom = -1;
3314 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3316 /* padding + 1 icon width, column width */
3317 expect(0, rect.left);
3318 expect(150, rect.right);
3321 rect.left = LVIR_SELECTBOUNDS;
3322 rect.right = rect.top = rect.bottom = -1;
3323 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3325 /* padding + 1 icon width, column width */
3326 expect(2 + 16, rect.left);
3327 expect(50, rect.right);
3330 rect.left = LVIR_LABEL;
3331 rect.right = rect.top = rect.bottom = -1;
3332 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3334 /* padding + 2 icon widths, column width */
3335 expect(2 + 16*2, rect.left);
3336 expect(50, rect.right);
3339 rect.left = LVIR_ICON;
3340 rect.right = rect.top = rect.bottom = -1;
3341 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
3343 /* padding + 1 icon width indentation, icon width */
3344 expect(2 + 16, rect.left);
3345 expect(34, rect.right);
3348 DestroyWindow(hwnd);
3351 static void test_editbox(void)
3353 HWND hwnd, hwndedit, hwndedit2;
3356 static CHAR testitemA[] = "testitem";
3357 static CHAR testitem1A[] = "testitem1";
3358 static CHAR buffer[10];
3360 hwnd = create_listview_control(LVS_EDITLABELS);
3361 ok(hwnd != NULL, "failed to create a listview window\n");
3363 insert_column(hwnd, 0);
3365 memset(&item, 0, sizeof(item));
3366 item.mask = LVIF_TEXT;
3367 item.pszText = testitemA;
3370 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
3373 /* setting focus is necessary */
3375 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3376 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
3378 /* modify initial string */
3379 r = SendMessage(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem1A);
3381 /* return focus to listview */
3384 memset(&item, 0, sizeof(item));
3385 item.mask = LVIF_TEXT;
3386 item.pszText = buffer;
3387 item.cchTextMax = 10;
3390 r = SendMessage(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
3393 ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
3395 /* send LVM_EDITLABEL on already created edit */
3397 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3398 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
3399 /* focus will be set to edit */
3400 ok(GetFocus() == hwndedit, "Expected Edit window to be focused\n");
3401 hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3402 ok(IsWindow(hwndedit2), "Expected Edit window to be created\n");
3404 /* creating label disabled when control isn't focused */
3406 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3407 todo_wine ok(hwndedit == NULL, "Expected Edit window not to be created\n");
3409 /* check EN_KILLFOCUS handling */
3410 memset(&item, 0, sizeof(item));
3411 item.pszText = testitemA;
3414 r = SendMessage(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&item);
3418 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3419 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
3420 /* modify edit and notify control that it lost focus */
3421 r = SendMessage(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem1A);
3423 r = SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit);
3425 memset(&item, 0, sizeof(item));
3426 item.pszText = buffer;
3427 item.cchTextMax = 10;
3430 r = SendMessage(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
3431 expect(lstrlen(item.pszText), r);
3432 ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
3433 ok(!IsWindow(hwndedit), "Expected Edit window to be freed\n");
3434 /* end edit without saving */
3436 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3437 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3438 r = SendMessage(hwndedit, WM_KEYDOWN, VK_ESCAPE, 0);
3440 ok_sequence(sequences, PARENT_SEQ_INDEX, edit_end_nochange,
3441 "edit box - end edit, no change, escape", TRUE);
3442 /* end edit with saving */
3444 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3445 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3446 r = SendMessage(hwndedit, WM_KEYDOWN, VK_RETURN, 0);
3448 ok_sequence(sequences, PARENT_SEQ_INDEX, edit_end_nochange,
3449 "edit box - end edit, no change, return", TRUE);
3451 memset(&item, 0, sizeof(item));
3452 item.pszText = buffer;
3453 item.cchTextMax = 10;
3456 r = SendMessage(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
3457 expect(lstrlen(item.pszText), r);
3458 ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
3460 /* LVM_EDITLABEL with -1 destroys current edit */
3461 hwndedit = (HWND)SendMessage(hwnd, LVM_GETEDITCONTROL, 0, 0);
3462 ok(hwndedit == NULL, "Expected Edit window not to be created\n");
3463 /* no edit present */
3464 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -1, 0);
3465 ok(hwndedit == NULL, "Expected Edit window not to be created\n");
3466 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3467 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
3469 ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
3470 hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -1, 0);
3471 ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
3472 ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
3473 ok(GetFocus() == hwnd, "Expected List to be focused\n");
3474 /* check another negative value */
3475 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3476 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
3477 ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
3478 hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, -2, 0);
3479 ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
3480 ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
3481 ok(GetFocus() == hwnd, "Expected List to be focused\n");
3482 /* and value greater than max item index */
3483 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3484 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
3485 ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
3486 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
3487 hwndedit2 = (HWND)SendMessage(hwnd, LVM_EDITLABEL, r, 0);
3488 ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
3489 ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
3490 ok(GetFocus() == hwnd, "Expected List to be focused\n");
3492 /* messaging tests */
3494 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3496 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3497 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
3498 /* testing only sizing messages */
3499 ok_sequence(sequences, EDITBOX_SEQ_INDEX, editbox_create_pos,
3500 "edit box create - sizing", FALSE);
3502 /* WM_COMMAND with EN_KILLFOCUS isn't forwared to parent */
3504 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3505 ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
3506 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3507 r = SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit);
3509 ok_sequence(sequences, PARENT_SEQ_INDEX, edit_end_nochange,
3510 "edit box WM_COMMAND (EN_KILLFOCUS)", TRUE);
3512 DestroyWindow(hwnd);
3515 static void test_notifyformat(void)
3520 hwnd = create_listview_control(0);
3521 ok(hwnd != NULL, "failed to create a listview window\n");
3523 /* CCM_GETUNICODEFORMAT == LVM_GETUNICODEFORMAT,
3524 CCM_SETUNICODEFORMAT == LVM_SETUNICODEFORMAT */
3525 r = SendMessage(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3527 r = SendMessage(hwnd, WM_NOTIFYFORMAT, 0, NF_QUERY);
3529 r = SendMessage(hwnd, LVM_SETUNICODEFORMAT, 1, 0);
3531 r = SendMessage(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3534 r = SendMessage(hwnd, LVM_SETUNICODEFORMAT, 0, 0);
3536 r = SendMessage(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3541 win_skip("LVM_GETUNICODEFORMAT is unsupported\n");
3542 DestroyWindow(hwnd);
3546 DestroyWindow(hwnd);
3548 /* test failure in parent WM_NOTIFYFORMAT */
3550 hwnd = create_listview_control(0);
3551 ok(hwnd != NULL, "failed to create a listview window\n");
3552 header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0);
3553 ok(IsWindow(header), "expected header to be created\n");
3554 r = SendMessage(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3556 r = SendMessage(header, HDM_GETUNICODEFORMAT, 0, 0);
3557 ok( r == 1 || broken(r == 0), /* win9x */ "Expected 1, got %d\n", r );
3558 r = SendMessage(hwnd, WM_NOTIFYFORMAT, 0, NF_QUERY);
3559 ok(r != 0, "Expected valid format\n");
3561 notifyFormat = NFR_UNICODE;
3562 r = SendMessage(hwnd, WM_NOTIFYFORMAT, 0, NF_REQUERY);
3563 expect(NFR_UNICODE, r);
3564 r = SendMessage(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3566 r = SendMessage(header, HDM_GETUNICODEFORMAT, 0, 0);
3567 ok( r == 1 || broken(r == 0), /* win9x */ "Expected 1, got %d\n", r );
3569 notifyFormat = NFR_ANSI;
3570 r = SendMessage(hwnd, WM_NOTIFYFORMAT, 0, NF_REQUERY);
3571 expect(NFR_ANSI, r);
3572 r = SendMessage(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3574 r = SendMessage(header, HDM_GETUNICODEFORMAT, 0, 0);
3575 ok( r == 1 || broken(r == 0), /* win9x */ "Expected 1, got %d\n", r );
3577 DestroyWindow(hwnd);
3579 /* try different unicode window combination and defaults */
3580 if (!GetModuleHandleW(NULL))
3582 win_skip("Additional notify format tests are incompatible with Win9x\n");
3586 hwndparentW = create_parent_window(TRUE);
3587 ok(IsWindow(hwndparentW), "Unicode parent creation failed\n");
3588 if (!IsWindow(hwndparentW)) return;
3591 hwnd = create_listview_controlW(0, hwndparentW);
3592 ok(hwnd != NULL, "failed to create a listview window\n");
3593 header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0);
3594 ok(IsWindow(header), "expected header to be created\n");
3595 r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3597 r = SendMessage(header, HDM_GETUNICODEFORMAT, 0, 0);
3599 DestroyWindow(hwnd);
3600 /* receiving error code defaulting to ansi */
3602 hwnd = create_listview_controlW(0, hwndparentW);
3603 ok(hwnd != NULL, "failed to create a listview window\n");
3604 header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0);
3605 ok(IsWindow(header), "expected header to be created\n");
3606 r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3608 r = SendMessage(header, HDM_GETUNICODEFORMAT, 0, 0);
3610 DestroyWindow(hwnd);
3611 /* receiving ansi code from unicode window, use it */
3612 notifyFormat = NFR_ANSI;
3613 hwnd = create_listview_controlW(0, hwndparentW);
3614 ok(hwnd != NULL, "failed to create a listview window\n");
3615 header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0);
3616 ok(IsWindow(header), "expected header to be created\n");
3617 r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3619 r = SendMessage(header, HDM_GETUNICODEFORMAT, 0, 0);
3621 DestroyWindow(hwnd);
3622 /* unicode listview with ansi parent window */
3624 hwnd = create_listview_controlW(0, hwndparent);
3625 ok(hwnd != NULL, "failed to create a listview window\n");
3626 header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0);
3627 ok(IsWindow(header), "expected header to be created\n");
3628 r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3630 r = SendMessage(header, HDM_GETUNICODEFORMAT, 0, 0);
3632 DestroyWindow(hwnd);
3633 /* unicode listview with ansi parent window, return error code */
3635 hwnd = create_listview_controlW(0, hwndparent);
3636 ok(hwnd != NULL, "failed to create a listview window\n");
3637 header = (HWND)SendMessage(hwnd, LVM_GETHEADER, 0, 0);
3638 ok(IsWindow(header), "expected header to be created\n");
3639 r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
3641 r = SendMessage(header, HDM_GETUNICODEFORMAT, 0, 0);
3643 DestroyWindow(hwnd);
3645 DestroyWindow(hwndparentW);
3648 static void test_indentation(void)
3654 hwnd = create_listview_control(0);
3655 ok(hwnd != NULL, "failed to create a listview window\n");
3657 memset(&item, 0, sizeof(item));
3658 item.mask = LVIF_INDENT;
3660 item.iIndent = I_INDENTCALLBACK;
3661 r = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
3664 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3667 item.mask = LVIF_INDENT;
3668 r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM)&item);
3671 ok_sequence(sequences, PARENT_SEQ_INDEX, single_getdispinfo_parent_seq,
3672 "get indent dispinfo", FALSE);
3674 DestroyWindow(hwnd);
3677 static INT CALLBACK DummyCompareEx(LPARAM first, LPARAM second, LPARAM param)
3682 static BOOL is_below_comctl_5(void)
3687 hwnd = create_listview_control(0);
3688 ok(hwnd != NULL, "failed to create a listview window\n");
3689 insert_item(hwnd, 0);
3691 ret = SendMessage(hwnd, LVM_SORTITEMSEX, 0, (LPARAM)&DummyCompareEx);
3693 DestroyWindow(hwnd);
3698 static void test_get_set_view(void)
3704 /* test style->view mapping */
3705 hwnd = create_listview_control(0);
3706 ok(hwnd != NULL, "failed to create a listview window\n");
3708 ret = SendMessage(hwnd, LVM_GETVIEW, 0, 0);
3709 expect(LV_VIEW_DETAILS, ret);
3711 style = GetWindowLongPtr(hwnd, GWL_STYLE);
3713 SetWindowLongPtr(hwnd, GWL_STYLE, style & ~LVS_REPORT);
3714 ret = SendMessage(hwnd, LVM_GETVIEW, 0, 0);
3715 expect(LV_VIEW_ICON, ret);
3717 style = GetWindowLongPtr(hwnd, GWL_STYLE);
3718 SetWindowLongPtr(hwnd, GWL_STYLE, style | LVS_SMALLICON);
3719 ret = SendMessage(hwnd, LVM_GETVIEW, 0, 0);
3720 expect(LV_VIEW_SMALLICON, ret);
3722 style = GetWindowLongPtr(hwnd, GWL_STYLE);
3723 SetWindowLongPtr(hwnd, GWL_STYLE, (style & ~LVS_SMALLICON) | LVS_LIST);
3724 ret = SendMessage(hwnd, LVM_GETVIEW, 0, 0);
3725 expect(LV_VIEW_LIST, ret);
3727 /* switching view doesn't touch window style */
3728 ret = SendMessage(hwnd, LVM_SETVIEW, LV_VIEW_DETAILS, 0);
3730 style = GetWindowLongPtr(hwnd, GWL_STYLE);
3731 ok(style & LVS_LIST, "Expected style to be preserved\n");
3732 ret = SendMessage(hwnd, LVM_SETVIEW, LV_VIEW_ICON, 0);
3734 style = GetWindowLongPtr(hwnd, GWL_STYLE);
3735 ok(style & LVS_LIST, "Expected style to be preserved\n");
3736 ret = SendMessage(hwnd, LVM_SETVIEW, LV_VIEW_SMALLICON, 0);
3738 style = GetWindowLongPtr(hwnd, GWL_STYLE);
3739 ok(style & LVS_LIST, "Expected style to be preserved\n");
3741 DestroyWindow(hwnd);
3744 static void test_canceleditlabel(void)
3746 HWND hwnd, hwndedit;
3750 static CHAR test[] = "test";
3751 static const CHAR test1[] = "test1";
3753 hwnd = create_listview_control(LVS_EDITLABELS);
3754 ok(hwnd != NULL, "failed to create a listview window\n");
3756 insert_item(hwnd, 0);
3758 /* try without edit created */
3759 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3760 ret = SendMessage(hwnd, LVM_CANCELEDITLABEL, 0, 0);
3762 ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
3763 "cancel edit label without edit", FALSE);
3765 /* cancel without data change */
3767 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3768 ok(IsWindow(hwndedit), "Expected edit control to be created\n");
3769 ret = SendMessage(hwnd, LVM_CANCELEDITLABEL, 0, 0);
3771 ok(!IsWindow(hwndedit), "Expected edit control to be destroyed\n");
3773 /* cancel after data change */
3774 memset(&itema, 0, sizeof(itema));
3775 itema.pszText = test;
3776 ret = SendMessage(hwnd, LVM_SETITEMTEXT, 0, (LPARAM)&itema);
3779 hwndedit = (HWND)SendMessage(hwnd, LVM_EDITLABEL, 0, 0);
3780 ok(IsWindow(hwndedit), "Expected edit control to be created\n");
3781 ret = SetWindowText(hwndedit, test1);
3782 ok(ret != 0, "Expected edit text to change\n");
3783 ret = SendMessage(hwnd, LVM_CANCELEDITLABEL, 0, 0);
3785 ok(!IsWindow(hwndedit), "Expected edit control to be destroyed\n");
3786 memset(&itema, 0, sizeof(itema));
3787 itema.pszText = buff;
3788 itema.cchTextMax = sizeof(buff)/sizeof(CHAR);
3789 ret = SendMessage(hwnd, LVM_GETITEMTEXT, 0, (LPARAM)&itema);
3791 ok(strcmp(buff, test1) == 0, "Expected label text not to change\n");
3793 DestroyWindow(hwnd);
3796 static void test_mapidindex(void)
3801 /* LVM_MAPINDEXTOID unsupported with LVS_OWNERDATA */
3802 hwnd = create_listview_control(LVS_OWNERDATA);
3803 ok(hwnd != NULL, "failed to create a listview window\n");
3804 insert_item(hwnd, 0);
3805 ret = SendMessage(hwnd, LVM_MAPINDEXTOID, 0, 0);
3807 DestroyWindow(hwnd);
3809 hwnd = create_listview_control(0);
3810 ok(hwnd != NULL, "failed to create a listview window\n");
3812 /* LVM_MAPINDEXTOID with invalid index */
3813 ret = SendMessage(hwnd, LVM_MAPINDEXTOID, 0, 0);
3816 insert_item(hwnd, 0);
3817 insert_item(hwnd, 1);
3819 ret = SendMessage(hwnd, LVM_MAPINDEXTOID, -1, 0);
3821 ret = SendMessage(hwnd, LVM_MAPINDEXTOID, 2, 0);
3824 ret = SendMessage(hwnd, LVM_MAPINDEXTOID, 0, 0);
3826 ret = SendMessage(hwnd, LVM_MAPINDEXTOID, 1, 0);
3828 /* remove 0 indexed item, id retained */
3829 SendMessage(hwnd, LVM_DELETEITEM, 0, 0);
3830 ret = SendMessage(hwnd, LVM_MAPINDEXTOID, 0, 0);
3832 /* new id starts from previous value */
3833 insert_item(hwnd, 1);
3834 ret = SendMessage(hwnd, LVM_MAPINDEXTOID, 1, 0);
3837 /* get index by id */
3838 ret = SendMessage(hwnd, LVM_MAPIDTOINDEX, -1, 0);
3840 ret = SendMessage(hwnd, LVM_MAPIDTOINDEX, 0, 0);
3842 ret = SendMessage(hwnd, LVM_MAPIDTOINDEX, 1, 0);
3844 ret = SendMessage(hwnd, LVM_MAPIDTOINDEX, 2, 0);
3847 DestroyWindow(hwnd);
3850 static void test_getitemspacing(void)
3859 cx = GetSystemMetrics(SM_CXICONSPACING) - GetSystemMetrics(SM_CXICON);
3860 cy = GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON);
3863 hwnd = create_custom_listview_control(0);
3864 ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
3866 expect(cx, LOWORD(ret));
3867 expect(cy, HIWORD(ret));
3869 /* now try with icons */
3870 himl = ImageList_Create(40, 40, 0, 4, 4);
3871 ok(himl != NULL, "failed to create imagelist\n");
3872 hbmp = CreateBitmap(40, 40, 1, 1, NULL);
3873 ok(hbmp != NULL, "failed to create bitmap\n");
3874 ret = ImageList_Add(himl, hbmp, 0);
3876 ret = SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
3879 itema.mask = LVIF_IMAGE;
3883 ret = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM)&itema);
3885 ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
3887 /* spacing + icon size returned */
3888 expect(cx + 40, LOWORD(ret));
3889 expect(cy + 40, HIWORD(ret));
3891 DestroyWindow(hwnd);
3893 hwnd = create_custom_listview_control(LVS_SMALLICON);
3894 ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
3896 expect(cx, LOWORD(ret));
3897 expect(cy, HIWORD(ret));
3899 DestroyWindow(hwnd);
3901 hwnd = create_custom_listview_control(LVS_REPORT);
3902 ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
3904 expect(cx, LOWORD(ret));
3905 expect(cy, HIWORD(ret));
3907 DestroyWindow(hwnd);
3909 hwnd = create_custom_listview_control(LVS_LIST);
3910 ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
3912 expect(cx, LOWORD(ret));
3913 expect(cy, HIWORD(ret));
3915 DestroyWindow(hwnd);
3918 static void test_getcolumnwidth(void)
3925 /* default column width */
3926 hwnd = create_custom_listview_control(0);
3927 ret = SendMessage(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
3929 style = GetWindowLong(hwnd, GWL_STYLE);
3930 SetWindowLong(hwnd, GWL_STYLE, style | LVS_LIST);
3931 ret = SendMessage(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
3932 todo_wine expect(8, ret);
3933 style = GetWindowLong(hwnd, GWL_STYLE) & ~LVS_LIST;
3934 SetWindowLong(hwnd, GWL_STYLE, style | LVS_REPORT);
3936 ret = SendMessage(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
3938 ret = SendMessage(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
3940 DestroyWindow(hwnd);
3943 static void test_scrollnotify(void)
3948 hwnd = create_listview_control(0);
3950 insert_column(hwnd, 0);
3951 insert_column(hwnd, 1);
3952 insert_item(hwnd, 0);
3954 /* make it scrollable - resize */
3955 ret = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0));
3957 ret = SendMessage(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(100, 0));
3960 /* try with dummy call */
3961 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3962 ret = SendMessage(hwnd, LVM_SCROLL, 0, 0);
3964 ok_sequence(sequences, PARENT_SEQ_INDEX, scroll_parent_seq,
3965 "scroll notify 1", TRUE);
3967 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3968 ret = SendMessage(hwnd, LVM_SCROLL, 1, 0);
3970 ok_sequence(sequences, PARENT_SEQ_INDEX, scroll_parent_seq,
3971 "scroll notify 2", TRUE);
3973 flush_sequences(sequences, NUM_MSG_SEQUENCES);
3974 ret = SendMessage(hwnd, LVM_SCROLL, 1, 1);
3976 ok_sequence(sequences, PARENT_SEQ_INDEX, scroll_parent_seq,
3977 "scroll notify 3", TRUE);
3979 DestroyWindow(hwnd);
3982 static void test_LVS_EX_TRANSPARENTBKGND(void)
3988 hwnd = create_listview_control(0);
3990 ret = SendMessage(hwnd, LVM_SETBKCOLOR, 0, RGB(0, 0, 0));
3993 SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_TRANSPARENTBKGND,
3994 LVS_EX_TRANSPARENTBKGND);
3996 ret = SendMessage(hwnd, LVM_GETBKCOLOR, 0, 0);
3997 if (ret != CLR_NONE)
3999 win_skip("LVS_EX_TRANSPARENTBKGND unsupported\n");
4000 DestroyWindow(hwnd);
4004 /* try to set some back color and check this style bit */
4005 ret = SendMessage(hwnd, LVM_SETBKCOLOR, 0, RGB(0, 0, 0));
4007 ret = SendMessage(hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
4008 ok(!(ret & LVS_EX_TRANSPARENTBKGND), "Expected LVS_EX_TRANSPARENTBKGND to unset\n");
4010 /* now test what this style actually does */
4011 SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_TRANSPARENTBKGND,
4012 LVS_EX_TRANSPARENTBKGND);
4014 hdc = GetWindowDC(hwndparent);
4016 flush_sequences(sequences, NUM_MSG_SEQUENCES);
4017 SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
4018 ok_sequence(sequences, PARENT_SEQ_INDEX, lvs_ex_transparentbkgnd_seq,
4019 "LVS_EX_TRANSPARENTBKGND parent", FALSE);
4021 ReleaseDC(hwndparent, hdc);
4023 DestroyWindow(hwnd);
4026 static void test_ApproximateViewRect(void)
4034 static CHAR test[] = "abracadabra, a very long item label";
4036 cx = GetSystemMetrics(SM_CXICONSPACING) - GetSystemMetrics(SM_CXICON);
4037 cy = GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON);
4039 hwnd = create_custom_listview_control(LVS_ICON);
4040 himl = ImageList_Create(40, 40, 0, 4, 4);
4041 ok(himl != NULL, "failed to create imagelist\n");
4042 hbmp = CreateBitmap(40, 40, 1, 1, NULL);
4043 ok(hbmp != NULL, "failed to create bitmap\n");
4044 ret = ImageList_Add(himl, hbmp, 0);
4046 ret = SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
4049 itema.mask = LVIF_IMAGE;
4053 ret = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM)&itema);
4056 ret = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(75, 75));
4060 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
4064 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 11, MAKELPARAM(100,100));
4065 ok(MAKELONG(77,827)==ret,"Incorrect Approximate rect\n");
4067 ret = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(50, 50));
4068 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 11, MAKELPARAM(100,100));
4069 ok(MAKELONG(102,302)==ret,"Incorrect Approximate rect\n");
4071 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, -1, MAKELPARAM(100,100));
4072 ok(MAKELONG(52,52)==ret,"Incorrect Approximate rect\n");
4074 itema.pszText = test;
4075 ret = SendMessage(hwnd, LVM_SETITEMTEXT, 0, (LPARAM)&itema);
4077 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, -1, MAKELPARAM(100,100));
4078 ok(MAKELONG(52,52)==ret,"Incorrect Approximate rect\n");
4080 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 0, MAKELPARAM(100,100));
4081 ok(MAKELONG(52,2)==ret,"Incorrect Approximate rect\n");
4082 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 1, MAKELPARAM(100,100));
4083 ok(MAKELONG(52,52)==ret,"Incorrect Approximate rect\n");
4084 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 2, MAKELPARAM(100,100));
4085 ok(MAKELONG(102,52)==ret,"Incorrect Approximate rect\n");
4086 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 3, MAKELPARAM(100,100));
4087 ok(MAKELONG(102,102)==ret,"Incorrect Approximate rect\n");
4088 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 4, MAKELPARAM(100,100));
4089 ok(MAKELONG(102,102)==ret,"Incorrect Approximate rect\n");
4090 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 5, MAKELPARAM(100,100));
4091 ok(MAKELONG(102,152)==ret,"Incorrect Approximate rect\n");
4092 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 6, MAKELPARAM(100,100));
4093 ok(MAKELONG(102,152)==ret,"Incorrect Approximate rect\n");
4094 ret = SendMessage(hwnd, LVM_APPROXIMATEVIEWRECT, 7, MAKELPARAM(160,100));
4095 ok(MAKELONG(152,152)==ret,"Incorrect Approximate rect\n");
4097 DestroyWindow(hwnd);
4100 START_TEST(listview)
4103 BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
4105 ULONG_PTR ctx_cookie;
4109 hComctl32 = GetModuleHandleA("comctl32.dll");
4110 pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
4111 if (pInitCommonControlsEx)
4113 INITCOMMONCONTROLSEX iccex;
4114 iccex.dwSize = sizeof(iccex);
4115 iccex.dwICC = ICC_LISTVIEW_CLASSES;
4116 pInitCommonControlsEx(&iccex);
4119 InitCommonControls();
4121 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
4123 hwndparent = create_parent_window(FALSE);
4124 flush_sequences(sequences, NUM_MSG_SEQUENCES);
4126 g_is_below_5 = is_below_comctl_5();
4134 test_icon_spacing();
4137 test_item_position();
4142 test_subitem_rect();
4146 test_nosortheader();
4150 test_getitemposition();
4151 test_columnscreation();
4153 test_notifyformat();
4155 test_getitemspacing();
4156 test_getcolumnwidth();
4157 test_ApproximateViewRect();
4159 if (!load_v6_module(&ctx_cookie, &hCtx))
4161 DestroyWindow(hwndparent);
4165 /* this is a XP SP3 failure workaround */
4166 hwnd = CreateWindowExA(0, WC_LISTVIEW, "foo",
4167 WS_CHILD | WS_BORDER | WS_VISIBLE | LVS_REPORT,
4169 hwndparent, NULL, GetModuleHandleA(NULL), NULL);
4170 if (!IsWindow(hwnd))
4172 win_skip("FIXME: failed to create ListView window.\n");
4173 unload_v6_module(ctx_cookie, hCtx);
4174 DestroyWindow(hwndparent);
4178 DestroyWindow(hwnd);
4180 /* comctl32 version 6 tests start here */
4181 test_get_set_view();
4182 test_canceleditlabel();
4184 test_scrollnotify();
4185 test_LVS_EX_TRANSPARENTBKGND();
4187 unload_v6_module(ctx_cookie, hCtx);
4189 DestroyWindow(hwndparent);