4 * Copyright 2006 Mike McCormack for CodeWeavers
5 * Copyright 2007 George Gov
6 * Copyright 2009-2012 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 static 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 /* notification data for LVN_ITEMCHANGED */
54 static NMLISTVIEW g_nmlistview
;
55 /* format reported to control:
56 -1 falls to defproc, anything else returned */
57 static INT notifyFormat
;
58 /* indicates we're running < 5.80 version */
59 static BOOL g_is_below_5
;
60 /* item data passed to LVN_GETDISPINFOA */
61 static LVITEMA g_itema
;
62 /* alter notification code A->W */
63 static BOOL g_disp_A_to_W
;
64 /* dispinfo data sent with LVN_LVN_ENDLABELEDIT */
65 static NMLVDISPINFO g_editbox_disp_info
;
67 static HWND
subclass_editbox(HWND hwndListview
);
69 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
71 static const struct message create_ownerdrawfixed_parent_seq
[] = {
72 { WM_NOTIFYFORMAT
, sent
},
73 { WM_QUERYUISTATE
, sent
|optional
}, /* Win2K and higher */
74 { WM_MEASUREITEM
, sent
},
75 { WM_PARENTNOTIFY
, sent
},
79 static const struct message redraw_listview_seq
[] = {
80 { WM_PAINT
, sent
|id
, 0, 0, LISTVIEW_ID
},
81 { WM_PAINT
, sent
|id
, 0, 0, HEADER_ID
},
82 { WM_NCPAINT
, sent
|id
|defwinproc
, 0, 0, HEADER_ID
},
83 { WM_ERASEBKGND
, sent
|id
|defwinproc
|optional
, 0, 0, HEADER_ID
},
84 { WM_NOTIFY
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
85 { WM_NCPAINT
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
86 { WM_ERASEBKGND
, sent
|id
|defwinproc
|optional
, 0, 0, LISTVIEW_ID
},
90 static const struct message listview_icon_spacing_seq
[] = {
91 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(20, 30) },
92 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(25, 35) },
93 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(-1, -1) },
97 static const struct message listview_color_seq
[] = {
98 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
99 { LVM_GETBKCOLOR
, sent
},
100 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
101 { LVM_GETTEXTCOLOR
, sent
},
102 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
103 { LVM_GETTEXTBKCOLOR
, sent
},
105 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
106 { LVM_GETBKCOLOR
, sent
},
107 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
108 { LVM_GETTEXTCOLOR
, sent
},
109 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
110 { LVM_GETTEXTBKCOLOR
, sent
},
112 { LVM_SETBKCOLOR
, sent
|lparam
, 0, CLR_NONE
},
113 { LVM_GETBKCOLOR
, sent
},
114 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, CLR_NONE
},
115 { LVM_GETTEXTCOLOR
, sent
},
116 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, CLR_NONE
},
117 { LVM_GETTEXTBKCOLOR
, sent
},
119 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
120 { LVM_GETBKCOLOR
, sent
},
121 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
122 { LVM_GETTEXTCOLOR
, sent
},
123 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
124 { LVM_GETTEXTBKCOLOR
, sent
},
128 static const struct message listview_item_count_seq
[] = {
129 { LVM_GETITEMCOUNT
, sent
},
130 { LVM_INSERTITEM
, sent
},
131 { LVM_INSERTITEM
, sent
},
132 { LVM_INSERTITEM
, sent
},
133 { LVM_GETITEMCOUNT
, sent
},
134 { LVM_DELETEITEM
, sent
|wparam
, 2 },
135 { WM_NCPAINT
, sent
|optional
},
136 { WM_ERASEBKGND
, sent
|optional
},
137 { LVM_GETITEMCOUNT
, sent
},
138 { LVM_DELETEALLITEMS
, sent
},
139 { LVM_GETITEMCOUNT
, sent
},
140 { LVM_INSERTITEM
, sent
},
141 { LVM_INSERTITEM
, sent
},
142 { LVM_GETITEMCOUNT
, sent
},
143 { LVM_INSERTITEM
, sent
},
144 { LVM_GETITEMCOUNT
, sent
},
148 static const struct message listview_itempos_seq
[] = {
149 { LVM_INSERTITEM
, sent
},
150 { LVM_INSERTITEM
, sent
},
151 { LVM_INSERTITEM
, sent
},
152 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 1, MAKELPARAM(10,5) },
153 { WM_NCPAINT
, sent
|optional
},
154 { WM_ERASEBKGND
, sent
|optional
},
155 { LVM_GETITEMPOSITION
, sent
|wparam
, 1 },
156 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 2, MAKELPARAM(0,0) },
157 { LVM_GETITEMPOSITION
, sent
|wparam
, 2 },
158 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 0, MAKELPARAM(20,20) },
159 { LVM_GETITEMPOSITION
, sent
|wparam
, 0 },
163 static const struct message listview_ownerdata_switchto_seq
[] = {
164 { WM_STYLECHANGING
, sent
},
165 { WM_STYLECHANGED
, sent
},
169 static const struct message listview_getorderarray_seq
[] = {
170 { LVM_GETCOLUMNORDERARRAY
, sent
|id
|wparam
, 2, 0, LISTVIEW_ID
},
171 { HDM_GETORDERARRAY
, sent
|id
|wparam
, 2, 0, HEADER_ID
},
175 static const struct message empty_seq
[] = {
179 static const struct message forward_erasebkgnd_parent_seq
[] = {
180 { WM_ERASEBKGND
, sent
},
184 static const struct message ownderdata_select_focus_parent_seq
[] = {
185 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
186 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
187 { WM_NOTIFY
, sent
|id
|optional
, 0, 0, LVN_GETDISPINFOA
}, /* version 4.7x */
191 static const struct message ownerdata_setstate_all_parent_seq
[] = {
192 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
196 static const struct message ownerdata_defocus_all_parent_seq
[] = {
197 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
198 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
199 { WM_NOTIFY
, sent
|id
|optional
, 0, 0, LVN_GETDISPINFOA
},
200 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
204 static const struct message ownerdata_deselect_all_parent_seq
[] = {
205 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ODCACHEHINT
},
206 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
210 static const struct message select_all_parent_seq
[] = {
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
},
220 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
221 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
223 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
224 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
228 static const struct message textcallback_set_again_parent_seq
[] = {
229 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
230 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
234 static const struct message single_getdispinfo_parent_seq
[] = {
235 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
239 static const struct message getitemposition_seq1
[] = {
240 { LVM_GETITEMPOSITION
, sent
|id
, 0, 0, LISTVIEW_ID
},
244 static const struct message getitemposition_seq2
[] = {
245 { LVM_GETITEMPOSITION
, sent
|id
, 0, 0, LISTVIEW_ID
},
246 { HDM_GETITEMRECT
, sent
|id
, 0, 0, HEADER_ID
},
250 static const struct message editbox_create_pos
[] = {
251 /* sequence sent after LVN_BEGINLABELEDIT */
252 /* next two are 4.7x specific */
253 { WM_WINDOWPOSCHANGING
, sent
},
254 { WM_WINDOWPOSCHANGED
, sent
|optional
},
256 { WM_WINDOWPOSCHANGING
, sent
|optional
},
257 { WM_NCCALCSIZE
, sent
},
258 { WM_WINDOWPOSCHANGED
, sent
},
259 { WM_MOVE
, sent
|defwinproc
},
260 { WM_SIZE
, sent
|defwinproc
},
261 /* the rest is todo, skipped in 4.7x */
262 { WM_WINDOWPOSCHANGING
, sent
|optional
},
263 { WM_WINDOWPOSCHANGED
, sent
|optional
},
267 static const struct message scroll_parent_seq
[] = {
268 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_BEGINSCROLL
},
269 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ENDSCROLL
},
273 static const struct message setredraw_seq
[] = {
274 { WM_SETREDRAW
, sent
|id
|wparam
, FALSE
, 0, LISTVIEW_ID
},
278 static const struct message lvs_ex_transparentbkgnd_seq
[] = {
279 { WM_PRINTCLIENT
, sent
|lparam
, 0, PRF_ERASEBKGND
},
283 static const struct message edit_end_nochange
[] = {
284 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ENDLABELEDITA
},
285 { WM_NOTIFY
, sent
|id
, 0, 0, NM_CUSTOMDRAW
}, /* todo */
286 { WM_NOTIFY
, sent
|id
, 0, 0, NM_SETFOCUS
},
290 static const struct message hover_parent
[] = {
291 { WM_GETDLGCODE
, sent
}, /* todo_wine */
292 { WM_NOTIFY
, sent
|id
, 0, 0, NM_HOVER
},
296 static const struct message listview_destroy
[] = {
297 { 0x0090, sent
|optional
}, /* Vista */
298 { WM_PARENTNOTIFY
, sent
},
299 { WM_SHOWWINDOW
, sent
},
300 { WM_WINDOWPOSCHANGING
, sent
},
301 { WM_WINDOWPOSCHANGED
, sent
|optional
},
302 { WM_DESTROY
, sent
},
303 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_DELETEALLITEMS
},
304 { WM_NCDESTROY
, sent
},
308 static const struct message listview_header_changed_seq
[] = {
309 { LVM_SETCOLUMNA
, sent
},
310 { WM_NOTIFY
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
311 { WM_NOTIFY
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
315 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
317 static LONG defwndproc_counter
= 0;
321 msg
.message
= message
;
322 msg
.flags
= sent
|wparam
|lparam
;
323 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
326 if (message
== WM_NOTIFY
&& lParam
) msg
.id
= ((NMHDR
*)lParam
)->code
;
328 /* log system messages, except for painting */
329 if (message
< WM_USER
&&
330 message
!= WM_PAINT
&&
331 message
!= WM_ERASEBKGND
&&
332 message
!= WM_NCPAINT
&&
333 message
!= WM_NCHITTEST
&&
334 message
!= WM_GETTEXT
&&
335 message
!= WM_GETICON
&&
336 message
!= WM_DEVICECHANGE
)
338 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
340 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
341 add_message(sequences
, COMBINED_SEQ_INDEX
, &msg
);
343 add_message(sequences
, PARENT_FULL_SEQ_INDEX
, &msg
);
349 switch (((NMHDR
*)lParam
)->code
)
351 case LVN_BEGINLABELEDIT
:
355 /* subclass edit box */
357 edit
= subclass_editbox(((NMHDR
*)lParam
)->hwndFrom
);
361 INT len
= SendMessageA(edit
, EM_GETLIMITTEXT
, 0, 0);
362 ok(len
== 259 || broken(len
== 260) /* includes NULL in NT4 */,
363 "text limit %d, expected 259\n", len
);
368 case LVN_ENDLABELEDIT
:
372 /* always accept new item text */
373 NMLVDISPINFO
*di
= (NMLVDISPINFO
*)lParam
;
374 g_editbox_disp_info
= *di
;
375 trace("LVN_ENDLABELEDIT: text=%s\n", di
->item
.pszText
? di
->item
.pszText
: "(null)");
377 /* edit control still available from this notification */
378 edit
= (HWND
)SendMessageA(((NMHDR
*)lParam
)->hwndFrom
, LVM_GETEDITCONTROL
, 0, 0);
379 ok(IsWindow(edit
), "expected valid edit control handle\n");
380 ok((GetWindowLongA(edit
, GWL_STYLE
) & ES_MULTILINE
) == 0, "edit is multiline\n");
384 case LVN_BEGINSCROLL
:
387 NMLVSCROLL
*pScroll
= (NMLVSCROLL
*)lParam
;
389 trace("LVN_%sSCROLL: (%d,%d)\n", pScroll
->hdr
.code
== LVN_BEGINSCROLL
?
390 "BEGIN" : "END", pScroll
->dx
, pScroll
->dy
);
393 case LVN_ITEMCHANGED
:
395 NMLISTVIEW
*nmlv
= (NMLISTVIEW
*)lParam
;
396 g_nmlistview
= *nmlv
;
399 case LVN_GETDISPINFOA
:
401 NMLVDISPINFOA
*dispinfo
= (NMLVDISPINFOA
*)lParam
;
402 g_itema
= dispinfo
->item
;
404 if (g_disp_A_to_W
&& (dispinfo
->item
.mask
& LVIF_TEXT
))
406 static const WCHAR testW
[] = {'T','E','S','T',0};
407 dispinfo
->hdr
.code
= LVN_GETDISPINFOW
;
408 memcpy(dispinfo
->item
.pszText
, testW
, sizeof(testW
));
411 /* test control buffer size for text, 10 used to mask cases when control
412 is using caller buffer to process LVM_GETITEM for example */
413 if (dispinfo
->item
.mask
& LVIF_TEXT
&& dispinfo
->item
.cchTextMax
> 10)
414 ok(dispinfo
->item
.cchTextMax
== 260 ||
415 broken(dispinfo
->item
.cchTextMax
== 264) /* NT4 reports aligned size */,
416 "buffer size %d\n", dispinfo
->item
.cchTextMax
);
420 if (g_block_hover
) return 1;
425 case WM_NOTIFYFORMAT
:
427 /* force to return format */
428 if (lParam
== NF_QUERY
&& notifyFormat
!= -1) return notifyFormat
;
433 defwndproc_counter
++;
434 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
435 defwndproc_counter
--;
440 static BOOL
register_parent_wnd_class(BOOL Unicode
)
448 clsW
.lpfnWndProc
= parent_wnd_proc
;
451 clsW
.hInstance
= GetModuleHandleW(NULL
);
453 clsW
.hCursor
= LoadCursorA(0, IDC_ARROW
);
454 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
455 clsW
.lpszMenuName
= NULL
;
456 clsW
.lpszClassName
= testparentclassW
;
461 clsA
.lpfnWndProc
= parent_wnd_proc
;
464 clsA
.hInstance
= GetModuleHandleA(NULL
);
466 clsA
.hCursor
= LoadCursorA(0, IDC_ARROW
);
467 clsA
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
468 clsA
.lpszMenuName
= NULL
;
469 clsA
.lpszClassName
= "Listview test parent class";
472 return Unicode
? RegisterClassW(&clsW
) : RegisterClassA(&clsA
);
475 static HWND
create_parent_window(BOOL Unicode
)
477 static const WCHAR nameW
[] = {'t','e','s','t','p','a','r','e','n','t','n','a','m','e','W',0};
480 if (!register_parent_wnd_class(Unicode
))
487 hwnd
= CreateWindowExW(0, testparentclassW
, nameW
,
488 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
489 WS_MAXIMIZEBOX
| WS_VISIBLE
,
491 GetDesktopWindow(), NULL
, GetModuleHandleW(NULL
), NULL
);
493 hwnd
= CreateWindowExA(0, "Listview test parent class",
494 "Listview test parent window",
495 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
496 WS_MAXIMIZEBOX
| WS_VISIBLE
,
498 GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
499 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
503 static LRESULT WINAPI
listview_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
505 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
506 static LONG defwndproc_counter
= 0;
510 trace("listview: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
512 /* some debug output for style changing */
513 if ((message
== WM_STYLECHANGING
||
514 message
== WM_STYLECHANGED
) && lParam
)
516 STYLESTRUCT
*style
= (STYLESTRUCT
*)lParam
;
517 trace("\told style: 0x%08x, new style: 0x%08x\n", style
->styleOld
, style
->styleNew
);
520 msg
.message
= message
;
521 msg
.flags
= sent
|wparam
|lparam
;
522 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
525 msg
.id
= LISTVIEW_ID
;
526 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
527 add_message(sequences
, COMBINED_SEQ_INDEX
, &msg
);
529 defwndproc_counter
++;
530 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
531 defwndproc_counter
--;
535 static HWND
create_listview_control(DWORD style
)
541 GetClientRect(hwndparent
, &rect
);
542 hwnd
= CreateWindowExA(0, WC_LISTVIEW
, "foo",
543 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
544 0, 0, rect
.right
, rect
.bottom
,
545 hwndparent
, NULL
, GetModuleHandleA(NULL
), NULL
);
546 ok(hwnd
!= NULL
, "gle=%d\n", GetLastError());
548 if (!hwnd
) return NULL
;
550 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
551 (LONG_PTR
)listview_subclass_proc
);
552 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
557 /* unicode listview window with specified parent */
558 static HWND
create_listview_controlW(DWORD style
, HWND parent
)
563 static const WCHAR nameW
[] = {'f','o','o',0};
565 GetClientRect(parent
, &rect
);
566 hwnd
= CreateWindowExW(0, WC_LISTVIEWW
, nameW
,
567 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
568 0, 0, rect
.right
, rect
.bottom
,
569 parent
, NULL
, GetModuleHandleW(NULL
), NULL
);
570 ok(hwnd
!= NULL
, "gle=%d\n", GetLastError());
572 if (!hwnd
) return NULL
;
574 oldproc
= (WNDPROC
)SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
,
575 (LONG_PTR
)listview_subclass_proc
);
576 SetWindowLongPtrW(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
581 static LRESULT WINAPI
header_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
583 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
584 static LONG defwndproc_counter
= 0;
588 trace("header: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
590 msg
.message
= message
;
591 msg
.flags
= sent
|wparam
|lparam
;
592 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
596 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
598 defwndproc_counter
++;
599 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
600 defwndproc_counter
--;
604 static HWND
subclass_header(HWND hwndListview
)
609 hwnd
= ListView_GetHeader(hwndListview
);
610 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
611 (LONG_PTR
)header_subclass_proc
);
612 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
617 static LRESULT WINAPI
editbox_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
619 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
620 static LONG defwndproc_counter
= 0;
624 msg
.message
= message
;
625 msg
.flags
= sent
|wparam
|lparam
;
626 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
630 /* all we need is sizing */
631 if (message
== WM_WINDOWPOSCHANGING
||
632 message
== WM_NCCALCSIZE
||
633 message
== WM_WINDOWPOSCHANGED
||
634 message
== WM_MOVE
||
637 add_message(sequences
, EDITBOX_SEQ_INDEX
, &msg
);
640 defwndproc_counter
++;
641 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
642 defwndproc_counter
--;
646 static HWND
subclass_editbox(HWND hwndListview
)
651 hwnd
= (HWND
)SendMessage(hwndListview
, LVM_GETEDITCONTROL
, 0, 0);
652 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
653 (LONG_PTR
)editbox_subclass_proc
);
654 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
659 /* Performs a single LVM_HITTEST test */
660 static void test_lvm_hittest_(HWND hwnd
, INT x
, INT y
, INT item
, UINT flags
, UINT broken_flags
,
661 BOOL todo_item
, BOOL todo_flags
, int line
)
670 ret
= SendMessage(hwnd
, LVM_HITTEST
, 0, (LPARAM
)&lpht
);
676 ok_(__FILE__
, line
)(ret
== item
, "Expected %d retval, got %d\n", item
, ret
);
677 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
678 ok_(__FILE__
, line
)(lpht
.iSubItem
== 10, "Expected subitem not overwrited\n");
683 ok_(__FILE__
, line
)(ret
== item
, "Expected %d retval, got %d\n", item
, ret
);
684 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
685 ok_(__FILE__
, line
)(lpht
.iSubItem
== 10, "Expected subitem not overwrited\n");
691 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags 0x%x, got 0x%x\n", flags
, lpht
.flags
);
693 else if (broken_flags
)
694 ok_(__FILE__
, line
)(lpht
.flags
== flags
|| broken(lpht
.flags
== broken_flags
),
695 "Expected flags %x, got %x\n", flags
, lpht
.flags
);
697 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags 0x%x, got 0x%x\n", flags
, lpht
.flags
);
700 #define test_lvm_hittest(a,b,c,d,e,f,g,h) test_lvm_hittest_(a,b,c,d,e,f,g,h,__LINE__)
702 /* Performs a single LVM_SUBITEMHITTEST test */
703 static void test_lvm_subitemhittest_(HWND hwnd
, INT x
, INT y
, INT item
, INT subitem
, UINT flags
,
704 BOOL todo_item
, BOOL todo_subitem
, BOOL todo_flags
, int line
)
712 ret
= SendMessage(hwnd
, LVM_SUBITEMHITTEST
, 0, (LPARAM
)&lpht
);
718 ok_(__FILE__
, line
)(ret
== item
, "Expected %d retval, got %d\n", item
, ret
);
719 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
724 ok_(__FILE__
, line
)(ret
== item
, "Expected %d retval, got %d\n", item
, ret
);
725 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
731 ok_(__FILE__
, line
)(lpht
.iSubItem
== subitem
, "Expected subitem %d, got %d\n", subitem
, lpht
.iSubItem
);
734 ok_(__FILE__
, line
)(lpht
.iSubItem
== subitem
, "Expected subitem %d, got %d\n", subitem
, lpht
.iSubItem
);
739 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags 0x%x, got 0x%x\n", flags
, lpht
.flags
);
742 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags 0x%x, got 0x%x\n", flags
, lpht
.flags
);
745 #define test_lvm_subitemhittest(a,b,c,d,e,f,g,h,i) test_lvm_subitemhittest_(a,b,c,d,e,f,g,h,i,__LINE__)
747 static void test_images(void)
755 static CHAR hello
[] = "hello";
757 himl
= ImageList_Create(40, 40, 0, 4, 4);
758 ok(himl
!= NULL
, "failed to create imagelist\n");
760 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
761 ok(hbmp
!= NULL
, "failed to create bitmap\n");
763 r
= ImageList_Add(himl
, hbmp
, 0);
764 ok(r
== 0, "should be zero\n");
766 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_OWNERDRAWFIXED
,
767 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
768 ok(hwnd
!= NULL
, "failed to create listview window\n");
770 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0,
771 LVS_EX_UNDERLINEHOT
| LVS_EX_FLATSB
| LVS_EX_ONECLICKACTIVATE
);
773 ok(r
== 0, "should return zero\n");
775 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
776 ok(r
== 0, "should return zero\n");
778 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELONG(100,50));
779 ok(r
!= 0, "got 0\n");
781 /* returns dimensions */
783 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
784 ok(r
== 0, "should be zero items\n");
786 item
.mask
= LVIF_IMAGE
| LVIF_TEXT
;
791 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
792 ok(r
== -1, "should fail\n");
795 item
.pszText
= hello
;
796 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
797 ok(r
== 0, "should not fail\n");
799 memset(&r1
, 0, sizeof r1
);
801 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
) &r1
);
804 r
= SendMessage(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
805 ok(r
== TRUE
, "should not fail\n");
808 item
.pszText
= hello
;
809 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
810 ok(r
== 0, "should not fail\n");
812 memset(&r2
, 0, sizeof r2
);
814 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
) &r2
);
817 ok(!memcmp(&r1
, &r2
, sizeof r1
), "rectangle should be the same\n");
822 static void test_checkboxes(void)
827 static CHAR text
[] = "Text",
831 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT
,
832 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
833 ok(hwnd
!= NULL
, "failed to create listview window\n");
835 /* first without LVS_EX_CHECKBOXES set and an item and check that state is preserved */
836 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
837 item
.stateMask
= 0xffff;
842 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
846 item
.mask
= LVIF_STATE
;
847 item
.stateMask
= 0xffff;
848 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
850 ok(item
.state
== 0xfccc, "state %x\n", item
.state
);
852 /* Don't set LVIF_STATE */
853 item
.mask
= LVIF_TEXT
;
854 item
.stateMask
= 0xffff;
859 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
863 item
.mask
= LVIF_STATE
;
864 item
.stateMask
= 0xffff;
865 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
867 ok(item
.state
== 0, "state %x\n", item
.state
);
869 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
872 /* Having turned on checkboxes, check that all existing items are set to 0x1000 (unchecked) */
874 item
.mask
= LVIF_STATE
;
875 item
.stateMask
= 0xffff;
876 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
878 if (item
.state
!= 0x1ccc)
880 win_skip("LVS_EX_CHECKBOXES style is unavailable. Skipping.\n");
885 /* Now add an item without specifying a state and check that its state goes to 0x1000 */
887 item
.mask
= LVIF_TEXT
;
889 item
.pszText
= text2
;
890 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
894 item
.mask
= LVIF_STATE
;
895 item
.stateMask
= 0xffff;
896 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
898 ok(item
.state
== 0x1000, "state %x\n", item
.state
);
900 /* Add a further item this time specifying a state and still its state goes to 0x1000 */
902 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
903 item
.stateMask
= 0xffff;
905 item
.pszText
= text3
;
906 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
910 item
.mask
= LVIF_STATE
;
911 item
.stateMask
= 0xffff;
912 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
914 ok(item
.state
== 0x1aaa, "state %x\n", item
.state
);
916 /* Set an item's state to checked */
918 item
.mask
= LVIF_STATE
;
919 item
.stateMask
= 0xf000;
921 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
925 item
.mask
= LVIF_STATE
;
926 item
.stateMask
= 0xffff;
927 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
929 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
931 /* Check that only the bits we asked for are returned,
932 * and that all the others are set to zero
935 item
.mask
= LVIF_STATE
;
936 item
.stateMask
= 0xf000;
938 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
940 ok(item
.state
== 0x2000, "state %x\n", item
.state
);
942 /* Set the style again and check that doesn't change an item's state */
943 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
944 ok(r
== LVS_EX_CHECKBOXES
, "ret %x\n", r
);
947 item
.mask
= LVIF_STATE
;
948 item
.stateMask
= 0xffff;
949 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
951 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
953 /* Unsetting the checkbox extended style doesn't change an item's state */
954 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, 0);
955 ok(r
== LVS_EX_CHECKBOXES
, "ret %x\n", r
);
958 item
.mask
= LVIF_STATE
;
959 item
.stateMask
= 0xffff;
960 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
962 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
964 /* Now setting the style again will change an item's state */
965 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
969 item
.mask
= LVIF_STATE
;
970 item
.stateMask
= 0xffff;
971 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
973 ok(item
.state
== 0x1aaa, "state %x\n", item
.state
);
975 /* Toggle checkbox tests (bug 9934) */
976 memset (&item
, 0xcc, sizeof(item
));
977 item
.mask
= LVIF_STATE
;
980 item
.state
= LVIS_FOCUSED
;
981 item
.stateMask
= LVIS_FOCUSED
;
982 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
) &item
);
986 item
.mask
= LVIF_STATE
;
987 item
.stateMask
= 0xffff;
988 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
990 ok(item
.state
== 0x1aab, "state %x\n", item
.state
);
992 r
= SendMessage(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
994 r
= SendMessage(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
998 item
.mask
= LVIF_STATE
;
999 item
.stateMask
= 0xffff;
1000 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1002 ok(item
.state
== 0x2aab, "state %x\n", item
.state
);
1004 r
= SendMessage(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
1006 r
= SendMessage(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
1010 item
.mask
= LVIF_STATE
;
1011 item
.stateMask
= 0xffff;
1012 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1014 ok(item
.state
== 0x1aab, "state %x\n", item
.state
);
1016 DestroyWindow(hwnd
);
1019 static void insert_column(HWND hwnd
, int idx
)
1024 memset(&column
, 0xcc, sizeof(column
));
1025 column
.mask
= LVCF_SUBITEM
;
1026 column
.iSubItem
= idx
;
1028 rc
= ListView_InsertColumn(hwnd
, idx
, &column
);
1032 static void insert_item(HWND hwnd
, int idx
)
1034 static CHAR text
[] = "foo";
1039 memset(&item
, 0xcc, sizeof (item
));
1040 item
.mask
= LVIF_TEXT
;
1043 item
.pszText
= text
;
1045 rc
= ListView_InsertItem(hwnd
, &item
);
1049 static void test_items(void)
1051 const LPARAM lparamTest
= 0x42;
1052 static CHAR text
[] = "Text";
1058 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT
,
1059 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
1060 ok(hwnd
!= NULL
, "failed to create listview window\n");
1063 * Test setting/getting item params
1066 /* Set up two columns */
1067 insert_column(hwnd
, 0);
1068 insert_column(hwnd
, 1);
1070 /* LVIS_SELECTED with zero stateMask */
1072 memset (&item
, 0, sizeof (item
));
1073 item
.mask
= LVIF_STATE
;
1074 item
.state
= LVIS_SELECTED
;
1078 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1081 memset (&item
, 0xcc, sizeof (item
));
1082 item
.mask
= LVIF_STATE
;
1083 item
.stateMask
= LVIS_SELECTED
;
1087 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1089 ok(item
.state
& LVIS_SELECTED
, "Expected LVIS_SELECTED\n");
1090 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
1092 /* LVIS_SELECTED with zero stateMask */
1094 memset (&item
, 0, sizeof (item
));
1095 item
.mask
= LVIF_STATE
;
1096 item
.state
= LVIS_FOCUSED
;
1100 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1103 memset (&item
, 0xcc, sizeof (item
));
1104 item
.mask
= LVIF_STATE
;
1105 item
.stateMask
= LVIS_FOCUSED
;
1109 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1111 ok(item
.state
& LVIS_FOCUSED
, "Expected LVIS_FOCUSED\n");
1112 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
1114 /* LVIS_CUT with LVIS_FOCUSED stateMask */
1116 memset (&item
, 0, sizeof (item
));
1117 item
.mask
= LVIF_STATE
;
1118 item
.state
= LVIS_CUT
;
1119 item
.stateMask
= LVIS_FOCUSED
;
1122 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1125 memset (&item
, 0xcc, sizeof (item
));
1126 item
.mask
= LVIF_STATE
;
1127 item
.stateMask
= LVIS_CUT
;
1131 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1133 ok(item
.state
& LVIS_CUT
, "Expected LVIS_CUT\n");
1134 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
1136 /* Insert an item with just a param */
1137 memset (&item
, 0xcc, sizeof (item
));
1138 item
.mask
= LVIF_PARAM
;
1141 item
.lParam
= lparamTest
;
1142 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1145 /* Test getting of the param */
1146 memset (&item
, 0xcc, sizeof (item
));
1147 item
.mask
= LVIF_PARAM
;
1150 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1152 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1154 /* Set up a subitem */
1155 memset (&item
, 0xcc, sizeof (item
));
1156 item
.mask
= LVIF_TEXT
;
1159 item
.pszText
= text
;
1160 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1163 item
.mask
= LVIF_TEXT
;
1166 item
.pszText
= buffA
;
1167 item
.cchTextMax
= sizeof(buffA
);
1168 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1170 ok(!memcmp(item
.pszText
, text
, sizeof(text
)), "got text %s, expected %s\n", item
.pszText
, text
);
1172 /* set up with extra flag */
1173 /* 1. reset subitem text */
1174 item
.mask
= LVIF_TEXT
;
1177 item
.pszText
= NULL
;
1178 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1181 item
.mask
= LVIF_TEXT
;
1184 item
.pszText
= buffA
;
1186 item
.cchTextMax
= sizeof(buffA
);
1187 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1189 ok(item
.pszText
[0] == 0, "got %p\n", item
.pszText
);
1191 /* 2. set new text with extra flag specified */
1192 item
.mask
= LVIF_TEXT
| LVIF_DI_SETITEM
;
1195 item
.pszText
= text
;
1196 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1197 ok(r
== 1 || broken(r
== 0) /* NT4 */, "ret %d\n", r
);
1201 item
.mask
= LVIF_TEXT
;
1204 item
.pszText
= buffA
;
1206 item
.cchTextMax
= sizeof(buffA
);
1207 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1209 ok(!memcmp(item
.pszText
, text
, sizeof(text
)), "got %s, expected %s\n", item
.pszText
, text
);
1212 /* Query param from subitem: returns main item param */
1213 memset (&item
, 0xcc, sizeof (item
));
1214 item
.mask
= LVIF_PARAM
;
1217 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1219 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1221 /* Set up param on first subitem: no effect */
1222 memset (&item
, 0xcc, sizeof (item
));
1223 item
.mask
= LVIF_PARAM
;
1226 item
.lParam
= lparamTest
+1;
1227 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1230 /* Query param from subitem again: should still return main item param */
1231 memset (&item
, 0xcc, sizeof (item
));
1232 item
.mask
= LVIF_PARAM
;
1235 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1237 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1239 /**** Some tests of state highlighting ****/
1240 memset (&item
, 0xcc, sizeof (item
));
1241 item
.mask
= LVIF_STATE
;
1244 item
.state
= LVIS_SELECTED
;
1245 item
.stateMask
= LVIS_SELECTED
| LVIS_DROPHILITED
;
1246 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
) &item
);
1249 item
.state
= LVIS_DROPHILITED
;
1250 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
) &item
);
1253 memset (&item
, 0xcc, sizeof (item
));
1254 item
.mask
= LVIF_STATE
;
1257 item
.stateMask
= -1;
1258 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
1260 ok(item
.state
== LVIS_SELECTED
, "got state %x, expected %x\n", item
.state
, LVIS_SELECTED
);
1262 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
1264 todo_wine
ok(item
.state
== LVIS_DROPHILITED
, "got state %x, expected %x\n", item
.state
, LVIS_DROPHILITED
);
1266 /* some notnull but meaningless masks */
1267 memset (&item
, 0, sizeof(item
));
1268 item
.mask
= LVIF_NORECOMPUTE
;
1271 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1273 memset (&item
, 0, sizeof(item
));
1274 item
.mask
= LVIF_DI_SETITEM
;
1277 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1280 /* set text to callback value already having it */
1281 r
= SendMessage(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
1283 memset (&item
, 0, sizeof (item
));
1284 item
.mask
= LVIF_TEXT
;
1285 item
.pszText
= LPSTR_TEXTCALLBACK
;
1287 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1289 memset (&item
, 0, sizeof (item
));
1291 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1293 item
.pszText
= LPSTR_TEXTCALLBACK
;
1294 r
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0 , (LPARAM
) &item
);
1297 ok_sequence(sequences
, PARENT_SEQ_INDEX
, textcallback_set_again_parent_seq
,
1298 "check callback text comparison rule", FALSE
);
1300 DestroyWindow(hwnd
);
1303 static void test_columns(void)
1312 hwnd
= CreateWindowExA(0, "SysListView32", "foo", LVS_REPORT
,
1313 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
1314 ok(hwnd
!= NULL
, "failed to create listview window\n");
1316 /* Add a column with no mask */
1317 memset(&column
, 0xcc, sizeof(column
));
1319 rc
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&column
);
1320 ok(rc
== 0, "Inserting column with no mask failed with %d\n", rc
);
1322 /* Check its width */
1323 rc
= SendMessageA(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
1324 ok(rc
== 10, "Inserting column with no mask failed to set width to 10 with %d\n", rc
);
1326 DestroyWindow(hwnd
);
1328 /* LVM_GETCOLUMNORDERARRAY */
1329 hwnd
= create_listview_control(LVS_REPORT
);
1330 subclass_header(hwnd
);
1332 memset(&column
, 0, sizeof(column
));
1333 column
.mask
= LVCF_WIDTH
;
1335 rc
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&column
);
1339 rc
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 1, (LPARAM
)&column
);
1342 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1344 rc
= SendMessageA(hwnd
, LVM_GETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
1346 ok(order
[0] == 0, "Expected order 0, got %d\n", order
[0]);
1347 ok(order
[1] == 1, "Expected order 1, got %d\n", order
[1]);
1349 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_getorderarray_seq
, "get order array", FALSE
);
1351 /* after column added subitem is considered as present */
1352 insert_item(hwnd
, 0);
1354 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1356 item
.pszText
= buff
;
1357 item
.cchTextMax
= sizeof(buff
);
1360 item
.mask
= LVIF_TEXT
;
1361 memset(&g_itema
, 0, sizeof(g_itema
));
1362 rc
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
1364 ok(g_itema
.iSubItem
== 1, "got %d\n", g_itema
.iSubItem
);
1366 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
1367 "get subitem text after column added", FALSE
);
1369 DestroyWindow(hwnd
);
1372 /* test setting imagelist between WM_NCCREATE and WM_CREATE */
1373 static WNDPROC listviewWndProc
;
1374 static HIMAGELIST test_create_imagelist
;
1376 static LRESULT CALLBACK
create_test_wndproc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1380 if (uMsg
== WM_CREATE
)
1382 LPCREATESTRUCT lpcs
= (LPCREATESTRUCT
)lParam
;
1383 lpcs
->style
|= LVS_REPORT
;
1385 ret
= CallWindowProc(listviewWndProc
, hwnd
, uMsg
, wParam
, lParam
);
1386 if (uMsg
== WM_CREATE
) SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)test_create_imagelist
);
1390 static void test_create(void)
1401 cls
.cbSize
= sizeof(WNDCLASSEX
);
1402 ok(GetClassInfoEx(GetModuleHandle(NULL
), "SysListView32", &cls
), "GetClassInfoEx failed\n");
1403 listviewWndProc
= cls
.lpfnWndProc
;
1404 cls
.lpfnWndProc
= create_test_wndproc
;
1405 cls
.lpszClassName
= "MyListView32";
1406 ok(RegisterClassEx(&cls
), "RegisterClassEx failed\n");
1408 test_create_imagelist
= ImageList_Create(16, 16, 0, 5, 10);
1409 hList
= CreateWindow("MyListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
, GetModuleHandle(NULL
), 0);
1410 ok((HIMAGELIST
)SendMessage(hList
, LVM_GETIMAGELIST
, 0, 0) == test_create_imagelist
, "Image list not obtained\n");
1411 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1413 if (!IsWindow(hHeader
))
1416 win_skip("LVM_GETHEADER not implemented. Skipping.\n");
1417 DestroyWindow(hList
);
1421 ok(IsWindow(hHeader
) && IsWindowVisible(hHeader
), "Listview not in report mode\n");
1422 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1423 DestroyWindow(hList
);
1425 /* header isn't created on LVS_ICON and LVS_LIST styles */
1426 hList
= CreateWindow("SysListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
,
1427 GetModuleHandle(NULL
), 0);
1428 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1429 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1430 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1432 memset(&col
, 0, sizeof(LVCOLUMNA
));
1433 col
.mask
= LVCF_WIDTH
;
1435 r
= SendMessage(hList
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
1437 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1438 ok(IsWindow(hHeader
), "Header should be created\n");
1439 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1440 style
= GetWindowLong(hHeader
, GWL_STYLE
);
1441 ok(!(style
& HDS_HIDDEN
), "Not expected HDS_HIDDEN\n");
1442 DestroyWindow(hList
);
1444 hList
= CreateWindow("SysListView32", "Test", WS_VISIBLE
|LVS_LIST
, 0, 0, 100, 100, NULL
, NULL
,
1445 GetModuleHandle(NULL
), 0);
1446 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1447 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1448 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1450 memset(&col
, 0, sizeof(LVCOLUMNA
));
1451 col
.mask
= LVCF_WIDTH
;
1453 r
= SendMessage(hList
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
1455 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1456 ok(IsWindow(hHeader
), "Header should be created\n");
1457 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1458 DestroyWindow(hList
);
1460 /* try to switch LVS_ICON -> LVS_REPORT and back LVS_ICON -> LVS_REPORT */
1461 hList
= CreateWindow("SysListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
,
1462 GetModuleHandle(NULL
), 0);
1463 ret
= SetWindowLongPtr(hList
, GWL_STYLE
, GetWindowLongPtr(hList
, GWL_STYLE
) | LVS_REPORT
);
1464 ok(ret
& WS_VISIBLE
, "Style wrong, should have WS_VISIBLE\n");
1465 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1466 ok(IsWindow(hHeader
), "Header should be created\n");
1467 ret
= SetWindowLongPtr(hList
, GWL_STYLE
, GetWindowLong(hList
, GWL_STYLE
) & ~LVS_REPORT
);
1468 ok((ret
& WS_VISIBLE
) && (ret
& LVS_REPORT
), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1469 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1470 ok(IsWindow(hHeader
), "Header should be created\n");
1471 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1472 DestroyWindow(hList
);
1474 /* try to switch LVS_LIST -> LVS_REPORT and back LVS_LIST -> LVS_REPORT */
1475 hList
= CreateWindow("SysListView32", "Test", WS_VISIBLE
|LVS_LIST
, 0, 0, 100, 100, NULL
, NULL
,
1476 GetModuleHandle(NULL
), 0);
1477 ret
= SetWindowLongPtr(hList
, GWL_STYLE
,
1478 (GetWindowLongPtr(hList
, GWL_STYLE
) & ~LVS_LIST
) | LVS_REPORT
);
1479 ok(((ret
& WS_VISIBLE
) && (ret
& LVS_LIST
)), "Style wrong, should have WS_VISIBLE|LVS_LIST\n");
1480 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1481 ok(IsWindow(hHeader
), "Header should be created\n");
1482 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1483 ret
= SetWindowLongPtr(hList
, GWL_STYLE
,
1484 (GetWindowLongPtr(hList
, GWL_STYLE
) & ~LVS_REPORT
) | LVS_LIST
);
1485 ok(((ret
& WS_VISIBLE
) && (ret
& LVS_REPORT
)), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1486 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1487 ok(IsWindow(hHeader
), "Header should be created\n");
1488 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1489 DestroyWindow(hList
);
1491 /* LVS_REPORT without WS_VISIBLE */
1492 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1493 GetModuleHandle(NULL
), 0);
1494 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1495 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1496 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1498 memset(&col
, 0, sizeof(LVCOLUMNA
));
1499 col
.mask
= LVCF_WIDTH
;
1501 r
= SendMessage(hList
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
1503 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1504 ok(IsWindow(hHeader
), "Header should be created\n");
1505 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1506 DestroyWindow(hList
);
1508 /* LVS_REPORT without WS_VISIBLE, try to show it */
1509 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1510 GetModuleHandle(NULL
), 0);
1511 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1512 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1513 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1514 ShowWindow(hList
, SW_SHOW
);
1515 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1516 ok(IsWindow(hHeader
), "Header should be created\n");
1517 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1518 DestroyWindow(hList
);
1520 /* LVS_REPORT with LVS_NOCOLUMNHEADER */
1521 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
|LVS_NOCOLUMNHEADER
|WS_VISIBLE
,
1522 0, 0, 100, 100, NULL
, NULL
, GetModuleHandle(NULL
), 0);
1523 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1524 ok(IsWindow(hHeader
), "Header should be created\n");
1525 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1526 /* HDS_DRAGDROP set by default */
1527 ok(GetWindowLongPtr(hHeader
, GWL_STYLE
) & HDS_DRAGDROP
, "Expected header to have HDS_DRAGDROP\n");
1528 DestroyWindow(hList
);
1530 /* setting LVS_EX_HEADERDRAGDROP creates header */
1531 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1532 GetModuleHandle(NULL
), 0);
1533 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1534 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1535 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1536 SendMessage(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_HEADERDRAGDROP
);
1537 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1538 ok(IsWindow(hHeader
) ||
1539 broken(!IsWindow(hHeader
)), /* 4.7x common controls */
1540 "Header should be created\n");
1541 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1542 DestroyWindow(hList
);
1544 /* setting LVS_EX_GRIDLINES creates header */
1545 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1546 GetModuleHandle(NULL
), 0);
1547 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1548 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1549 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1550 SendMessage(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_GRIDLINES
);
1551 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1552 ok(IsWindow(hHeader
) ||
1553 broken(!IsWindow(hHeader
)), /* 4.7x common controls */
1554 "Header should be created\n");
1555 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1556 DestroyWindow(hList
);
1558 /* setting LVS_EX_FULLROWSELECT creates header */
1559 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1560 GetModuleHandle(NULL
), 0);
1561 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1562 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1563 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1564 SendMessage(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_FULLROWSELECT
);
1565 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1566 ok(IsWindow(hHeader
) ||
1567 broken(!IsWindow(hHeader
)), /* 4.7x common controls */
1568 "Header should be created\n");
1569 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1570 DestroyWindow(hList
);
1572 /* not report style accepts LVS_EX_HEADERDRAGDROP too */
1573 hList
= create_listview_control(LVS_ICON
);
1574 SendMessage(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_HEADERDRAGDROP
);
1575 r
= SendMessage(hList
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
1576 ok(r
& LVS_EX_HEADERDRAGDROP
, "Expected LVS_EX_HEADERDRAGDROP to be set\n");
1577 DestroyWindow(hList
);
1579 /* requesting header info with LVM_GETSUBITEMRECT doesn't create it */
1580 hList
= CreateWindow("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1581 GetModuleHandle(NULL
), 0);
1582 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1583 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1585 rect
.left
= LVIR_BOUNDS
;
1587 rect
.right
= rect
.bottom
= -10;
1588 r
= SendMessage(hList
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
1591 hHeader
= (HWND
)SendMessage(hList
, LVM_GETHEADER
, 0, 0);
1592 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1593 ok(GetDlgItem(hList
, 0) == NULL
, "NULL dialog item expected\n");
1595 DestroyWindow(hList
);
1597 /* WM_MEASUREITEM should be sent when created with LVS_OWNERDRAWFIXED */
1598 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1599 hList
= create_listview_control(LVS_OWNERDRAWFIXED
| LVS_REPORT
);
1600 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_ownerdrawfixed_parent_seq
,
1601 "created with LVS_OWNERDRAWFIXED|LVS_REPORT - parent seq", FALSE
);
1602 DestroyWindow(hList
);
1605 static void test_redraw(void)
1612 hwnd
= create_listview_control(LVS_REPORT
);
1613 subclass_header(hwnd
);
1615 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1617 InvalidateRect(hwnd
, NULL
, TRUE
);
1619 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, redraw_listview_seq
, "redraw listview", FALSE
);
1621 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1623 /* forward WM_ERASEBKGND to parent on CLR_NONE background color */
1624 /* 1. Without backbuffer */
1625 res
= ListView_SetBkColor(hwnd
, CLR_NONE
);
1628 hdc
= GetWindowDC(hwndparent
);
1630 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1631 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1632 ok(r
== 1, "Expected not zero result\n");
1633 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, forward_erasebkgnd_parent_seq
,
1634 "forward WM_ERASEBKGND on CLR_NONE", FALSE
);
1636 res
= ListView_SetBkColor(hwnd
, CLR_DEFAULT
);
1639 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1640 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1642 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, empty_seq
,
1643 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE
);
1645 /* 2. With backbuffer */
1646 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_DOUBLEBUFFER
,
1647 LVS_EX_DOUBLEBUFFER
);
1648 res
= ListView_SetBkColor(hwnd
, CLR_NONE
);
1651 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1652 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1654 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, forward_erasebkgnd_parent_seq
,
1655 "forward WM_ERASEBKGND on CLR_NONE", FALSE
);
1657 res
= ListView_SetBkColor(hwnd
, CLR_DEFAULT
);
1660 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1661 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1662 todo_wine
expect(1, r
);
1663 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, empty_seq
,
1664 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE
);
1666 ReleaseDC(hwndparent
, hdc
);
1668 DestroyWindow(hwnd
);
1671 static LRESULT WINAPI
cd_wndproc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
1673 COLORREF clr
, c0ffee
= RGB(0xc0, 0xff, 0xee);
1675 if(msg
== WM_NOTIFY
) {
1676 NMHDR
*nmhdr
= (PVOID
)lp
;
1677 if(nmhdr
->code
== NM_CUSTOMDRAW
) {
1678 NMLVCUSTOMDRAW
*nmlvcd
= (PVOID
)nmhdr
;
1679 trace("NMCUSTOMDRAW (0x%.8x)\n", nmlvcd
->nmcd
.dwDrawStage
);
1680 switch(nmlvcd
->nmcd
.dwDrawStage
) {
1682 SetBkColor(nmlvcd
->nmcd
.hdc
, c0ffee
);
1683 return CDRF_NOTIFYITEMDRAW
;
1684 case CDDS_ITEMPREPAINT
:
1685 nmlvcd
->clrTextBk
= CLR_DEFAULT
;
1686 return CDRF_NOTIFYSUBITEMDRAW
;
1687 case CDDS_ITEMPREPAINT
| CDDS_SUBITEM
:
1688 clr
= GetBkColor(nmlvcd
->nmcd
.hdc
);
1689 todo_wine
ok(clr
== c0ffee
, "clr=%.8x\n", clr
);
1690 return CDRF_NOTIFYPOSTPAINT
;
1691 case CDDS_ITEMPOSTPAINT
| CDDS_SUBITEM
:
1692 clr
= GetBkColor(nmlvcd
->nmcd
.hdc
);
1693 todo_wine
ok(clr
== c0ffee
, "clr=%.8x\n", clr
);
1694 return CDRF_DODEFAULT
;
1696 return CDRF_DODEFAULT
;
1700 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
1703 static void test_customdraw(void)
1708 hwnd
= create_listview_control(LVS_REPORT
);
1710 insert_column(hwnd
, 0);
1711 insert_column(hwnd
, 1);
1712 insert_item(hwnd
, 0);
1714 oldwndproc
= (WNDPROC
)SetWindowLongPtr(hwndparent
, GWLP_WNDPROC
,
1715 (LONG_PTR
)cd_wndproc
);
1717 InvalidateRect(hwnd
, NULL
, TRUE
);
1720 SetWindowLongPtr(hwndparent
, GWLP_WNDPROC
, (LONG_PTR
)oldwndproc
);
1722 DestroyWindow(hwnd
);
1725 static void test_icon_spacing(void)
1727 /* LVM_SETICONSPACING */
1728 /* note: LVM_SETICONSPACING returns the previous icon spacing if successful */
1734 hwnd
= create_listview_control(LVS_ICON
);
1735 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1737 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, (WPARAM
)hwndparent
, NF_REQUERY
);
1738 expect(NFR_ANSI
, r
);
1740 /* reset the icon spacing to defaults */
1741 SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1, -1));
1743 /* now we can request what the defaults are */
1744 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1, -1));
1748 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1750 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(20, 30));
1751 ok(r
== MAKELONG(w
, h
) ||
1752 broken(r
== MAKELONG(w
, w
)), /* win98 */
1753 "Expected %d, got %d\n", MAKELONG(w
, h
), r
);
1755 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(25, 35));
1759 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
1760 DestroyWindow(hwnd
);
1763 expect(MAKELONG(20,30), r
);
1765 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1,-1));
1766 expect(MAKELONG(25,35), r
);
1768 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_icon_spacing_seq
, "test icon spacing seq", FALSE
);
1770 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1771 DestroyWindow(hwnd
);
1774 static void test_color(void)
1782 COLORREF colors
[4] = {RGB(0,0,0), RGB(100,50,200), CLR_NONE
, RGB(255,255,255)};
1784 hwnd
= create_listview_control(LVS_REPORT
);
1785 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1787 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1789 for (i
= 0; i
< 4; i
++)
1793 r
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, color
);
1795 r
= SendMessage(hwnd
, LVM_GETBKCOLOR
, 0, 0);
1798 r
= SendMessage(hwnd
, LVM_SETTEXTCOLOR
, 0, color
);
1800 r
= SendMessage(hwnd
, LVM_GETTEXTCOLOR
, 0, 0);
1803 r
= SendMessage(hwnd
, LVM_SETTEXTBKCOLOR
, 0, color
);
1805 r
= SendMessage(hwnd
, LVM_GETTEXTBKCOLOR
, 0, 0);
1809 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_color_seq
, "test color seq", FALSE
);
1810 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1812 /* invalidation test done separately to avoid a message chain mess */
1813 r
= ValidateRect(hwnd
, NULL
);
1815 r
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, colors
[0]);
1818 rect
.right
= rect
.bottom
= 1;
1819 r
= GetUpdateRect(hwnd
, &rect
, TRUE
);
1820 todo_wine
expect(FALSE
, r
);
1821 ok(rect
.right
== 0 && rect
.bottom
== 0, "got update rectangle\n");
1823 r
= ValidateRect(hwnd
, NULL
);
1825 r
= SendMessage(hwnd
, LVM_SETTEXTCOLOR
, 0, colors
[0]);
1828 rect
.right
= rect
.bottom
= 1;
1829 r
= GetUpdateRect(hwnd
, &rect
, TRUE
);
1830 todo_wine
expect(FALSE
, r
);
1831 ok(rect
.right
== 0 && rect
.bottom
== 0, "got update rectangle\n");
1833 r
= ValidateRect(hwnd
, NULL
);
1835 r
= SendMessage(hwnd
, LVM_SETTEXTBKCOLOR
, 0, colors
[0]);
1838 rect
.right
= rect
.bottom
= 1;
1839 r
= GetUpdateRect(hwnd
, &rect
, TRUE
);
1840 todo_wine
expect(FALSE
, r
);
1841 ok(rect
.right
== 0 && rect
.bottom
== 0, "got update rectangle\n");
1843 DestroyWindow(hwnd
);
1846 static void test_item_count(void)
1848 /* LVM_INSERTITEM, LVM_DELETEITEM, LVM_DELETEALLITEMS, LVM_GETITEMCOUNT */
1861 static CHAR item0text
[] = "item0";
1862 static CHAR item1text
[] = "item1";
1863 static CHAR item2text
[] = "item2";
1865 hwnd
= create_listview_control(LVS_REPORT
);
1866 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1868 /* resize in dpiaware manner to fit all 3 items added */
1870 hOldFont
= SelectObject(hdc
, GetStockObject(SYSTEM_FONT
));
1871 GetTextMetricsA(hdc
, &tm
);
1872 /* 2 extra pixels for bounds and header border */
1873 height
= tm
.tmHeight
+ 2;
1874 SelectObject(hdc
, hOldFont
);
1877 GetWindowRect(hwnd
, &rect
);
1878 /* 3 items + 1 header + 1 to be sure */
1879 MoveWindow(hwnd
, 0, 0, rect
.right
- rect
.left
, 5 * height
, FALSE
);
1881 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1883 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1887 item0
.mask
= LVIF_TEXT
;
1890 item0
.pszText
= item0text
;
1891 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item0
);
1894 /* [item0, item1] */
1895 item1
.mask
= LVIF_TEXT
;
1898 item1
.pszText
= item1text
;
1899 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item1
);
1902 /* [item0, item1, item2] */
1903 item2
.mask
= LVIF_TEXT
;
1906 item2
.pszText
= item2text
;
1907 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item2
);
1910 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1913 /* [item0, item1] */
1914 r
= SendMessage(hwnd
, LVM_DELETEITEM
, 2, 0);
1917 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1921 r
= SendMessage(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
1924 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1928 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item1
);
1931 /* [item0, item1] */
1932 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item1
);
1935 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1938 /* [item0, item1, item2] */
1939 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item2
);
1942 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
1945 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_item_count_seq
, "test item count seq", FALSE
);
1947 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1948 DestroyWindow(hwnd
);
1951 static void test_item_position(void)
1953 /* LVM_SETITEMPOSITION/LVM_GETITEMPOSITION */
1962 static CHAR item0text
[] = "item0";
1963 static CHAR item1text
[] = "item1";
1964 static CHAR item2text
[] = "item2";
1966 hwnd
= create_listview_control(LVS_ICON
);
1967 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1969 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1972 item0
.mask
= LVIF_TEXT
;
1975 item0
.pszText
= item0text
;
1976 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item0
);
1979 /* [item0, item1] */
1980 item1
.mask
= LVIF_TEXT
;
1983 item1
.pszText
= item1text
;
1984 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item1
);
1987 /* [item0, item1, item2] */
1988 item2
.mask
= LVIF_TEXT
;
1991 item2
.pszText
= item2text
;
1992 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item2
);
1995 r
= SendMessage(hwnd
, LVM_SETITEMPOSITION
, 1, MAKELPARAM(10,5));
1997 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 1, (LPARAM
) &position
);
1999 expect2(10, 5, position
.x
, position
.y
);
2001 r
= SendMessage(hwnd
, LVM_SETITEMPOSITION
, 2, MAKELPARAM(0,0));
2003 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 2, (LPARAM
) &position
);
2005 expect2(0, 0, position
.x
, position
.y
);
2007 r
= SendMessage(hwnd
, LVM_SETITEMPOSITION
, 0, MAKELPARAM(20,20));
2009 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
) &position
);
2011 expect2(20, 20, position
.x
, position
.y
);
2013 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_itempos_seq
, "test item position seq", TRUE
);
2015 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2016 DestroyWindow(hwnd
);
2019 static void test_getorigin(void)
2027 position
.x
= position
.y
= 0;
2029 hwnd
= create_listview_control(LVS_ICON
);
2030 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2031 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2033 r
= SendMessage(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
2035 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2036 DestroyWindow(hwnd
);
2038 hwnd
= create_listview_control(LVS_SMALLICON
);
2039 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2040 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2042 r
= SendMessage(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
2044 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2045 DestroyWindow(hwnd
);
2047 hwnd
= create_listview_control(LVS_LIST
);
2048 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2049 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2051 r
= SendMessage(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
2053 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2054 DestroyWindow(hwnd
);
2056 hwnd
= create_listview_control(LVS_REPORT
);
2057 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2058 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2060 r
= SendMessage(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
2062 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2063 DestroyWindow(hwnd
);
2066 static void test_multiselect(void)
2068 typedef struct t_select_task
2079 int i
,j
,item_count
,selected_count
;
2080 static const int items
=5;
2086 static struct t_select_task task_list
[] = {
2087 { "using VK_DOWN", 0, VK_DOWN
, -1, -1 },
2088 { "using VK_UP", -1, VK_UP
, -1, -1 },
2089 { "using VK_END", 0, VK_END
, 1, -1 },
2090 { "using VK_HOME", -1, VK_HOME
, 1, -1 }
2094 hwnd
= create_listview_control(LVS_REPORT
);
2096 for (i
=0;i
<items
;i
++) {
2097 insert_item(hwnd
, 0);
2100 item_count
= (int)SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2102 expect(items
,item_count
);
2105 task
= task_list
[i
];
2107 /* deselect all items */
2108 ListView_SetItemState(hwnd
, -1, 0, LVIS_SELECTED
);
2109 SendMessage(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2111 /* set initial position */
2112 SendMessage(hwnd
, LVM_SETSELECTIONMARK
, 0, (task
.initPos
== -1 ? item_count
-1 : task
.initPos
));
2113 ListView_SetItemState(hwnd
,(task
.initPos
== -1 ? item_count
-1 : task
.initPos
),LVIS_SELECTED
,LVIS_SELECTED
);
2115 selected_count
= (int)SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2117 ok(selected_count
== 1, "There should be only one selected item at the beginning (is %d)\n",selected_count
);
2119 /* Set SHIFT key pressed */
2120 GetKeyboardState(kstate
);
2121 kstate
[VK_SHIFT
]=0x80;
2122 SetKeyboardState(kstate
);
2124 for (j
=1;j
<=(task
.count
== -1 ? item_count
: task
.count
);j
++) {
2125 r
= SendMessage(hwnd
, WM_KEYDOWN
, task
.loopVK
, 0);
2127 r
= SendMessage(hwnd
, WM_KEYUP
, task
.loopVK
, 0);
2131 selected_count
= (int)SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2133 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
);
2135 /* Set SHIFT key released */
2136 GetKeyboardState(kstate
);
2137 kstate
[VK_SHIFT
]=0x00;
2138 SetKeyboardState(kstate
);
2140 DestroyWindow(hwnd
);
2142 /* make multiple selection, then switch to LVS_SINGLESEL */
2143 hwnd
= create_listview_control(LVS_REPORT
);
2144 for (i
=0;i
<items
;i
++) {
2145 insert_item(hwnd
, 0);
2147 item_count
= (int)SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2148 expect(items
,item_count
);
2150 /* try with NULL pointer */
2151 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, 0);
2154 /* select all, check notifications */
2155 ListView_SetItemState(hwnd
, -1, 0, LVIS_SELECTED
);
2157 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2159 item
.stateMask
= LVIS_SELECTED
;
2160 item
.state
= LVIS_SELECTED
;
2161 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2164 ok_sequence(sequences
, PARENT_SEQ_INDEX
, select_all_parent_seq
,
2165 "select all notification", FALSE
);
2167 /* deselect all items */
2168 ListView_SetItemState(hwnd
, -1, 0, LVIS_SELECTED
);
2169 SendMessage(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2171 ListView_SetItemState(hwnd
, i
, LVIS_SELECTED
, LVIS_SELECTED
);
2174 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2176 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2179 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2180 ok(!(style
& LVS_SINGLESEL
), "LVS_SINGLESEL isn't expected\n");
2181 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SINGLESEL
);
2182 /* check that style is accepted */
2183 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2184 ok(style
& LVS_SINGLESEL
, "LVS_SINGLESEL expected\n");
2187 r
= ListView_GetItemState(hwnd
, i
, LVIS_SELECTED
);
2188 ok(r
& LVIS_SELECTED
, "Expected item %d to be selected\n", i
);
2190 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2192 SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2195 /* select one more */
2196 ListView_SetItemState(hwnd
, 3, LVIS_SELECTED
, LVIS_SELECTED
);
2199 r
= ListView_GetItemState(hwnd
, i
, LVIS_SELECTED
);
2200 ok(!(r
& LVIS_SELECTED
), "Expected item %d to be unselected\n", i
);
2202 r
= ListView_GetItemState(hwnd
, 3, LVIS_SELECTED
);
2203 ok(r
& LVIS_SELECTED
, "Expected item %d to be selected\n", i
);
2205 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2207 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2210 /* try to select all on LVS_SINGLESEL */
2211 memset(&item
, 0, sizeof(item
));
2212 item
.stateMask
= LVIS_SELECTED
;
2213 r
= SendMessage(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2215 SendMessage(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2217 item
.stateMask
= LVIS_SELECTED
;
2218 item
.state
= LVIS_SELECTED
;
2219 r
= SendMessage(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2222 r
= ListView_GetSelectedCount(hwnd
);
2224 r
= ListView_GetSelectionMark(hwnd
);
2227 /* try to deselect all on LVS_SINGLESEL */
2228 item
.stateMask
= LVIS_SELECTED
;
2229 item
.state
= LVIS_SELECTED
;
2230 r
= SendMessage(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2233 item
.stateMask
= LVIS_SELECTED
;
2235 r
= SendMessage(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2237 r
= ListView_GetSelectedCount(hwnd
);
2240 DestroyWindow(hwnd
);
2243 static void test_subitem_rect(void)
2251 /* test LVM_GETSUBITEMRECT for header */
2252 hwnd
= create_listview_control(LVS_REPORT
);
2253 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2254 /* add some columns */
2255 memset(&col
, 0, sizeof(LVCOLUMN
));
2256 col
.mask
= LVCF_WIDTH
;
2258 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
2261 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 1, (LPARAM
)&col
);
2264 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 2, (LPARAM
)&col
);
2266 /* item = -1 means header, subitem index is 1 based */
2267 rect
.left
= LVIR_BOUNDS
;
2269 rect
.right
= rect
.bottom
= 0;
2270 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2273 rect
.left
= LVIR_BOUNDS
;
2275 rect
.right
= rect
.bottom
= 0;
2276 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2279 expect(100, rect
.left
);
2280 expect(250, rect
.right
);
2282 expect(3, rect
.top
);
2284 rect
.left
= LVIR_BOUNDS
;
2286 rect
.right
= rect
.bottom
= 0;
2287 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2290 expect(250, rect
.left
);
2291 expect(450, rect
.right
);
2293 expect(3, rect
.top
);
2295 /* item LVS_REPORT padding isn't applied to subitems */
2296 insert_item(hwnd
, 0);
2298 rect
.left
= LVIR_BOUNDS
;
2300 rect
.right
= rect
.bottom
= 0;
2301 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2303 expect(100, rect
.left
);
2304 expect(250, rect
.right
);
2306 rect
.left
= LVIR_ICON
;
2308 rect
.right
= rect
.bottom
= 0;
2309 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2311 /* no icon attached - zero width rectangle, with no left padding */
2312 expect(100, rect
.left
);
2313 expect(100, rect
.right
);
2315 rect
.left
= LVIR_LABEL
;
2317 rect
.right
= rect
.bottom
= 0;
2318 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2320 /* same as full LVIR_BOUNDS */
2321 expect(100, rect
.left
);
2322 expect(250, rect
.right
);
2324 SendMessage(hwnd
, LVM_SCROLL
, 10, 0);
2326 rect
.left
= LVIR_BOUNDS
;
2328 rect
.right
= rect
.bottom
= 0;
2329 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2331 expect(90, rect
.left
);
2332 expect(240, rect
.right
);
2334 SendMessage(hwnd
, LVM_SCROLL
, -10, 0);
2336 DestroyWindow(hwnd
);
2338 /* test subitem rects after re-arranging columns */
2339 hwnd
= create_listview_control(LVS_REPORT
);
2340 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2341 memset(&col
, 0, sizeof(LVCOLUMN
));
2342 col
.mask
= LVCF_WIDTH
;
2345 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 0, (LPARAM
)&col
);
2349 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 1, (LPARAM
)&col
);
2353 r
= SendMessage(hwnd
, LVM_INSERTCOLUMN
, 2, (LPARAM
)&col
);
2356 insert_item(hwnd
, 0);
2357 insert_item(hwnd
, 1);
2359 /* wrong item is refused for main item */
2360 rect
.left
= LVIR_BOUNDS
;
2362 rect
.right
= rect
.bottom
= -1;
2363 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 2, (LPARAM
)&rect
);
2366 /* for subitems rectangle is calculated even if there's no item added */
2367 rect
.left
= LVIR_BOUNDS
;
2369 rect
.right
= rect
.bottom
= -1;
2370 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 1, (LPARAM
)&rect
);
2373 rect2
.left
= LVIR_BOUNDS
;
2375 rect2
.right
= rect2
.bottom
= -1;
2376 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 2, (LPARAM
)&rect2
);
2379 expect(rect
.right
, rect2
.right
);
2380 expect(rect
.left
, rect2
.left
);
2381 expect(rect
.bottom
, rect2
.top
);
2382 ok(rect2
.bottom
> rect2
.top
, "expected not zero height\n");
2385 arr
[0] = 1; arr
[1] = 0; arr
[2] = 2;
2386 r
= SendMessage(hwnd
, LVM_SETCOLUMNORDERARRAY
, 3, (LPARAM
)arr
);
2389 rect
.left
= LVIR_BOUNDS
;
2391 rect
.right
= rect
.bottom
= -1;
2392 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2394 expect(0, rect
.left
);
2395 expect(600, rect
.right
);
2397 rect
.left
= LVIR_BOUNDS
;
2399 rect
.right
= rect
.bottom
= -1;
2400 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2402 expect(0, rect
.left
);
2403 expect(200, rect
.right
);
2405 rect2
.left
= LVIR_BOUNDS
;
2407 rect2
.right
= rect2
.bottom
= -1;
2408 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 1, (LPARAM
)&rect2
);
2410 expect(0, rect2
.left
);
2411 expect(200, rect2
.right
);
2412 /* items are of the same height */
2413 ok(rect2
.top
> 0, "expected positive item height\n");
2414 expect(rect
.bottom
, rect2
.top
);
2415 expect(rect
.bottom
* 2 - rect
.top
, rect2
.bottom
);
2417 rect
.left
= LVIR_BOUNDS
;
2419 rect
.right
= rect
.bottom
= -1;
2420 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2422 expect(300, rect
.left
);
2423 expect(600, rect
.right
);
2425 DestroyWindow(hwnd
);
2427 /* try it for non LVS_REPORT style */
2428 hwnd
= CreateWindow("SysListView32", "Test", LVS_ICON
, 0, 0, 100, 100, NULL
, NULL
,
2429 GetModuleHandle(NULL
), 0);
2430 rect
.left
= LVIR_BOUNDS
;
2432 rect
.right
= rect
.bottom
= -10;
2433 r
= SendMessage(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2435 /* rect is unchanged */
2436 expect(0, rect
.left
);
2437 expect(-10, rect
.right
);
2438 expect(1, rect
.top
);
2439 expect(-10, rect
.bottom
);
2440 DestroyWindow(hwnd
);
2443 /* comparison callback for test_sorting */
2444 static INT WINAPI
test_CallBackCompare(LPARAM first
, LPARAM second
, LPARAM lParam
)
2446 if (first
== second
) return 0;
2447 return (first
> second
? 1 : -1);
2450 static void test_sorting(void)
2456 static CHAR names
[][5] = {"A", "B", "C", "D", "0"};
2459 hwnd
= create_listview_control(LVS_REPORT
);
2460 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2462 /* insert some items */
2463 item
.mask
= LVIF_PARAM
| LVIF_STATE
;
2464 item
.state
= LVIS_SELECTED
;
2468 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2471 item
.mask
= LVIF_PARAM
;
2475 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2478 item
.mask
= LVIF_STATE
| LVIF_PARAM
;
2479 item
.state
= LVIS_SELECTED
;
2483 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2486 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2489 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2492 r
= SendMessage(hwnd
, LVM_SORTITEMS
, 0, (LPARAM
)test_CallBackCompare
);
2495 r
= SendMessage(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2497 r
= SendMessage(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2499 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_SELECTED
);
2501 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 1, LVIS_SELECTED
);
2502 expect(LVIS_SELECTED
, r
);
2503 r
= SendMessage(hwnd
, LVM_GETITEMSTATE
, 2, LVIS_SELECTED
);
2504 expect(LVIS_SELECTED
, r
);
2506 DestroyWindow(hwnd
);
2508 /* switch to LVS_SORTASCENDING when some items added */
2509 hwnd
= create_listview_control(LVS_REPORT
);
2510 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2512 item
.mask
= LVIF_TEXT
;
2515 item
.pszText
= names
[1];
2516 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2519 item
.mask
= LVIF_TEXT
;
2522 item
.pszText
= names
[2];
2523 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2526 item
.mask
= LVIF_TEXT
;
2529 item
.pszText
= names
[0];
2530 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2533 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2534 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTASCENDING
);
2535 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2536 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2538 /* no sorting performed when switched to LVS_SORTASCENDING */
2539 item
.mask
= LVIF_TEXT
;
2541 item
.pszText
= buff
;
2542 item
.cchTextMax
= sizeof(buff
);
2543 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2545 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2548 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2550 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2553 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2555 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2557 /* adding new item doesn't resort list */
2558 item
.mask
= LVIF_TEXT
;
2561 item
.pszText
= names
[3];
2562 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2565 item
.mask
= LVIF_TEXT
;
2567 item
.pszText
= buff
;
2568 item
.cchTextMax
= sizeof(buff
);
2569 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2571 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2574 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2576 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2579 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2581 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2584 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2586 ok(lstrcmp(buff
, names
[3]) == 0, "Expected '%s', got '%s'\n", names
[3], buff
);
2588 /* corner case - item should be placed at first position */
2589 item
.mask
= LVIF_TEXT
;
2592 item
.pszText
= names
[4];
2593 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
2597 item
.pszText
= buff
;
2598 item
.cchTextMax
= sizeof(buff
);
2599 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2601 ok(lstrcmp(buff
, names
[4]) == 0, "Expected '%s', got '%s'\n", names
[4], buff
);
2604 item
.pszText
= buff
;
2605 item
.cchTextMax
= sizeof(buff
);
2606 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2608 ok(lstrcmp(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2611 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2613 ok(lstrcmp(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2616 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2618 ok(lstrcmp(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2621 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
) &item
);
2623 ok(lstrcmp(buff
, names
[3]) == 0, "Expected '%s', got '%s'\n", names
[3], buff
);
2625 DestroyWindow(hwnd
);
2628 static void test_ownerdata(void)
2631 LONG_PTR style
, ret
;
2635 /* it isn't possible to set LVS_OWNERDATA after creation */
2638 win_skip("set LVS_OWNERDATA after creation leads to crash on < 5.80\n");
2642 hwnd
= create_listview_control(LVS_REPORT
);
2643 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2644 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2645 ok(!(style
& LVS_OWNERDATA
) && style
, "LVS_OWNERDATA isn't expected\n");
2647 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2649 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_OWNERDATA
);
2650 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2651 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2652 "try to switch to LVS_OWNERDATA seq", FALSE
);
2654 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2655 ok(!(style
& LVS_OWNERDATA
), "LVS_OWNERDATA isn't expected\n");
2656 DestroyWindow(hwnd
);
2659 /* try to set LVS_OWNERDATA after creation just having it */
2660 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2661 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2662 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2663 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2665 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2667 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_OWNERDATA
);
2668 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2669 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2670 "try to switch to LVS_OWNERDATA seq", FALSE
);
2671 DestroyWindow(hwnd
);
2673 /* try to remove LVS_OWNERDATA after creation just having it */
2676 win_skip("remove LVS_OWNERDATA after creation leads to crash on < 5.80\n");
2680 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2681 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2682 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2683 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2685 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2687 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_OWNERDATA
);
2688 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
2689 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
2690 "try to switch to LVS_OWNERDATA seq", FALSE
);
2691 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2692 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
2693 DestroyWindow(hwnd
);
2696 /* try select an item */
2697 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2698 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2699 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2701 res
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2703 memset(&item
, 0, sizeof(item
));
2704 item
.stateMask
= LVIS_SELECTED
;
2705 item
.state
= LVIS_SELECTED
;
2706 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2708 res
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2710 res
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2712 DestroyWindow(hwnd
);
2714 /* LVM_SETITEM is unsupported on LVS_OWNERDATA */
2715 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2716 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2717 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2719 res
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2721 memset(&item
, 0, sizeof(item
));
2722 item
.mask
= LVIF_STATE
;
2724 item
.stateMask
= LVIS_SELECTED
;
2725 item
.state
= LVIS_SELECTED
;
2726 res
= SendMessageA(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
2728 DestroyWindow(hwnd
);
2730 /* check notifications after focused/selected changed */
2731 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2732 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2733 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 20, 0);
2736 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2738 memset(&item
, 0, sizeof(item
));
2739 item
.stateMask
= LVIS_SELECTED
;
2740 item
.state
= LVIS_SELECTED
;
2741 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2744 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownderdata_select_focus_parent_seq
,
2745 "ownerdata select notification", TRUE
);
2747 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2749 memset(&item
, 0, sizeof(item
));
2750 item
.stateMask
= LVIS_FOCUSED
;
2751 item
.state
= LVIS_FOCUSED
;
2752 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2755 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownderdata_select_focus_parent_seq
,
2756 "ownerdata focus notification", TRUE
);
2758 /* select all, check notifications */
2759 item
.stateMask
= LVIS_SELECTED
;
2761 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2764 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2766 item
.stateMask
= LVIS_SELECTED
;
2767 item
.state
= LVIS_SELECTED
;
2769 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
2770 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2772 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
2773 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
2774 ok(g_nmlistview
.uNewState
== LVIS_SELECTED
, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
2775 ok(g_nmlistview
.uOldState
== 0, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
2776 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
2777 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
2778 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
2780 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2781 "ownerdata select all notification", FALSE
);
2783 /* select all again, note that all items are selected already */
2784 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2785 item
.stateMask
= LVIS_SELECTED
;
2786 item
.state
= LVIS_SELECTED
;
2788 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
2789 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2791 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
2792 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
2793 ok(g_nmlistview
.uNewState
== LVIS_SELECTED
, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
2794 ok(g_nmlistview
.uOldState
== 0, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
2795 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
2796 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
2797 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
2799 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2800 "ownerdata select all notification", FALSE
);
2803 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2804 item
.stateMask
= LVIS_SELECTED
;
2807 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
2808 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2810 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
2811 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
2812 ok(g_nmlistview
.uNewState
== 0, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
2813 ok(g_nmlistview
.uOldState
== LVIS_SELECTED
, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
2814 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
2815 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
2816 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
2818 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_deselect_all_parent_seq
,
2819 "ownerdata deselect all notification", TRUE
);
2821 /* nothing selected, deselect all again */
2822 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2823 item
.stateMask
= LVIS_SELECTED
;
2826 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2829 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "ownerdata deselect all notification", TRUE
);
2831 /* select one, then deselect all */
2832 item
.stateMask
= LVIS_SELECTED
;
2833 item
.state
= LVIS_SELECTED
;
2834 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2836 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2837 item
.stateMask
= LVIS_SELECTED
;
2840 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
2841 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2843 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
2844 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
2845 ok(g_nmlistview
.uNewState
== 0, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
2846 ok(g_nmlistview
.uOldState
== LVIS_SELECTED
, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
2847 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
2848 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
2849 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
2851 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_deselect_all_parent_seq
,
2852 "ownerdata select all notification", TRUE
);
2854 /* remove focused, try to focus all */
2855 item
.stateMask
= LVIS_FOCUSED
;
2856 item
.state
= LVIS_FOCUSED
;
2857 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2859 item
.stateMask
= LVIS_FOCUSED
;
2861 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2863 item
.stateMask
= LVIS_FOCUSED
;
2864 res
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_FOCUSED
);
2867 /* setting all to focused returns failure value */
2868 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2869 item
.stateMask
= LVIS_FOCUSED
;
2870 item
.state
= LVIS_FOCUSED
;
2872 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2875 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2876 "ownerdata focus all notification", FALSE
);
2878 /* focus single item, remove all */
2879 item
.stateMask
= LVIS_FOCUSED
;
2880 item
.state
= LVIS_FOCUSED
;
2881 res
= SendMessage(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2883 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2884 item
.stateMask
= LVIS_FOCUSED
;
2887 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
2888 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2890 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
2891 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
2892 ok(g_nmlistview
.uNewState
== 0, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
2893 ok(g_nmlistview
.uOldState
== LVIS_FOCUSED
, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
2894 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
2895 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
2896 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
2898 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_defocus_all_parent_seq
,
2899 "ownerdata remove focus all notification", TRUE
);
2902 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2903 item
.stateMask
= LVIS_CUT
;
2904 item
.state
= LVIS_CUT
;
2906 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
2907 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2909 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
2910 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
2911 ok(g_nmlistview
.uNewState
== LVIS_CUT
, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
2912 ok(g_nmlistview
.uOldState
== 0, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
2913 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
2914 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
2915 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
2917 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2918 "ownerdata cut all notification", FALSE
);
2920 /* all marked cut, try again */
2921 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2922 item
.stateMask
= LVIS_CUT
;
2923 item
.state
= LVIS_CUT
;
2925 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
2926 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2928 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
2929 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
2930 ok(g_nmlistview
.uNewState
== LVIS_CUT
, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
2931 ok(g_nmlistview
.uOldState
== 0, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
2932 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
2933 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
2934 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
2936 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
2937 "ownerdata cut all notification #2", FALSE
);
2939 DestroyWindow(hwnd
);
2941 /* check notifications on LVM_GETITEM */
2942 /* zero callback mask */
2943 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
2944 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2945 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
2948 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2950 memset(&item
, 0, sizeof(item
));
2951 item
.stateMask
= LVIS_SELECTED
;
2952 item
.mask
= LVIF_STATE
;
2953 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2956 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2957 "ownerdata getitem selected state 1", FALSE
);
2959 /* non zero callback mask but not we asking for */
2960 res
= SendMessageA(hwnd
, LVM_SETCALLBACKMASK
, LVIS_OVERLAYMASK
, 0);
2963 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2965 memset(&item
, 0, sizeof(item
));
2966 item
.stateMask
= LVIS_SELECTED
;
2967 item
.mask
= LVIF_STATE
;
2968 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2971 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
2972 "ownerdata getitem selected state 2", FALSE
);
2974 /* LVIS_OVERLAYMASK callback mask, asking for index */
2975 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2977 memset(&item
, 0, sizeof(item
));
2978 item
.stateMask
= LVIS_OVERLAYMASK
;
2979 item
.mask
= LVIF_STATE
;
2980 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
2983 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
2984 "ownerdata getitem selected state 2", FALSE
);
2986 DestroyWindow(hwnd
);
2988 /* LVS_SORTASCENDING/LVS_SORTDESCENDING aren't compatible with LVS_OWNERDATA */
2989 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_SORTASCENDING
| LVS_REPORT
);
2990 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2991 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2992 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
2993 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2994 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_SORTASCENDING
);
2995 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2996 ok(!(style
& LVS_SORTASCENDING
), "Expected LVS_SORTASCENDING not set\n");
2997 DestroyWindow(hwnd
);
2998 /* apparently it's allowed to switch these style on after creation */
2999 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3000 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3001 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3002 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
3003 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTASCENDING
);
3004 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3005 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
3006 DestroyWindow(hwnd
);
3008 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3009 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3010 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3011 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
3012 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTDESCENDING
);
3013 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3014 ok(style
& LVS_SORTDESCENDING
, "Expected LVS_SORTDESCENDING to be set\n");
3015 DestroyWindow(hwnd
);
3018 static void test_norecompute(void)
3020 static CHAR testA
[] = "test";
3026 /* self containing control */
3027 hwnd
= create_listview_control(LVS_REPORT
);
3028 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3029 memset(&item
, 0, sizeof(item
));
3030 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
3032 item
.stateMask
= LVIS_SELECTED
;
3033 item
.state
= LVIS_SELECTED
;
3034 item
.pszText
= testA
;
3035 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
3037 /* retrieve with LVIF_NORECOMPUTE */
3038 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
3040 item
.pszText
= buff
;
3041 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
3042 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
3044 ok(lstrcmp(buff
, testA
) == 0, "Expected (%s), got (%s)\n", testA
, buff
);
3046 item
.mask
= LVIF_TEXT
;
3048 item
.pszText
= LPSTR_TEXTCALLBACK
;
3049 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
3052 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
3054 item
.pszText
= buff
;
3055 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
3057 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3058 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
3060 ok(item
.pszText
== LPSTR_TEXTCALLBACK
, "Expected (%p), got (%p)\n",
3061 LPSTR_TEXTCALLBACK
, (VOID
*)item
.pszText
);
3062 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "retrieve with LVIF_NORECOMPUTE seq", FALSE
);
3064 DestroyWindow(hwnd
);
3067 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3068 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3070 item
.mask
= LVIF_STATE
;
3071 item
.stateMask
= LVIS_SELECTED
;
3072 item
.state
= LVIS_SELECTED
;
3074 res
= SendMessageA(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&item
);
3077 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
3079 item
.pszText
= buff
;
3080 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
3081 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3082 res
= SendMessageA(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
3084 ok(item
.pszText
== LPSTR_TEXTCALLBACK
, "Expected (%p), got (%p)\n",
3085 LPSTR_TEXTCALLBACK
, (VOID
*)item
.pszText
);
3086 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "retrieve with LVIF_NORECOMPUTE seq 2", FALSE
);
3088 DestroyWindow(hwnd
);
3091 static void test_nosortheader(void)
3096 hwnd
= create_listview_control(LVS_REPORT
);
3097 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3099 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
3100 ok(IsWindow(header
), "header expected\n");
3102 style
= GetWindowLongPtr(header
, GWL_STYLE
);
3103 ok(style
& HDS_BUTTONS
, "expected header to have HDS_BUTTONS\n");
3105 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3106 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
| LVS_NOSORTHEADER
);
3107 /* HDS_BUTTONS retained */
3108 style
= GetWindowLongPtr(header
, GWL_STYLE
);
3109 ok(style
& HDS_BUTTONS
, "expected header to retain HDS_BUTTONS\n");
3111 DestroyWindow(hwnd
);
3113 /* create with LVS_NOSORTHEADER */
3114 hwnd
= create_listview_control(LVS_NOSORTHEADER
| LVS_REPORT
);
3115 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3117 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
3118 ok(IsWindow(header
), "header expected\n");
3120 style
= GetWindowLongPtr(header
, GWL_STYLE
);
3121 ok(!(style
& HDS_BUTTONS
), "expected header to have no HDS_BUTTONS\n");
3123 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3124 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
& ~LVS_NOSORTHEADER
);
3125 /* not changed here */
3126 style
= GetWindowLongPtr(header
, GWL_STYLE
);
3127 ok(!(style
& HDS_BUTTONS
), "expected header to have no HDS_BUTTONS\n");
3129 DestroyWindow(hwnd
);
3132 static void test_setredraw(void)
3140 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3141 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3143 /* Passing WM_SETREDRAW to DefWinProc removes WS_VISIBLE.
3144 ListView seems to handle it internally without DefWinProc */
3146 /* default value first */
3147 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3150 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3151 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
3152 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3154 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
3155 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
3156 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3159 /* check update rect after redrawing */
3160 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3162 InvalidateRect(hwnd
, NULL
, FALSE
);
3163 RedrawWindow(hwnd
, NULL
, NULL
, RDW_UPDATENOW
);
3164 rect
.right
= rect
.bottom
= 1;
3165 GetUpdateRect(hwnd
, &rect
, FALSE
);
3166 expect(0, rect
.right
);
3167 expect(0, rect
.bottom
);
3170 hdc
= GetWindowDC(hwndparent
);
3171 ret
= SendMessage(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
3173 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3175 ret
= SendMessage(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
3177 ret
= SendMessage(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3179 ReleaseDC(hwndparent
, hdc
);
3181 /* check notification messages to show that repainting is disabled */
3182 ret
= SendMessage(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
3184 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3186 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3188 InvalidateRect(hwnd
, NULL
, TRUE
);
3190 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3191 "redraw after WM_SETREDRAW (FALSE)", FALSE
);
3193 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, CLR_NONE
);
3195 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3196 InvalidateRect(hwnd
, NULL
, TRUE
);
3198 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3199 "redraw after WM_SETREDRAW (FALSE) with CLR_NONE bkgnd", FALSE
);
3201 /* message isn't forwarded to header */
3202 subclass_header(hwnd
);
3203 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3204 ret
= SendMessage(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3206 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, setredraw_seq
,
3207 "WM_SETREDRAW: not forwarded to header", FALSE
);
3209 DestroyWindow(hwnd
);
3212 static void test_hittest(void)
3218 static CHAR text
[] = "1234567890ABCDEFGHIJKLMNOPQRST";
3222 HIMAGELIST himl
, himl2
;
3225 hwnd
= create_listview_control(LVS_REPORT
);
3226 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3228 /* LVS_REPORT with a single subitem (2 columns) */
3229 insert_column(hwnd
, 0);
3230 insert_column(hwnd
, 1);
3231 insert_item(hwnd
, 0);
3234 /* the only purpose of that line is to be as long as a half item rect */
3235 item
.pszText
= text
;
3236 r
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&item
);
3239 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
3241 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(100, 0));
3244 memset(&bounds
, 0, sizeof(bounds
));
3245 bounds
.left
= LVIR_BOUNDS
;
3246 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&bounds
);
3248 ok(bounds
.bottom
- bounds
.top
> 0, "Expected non zero item height\n");
3249 ok(bounds
.right
- bounds
.left
> 0, "Expected non zero item width\n");
3250 r
= SendMessage(hwnd
, LVM_GETITEMSPACING
, TRUE
, 0);
3252 ok(bounds
.bottom
- bounds
.top
== vert
,
3253 "Vertical spacing inconsistent (%d != %d)\n", bounds
.bottom
- bounds
.top
, vert
);
3254 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pos
);
3257 /* LVS_EX_FULLROWSELECT not set, no icons attached */
3259 /* outside columns by x position - valid is [0, 199] */
3261 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3262 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TOLEFT
, 0, FALSE
, FALSE
);
3263 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3265 x
= pos
.x
+ 50; /* column half width */
3266 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3267 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMLABEL
, 0, FALSE
, FALSE
);
3268 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3269 x
= pos
.x
+ 150; /* outside column */
3270 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3271 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
);
3272 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3273 y
= (bounds
.bottom
- bounds
.top
) / 2;
3274 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
);
3275 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3276 /* outside possible client rectangle (to right) */
3278 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3279 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
);
3280 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3281 y
= (bounds
.bottom
- bounds
.top
) / 2;
3282 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
);
3283 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3284 /* subitem returned with -1 item too */
3286 y
= bounds
.top
- vert
;
3287 test_lvm_subitemhittest(hwnd
, x
, y
, -1, 1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3288 test_lvm_subitemhittest(hwnd
, x
, y
- vert
+ 1, -1, 1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3289 /* return values appear to underflow with negative indices */
3293 test_lvm_subitemhittest(hwnd
, x
, y
, i
, 1, LVHT_ONITEMLABEL
, TRUE
, FALSE
, TRUE
);
3294 test_lvm_subitemhittest(hwnd
, x
, y
- vert
+ 1, i
, 1, LVHT_ONITEMLABEL
, TRUE
, FALSE
, TRUE
);
3298 /* parent client area is 100x100 by default */
3299 MoveWindow(hwnd
, 0, 0, 300, 100, FALSE
);
3300 x
= pos
.x
+ 150; /* outside column */
3301 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3302 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_NOWHERE
, 0, FALSE
, FALSE
);
3303 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3304 y
= (bounds
.bottom
- bounds
.top
) / 2;
3305 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_NOWHERE
, 0, FALSE
, TRUE
);
3306 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3307 /* the same with LVS_EX_FULLROWSELECT */
3308 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_FULLROWSELECT
);
3309 x
= pos
.x
+ 150; /* outside column */
3310 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3311 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEM
, LVHT_ONITEMLABEL
, FALSE
, FALSE
);
3312 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3313 y
= (bounds
.bottom
- bounds
.top
) / 2;
3314 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3315 MoveWindow(hwnd
, 0, 0, 100, 100, FALSE
);
3316 x
= pos
.x
+ 150; /* outside column */
3317 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3318 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
);
3319 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3320 y
= (bounds
.bottom
- bounds
.top
) / 2;
3321 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
);
3322 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3323 /* outside possible client rectangle (to right) */
3325 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3326 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
);
3327 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3328 y
= (bounds
.bottom
- bounds
.top
) / 2;
3329 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
);
3330 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3331 /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
3332 himl
= ImageList_Create(16, 16, 0, 4, 4);
3333 ok(himl
!= NULL
, "failed to create imagelist\n");
3334 hbmp
= CreateBitmap(16, 16, 1, 1, NULL
);
3335 ok(hbmp
!= NULL
, "failed to create bitmap\n");
3336 r
= ImageList_Add(himl
, hbmp
, 0);
3337 ok(r
== 0, "should be zero\n");
3338 hbmp
= CreateBitmap(16, 16, 1, 1, NULL
);
3339 ok(hbmp
!= NULL
, "failed to create bitmap\n");
3340 r
= ImageList_Add(himl
, hbmp
, 0);
3341 ok(r
== 1, "should be one\n");
3343 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl
);
3346 item
.mask
= LVIF_IMAGE
;
3350 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3354 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3355 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMSTATEICON
, 0, FALSE
, FALSE
);
3356 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
);
3357 y
= (bounds
.bottom
- bounds
.top
) / 2;
3358 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
);
3360 /* state icons indices are 1 based, check with valid index */
3361 item
.mask
= LVIF_STATE
;
3362 item
.state
= INDEXTOSTATEIMAGEMASK(1);
3363 item
.stateMask
= LVIS_STATEIMAGEMASK
;
3366 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3370 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3371 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMSTATEICON
, 0, FALSE
, FALSE
);
3372 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
);
3373 y
= (bounds
.bottom
- bounds
.top
) / 2;
3374 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
);
3376 himl2
= (HIMAGELIST
)SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, 0);
3377 ok(himl2
== himl
, "should return handle\n");
3379 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl
);
3383 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3384 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMICON
, 0, FALSE
, FALSE
);
3385 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMICON
, FALSE
, FALSE
, FALSE
);
3386 y
= (bounds
.bottom
- bounds
.top
) / 2;
3387 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMICON
, FALSE
, FALSE
, FALSE
);
3389 DestroyWindow(hwnd
);
3392 static void test_getviewrect(void)
3399 hwnd
= create_listview_control(LVS_REPORT
);
3400 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3403 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3406 insert_column(hwnd
, 0);
3407 insert_column(hwnd
, 1);
3409 memset(&item
, 0, sizeof(item
));
3412 SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3414 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
3416 r
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(120, 0));
3419 rect
.left
= rect
.right
= rect
.top
= rect
.bottom
= -1;
3420 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3422 /* left is set to (2e31-1) - XP SP2 */
3423 expect(0, rect
.right
);
3424 expect(0, rect
.top
);
3425 expect(0, rect
.bottom
);
3427 /* switch to LVS_ICON */
3428 SetWindowLong(hwnd
, GWL_STYLE
, GetWindowLong(hwnd
, GWL_STYLE
) & ~LVS_REPORT
);
3430 rect
.left
= rect
.right
= rect
.top
= rect
.bottom
= -1;
3431 r
= SendMessage(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3433 expect(0, rect
.left
);
3434 expect(0, rect
.top
);
3435 /* precise value differs for 2k, XP and Vista */
3436 ok(rect
.bottom
> 0, "Expected positive bottom value, got %d\n", rect
.bottom
);
3437 ok(rect
.right
> 0, "Expected positive right value, got %d\n", rect
.right
);
3439 DestroyWindow(hwnd
);
3442 static void test_getitemposition(void)
3449 hwnd
= create_listview_control(LVS_REPORT
);
3450 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3451 header
= subclass_header(hwnd
);
3453 /* LVS_REPORT, single item, no columns added */
3454 insert_item(hwnd
, 0);
3456 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3459 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3461 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getitemposition_seq1
, "get item position 1", FALSE
);
3463 /* LVS_REPORT, single item, single column */
3464 insert_column(hwnd
, 0);
3466 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3469 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3471 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getitemposition_seq2
, "get item position 2", TRUE
);
3473 memset(&rect
, 0, sizeof(rect
));
3474 SendMessage(header
, HDM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3477 /* offset by header height */
3478 expect(rect
.bottom
- rect
.top
, pt
.y
);
3480 DestroyWindow(hwnd
);
3483 static void test_columnscreation(void)
3488 hwnd
= create_listview_control(LVS_REPORT
);
3489 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3491 insert_item(hwnd
, 0);
3493 /* headers columns aren't created automatically */
3494 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
3495 ok(IsWindow(header
), "Expected header handle\n");
3496 r
= SendMessage(header
, HDM_GETITEMCOUNT
, 0, 0);
3499 DestroyWindow(hwnd
);
3502 static void test_getitemrect(void)
3505 HIMAGELIST himl
, himl_ret
;
3515 /* rectangle isn't empty for empty text items */
3516 hwnd
= create_listview_control(LVS_LIST
);
3517 memset(&item
, 0, sizeof(item
));
3520 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3522 rect
.left
= LVIR_LABEL
;
3523 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3525 expect(0, rect
.left
);
3526 expect(0, rect
.top
);
3528 todo_wine
expect(((GetDeviceCaps(hdc
, LOGPIXELSX
) + 15) / 16) * 16, rect
.right
);
3529 ReleaseDC(hwnd
, hdc
);
3530 DestroyWindow(hwnd
);
3532 hwnd
= create_listview_control(LVS_REPORT
);
3533 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3536 memset(&item
, 0, sizeof(item
));
3539 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3542 rect
.left
= LVIR_BOUNDS
;
3543 rect
.right
= rect
.top
= rect
.bottom
= -1;
3544 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3547 /* zero width rectangle with no padding */
3548 expect(0, rect
.left
);
3549 expect(0, rect
.right
);
3551 insert_column(hwnd
, 0);
3552 insert_column(hwnd
, 1);
3554 col
.mask
= LVCF_WIDTH
;
3556 r
= SendMessage(hwnd
, LVM_SETCOLUMN
, 0, (LPARAM
)&col
);
3559 col
.mask
= LVCF_WIDTH
;
3561 r
= SendMessage(hwnd
, LVM_SETCOLUMN
, 1, (LPARAM
)&col
);
3564 rect
.left
= LVIR_BOUNDS
;
3565 rect
.right
= rect
.top
= rect
.bottom
= -1;
3566 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3569 /* still no left padding */
3570 expect(0, rect
.left
);
3571 expect(150, rect
.right
);
3573 rect
.left
= LVIR_SELECTBOUNDS
;
3574 rect
.right
= rect
.top
= rect
.bottom
= -1;
3575 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3578 expect(2, rect
.left
);
3580 rect
.left
= LVIR_LABEL
;
3581 rect
.right
= rect
.top
= rect
.bottom
= -1;
3582 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3584 /* padding, column width */
3585 expect(2, rect
.left
);
3586 expect(50, rect
.right
);
3588 /* no icons attached */
3589 rect
.left
= LVIR_ICON
;
3590 rect
.right
= rect
.top
= rect
.bottom
= -1;
3591 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3594 expect(2, rect
.left
);
3595 expect(2, rect
.right
);
3598 order
[0] = 1; order
[1] = 0;
3599 r
= SendMessage(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
3602 r
= SendMessage(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3604 /* 1 indexed column width + padding */
3606 /* rect is at zero too */
3607 rect
.left
= LVIR_BOUNDS
;
3608 rect
.right
= rect
.top
= rect
.bottom
= -1;
3609 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3611 expect(0, rect
.left
);
3612 /* just width sum */
3613 expect(150, rect
.right
);
3615 rect
.left
= LVIR_SELECTBOUNDS
;
3616 rect
.right
= rect
.top
= rect
.bottom
= -1;
3617 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3619 /* column width + padding */
3620 expect(102, rect
.left
);
3622 /* back to initial order */
3623 order
[0] = 0; order
[1] = 1;
3624 r
= SendMessage(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
3628 himl
= ImageList_Create(16, 16, 0, 2, 2);
3629 ok(himl
!= NULL
, "failed to create imagelist\n");
3630 hbm
= CreateBitmap(16, 16, 1, 1, NULL
);
3631 ok(hbm
!= NULL
, "failed to create bitmap\n");
3632 r
= ImageList_Add(himl
, hbm
, 0);
3634 hbm
= CreateBitmap(16, 16, 1, 1, NULL
);
3635 ok(hbm
!= NULL
, "failed to create bitmap\n");
3636 r
= ImageList_Add(himl
, hbm
, 0);
3639 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl
);
3642 item
.mask
= LVIF_STATE
;
3643 item
.state
= INDEXTOSTATEIMAGEMASK(1);
3644 item
.stateMask
= LVIS_STATEIMAGEMASK
;
3647 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3651 rect
.left
= LVIR_ICON
;
3652 rect
.right
= rect
.top
= rect
.bottom
= -1;
3653 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3655 /* padding + stateicon width */
3656 expect(18, rect
.left
);
3657 expect(18, rect
.right
);
3659 rect
.left
= LVIR_LABEL
;
3660 rect
.right
= rect
.top
= rect
.bottom
= -1;
3661 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3663 /* padding + stateicon width -> column width */
3664 expect(18, rect
.left
);
3665 expect(50, rect
.right
);
3667 himl_ret
= (HIMAGELIST
)SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, 0);
3668 ok(himl_ret
== himl
, "got %p, expected %p\n", himl_ret
, himl
);
3670 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl
);
3673 item
.mask
= LVIF_STATE
| LVIF_IMAGE
;
3676 item
.stateMask
= ~0;
3679 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3683 rect
.left
= LVIR_ICON
;
3684 rect
.right
= rect
.top
= rect
.bottom
= -1;
3685 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3687 /* padding, icon width */
3688 expect(2, rect
.left
);
3689 expect(18, rect
.right
);
3691 rect
.left
= LVIR_LABEL
;
3692 rect
.right
= rect
.top
= rect
.bottom
= -1;
3693 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3695 /* padding + icon width -> column width */
3696 expect(18, rect
.left
);
3697 expect(50, rect
.right
);
3700 rect
.left
= LVIR_SELECTBOUNDS
;
3701 rect
.right
= rect
.top
= rect
.bottom
= -1;
3702 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3704 /* padding, column width */
3705 expect(2, rect
.left
);
3706 expect(50, rect
.right
);
3708 /* try with indentation */
3709 item
.mask
= LVIF_INDENT
;
3713 r
= SendMessage(hwnd
, LVM_SETITEM
, 0, (LPARAM
)&item
);
3717 rect
.left
= LVIR_BOUNDS
;
3718 rect
.right
= rect
.top
= rect
.bottom
= -1;
3719 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3721 /* padding + 1 icon width, column width */
3722 expect(0, rect
.left
);
3723 expect(150, rect
.right
);
3726 rect
.left
= LVIR_SELECTBOUNDS
;
3727 rect
.right
= rect
.top
= rect
.bottom
= -1;
3728 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3730 /* padding + 1 icon width, column width */
3731 expect(2 + 16, rect
.left
);
3732 expect(50, rect
.right
);
3735 rect
.left
= LVIR_LABEL
;
3736 rect
.right
= rect
.top
= rect
.bottom
= -1;
3737 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3739 /* padding + 2 icon widths, column width */
3740 expect(2 + 16*2, rect
.left
);
3741 expect(50, rect
.right
);
3744 rect
.left
= LVIR_ICON
;
3745 rect
.right
= rect
.top
= rect
.bottom
= -1;
3746 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3748 /* padding + 1 icon width indentation, icon width */
3749 expect(2 + 16, rect
.left
);
3750 expect(34, rect
.right
);
3752 DestroyWindow(hwnd
);
3755 static void test_editbox(void)
3757 static CHAR testitemA
[] = "testitem";
3758 static CHAR testitem1A
[] = "testitem_quitelongname";
3759 static CHAR testitem2A
[] = "testITEM_quitelongname";
3760 static CHAR buffer
[25];
3761 HWND hwnd
, hwndedit
, hwndedit2
, header
;
3765 hwnd
= create_listview_control(LVS_EDITLABELS
| LVS_REPORT
);
3766 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3768 insert_column(hwnd
, 0);
3770 memset(&item
, 0, sizeof(item
));
3771 item
.mask
= LVIF_TEXT
;
3772 item
.pszText
= testitemA
;
3775 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3778 /* test notifications without edit created */
3779 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3780 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_SETFOCUS
), (LPARAM
)0xdeadbeef);
3782 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3783 "edit box WM_COMMAND (EN_SETFOCUS), no edit created", FALSE
);
3784 /* same thing but with valid window */
3785 hwndedit
= CreateWindowA("Edit", "Test edit", WS_VISIBLE
| WS_CHILD
, 0, 0, 20,
3786 10, hwnd
, (HMENU
)1, (HINSTANCE
)GetWindowLongPtrA(hwnd
, GWLP_HINSTANCE
), 0);
3787 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3788 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_SETFOCUS
), (LPARAM
)hwndedit
);
3790 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3791 "edit box WM_COMMAND (EN_SETFOCUS), no edit created #2", FALSE
);
3792 DestroyWindow(hwndedit
);
3794 /* setting focus is necessary */
3796 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3797 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3799 /* test children Z-order after Edit box created */
3800 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
3801 ok(IsWindow(header
), "Expected header to be created\n");
3802 ok(GetTopWindow(hwnd
) == header
, "Expected header to be on top\n");
3803 ok(GetNextWindow(header
, GW_HWNDNEXT
) == hwndedit
, "got %p\n", GetNextWindow(header
, GW_HWNDNEXT
));
3805 /* modify initial string */
3806 r
= SendMessage(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem1A
);
3809 /* edit window is resized and repositioned,
3810 check again for Z-order - it should be preserved */
3811 ok(GetTopWindow(hwnd
) == header
, "Expected header to be on top\n");
3812 ok(GetNextWindow(header
, GW_HWNDNEXT
) == hwndedit
, "got %p\n", GetNextWindow(header
, GW_HWNDNEXT
));
3814 /* return focus to listview */
3817 memset(&item
, 0, sizeof(item
));
3818 item
.mask
= LVIF_TEXT
;
3819 item
.pszText
= buffer
;
3820 item
.cchTextMax
= sizeof(buffer
);
3823 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3826 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
3828 /* send LVM_EDITLABEL on already created edit */
3830 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3831 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3832 /* focus will be set to edit */
3833 ok(GetFocus() == hwndedit
, "Expected Edit window to be focused\n");
3834 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3835 ok(IsWindow(hwndedit2
), "Expected Edit window to be created\n");
3837 /* creating label disabled when control isn't focused */
3839 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3840 todo_wine
ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3842 /* check EN_KILLFOCUS handling */
3843 memset(&item
, 0, sizeof(item
));
3844 item
.pszText
= testitemA
;
3847 r
= SendMessage(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
3851 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3852 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3853 /* modify edit and notify control that it lost focus */
3854 r
= SendMessage(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem1A
);
3856 g_editbox_disp_info
.item
.pszText
= NULL
;
3857 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
3859 ok(g_editbox_disp_info
.item
.pszText
!= NULL
, "expected notification with not null text\n");
3861 memset(&item
, 0, sizeof(item
));
3862 item
.pszText
= buffer
;
3863 item
.cchTextMax
= sizeof(buffer
);
3866 r
= SendMessage(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
3867 expect(lstrlen(item
.pszText
), r
);
3868 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
3869 ok(!IsWindow(hwndedit
), "Expected Edit window to be freed\n");
3871 /* change item name to differ in casing only */
3873 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3874 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3875 /* modify edit and notify control that it lost focus */
3876 r
= SendMessage(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem2A
);
3878 g_editbox_disp_info
.item
.pszText
= NULL
;
3879 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
3881 ok(g_editbox_disp_info
.item
.pszText
!= NULL
, "got %p\n", g_editbox_disp_info
.item
.pszText
);
3883 memset(&item
, 0, sizeof(item
));
3884 item
.pszText
= buffer
;
3885 item
.cchTextMax
= sizeof(buffer
);
3888 r
= SendMessage(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
3889 expect(lstrlen(item
.pszText
), r
);
3890 ok(strcmp(buffer
, testitem2A
) == 0, "got %s, expected %s\n", buffer
, testitem2A
);
3891 ok(!IsWindow(hwndedit
), "Expected Edit window to be freed\n");
3893 /* end edit without saving */
3895 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3896 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3897 r
= SendMessage(hwndedit
, WM_KEYDOWN
, VK_ESCAPE
, 0);
3899 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3900 "edit box - end edit, no change, escape", TRUE
);
3901 /* end edit with saving */
3903 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3904 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3905 r
= SendMessage(hwndedit
, WM_KEYDOWN
, VK_RETURN
, 0);
3907 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3908 "edit box - end edit, no change, return", TRUE
);
3910 memset(&item
, 0, sizeof(item
));
3911 item
.pszText
= buffer
;
3912 item
.cchTextMax
= sizeof(buffer
);
3915 r
= SendMessage(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
3916 expect(lstrlen(item
.pszText
), r
);
3917 ok(strcmp(buffer
, testitem2A
) == 0, "Expected item text to change\n");
3919 /* LVM_EDITLABEL with -1 destroys current edit */
3920 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_GETEDITCONTROL
, 0, 0);
3921 ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3922 /* no edit present */
3923 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -1, 0);
3924 ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
3925 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3926 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3928 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3929 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -1, 0);
3930 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3931 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3932 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3933 /* check another negative value */
3934 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3935 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3936 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3937 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, -2, 0);
3938 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3939 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3940 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3941 /* and value greater than max item index */
3942 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3943 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3944 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
3945 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
3946 hwndedit2
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, r
, 0);
3947 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
3948 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
3949 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
3951 /* messaging tests */
3953 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3955 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3956 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3957 /* testing only sizing messages */
3958 ok_sequence(sequences
, EDITBOX_SEQ_INDEX
, editbox_create_pos
,
3959 "edit box create - sizing", FALSE
);
3961 /* WM_COMMAND with EN_KILLFOCUS isn't forwarded to parent */
3963 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
3964 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
3965 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3966 r
= SendMessage(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
3968 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
3969 "edit box WM_COMMAND (EN_KILLFOCUS)", TRUE
);
3971 DestroyWindow(hwnd
);
3974 static void test_notifyformat(void)
3979 hwnd
= create_listview_control(LVS_REPORT
);
3980 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3982 /* CCM_GETUNICODEFORMAT == LVM_GETUNICODEFORMAT,
3983 CCM_SETUNICODEFORMAT == LVM_SETUNICODEFORMAT */
3984 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3986 SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_QUERY
);
3988 r
= SendMessage(hwnd
, LVM_SETUNICODEFORMAT
, 1, 0);
3990 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
3993 r
= SendMessage(hwnd
, LVM_SETUNICODEFORMAT
, 0, 0);
3995 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4000 win_skip("LVM_GETUNICODEFORMAT is unsupported\n");
4001 DestroyWindow(hwnd
);
4005 DestroyWindow(hwnd
);
4007 /* test failure in parent WM_NOTIFYFORMAT */
4009 hwnd
= create_listview_control(LVS_REPORT
);
4010 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4011 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4012 ok(IsWindow(header
), "expected header to be created\n");
4013 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4015 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4016 ok( r
== 1, "Expected 1, got %d\n", r
);
4017 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_QUERY
);
4018 ok(r
!= 0, "Expected valid format\n");
4020 notifyFormat
= NFR_UNICODE
;
4021 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_REQUERY
);
4022 expect(NFR_UNICODE
, r
);
4023 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4025 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4026 ok( r
== 1, "Expected 1, got %d\n", r
);
4028 notifyFormat
= NFR_ANSI
;
4029 r
= SendMessage(hwnd
, WM_NOTIFYFORMAT
, 0, NF_REQUERY
);
4030 expect(NFR_ANSI
, r
);
4031 r
= SendMessage(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4033 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4034 ok( r
== 1, "Expected 1, got %d\n", r
);
4036 DestroyWindow(hwnd
);
4038 hwndparentW
= create_parent_window(TRUE
);
4039 ok(IsWindow(hwndparentW
), "Unicode parent creation failed\n");
4040 if (!IsWindow(hwndparentW
)) return;
4043 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
4044 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4045 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4046 ok(IsWindow(header
), "expected header to be created\n");
4047 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4049 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4051 DestroyWindow(hwnd
);
4052 /* receiving error code defaulting to ansi */
4054 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
4055 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4056 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4057 ok(IsWindow(header
), "expected header to be created\n");
4058 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4060 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4062 DestroyWindow(hwnd
);
4063 /* receiving ansi code from unicode window, use it */
4064 notifyFormat
= NFR_ANSI
;
4065 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
4066 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4067 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4068 ok(IsWindow(header
), "expected header to be created\n");
4069 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4071 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4073 DestroyWindow(hwnd
);
4074 /* unicode listview with ansi parent window */
4076 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparent
);
4077 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4078 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4079 ok(IsWindow(header
), "expected header to be created\n");
4080 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4082 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4084 DestroyWindow(hwnd
);
4085 /* unicode listview with ansi parent window, return error code */
4087 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparent
);
4088 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4089 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4090 ok(IsWindow(header
), "expected header to be created\n");
4091 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4093 r
= SendMessage(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4095 DestroyWindow(hwnd
);
4097 DestroyWindow(hwndparentW
);
4100 static void test_indentation(void)
4106 hwnd
= create_listview_control(LVS_REPORT
);
4107 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4109 memset(&item
, 0, sizeof(item
));
4110 item
.mask
= LVIF_INDENT
;
4112 item
.iIndent
= I_INDENTCALLBACK
;
4113 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
4116 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4119 item
.mask
= LVIF_INDENT
;
4120 r
= SendMessage(hwnd
, LVM_GETITEM
, 0, (LPARAM
)&item
);
4123 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
4124 "get indent dispinfo", FALSE
);
4126 DestroyWindow(hwnd
);
4129 static INT CALLBACK
DummyCompareEx(LPARAM first
, LPARAM second
, LPARAM param
)
4134 static BOOL
is_below_comctl_5(void)
4139 hwnd
= create_listview_control(LVS_REPORT
);
4140 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4141 insert_item(hwnd
, 0);
4143 ret
= SendMessage(hwnd
, LVM_SORTITEMSEX
, 0, (LPARAM
)&DummyCompareEx
);
4145 DestroyWindow(hwnd
);
4150 static void test_get_set_view(void)
4156 /* test style->view mapping */
4157 hwnd
= create_listview_control(LVS_REPORT
);
4158 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4160 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
4161 expect(LV_VIEW_DETAILS
, ret
);
4163 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
4165 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
& ~LVS_REPORT
);
4166 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
4167 expect(LV_VIEW_ICON
, ret
);
4169 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
4170 SetWindowLongPtr(hwnd
, GWL_STYLE
, style
| LVS_SMALLICON
);
4171 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
4172 expect(LV_VIEW_SMALLICON
, ret
);
4174 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
4175 SetWindowLongPtr(hwnd
, GWL_STYLE
, (style
& ~LVS_SMALLICON
) | LVS_LIST
);
4176 ret
= SendMessage(hwnd
, LVM_GETVIEW
, 0, 0);
4177 expect(LV_VIEW_LIST
, ret
);
4179 /* switching view doesn't touch window style */
4180 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_DETAILS
, 0);
4182 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
4183 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
4184 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_ICON
, 0);
4186 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
4187 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
4188 ret
= SendMessage(hwnd
, LVM_SETVIEW
, LV_VIEW_SMALLICON
, 0);
4190 style
= GetWindowLongPtr(hwnd
, GWL_STYLE
);
4191 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
4193 DestroyWindow(hwnd
);
4196 static void test_canceleditlabel(void)
4198 HWND hwnd
, hwndedit
;
4202 static CHAR test
[] = "test";
4203 static const CHAR test1
[] = "test1";
4205 hwnd
= create_listview_control(LVS_EDITLABELS
| LVS_REPORT
);
4206 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4208 insert_item(hwnd
, 0);
4210 /* try without edit created */
4211 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4212 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
4214 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
4215 "cancel edit label without edit", FALSE
);
4217 /* cancel without data change */
4219 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
4220 ok(IsWindow(hwndedit
), "Expected edit control to be created\n");
4221 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
4223 ok(!IsWindow(hwndedit
), "Expected edit control to be destroyed\n");
4225 /* cancel after data change */
4226 memset(&itema
, 0, sizeof(itema
));
4227 itema
.pszText
= test
;
4228 ret
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&itema
);
4231 hwndedit
= (HWND
)SendMessage(hwnd
, LVM_EDITLABEL
, 0, 0);
4232 ok(IsWindow(hwndedit
), "Expected edit control to be created\n");
4233 ret
= SetWindowText(hwndedit
, test1
);
4235 ret
= SendMessage(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
4237 ok(!IsWindow(hwndedit
), "Expected edit control to be destroyed\n");
4238 memset(&itema
, 0, sizeof(itema
));
4239 itema
.pszText
= buff
;
4240 itema
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
4241 ret
= SendMessage(hwnd
, LVM_GETITEMTEXT
, 0, (LPARAM
)&itema
);
4243 ok(strcmp(buff
, test1
) == 0, "Expected label text not to change\n");
4245 DestroyWindow(hwnd
);
4248 static void test_mapidindex(void)
4253 /* LVM_MAPINDEXTOID unsupported with LVS_OWNERDATA */
4254 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
4255 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4256 insert_item(hwnd
, 0);
4257 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
4259 DestroyWindow(hwnd
);
4261 hwnd
= create_listview_control(LVS_REPORT
);
4262 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4264 /* LVM_MAPINDEXTOID with invalid index */
4265 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
4268 insert_item(hwnd
, 0);
4269 insert_item(hwnd
, 1);
4271 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, -1, 0);
4273 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 2, 0);
4276 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
4278 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 1, 0);
4280 /* remove 0 indexed item, id retained */
4281 SendMessage(hwnd
, LVM_DELETEITEM
, 0, 0);
4282 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
4284 /* new id starts from previous value */
4285 insert_item(hwnd
, 1);
4286 ret
= SendMessage(hwnd
, LVM_MAPINDEXTOID
, 1, 0);
4289 /* get index by id */
4290 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, -1, 0);
4292 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 0, 0);
4294 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 1, 0);
4296 ret
= SendMessage(hwnd
, LVM_MAPIDTOINDEX
, 2, 0);
4299 DestroyWindow(hwnd
);
4302 static void test_getitemspacing(void)
4311 cx
= GetSystemMetrics(SM_CXICONSPACING
) - GetSystemMetrics(SM_CXICON
);
4312 cy
= GetSystemMetrics(SM_CYICONSPACING
) - GetSystemMetrics(SM_CYICON
);
4315 hwnd
= create_listview_control(LVS_ICON
);
4316 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4318 expect(cx
, LOWORD(ret
));
4319 expect(cy
, HIWORD(ret
));
4321 /* now try with icons */
4322 himl
= ImageList_Create(40, 40, 0, 4, 4);
4323 ok(himl
!= NULL
, "failed to create imagelist\n");
4324 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
4325 ok(hbmp
!= NULL
, "failed to create bitmap\n");
4326 ret
= ImageList_Add(himl
, hbmp
, 0);
4328 ret
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
4331 itema
.mask
= LVIF_IMAGE
;
4335 ret
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&itema
);
4337 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4339 /* spacing + icon size returned */
4340 expect(cx
+ 40, LOWORD(ret
));
4341 expect(cy
+ 40, HIWORD(ret
));
4343 DestroyWindow(hwnd
);
4345 hwnd
= create_listview_control(LVS_SMALLICON
);
4346 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4348 expect(cx
, LOWORD(ret
));
4349 expect(cy
, HIWORD(ret
));
4351 DestroyWindow(hwnd
);
4353 hwnd
= create_listview_control(LVS_REPORT
);
4354 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4356 expect(cx
, LOWORD(ret
));
4357 expect(cy
, HIWORD(ret
));
4359 DestroyWindow(hwnd
);
4361 hwnd
= create_listview_control(LVS_LIST
);
4362 ret
= SendMessage(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4364 expect(cx
, LOWORD(ret
));
4365 expect(cy
, HIWORD(ret
));
4367 DestroyWindow(hwnd
);
4370 static void test_getcolumnwidth(void)
4379 /* default column width */
4380 hwnd
= create_listview_control(LVS_ICON
);
4381 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
4383 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4384 SetWindowLong(hwnd
, GWL_STYLE
, style
| LVS_LIST
);
4385 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
4386 todo_wine
expect(8, ret
);
4387 style
= GetWindowLong(hwnd
, GWL_STYLE
) & ~LVS_LIST
;
4388 SetWindowLong(hwnd
, GWL_STYLE
, style
| LVS_REPORT
);
4390 ret
= SendMessage(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
4392 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
4394 DestroyWindow(hwnd
);
4396 /* default column width with item added */
4397 hwnd
= create_listview_control(LVS_LIST
);
4398 memset(&itema
, 0, sizeof(itema
));
4399 SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&itema
);
4400 ret
= SendMessage(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
4402 todo_wine
expect(((GetDeviceCaps(hdc
, LOGPIXELSX
) + 15) / 16) * 16, ret
);
4403 ReleaseDC(hwnd
, hdc
);
4404 DestroyWindow(hwnd
);
4407 static void test_scrollnotify(void)
4412 hwnd
= create_listview_control(LVS_REPORT
);
4414 insert_column(hwnd
, 0);
4415 insert_column(hwnd
, 1);
4416 insert_item(hwnd
, 0);
4418 /* make it scrollable - resize */
4419 ret
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
4421 ret
= SendMessage(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(100, 0));
4424 /* try with dummy call */
4425 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4426 ret
= SendMessage(hwnd
, LVM_SCROLL
, 0, 0);
4428 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4429 "scroll notify 1", TRUE
);
4431 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4432 ret
= SendMessage(hwnd
, LVM_SCROLL
, 1, 0);
4434 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4435 "scroll notify 2", TRUE
);
4437 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4438 ret
= SendMessage(hwnd
, LVM_SCROLL
, 1, 1);
4440 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4441 "scroll notify 3", TRUE
);
4443 DestroyWindow(hwnd
);
4446 static void test_LVS_EX_TRANSPARENTBKGND(void)
4452 hwnd
= create_listview_control(LVS_REPORT
);
4454 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, RGB(0, 0, 0));
4457 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_TRANSPARENTBKGND
,
4458 LVS_EX_TRANSPARENTBKGND
);
4460 ret
= SendMessage(hwnd
, LVM_GETBKCOLOR
, 0, 0);
4461 if (ret
!= CLR_NONE
)
4463 win_skip("LVS_EX_TRANSPARENTBKGND unsupported\n");
4464 DestroyWindow(hwnd
);
4468 /* try to set some back color and check this style bit */
4469 ret
= SendMessage(hwnd
, LVM_SETBKCOLOR
, 0, RGB(0, 0, 0));
4471 ret
= SendMessage(hwnd
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
4472 ok(!(ret
& LVS_EX_TRANSPARENTBKGND
), "Expected LVS_EX_TRANSPARENTBKGND to unset\n");
4474 /* now test what this style actually does */
4475 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_TRANSPARENTBKGND
,
4476 LVS_EX_TRANSPARENTBKGND
);
4478 hdc
= GetWindowDC(hwndparent
);
4480 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4481 SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
4482 ok_sequence(sequences
, PARENT_SEQ_INDEX
, lvs_ex_transparentbkgnd_seq
,
4483 "LVS_EX_TRANSPARENTBKGND parent", FALSE
);
4485 ReleaseDC(hwndparent
, hdc
);
4487 DestroyWindow(hwnd
);
4490 static void test_approximate_viewrect(void)
4497 static CHAR test
[] = "abracadabra, a very long item label";
4499 hwnd
= create_listview_control(LVS_ICON
);
4500 himl
= ImageList_Create(40, 40, 0, 4, 4);
4501 ok(himl
!= NULL
, "failed to create imagelist\n");
4502 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
4503 ok(hbmp
!= NULL
, "failed to create bitmap\n");
4504 ret
= ImageList_Add(himl
, hbmp
, 0);
4506 ret
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
4509 itema
.mask
= LVIF_IMAGE
;
4513 ret
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
)&itema
);
4516 ret
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(75, 75));
4520 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
4524 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 11, MAKELPARAM(100,100));
4525 expect(MAKELONG(77,827), ret
);
4527 ret
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(50, 50));
4528 ok(ret
!= 0, "got 0\n");
4530 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 11, MAKELPARAM(100,100));
4531 expect(MAKELONG(102,302), ret
);
4533 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, -1, MAKELPARAM(100,100));
4534 expect(MAKELONG(52,52), ret
);
4536 itema
.pszText
= test
;
4537 ret
= SendMessage(hwnd
, LVM_SETITEMTEXT
, 0, (LPARAM
)&itema
);
4539 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, -1, MAKELPARAM(100,100));
4540 expect(MAKELONG(52,52), ret
);
4542 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 0, MAKELPARAM(100,100));
4543 expect(MAKELONG(52,2), ret
);
4544 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 1, MAKELPARAM(100,100));
4545 expect(MAKELONG(52,52), ret
);
4546 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 2, MAKELPARAM(100,100));
4547 expect(MAKELONG(102,52), ret
);
4548 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 3, MAKELPARAM(100,100));
4549 expect(MAKELONG(102,102), ret
);
4550 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 4, MAKELPARAM(100,100));
4551 expect(MAKELONG(102,102), ret
);
4552 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 5, MAKELPARAM(100,100));
4553 expect(MAKELONG(102,152), ret
);
4554 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 6, MAKELPARAM(100,100));
4555 expect(MAKELONG(102,152), ret
);
4556 ret
= SendMessage(hwnd
, LVM_APPROXIMATEVIEWRECT
, 7, MAKELPARAM(160,100));
4557 expect(MAKELONG(152,152), ret
);
4559 DestroyWindow(hwnd
);
4562 static void test_finditem(void)
4569 hwnd
= create_listview_control(LVS_REPORT
);
4570 insert_item(hwnd
, 0);
4572 memset(&fi
, 0, sizeof(fi
));
4574 /* full string search, inserted text was "foo" */
4576 fi
.flags
= LVFI_STRING
;
4578 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4580 /* partial string search, inserted text was "foo" */
4582 fi
.flags
= LVFI_STRING
| LVFI_PARTIAL
;
4584 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4586 /* partial string search, part after start char */
4588 fi
.flags
= LVFI_STRING
| LVFI_PARTIAL
;
4590 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4593 /* try with LVFI_SUBSTRING */
4595 fi
.flags
= LVFI_SUBSTRING
;
4597 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4600 win_skip("LVFI_SUBSTRING not supported\n");
4601 DestroyWindow(hwnd
);
4606 fi
.flags
= LVFI_SUBSTRING
;
4608 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4611 fi
.flags
= LVFI_SUBSTRING
;
4613 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4617 fi
.flags
= LVFI_SUBSTRING
| LVFI_STRING
;
4619 r
= SendMessage(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
4622 DestroyWindow(hwnd
);
4625 static void test_LVS_EX_HEADERINALLVIEWS(void)
4630 hwnd
= create_listview_control(LVS_ICON
);
4632 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4633 LVS_EX_HEADERINALLVIEWS
);
4635 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4636 if (!IsWindow(header
))
4638 win_skip("LVS_EX_HEADERINALLVIEWS unsupported\n");
4639 DestroyWindow(hwnd
);
4643 /* LVS_NOCOLUMNHEADER works as before */
4644 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4645 SetWindowLongW(hwnd
, GWL_STYLE
, style
| LVS_NOCOLUMNHEADER
);
4646 style
= GetWindowLongA(header
, GWL_STYLE
);
4647 ok(style
& HDS_HIDDEN
, "Expected HDS_HIDDEN\n");
4648 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4649 SetWindowLongW(hwnd
, GWL_STYLE
, style
& ~LVS_NOCOLUMNHEADER
);
4650 style
= GetWindowLongA(header
, GWL_STYLE
);
4651 ok(!(style
& HDS_HIDDEN
), "Expected HDS_HIDDEN to be unset\n");
4653 /* try to remove style */
4654 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
, 0);
4655 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4656 ok(IsWindow(header
), "Expected header to be created\n");
4657 style
= GetWindowLongA(header
, GWL_STYLE
);
4658 ok(!(style
& HDS_HIDDEN
), "HDS_HIDDEN not expected\n");
4660 DestroyWindow(hwnd
);
4662 /* check other styles */
4663 hwnd
= create_listview_control(LVS_LIST
);
4664 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4665 LVS_EX_HEADERINALLVIEWS
);
4666 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4667 ok(IsWindow(header
), "Expected header to be created\n");
4668 DestroyWindow(hwnd
);
4670 hwnd
= create_listview_control(LVS_SMALLICON
);
4671 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4672 LVS_EX_HEADERINALLVIEWS
);
4673 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4674 ok(IsWindow(header
), "Expected header to be created\n");
4675 DestroyWindow(hwnd
);
4677 hwnd
= create_listview_control(LVS_REPORT
);
4678 SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
4679 LVS_EX_HEADERINALLVIEWS
);
4680 header
= (HWND
)SendMessage(hwnd
, LVM_GETHEADER
, 0, 0);
4681 ok(IsWindow(header
), "Expected header to be created\n");
4682 DestroyWindow(hwnd
);
4685 static void test_hover(void)
4690 hwnd
= create_listview_control(LVS_ICON
);
4692 /* test WM_MOUSEHOVER forwarding */
4693 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4694 r
= SendMessage(hwnd
, WM_MOUSEHOVER
, 0, 0);
4696 ok_sequence(sequences
, PARENT_SEQ_INDEX
, hover_parent
, "NM_HOVER allow test", TRUE
);
4697 g_block_hover
= TRUE
;
4698 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4699 r
= SendMessage(hwnd
, WM_MOUSEHOVER
, 0, 0);
4701 ok_sequence(sequences
, PARENT_SEQ_INDEX
, hover_parent
, "NM_HOVER block test", TRUE
);
4702 g_block_hover
= FALSE
;
4704 r
= SendMessage(hwnd
, LVM_SETHOVERTIME
, 0, 500);
4705 expect(HOVER_DEFAULT
, r
);
4706 r
= SendMessage(hwnd
, LVM_GETHOVERTIME
, 0, 0);
4709 DestroyWindow(hwnd
);
4712 static void test_destroynotify(void)
4716 hwnd
= create_listview_control(LVS_REPORT
);
4717 ok(hwnd
!= NULL
, "failed to create listview window\n");
4719 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4720 DestroyWindow(hwnd
);
4721 ok_sequence(sequences
, COMBINED_SEQ_INDEX
, listview_destroy
, "check destroy order", FALSE
);
4724 static void test_header_notification(void)
4726 static char textA
[] = "newtext";
4734 list
= create_listview_control(LVS_REPORT
);
4735 ok(list
!= NULL
, "failed to create listview window\n");
4737 memset(&col
, 0, sizeof(col
));
4738 col
.mask
= LVCF_WIDTH
;
4740 ret
= SendMessage(list
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
4743 /* check list parent notification after header item changed,
4744 this test should be placed before header subclassing to avoid
4745 Listview -> Header messages to be logged */
4746 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4748 col
.mask
= LVCF_TEXT
;
4749 col
.pszText
= textA
;
4750 r
= SendMessage(list
, LVM_SETCOLUMNA
, 0, (LPARAM
)&col
);
4753 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_header_changed_seq
,
4754 "header notify, listview", FALSE
);
4755 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
4756 "header notify, parent", FALSE
);
4758 header
= subclass_header(list
);
4760 ret
= SendMessage(header
, HDM_GETITEMCOUNT
, 0, 0);
4763 memset(&item
, 0, sizeof(item
));
4764 item
.mask
= HDI_WIDTH
;
4765 ret
= SendMessage(header
, HDM_GETITEMA
, 0, (LPARAM
)&item
);
4767 expect(100, item
.cxy
);
4769 nmh
.hdr
.hwndFrom
= header
;
4770 nmh
.hdr
.idFrom
= GetWindowLongPtr(header
, GWLP_ID
);
4771 nmh
.hdr
.code
= HDN_ITEMCHANGEDA
;
4774 item
.mask
= HDI_WIDTH
;
4777 ret
= SendMessage(list
, WM_NOTIFY
, 0, (LPARAM
)&nmh
);
4780 DestroyWindow(list
);
4783 static void test_createdragimage(void)
4789 list
= create_listview_control(LVS_ICON
);
4790 ok(list
!= NULL
, "failed to create listview window\n");
4792 insert_item(list
, 0);
4795 himl
= (HIMAGELIST
)SendMessageA(list
, LVM_CREATEDRAGIMAGE
, 0, 0);
4796 ok(himl
== NULL
, "got %p\n", himl
);
4798 himl
= (HIMAGELIST
)SendMessageA(list
, LVM_CREATEDRAGIMAGE
, 0, (LPARAM
)&pt
);
4799 ok(himl
!= NULL
, "got %p\n", himl
);
4800 ImageList_Destroy(himl
);
4802 DestroyWindow(list
);
4805 static void test_dispinfo(void)
4807 static const char testA
[] = "TEST";
4813 hwnd
= create_listview_control(LVS_ICON
);
4814 ok(hwnd
!= NULL
, "failed to create listview window\n");
4816 insert_item(hwnd
, 0);
4818 memset(&item
, 0, sizeof(item
));
4819 item
.pszText
= LPSTR_TEXTCALLBACKA
;
4820 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
4823 g_disp_A_to_W
= TRUE
;
4824 item
.pszText
= (char*)buff
;
4825 item
.cchTextMax
= sizeof(buff
)/sizeof(WCHAR
);
4826 ret
= SendMessageA(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
4827 ok(ret
== sizeof(testA
)-1, "got %d, expected 4\n", ret
);
4828 g_disp_A_to_W
= FALSE
;
4830 ok(memcmp(item
.pszText
, testA
, sizeof(testA
)) == 0,
4831 "got %s, expected %s\n", item
.pszText
, testA
);
4833 DestroyWindow(hwnd
);
4836 static void test_LVM_SETITEMTEXT(void)
4838 static char testA
[] = "TEST";
4843 hwnd
= create_listview_control(LVS_ICON
);
4844 ok(hwnd
!= NULL
, "failed to create listview window\n");
4846 insert_item(hwnd
, 0);
4848 /* null item pointer */
4849 ret
= SendMessage(hwnd
, LVM_SETITEMTEXTA
, 0, 0);
4852 ret
= SendMessage(hwnd
, LVM_SETITEMTEXTW
, 0, 0);
4855 /* index out of bounds */
4856 item
.pszText
= testA
;
4857 item
.cchTextMax
= 0; /* ignored */
4860 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 1, (LPARAM
)&item
);
4863 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, -1, (LPARAM
)&item
);
4866 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
4869 DestroyWindow(hwnd
);
4872 START_TEST(listview
)
4875 BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
4877 ULONG_PTR ctx_cookie
;
4881 hComctl32
= GetModuleHandleA("comctl32.dll");
4882 pInitCommonControlsEx
= (void*)GetProcAddress(hComctl32
, "InitCommonControlsEx");
4883 if (pInitCommonControlsEx
)
4885 INITCOMMONCONTROLSEX iccex
;
4886 iccex
.dwSize
= sizeof(iccex
);
4887 iccex
.dwICC
= ICC_LISTVIEW_CLASSES
;
4888 pInitCommonControlsEx(&iccex
);
4891 InitCommonControls();
4893 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
4895 hwndparent
= create_parent_window(FALSE
);
4896 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4898 g_is_below_5
= is_below_comctl_5();
4900 test_header_notification();
4907 test_icon_spacing();
4910 test_item_position();
4915 test_subitem_rect();
4919 test_nosortheader();
4923 test_getitemposition();
4924 test_columnscreation();
4926 test_notifyformat();
4928 test_getitemspacing();
4929 test_getcolumnwidth();
4930 test_approximate_viewrect();
4933 test_destroynotify();
4934 test_createdragimage();
4936 test_LVM_SETITEMTEXT();
4938 if (!load_v6_module(&ctx_cookie
, &hCtx
))
4940 DestroyWindow(hwndparent
);
4944 /* this is a XP SP3 failure workaround */
4945 hwnd
= CreateWindowExA(0, WC_LISTVIEW
, "foo",
4946 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| LVS_REPORT
,
4948 hwndparent
, NULL
, GetModuleHandleA(NULL
), NULL
);
4949 if (!IsWindow(hwnd
))
4951 win_skip("FIXME: failed to create ListView window.\n");
4952 unload_v6_module(ctx_cookie
, hCtx
);
4953 DestroyWindow(hwndparent
);
4957 DestroyWindow(hwnd
);
4959 /* comctl32 version 6 tests start here */
4960 test_get_set_view();
4961 test_canceleditlabel();
4963 test_scrollnotify();
4964 test_LVS_EX_TRANSPARENTBKGND();
4965 test_LVS_EX_HEADERINALLVIEWS();
4967 unload_v6_module(ctx_cookie
, hCtx
);
4969 DestroyWindow(hwndparent
);