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',0};
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 ListView_Scroll(hwnd
, 10, 0);
2140 rect
.left
= LVIR_BOUNDS
;
2142 rect
.right
= rect
.bottom
= 0;
2143 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2144 ok(r
!= 0, "Expected not-null LRESULT\n");
2145 expect(90, rect
.left
);
2146 expect(240, rect
.right
);
2148 ListView_Scroll(hwnd
, -10, 0);
2150 DestroyWindow(hwnd
);
2152 /* try it for non LVS_REPORT style */
2153 hwnd
= CreateWindow("SysListView32", "Test", LVS_ICON
, 0, 0, 100, 100, NULL
, NULL
,
2154 GetModuleHandle(NULL
), 0);
2155 rect
.left
= LVIR_BOUNDS
;
2157 rect
.right
= rect
.bottom
= -10;
2158 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2159 ok(r
== 0, "Expected not-null LRESULT\n");
2160 /* rect is unchanged */
2161 expect(0, rect
.left
);
2162 expect(-10, rect
.right
);
2163 expect(1, rect
.top
);
2164 expect(-10, rect
.bottom
);
2165 DestroyWindow(hwnd
);
2168 /* comparison callback for test_sorting */
2169 static INT WINAPI
test_CallBackCompare(LPARAM first
, LPARAM second
, LPARAM lParam
)
2171 if (first
== second
) return 0;
2172 return (first
> second
? 1 : -1);
2175 static void test_sorting(void)
2181 static CHAR names
[][5] = {"A", "B", "C", "D", "0"};
2184 hwnd
= create_listview_control(LVS_REPORT
);
2185 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2187 /* insert some items */
2188 item
.mask
= LVIF_PARAM
| LVIF_STATE
;
2189 item
.state
= LVIS_SELECTED
;
2193 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2196 item
.mask
= LVIF_PARAM
;
2200 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2203 item
.mask
= LVIF_STATE
| LVIF_PARAM
;
2204 item
.state
= LVIS_SELECTED
;
2208 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2211 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2214 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2217 r
= SendMessage(hwnd
, LVM_SORTITEMS
, 0, (LPARAM
)test_CallBackCompare
);
2220 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2222 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2224 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_SELECTED
);
2226 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 1, LVIS_SELECTED
);
2227 expect(LVIS_SELECTED
, r
);
2228 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 2, LVIS_SELECTED
);
2229 expect(LVIS_SELECTED
, r
);
2231 DestroyWindow(hwnd
);
2233 /* switch to LVS_SORTASCENDING when some items added */
2234 hwnd
= create_listview_control(LVS_REPORT
);
2235 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2237 item
.mask
= LVIF_TEXT
;
2240 item
.pszText
= names
[1];
2241 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2244 item
.mask
= LVIF_TEXT
;
2247 item
.pszText
= names
[2];
2248 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2251 item
.mask
= LVIF_TEXT
;
2254 item
.pszText
= names
[0];
2255 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2258 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2259 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTASCENDING
);
2260 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2261 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2263 /* no sorting performed when switched to LVS_SORTASCENDING */
2264 item
.mask
= LVIF_TEXT
;
2266 item
.pszText
= buff
;
2267 item
.cchTextMax
= sizeof(buff
);
2268 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2270 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2273 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2275 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2278 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2280 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2282 /* adding new item doesn't resort list */
2283 item
.mask
= LVIF_TEXT
;
2286 item
.pszText
= names
[3];
2287 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2290 item
.mask
= LVIF_TEXT
;
2292 item
.pszText
= buff
;
2293 item
.cchTextMax
= sizeof(buff
);
2294 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2296 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2299 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2301 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2304 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2306 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2309 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2311 ok(lstrcmp(buff
, names
[3]) == 0, "Expected '%s', got '%s'\n", names
[3], buff
);
2313 /* corner case - item should be placed at first position */
2314 item
.mask
= LVIF_TEXT
;
2317 item
.pszText
= names
[4];
2318 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2322 item
.pszText
= buff
;
2323 item
.cchTextMax
= sizeof(buff
);
2324 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2326 ok(lstrcmp(buff
, names
[4]) == 0, "Expected '%s', got '%s'\n", names
[4], buff
);
2329 item
.pszText
= buff
;
2330 item
.cchTextMax
= sizeof(buff
);
2331 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2333 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2336 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2338 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2341 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2343 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2346 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2348 ok(lstrcmp(buff
, names
[3]) == 0, "Expected '%s', got '%s'\n", names
[3], buff
);
2350 DestroyWindow(hwnd
);
2353 static void test_ownerdata(void)
2356 LONG_PTR style
, ret
;
2360 /* it isn't possible to set LVS_OWNERDATA after creation */
2363 win_skip("set LVS_OWNERDATA after creation leads to crash on < 5.80\n");
2367 hwnd
= create_listview_control(LVS_REPORT
);
2368 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2369 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2370 ok(!(style
& LVS_OWNERDATA
) && style
, "LVS_OWNERDATA isn't expected\n");
2372 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2374 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_OWNERDATA
);
2375 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2376 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2377 "try to switch to LVS_OWNERDATA seq", FALSE
);
2379 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2380 ok(!(style
& LVS_OWNERDATA
), "LVS_OWNERDATA isn't expected\n");
2381 DestroyWindow(hwnd
);
2384 /* try to set LVS_OWNERDATA after creation just having it */
2385 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2386 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2387 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2388 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2390 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2392 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_OWNERDATA
);
2393 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2394 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2395 "try to switch to LVS_OWNERDATA seq", FALSE
);
2396 DestroyWindow(hwnd
);
2398 /* try to remove LVS_OWNERDATA after creation just having it */
2401 win_skip("remove LVS_OWNERDATA after creation leads to crash on < 5.80\n");
2405 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2406 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2407 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2408 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2410 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2412 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_OWNERDATA
);
2413 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2414 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2415 "try to switch to LVS_OWNERDATA seq", FALSE
);
2416 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2417 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2418 DestroyWindow(hwnd
);
2421 /* try select an item */
2422 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2423 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2424 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2425 ok(res
!= 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2426 res
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2428 memset(&item
, 0, sizeof(item
));
2429 item
.stateMask
= LVIS_SELECTED
;
2430 item
.state
= LVIS_SELECTED
;
2431 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2433 res
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2435 res
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2437 DestroyWindow(hwnd
);
2439 /* LVM_SETITEM is unsupported on LVS_OWNERDATA */
2440 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2441 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2442 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2443 ok(res
!= 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2444 res
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2446 memset(&item
, 0, sizeof(item
));
2447 item
.mask
= LVIF_STATE
;
2449 item
.stateMask
= LVIS_SELECTED
;
2450 item
.state
= LVIS_SELECTED
;
2451 res
= SendMessageA(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
2453 DestroyWindow(hwnd
);
2455 /* check notifications after focused/selected changed */
2456 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2457 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2458 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 20, 0);
2459 ok(res
!= 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2461 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2463 memset(&item
, 0, sizeof(item
));
2464 item
.stateMask
= LVIS_SELECTED
;
2465 item
.state
= LVIS_SELECTED
;
2466 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2469 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownderdata_select_focus_parent_seq
,
2470 "ownerdata select notification", TRUE
);
2472 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2474 memset(&item
, 0, sizeof(item
));
2475 item
.stateMask
= LVIS_FOCUSED
;
2476 item
.state
= LVIS_FOCUSED
;
2477 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2480 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownderdata_select_focus_parent_seq
,
2481 "ownerdata focus notification", TRUE
);
2483 /* select all, check notifications */
2484 item
.stateMask
= LVIS_SELECTED
;
2486 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2489 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2491 item
.stateMask
= LVIS_SELECTED
;
2492 item
.state
= LVIS_SELECTED
;
2494 g_dump_itemchanged
= TRUE
;
2495 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2497 g_dump_itemchanged
= FALSE
;
2499 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2500 "ownerdata select all notification", TRUE
);
2502 /* select all again, note that all items are selected already */
2503 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2504 item
.stateMask
= LVIS_SELECTED
;
2505 item
.state
= LVIS_SELECTED
;
2506 g_dump_itemchanged
= TRUE
;
2507 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2509 g_dump_itemchanged
= FALSE
;
2510 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2511 "ownerdata select all notification", TRUE
);
2513 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2514 item
.stateMask
= LVIS_SELECTED
;
2516 g_dump_itemchanged
= TRUE
;
2517 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2519 g_dump_itemchanged
= FALSE
;
2520 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_deselect_all_parent_seq
,
2521 "ownerdata deselect all notification", TRUE
);
2523 /* select one, then deselect all */
2524 item
.stateMask
= LVIS_SELECTED
;
2525 item
.state
= LVIS_SELECTED
;
2526 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2528 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2529 item
.stateMask
= LVIS_SELECTED
;
2531 g_dump_itemchanged
= TRUE
;
2532 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2534 g_dump_itemchanged
= FALSE
;
2535 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_deselect_all_parent_seq
,
2536 "ownerdata select all notification", TRUE
);
2538 /* remove focused, try to focus all */
2539 item
.stateMask
= LVIS_FOCUSED
;
2540 item
.state
= LVIS_FOCUSED
;
2541 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2543 item
.stateMask
= LVIS_FOCUSED
;
2545 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2547 item
.stateMask
= LVIS_FOCUSED
;
2548 res
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_FOCUSED
);
2550 /* setting all to focused returns failure value */
2551 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2552 item
.stateMask
= LVIS_FOCUSED
;
2553 item
.state
= LVIS_FOCUSED
;
2554 g_dump_itemchanged
= TRUE
;
2555 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2557 g_dump_itemchanged
= FALSE
;
2558 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2559 "ownerdata focus all notification", FALSE
);
2560 /* focus single item, remove all */
2561 item
.stateMask
= LVIS_FOCUSED
;
2562 item
.state
= LVIS_FOCUSED
;
2563 res
= SendMessage(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2565 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2566 item
.stateMask
= LVIS_FOCUSED
;
2568 g_dump_itemchanged
= TRUE
;
2569 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2571 g_dump_itemchanged
= FALSE
;
2572 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_defocus_all_parent_seq
,
2573 "ownerdata remove focus all notification", TRUE
);
2575 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2576 item
.stateMask
= LVIS_CUT
;
2577 item
.state
= LVIS_CUT
;
2578 g_dump_itemchanged
= TRUE
;
2579 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2581 g_dump_itemchanged
= FALSE
;
2582 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2583 "ownerdata cut all notification", TRUE
);
2584 /* all marked cut, try again */
2585 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2586 item
.stateMask
= LVIS_CUT
;
2587 item
.state
= LVIS_CUT
;
2588 g_dump_itemchanged
= TRUE
;
2589 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2591 g_dump_itemchanged
= FALSE
;
2592 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2593 "ownerdata cut all notification #2", TRUE
);
2595 DestroyWindow(hwnd
);
2597 /* check notifications on LVM_GETITEM */
2598 /* zero callback mask */
2599 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2600 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2601 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2602 ok(res
!= 0, "Expected LVM_SETITEMCOUNT to succeed\n");
2604 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2606 memset(&item
, 0, sizeof(item
));
2607 item
.stateMask
= LVIS_SELECTED
;
2608 item
.mask
= LVIF_STATE
;
2609 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2612 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2613 "ownerdata getitem selected state 1", FALSE
);
2615 /* non zero callback mask but not we asking for */
2616 res
= SendMessageA(hwnd
, LVM_SETCALLBACKMASK
, LVIS_OVERLAYMASK
, 0);
2619 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2621 memset(&item
, 0, sizeof(item
));
2622 item
.stateMask
= LVIS_SELECTED
;
2623 item
.mask
= LVIF_STATE
;
2624 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2627 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2628 "ownerdata getitem selected state 2", FALSE
);
2630 /* LVIS_OVERLAYMASK callback mask, asking for index */
2631 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2633 memset(&item
, 0, sizeof(item
));
2634 item
.stateMask
= LVIS_OVERLAYMASK
;
2635 item
.mask
= LVIF_STATE
;
2636 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2639 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
2640 "ownerdata getitem selected state 2", FALSE
);
2642 DestroyWindow(hwnd
);
2644 /* LVS_SORTASCENDING/LVS_SORTDESCENDING aren't compatible with LVS_OWNERDATA */
2645 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_SORTASCENDING
| LVS_REPORT
);
2646 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2647 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2648 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
2649 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2650 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_SORTASCENDING
);
2651 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2652 ok(!(style
& LVS_SORTASCENDING
), "Expected LVS_SORTASCENDING not set\n");
2653 DestroyWindow(hwnd
);
2654 /* apparently it's allowed to switch these style on after creation */
2655 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2656 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2657 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2658 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
2659 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTASCENDING
);
2660 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2661 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2662 DestroyWindow(hwnd
);
2664 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2665 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2666 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2667 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
2668 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTDESCENDING
);
2669 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2670 ok(style
& LVS_SORTDESCENDING
, "Expected LVS_SORTDESCENDING to be set\n");
2671 DestroyWindow(hwnd
);
2674 static void test_norecompute(void)
2676 static CHAR testA
[] = "test";
2682 /* self containing control */
2683 hwnd
= create_listview_control(LVS_REPORT
);
2684 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2685 memset(&item
, 0, sizeof(item
));
2686 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
2688 item
.stateMask
= LVIS_SELECTED
;
2689 item
.state
= LVIS_SELECTED
;
2690 item
.pszText
= testA
;
2691 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
2693 /* retrieve with LVIF_NORECOMPUTE */
2694 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
2696 item
.pszText
= buff
;
2697 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
2698 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
2700 ok(lstrcmp(buff
, testA
) == 0, "Expected (%s), got (%s)\n", testA
, buff
);
2702 item
.mask
= LVIF_TEXT
;
2704 item
.pszText
= LPSTR_TEXTCALLBACK
;
2705 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
2708 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
2710 item
.pszText
= buff
;
2711 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
2713 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2714 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
2716 ok(item
.pszText
== LPSTR_TEXTCALLBACK
, "Expected (%p), got (%p)\n",
2717 LPSTR_TEXTCALLBACK
, (VOID
*)item
.pszText
);
2718 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "retrieve with LVIF_NORECOMPUTE seq", FALSE
);
2720 DestroyWindow(hwnd
);
2723 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2724 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2726 item
.mask
= LVIF_STATE
;
2727 item
.stateMask
= LVIS_SELECTED
;
2728 item
.state
= LVIS_SELECTED
;
2730 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
2733 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
2735 item
.pszText
= buff
;
2736 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
2737 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2738 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
2740 ok(item
.pszText
== LPSTR_TEXTCALLBACK
, "Expected (%p), got (%p)\n",
2741 LPSTR_TEXTCALLBACK
, (VOID
*)item
.pszText
);
2742 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "retrieve with LVIF_NORECOMPUTE seq 2", FALSE
);
2744 DestroyWindow(hwnd
);
2747 static void test_nosortheader(void)
2752 hwnd
= create_listview_control(LVS_REPORT
);
2753 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2755 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
2756 ok(IsWindow(header
), "header expected\n");
2758 style
= GetWindowLongPtr(header
, GWL_STYLE
);
2759 ok(style
& HDS_BUTTONS
, "expected header to have HDS_BUTTONS\n");
2761 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
2762 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
| LVS_NOSORTHEADER
);
2763 /* HDS_BUTTONS retained */
2764 style
= GetWindowLongPtr(header
, GWL_STYLE
);
2765 ok(style
& HDS_BUTTONS
, "expected header to retain HDS_BUTTONS\n");
2767 DestroyWindow(hwnd
);
2769 /* create with LVS_NOSORTHEADER */
2770 hwnd
= create_listview_control(LVS_NOSORTHEADER
| LVS_REPORT
);
2771 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2773 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
2774 ok(IsWindow(header
), "header expected\n");
2776 style
= GetWindowLongPtr(header
, GWL_STYLE
);
2777 ok(!(style
& HDS_BUTTONS
), "expected header to have no HDS_BUTTONS\n");
2779 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
2780 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
& ~LVS_NOSORTHEADER
);
2781 /* not changed here */
2782 style
= GetWindowLongPtr(header
, GWL_STYLE
);
2783 ok(!(style
& HDS_BUTTONS
), "expected header to have no HDS_BUTTONS\n");
2785 DestroyWindow(hwnd
);
2788 static void test_setredraw(void)
2796 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2797 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2799 /* Passing WM_SETREDRAW to DefWinProc removes WS_VISIBLE.
2800 ListView seems to handle it internally without DefWinProc */
2802 /* default value first */
2803 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
2806 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
2807 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
2808 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2810 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
2811 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
2812 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
2815 /* check update rect after redrawing */
2816 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2818 InvalidateRect(hwnd
, NULL
, FALSE
);
2819 RedrawWindow(hwnd
, NULL
, NULL
, RDW_UPDATENOW
);
2820 rect
.right
= rect
.bottom
= 1;
2821 GetUpdateRect(hwnd
, &rect
, FALSE
);
2822 expect(0, rect
.right
);
2823 expect(0, rect
.bottom
);
2826 hdc
= GetWindowDC(hwndparent
);
2827 ret
= SendMessage(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
2829 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2831 ret
= SendMessage(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
2833 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
2835 ReleaseDC(hwndparent
, hdc
);
2837 /* check notification messages to show that repainting is disabled */
2838 ret
= SendMessage(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2840 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2842 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2844 InvalidateRect(hwnd
, NULL
, TRUE
);
2846 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2847 "redraw after WM_SETREDRAW (FALSE)", FALSE
);
2849 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, CLR_NONE
);
2851 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2852 InvalidateRect(hwnd
, NULL
, TRUE
);
2854 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2855 "redraw after WM_SETREDRAW (FALSE) with CLR_NONE bkgnd", FALSE
);
2857 /* message isn't forwarded to header */
2858 subclass_header(hwnd
);
2859 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2860 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
2862 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, setredraw_seq
,
2863 "WM_SETREDRAW: not forwarded to header", FALSE
);
2865 DestroyWindow(hwnd
);
2868 static void test_hittest(void)
2874 static CHAR text
[] = "1234567890ABCDEFGHIJKLMNOPQRST";
2877 HIMAGELIST himl
, himl2
;
2880 hwnd
= create_listview_control(LVS_REPORT
);
2881 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2883 /* LVS_REPORT with a single subitem (2 columns) */
2884 insert_column(hwnd
, 0);
2885 insert_column(hwnd
, 1);
2886 insert_item(hwnd
, 0);
2889 /* the only purpose of that line is to be as long as a half item rect */
2890 item
.pszText
= text
;
2891 r
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&item
);
2894 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
2896 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(100, 0));
2899 memset(&bounds
, 0, sizeof(bounds
));
2900 bounds
.left
= LVIR_BOUNDS
;
2901 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&bounds
);
2902 ok(bounds
.bottom
- bounds
.top
> 0, "Expected non zero item height\n");
2903 ok(bounds
.right
- bounds
.left
> 0, "Expected non zero item width\n");
2904 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pos
);
2907 /* LVS_EX_FULLROWSELECT not set, no icons attached */
2908 x
= pos
.x
+ 50; /* column half width */
2909 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2910 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMLABEL
, 0, FALSE
, FALSE
, __LINE__
);
2911 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2912 x
= pos
.x
+ 150; /* outside column */
2913 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2914 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
, __LINE__
);
2915 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2916 y
= (bounds
.bottom
- bounds
.top
) / 2;
2917 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
, __LINE__
);
2918 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2919 /* outside possible client rectangle (to right) */
2921 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2922 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
, __LINE__
);
2923 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2924 y
= (bounds
.bottom
- bounds
.top
) / 2;
2925 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
, __LINE__
);
2926 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2927 /* subitem returned with -1 item too */
2930 test_lvm_subitemhittest(hwnd
, x
, y
, -1, 1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2931 /* parent client area is 100x100 by default */
2932 MoveWindow(hwnd
, 0, 0, 300, 100, FALSE
);
2933 x
= pos
.x
+ 150; /* outside column */
2934 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2935 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_NOWHERE
, 0, FALSE
, FALSE
, __LINE__
);
2936 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2937 y
= (bounds
.bottom
- bounds
.top
) / 2;
2938 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_NOWHERE
, 0, FALSE
, TRUE
, __LINE__
);
2939 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2940 /* the same with LVS_EX_FULLROWSELECT */
2941 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_FULLROWSELECT
);
2942 x
= pos
.x
+ 150; /* outside column */
2943 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2944 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEM
, LVHT_ONITEMLABEL
, FALSE
, FALSE
, __LINE__
);
2945 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2946 y
= (bounds
.bottom
- bounds
.top
) / 2;
2947 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2948 MoveWindow(hwnd
, 0, 0, 100, 100, FALSE
);
2949 x
= pos
.x
+ 150; /* outside column */
2950 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2951 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
, __LINE__
);
2952 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2953 y
= (bounds
.bottom
- bounds
.top
) / 2;
2954 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
, __LINE__
);
2955 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
, __LINE__
);
2956 /* outside possible client rectangle (to right) */
2958 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2959 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
, __LINE__
);
2960 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2961 y
= (bounds
.bottom
- bounds
.top
) / 2;
2962 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
, __LINE__
);
2963 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
, __LINE__
);
2964 /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
2965 himl
= ImageList_Create(16, 16, 0, 4, 4);
2966 ok(himl
!= NULL
, "failed to create imagelist\n");
2967 hbmp
= CreateBitmap(16, 16, 1, 1, NULL
);
2968 ok(hbmp
!= NULL
, "failed to create bitmap\n");
2969 r
= ImageList_Add(himl
, hbmp
, 0);
2970 ok(r
== 0, "should be zero\n");
2971 hbmp
= CreateBitmap(16, 16, 1, 1, NULL
);
2972 ok(hbmp
!= NULL
, "failed to create bitmap\n");
2973 r
= ImageList_Add(himl
, hbmp
, 0);
2974 ok(r
== 1, "should be one\n");
2976 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl
);
2977 ok(r
== 0, "should return zero\n");
2979 item
.mask
= LVIF_IMAGE
;
2983 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
2987 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
2988 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMSTATEICON
, 0, FALSE
, FALSE
, __LINE__
);
2989 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
2990 y
= (bounds
.bottom
- bounds
.top
) / 2;
2991 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
2993 /* state icons indices are 1 based, check with valid index */
2994 item
.mask
= LVIF_STATE
;
2995 item
.state
= INDEXTOSTATEIMAGEMASK(1);
2996 item
.stateMask
= LVIS_STATEIMAGEMASK
;
2999 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3003 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3004 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMSTATEICON
, 0, FALSE
, FALSE
, __LINE__
);
3005 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
3006 y
= (bounds
.bottom
- bounds
.top
) / 2;
3007 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
3009 himl2
= (HIMAGELIST
)SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, 0);
3010 ok(himl2
== himl
, "should return handle\n");
3012 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl
);
3013 ok(r
== 0, "should return zero\n");
3016 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3017 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMICON
, 0, FALSE
, FALSE
, __LINE__
);
3018 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
3019 y
= (bounds
.bottom
- bounds
.top
) / 2;
3020 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMICON
, FALSE
, FALSE
, FALSE
, __LINE__
);
3022 DestroyWindow(hwnd
);
3025 static void test_getviewrect(void)
3032 hwnd
= create_listview_control(LVS_REPORT
);
3033 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3036 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3039 insert_column(hwnd
, 0);
3040 insert_column(hwnd
, 1);
3042 memset(&item
, 0, sizeof(item
));
3045 SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3047 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
3049 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(120, 0));
3052 rect
.left
= rect
.right
= rect
.top
= rect
.bottom
= -1;
3053 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3055 /* left is set to (2e31-1) - XP SP2 */
3056 expect(0, rect
.right
);
3057 expect(0, rect
.top
);
3058 expect(0, rect
.bottom
);
3060 /* switch to LVS_ICON */
3061 SetWindowLong(hwnd
, GWL_STYLE
, GetWindowLong(hwnd
, GWL_STYLE
) & ~LVS_REPORT
);
3063 rect
.left
= rect
.right
= rect
.top
= rect
.bottom
= -1;
3064 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3066 expect(0, rect
.left
);
3067 expect(0, rect
.top
);
3068 /* precise value differs for 2k, XP and Vista */
3069 ok(rect
.bottom
> 0, "Expected positive bottom value, got %d\n", rect
.bottom
);
3070 ok(rect
.right
> 0, "Expected positive right value, got %d\n", rect
.right
);
3072 DestroyWindow(hwnd
);
3075 static void test_getitemposition(void)
3082 hwnd
= create_listview_control(LVS_REPORT
);
3083 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3084 header
= subclass_header(hwnd
);
3086 /* LVS_REPORT, single item, no columns added */
3087 insert_item(hwnd
, 0);
3089 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3092 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3094 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getitemposition_seq1
, "get item position 1", FALSE
);
3096 /* LVS_REPORT, single item, single column */
3097 insert_column(hwnd
, 0);
3099 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3102 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3104 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getitemposition_seq2
, "get item position 2", TRUE
);
3106 memset(&rect
, 0, sizeof(rect
));
3107 SendMessage(header
, HDM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3110 /* offset by header height */
3111 expect(rect
.bottom
- rect
.top
, pt
.y
);
3113 DestroyWindow(hwnd
);
3116 static void test_columnscreation(void)
3121 hwnd
= create_listview_control(LVS_REPORT
);
3122 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3124 insert_item(hwnd
, 0);
3126 /* headers columns aren't created automatically */
3127 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3128 ok(IsWindow(header
), "Expected header handle\n");
3129 r
= SendMessage(header
, HDM_GETITEMCOUNT
, 0, 0);
3132 DestroyWindow(hwnd
);
3135 static void test_getitemrect(void)
3147 /* rectangle isn't empty for empty text items */
3148 hwnd
= create_listview_control(LVS_LIST
);
3149 memset(&item
, 0, sizeof(item
));
3152 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3154 rect
.left
= LVIR_LABEL
;
3155 SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3156 expect(0, rect
.left
);
3157 expect(0, rect
.top
);
3158 todo_wine
expect(96, rect
.right
);
3159 DestroyWindow(hwnd
);
3161 hwnd
= create_listview_control(LVS_REPORT
);
3162 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3165 memset(&item
, 0, sizeof(item
));
3168 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3171 rect
.left
= LVIR_BOUNDS
;
3172 rect
.right
= rect
.top
= rect
.bottom
= -1;
3173 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3176 /* zero width rectangle with no padding */
3177 expect(0, rect
.left
);
3178 expect(0, rect
.right
);
3180 insert_column(hwnd
, 0);
3181 insert_column(hwnd
, 1);
3183 col
.mask
= LVCF_WIDTH
;
3185 r
= SendMessage(hwnd
, LVM_SETCOLUMN
, 0, (LPARAM
)&col
);
3188 col
.mask
= LVCF_WIDTH
;
3190 r
= SendMessage(hwnd
, LVM_SETCOLUMN
, 1, (LPARAM
)&col
);
3193 rect
.left
= LVIR_BOUNDS
;
3194 rect
.right
= rect
.top
= rect
.bottom
= -1;
3195 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3198 /* still no left padding */
3199 expect(0, rect
.left
);
3200 expect(150, rect
.right
);
3202 rect
.left
= LVIR_SELECTBOUNDS
;
3203 rect
.right
= rect
.top
= rect
.bottom
= -1;
3204 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3207 expect(2, rect
.left
);
3209 rect
.left
= LVIR_LABEL
;
3210 rect
.right
= rect
.top
= rect
.bottom
= -1;
3211 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3213 /* padding, column width */
3214 expect(2, rect
.left
);
3215 expect(50, rect
.right
);
3217 /* no icons attached */
3218 rect
.left
= LVIR_ICON
;
3219 rect
.right
= rect
.top
= rect
.bottom
= -1;
3220 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3223 expect(2, rect
.left
);
3224 expect(2, rect
.right
);
3227 order
[0] = 1; order
[1] = 0;
3228 r
= SendMessage(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
3231 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3233 /* 1 indexed column width + padding */
3235 /* rect is at zero too */
3236 rect
.left
= LVIR_BOUNDS
;
3237 rect
.right
= rect
.top
= rect
.bottom
= -1;
3238 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3240 expect(0, rect
.left
);
3241 /* just width sum */
3242 expect(150, rect
.right
);
3244 rect
.left
= LVIR_SELECTBOUNDS
;
3245 rect
.right
= rect
.top
= rect
.bottom
= -1;
3246 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3248 /* column width + padding */
3249 expect(102, rect
.left
);
3251 /* back to initial order */
3252 order
[0] = 0; order
[1] = 1;
3253 r
= SendMessage(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
3257 himl
= ImageList_Create(16, 16, 0, 2, 2);
3258 ok(himl
!= NULL
, "failed to create imagelist\n");
3259 hbm
= CreateBitmap(16, 16, 1, 1, NULL
);
3260 ok(hbm
!= NULL
, "failed to create bitmap\n");
3261 r
= ImageList_Add(himl
, hbm
, 0);
3262 ok(r
== 0, "should be zero\n");
3263 hbm
= CreateBitmap(16, 16, 1, 1, NULL
);
3264 ok(hbm
!= NULL
, "failed to create bitmap\n");
3265 r
= ImageList_Add(himl
, hbm
, 0);
3266 ok(r
== 1, "should be one\n");
3268 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl
);
3269 ok(r
== 0, "should return zero\n");
3271 item
.mask
= LVIF_STATE
;
3272 item
.state
= INDEXTOSTATEIMAGEMASK(1);
3273 item
.stateMask
= LVIS_STATEIMAGEMASK
;
3276 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3280 rect
.left
= LVIR_ICON
;
3281 rect
.right
= rect
.top
= rect
.bottom
= -1;
3282 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3284 /* padding + stateicon width */
3285 expect(18, rect
.left
);
3286 expect(18, rect
.right
);
3288 rect
.left
= LVIR_LABEL
;
3289 rect
.right
= rect
.top
= rect
.bottom
= -1;
3290 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3292 /* padding + stateicon width -> column width */
3293 expect(18, rect
.left
);
3294 expect(50, rect
.right
);
3296 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, 0);
3297 ok(r
!= 0, "should return current list handle\n");
3299 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl
);
3300 ok(r
== 0, "should return zero\n");
3302 item
.mask
= LVIF_STATE
| LVIF_IMAGE
;
3305 item
.stateMask
= ~0;
3308 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3312 rect
.left
= LVIR_ICON
;
3313 rect
.right
= rect
.top
= rect
.bottom
= -1;
3314 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3316 /* padding, icon width */
3317 expect(2, rect
.left
);
3318 expect(18, rect
.right
);
3320 rect
.left
= LVIR_LABEL
;
3321 rect
.right
= rect
.top
= rect
.bottom
= -1;
3322 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3324 /* padding + icon width -> column width */
3325 expect(18, rect
.left
);
3326 expect(50, rect
.right
);
3329 rect
.left
= LVIR_SELECTBOUNDS
;
3330 rect
.right
= rect
.top
= rect
.bottom
= -1;
3331 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3333 /* padding, column width */
3334 expect(2, rect
.left
);
3335 expect(50, rect
.right
);
3337 /* try with indentation */
3338 item
.mask
= LVIF_INDENT
;
3342 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3346 rect
.left
= LVIR_BOUNDS
;
3347 rect
.right
= rect
.top
= rect
.bottom
= -1;
3348 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3350 /* padding + 1 icon width, column width */
3351 expect(0, rect
.left
);
3352 expect(150, rect
.right
);
3355 rect
.left
= LVIR_SELECTBOUNDS
;
3356 rect
.right
= rect
.top
= rect
.bottom
= -1;
3357 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3359 /* padding + 1 icon width, column width */
3360 expect(2 + 16, rect
.left
);
3361 expect(50, rect
.right
);
3364 rect
.left
= LVIR_LABEL
;
3365 rect
.right
= rect
.top
= rect
.bottom
= -1;
3366 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3368 /* padding + 2 icon widths, column width */
3369 expect(2 + 16*2, rect
.left
);
3370 expect(50, rect
.right
);
3373 rect
.left
= LVIR_ICON
;
3374 rect
.right
= rect
.top
= rect
.bottom
= -1;
3375 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3377 /* padding + 1 icon width indentation, icon width */
3378 expect(2 + 16, rect
.left
);
3379 expect(34, rect
.right
);
3382 DestroyWindow(hwnd
);
3385 static void test_editbox(void)
3387 HWND hwnd
, hwndedit
, hwndedit2
;
3390 static CHAR testitemA
[] = "testitem";
3391 static CHAR testitem1A
[] = "testitem1";
3392 static CHAR buffer
[10];
3394 hwnd
= create_listview_control(LVS_EDITLABELS
| LVS_REPORT
);
3395 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3397 insert_column(hwnd
, 0);
3399 memset(&item
, 0, sizeof(item
));
3400 item
.mask
= LVIF_TEXT
;
3401 item
.pszText
= testitemA
;
3404 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3407 /* setting focus is necessary */
3409 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3410 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3412 /* modify initial string */
3413 r
= SendMessage(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem1A
);
3415 /* return focus to listview */
3418 memset(&item
, 0, sizeof(item
));
3419 item
.mask
= LVIF_TEXT
;
3420 item
.pszText
= buffer
;
3421 item
.cchTextMax
= 10;
3424 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3427 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
3429 /* send LVM_EDITLABEL on already created edit */
3431 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3432 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3433 /* focus will be set to edit */
3434 ok(GetFocus() == hwndedit
, "Expected Edit window to be focused\n");
3435 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3436 ok(IsWindow(hwndedit2
), "Expected Edit window to be created\n");
3438 /* creating label disabled when control isn't focused */
3440 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3441 todo_wine
ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3443 /* check EN_KILLFOCUS handling */
3444 memset(&item
, 0, sizeof(item
));
3445 item
.pszText
= testitemA
;
3448 r
= SendMessage(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
3452 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3453 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3454 /* modify edit and notify control that it lost focus */
3455 r
= SendMessage(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem1A
);
3457 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
3459 memset(&item
, 0, sizeof(item
));
3460 item
.pszText
= buffer
;
3461 item
.cchTextMax
= 10;
3464 r
= SendMessage(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
3465 expect(lstrlen(item
.pszText
), r
);
3466 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
3467 ok(!IsWindow(hwndedit
), "Expected Edit window to be freed\n");
3468 /* end edit without saving */
3470 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3471 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3472 r
= SendMessage(hwndedit
, WM_KEYDOWN
, VK_ESCAPE
, 0);
3474 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3475 "edit box - end edit, no change, escape", TRUE
);
3476 /* end edit with saving */
3478 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3479 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3480 r
= SendMessage(hwndedit
, WM_KEYDOWN
, VK_RETURN
, 0);
3482 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3483 "edit box - end edit, no change, return", TRUE
);
3485 memset(&item
, 0, sizeof(item
));
3486 item
.pszText
= buffer
;
3487 item
.cchTextMax
= 10;
3490 r
= SendMessage(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
3491 expect(lstrlen(item
.pszText
), r
);
3492 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
3494 /* LVM_EDITLABEL with -1 destroys current edit */
3495 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_GETEDITCONTROL
, 0, 0);
3496 ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3497 /* no edit present */
3498 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -1, 0);
3499 ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3500 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3501 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3503 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3504 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -1, 0);
3505 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3506 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3507 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3508 /* check another negative value */
3509 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3510 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3511 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3512 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -2, 0);
3513 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3514 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3515 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3516 /* and value greater than max item index */
3517 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3518 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3519 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3520 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
3521 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, r
, 0);
3522 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3523 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3524 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3526 /* messaging tests */
3528 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3530 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3531 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3532 /* testing only sizing messages */
3533 ok_sequence(sequences
, EDITBOX_SEQ_INDEX
, editbox_create_pos
,
3534 "edit box create - sizing", FALSE
);
3536 /* WM_COMMAND with EN_KILLFOCUS isn't forwared to parent */
3538 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3539 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3540 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3541 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
3543 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3544 "edit box WM_COMMAND (EN_KILLFOCUS)", TRUE
);
3546 DestroyWindow(hwnd
);
3549 static void test_notifyformat(void)
3554 hwnd
= create_listview_control(LVS_REPORT
);
3555 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3557 /* CCM_GETUNICODEFORMAT == LVM_GETUNICODEFORMAT,
3558 CCM_SETUNICODEFORMAT == LVM_SETUNICODEFORMAT */
3559 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3561 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_QUERY
);
3563 r
= SendMessage(hwnd
, LVM_SETUNICODEFORMAT
, 1, 0);
3565 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3568 r
= SendMessage(hwnd
, LVM_SETUNICODEFORMAT
, 0, 0);
3570 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3575 win_skip("LVM_GETUNICODEFORMAT is unsupported\n");
3576 DestroyWindow(hwnd
);
3580 DestroyWindow(hwnd
);
3582 /* test failure in parent WM_NOTIFYFORMAT */
3584 hwnd
= create_listview_control(LVS_REPORT
);
3585 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3586 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3587 ok(IsWindow(header
), "expected header to be created\n");
3588 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3590 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3591 ok( r
== 1 || broken(r
== 0), /* win9x */ "Expected 1, got %d\n", r
);
3592 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_QUERY
);
3593 ok(r
!= 0, "Expected valid format\n");
3595 notifyFormat
= NFR_UNICODE
;
3596 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_REQUERY
);
3597 expect(NFR_UNICODE
, r
);
3598 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3600 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3601 ok( r
== 1 || broken(r
== 0), /* win9x */ "Expected 1, got %d\n", r
);
3603 notifyFormat
= NFR_ANSI
;
3604 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_REQUERY
);
3605 expect(NFR_ANSI
, r
);
3606 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3608 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3609 ok( r
== 1 || broken(r
== 0), /* win9x */ "Expected 1, got %d\n", r
);
3611 DestroyWindow(hwnd
);
3613 /* try different unicode window combination and defaults */
3614 if (!GetModuleHandleW(NULL
))
3616 win_skip("Additional notify format tests are incompatible with Win9x\n");
3620 hwndparentW
= create_parent_window(TRUE
);
3621 ok(IsWindow(hwndparentW
), "Unicode parent creation failed\n");
3622 if (!IsWindow(hwndparentW
)) return;
3625 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
3626 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3627 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3628 ok(IsWindow(header
), "expected header to be created\n");
3629 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3631 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3633 DestroyWindow(hwnd
);
3634 /* receiving error code defaulting to ansi */
3636 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
3637 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3638 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3639 ok(IsWindow(header
), "expected header to be created\n");
3640 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3642 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3644 DestroyWindow(hwnd
);
3645 /* receiving ansi code from unicode window, use it */
3646 notifyFormat
= NFR_ANSI
;
3647 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
3648 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3649 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3650 ok(IsWindow(header
), "expected header to be created\n");
3651 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3653 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3655 DestroyWindow(hwnd
);
3656 /* unicode listview with ansi parent window */
3658 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparent
);
3659 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3660 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3661 ok(IsWindow(header
), "expected header to be created\n");
3662 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3664 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3666 DestroyWindow(hwnd
);
3667 /* unicode listview with ansi parent window, return error code */
3669 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparent
);
3670 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3671 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3672 ok(IsWindow(header
), "expected header to be created\n");
3673 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3675 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
3677 DestroyWindow(hwnd
);
3679 DestroyWindow(hwndparentW
);
3682 static void test_indentation(void)
3688 hwnd
= create_listview_control(LVS_REPORT
);
3689 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3691 memset(&item
, 0, sizeof(item
));
3692 item
.mask
= LVIF_INDENT
;
3694 item
.iIndent
= I_INDENTCALLBACK
;
3695 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3698 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3701 item
.mask
= LVIF_INDENT
;
3702 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
3705 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
3706 "get indent dispinfo", FALSE
);
3708 DestroyWindow(hwnd
);
3711 static INT CALLBACK
DummyCompareEx(LPARAM first
, LPARAM second
, LPARAM param
)
3716 static BOOL
is_below_comctl_5(void)
3721 hwnd
= create_listview_control(LVS_REPORT
);
3722 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3723 insert_item(hwnd
, 0);
3725 ret
= SendMessage(hwnd
, LVM_SORTITEMSEX
, 0, (LPARAM
)&DummyCompareEx
);
3727 DestroyWindow(hwnd
);
3732 static void test_get_set_view(void)
3738 /* test style->view mapping */
3739 hwnd
= create_listview_control(LVS_REPORT
);
3740 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3742 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
3743 expect(LV_VIEW_DETAILS
, ret
);
3745 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3747 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
& ~LVS_REPORT
);
3748 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
3749 expect(LV_VIEW_ICON
, ret
);
3751 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3752 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
| LVS_SMALLICON
);
3753 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
3754 expect(LV_VIEW_SMALLICON
, ret
);
3756 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3757 SetWindowLongPtr(hwnd
, GWL_STYLE
, (style
& ~LVS_SMALLICON
) | LVS_LIST
);
3758 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
3759 expect(LV_VIEW_LIST
, ret
);
3761 /* switching view doesn't touch window style */
3762 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_DETAILS
, 0);
3764 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3765 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
3766 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_ICON
, 0);
3768 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3769 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
3770 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_SMALLICON
, 0);
3772 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3773 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
3775 DestroyWindow(hwnd
);
3778 static void test_canceleditlabel(void)
3780 HWND hwnd
, hwndedit
;
3784 static CHAR test
[] = "test";
3785 static const CHAR test1
[] = "test1";
3787 hwnd
= create_listview_control(LVS_EDITLABELS
| LVS_REPORT
);
3788 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3790 insert_item(hwnd
, 0);
3792 /* try without edit created */
3793 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3794 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
3796 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3797 "cancel edit label without edit", FALSE
);
3799 /* cancel without data change */
3801 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3802 ok(IsWindow(hwndedit
), "Expected edit control to be created\n");
3803 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
3805 ok(!IsWindow(hwndedit
), "Expected edit control to be destroyed\n");
3807 /* cancel after data change */
3808 memset(&itema
, 0, sizeof(itema
));
3809 itema
.pszText
= test
;
3810 ret
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&itema
);
3813 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3814 ok(IsWindow(hwndedit
), "Expected edit control to be created\n");
3815 ret
= SetWindowText(hwndedit
, test1
);
3816 ok(ret
!= 0, "Expected edit text to change\n");
3817 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
3819 ok(!IsWindow(hwndedit
), "Expected edit control to be destroyed\n");
3820 memset(&itema
, 0, sizeof(itema
));
3821 itema
.pszText
= buff
;
3822 itema
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
3823 ret
= SendMessage(hwnd
, LVM_GETITEMTEXT
, 0, (LPARAM
)&itema
);
3825 ok(strcmp(buff
, test1
) == 0, "Expected label text not to change\n");
3827 DestroyWindow(hwnd
);
3830 static void test_mapidindex(void)
3835 /* LVM_MAPINDEXTOID unsupported with LVS_OWNERDATA */
3836 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3837 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3838 insert_item(hwnd
, 0);
3839 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
3841 DestroyWindow(hwnd
);
3843 hwnd
= create_listview_control(LVS_REPORT
);
3844 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3846 /* LVM_MAPINDEXTOID with invalid index */
3847 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
3850 insert_item(hwnd
, 0);
3851 insert_item(hwnd
, 1);
3853 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, -1, 0);
3855 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 2, 0);
3858 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
3860 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 1, 0);
3862 /* remove 0 indexed item, id retained */
3863 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
3864 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
3866 /* new id starts from previous value */
3867 insert_item(hwnd
, 1);
3868 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 1, 0);
3871 /* get index by id */
3872 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, -1, 0);
3874 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 0, 0);
3876 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 1, 0);
3878 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 2, 0);
3881 DestroyWindow(hwnd
);
3884 static void test_getitemspacing(void)
3893 cx
= GetSystemMetrics(SM_CXICONSPACING
) - GetSystemMetrics(SM_CXICON
);
3894 cy
= GetSystemMetrics(SM_CYICONSPACING
) - GetSystemMetrics(SM_CYICON
);
3897 hwnd
= create_listview_control(LVS_ICON
);
3898 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3900 expect(cx
, LOWORD(ret
));
3901 expect(cy
, HIWORD(ret
));
3903 /* now try with icons */
3904 himl
= ImageList_Create(40, 40, 0, 4, 4);
3905 ok(himl
!= NULL
, "failed to create imagelist\n");
3906 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
3907 ok(hbmp
!= NULL
, "failed to create bitmap\n");
3908 ret
= ImageList_Add(himl
, hbmp
, 0);
3910 ret
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
3913 itema
.mask
= LVIF_IMAGE
;
3917 ret
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&itema
);
3919 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3921 /* spacing + icon size returned */
3922 expect(cx
+ 40, LOWORD(ret
));
3923 expect(cy
+ 40, HIWORD(ret
));
3925 DestroyWindow(hwnd
);
3927 hwnd
= create_listview_control(LVS_SMALLICON
);
3928 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3930 expect(cx
, LOWORD(ret
));
3931 expect(cy
, HIWORD(ret
));
3933 DestroyWindow(hwnd
);
3935 hwnd
= create_listview_control(LVS_REPORT
);
3936 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3938 expect(cx
, LOWORD(ret
));
3939 expect(cy
, HIWORD(ret
));
3941 DestroyWindow(hwnd
);
3943 hwnd
= create_listview_control(LVS_LIST
);
3944 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
3946 expect(cx
, LOWORD(ret
));
3947 expect(cy
, HIWORD(ret
));
3949 DestroyWindow(hwnd
);
3952 static void test_getcolumnwidth(void)
3960 /* default column width */
3961 hwnd
= create_listview_control(LVS_ICON
);
3962 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
3964 style
= GetWindowLong(hwnd
, GWL_STYLE
);
3965 SetWindowLong(hwnd
, GWL_STYLE
, style
| LVS_LIST
);
3966 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
3967 todo_wine
expect(8, ret
);
3968 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~LVS_LIST
;
3969 SetWindowLong(hwnd
, GWL_STYLE
, style
| LVS_REPORT
);
3971 ret
= SendMessage(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
3973 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
3975 DestroyWindow(hwnd
);
3977 /* default column width with item added */
3978 hwnd
= create_listview_control(LVS_LIST
);
3979 memset(&itema
, 0, sizeof(itema
));
3980 SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&itema
);
3981 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
3982 todo_wine
expect(96, ret
);
3983 DestroyWindow(hwnd
);
3986 static void test_scrollnotify(void)
3991 hwnd
= create_listview_control(LVS_REPORT
);
3993 insert_column(hwnd
, 0);
3994 insert_column(hwnd
, 1);
3995 insert_item(hwnd
, 0);
3997 /* make it scrollable - resize */
3998 ret
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
4000 ret
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(100, 0));
4003 /* try with dummy call */
4004 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4005 ret
= SendMessage(hwnd
, LVM_SCROLL
, 0, 0);
4007 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4008 "scroll notify 1", TRUE
);
4010 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4011 ret
= SendMessage(hwnd
, LVM_SCROLL
, 1, 0);
4013 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4014 "scroll notify 2", TRUE
);
4016 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4017 ret
= SendMessage(hwnd
, LVM_SCROLL
, 1, 1);
4019 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4020 "scroll notify 3", TRUE
);
4022 DestroyWindow(hwnd
);
4025 static void test_LVS_EX_TRANSPARENTBKGND(void)
4031 hwnd
= create_listview_control(LVS_REPORT
);
4033 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, RGB(0, 0, 0));
4036 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_TRANSPARENTBKGND
,
4037 LVS_EX_TRANSPARENTBKGND
);
4039 ret
= SendMessage(hwnd
, LVM_GETBKCOLOR
, 0, 0);
4040 if (ret
!= CLR_NONE
)
4042 win_skip("LVS_EX_TRANSPARENTBKGND unsupported\n");
4043 DestroyWindow(hwnd
);
4047 /* try to set some back color and check this style bit */
4048 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, RGB(0, 0, 0));
4050 ret
= SendMessage(hwnd
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
4051 ok(!(ret
& LVS_EX_TRANSPARENTBKGND
), "Expected LVS_EX_TRANSPARENTBKGND to unset\n");
4053 /* now test what this style actually does */
4054 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_TRANSPARENTBKGND
,
4055 LVS_EX_TRANSPARENTBKGND
);
4057 hdc
= GetWindowDC(hwndparent
);
4059 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4060 SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
4061 ok_sequence(sequences
, PARENT_SEQ_INDEX
, lvs_ex_transparentbkgnd_seq
,
4062 "LVS_EX_TRANSPARENTBKGND parent", FALSE
);
4064 ReleaseDC(hwndparent
, hdc
);
4066 DestroyWindow(hwnd
);
4069 static void test_approximate_viewrect(void)
4077 static CHAR test
[] = "abracadabra, a very long item label";
4079 cx
= GetSystemMetrics(SM_CXICONSPACING
) - GetSystemMetrics(SM_CXICON
);
4080 cy
= GetSystemMetrics(SM_CYICONSPACING
) - GetSystemMetrics(SM_CYICON
);
4082 hwnd
= create_listview_control(LVS_ICON
);
4083 himl
= ImageList_Create(40, 40, 0, 4, 4);
4084 ok(himl
!= NULL
, "failed to create imagelist\n");
4085 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
4086 ok(hbmp
!= NULL
, "failed to create bitmap\n");
4087 ret
= ImageList_Add(himl
, hbmp
, 0);
4089 ret
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
4092 itema
.mask
= LVIF_IMAGE
;
4096 ret
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&itema
);
4099 ret
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(75, 75));
4103 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
4107 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 11, MAKELPARAM(100,100));
4108 ok(MAKELONG(77,827)==ret
,"Incorrect Approximate rect\n");
4110 ret
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(50, 50));
4111 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 11, MAKELPARAM(100,100));
4112 ok(MAKELONG(102,302)==ret
,"Incorrect Approximate rect\n");
4114 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, -1, MAKELPARAM(100,100));
4115 ok(MAKELONG(52,52)==ret
,"Incorrect Approximate rect\n");
4117 itema
.pszText
= test
;
4118 ret
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&itema
);
4120 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, -1, MAKELPARAM(100,100));
4121 ok(MAKELONG(52,52)==ret
,"Incorrect Approximate rect\n");
4123 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 0, MAKELPARAM(100,100));
4124 ok(MAKELONG(52,2)==ret
,"Incorrect Approximate rect\n");
4125 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 1, MAKELPARAM(100,100));
4126 ok(MAKELONG(52,52)==ret
,"Incorrect Approximate rect\n");
4127 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 2, MAKELPARAM(100,100));
4128 ok(MAKELONG(102,52)==ret
,"Incorrect Approximate rect\n");
4129 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 3, MAKELPARAM(100,100));
4130 ok(MAKELONG(102,102)==ret
,"Incorrect Approximate rect\n");
4131 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 4, MAKELPARAM(100,100));
4132 ok(MAKELONG(102,102)==ret
,"Incorrect Approximate rect\n");
4133 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 5, MAKELPARAM(100,100));
4134 ok(MAKELONG(102,152)==ret
,"Incorrect Approximate rect\n");
4135 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 6, MAKELPARAM(100,100));
4136 ok(MAKELONG(102,152)==ret
,"Incorrect Approximate rect\n");
4137 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 7, MAKELPARAM(160,100));
4138 ok(MAKELONG(152,152)==ret
,"Incorrect Approximate rect\n");
4140 DestroyWindow(hwnd
);
4143 static void test_finditem(void)
4150 hwnd
= create_listview_control(LVS_REPORT
);
4151 insert_item(hwnd
, 0);
4153 memset(&fi
, 0, sizeof(fi
));
4155 /* full string search, inserted text was "foo" */
4157 fi
.flags
= LVFI_STRING
;
4159 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4161 /* partial string search, inserted text was "foo" */
4163 fi
.flags
= LVFI_STRING
| LVFI_PARTIAL
;
4165 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4167 /* partial string search, part after start char */
4169 fi
.flags
= LVFI_STRING
| LVFI_PARTIAL
;
4171 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4174 /* try with LVFI_SUBSTRING */
4176 fi
.flags
= LVFI_SUBSTRING
;
4178 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4181 win_skip("LVFI_SUBSTRING not supported\n");
4182 DestroyWindow(hwnd
);
4187 fi
.flags
= LVFI_SUBSTRING
;
4189 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4192 fi
.flags
= LVFI_SUBSTRING
;
4194 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4198 fi
.flags
= LVFI_SUBSTRING
| LVFI_STRING
;
4200 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4203 DestroyWindow(hwnd
);
4206 static void test_LVS_EX_HEADERINALLVIEWS(void)
4211 hwnd
= create_listview_control(LVS_ICON
);
4213 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4214 LVS_EX_HEADERINALLVIEWS
);
4216 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4217 if (!IsWindow(header
))
4219 win_skip("LVS_EX_HEADERINALLVIEWS unsupported\n");
4220 DestroyWindow(hwnd
);
4224 /* LVS_NOCOLUMNHEADER works as before */
4225 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4226 SetWindowLongW(hwnd
, GWL_STYLE
, style
| LVS_NOCOLUMNHEADER
);
4227 style
= GetWindowLongA(header
, GWL_STYLE
);
4228 ok(style
& HDS_HIDDEN
, "Expected HDS_HIDDEN\n");
4229 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4230 SetWindowLongW(hwnd
, GWL_STYLE
, style
& ~LVS_NOCOLUMNHEADER
);
4231 style
= GetWindowLongA(header
, GWL_STYLE
);
4232 ok(!(style
& HDS_HIDDEN
), "Expected HDS_HIDDEN to be unset\n");
4234 /* try to remove style */
4235 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
, 0);
4236 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4237 ok(IsWindow(header
), "Expected header to be created\n");
4238 style
= GetWindowLongA(header
, GWL_STYLE
);
4239 ok(!(style
& HDS_HIDDEN
), "HDS_HIDDEN not expected\n");
4241 DestroyWindow(hwnd
);
4243 /* check other styles */
4244 hwnd
= create_listview_control(LVS_LIST
);
4245 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4246 LVS_EX_HEADERINALLVIEWS
);
4247 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4248 ok(IsWindow(header
), "Expected header to be created\n");
4249 DestroyWindow(hwnd
);
4251 hwnd
= create_listview_control(LVS_SMALLICON
);
4252 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4253 LVS_EX_HEADERINALLVIEWS
);
4254 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4255 ok(IsWindow(header
), "Expected header to be created\n");
4256 DestroyWindow(hwnd
);
4258 hwnd
= create_listview_control(LVS_REPORT
);
4259 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4260 LVS_EX_HEADERINALLVIEWS
);
4261 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4262 ok(IsWindow(header
), "Expected header to be created\n");
4263 DestroyWindow(hwnd
);
4266 static void test_hover(void)
4271 hwnd
= create_listview_control(LVS_ICON
);
4273 /* test WM_MOUSEHOVER forwarding */
4274 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4275 r
= SendMessage(hwnd
, WM_MOUSEHOVER
, 0, 0);
4277 ok_sequence(sequences
, PARENT_SEQ_INDEX
, hover_parent
, "NM_HOVER allow test", TRUE
);
4278 g_block_hover
= TRUE
;
4279 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4280 r
= SendMessage(hwnd
, WM_MOUSEHOVER
, 0, 0);
4282 ok_sequence(sequences
, PARENT_SEQ_INDEX
, hover_parent
, "NM_HOVER block test", TRUE
);
4283 g_block_hover
= FALSE
;
4285 r
= SendMessage(hwnd
, LVM_SETHOVERTIME
, 0, 500);
4286 expect(HOVER_DEFAULT
, r
);
4287 r
= SendMessage(hwnd
, LVM_GETHOVERTIME
, 0, 0);
4290 DestroyWindow(hwnd
);
4293 static void test_destroynotify(void)
4297 hwnd
= create_listview_control(LVS_REPORT
);
4298 ok(hwnd
!= NULL
, "failed to create listview window\n");
4300 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4301 DestroyWindow(hwnd
);
4302 ok_sequence(sequences
, COMBINED_SEQ_INDEX
, listview_destroy
, "check destroy order", FALSE
);
4305 static void test_header_notification(void)
4313 list
= create_listview_control(LVS_REPORT
);
4314 ok(list
!= 0, "failed to create listview window\n");
4316 memset(&col
, 0, sizeof(col
));
4317 col
.mask
= LVCF_WIDTH
;
4319 ret
= SendMessage(list
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
4320 ok(!ret
, "expected 0, got %ld\n", ret
);
4322 header
= subclass_header(list
);
4324 ret
= SendMessage(header
, HDM_GETITEMCOUNT
, 0, 0);
4325 ok(ret
== 1, "expected header item count 1, got %ld\n", ret
);
4327 memset(&item
, 0, sizeof(item
));
4328 item
.mask
= HDI_WIDTH
;
4329 ret
= SendMessage(header
, HDM_GETITEMA
, 0, (LPARAM
)&item
);
4330 ok(ret
, "HDM_GETITEM failed\n");
4331 ok(item
.cxy
== 100, "expected 100, got %d\n", item
.cxy
);
4333 nmh
.hdr
.hwndFrom
= header
;
4334 nmh
.hdr
.idFrom
= GetWindowLongPtr(header
, GWLP_ID
);
4335 nmh
.hdr
.code
= HDN_ITEMCHANGEDA
;
4338 item
.mask
= HDI_WIDTH
;
4341 ret
= SendMessage(list
, WM_NOTIFY
, 0, (LPARAM
)&nmh
);
4342 ok(!ret
, "WM_NOTIFY/HDN_ITEMCHANGED failed\n");
4344 DestroyWindow(list
);
4347 START_TEST(listview
)
4350 BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
4352 ULONG_PTR ctx_cookie
;
4356 hComctl32
= GetModuleHandleA("comctl32.dll");
4357 pInitCommonControlsEx
= (void*)GetProcAddress(hComctl32
, "InitCommonControlsEx");
4358 if (pInitCommonControlsEx
)
4360 INITCOMMONCONTROLSEX iccex
;
4361 iccex
.dwSize
= sizeof(iccex
);
4362 iccex
.dwICC
= ICC_LISTVIEW_CLASSES
;
4363 pInitCommonControlsEx(&iccex
);
4366 InitCommonControls();
4368 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
4370 hwndparent
= create_parent_window(FALSE
);
4371 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4373 g_is_below_5
= is_below_comctl_5();
4375 test_header_notification();
4382 test_icon_spacing();
4385 test_item_position();
4390 test_subitem_rect();
4394 test_nosortheader();
4398 test_getitemposition();
4399 test_columnscreation();
4401 test_notifyformat();
4403 test_getitemspacing();
4404 test_getcolumnwidth();
4405 test_approximate_viewrect();
4408 test_destroynotify();
4410 if (!load_v6_module(&ctx_cookie
, &hCtx
))
4412 DestroyWindow(hwndparent
);
4416 /* this is a XP SP3 failure workaround */
4417 hwnd
= CreateWindowExA(0, WC_LISTVIEW
, "foo",
4418 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| LVS_REPORT
,
4420 hwndparent
, NULL
, GetModuleHandleA(NULL
), NULL
);
4421 if (!IsWindow(hwnd
))
4423 win_skip("FIXME: failed to create ListView window.\n");
4424 unload_v6_module(ctx_cookie
, hCtx
);
4425 DestroyWindow(hwndparent
);
4429 DestroyWindow(hwnd
);
4431 /* comctl32 version 6 tests start here */
4432 test_get_set_view();
4433 test_canceleditlabel();
4435 test_scrollnotify();
4436 test_LVS_EX_TRANSPARENTBKGND();
4437 test_LVS_EX_HEADERINALLVIEWS();
4439 unload_v6_module(ctx_cookie
, hCtx
);
4441 DestroyWindow(hwndparent
);