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 COMBINED_SEQ_INDEX 4
36 #define NUM_MSG_SEQUENCES 5
41 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
42 #define expect2(expected1, expected2, got1, got2) ok(expected1 == got1 && expected2 == got2, \
43 "expected (%d,%d), got (%d,%d)\n", expected1, expected2, got1, got2)
45 static const WCHAR testparentclassW
[] =
46 {'L','i','s','t','v','i','e','w',' ','t','e','s','t',' ','p','a','r','e','n','t','W', 0};
48 HWND hwndparent
, hwndparentW
;
49 /* prevents edit box creation, LVN_BEGINLABELEDIT return value */
50 static BOOL blockEdit
;
51 /* return nonzero on NM_HOVER */
52 static BOOL g_block_hover
;
53 /* dumps LVN_ITEMCHANGED message data */
54 static BOOL g_dump_itemchanged
;
55 /* format reported to control:
56 -1 falls to defproc, anything else returned */
58 /* indicates we're running < 5.80 version */
61 static HWND
subclass_editbox(HWND hwndListview
);
63 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
65 static const struct message create_ownerdrawfixed_parent_seq
[] = {
66 { WM_NOTIFYFORMAT
, sent
},
67 { WM_QUERYUISTATE
, sent
|optional
}, /* Win2K and higher */
68 { WM_MEASUREITEM
, sent
},
69 { WM_PARENTNOTIFY
, sent
},
73 static const struct message redraw_listview_seq
[] = {
74 { WM_PAINT
, sent
|id
, 0, 0, LISTVIEW_ID
},
75 { WM_PAINT
, sent
|id
, 0, 0, HEADER_ID
},
76 { WM_NCPAINT
, sent
|id
|defwinproc
, 0, 0, HEADER_ID
},
77 { WM_ERASEBKGND
, sent
|id
|defwinproc
|optional
, 0, 0, HEADER_ID
},
78 { WM_NOTIFY
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
79 { WM_NCPAINT
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
80 { WM_ERASEBKGND
, sent
|id
|defwinproc
|optional
, 0, 0, LISTVIEW_ID
},
84 static const struct message listview_icon_spacing_seq
[] = {
85 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(20, 30) },
86 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(25, 35) },
87 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(-1, -1) },
91 static const struct message listview_color_seq
[] = {
92 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
93 { LVM_GETBKCOLOR
, sent
},
94 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
95 { LVM_GETTEXTCOLOR
, sent
},
96 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
97 { LVM_GETTEXTBKCOLOR
, sent
},
99 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
100 { LVM_GETBKCOLOR
, sent
},
101 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
102 { LVM_GETTEXTCOLOR
, sent
},
103 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
104 { LVM_GETTEXTBKCOLOR
, sent
},
106 { LVM_SETBKCOLOR
, sent
|lparam
, 0, CLR_NONE
},
107 { LVM_GETBKCOLOR
, sent
},
108 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, CLR_NONE
},
109 { LVM_GETTEXTCOLOR
, sent
},
110 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, CLR_NONE
},
111 { LVM_GETTEXTBKCOLOR
, sent
},
113 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
114 { LVM_GETBKCOLOR
, sent
},
115 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
116 { LVM_GETTEXTCOLOR
, sent
},
117 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
118 { LVM_GETTEXTBKCOLOR
, sent
},
122 static const struct message listview_item_count_seq
[] = {
123 { LVM_GETITEMCOUNT
, sent
},
124 { LVM_INSERTITEM
, sent
},
125 { LVM_INSERTITEM
, sent
},
126 { LVM_INSERTITEM
, sent
},
127 { LVM_GETITEMCOUNT
, sent
},
128 { LVM_DELETEITEM
, sent
|wparam
, 2 },
129 { WM_NCPAINT
, sent
|optional
},
130 { WM_ERASEBKGND
, sent
|optional
},
131 { LVM_GETITEMCOUNT
, sent
},
132 { LVM_DELETEALLITEMS
, sent
},
133 { LVM_GETITEMCOUNT
, sent
},
134 { LVM_INSERTITEM
, sent
},
135 { LVM_INSERTITEM
, sent
},
136 { LVM_GETITEMCOUNT
, sent
},
137 { LVM_INSERTITEM
, sent
},
138 { LVM_GETITEMCOUNT
, sent
},
142 static const struct message listview_itempos_seq
[] = {
143 { LVM_INSERTITEM
, sent
},
144 { LVM_INSERTITEM
, sent
},
145 { LVM_INSERTITEM
, sent
},
146 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 1, MAKELPARAM(10,5) },
147 { WM_NCPAINT
, sent
|optional
},
148 { WM_ERASEBKGND
, sent
|optional
},
149 { LVM_GETITEMPOSITION
, sent
|wparam
, 1 },
150 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 2, MAKELPARAM(0,0) },
151 { LVM_GETITEMPOSITION
, sent
|wparam
, 2 },
152 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 0, MAKELPARAM(20,20) },
153 { LVM_GETITEMPOSITION
, sent
|wparam
, 0 },
157 static const struct message listview_ownerdata_switchto_seq
[] = {
158 { WM_STYLECHANGING
, sent
},
159 { WM_STYLECHANGED
, sent
},
163 static const struct message listview_getorderarray_seq
[] = {
164 { LVM_GETCOLUMNORDERARRAY
, sent
|id
|wparam
, 2, 0, LISTVIEW_ID
},
165 { HDM_GETORDERARRAY
, sent
|id
|wparam
, 2, 0, HEADER_ID
},
169 static const struct message empty_seq
[] = {
173 static const struct message forward_erasebkgnd_parent_seq
[] = {
174 { WM_ERASEBKGND
, sent
},
178 static const struct message ownderdata_select_focus_parent_seq
[] = {
179 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
180 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
181 { WM_NOTIFY
, sent
|id
|optional
, 0, 0, LVN_GETDISPINFOA
}, /* version 4.7x */
185 static const struct message ownerdata_setstate_all_parent_seq
[] = {
186 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
190 static const struct message ownerdata_defocus_all_parent_seq
[] = {
191 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
192 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
193 { WM_NOTIFY
, sent
|id
|optional
, 0, 0, LVN_GETDISPINFOA
},
194 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
198 static const struct message ownerdata_deselect_all_parent_seq
[] = {
199 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ODCACHEHINT
},
200 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
204 static const struct message select_all_parent_seq
[] = {
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
},
217 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
218 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
222 static const struct message textcallback_set_again_parent_seq
[] = {
223 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
224 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
228 static const struct message single_getdispinfo_parent_seq
[] = {
229 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
233 static const struct message getitemposition_seq1
[] = {
234 { LVM_GETITEMPOSITION
, sent
|id
, 0, 0, LISTVIEW_ID
},
238 static const struct message getitemposition_seq2
[] = {
239 { LVM_GETITEMPOSITION
, sent
|id
, 0, 0, LISTVIEW_ID
},
240 { HDM_GETITEMRECT
, sent
|id
, 0, 0, HEADER_ID
},
244 static const struct message editbox_create_pos
[] = {
245 /* sequence sent after LVN_BEGINLABELEDIT */
246 /* next two are 4.7x specific */
247 { WM_WINDOWPOSCHANGING
, sent
},
248 { WM_WINDOWPOSCHANGED
, sent
|optional
},
250 { WM_WINDOWPOSCHANGING
, sent
|optional
},
251 { WM_NCCALCSIZE
, sent
},
252 { WM_WINDOWPOSCHANGED
, sent
},
253 { WM_MOVE
, sent
|defwinproc
},
254 { WM_SIZE
, sent
|defwinproc
},
255 /* the rest is todo, skipped in 4.7x */
256 { WM_WINDOWPOSCHANGING
, sent
|optional
},
257 { WM_WINDOWPOSCHANGED
, sent
|optional
},
261 static const struct message scroll_parent_seq
[] = {
262 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_BEGINSCROLL
},
263 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ENDSCROLL
},
267 static const struct message setredraw_seq
[] = {
268 { WM_SETREDRAW
, sent
|id
|wparam
, FALSE
, 0, LISTVIEW_ID
},
272 static const struct message lvs_ex_transparentbkgnd_seq
[] = {
273 { WM_PRINTCLIENT
, sent
|lparam
, 0, PRF_ERASEBKGND
},
277 static const struct message edit_end_nochange
[] = {
278 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ENDLABELEDITA
},
279 { WM_NOTIFY
, sent
|id
, 0, 0, NM_CUSTOMDRAW
}, /* todo */
280 { WM_NOTIFY
, sent
|id
, 0, 0, NM_SETFOCUS
},
284 static const struct message hover_parent
[] = {
285 { WM_GETDLGCODE
, sent
}, /* todo_wine */
286 { WM_NOTIFY
, sent
|id
, 0, 0, NM_HOVER
},
290 static const struct message listview_destroy
[] = {
291 { 0x0090, sent
|optional
}, /* Vista */
292 { WM_PARENTNOTIFY
, sent
},
293 { WM_SHOWWINDOW
, sent
},
294 { WM_WINDOWPOSCHANGING
, sent
},
295 { WM_WINDOWPOSCHANGED
, sent
|optional
},
296 { WM_DESTROY
, sent
},
297 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_DELETEALLITEMS
},
298 { WM_NCDESTROY
, sent
},
302 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
304 static LONG defwndproc_counter
= 0;
308 msg
.message
= message
;
309 msg
.flags
= sent
|wparam
|lparam
;
310 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
313 if (message
== WM_NOTIFY
&& lParam
) msg
.id
= ((NMHDR
*)lParam
)->code
;
315 /* log system messages, except for painting */
316 if (message
< WM_USER
&&
317 message
!= WM_PAINT
&&
318 message
!= WM_ERASEBKGND
&&
319 message
!= WM_NCPAINT
&&
320 message
!= WM_NCHITTEST
&&
321 message
!= WM_GETTEXT
&&
322 message
!= WM_GETICON
&&
323 message
!= WM_DEVICECHANGE
)
325 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
327 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
328 add_message(sequences
, COMBINED_SEQ_INDEX
, &msg
);
330 add_message(sequences
, PARENT_FULL_SEQ_INDEX
, &msg
);
336 switch (((NMHDR
*)lParam
)->code
)
338 case LVN_BEGINLABELEDIT
:
339 /* subclass edit box */
341 subclass_editbox(((NMHDR
*)lParam
)->hwndFrom
);
345 case LVN_ENDLABELEDIT
:
347 /* always accept new item text */
348 NMLVDISPINFO
*di
= (NMLVDISPINFO
*)lParam
;
349 trace("LVN_ENDLABELEDIT: text=%s\n", di
->item
.pszText
);
352 case LVN_BEGINSCROLL
:
355 NMLVSCROLL
*pScroll
= (NMLVSCROLL
*)lParam
;
357 trace("LVN_%sSCROLL: (%d,%d)\n", pScroll
->hdr
.code
== LVN_BEGINSCROLL
?
358 "BEGIN" : "END", pScroll
->dx
, pScroll
->dy
);
361 case LVN_ITEMCHANGED
:
362 if (g_dump_itemchanged
)
364 NMLISTVIEW
*nmlv
= (NMLISTVIEW
*)lParam
;
365 trace("LVN_ITEMCHANGED: item=%d,new=%x,old=%x,changed=%x\n",
366 nmlv
->iItem
, nmlv
->uNewState
, nmlv
->uOldState
, nmlv
->uChanged
);
370 if (g_block_hover
) return 1;
375 case WM_NOTIFYFORMAT
:
377 /* force to return format */
378 if (lParam
== NF_QUERY
&& notifyFormat
!= -1) return notifyFormat
;
383 defwndproc_counter
++;
384 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
385 defwndproc_counter
--;
390 static BOOL
register_parent_wnd_class(BOOL Unicode
)
398 clsW
.lpfnWndProc
= parent_wnd_proc
;
401 clsW
.hInstance
= GetModuleHandleW(NULL
);
403 clsW
.hCursor
= LoadCursorA(0, IDC_ARROW
);
404 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
405 clsW
.lpszMenuName
= NULL
;
406 clsW
.lpszClassName
= testparentclassW
;
411 clsA
.lpfnWndProc
= parent_wnd_proc
;
414 clsA
.hInstance
= GetModuleHandleA(NULL
);
416 clsA
.hCursor
= LoadCursorA(0, IDC_ARROW
);
417 clsA
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
418 clsA
.lpszMenuName
= NULL
;
419 clsA
.lpszClassName
= "Listview test parent class";
422 return Unicode
? RegisterClassW(&clsW
) : RegisterClassA(&clsA
);
425 static HWND
create_parent_window(BOOL Unicode
)
427 static const WCHAR nameW
[] = {'t','e','s','t','p','a','r','e','n','t','n','a','m','e','W'};
430 if (!register_parent_wnd_class(Unicode
))
437 hwnd
= CreateWindowExW(0, testparentclassW
, nameW
,
438 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
439 WS_MAXIMIZEBOX
| WS_VISIBLE
,
441 GetDesktopWindow(), NULL
, GetModuleHandleW(NULL
), NULL
);
443 hwnd
= CreateWindowExA(0, "Listview test parent class",
444 "Listview test parent window",
445 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
446 WS_MAXIMIZEBOX
| WS_VISIBLE
,
448 GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
449 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
453 static LRESULT WINAPI
listview_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
455 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
456 static LONG defwndproc_counter
= 0;
460 trace("listview: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
462 /* some debug output for style changing */
463 if ((message
== WM_STYLECHANGING
||
464 message
== WM_STYLECHANGED
) && lParam
)
466 STYLESTRUCT
*style
= (STYLESTRUCT
*)lParam
;
467 trace("\told style: 0x%08x, new style: 0x%08x\n", style
->styleOld
, style
->styleNew
);
470 msg
.message
= message
;
471 msg
.flags
= sent
|wparam
|lparam
;
472 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
475 msg
.id
= LISTVIEW_ID
;
476 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
477 add_message(sequences
, COMBINED_SEQ_INDEX
, &msg
);
479 defwndproc_counter
++;
480 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
481 defwndproc_counter
--;
485 static HWND
create_listview_control(DWORD style
)
491 GetClientRect(hwndparent
, &rect
);
492 hwnd
= CreateWindowExA(0, WC_LISTVIEW
, "foo",
493 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
494 0, 0, rect
.right
, rect
.bottom
,
495 hwndparent
, NULL
, GetModuleHandleA(NULL
), NULL
);
496 ok(hwnd
!= NULL
, "gle=%d\n", GetLastError());
498 if (!hwnd
) return NULL
;
500 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
501 (LONG_PTR
)listview_subclass_proc
);
502 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
507 /* unicode listview window with specified parent */
508 static HWND
create_listview_controlW(DWORD style
, HWND parent
)
513 static const WCHAR nameW
[] = {'f','o','o',0};
515 GetClientRect(parent
, &rect
);
516 hwnd
= CreateWindowExW(0, WC_LISTVIEWW
, nameW
,
517 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
518 0, 0, rect
.right
, rect
.bottom
,
519 parent
, NULL
, GetModuleHandleW(NULL
), NULL
);
520 ok(hwnd
!= NULL
, "gle=%d\n", GetLastError());
522 if (!hwnd
) return NULL
;
524 oldproc
= (WNDPROC
)SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
,
525 (LONG_PTR
)listview_subclass_proc
);
526 SetWindowLongPtrW(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
531 static LRESULT WINAPI
header_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
533 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
534 static LONG defwndproc_counter
= 0;
538 trace("header: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
540 msg
.message
= message
;
541 msg
.flags
= sent
|wparam
|lparam
;
542 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
546 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
548 defwndproc_counter
++;
549 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
550 defwndproc_counter
--;
554 static HWND
subclass_header(HWND hwndListview
)
559 hwnd
= ListView_GetHeader(hwndListview
);
560 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
561 (LONG_PTR
)header_subclass_proc
);
562 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
567 static LRESULT WINAPI
editbox_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
569 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
570 static LONG defwndproc_counter
= 0;
574 msg
.message
= message
;
575 msg
.flags
= sent
|wparam
|lparam
;
576 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
580 /* all we need is sizing */
581 if (message
== WM_WINDOWPOSCHANGING
||
582 message
== WM_NCCALCSIZE
||
583 message
== WM_WINDOWPOSCHANGED
||
584 message
== WM_MOVE
||
587 add_message(sequences
, EDITBOX_SEQ_INDEX
, &msg
);
590 defwndproc_counter
++;
591 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
592 defwndproc_counter
--;
596 static HWND
subclass_editbox(HWND hwndListview
)
601 hwnd
= (HWND
)SendMessage(hwndListview
, LVM_GETEDITCONTROL
, 0, 0);
602 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
603 (LONG_PTR
)editbox_subclass_proc
);
604 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
609 /* Performs a single LVM_HITTEST test */
610 static void test_lvm_hittest(HWND hwnd
, INT x
, INT y
, INT item
, UINT flags
, UINT broken_flags
,
611 BOOL todo_item
, BOOL todo_flags
, int line
)
620 trace("hittesting pt=(%d,%d)\n", lpht
.pt
.x
, lpht
.pt
.y
);
621 ret
= SendMessage(hwnd
, LVM_HITTEST
, 0, (LPARAM
)&lpht
);
627 ok_(__FILE__
, line
)(ret
== item
, "Expected %d item, got %d\n", item
, ret
);
628 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
629 ok_(__FILE__
, line
)(lpht
.iSubItem
== 10, "Expected subitem not overwrited\n");
634 ok_(__FILE__
, line
)(ret
== item
, "Expected %d item, got %d\n", item
, ret
);
635 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
636 ok_(__FILE__
, line
)(lpht
.iSubItem
== 10, "Expected subitem not overwrited\n");
642 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags %x, got %x\n", flags
, lpht
.flags
);
644 else if (broken_flags
)
645 ok_(__FILE__
, line
)(lpht
.flags
== flags
|| broken(lpht
.flags
== broken_flags
),
646 "Expected flags %x, got %x\n", flags
, lpht
.flags
);
648 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags %x, got %x\n", flags
, lpht
.flags
);
651 /* Performs a single LVM_SUBITEMHITTEST test */
652 static void test_lvm_subitemhittest(HWND hwnd
, INT x
, INT y
, INT item
, INT subitem
, UINT flags
,
653 BOOL todo_item
, BOOL todo_subitem
, BOOL todo_flags
, int line
)
661 trace("subhittesting pt=(%d,%d)\n", lpht
.pt
.x
, lpht
.pt
.y
);
662 ret
= SendMessage(hwnd
, LVM_SUBITEMHITTEST
, 0, (LPARAM
)&lpht
);
668 ok_(__FILE__
, line
)(ret
== item
, "Expected %d item, got %d\n", item
, ret
);
669 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
674 ok_(__FILE__
, line
)(ret
== item
, "Expected %d item, got %d\n", item
, ret
);
675 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
681 ok_(__FILE__
, line
)(lpht
.iSubItem
== subitem
, "Expected subitem %d, got %d\n", subitem
, lpht
.iSubItem
);
684 ok_(__FILE__
, line
)(lpht
.iSubItem
== subitem
, "Expected subitem %d, got %d\n", subitem
, lpht
.iSubItem
);
689 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags %x, got %x\n", flags
, lpht
.flags
);
692 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags %x, got %x\n", flags
, lpht
.flags
);
695 static void test_images(void)
703 static CHAR hello
[] = "hello";
705 himl
= ImageList_Create(40, 40, 0, 4, 4);
706 ok(himl
!= NULL
, "failed to create imagelist\n");
708 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
709 ok(hbmp
!= NULL
, "failed to create bitmap\n");
711 r
= ImageList_Add(himl
, hbmp
, 0);
712 ok(r
== 0, "should be zero\n");
714 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_OWNERDRAWFIXED
,
715 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
716 ok(hwnd
!= NULL
, "failed to create listview window\n");
718 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0,
719 LVS_EX_UNDERLINEHOT
| LVS_EX_FLATSB
| LVS_EX_ONECLICKACTIVATE
);
721 ok(r
== 0, "should return zero\n");
723 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
724 ok(r
== 0, "should return zero\n");
726 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELONG(100,50));
727 /* returns dimensions */
729 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
730 ok(r
== 0, "should be zero items\n");
732 item
.mask
= LVIF_IMAGE
| LVIF_TEXT
;
737 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
738 ok(r
== -1, "should fail\n");
741 item
.pszText
= hello
;
742 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
743 ok(r
== 0, "should not fail\n");
745 memset(&r1
, 0, sizeof r1
);
747 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
) &r1
);
749 r
= SendMessage(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
750 ok(r
== TRUE
, "should not fail\n");
753 item
.pszText
= hello
;
754 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
755 ok(r
== 0, "should not fail\n");
757 memset(&r2
, 0, sizeof r2
);
759 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
) &r2
);
761 ok(!memcmp(&r1
, &r2
, sizeof r1
), "rectangle should be the same\n");
766 static void test_checkboxes(void)
771 static CHAR text
[] = "Text",
775 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT
,
776 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
777 ok(hwnd
!= NULL
, "failed to create listview window\n");
779 /* first without LVS_EX_CHECKBOXES set and an item and check that state is preserved */
780 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
781 item
.stateMask
= 0xffff;
786 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
787 ok(r
== 0, "ret %d\n", r
);
790 item
.mask
= LVIF_STATE
;
791 item
.stateMask
= 0xffff;
792 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
793 ok(item
.state
== 0xfccc, "state %x\n", item
.state
);
795 /* Don't set LVIF_STATE */
796 item
.mask
= LVIF_TEXT
;
797 item
.stateMask
= 0xffff;
802 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
803 ok(r
== 1, "ret %d\n", r
);
806 item
.mask
= LVIF_STATE
;
807 item
.stateMask
= 0xffff;
808 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
809 ok(item
.state
== 0, "state %x\n", item
.state
);
811 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
812 ok(r
== 0, "should return zero\n");
814 /* Having turned on checkboxes, check that all existing items are set to 0x1000 (unchecked) */
816 item
.mask
= LVIF_STATE
;
817 item
.stateMask
= 0xffff;
818 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
819 if (item
.state
!= 0x1ccc)
821 win_skip("LVS_EX_CHECKBOXES style is unavailable. Skipping.\n");
826 /* Now add an item without specifying a state and check that its state goes to 0x1000 */
828 item
.mask
= LVIF_TEXT
;
830 item
.pszText
= text2
;
831 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
832 ok(r
== 2, "ret %d\n", r
);
835 item
.mask
= LVIF_STATE
;
836 item
.stateMask
= 0xffff;
837 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
838 ok(item
.state
== 0x1000, "state %x\n", item
.state
);
840 /* Add a further item this time specifying a state and still its state goes to 0x1000 */
842 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
843 item
.stateMask
= 0xffff;
845 item
.pszText
= text3
;
846 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
847 ok(r
== 3, "ret %d\n", r
);
850 item
.mask
= LVIF_STATE
;
851 item
.stateMask
= 0xffff;
852 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
853 ok(item
.state
== 0x1aaa, "state %x\n", item
.state
);
855 /* Set an item's state to checked */
857 item
.mask
= LVIF_STATE
;
858 item
.stateMask
= 0xf000;
860 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
863 item
.mask
= LVIF_STATE
;
864 item
.stateMask
= 0xffff;
865 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
866 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
868 /* Check that only the bits we asked for are returned,
869 * and that all the others are set to zero
872 item
.mask
= LVIF_STATE
;
873 item
.stateMask
= 0xf000;
875 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
876 ok(item
.state
== 0x2000, "state %x\n", item
.state
);
878 /* Set the style again and check that doesn't change an item's state */
879 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
880 ok(r
== LVS_EX_CHECKBOXES
, "ret %x\n", r
);
883 item
.mask
= LVIF_STATE
;
884 item
.stateMask
= 0xffff;
885 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
886 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
888 /* Unsetting the checkbox extended style doesn't change an item's state */
889 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, 0);
890 ok(r
== LVS_EX_CHECKBOXES
, "ret %x\n", r
);
893 item
.mask
= LVIF_STATE
;
894 item
.stateMask
= 0xffff;
895 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
896 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
898 /* Now setting the style again will change an item's state */
899 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
900 ok(r
== 0, "ret %x\n", r
);
903 item
.mask
= LVIF_STATE
;
904 item
.stateMask
= 0xffff;
905 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
906 ok(item
.state
== 0x1aaa, "state %x\n", item
.state
);
908 /* Toggle checkbox tests (bug 9934) */
909 memset (&item
, 0xcc, sizeof(item
));
910 item
.mask
= LVIF_STATE
;
913 item
.state
= LVIS_FOCUSED
;
914 item
.stateMask
= LVIS_FOCUSED
;
915 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
) &item
);
919 item
.mask
= LVIF_STATE
;
920 item
.stateMask
= 0xffff;
921 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
922 ok(item
.state
== 0x1aab, "state %x\n", item
.state
);
924 r
= SendMessage(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
926 r
= SendMessage(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
930 item
.mask
= LVIF_STATE
;
931 item
.stateMask
= 0xffff;
932 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
933 ok(item
.state
== 0x2aab, "state %x\n", item
.state
);
935 r
= SendMessage(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
937 r
= SendMessage(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
941 item
.mask
= LVIF_STATE
;
942 item
.stateMask
= 0xffff;
943 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
944 ok(item
.state
== 0x1aab, "state %x\n", item
.state
);
949 static void insert_column(HWND hwnd
, int idx
)
954 memset(&column
, 0xcc, sizeof(column
));
955 column
.mask
= LVCF_SUBITEM
;
956 column
.iSubItem
= idx
;
958 rc
= ListView_InsertColumn(hwnd
, idx
, &column
);
962 static void insert_item(HWND hwnd
, int idx
)
964 static CHAR text
[] = "foo";
969 memset(&item
, 0xcc, sizeof (item
));
970 item
.mask
= LVIF_TEXT
;
975 rc
= ListView_InsertItem(hwnd
, &item
);
979 static void test_items(void)
981 const LPARAM lparamTest
= 0x42;
985 static CHAR text
[] = "Text";
987 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT
,
988 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
989 ok(hwnd
!= NULL
, "failed to create listview window\n");
992 * Test setting/getting item params
995 /* Set up two columns */
996 insert_column(hwnd
, 0);
997 insert_column(hwnd
, 1);
999 /* LVIS_SELECTED with zero stateMask */
1001 memset (&item
, 0, sizeof (item
));
1002 item
.mask
= LVIF_STATE
;
1003 item
.state
= LVIS_SELECTED
;
1007 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1008 ok(r
== 0, "ret %d\n", r
);
1010 memset (&item
, 0xcc, sizeof (item
));
1011 item
.mask
= LVIF_STATE
;
1012 item
.stateMask
= LVIS_SELECTED
;
1016 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1017 ok(r
!= 0, "ret %d\n", r
);
1018 ok(item
.state
& LVIS_SELECTED
, "Expected LVIS_SELECTED\n");
1019 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
1021 /* LVIS_SELECTED with zero stateMask */
1023 memset (&item
, 0, sizeof (item
));
1024 item
.mask
= LVIF_STATE
;
1025 item
.state
= LVIS_FOCUSED
;
1029 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1030 ok(r
== 0, "ret %d\n", r
);
1032 memset (&item
, 0xcc, sizeof (item
));
1033 item
.mask
= LVIF_STATE
;
1034 item
.stateMask
= LVIS_FOCUSED
;
1038 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1039 ok(r
!= 0, "ret %d\n", r
);
1040 ok(item
.state
& LVIS_FOCUSED
, "Expected LVIS_FOCUSED\n");
1041 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
1043 /* LVIS_CUT with LVIS_FOCUSED stateMask */
1045 memset (&item
, 0, sizeof (item
));
1046 item
.mask
= LVIF_STATE
;
1047 item
.state
= LVIS_CUT
;
1048 item
.stateMask
= LVIS_FOCUSED
;
1051 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1052 ok(r
== 0, "ret %d\n", r
);
1054 memset (&item
, 0xcc, sizeof (item
));
1055 item
.mask
= LVIF_STATE
;
1056 item
.stateMask
= LVIS_CUT
;
1060 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1061 ok(r
!= 0, "ret %d\n", r
);
1062 ok(item
.state
& LVIS_CUT
, "Expected LVIS_CUT\n");
1063 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
1065 /* Insert an item with just a param */
1066 memset (&item
, 0xcc, sizeof (item
));
1067 item
.mask
= LVIF_PARAM
;
1070 item
.lParam
= lparamTest
;
1071 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1072 ok(r
== 0, "ret %d\n", r
);
1074 /* Test getting of the param */
1075 memset (&item
, 0xcc, sizeof (item
));
1076 item
.mask
= LVIF_PARAM
;
1079 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1080 ok(r
!= 0, "ret %d\n", r
);
1081 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1083 /* Set up a subitem */
1084 memset (&item
, 0xcc, sizeof (item
));
1085 item
.mask
= LVIF_TEXT
;
1088 item
.pszText
= text
;
1089 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1090 ok(r
!= 0, "ret %d\n", r
);
1092 /* Query param from subitem: returns main item param */
1093 memset (&item
, 0xcc, sizeof (item
));
1094 item
.mask
= LVIF_PARAM
;
1097 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1098 ok(r
!= 0, "ret %d\n", r
);
1099 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1101 /* Set up param on first subitem: no effect */
1102 memset (&item
, 0xcc, sizeof (item
));
1103 item
.mask
= LVIF_PARAM
;
1106 item
.lParam
= lparamTest
+1;
1107 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1108 ok(r
== 0, "ret %d\n", r
);
1110 /* Query param from subitem again: should still return main item param */
1111 memset (&item
, 0xcc, sizeof (item
));
1112 item
.mask
= LVIF_PARAM
;
1115 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1116 ok(r
!= 0, "ret %d\n", r
);
1117 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1119 /**** Some tests of state highlighting ****/
1120 memset (&item
, 0xcc, sizeof (item
));
1121 item
.mask
= LVIF_STATE
;
1124 item
.state
= LVIS_SELECTED
;
1125 item
.stateMask
= LVIS_SELECTED
| LVIS_DROPHILITED
;
1126 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
) &item
);
1127 ok(r
!= 0, "ret %d\n", r
);
1129 item
.state
= LVIS_DROPHILITED
;
1130 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
) &item
);
1131 ok(r
!= 0, "ret %d\n", r
);
1133 memset (&item
, 0xcc, sizeof (item
));
1134 item
.mask
= LVIF_STATE
;
1137 item
.stateMask
= -1;
1138 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
1139 ok(r
!= 0, "ret %d\n", r
);
1140 ok(item
.state
== LVIS_SELECTED
, "got state %x, expected %x\n", item
.state
, LVIS_SELECTED
);
1142 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
1143 ok(r
!= 0, "ret %d\n", r
);
1144 todo_wine
ok(item
.state
== LVIS_DROPHILITED
, "got state %x, expected %x\n", item
.state
, LVIS_DROPHILITED
);
1146 /* some notnull but meaningless masks */
1147 memset (&item
, 0, sizeof(item
));
1148 item
.mask
= LVIF_NORECOMPUTE
;
1151 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1152 ok(r
!= 0, "ret %d\n", r
);
1153 memset (&item
, 0, sizeof(item
));
1154 item
.mask
= LVIF_DI_SETITEM
;
1157 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1158 ok(r
!= 0, "ret %d\n", r
);
1160 /* set text to callback value already having it */
1161 r
= SendMessage(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
1163 memset (&item
, 0, sizeof (item
));
1164 item
.mask
= LVIF_TEXT
;
1165 item
.pszText
= LPSTR_TEXTCALLBACK
;
1167 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1168 ok(r
== 0, "ret %d\n", r
);
1169 memset (&item
, 0, sizeof (item
));
1171 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1173 item
.pszText
= LPSTR_TEXTCALLBACK
;
1174 r
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0 , (LPARAM
) &item
);
1177 ok_sequence(sequences
, PARENT_SEQ_INDEX
, textcallback_set_again_parent_seq
,
1178 "check callback text comparison rule", FALSE
);
1180 DestroyWindow(hwnd
);
1183 static void test_columns(void)
1185 HWND hwnd
, hwndheader
;
1190 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT
,
1191 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
1192 ok(hwnd
!= NULL
, "failed to create listview window\n");
1194 /* Add a column with no mask */
1195 memset(&column
, 0xcc, sizeof(column
));
1197 rc
= ListView_InsertColumn(hwnd
, 0, &column
);
1198 ok(rc
==0, "Inserting column with no mask failed with %d\n", rc
);
1200 /* Check its width */
1201 rc
= ListView_GetColumnWidth(hwnd
, 0);
1203 broken(rc
==0), /* win9x */
1204 "Inserting column with no mask failed to set width to 10 with %d\n", rc
);
1206 DestroyWindow(hwnd
);
1208 /* LVM_GETCOLUMNORDERARRAY */
1209 hwnd
= create_listview_control(LVS_REPORT
);
1210 hwndheader
= subclass_header(hwnd
);
1212 memset(&column
, 0, sizeof(column
));
1213 column
.mask
= LVCF_WIDTH
;
1215 rc
= ListView_InsertColumn(hwnd
, 0, &column
);
1216 ok(rc
== 0, "Inserting column failed with %d\n", rc
);
1219 rc
= ListView_InsertColumn(hwnd
, 1, &column
);
1220 ok(rc
== 1, "Inserting column failed with %d\n", rc
);
1222 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1224 rc
= SendMessage(hwnd
, LVM_GETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
1225 ok(rc
!= 0, "Expected LVM_GETCOLUMNORDERARRAY to succeed\n");
1226 ok(order
[0] == 0, "Expected order 0, got %d\n", order
[0]);
1227 ok(order
[1] == 1, "Expected order 1, got %d\n", order
[1]);
1229 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_getorderarray_seq
, "get order array", FALSE
);
1231 DestroyWindow(hwnd
);
1233 /* test setting imagelist between WM_NCCREATE and WM_CREATE */
1234 static WNDPROC listviewWndProc
;
1235 static HIMAGELIST test_create_imagelist
;
1237 static LRESULT CALLBACK
create_test_wndproc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1241 if (uMsg
== WM_CREATE
)
1243 LPCREATESTRUCT lpcs
= (LPCREATESTRUCT
)lParam
;
1244 lpcs
->style
|= LVS_REPORT
;
1246 ret
= CallWindowProc(listviewWndProc
, hwnd
, uMsg
, wParam
, lParam
);
1247 if (uMsg
== WM_CREATE
) SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)test_create_imagelist
);
1251 static void test_create(void)
1262 cls
.cbSize
= sizeof(WNDCLASSEX
);
1263 ok(GetClassInfoEx(GetModuleHandle(NULL
), "SysListView32", &cls
), "GetClassInfoEx failed\n");
1264 listviewWndProc
= cls
.lpfnWndProc
;
1265 cls
.lpfnWndProc
= create_test_wndproc
;
1266 cls
.lpszClassName
= "MyListView32";
1267 ok(RegisterClassEx(&cls
), "RegisterClassEx failed\n");
1269 test_create_imagelist
= ImageList_Create(16, 16, 0, 5, 10);
1270 hList
= CreateWindow("MyListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
, GetModuleHandle(NULL
), 0);
1271 ok((HIMAGELIST
)SendMessage(hList
, LVM_GETIMAGELIST
, 0, 0) == test_create_imagelist
, "Image list not obtained\n");
1272 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1274 if (!IsWindow(hHeader
))
1277 win_skip("LVM_GETHEADER not implemented. Skipping.\n");
1278 DestroyWindow(hList
);
1282 ok(IsWindow(hHeader
) && IsWindowVisible(hHeader
), "Listview not in report mode\n");
1283 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1284 DestroyWindow(hList
);
1286 /* header isn't created on LVS_ICON and LVS_LIST styles */
1287 hList
= CreateWindow("SysListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
,
1288 GetModuleHandle(NULL
), 0);
1289 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1290 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1291 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1293 memset(&col
, 0, sizeof(LVCOLUMNA
));
1294 col
.mask
= LVCF_WIDTH
;
1296 r
= SendMessage(hList
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
1297 ok(r
== 0, "Expected 0 column's inserted\n");
1298 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1299 ok(IsWindow(hHeader
), "Header should be created\n");
1300 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1301 style
= GetWindowLong(hHeader
, GWL_STYLE
);
1302 ok(!(style
& HDS_HIDDEN
), "Not expected HDS_HIDDEN\n");
1303 DestroyWindow(hList
);
1305 hList
= CreateWindow("SysListView32", "Test", WS_VISIBLE
|LVS_LIST
, 0, 0, 100, 100, NULL
, NULL
,
1306 GetModuleHandle(NULL
), 0);
1307 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1308 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1309 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1311 memset(&col
, 0, sizeof(LVCOLUMNA
));
1312 col
.mask
= LVCF_WIDTH
;
1314 r
= SendMessage(hList
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
1315 ok(r
== 0, "Expected 0 column's inserted\n");
1316 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1317 ok(IsWindow(hHeader
), "Header should be created\n");
1318 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1319 DestroyWindow(hList
);
1321 /* try to switch LVS_ICON -> LVS_REPORT and back LVS_ICON -> LVS_REPORT */
1322 hList
= CreateWindow("SysListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
,
1323 GetModuleHandle(NULL
), 0);
1324 ret
= SetWindowLongPtr(hList
, GWL_STYLE
, GetWindowLongPtr(hList
, GWL_STYLE
) | LVS_REPORT
);
1325 ok(ret
& WS_VISIBLE
, "Style wrong, should have WS_VISIBLE\n");
1326 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1327 ok(IsWindow(hHeader
), "Header should be created\n");
1328 ret
= SetWindowLongPtr(hList
, GWL_STYLE
, GetWindowLong(hList
, GWL_STYLE
) & ~LVS_REPORT
);
1329 ok((ret
& WS_VISIBLE
) && (ret
& LVS_REPORT
), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1330 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1331 ok(IsWindow(hHeader
), "Header should be created\n");
1332 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1333 DestroyWindow(hList
);
1335 /* try to switch LVS_LIST -> LVS_REPORT and back LVS_LIST -> LVS_REPORT */
1336 hList
= CreateWindow("SysListView32", "Test", WS_VISIBLE
|LVS_LIST
, 0, 0, 100, 100, NULL
, NULL
,
1337 GetModuleHandle(NULL
), 0);
1338 ret
= SetWindowLongPtr(hList
, GWL_STYLE
,
1339 (GetWindowLongPtr(hList
, GWL_STYLE
) & ~LVS_LIST
) | LVS_REPORT
);
1340 ok(((ret
& WS_VISIBLE
) && (ret
& LVS_LIST
)), "Style wrong, should have WS_VISIBLE|LVS_LIST\n");
1341 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1342 ok(IsWindow(hHeader
), "Header should be created\n");
1343 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1344 ret
= SetWindowLongPtr(hList
, GWL_STYLE
,
1345 (GetWindowLongPtr(hList
, GWL_STYLE
) & ~LVS_REPORT
) | LVS_LIST
);
1346 ok(((ret
& WS_VISIBLE
) && (ret
& LVS_REPORT
)), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1347 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1348 ok(IsWindow(hHeader
), "Header should be created\n");
1349 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1350 DestroyWindow(hList
);
1352 /* LVS_REPORT without WS_VISIBLE */
1353 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1354 GetModuleHandle(NULL
), 0);
1355 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1356 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1357 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1359 memset(&col
, 0, sizeof(LVCOLUMNA
));
1360 col
.mask
= LVCF_WIDTH
;
1362 r
= SendMessage(hList
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
1363 ok(r
== 0, "Expected 0 column's inserted\n");
1364 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1365 ok(IsWindow(hHeader
), "Header should be created\n");
1366 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1367 DestroyWindow(hList
);
1369 /* LVS_REPORT without WS_VISIBLE, try to show it */
1370 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1371 GetModuleHandle(NULL
), 0);
1372 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1373 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1374 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1375 ShowWindow(hList
, SW_SHOW
);
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 DestroyWindow(hList
);
1381 /* LVS_REPORT with LVS_NOCOLUMNHEADER */
1382 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
|LVS_NOCOLUMNHEADER
|WS_VISIBLE
,
1383 0, 0, 100, 100, NULL
, NULL
, GetModuleHandle(NULL
), 0);
1384 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1385 ok(IsWindow(hHeader
), "Header should be created\n");
1386 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1387 /* HDS_DRAGDROP set by default */
1388 ok(GetWindowLongPtr(hHeader
, GWL_STYLE
) & HDS_DRAGDROP
, "Expected header to have HDS_DRAGDROP\n");
1389 DestroyWindow(hList
);
1391 /* setting LVS_EX_HEADERDRAGDROP creates header */
1392 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1393 GetModuleHandle(NULL
), 0);
1394 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1395 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1396 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1397 SendMessage(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_HEADERDRAGDROP
);
1398 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1399 ok(IsWindow(hHeader
) ||
1400 broken(!IsWindow(hHeader
)), /* 4.7x common controls */
1401 "Header should be created\n");
1402 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1403 DestroyWindow(hList
);
1405 /* not report style accepts LVS_EX_HEADERDRAGDROP too */
1406 hList
= create_listview_control(LVS_ICON
);
1407 SendMessage(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_HEADERDRAGDROP
);
1408 r
= SendMessage(hList
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
1409 ok(r
& LVS_EX_HEADERDRAGDROP
, "Expected LVS_EX_HEADERDRAGDROP to be set\n");
1410 DestroyWindow(hList
);
1412 /* requesting header info with LVM_GETSUBITEMRECT doesn't create it */
1413 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1414 GetModuleHandle(NULL
), 0);
1415 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1416 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1418 rect
.left
= LVIR_BOUNDS
;
1420 rect
.right
= rect
.bottom
= -10;
1421 r
= SendMessage(hList
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
1422 ok(r
!= 0, "Expected not-null LRESULT\n");
1424 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1425 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1426 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1428 DestroyWindow(hList
);
1430 /* WM_MEASUREITEM should be sent when created with LVS_OWNERDRAWFIXED */
1431 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1432 hList
= create_listview_control(LVS_OWNERDRAWFIXED
| LVS_REPORT
);
1433 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_ownerdrawfixed_parent_seq
,
1434 "created with LVS_OWNERDRAWFIXED|LVS_REPORT - parent seq", FALSE
);
1435 DestroyWindow(hList
);
1438 static void test_redraw(void)
1440 HWND hwnd
, hwndheader
;
1445 hwnd
= create_listview_control(LVS_REPORT
);
1446 hwndheader
= subclass_header(hwnd
);
1448 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1450 trace("invalidate & update\n");
1451 InvalidateRect(hwnd
, NULL
, TRUE
);
1453 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, redraw_listview_seq
, "redraw listview", FALSE
);
1455 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1457 /* forward WM_ERASEBKGND to parent on CLR_NONE background color */
1458 /* 1. Without backbuffer */
1459 res
= ListView_SetBkColor(hwnd
, CLR_NONE
);
1462 hdc
= GetWindowDC(hwndparent
);
1464 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1465 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1466 ok(r
!= 0, "Expected not zero result\n");
1467 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, forward_erasebkgnd_parent_seq
,
1468 "forward WM_ERASEBKGND on CLR_NONE", FALSE
);
1470 res
= ListView_SetBkColor(hwnd
, CLR_DEFAULT
);
1473 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1474 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1475 ok(r
!= 0, "Expected not zero result\n");
1476 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, empty_seq
,
1477 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE
);
1479 /* 2. With backbuffer */
1480 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_DOUBLEBUFFER
,
1481 LVS_EX_DOUBLEBUFFER
);
1482 res
= ListView_SetBkColor(hwnd
, CLR_NONE
);
1485 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1486 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1487 ok(r
!= 0, "Expected not zero result\n");
1488 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, forward_erasebkgnd_parent_seq
,
1489 "forward WM_ERASEBKGND on CLR_NONE", FALSE
);
1491 res
= ListView_SetBkColor(hwnd
, CLR_DEFAULT
);
1494 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1495 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1496 todo_wine
ok(r
!= 0, "Expected not zero result\n");
1497 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, empty_seq
,
1498 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE
);
1500 ReleaseDC(hwndparent
, hdc
);
1502 DestroyWindow(hwnd
);
1505 static LRESULT WINAPI
cd_wndproc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
1507 COLORREF clr
, c0ffee
= RGB(0xc0, 0xff, 0xee);
1509 if(msg
== WM_NOTIFY
) {
1510 NMHDR
*nmhdr
= (PVOID
)lp
;
1511 if(nmhdr
->code
== NM_CUSTOMDRAW
) {
1512 NMLVCUSTOMDRAW
*nmlvcd
= (PVOID
)nmhdr
;
1513 trace("NMCUSTOMDRAW (0x%.8x)\n", nmlvcd
->nmcd
.dwDrawStage
);
1514 switch(nmlvcd
->nmcd
.dwDrawStage
) {
1516 SetBkColor(nmlvcd
->nmcd
.hdc
, c0ffee
);
1517 return CDRF_NOTIFYITEMDRAW
;
1518 case CDDS_ITEMPREPAINT
:
1519 nmlvcd
->clrTextBk
= CLR_DEFAULT
;
1520 return CDRF_NOTIFYSUBITEMDRAW
;
1521 case CDDS_ITEMPREPAINT
| CDDS_SUBITEM
:
1522 clr
= GetBkColor(nmlvcd
->nmcd
.hdc
);
1523 todo_wine
ok(clr
== c0ffee
, "clr=%.8x\n", clr
);
1524 return CDRF_NOTIFYPOSTPAINT
;
1525 case CDDS_ITEMPOSTPAINT
| CDDS_SUBITEM
:
1526 clr
= GetBkColor(nmlvcd
->nmcd
.hdc
);
1527 todo_wine
ok(clr
== c0ffee
, "clr=%.8x\n", clr
);
1528 return CDRF_DODEFAULT
;
1530 return CDRF_DODEFAULT
;
1534 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
1537 static void test_customdraw(void)
1542 hwnd
= create_listview_control(LVS_REPORT
);
1544 insert_column(hwnd
, 0);
1545 insert_column(hwnd
, 1);
1546 insert_item(hwnd
, 0);
1548 oldwndproc
= (WNDPROC
)SetWindowLongPtr(hwndparent
, GWLP_WNDPROC
,
1549 (LONG_PTR
)cd_wndproc
);
1551 InvalidateRect(hwnd
, NULL
, TRUE
);
1554 SetWindowLongPtr(hwndparent
, GWLP_WNDPROC
, (LONG_PTR
)oldwndproc
);
1556 DestroyWindow(hwnd
);
1559 static void test_icon_spacing(void)
1561 /* LVM_SETICONSPACING */
1562 /* note: LVM_SETICONSPACING returns the previous icon spacing if successful */
1568 hwnd
= create_listview_control(LVS_ICON
);
1569 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1571 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, (WPARAM
)hwndparent
, NF_REQUERY
);
1572 expect(NFR_ANSI
, r
);
1574 /* reset the icon spacing to defaults */
1575 SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1, -1));
1577 /* now we can request what the defaults are */
1578 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1, -1));
1582 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1584 trace("test icon spacing\n");
1586 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(20, 30));
1587 ok(r
== MAKELONG(w
, h
) ||
1588 broken(r
== MAKELONG(w
, w
)), /* win98 */
1589 "Expected %d, got %d\n", MAKELONG(w
, h
), r
);
1591 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(25, 35));
1595 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
1596 DestroyWindow(hwnd
);
1599 expect(MAKELONG(20,30), r
);
1601 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1,-1));
1602 expect(MAKELONG(25,35), r
);
1604 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_icon_spacing_seq
, "test icon spacing seq", FALSE
);
1606 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1607 DestroyWindow(hwnd
);
1610 static void test_color(void)
1612 /* SETBKCOLOR/GETBKCOLOR, SETTEXTCOLOR/GETTEXTCOLOR, SETTEXTBKCOLOR/GETTEXTBKCOLOR */
1619 COLORREF colors
[4] = {RGB(0,0,0), RGB(100,50,200), CLR_NONE
, RGB(255,255,255)};
1621 hwnd
= create_listview_control(LVS_REPORT
);
1622 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1624 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1626 trace("test color seq\n");
1627 for (i
= 0; i
< 4; i
++)
1631 r
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, color
);
1633 r
= SendMessage(hwnd
, LVM_GETBKCOLOR
, 0, color
);
1636 r
= SendMessage(hwnd
, LVM_SETTEXTCOLOR
, 0, color
);
1638 r
= SendMessage(hwnd
, LVM_GETTEXTCOLOR
, 0, color
);
1641 r
= SendMessage(hwnd
, LVM_SETTEXTBKCOLOR
, 0, color
);
1643 r
= SendMessage(hwnd
, LVM_GETTEXTBKCOLOR
, 0, color
);
1647 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_color_seq
, "test color seq", FALSE
);
1649 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1650 DestroyWindow(hwnd
);
1653 static void test_item_count(void)
1655 /* LVM_INSERTITEM, LVM_DELETEITEM, LVM_DELETEALLITEMS, LVM_GETITEMCOUNT */
1668 static CHAR item0text
[] = "item0";
1669 static CHAR item1text
[] = "item1";
1670 static CHAR item2text
[] = "item2";
1672 hwnd
= create_listview_control(LVS_REPORT
);
1673 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1675 /* resize in dpiaware manner to fit all 3 items added */
1677 hOldFont
= SelectObject(hdc
, GetStockObject(SYSTEM_FONT
));
1678 GetTextMetricsA(hdc
, &tm
);
1679 /* 2 extra pixels for bounds and header border */
1680 height
= tm
.tmHeight
+ 2;
1681 SelectObject(hdc
, hOldFont
);
1684 GetWindowRect(hwnd
, &rect
);
1685 /* 3 items + 1 header + 1 to be sure */
1686 MoveWindow(hwnd
, 0, 0, rect
.right
- rect
.left
, 5 * height
, FALSE
);
1688 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1690 trace("test item count\n");
1692 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1696 item0
.mask
= LVIF_TEXT
;
1699 item0
.pszText
= item0text
;
1700 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item0
);
1703 /* [item0, item1] */
1704 item1
.mask
= LVIF_TEXT
;
1707 item1
.pszText
= item1text
;
1708 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item1
);
1711 /* [item0, item1, item2] */
1712 item2
.mask
= LVIF_TEXT
;
1715 item2
.pszText
= item2text
;
1716 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item2
);
1719 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1722 /* [item0, item1] */
1723 r
= SendMessage(hwnd
, LVM_DELETEITEM
, 2, 0);
1726 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1730 r
= SendMessage(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
1733 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1737 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item1
);
1740 /* [item0, item1] */
1741 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item1
);
1744 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1747 /* [item0, item1, item2] */
1748 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item2
);
1751 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1754 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_item_count_seq
, "test item count seq", FALSE
);
1756 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1757 DestroyWindow(hwnd
);
1760 static void test_item_position(void)
1762 /* LVM_SETITEMPOSITION/LVM_GETITEMPOSITION */
1771 static CHAR item0text
[] = "item0";
1772 static CHAR item1text
[] = "item1";
1773 static CHAR item2text
[] = "item2";
1775 hwnd
= create_listview_control(LVS_ICON
);
1776 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1778 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1780 trace("test item position\n");
1783 item0
.mask
= LVIF_TEXT
;
1786 item0
.pszText
= item0text
;
1787 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item0
);
1790 /* [item0, item1] */
1791 item1
.mask
= LVIF_TEXT
;
1794 item1
.pszText
= item1text
;
1795 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item1
);
1798 /* [item0, item1, item2] */
1799 item2
.mask
= LVIF_TEXT
;
1802 item2
.pszText
= item2text
;
1803 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item2
);
1806 r
= SendMessage(hwnd
, LVM_SETITEMPOSITION
, 1, MAKELPARAM(10,5));
1808 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 1, (LPARAM
) &position
);
1810 expect2(10, 5, position
.x
, position
.y
);
1812 r
= SendMessage(hwnd
, LVM_SETITEMPOSITION
, 2, MAKELPARAM(0,0));
1814 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 2, (LPARAM
) &position
);
1816 expect2(0, 0, position
.x
, position
.y
);
1818 r
= SendMessage(hwnd
, LVM_SETITEMPOSITION
, 0, MAKELPARAM(20,20));
1820 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
) &position
);
1822 expect2(20, 20, position
.x
, position
.y
);
1824 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_itempos_seq
, "test item position seq", TRUE
);
1826 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1827 DestroyWindow(hwnd
);
1830 static void test_getorigin(void)
1838 position
.x
= position
.y
= 0;
1840 hwnd
= create_listview_control(LVS_ICON
);
1841 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1842 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1843 trace("test get origin results\n");
1844 r
= SendMessage(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
1846 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1847 DestroyWindow(hwnd
);
1849 hwnd
= create_listview_control(LVS_SMALLICON
);
1850 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1851 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1852 trace("test get origin results\n");
1853 r
= SendMessage(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
1855 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1856 DestroyWindow(hwnd
);
1858 hwnd
= create_listview_control(LVS_LIST
);
1859 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1860 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1861 trace("test get origin results\n");
1862 r
= SendMessage(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
1864 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1865 DestroyWindow(hwnd
);
1867 hwnd
= create_listview_control(LVS_REPORT
);
1868 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1869 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1870 trace("test get origin results\n");
1871 r
= SendMessage(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
1873 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1874 DestroyWindow(hwnd
);
1878 static void test_multiselect(void)
1880 typedef struct t_select_task
1891 int i
,j
,item_count
,selected_count
;
1892 static const int items
=5;
1898 static struct t_select_task task_list
[] = {
1899 { "using VK_DOWN", 0, VK_DOWN
, -1, -1 },
1900 { "using VK_UP", -1, VK_UP
, -1, -1 },
1901 { "using VK_END", 0, VK_END
, 1, -1 },
1902 { "using VK_HOME", -1, VK_HOME
, 1, -1 }
1906 hwnd
= create_listview_control(LVS_REPORT
);
1908 for (i
=0;i
<items
;i
++) {
1909 insert_item(hwnd
, 0);
1912 item_count
= (int)SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1914 expect(items
,item_count
);
1917 task
= task_list
[i
];
1919 /* deselect all items */
1920 ListView_SetItemState(hwnd
, -1, 0, LVIS_SELECTED
);
1921 SendMessage(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
1923 /* set initial position */
1924 SendMessage(hwnd
, LVM_SETSELECTIONMARK
, 0, (task
.initPos
== -1 ? item_count
-1 : task
.initPos
));
1925 ListView_SetItemState(hwnd
,(task
.initPos
== -1 ? item_count
-1 : task
.initPos
),LVIS_SELECTED
,LVIS_SELECTED
);
1927 selected_count
= (int)SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
1929 ok(selected_count
== 1, "There should be only one selected item at the beginning (is %d)\n",selected_count
);
1931 /* Set SHIFT key pressed */
1932 GetKeyboardState(kstate
);
1933 kstate
[VK_SHIFT
]=0x80;
1934 SetKeyboardState(kstate
);
1936 for (j
=1;j
<=(task
.count
== -1 ? item_count
: task
.count
);j
++) {
1937 r
= SendMessage(hwnd
, WM_KEYDOWN
, task
.loopVK
, 0);
1939 r
= SendMessage(hwnd
, WM_KEYUP
, task
.loopVK
, 0);
1943 selected_count
= (int)SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
1945 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
);
1947 /* Set SHIFT key released */
1948 GetKeyboardState(kstate
);
1949 kstate
[VK_SHIFT
]=0x00;
1950 SetKeyboardState(kstate
);
1952 DestroyWindow(hwnd
);
1954 /* make multiple selection, then switch to LVS_SINGLESEL */
1955 hwnd
= create_listview_control(LVS_REPORT
);
1956 for (i
=0;i
<items
;i
++) {
1957 insert_item(hwnd
, 0);
1959 item_count
= (int)SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1960 expect(items
,item_count
);
1962 /* try with NULL pointer */
1963 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, 0);
1966 /* select all, check notifications */
1967 ListView_SetItemState(hwnd
, -1, 0, LVIS_SELECTED
);
1969 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1971 item
.stateMask
= LVIS_SELECTED
;
1972 item
.state
= LVIS_SELECTED
;
1973 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
1976 ok_sequence(sequences
, PARENT_SEQ_INDEX
, select_all_parent_seq
,
1977 "select all notification", FALSE
);
1979 /* deselect all items */
1980 ListView_SetItemState(hwnd
, -1, 0, LVIS_SELECTED
);
1981 SendMessage(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
1983 ListView_SetItemState(hwnd
, i
, LVIS_SELECTED
, LVIS_SELECTED
);
1986 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
1988 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
1991 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
1992 ok(!(style
& LVS_SINGLESEL
), "LVS_SINGLESEL isn't expected\n");
1993 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SINGLESEL
);
1994 /* check that style is accepted */
1995 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
1996 ok(style
& LVS_SINGLESEL
, "LVS_SINGLESEL expected\n");
1999 r
= ListView_GetItemState(hwnd
, i
, LVIS_SELECTED
);
2000 ok(r
& LVIS_SELECTED
, "Expected item %d to be selected\n", i
);
2002 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2004 SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2007 /* select one more */
2008 ListView_SetItemState(hwnd
, 3, LVIS_SELECTED
, LVIS_SELECTED
);
2011 r
= ListView_GetItemState(hwnd
, i
, LVIS_SELECTED
);
2012 ok(!(r
& LVIS_SELECTED
), "Expected item %d to be unselected\n", i
);
2014 r
= ListView_GetItemState(hwnd
, 3, LVIS_SELECTED
);
2015 ok(r
& LVIS_SELECTED
, "Expected item %d to be selected\n", i
);
2017 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2019 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2022 /* try to select all on LVS_SINGLESEL */
2023 memset(&item
, 0, sizeof(item
));
2024 item
.stateMask
= LVIS_SELECTED
;
2025 r
= SendMessage(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2027 SendMessage(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2029 item
.stateMask
= LVIS_SELECTED
;
2030 item
.state
= LVIS_SELECTED
;
2031 r
= SendMessage(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2034 r
= ListView_GetSelectedCount(hwnd
);
2036 r
= ListView_GetSelectionMark(hwnd
);
2039 /* try to deselect all on LVS_SINGLESEL */
2040 item
.stateMask
= LVIS_SELECTED
;
2041 item
.state
= LVIS_SELECTED
;
2042 r
= SendMessage(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2045 item
.stateMask
= LVIS_SELECTED
;
2047 r
= SendMessage(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2049 r
= ListView_GetSelectedCount(hwnd
);
2052 DestroyWindow(hwnd
);
2055 static void test_subitem_rect(void)
2062 /* test LVM_GETSUBITEMRECT for header */
2063 hwnd
= create_listview_control(LVS_REPORT
);
2064 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2065 /* add some columns */
2066 memset(&col
, 0, sizeof(LVCOLUMN
));
2067 col
.mask
= LVCF_WIDTH
;
2070 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
2074 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 1, (LPARAM
)&col
);
2078 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 2, (LPARAM
)&col
);
2080 /* item = -1 means header, subitem index is 1 based */
2081 rect
.left
= LVIR_BOUNDS
;
2083 rect
.right
= rect
.bottom
= 0;
2084 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2087 rect
.left
= LVIR_BOUNDS
;
2089 rect
.right
= rect
.bottom
= 0;
2090 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2092 ok(r
!= 0, "Expected not-null LRESULT\n");
2093 expect(100, rect
.left
);
2094 expect(250, rect
.right
);
2096 expect(3, rect
.top
);
2098 rect
.left
= LVIR_BOUNDS
;
2100 rect
.right
= rect
.bottom
= 0;
2101 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2103 ok(r
!= 0, "Expected not-null LRESULT\n");
2104 expect(250, rect
.left
);
2105 expect(450, rect
.right
);
2107 expect(3, rect
.top
);
2109 /* item LVS_REPORT padding isn't applied to subitems */
2110 insert_item(hwnd
, 0);
2112 rect
.left
= LVIR_BOUNDS
;
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 expect(100, rect
.left
);
2118 expect(250, rect
.right
);
2120 rect
.left
= LVIR_ICON
;
2122 rect
.right
= rect
.bottom
= 0;
2123 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2124 ok(r
!= 0, "Expected not-null LRESULT\n");
2125 /* no icon attached - zero width rectangle, with no left padding */
2126 expect(100, rect
.left
);
2127 expect(100, rect
.right
);
2129 rect
.left
= LVIR_LABEL
;
2131 rect
.right
= rect
.bottom
= 0;
2132 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2133 ok(r
!= 0, "Expected not-null LRESULT\n");
2134 /* same as full LVIR_BOUNDS */
2135 expect(100, rect
.left
);
2136 expect(250, rect
.right
);
2138 DestroyWindow(hwnd
);
2140 /* try it for non LVS_REPORT style */
2141 hwnd
= CreateWindow("SysListView32", "Test", LVS_ICON
, 0, 0, 100, 100, NULL
, NULL
,
2142 GetModuleHandle(NULL
), 0);
2143 rect
.left
= LVIR_BOUNDS
;
2145 rect
.right
= rect
.bottom
= -10;
2146 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2147 ok(r
== 0, "Expected not-null LRESULT\n");
2148 /* rect is unchanged */
2149 expect(0, rect
.left
);
2150 expect(-10, rect
.right
);
2151 expect(1, rect
.top
);
2152 expect(-10, rect
.bottom
);
2153 DestroyWindow(hwnd
);
2156 /* comparison callback for test_sorting */
2157 static INT WINAPI
test_CallBackCompare(LPARAM first
, LPARAM second
, LPARAM lParam
)
2159 if (first
== second
) return 0;
2160 return (first
> second
? 1 : -1);
2163 static void test_sorting(void)
2169 static CHAR names
[][5] = {"A", "B", "C", "D", "0"};
2172 hwnd
= create_listview_control(LVS_REPORT
);
2173 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2175 /* insert some items */
2176 item
.mask
= LVIF_PARAM
| LVIF_STATE
;
2177 item
.state
= LVIS_SELECTED
;
2181 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2184 item
.mask
= LVIF_PARAM
;
2188 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2191 item
.mask
= LVIF_STATE
| LVIF_PARAM
;
2192 item
.state
= LVIS_SELECTED
;
2196 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2199 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2202 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2205 r
= SendMessage(hwnd
, LVM_SORTITEMS
, 0, (LPARAM
)test_CallBackCompare
);
2208 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2210 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2212 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_SELECTED
);
2214 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 1, LVIS_SELECTED
);
2215 expect(LVIS_SELECTED
, r
);
2216 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 2, LVIS_SELECTED
);
2217 expect(LVIS_SELECTED
, r
);
2219 DestroyWindow(hwnd
);
2221 /* switch to LVS_SORTASCENDING when some items added */
2222 hwnd
= create_listview_control(LVS_REPORT
);
2223 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2225 item
.mask
= LVIF_TEXT
;
2228 item
.pszText
= names
[1];
2229 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2232 item
.mask
= LVIF_TEXT
;
2235 item
.pszText
= names
[2];
2236 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2239 item
.mask
= LVIF_TEXT
;
2242 item
.pszText
= names
[0];
2243 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2246 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2247 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTASCENDING
);
2248 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2249 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2251 /* no sorting performed when switched to LVS_SORTASCENDING */
2252 item
.mask
= LVIF_TEXT
;
2254 item
.pszText
= buff
;
2255 item
.cchTextMax
= sizeof(buff
);
2256 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2258 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2261 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2263 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2266 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2268 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2270 /* adding new item doesn't resort list */
2271 item
.mask
= LVIF_TEXT
;
2274 item
.pszText
= names
[3];
2275 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2278 item
.mask
= LVIF_TEXT
;
2280 item
.pszText
= buff
;
2281 item
.cchTextMax
= sizeof(buff
);
2282 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2284 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2287 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2289 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2292 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2294 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2297 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2299 ok(lstrcmp(buff
, names
[3]) == 0, "Expected '%s', got '%s'\n", names
[3], buff
);
2301 /* corner case - item should be placed at first position */
2302 item
.mask
= LVIF_TEXT
;
2305 item
.pszText
= names
[4];
2306 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2310 item
.pszText
= buff
;
2311 item
.cchTextMax
= sizeof(buff
);
2312 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2314 ok(lstrcmp(buff
, names
[4]) == 0, "Expected '%s', got '%s'\n", names
[4], buff
);
2317 item
.pszText
= buff
;
2318 item
.cchTextMax
= sizeof(buff
);
2319 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2321 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2324 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2326 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2329 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2331 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2334 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2336 ok(lstrcmp(buff
, names
[3]) == 0, "Expected '%s', got '%s'\n", names
[3], buff
);
2338 DestroyWindow(hwnd
);
2341 static void test_ownerdata(void)
2344 LONG_PTR style
, ret
;
2348 /* it isn't possible to set LVS_OWNERDATA after creation */
2351 win_skip("set LVS_OWNERDATA after creation leads to crash on < 5.80\n");
2355 hwnd
= create_listview_control(LVS_REPORT
);
2356 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2357 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2358 ok(!(style
& LVS_OWNERDATA
) && style
, "LVS_OWNERDATA isn't expected\n");
2360 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2362 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_OWNERDATA
);
2363 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2364 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2365 "try to switch to LVS_OWNERDATA seq", FALSE
);
2367 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2368 ok(!(style
& LVS_OWNERDATA
), "LVS_OWNERDATA isn't expected\n");
2369 DestroyWindow(hwnd
);
2372 /* try to set LVS_OWNERDATA after creation just having it */
2373 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2374 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2375 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2376 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2378 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2380 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_OWNERDATA
);
2381 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2382 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2383 "try to switch to LVS_OWNERDATA seq", FALSE
);
2384 DestroyWindow(hwnd
);
2386 /* try to remove LVS_OWNERDATA after creation just having it */
2389 win_skip("remove LVS_OWNERDATA after creation leads to crash on < 5.80\n");
2393 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2394 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2395 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2396 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2398 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2400 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_OWNERDATA
);
2401 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2402 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2403 "try to switch to LVS_OWNERDATA seq", FALSE
);
2404 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2405 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2406 DestroyWindow(hwnd
);
2409 /* try select an item */
2410 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2411 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2412 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2413 ok(res
!= 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2414 res
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2416 memset(&item
, 0, sizeof(item
));
2417 item
.stateMask
= LVIS_SELECTED
;
2418 item
.state
= LVIS_SELECTED
;
2419 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2421 res
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2423 res
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2425 DestroyWindow(hwnd
);
2427 /* LVM_SETITEM is unsupported on LVS_OWNERDATA */
2428 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2429 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2430 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2431 ok(res
!= 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2432 res
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2434 memset(&item
, 0, sizeof(item
));
2435 item
.mask
= LVIF_STATE
;
2437 item
.stateMask
= LVIS_SELECTED
;
2438 item
.state
= LVIS_SELECTED
;
2439 res
= SendMessageA(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
2441 DestroyWindow(hwnd
);
2443 /* check notifications after focused/selected changed */
2444 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2445 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2446 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 20, 0);
2447 ok(res
!= 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2449 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2451 memset(&item
, 0, sizeof(item
));
2452 item
.stateMask
= LVIS_SELECTED
;
2453 item
.state
= LVIS_SELECTED
;
2454 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2457 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownderdata_select_focus_parent_seq
,
2458 "ownerdata select notification", TRUE
);
2460 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2462 memset(&item
, 0, sizeof(item
));
2463 item
.stateMask
= LVIS_FOCUSED
;
2464 item
.state
= LVIS_FOCUSED
;
2465 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2468 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownderdata_select_focus_parent_seq
,
2469 "ownerdata focus notification", TRUE
);
2471 /* select all, check notifications */
2472 item
.stateMask
= LVIS_SELECTED
;
2474 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2477 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2479 item
.stateMask
= LVIS_SELECTED
;
2480 item
.state
= LVIS_SELECTED
;
2482 g_dump_itemchanged
= TRUE
;
2483 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2485 g_dump_itemchanged
= FALSE
;
2487 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2488 "ownerdata select all notification", TRUE
);
2490 /* select all again, note that all items are selected already */
2491 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2492 item
.stateMask
= LVIS_SELECTED
;
2493 item
.state
= LVIS_SELECTED
;
2494 g_dump_itemchanged
= TRUE
;
2495 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2497 g_dump_itemchanged
= FALSE
;
2498 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2499 "ownerdata select all notification", TRUE
);
2501 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2502 item
.stateMask
= LVIS_SELECTED
;
2504 g_dump_itemchanged
= TRUE
;
2505 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2507 g_dump_itemchanged
= FALSE
;
2508 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_deselect_all_parent_seq
,
2509 "ownerdata deselect all notification", TRUE
);
2511 /* select one, then deselect all */
2512 item
.stateMask
= LVIS_SELECTED
;
2513 item
.state
= LVIS_SELECTED
;
2514 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2516 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2517 item
.stateMask
= LVIS_SELECTED
;
2519 g_dump_itemchanged
= TRUE
;
2520 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2522 g_dump_itemchanged
= FALSE
;
2523 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_deselect_all_parent_seq
,
2524 "ownerdata select all notification", TRUE
);
2526 /* remove focused, try to focus all */
2527 item
.stateMask
= LVIS_FOCUSED
;
2528 item
.state
= LVIS_FOCUSED
;
2529 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2531 item
.stateMask
= LVIS_FOCUSED
;
2533 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2535 item
.stateMask
= LVIS_FOCUSED
;
2536 res
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_FOCUSED
);
2538 /* setting all to focused returns failure value */
2539 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2540 item
.stateMask
= LVIS_FOCUSED
;
2541 item
.state
= LVIS_FOCUSED
;
2542 g_dump_itemchanged
= TRUE
;
2543 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2545 g_dump_itemchanged
= FALSE
;
2546 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2547 "ownerdata focus all notification", FALSE
);
2548 /* focus single item, remove all */
2549 item
.stateMask
= LVIS_FOCUSED
;
2550 item
.state
= LVIS_FOCUSED
;
2551 res
= SendMessage(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2553 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2554 item
.stateMask
= LVIS_FOCUSED
;
2556 g_dump_itemchanged
= TRUE
;
2557 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2559 g_dump_itemchanged
= FALSE
;
2560 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_defocus_all_parent_seq
,
2561 "ownerdata remove focus all notification", TRUE
);
2563 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2564 item
.stateMask
= LVIS_CUT
;
2565 item
.state
= LVIS_CUT
;
2566 g_dump_itemchanged
= TRUE
;
2567 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2569 g_dump_itemchanged
= FALSE
;
2570 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2571 "ownerdata cut all notification", TRUE
);
2572 /* all marked cut, try again */
2573 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2574 item
.stateMask
= LVIS_CUT
;
2575 item
.state
= LVIS_CUT
;
2576 g_dump_itemchanged
= TRUE
;
2577 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2579 g_dump_itemchanged
= FALSE
;
2580 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2581 "ownerdata cut all notification #2", TRUE
);
2583 DestroyWindow(hwnd
);
2585 /* check notifications on LVM_GETITEM */
2586 /* zero callback mask */
2587 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2588 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2589 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2590 ok(res
!= 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2592 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2594 memset(&item
, 0, sizeof(item
));
2595 item
.stateMask
= LVIS_SELECTED
;
2596 item
.mask
= LVIF_STATE
;
2597 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2600 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2601 "ownerdata getitem selected state 1", FALSE
);
2603 /* non zero callback mask but not we asking for */
2604 res
= SendMessageA(hwnd
, LVM_SETCALLBACKMASK
, LVIS_OVERLAYMASK
, 0);
2607 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2609 memset(&item
, 0, sizeof(item
));
2610 item
.stateMask
= LVIS_SELECTED
;
2611 item
.mask
= LVIF_STATE
;
2612 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2615 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2616 "ownerdata getitem selected state 2", FALSE
);
2618 /* LVIS_OVERLAYMASK callback mask, asking for index */
2619 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2621 memset(&item
, 0, sizeof(item
));
2622 item
.stateMask
= LVIS_OVERLAYMASK
;
2623 item
.mask
= LVIF_STATE
;
2624 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2627 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
2628 "ownerdata getitem selected state 2", FALSE
);
2630 DestroyWindow(hwnd
);
2632 /* LVS_SORTASCENDING/LVS_SORTDESCENDING aren't compatible with LVS_OWNERDATA */
2633 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_SORTASCENDING
| LVS_REPORT
);
2634 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2635 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2636 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
2637 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2638 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_SORTASCENDING
);
2639 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2640 ok(!(style
& LVS_SORTASCENDING
), "Expected LVS_SORTASCENDING not set\n");
2641 DestroyWindow(hwnd
);
2642 /* apparently it's allowed to switch these style on after creation */
2643 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2644 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2645 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2646 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
2647 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTASCENDING
);
2648 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2649 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2650 DestroyWindow(hwnd
);
2652 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2653 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2654 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2655 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
2656 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTDESCENDING
);
2657 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2658 ok(style
& LVS_SORTDESCENDING
, "Expected LVS_SORTDESCENDING to be set\n");
2659 DestroyWindow(hwnd
);
2662 static void test_norecompute(void)
2664 static CHAR testA
[] = "test";
2670 /* self containing control */
2671 hwnd
= create_listview_control(LVS_REPORT
);
2672 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2673 memset(&item
, 0, sizeof(item
));
2674 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
2676 item
.stateMask
= LVIS_SELECTED
;
2677 item
.state
= LVIS_SELECTED
;
2678 item
.pszText
= testA
;
2679 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
2681 /* retrieve with LVIF_NORECOMPUTE */
2682 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
2684 item
.pszText
= buff
;
2685 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
2686 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
2688 ok(lstrcmp(buff
, testA
) == 0, "Expected (%s), got (%s)\n", testA
, buff
);
2690 item
.mask
= LVIF_TEXT
;
2692 item
.pszText
= LPSTR_TEXTCALLBACK
;
2693 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
2696 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
2698 item
.pszText
= buff
;
2699 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
2701 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2702 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
2704 ok(item
.pszText
== LPSTR_TEXTCALLBACK
, "Expected (%p), got (%p)\n",
2705 LPSTR_TEXTCALLBACK
, (VOID
*)item
.pszText
);
2706 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "retrieve with LVIF_NORECOMPUTE seq", FALSE
);
2708 DestroyWindow(hwnd
);
2711 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2712 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2714 item
.mask
= LVIF_STATE
;
2715 item
.stateMask
= LVIS_SELECTED
;
2716 item
.state
= LVIS_SELECTED
;
2718 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
2721 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
2723 item
.pszText
= buff
;
2724 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
2725 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2726 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
2728 ok(item
.pszText
== LPSTR_TEXTCALLBACK
, "Expected (%p), got (%p)\n",
2729 LPSTR_TEXTCALLBACK
, (VOID
*)item
.pszText
);
2730 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "retrieve with LVIF_NORECOMPUTE seq 2", FALSE
);
2732 DestroyWindow(hwnd
);
2735 static void test_nosortheader(void)
2740 hwnd
= create_listview_control(LVS_REPORT
);
2741 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2743 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
2744 ok(IsWindow(header
), "header expected\n");
2746 style
= GetWindowLongPtr(header
, GWL_STYLE
);
2747 ok(style
& HDS_BUTTONS
, "expected header to have HDS_BUTTONS\n");
2749 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
2750 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
| LVS_NOSORTHEADER
);
2751 /* HDS_BUTTONS retained */
2752 style
= GetWindowLongPtr(header
, GWL_STYLE
);
2753 ok(style
& HDS_BUTTONS
, "expected header to retain HDS_BUTTONS\n");
2755 DestroyWindow(hwnd
);
2757 /* create with LVS_NOSORTHEADER */
2758 hwnd
= create_listview_control(LVS_NOSORTHEADER
| LVS_REPORT
);
2759 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2761 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
2762 ok(IsWindow(header
), "header expected\n");
2764 style
= GetWindowLongPtr(header
, GWL_STYLE
);
2765 ok(!(style
& HDS_BUTTONS
), "expected header to have no HDS_BUTTONS\n");
2767 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
2768 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
& ~LVS_NOSORTHEADER
);
2769 /* not changed here */
2770 style
= GetWindowLongPtr(header
, GWL_STYLE
);
2771 ok(!(style
& HDS_BUTTONS
), "expected header to have no HDS_BUTTONS\n");
2773 DestroyWindow(hwnd
);
2776 static void test_setredraw(void)
2784 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2785 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2787 /* Passing WM_SETREDRAW to DefWinProc removes WS_VISIBLE.
2788 ListView seems to handle it internally without DefWinProc */
2790 /* default value first */
2791 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
2794 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
2795 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
2796 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2798 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
2799 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
2800 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
2803 /* check update rect after redrawing */
2804 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2806 InvalidateRect(hwnd
, NULL
, FALSE
);
2807 RedrawWindow(hwnd
, NULL
, NULL
, RDW_UPDATENOW
);
2808 rect
.right
= rect
.bottom
= 1;
2809 GetUpdateRect(hwnd
, &rect
, FALSE
);
2810 expect(0, rect
.right
);
2811 expect(0, rect
.bottom
);
2814 hdc
= GetWindowDC(hwndparent
);
2815 ret
= SendMessage(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
2817 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2819 ret
= SendMessage(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
2821 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
2823 ReleaseDC(hwndparent
, hdc
);
2825 /* check notification messages to show that repainting is disabled */
2826 ret
= SendMessage(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2828 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2830 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)", FALSE
);
2837 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, CLR_NONE
);
2839 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2840 InvalidateRect(hwnd
, NULL
, TRUE
);
2842 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2843 "redraw after WM_SETREDRAW (FALSE) with CLR_NONE bkgnd", FALSE
);
2845 /* message isn't forwarded to header */
2846 subclass_header(hwnd
);
2847 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2848 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2850 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, setredraw_seq
,
2851 "WM_SETREDRAW: not forwarded to header", FALSE
);
2853 DestroyWindow(hwnd
);
2856 static void test_hittest(void)
2862 static CHAR text
[] = "1234567890ABCDEFGHIJKLMNOPQRST";
2865 HIMAGELIST himl
, himl2
;
2868 hwnd
= create_listview_control(LVS_REPORT
);
2869 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2871 /* LVS_REPORT with a single subitem (2 columns) */
2872 insert_column(hwnd
, 0);
2873 insert_column(hwnd
, 1);
2874 insert_item(hwnd
, 0);
2877 /* the only purpose of that line is to be as long as a half item rect */
2878 item
.pszText
= text
;
2879 r
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&item
);
2882 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
2884 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(100, 0));
2887 memset(&bounds
, 0, sizeof(bounds
));
2888 bounds
.left
= LVIR_BOUNDS
;
2889 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&bounds
);
2890 ok(bounds
.bottom
- bounds
.top
> 0, "Expected non zero item height\n");
2891 ok(bounds
.right
- bounds
.left
> 0, "Expected non zero item width\n");
2892 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pos
);
2895 /* LVS_EX_FULLROWSELECT not set, no icons attached */
2896 x
= pos
.x
+ 50; /* column half width */
2897 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2898 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMLABEL
, 0, FALSE
, FALSE
, __LINE__
);
2899 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2900 x
= pos
.x
+ 150; /* outside column */
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
, 0, 1, LVHT_ONITEMLABEL
, 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
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2907 /* outside possible client rectangle (to right) */
2909 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2910 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
, __LINE__
);
2911 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2912 y
= (bounds
.bottom
- bounds
.top
) / 2;
2913 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
, __LINE__
);
2914 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2915 /* subitem returned with -1 item too */
2918 test_lvm_subitemhittest(hwnd
, x
, y
, -1, 1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2919 /* parent client area is 100x100 by default */
2920 MoveWindow(hwnd
, 0, 0, 300, 100, FALSE
);
2921 x
= pos
.x
+ 150; /* outside column */
2922 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2923 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_NOWHERE
, 0, FALSE
, FALSE
, __LINE__
);
2924 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2925 y
= (bounds
.bottom
- bounds
.top
) / 2;
2926 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_NOWHERE
, 0, FALSE
, TRUE
, __LINE__
);
2927 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2928 /* the same with LVS_EX_FULLROWSELECT */
2929 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_FULLROWSELECT
);
2930 x
= pos
.x
+ 150; /* outside column */
2931 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2932 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEM
, LVHT_ONITEMLABEL
, FALSE
, FALSE
, __LINE__
);
2933 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2934 y
= (bounds
.bottom
- bounds
.top
) / 2;
2935 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2936 MoveWindow(hwnd
, 0, 0, 100, 100, FALSE
);
2937 x
= pos
.x
+ 150; /* outside column */
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
, 0, 1, LVHT_ONITEMLABEL
, 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
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2944 /* outside possible client rectangle (to right) */
2946 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2947 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
, __LINE__
);
2948 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2949 y
= (bounds
.bottom
- bounds
.top
) / 2;
2950 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
, __LINE__
);
2951 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2952 /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
2953 himl
= ImageList_Create(16, 16, 0, 4, 4);
2954 ok(himl
!= NULL
, "failed to create imagelist\n");
2955 hbmp
= CreateBitmap(16, 16, 1, 1, NULL
);
2956 ok(hbmp
!= NULL
, "failed to create bitmap\n");
2957 r
= ImageList_Add(himl
, hbmp
, 0);
2958 ok(r
== 0, "should be zero\n");
2959 hbmp
= CreateBitmap(16, 16, 1, 1, NULL
);
2960 ok(hbmp
!= NULL
, "failed to create bitmap\n");
2961 r
= ImageList_Add(himl
, hbmp
, 0);
2962 ok(r
== 1, "should be one\n");
2964 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl
);
2965 ok(r
== 0, "should return zero\n");
2967 item
.mask
= LVIF_IMAGE
;
2971 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
2975 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2976 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMSTATEICON
, 0, FALSE
, FALSE
, __LINE__
);
2977 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
2978 y
= (bounds
.bottom
- bounds
.top
) / 2;
2979 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
2981 /* state icons indices are 1 based, check with valid index */
2982 item
.mask
= LVIF_STATE
;
2983 item
.state
= INDEXTOSTATEIMAGEMASK(1);
2984 item
.stateMask
= LVIS_STATEIMAGEMASK
;
2987 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
2991 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2992 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMSTATEICON
, 0, FALSE
, FALSE
, __LINE__
);
2993 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
2994 y
= (bounds
.bottom
- bounds
.top
) / 2;
2995 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
2997 himl2
= (HIMAGELIST
)SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, 0);
2998 ok(himl2
== himl
, "should return handle\n");
3000 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl
);
3001 ok(r
== 0, "should return zero\n");
3004 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3005 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMICON
, 0, FALSE
, FALSE
, __LINE__
);
3006 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
3007 y
= (bounds
.bottom
- bounds
.top
) / 2;
3008 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
3010 DestroyWindow(hwnd
);
3013 static void test_getviewrect(void)
3020 hwnd
= create_listview_control(LVS_REPORT
);
3021 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3024 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3027 insert_column(hwnd
, 0);
3028 insert_column(hwnd
, 1);
3030 memset(&item
, 0, sizeof(item
));
3033 SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3035 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
3037 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(120, 0));
3040 rect
.left
= rect
.right
= rect
.top
= rect
.bottom
= -1;
3041 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3043 /* left is set to (2e31-1) - XP SP2 */
3044 expect(0, rect
.right
);
3045 expect(0, rect
.top
);
3046 expect(0, rect
.bottom
);
3048 /* switch to LVS_ICON */
3049 SetWindowLong(hwnd
, GWL_STYLE
, GetWindowLong(hwnd
, GWL_STYLE
) & ~LVS_REPORT
);
3051 rect
.left
= rect
.right
= rect
.top
= rect
.bottom
= -1;
3052 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3054 expect(0, rect
.left
);
3055 expect(0, rect
.top
);
3056 /* precise value differs for 2k, XP and Vista */
3057 ok(rect
.bottom
> 0, "Expected positive bottom value, got %d\n", rect
.bottom
);
3058 ok(rect
.right
> 0, "Expected positive right value, got %d\n", rect
.right
);
3060 DestroyWindow(hwnd
);
3063 static void test_getitemposition(void)
3070 hwnd
= create_listview_control(LVS_REPORT
);
3071 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3072 header
= subclass_header(hwnd
);
3074 /* LVS_REPORT, single item, no columns added */
3075 insert_item(hwnd
, 0);
3077 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3080 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3082 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getitemposition_seq1
, "get item position 1", FALSE
);
3084 /* LVS_REPORT, single item, single column */
3085 insert_column(hwnd
, 0);
3087 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3090 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3092 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getitemposition_seq2
, "get item position 2", TRUE
);
3094 memset(&rect
, 0, sizeof(rect
));
3095 SendMessage(header
, HDM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3098 /* offset by header height */
3099 expect(rect
.bottom
- rect
.top
, pt
.y
);
3101 DestroyWindow(hwnd
);
3104 static void test_columnscreation(void)
3109 hwnd
= create_listview_control(LVS_REPORT
);
3110 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3112 insert_item(hwnd
, 0);
3114 /* headers columns aren't created automatically */
3115 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3116 ok(IsWindow(header
), "Expected header handle\n");
3117 r
= SendMessage(header
, HDM_GETITEMCOUNT
, 0, 0);
3120 DestroyWindow(hwnd
);
3123 static void test_getitemrect(void)
3135 /* rectangle isn't empty for empty text items */
3136 hwnd
= create_listview_control(LVS_LIST
);
3137 memset(&item
, 0, sizeof(item
));
3140 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3142 rect
.left
= LVIR_LABEL
;
3143 SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3144 expect(0, rect
.left
);
3145 expect(0, rect
.top
);
3146 todo_wine
expect(96, rect
.right
);
3147 DestroyWindow(hwnd
);
3149 hwnd
= create_listview_control(LVS_REPORT
);
3150 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3153 memset(&item
, 0, sizeof(item
));
3156 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3159 rect
.left
= LVIR_BOUNDS
;
3160 rect
.right
= rect
.top
= rect
.bottom
= -1;
3161 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3164 /* zero width rectangle with no padding */
3165 expect(0, rect
.left
);
3166 expect(0, rect
.right
);
3168 insert_column(hwnd
, 0);
3169 insert_column(hwnd
, 1);
3171 col
.mask
= LVCF_WIDTH
;
3173 r
= SendMessage(hwnd
, LVM_SETCOLUMN
, 0, (LPARAM
)&col
);
3176 col
.mask
= LVCF_WIDTH
;
3178 r
= SendMessage(hwnd
, LVM_SETCOLUMN
, 1, (LPARAM
)&col
);
3181 rect
.left
= LVIR_BOUNDS
;
3182 rect
.right
= rect
.top
= rect
.bottom
= -1;
3183 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3186 /* still no left padding */
3187 expect(0, rect
.left
);
3188 expect(150, rect
.right
);
3190 rect
.left
= LVIR_SELECTBOUNDS
;
3191 rect
.right
= rect
.top
= rect
.bottom
= -1;
3192 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3195 expect(2, rect
.left
);
3197 rect
.left
= LVIR_LABEL
;
3198 rect
.right
= rect
.top
= rect
.bottom
= -1;
3199 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3201 /* padding, column width */
3202 expect(2, rect
.left
);
3203 expect(50, rect
.right
);
3205 /* no icons attached */
3206 rect
.left
= LVIR_ICON
;
3207 rect
.right
= rect
.top
= rect
.bottom
= -1;
3208 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3211 expect(2, rect
.left
);
3212 expect(2, rect
.right
);
3215 order
[0] = 1; order
[1] = 0;
3216 r
= SendMessage(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
3219 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3221 /* 1 indexed column width + padding */
3223 /* rect is at zero too */
3224 rect
.left
= LVIR_BOUNDS
;
3225 rect
.right
= rect
.top
= rect
.bottom
= -1;
3226 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3228 expect(0, rect
.left
);
3229 /* just width sum */
3230 expect(150, rect
.right
);
3232 rect
.left
= LVIR_SELECTBOUNDS
;
3233 rect
.right
= rect
.top
= rect
.bottom
= -1;
3234 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3236 /* column width + padding */
3237 expect(102, rect
.left
);
3239 /* back to initial order */
3240 order
[0] = 0; order
[1] = 1;
3241 r
= SendMessage(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
3245 himl
= ImageList_Create(16, 16, 0, 2, 2);
3246 ok(himl
!= NULL
, "failed to create imagelist\n");
3247 hbm
= CreateBitmap(16, 16, 1, 1, NULL
);
3248 ok(hbm
!= NULL
, "failed to create bitmap\n");
3249 r
= ImageList_Add(himl
, hbm
, 0);
3250 ok(r
== 0, "should be zero\n");
3251 hbm
= CreateBitmap(16, 16, 1, 1, NULL
);
3252 ok(hbm
!= NULL
, "failed to create bitmap\n");
3253 r
= ImageList_Add(himl
, hbm
, 0);
3254 ok(r
== 1, "should be one\n");
3256 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl
);
3257 ok(r
== 0, "should return zero\n");
3259 item
.mask
= LVIF_STATE
;
3260 item
.state
= INDEXTOSTATEIMAGEMASK(1);
3261 item
.stateMask
= LVIS_STATEIMAGEMASK
;
3264 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3268 rect
.left
= LVIR_ICON
;
3269 rect
.right
= rect
.top
= rect
.bottom
= -1;
3270 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3272 /* padding + stateicon width */
3273 expect(18, rect
.left
);
3274 expect(18, rect
.right
);
3276 rect
.left
= LVIR_LABEL
;
3277 rect
.right
= rect
.top
= rect
.bottom
= -1;
3278 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3280 /* padding + stateicon width -> column width */
3281 expect(18, rect
.left
);
3282 expect(50, rect
.right
);
3284 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)NULL
);
3285 ok(r
!= 0, "should return current list handle\n");
3287 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl
);
3288 ok(r
== 0, "should return zero\n");
3290 item
.mask
= LVIF_STATE
| LVIF_IMAGE
;
3293 item
.stateMask
= ~0;
3296 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3300 rect
.left
= LVIR_ICON
;
3301 rect
.right
= rect
.top
= rect
.bottom
= -1;
3302 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3304 /* padding, icon width */
3305 expect(2, rect
.left
);
3306 expect(18, rect
.right
);
3308 rect
.left
= LVIR_LABEL
;
3309 rect
.right
= rect
.top
= rect
.bottom
= -1;
3310 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3312 /* padding + icon width -> column width */
3313 expect(18, rect
.left
);
3314 expect(50, rect
.right
);
3317 rect
.left
= LVIR_SELECTBOUNDS
;
3318 rect
.right
= rect
.top
= rect
.bottom
= -1;
3319 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3321 /* padding, column width */
3322 expect(2, rect
.left
);
3323 expect(50, rect
.right
);
3325 /* try with indentation */
3326 item
.mask
= LVIF_INDENT
;
3330 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3334 rect
.left
= LVIR_BOUNDS
;
3335 rect
.right
= rect
.top
= rect
.bottom
= -1;
3336 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3338 /* padding + 1 icon width, column width */
3339 expect(0, rect
.left
);
3340 expect(150, rect
.right
);
3343 rect
.left
= LVIR_SELECTBOUNDS
;
3344 rect
.right
= rect
.top
= rect
.bottom
= -1;
3345 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3347 /* padding + 1 icon width, column width */
3348 expect(2 + 16, rect
.left
);
3349 expect(50, rect
.right
);
3352 rect
.left
= LVIR_LABEL
;
3353 rect
.right
= rect
.top
= rect
.bottom
= -1;
3354 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3356 /* padding + 2 icon widths, column width */
3357 expect(2 + 16*2, rect
.left
);
3358 expect(50, rect
.right
);
3361 rect
.left
= LVIR_ICON
;
3362 rect
.right
= rect
.top
= rect
.bottom
= -1;
3363 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3365 /* padding + 1 icon width indentation, icon width */
3366 expect(2 + 16, rect
.left
);
3367 expect(34, rect
.right
);
3370 DestroyWindow(hwnd
);
3373 static void test_editbox(void)
3375 HWND hwnd
, hwndedit
, hwndedit2
;
3378 static CHAR testitemA
[] = "testitem";
3379 static CHAR testitem1A
[] = "testitem1";
3380 static CHAR buffer
[10];
3382 hwnd
= create_listview_control(LVS_EDITLABELS
| LVS_REPORT
);
3383 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3385 insert_column(hwnd
, 0);
3387 memset(&item
, 0, sizeof(item
));
3388 item
.mask
= LVIF_TEXT
;
3389 item
.pszText
= testitemA
;
3392 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3395 /* setting focus is necessary */
3397 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3398 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3400 /* modify initial string */
3401 r
= SendMessage(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem1A
);
3403 /* return focus to listview */
3406 memset(&item
, 0, sizeof(item
));
3407 item
.mask
= LVIF_TEXT
;
3408 item
.pszText
= buffer
;
3409 item
.cchTextMax
= 10;
3412 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3415 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
3417 /* send LVM_EDITLABEL on already created edit */
3419 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3420 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3421 /* focus will be set to edit */
3422 ok(GetFocus() == hwndedit
, "Expected Edit window to be focused\n");
3423 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3424 ok(IsWindow(hwndedit2
), "Expected Edit window to be created\n");
3426 /* creating label disabled when control isn't focused */
3428 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3429 todo_wine
ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3431 /* check EN_KILLFOCUS handling */
3432 memset(&item
, 0, sizeof(item
));
3433 item
.pszText
= testitemA
;
3436 r
= SendMessage(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
3440 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3441 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3442 /* modify edit and notify control that it lost focus */
3443 r
= SendMessage(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem1A
);
3445 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
3447 memset(&item
, 0, sizeof(item
));
3448 item
.pszText
= buffer
;
3449 item
.cchTextMax
= 10;
3452 r
= SendMessage(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
3453 expect(lstrlen(item
.pszText
), r
);
3454 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
3455 ok(!IsWindow(hwndedit
), "Expected Edit window to be freed\n");
3456 /* end edit without saving */
3458 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3459 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3460 r
= SendMessage(hwndedit
, WM_KEYDOWN
, VK_ESCAPE
, 0);
3462 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3463 "edit box - end edit, no change, escape", TRUE
);
3464 /* end edit with saving */
3466 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3467 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3468 r
= SendMessage(hwndedit
, WM_KEYDOWN
, VK_RETURN
, 0);
3470 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3471 "edit box - end edit, no change, return", TRUE
);
3473 memset(&item
, 0, sizeof(item
));
3474 item
.pszText
= buffer
;
3475 item
.cchTextMax
= 10;
3478 r
= SendMessage(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
3479 expect(lstrlen(item
.pszText
), r
);
3480 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
3482 /* LVM_EDITLABEL with -1 destroys current edit */
3483 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_GETEDITCONTROL
, 0, 0);
3484 ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3485 /* no edit present */
3486 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -1, 0);
3487 ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3488 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3489 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3491 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3492 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -1, 0);
3493 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3494 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3495 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3496 /* check another negative value */
3497 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3498 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3499 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3500 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -2, 0);
3501 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3502 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3503 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3504 /* and value greater than max item index */
3505 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3506 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3507 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3508 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
3509 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, r
, 0);
3510 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3511 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3512 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3514 /* messaging tests */
3516 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3518 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3519 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3520 /* testing only sizing messages */
3521 ok_sequence(sequences
, EDITBOX_SEQ_INDEX
, editbox_create_pos
,
3522 "edit box create - sizing", FALSE
);
3524 /* WM_COMMAND with EN_KILLFOCUS isn't forwared to parent */
3526 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3527 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3528 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3529 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
3531 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3532 "edit box WM_COMMAND (EN_KILLFOCUS)", TRUE
);
3534 DestroyWindow(hwnd
);
3537 static void test_notifyformat(void)
3542 hwnd
= create_listview_control(LVS_REPORT
);
3543 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3545 /* CCM_GETUNICODEFORMAT == LVM_GETUNICODEFORMAT,
3546 CCM_SETUNICODEFORMAT == LVM_SETUNICODEFORMAT */
3547 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3549 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_QUERY
);
3551 r
= SendMessage(hwnd
, LVM_SETUNICODEFORMAT
, 1, 0);
3553 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3556 r
= SendMessage(hwnd
, LVM_SETUNICODEFORMAT
, 0, 0);
3558 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3563 win_skip("LVM_GETUNICODEFORMAT is unsupported\n");
3564 DestroyWindow(hwnd
);
3568 DestroyWindow(hwnd
);
3570 /* test failure in parent WM_NOTIFYFORMAT */
3572 hwnd
= create_listview_control(LVS_REPORT
);
3573 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3574 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3575 ok(IsWindow(header
), "expected header to be created\n");
3576 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3578 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3579 ok( r
== 1 || broken(r
== 0), /* win9x */ "Expected 1, got %d\n", r
);
3580 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_QUERY
);
3581 ok(r
!= 0, "Expected valid format\n");
3583 notifyFormat
= NFR_UNICODE
;
3584 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_REQUERY
);
3585 expect(NFR_UNICODE
, r
);
3586 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3588 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3589 ok( r
== 1 || broken(r
== 0), /* win9x */ "Expected 1, got %d\n", r
);
3591 notifyFormat
= NFR_ANSI
;
3592 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_REQUERY
);
3593 expect(NFR_ANSI
, r
);
3594 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3596 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3597 ok( r
== 1 || broken(r
== 0), /* win9x */ "Expected 1, got %d\n", r
);
3599 DestroyWindow(hwnd
);
3601 /* try different unicode window combination and defaults */
3602 if (!GetModuleHandleW(NULL
))
3604 win_skip("Additional notify format tests are incompatible with Win9x\n");
3608 hwndparentW
= create_parent_window(TRUE
);
3609 ok(IsWindow(hwndparentW
), "Unicode parent creation failed\n");
3610 if (!IsWindow(hwndparentW
)) return;
3613 hwnd
= create_listview_controlW(LVS_REPORT
, 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 /* receiving error code defaulting to ansi */
3624 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
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 /* receiving ansi code from unicode window, use it */
3634 notifyFormat
= NFR_ANSI
;
3635 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
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
);
3644 /* unicode listview with ansi parent window */
3646 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparent
);
3647 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3648 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3649 ok(IsWindow(header
), "expected header to be created\n");
3650 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3652 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3654 DestroyWindow(hwnd
);
3655 /* unicode listview with ansi parent window, return error code */
3657 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparent
);
3658 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3659 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3660 ok(IsWindow(header
), "expected header to be created\n");
3661 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3663 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3665 DestroyWindow(hwnd
);
3667 DestroyWindow(hwndparentW
);
3670 static void test_indentation(void)
3676 hwnd
= create_listview_control(LVS_REPORT
);
3677 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3679 memset(&item
, 0, sizeof(item
));
3680 item
.mask
= LVIF_INDENT
;
3682 item
.iIndent
= I_INDENTCALLBACK
;
3683 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3686 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3689 item
.mask
= LVIF_INDENT
;
3690 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
3693 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
3694 "get indent dispinfo", FALSE
);
3696 DestroyWindow(hwnd
);
3699 static INT CALLBACK
DummyCompareEx(LPARAM first
, LPARAM second
, LPARAM param
)
3704 static BOOL
is_below_comctl_5(void)
3709 hwnd
= create_listview_control(LVS_REPORT
);
3710 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3711 insert_item(hwnd
, 0);
3713 ret
= SendMessage(hwnd
, LVM_SORTITEMSEX
, 0, (LPARAM
)&DummyCompareEx
);
3715 DestroyWindow(hwnd
);
3720 static void test_get_set_view(void)
3726 /* test style->view mapping */
3727 hwnd
= create_listview_control(LVS_REPORT
);
3728 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3730 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
3731 expect(LV_VIEW_DETAILS
, ret
);
3733 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3735 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
& ~LVS_REPORT
);
3736 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
3737 expect(LV_VIEW_ICON
, ret
);
3739 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3740 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
| LVS_SMALLICON
);
3741 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
3742 expect(LV_VIEW_SMALLICON
, ret
);
3744 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3745 SetWindowLongPtr(hwnd
, GWL_STYLE
, (style
& ~LVS_SMALLICON
) | LVS_LIST
);
3746 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
3747 expect(LV_VIEW_LIST
, ret
);
3749 /* switching view doesn't touch window style */
3750 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_DETAILS
, 0);
3752 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3753 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
3754 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_ICON
, 0);
3756 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3757 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
3758 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_SMALLICON
, 0);
3760 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3761 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
3763 DestroyWindow(hwnd
);
3766 static void test_canceleditlabel(void)
3768 HWND hwnd
, hwndedit
;
3772 static CHAR test
[] = "test";
3773 static const CHAR test1
[] = "test1";
3775 hwnd
= create_listview_control(LVS_EDITLABELS
| LVS_REPORT
);
3776 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3778 insert_item(hwnd
, 0);
3780 /* try without edit created */
3781 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3782 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
3784 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3785 "cancel edit label without edit", FALSE
);
3787 /* cancel without data change */
3789 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3790 ok(IsWindow(hwndedit
), "Expected edit control to be created\n");
3791 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
3793 ok(!IsWindow(hwndedit
), "Expected edit control to be destroyed\n");
3795 /* cancel after data change */
3796 memset(&itema
, 0, sizeof(itema
));
3797 itema
.pszText
= test
;
3798 ret
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&itema
);
3801 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3802 ok(IsWindow(hwndedit
), "Expected edit control to be created\n");
3803 ret
= SetWindowText(hwndedit
, test1
);
3804 ok(ret
!= 0, "Expected edit text to change\n");
3805 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
3807 ok(!IsWindow(hwndedit
), "Expected edit control to be destroyed\n");
3808 memset(&itema
, 0, sizeof(itema
));
3809 itema
.pszText
= buff
;
3810 itema
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
3811 ret
= SendMessage(hwnd
, LVM_GETITEMTEXT
, 0, (LPARAM
)&itema
);
3813 ok(strcmp(buff
, test1
) == 0, "Expected label text not to change\n");
3815 DestroyWindow(hwnd
);
3818 static void test_mapidindex(void)
3823 /* LVM_MAPINDEXTOID unsupported with LVS_OWNERDATA */
3824 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3825 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3826 insert_item(hwnd
, 0);
3827 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
3829 DestroyWindow(hwnd
);
3831 hwnd
= create_listview_control(LVS_REPORT
);
3832 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3834 /* LVM_MAPINDEXTOID with invalid index */
3835 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
3838 insert_item(hwnd
, 0);
3839 insert_item(hwnd
, 1);
3841 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, -1, 0);
3843 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 2, 0);
3846 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
3848 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 1, 0);
3850 /* remove 0 indexed item, id retained */
3851 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
3852 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
3854 /* new id starts from previous value */
3855 insert_item(hwnd
, 1);
3856 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 1, 0);
3859 /* get index by id */
3860 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, -1, 0);
3862 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 0, 0);
3864 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 1, 0);
3866 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 2, 0);
3869 DestroyWindow(hwnd
);
3872 static void test_getitemspacing(void)
3881 cx
= GetSystemMetrics(SM_CXICONSPACING
) - GetSystemMetrics(SM_CXICON
);
3882 cy
= GetSystemMetrics(SM_CYICONSPACING
) - GetSystemMetrics(SM_CYICON
);
3885 hwnd
= create_listview_control(LVS_ICON
);
3886 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3888 expect(cx
, LOWORD(ret
));
3889 expect(cy
, HIWORD(ret
));
3891 /* now try with icons */
3892 himl
= ImageList_Create(40, 40, 0, 4, 4);
3893 ok(himl
!= NULL
, "failed to create imagelist\n");
3894 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
3895 ok(hbmp
!= NULL
, "failed to create bitmap\n");
3896 ret
= ImageList_Add(himl
, hbmp
, 0);
3898 ret
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
3901 itema
.mask
= LVIF_IMAGE
;
3905 ret
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&itema
);
3907 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3909 /* spacing + icon size returned */
3910 expect(cx
+ 40, LOWORD(ret
));
3911 expect(cy
+ 40, HIWORD(ret
));
3913 DestroyWindow(hwnd
);
3915 hwnd
= create_listview_control(LVS_SMALLICON
);
3916 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3918 expect(cx
, LOWORD(ret
));
3919 expect(cy
, HIWORD(ret
));
3921 DestroyWindow(hwnd
);
3923 hwnd
= create_listview_control(LVS_REPORT
);
3924 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3926 expect(cx
, LOWORD(ret
));
3927 expect(cy
, HIWORD(ret
));
3929 DestroyWindow(hwnd
);
3931 hwnd
= create_listview_control(LVS_LIST
);
3932 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3934 expect(cx
, LOWORD(ret
));
3935 expect(cy
, HIWORD(ret
));
3937 DestroyWindow(hwnd
);
3940 static void test_getcolumnwidth(void)
3948 /* default column width */
3949 hwnd
= create_listview_control(LVS_ICON
);
3950 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
3952 style
= GetWindowLong(hwnd
, GWL_STYLE
);
3953 SetWindowLong(hwnd
, GWL_STYLE
, style
| LVS_LIST
);
3954 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
3955 todo_wine
expect(8, ret
);
3956 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~LVS_LIST
;
3957 SetWindowLong(hwnd
, GWL_STYLE
, style
| LVS_REPORT
);
3959 ret
= SendMessage(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
3961 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
3963 DestroyWindow(hwnd
);
3965 /* default column width with item added */
3966 hwnd
= create_listview_control(LVS_LIST
);
3967 memset(&itema
, 0, sizeof(itema
));
3968 SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&itema
);
3969 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
3971 DestroyWindow(hwnd
);
3974 static void test_scrollnotify(void)
3979 hwnd
= create_listview_control(LVS_REPORT
);
3981 insert_column(hwnd
, 0);
3982 insert_column(hwnd
, 1);
3983 insert_item(hwnd
, 0);
3985 /* make it scrollable - resize */
3986 ret
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
3988 ret
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(100, 0));
3991 /* try with dummy call */
3992 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3993 ret
= SendMessage(hwnd
, LVM_SCROLL
, 0, 0);
3995 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
3996 "scroll notify 1", TRUE
);
3998 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3999 ret
= SendMessage(hwnd
, LVM_SCROLL
, 1, 0);
4001 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4002 "scroll notify 2", TRUE
);
4004 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4005 ret
= SendMessage(hwnd
, LVM_SCROLL
, 1, 1);
4007 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4008 "scroll notify 3", TRUE
);
4010 DestroyWindow(hwnd
);
4013 static void test_LVS_EX_TRANSPARENTBKGND(void)
4019 hwnd
= create_listview_control(LVS_REPORT
);
4021 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, RGB(0, 0, 0));
4024 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_TRANSPARENTBKGND
,
4025 LVS_EX_TRANSPARENTBKGND
);
4027 ret
= SendMessage(hwnd
, LVM_GETBKCOLOR
, 0, 0);
4028 if (ret
!= CLR_NONE
)
4030 win_skip("LVS_EX_TRANSPARENTBKGND unsupported\n");
4031 DestroyWindow(hwnd
);
4035 /* try to set some back color and check this style bit */
4036 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, RGB(0, 0, 0));
4038 ret
= SendMessage(hwnd
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
4039 ok(!(ret
& LVS_EX_TRANSPARENTBKGND
), "Expected LVS_EX_TRANSPARENTBKGND to unset\n");
4041 /* now test what this style actually does */
4042 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_TRANSPARENTBKGND
,
4043 LVS_EX_TRANSPARENTBKGND
);
4045 hdc
= GetWindowDC(hwndparent
);
4047 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4048 SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
4049 ok_sequence(sequences
, PARENT_SEQ_INDEX
, lvs_ex_transparentbkgnd_seq
,
4050 "LVS_EX_TRANSPARENTBKGND parent", FALSE
);
4052 ReleaseDC(hwndparent
, hdc
);
4054 DestroyWindow(hwnd
);
4057 static void test_approximate_viewrect(void)
4065 static CHAR test
[] = "abracadabra, a very long item label";
4067 cx
= GetSystemMetrics(SM_CXICONSPACING
) - GetSystemMetrics(SM_CXICON
);
4068 cy
= GetSystemMetrics(SM_CYICONSPACING
) - GetSystemMetrics(SM_CYICON
);
4070 hwnd
= create_listview_control(LVS_ICON
);
4071 himl
= ImageList_Create(40, 40, 0, 4, 4);
4072 ok(himl
!= NULL
, "failed to create imagelist\n");
4073 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
4074 ok(hbmp
!= NULL
, "failed to create bitmap\n");
4075 ret
= ImageList_Add(himl
, hbmp
, 0);
4077 ret
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
4080 itema
.mask
= LVIF_IMAGE
;
4084 ret
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&itema
);
4087 ret
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(75, 75));
4091 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
4095 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 11, MAKELPARAM(100,100));
4096 ok(MAKELONG(77,827)==ret
,"Incorrect Approximate rect\n");
4098 ret
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(50, 50));
4099 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 11, MAKELPARAM(100,100));
4100 ok(MAKELONG(102,302)==ret
,"Incorrect Approximate rect\n");
4102 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, -1, MAKELPARAM(100,100));
4103 ok(MAKELONG(52,52)==ret
,"Incorrect Approximate rect\n");
4105 itema
.pszText
= test
;
4106 ret
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&itema
);
4108 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, -1, MAKELPARAM(100,100));
4109 ok(MAKELONG(52,52)==ret
,"Incorrect Approximate rect\n");
4111 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 0, MAKELPARAM(100,100));
4112 ok(MAKELONG(52,2)==ret
,"Incorrect Approximate rect\n");
4113 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 1, MAKELPARAM(100,100));
4114 ok(MAKELONG(52,52)==ret
,"Incorrect Approximate rect\n");
4115 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 2, MAKELPARAM(100,100));
4116 ok(MAKELONG(102,52)==ret
,"Incorrect Approximate rect\n");
4117 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 3, MAKELPARAM(100,100));
4118 ok(MAKELONG(102,102)==ret
,"Incorrect Approximate rect\n");
4119 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 4, MAKELPARAM(100,100));
4120 ok(MAKELONG(102,102)==ret
,"Incorrect Approximate rect\n");
4121 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 5, MAKELPARAM(100,100));
4122 ok(MAKELONG(102,152)==ret
,"Incorrect Approximate rect\n");
4123 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 6, MAKELPARAM(100,100));
4124 ok(MAKELONG(102,152)==ret
,"Incorrect Approximate rect\n");
4125 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 7, MAKELPARAM(160,100));
4126 ok(MAKELONG(152,152)==ret
,"Incorrect Approximate rect\n");
4128 DestroyWindow(hwnd
);
4131 static void test_finditem(void)
4138 hwnd
= create_listview_control(LVS_REPORT
);
4139 insert_item(hwnd
, 0);
4141 memset(&fi
, 0, sizeof(fi
));
4143 /* full string search, inserted text was "foo" */
4145 fi
.flags
= LVFI_STRING
;
4147 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4149 /* partial string search, inserted text was "foo" */
4151 fi
.flags
= LVFI_STRING
| LVFI_PARTIAL
;
4153 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4155 /* partial string search, part after start char */
4157 fi
.flags
= LVFI_STRING
| LVFI_PARTIAL
;
4159 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4162 /* try with LVFI_SUBSTRING */
4164 fi
.flags
= LVFI_SUBSTRING
;
4166 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4169 win_skip("LVFI_SUBSTRING not supported\n");
4170 DestroyWindow(hwnd
);
4175 fi
.flags
= LVFI_SUBSTRING
;
4177 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4180 fi
.flags
= LVFI_SUBSTRING
;
4182 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4186 fi
.flags
= LVFI_SUBSTRING
| LVFI_STRING
;
4188 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4191 DestroyWindow(hwnd
);
4194 static void test_LVS_EX_HEADERINALLVIEWS(void)
4199 hwnd
= create_listview_control(LVS_ICON
);
4201 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4202 LVS_EX_HEADERINALLVIEWS
);
4204 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4205 if (!IsWindow(header
))
4207 win_skip("LVS_EX_HEADERINALLVIEWS unsupported\n");
4208 DestroyWindow(hwnd
);
4212 /* LVS_NOCOLUMNHEADER works as before */
4213 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4214 SetWindowLongW(hwnd
, GWL_STYLE
, style
| LVS_NOCOLUMNHEADER
);
4215 style
= GetWindowLongA(header
, GWL_STYLE
);
4216 ok(style
& HDS_HIDDEN
, "Expected HDS_HIDDEN\n");
4217 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4218 SetWindowLongW(hwnd
, GWL_STYLE
, style
& ~LVS_NOCOLUMNHEADER
);
4219 style
= GetWindowLongA(header
, GWL_STYLE
);
4220 ok(!(style
& HDS_HIDDEN
), "Expected HDS_HIDDEN to be unset\n");
4222 /* try to remove style */
4223 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
, 0);
4224 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4225 ok(IsWindow(header
), "Expected header to be created\n");
4226 style
= GetWindowLongA(header
, GWL_STYLE
);
4227 ok(!(style
& HDS_HIDDEN
), "HDS_HIDDEN not expected\n");
4229 DestroyWindow(hwnd
);
4231 /* check other styles */
4232 hwnd
= create_listview_control(LVS_LIST
);
4233 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4234 LVS_EX_HEADERINALLVIEWS
);
4235 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4236 ok(IsWindow(header
), "Expected header to be created\n");
4237 DestroyWindow(hwnd
);
4239 hwnd
= create_listview_control(LVS_SMALLICON
);
4240 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4241 LVS_EX_HEADERINALLVIEWS
);
4242 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4243 ok(IsWindow(header
), "Expected header to be created\n");
4244 DestroyWindow(hwnd
);
4246 hwnd
= create_listview_control(LVS_REPORT
);
4247 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4248 LVS_EX_HEADERINALLVIEWS
);
4249 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4250 ok(IsWindow(header
), "Expected header to be created\n");
4251 DestroyWindow(hwnd
);
4254 static void test_hover(void)
4259 hwnd
= create_listview_control(LVS_ICON
);
4261 /* test WM_MOUSEHOVER forwarding */
4262 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4263 r
= SendMessage(hwnd
, WM_MOUSEHOVER
, 0, 0);
4265 ok_sequence(sequences
, PARENT_SEQ_INDEX
, hover_parent
, "NM_HOVER allow test", TRUE
);
4266 g_block_hover
= TRUE
;
4267 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4268 r
= SendMessage(hwnd
, WM_MOUSEHOVER
, 0, 0);
4270 ok_sequence(sequences
, PARENT_SEQ_INDEX
, hover_parent
, "NM_HOVER block test", TRUE
);
4271 g_block_hover
= FALSE
;
4273 r
= SendMessage(hwnd
, LVM_SETHOVERTIME
, 0, 500);
4274 expect(HOVER_DEFAULT
, r
);
4275 r
= SendMessage(hwnd
, LVM_GETHOVERTIME
, 0, 0);
4278 DestroyWindow(hwnd
);
4281 static void test_destroynotify(void)
4285 hwnd
= create_listview_control(LVS_REPORT
);
4286 ok(hwnd
!= NULL
, "failed to create listview window\n");
4288 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4289 DestroyWindow(hwnd
);
4290 ok_sequence(sequences
, COMBINED_SEQ_INDEX
, listview_destroy
, "check destroy order", FALSE
);
4293 START_TEST(listview
)
4296 BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
4298 ULONG_PTR ctx_cookie
;
4302 hComctl32
= GetModuleHandleA("comctl32.dll");
4303 pInitCommonControlsEx
= (void*)GetProcAddress(hComctl32
, "InitCommonControlsEx");
4304 if (pInitCommonControlsEx
)
4306 INITCOMMONCONTROLSEX iccex
;
4307 iccex
.dwSize
= sizeof(iccex
);
4308 iccex
.dwICC
= ICC_LISTVIEW_CLASSES
;
4309 pInitCommonControlsEx(&iccex
);
4312 InitCommonControls();
4314 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
4316 hwndparent
= create_parent_window(FALSE
);
4317 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4319 g_is_below_5
= is_below_comctl_5();
4327 test_icon_spacing();
4330 test_item_position();
4335 test_subitem_rect();
4339 test_nosortheader();
4343 test_getitemposition();
4344 test_columnscreation();
4346 test_notifyformat();
4348 test_getitemspacing();
4349 test_getcolumnwidth();
4350 test_approximate_viewrect();
4353 test_destroynotify();
4355 if (!load_v6_module(&ctx_cookie
, &hCtx
))
4357 DestroyWindow(hwndparent
);
4361 /* this is a XP SP3 failure workaround */
4362 hwnd
= CreateWindowExA(0, WC_LISTVIEW
, "foo",
4363 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| LVS_REPORT
,
4365 hwndparent
, NULL
, GetModuleHandleA(NULL
), NULL
);
4366 if (!IsWindow(hwnd
))
4368 win_skip("FIXME: failed to create ListView window.\n");
4369 unload_v6_module(ctx_cookie
, hCtx
);
4370 DestroyWindow(hwndparent
);
4374 DestroyWindow(hwnd
);
4376 /* comctl32 version 6 tests start here */
4377 test_get_set_view();
4378 test_canceleditlabel();
4380 test_scrollnotify();
4381 test_LVS_EX_TRANSPARENTBKGND();
4382 test_LVS_EX_HEADERINALLVIEWS();
4384 unload_v6_module(ctx_cookie
, hCtx
);
4386 DestroyWindow(hwndparent
);