4 * Copyright 2006 Mike McCormack for CodeWeavers
5 * Copyright 2007 George Gov
6 * Copyright 2009-2014 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"
33 PARENT_FULL_SEQ_INDEX
,
44 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
45 #define expect2(expected1, expected2, got1, got2) ok(expected1 == got1 && expected2 == got2, \
46 "expected (%d,%d), got (%d,%d)\n", expected1, expected2, got1, got2)
48 static const WCHAR testparentclassW
[] =
49 {'L','i','s','t','v','i','e','w',' ','t','e','s','t',' ','p','a','r','e','n','t','W', 0};
51 static HWND hwndparent
, hwndparentW
;
52 /* prevents edit box creation, LVN_BEGINLABELEDIT return value */
53 static BOOL blockEdit
;
54 /* return nonzero on NM_HOVER */
55 static BOOL g_block_hover
;
56 /* notification data for LVN_ITEMCHANGED */
57 static NMLISTVIEW g_nmlistview
;
58 /* notification data for LVN_ITEMCHANGING */
59 static NMLISTVIEW g_nmlistview_changing
;
60 /* format reported to control:
61 -1 falls to defproc, anything else returned */
62 static INT notifyFormat
;
63 /* indicates we're running < 5.80 version */
64 static BOOL g_is_below_5
;
65 /* item data passed to LVN_GETDISPINFOA */
66 static LVITEMA g_itema
;
67 /* alter notification code A->W */
68 static BOOL g_disp_A_to_W
;
69 /* dispinfo data sent with LVN_LVN_ENDLABELEDIT */
70 static NMLVDISPINFOA g_editbox_disp_info
;
71 /* when this is set focus will be tested on LVN_DELETEITEM */
72 static BOOL g_focus_test_LVN_DELETEITEM
;
74 static HWND
subclass_editbox(HWND hwndListview
);
76 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
78 static const struct message create_ownerdrawfixed_parent_seq
[] = {
79 { WM_NOTIFYFORMAT
, sent
},
80 { WM_QUERYUISTATE
, sent
|optional
}, /* Win2K and higher */
81 { WM_MEASUREITEM
, sent
},
82 { WM_PARENTNOTIFY
, sent
},
86 static const struct message redraw_listview_seq
[] = {
87 { WM_PAINT
, sent
|id
, 0, 0, LISTVIEW_ID
},
88 { WM_PAINT
, sent
|id
, 0, 0, HEADER_ID
},
89 { WM_NCPAINT
, sent
|id
|defwinproc
, 0, 0, HEADER_ID
},
90 { WM_ERASEBKGND
, sent
|id
|defwinproc
|optional
, 0, 0, HEADER_ID
},
91 { WM_NOTIFY
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
92 { WM_NCPAINT
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
93 { WM_ERASEBKGND
, sent
|id
|defwinproc
|optional
, 0, 0, LISTVIEW_ID
},
97 static const struct message listview_icon_spacing_seq
[] = {
98 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(20, 30) },
99 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(25, 35) },
100 { LVM_SETICONSPACING
, sent
|lparam
, 0, MAKELPARAM(-1, -1) },
104 static const struct message listview_color_seq
[] = {
105 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
106 { LVM_GETBKCOLOR
, sent
},
107 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
108 { LVM_GETTEXTCOLOR
, sent
},
109 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(0,0,0) },
110 { LVM_GETTEXTBKCOLOR
, sent
},
112 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
113 { LVM_GETBKCOLOR
, sent
},
114 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
115 { LVM_GETTEXTCOLOR
, sent
},
116 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(100,50,200) },
117 { LVM_GETTEXTBKCOLOR
, sent
},
119 { LVM_SETBKCOLOR
, sent
|lparam
, 0, CLR_NONE
},
120 { LVM_GETBKCOLOR
, sent
},
121 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, CLR_NONE
},
122 { LVM_GETTEXTCOLOR
, sent
},
123 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, CLR_NONE
},
124 { LVM_GETTEXTBKCOLOR
, sent
},
126 { LVM_SETBKCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
127 { LVM_GETBKCOLOR
, sent
},
128 { LVM_SETTEXTCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
129 { LVM_GETTEXTCOLOR
, sent
},
130 { LVM_SETTEXTBKCOLOR
, sent
|lparam
, 0, RGB(255,255,255) },
131 { LVM_GETTEXTBKCOLOR
, sent
},
135 static const struct message listview_item_count_seq
[] = {
136 { LVM_GETITEMCOUNT
, sent
},
137 { LVM_INSERTITEMA
, sent
},
138 { LVM_INSERTITEMA
, sent
},
139 { LVM_INSERTITEMA
, sent
},
140 { LVM_GETITEMCOUNT
, sent
},
141 { LVM_DELETEITEM
, sent
|wparam
, 2 },
142 { WM_NCPAINT
, sent
|optional
},
143 { WM_ERASEBKGND
, sent
|optional
},
144 { LVM_GETITEMCOUNT
, sent
},
145 { LVM_DELETEALLITEMS
, sent
},
146 { LVM_GETITEMCOUNT
, sent
},
147 { LVM_INSERTITEMA
, sent
},
148 { LVM_INSERTITEMA
, sent
},
149 { LVM_GETITEMCOUNT
, sent
},
150 { LVM_INSERTITEMA
, sent
},
151 { LVM_GETITEMCOUNT
, sent
},
155 static const struct message listview_itempos_seq
[] = {
156 { LVM_INSERTITEMA
, sent
},
157 { LVM_INSERTITEMA
, sent
},
158 { LVM_INSERTITEMA
, sent
},
159 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 1, MAKELPARAM(10,5) },
160 { WM_NCPAINT
, sent
|optional
},
161 { WM_ERASEBKGND
, sent
|optional
},
162 { LVM_GETITEMPOSITION
, sent
|wparam
, 1 },
163 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 2, MAKELPARAM(0,0) },
164 { LVM_GETITEMPOSITION
, sent
|wparam
, 2 },
165 { LVM_SETITEMPOSITION
, sent
|wparam
|lparam
, 0, MAKELPARAM(20,20) },
166 { LVM_GETITEMPOSITION
, sent
|wparam
, 0 },
170 static const struct message listview_ownerdata_switchto_seq
[] = {
171 { WM_STYLECHANGING
, sent
},
172 { WM_STYLECHANGED
, sent
},
176 static const struct message listview_getorderarray_seq
[] = {
177 { LVM_GETCOLUMNORDERARRAY
, sent
|id
|wparam
, 2, 0, LISTVIEW_ID
},
178 { HDM_GETORDERARRAY
, sent
|id
|wparam
, 2, 0, HEADER_ID
},
179 { LVM_GETCOLUMNORDERARRAY
, sent
|id
|wparam
, 0, 0, LISTVIEW_ID
},
180 { HDM_GETORDERARRAY
, sent
|id
|wparam
, 0, 0, HEADER_ID
},
184 static const struct message listview_setorderarray_seq
[] = {
185 { LVM_SETCOLUMNORDERARRAY
, sent
|id
|wparam
, 2, 0, LISTVIEW_ID
},
186 { HDM_SETORDERARRAY
, sent
|id
|wparam
, 2, 0, HEADER_ID
},
187 { LVM_SETCOLUMNORDERARRAY
, sent
|id
|wparam
, 0, 0, LISTVIEW_ID
},
188 { HDM_SETORDERARRAY
, sent
|id
|wparam
, 0, 0, HEADER_ID
},
192 static const struct message empty_seq
[] = {
196 static const struct message forward_erasebkgnd_parent_seq
[] = {
197 { WM_ERASEBKGND
, sent
},
201 static const struct message ownerdata_select_focus_parent_seq
[] = {
202 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
203 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
204 { WM_NOTIFY
, sent
|id
|optional
, 0, 0, LVN_GETDISPINFOA
}, /* version 4.7x */
208 static const struct message ownerdata_setstate_all_parent_seq
[] = {
209 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
213 static const struct message ownerdata_defocus_all_parent_seq
[] = {
214 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
215 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
216 { WM_NOTIFY
, sent
|id
|optional
, 0, 0, LVN_GETDISPINFOA
},
217 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
221 static const struct message ownerdata_deselect_all_parent_seq
[] = {
222 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ODCACHEHINT
},
223 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
227 static const struct message change_all_parent_seq
[] = {
228 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
229 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
231 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
232 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
234 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
235 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
237 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
238 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
240 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
241 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
245 static const struct message changing_all_parent_seq
[] = {
246 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
247 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
248 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
249 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
250 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
254 static const struct message textcallback_set_again_parent_seq
[] = {
255 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
256 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
260 static const struct message single_getdispinfo_parent_seq
[] = {
261 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_GETDISPINFOA
},
265 static const struct message getitemposition_seq1
[] = {
266 { LVM_GETITEMPOSITION
, sent
|id
, 0, 0, LISTVIEW_ID
},
270 static const struct message getitemposition_seq2
[] = {
271 { LVM_GETITEMPOSITION
, sent
|id
, 0, 0, LISTVIEW_ID
},
272 { HDM_GETITEMRECT
, sent
|id
, 0, 0, HEADER_ID
},
276 static const struct message getsubitemrect_seq
[] = {
277 { LVM_GETSUBITEMRECT
, sent
|id
|wparam
, -1, 0, LISTVIEW_ID
},
278 { HDM_GETITEMRECT
, sent
|id
, 0, 0, HEADER_ID
},
279 { LVM_GETSUBITEMRECT
, sent
|id
|wparam
, 0, 0, LISTVIEW_ID
},
280 { HDM_GETITEMRECT
, sent
|id
, 0, 0, HEADER_ID
},
281 { LVM_GETSUBITEMRECT
, sent
|id
|wparam
, -10, 0, LISTVIEW_ID
},
282 { HDM_GETITEMRECT
, sent
|id
, 0, 0, HEADER_ID
},
283 { LVM_GETSUBITEMRECT
, sent
|id
|wparam
, 20, 0, LISTVIEW_ID
},
284 { HDM_GETITEMRECT
, sent
|id
, 0, 0, HEADER_ID
},
288 static const struct message editbox_create_pos
[] = {
289 /* sequence sent after LVN_BEGINLABELEDIT */
290 /* next two are 4.7x specific */
291 { WM_WINDOWPOSCHANGING
, sent
},
292 { WM_WINDOWPOSCHANGED
, sent
|optional
},
294 { WM_WINDOWPOSCHANGING
, sent
|optional
},
295 { WM_NCCALCSIZE
, sent
},
296 { WM_WINDOWPOSCHANGED
, sent
},
297 { WM_MOVE
, sent
|defwinproc
},
298 { WM_SIZE
, sent
|defwinproc
},
299 /* the rest is todo, skipped in 4.7x */
300 { WM_WINDOWPOSCHANGING
, sent
|optional
},
301 { WM_WINDOWPOSCHANGED
, sent
|optional
},
305 static const struct message scroll_parent_seq
[] = {
306 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_BEGINSCROLL
},
307 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ENDSCROLL
},
311 static const struct message setredraw_seq
[] = {
312 { WM_SETREDRAW
, sent
|id
|wparam
, FALSE
, 0, LISTVIEW_ID
},
316 static const struct message lvs_ex_transparentbkgnd_seq
[] = {
317 { WM_PRINTCLIENT
, sent
|lparam
, 0, PRF_ERASEBKGND
},
321 static const struct message edit_end_nochange
[] = {
322 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ENDLABELEDITA
},
323 { WM_NOTIFY
, sent
|id
, 0, 0, NM_CUSTOMDRAW
}, /* todo */
324 { WM_NOTIFY
, sent
|id
, 0, 0, NM_SETFOCUS
},
328 static const struct message hover_parent
[] = {
329 { WM_GETDLGCODE
, sent
}, /* todo_wine */
330 { WM_NOTIFY
, sent
|id
, 0, 0, NM_HOVER
},
334 static const struct message listview_destroy
[] = {
335 { 0x0090, sent
|optional
}, /* Vista */
336 { WM_PARENTNOTIFY
, sent
},
337 { WM_SHOWWINDOW
, sent
},
338 { WM_WINDOWPOSCHANGING
, sent
},
339 { WM_WINDOWPOSCHANGED
, sent
|optional
},
340 { WM_DESTROY
, sent
},
341 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_DELETEALLITEMS
},
342 { WM_NCDESTROY
, sent
},
346 static const struct message listview_ownerdata_destroy
[] = {
347 { 0x0090, sent
|optional
}, /* Vista */
348 { WM_PARENTNOTIFY
, sent
},
349 { WM_SHOWWINDOW
, sent
},
350 { WM_WINDOWPOSCHANGING
, sent
},
351 { WM_WINDOWPOSCHANGED
, sent
|optional
},
352 { WM_DESTROY
, sent
},
353 { WM_NCDESTROY
, sent
},
357 static const struct message listview_ownerdata_deleteall
[] = {
358 { LVM_DELETEALLITEMS
, sent
},
359 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_DELETEALLITEMS
},
363 static const struct message listview_header_changed_seq
[] = {
364 { LVM_SETCOLUMNA
, sent
},
365 { WM_NOTIFY
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
366 { WM_NOTIFY
, sent
|id
|defwinproc
, 0, 0, LISTVIEW_ID
},
370 static const struct message parent_header_click_seq
[] = {
371 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_COLUMNCLICK
},
372 { WM_NOTIFY
, sent
|id
, 0, 0, HDN_ITEMCLICKA
},
376 static const struct message parent_header_divider_dclick_seq
[] = {
377 { WM_NOTIFY
, sent
|id
, 0, 0, HDN_ITEMCHANGINGA
},
378 { WM_NOTIFY
, sent
|id
, 0, 0, NM_CUSTOMDRAW
},
379 { WM_NOTIFY
, sent
|id
, 0, 0, NM_CUSTOMDRAW
},
380 { WM_NOTIFY
, sent
|id
, 0, 0, HDN_ITEMCHANGEDA
},
381 { WM_NOTIFY
, sent
|id
, 0, 0, HDN_DIVIDERDBLCLICKA
},
385 static const struct message listview_set_imagelist
[] = {
386 { LVM_SETIMAGELIST
, sent
|id
, 0, 0, LISTVIEW_ID
},
390 static const struct message listview_header_set_imagelist
[] = {
391 { LVM_SETIMAGELIST
, sent
|id
, 0, 0, LISTVIEW_ID
},
392 { HDM_SETIMAGELIST
, sent
|id
, 0, 0, HEADER_ID
},
396 static const struct message parent_insert_focused_seq
[] = {
397 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
398 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGING
},
399 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
400 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_ITEMCHANGED
},
401 { WM_NOTIFY
, sent
|id
, 0, 0, LVN_INSERTITEM
},
405 static const struct message parent_report_cd_seq
[] = {
406 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_PREPAINT
},
407 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_ITEMPREPAINT
},
408 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_ITEMPREPAINT
|CDDS_SUBITEM
},
409 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_ITEMPOSTPAINT
|CDDS_SUBITEM
},
410 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_ITEMPREPAINT
|CDDS_SUBITEM
},
411 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_ITEMPOSTPAINT
|CDDS_SUBITEM
},
412 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_ITEMPOSTPAINT
},
413 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_POSTPAINT
},
417 static const struct message parent_list_cd_seq
[] = {
418 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_PREPAINT
},
419 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_ITEMPREPAINT
},
420 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_ITEMPOSTPAINT
},
421 { WM_NOTIFY
, sent
|id
|custdraw
, 0, 0, NM_CUSTOMDRAW
, CDDS_POSTPAINT
},
425 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
427 static LONG defwndproc_counter
= 0;
431 msg
.message
= message
;
432 msg
.flags
= sent
|wparam
|lparam
;
433 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
436 if (message
== WM_NOTIFY
&& lParam
) msg
.id
= ((NMHDR
*)lParam
)->code
;
438 /* log system messages, except for painting */
439 if (message
< WM_USER
&&
440 message
!= WM_PAINT
&&
441 message
!= WM_ERASEBKGND
&&
442 message
!= WM_NCPAINT
&&
443 message
!= WM_NCHITTEST
&&
444 message
!= WM_GETTEXT
&&
445 message
!= WM_GETICON
&&
446 message
!= WM_DEVICECHANGE
)
448 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
449 add_message(sequences
, COMBINED_SEQ_INDEX
, &msg
);
451 add_message(sequences
, PARENT_FULL_SEQ_INDEX
, &msg
);
457 switch (((NMHDR
*)lParam
)->code
)
459 case LVN_BEGINLABELEDITA
:
463 /* subclass edit box */
465 edit
= subclass_editbox(((NMHDR
*)lParam
)->hwndFrom
);
469 INT len
= SendMessageA(edit
, EM_GETLIMITTEXT
, 0, 0);
470 ok(len
== 259 || broken(len
== 260) /* includes NULL in NT4 */,
471 "text limit %d, expected 259\n", len
);
476 case LVN_ENDLABELEDITA
:
480 /* always accept new item text */
481 NMLVDISPINFOA
*di
= (NMLVDISPINFOA
*)lParam
;
482 g_editbox_disp_info
= *di
;
483 trace("LVN_ENDLABELEDIT: text=%s\n", di
->item
.pszText
? di
->item
.pszText
: "(null)");
485 /* edit control still available from this notification */
486 edit
= (HWND
)SendMessageA(((NMHDR
*)lParam
)->hwndFrom
, LVM_GETEDITCONTROL
, 0, 0);
487 ok(IsWindow(edit
), "expected valid edit control handle\n");
488 ok((GetWindowLongA(edit
, GWL_STYLE
) & ES_MULTILINE
) == 0, "edit is multiline\n");
492 case LVN_BEGINSCROLL
:
495 NMLVSCROLL
*pScroll
= (NMLVSCROLL
*)lParam
;
497 trace("LVN_%sSCROLL: (%d,%d)\n", pScroll
->hdr
.code
== LVN_BEGINSCROLL
?
498 "BEGIN" : "END", pScroll
->dx
, pScroll
->dy
);
501 case LVN_ITEMCHANGING
:
503 NMLISTVIEW
*nmlv
= (NMLISTVIEW
*)lParam
;
504 g_nmlistview_changing
= *nmlv
;
507 case LVN_ITEMCHANGED
:
509 NMLISTVIEW
*nmlv
= (NMLISTVIEW
*)lParam
;
510 g_nmlistview
= *nmlv
;
513 case LVN_GETDISPINFOA
:
515 NMLVDISPINFOA
*dispinfo
= (NMLVDISPINFOA
*)lParam
;
516 g_itema
= dispinfo
->item
;
518 if (g_disp_A_to_W
&& (dispinfo
->item
.mask
& LVIF_TEXT
))
520 static const WCHAR testW
[] = {'T','E','S','T',0};
521 dispinfo
->hdr
.code
= LVN_GETDISPINFOW
;
522 memcpy(dispinfo
->item
.pszText
, testW
, sizeof(testW
));
525 /* test control buffer size for text, 10 used to mask cases when control
526 is using caller buffer to process LVM_GETITEM for example */
527 if (dispinfo
->item
.mask
& LVIF_TEXT
&& dispinfo
->item
.cchTextMax
> 10)
528 ok(dispinfo
->item
.cchTextMax
== 260 ||
529 broken(dispinfo
->item
.cchTextMax
== 264) /* NT4 reports aligned size */,
530 "buffer size %d\n", dispinfo
->item
.cchTextMax
);
534 if (g_focus_test_LVN_DELETEITEM
)
536 NMLISTVIEW
*nmlv
= (NMLISTVIEW
*)lParam
;
539 state
= SendMessageA(((NMHDR
*)lParam
)->hwndFrom
, LVM_GETITEMSTATE
, nmlv
->iItem
, LVIS_FOCUSED
);
540 ok(state
== 0, "got state %x\n", state
);
544 if (g_block_hover
) return 1;
549 case WM_NOTIFYFORMAT
:
551 /* force to return format */
552 if (lParam
== NF_QUERY
&& notifyFormat
!= -1) return notifyFormat
;
557 defwndproc_counter
++;
558 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
559 defwndproc_counter
--;
564 static BOOL
register_parent_wnd_class(BOOL Unicode
)
572 clsW
.lpfnWndProc
= parent_wnd_proc
;
575 clsW
.hInstance
= GetModuleHandleW(NULL
);
577 clsW
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
578 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
579 clsW
.lpszMenuName
= NULL
;
580 clsW
.lpszClassName
= testparentclassW
;
585 clsA
.lpfnWndProc
= parent_wnd_proc
;
588 clsA
.hInstance
= GetModuleHandleA(NULL
);
590 clsA
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
591 clsA
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
592 clsA
.lpszMenuName
= NULL
;
593 clsA
.lpszClassName
= "Listview test parent class";
596 return Unicode
? RegisterClassW(&clsW
) : RegisterClassA(&clsA
);
599 static HWND
create_parent_window(BOOL Unicode
)
601 static const WCHAR nameW
[] = {'t','e','s','t','p','a','r','e','n','t','n','a','m','e','W',0};
604 if (!register_parent_wnd_class(Unicode
))
611 hwnd
= CreateWindowExW(0, testparentclassW
, nameW
,
612 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
613 WS_MAXIMIZEBOX
| WS_VISIBLE
,
615 GetDesktopWindow(), NULL
, GetModuleHandleW(NULL
), NULL
);
617 hwnd
= CreateWindowExA(0, "Listview test parent class",
618 "Listview test parent window",
619 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
620 WS_MAXIMIZEBOX
| WS_VISIBLE
,
622 GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
623 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
627 static LRESULT WINAPI
listview_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
629 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
630 static LONG defwndproc_counter
= 0;
634 /* some debug output for style changing */
635 if ((message
== WM_STYLECHANGING
||
636 message
== WM_STYLECHANGED
) && lParam
)
638 STYLESTRUCT
*style
= (STYLESTRUCT
*)lParam
;
639 trace("\told style: 0x%08x, new style: 0x%08x\n", style
->styleOld
, style
->styleNew
);
642 msg
.message
= message
;
643 msg
.flags
= sent
|wparam
|lparam
;
644 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
647 msg
.id
= LISTVIEW_ID
;
648 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
649 add_message(sequences
, COMBINED_SEQ_INDEX
, &msg
);
651 defwndproc_counter
++;
652 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
653 defwndproc_counter
--;
657 static HWND
create_listview_control(DWORD style
)
663 GetClientRect(hwndparent
, &rect
);
664 hwnd
= CreateWindowExA(0, WC_LISTVIEWA
, "foo",
665 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
666 0, 0, rect
.right
, rect
.bottom
,
667 hwndparent
, NULL
, GetModuleHandleA(NULL
), NULL
);
668 ok(hwnd
!= NULL
, "gle=%d\n", GetLastError());
670 if (!hwnd
) return NULL
;
672 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
673 (LONG_PTR
)listview_subclass_proc
);
674 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
679 /* unicode listview window with specified parent */
680 static HWND
create_listview_controlW(DWORD style
, HWND parent
)
685 static const WCHAR nameW
[] = {'f','o','o',0};
687 GetClientRect(parent
, &rect
);
688 hwnd
= CreateWindowExW(0, WC_LISTVIEWW
, nameW
,
689 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
690 0, 0, rect
.right
, rect
.bottom
,
691 parent
, NULL
, GetModuleHandleW(NULL
), NULL
);
692 ok(hwnd
!= NULL
, "gle=%d\n", GetLastError());
694 if (!hwnd
) return NULL
;
696 oldproc
= (WNDPROC
)SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
,
697 (LONG_PTR
)listview_subclass_proc
);
698 SetWindowLongPtrW(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
703 static LRESULT WINAPI
header_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
705 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
706 static LONG defwndproc_counter
= 0;
710 msg
.message
= message
;
711 msg
.flags
= sent
|wparam
|lparam
;
712 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
716 add_message(sequences
, LISTVIEW_SEQ_INDEX
, &msg
);
718 defwndproc_counter
++;
719 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
720 defwndproc_counter
--;
724 static HWND
subclass_header(HWND hwndListview
)
729 hwnd
= (HWND
)SendMessageA(hwndListview
, LVM_GETHEADER
, 0, 0);
730 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
731 (LONG_PTR
)header_subclass_proc
);
732 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
737 static LRESULT WINAPI
editbox_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
739 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
740 static LONG defwndproc_counter
= 0;
744 msg
.message
= message
;
745 msg
.flags
= sent
|wparam
|lparam
;
746 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
751 /* all we need is sizing */
752 if (message
== WM_WINDOWPOSCHANGING
||
753 message
== WM_NCCALCSIZE
||
754 message
== WM_WINDOWPOSCHANGED
||
755 message
== WM_MOVE
||
758 add_message(sequences
, EDITBOX_SEQ_INDEX
, &msg
);
761 defwndproc_counter
++;
762 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
763 defwndproc_counter
--;
767 static HWND
subclass_editbox(HWND hwndListview
)
772 hwnd
= (HWND
)SendMessageA(hwndListview
, LVM_GETEDITCONTROL
, 0, 0);
773 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
774 (LONG_PTR
)editbox_subclass_proc
);
775 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
780 /* Performs a single LVM_HITTEST test */
781 static void test_lvm_hittest_(HWND hwnd
, INT x
, INT y
, INT item
, UINT flags
, UINT broken_flags
,
782 BOOL todo_item
, BOOL todo_flags
, int line
)
791 ret
= SendMessageA(hwnd
, LVM_HITTEST
, 0, (LPARAM
)&lpht
);
797 ok_(__FILE__
, line
)(ret
== item
, "Expected %d retval, got %d\n", item
, ret
);
798 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
799 ok_(__FILE__
, line
)(lpht
.iSubItem
== 10, "Expected subitem not overwrited\n");
804 ok_(__FILE__
, line
)(ret
== item
, "Expected %d retval, got %d\n", item
, ret
);
805 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
806 ok_(__FILE__
, line
)(lpht
.iSubItem
== 10, "Expected subitem not overwrited\n");
812 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags 0x%x, got 0x%x\n", flags
, lpht
.flags
);
814 else if (broken_flags
)
815 ok_(__FILE__
, line
)(lpht
.flags
== flags
|| broken(lpht
.flags
== broken_flags
),
816 "Expected flags %x, got %x\n", flags
, lpht
.flags
);
818 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags 0x%x, got 0x%x\n", flags
, lpht
.flags
);
821 #define test_lvm_hittest(a,b,c,d,e,f,g,h) test_lvm_hittest_(a,b,c,d,e,f,g,h,__LINE__)
823 /* Performs a single LVM_SUBITEMHITTEST test */
824 static void test_lvm_subitemhittest_(HWND hwnd
, INT x
, INT y
, INT item
, INT subitem
, UINT flags
,
825 BOOL todo_item
, BOOL todo_subitem
, BOOL todo_flags
, int line
)
833 ret
= SendMessageA(hwnd
, LVM_SUBITEMHITTEST
, 0, (LPARAM
)&lpht
);
839 ok_(__FILE__
, line
)(ret
== item
, "Expected %d retval, got %d\n", item
, ret
);
840 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
845 ok_(__FILE__
, line
)(ret
== item
, "Expected %d retval, got %d\n", item
, ret
);
846 ok_(__FILE__
, line
)(lpht
.iItem
== item
, "Expected %d item, got %d\n", item
, lpht
.iItem
);
852 ok_(__FILE__
, line
)(lpht
.iSubItem
== subitem
, "Expected subitem %d, got %d\n", subitem
, lpht
.iSubItem
);
855 ok_(__FILE__
, line
)(lpht
.iSubItem
== subitem
, "Expected subitem %d, got %d\n", subitem
, lpht
.iSubItem
);
860 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags 0x%x, got 0x%x\n", flags
, lpht
.flags
);
863 ok_(__FILE__
, line
)(lpht
.flags
== flags
, "Expected flags 0x%x, got 0x%x\n", flags
, lpht
.flags
);
866 #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__)
868 static void test_images(void)
876 static CHAR hello
[] = "hello";
878 himl
= ImageList_Create(40, 40, 0, 4, 4);
879 ok(himl
!= NULL
, "failed to create imagelist\n");
881 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
882 ok(hbmp
!= NULL
, "failed to create bitmap\n");
884 r
= ImageList_Add(himl
, hbmp
, 0);
885 ok(r
== 0, "should be zero\n");
887 hwnd
= CreateWindowExA(0, "SysListView32", "foo", LVS_OWNERDRAWFIXED
,
888 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
889 ok(hwnd
!= NULL
, "failed to create listview window\n");
891 r
= SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0,
892 LVS_EX_UNDERLINEHOT
| LVS_EX_FLATSB
| LVS_EX_ONECLICKACTIVATE
);
894 ok(r
== 0, "should return zero\n");
896 r
= SendMessageA(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
897 ok(r
== 0, "should return zero\n");
899 r
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELONG(100,50));
900 ok(r
!= 0, "got 0\n");
902 /* returns dimensions */
904 r
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
905 ok(r
== 0, "should be zero items\n");
907 item
.mask
= LVIF_IMAGE
| LVIF_TEXT
;
912 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
913 ok(r
== -1, "should fail\n");
916 item
.pszText
= hello
;
917 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
918 ok(r
== 0, "should not fail\n");
920 memset(&r1
, 0, sizeof r1
);
922 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
) &r1
);
925 r
= SendMessageA(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
926 ok(r
== TRUE
, "should not fail\n");
929 item
.pszText
= hello
;
930 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
931 ok(r
== 0, "should not fail\n");
933 memset(&r2
, 0, sizeof r2
);
935 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
) &r2
);
938 ok(!memcmp(&r1
, &r2
, sizeof r1
), "rectangle should be the same\n");
943 static void test_checkboxes(void)
948 static CHAR text
[] = "Text",
952 hwnd
= CreateWindowExA(0, "SysListView32", "foo", LVS_REPORT
,
953 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
954 ok(hwnd
!= NULL
, "failed to create listview window\n");
956 /* first without LVS_EX_CHECKBOXES set and an item and check that state is preserved */
957 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
958 item
.stateMask
= 0xffff;
963 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
967 item
.mask
= LVIF_STATE
;
968 item
.stateMask
= 0xffff;
969 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
971 ok(item
.state
== 0xfccc, "state %x\n", item
.state
);
973 /* Don't set LVIF_STATE */
974 item
.mask
= LVIF_TEXT
;
975 item
.stateMask
= 0xffff;
980 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
984 item
.mask
= LVIF_STATE
;
985 item
.stateMask
= 0xffff;
986 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
988 ok(item
.state
== 0, "state %x\n", item
.state
);
990 r
= SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
993 /* Having turned on checkboxes, check that all existing items are set to 0x1000 (unchecked) */
995 item
.mask
= LVIF_STATE
;
996 item
.stateMask
= 0xffff;
997 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
999 if (item
.state
!= 0x1ccc)
1001 win_skip("LVS_EX_CHECKBOXES style is unavailable. Skipping.\n");
1002 DestroyWindow(hwnd
);
1006 /* Now add an item without specifying a state and check that its state goes to 0x1000 */
1008 item
.mask
= LVIF_TEXT
;
1010 item
.pszText
= text2
;
1011 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1015 item
.mask
= LVIF_STATE
;
1016 item
.stateMask
= 0xffff;
1017 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1019 ok(item
.state
== 0x1000, "state %x\n", item
.state
);
1021 /* Add a further item this time specifying a state and still its state goes to 0x1000 */
1023 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
1024 item
.stateMask
= 0xffff;
1025 item
.state
= 0x2aaa;
1026 item
.pszText
= text3
;
1027 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1031 item
.mask
= LVIF_STATE
;
1032 item
.stateMask
= 0xffff;
1033 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1035 ok(item
.state
== 0x1aaa, "state %x\n", item
.state
);
1037 /* Set an item's state to checked */
1039 item
.mask
= LVIF_STATE
;
1040 item
.stateMask
= 0xf000;
1041 item
.state
= 0x2000;
1042 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1046 item
.mask
= LVIF_STATE
;
1047 item
.stateMask
= 0xffff;
1048 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1050 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
1052 /* Check that only the bits we asked for are returned,
1053 * and that all the others are set to zero
1056 item
.mask
= LVIF_STATE
;
1057 item
.stateMask
= 0xf000;
1058 item
.state
= 0xffff;
1059 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1061 ok(item
.state
== 0x2000, "state %x\n", item
.state
);
1063 /* Set the style again and check that doesn't change an item's state */
1064 r
= SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
1065 ok(r
== LVS_EX_CHECKBOXES
, "ret %x\n", r
);
1068 item
.mask
= LVIF_STATE
;
1069 item
.stateMask
= 0xffff;
1070 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1072 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
1074 /* Unsetting the checkbox extended style doesn't change an item's state */
1075 r
= SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, 0);
1076 ok(r
== LVS_EX_CHECKBOXES
, "ret %x\n", r
);
1079 item
.mask
= LVIF_STATE
;
1080 item
.stateMask
= 0xffff;
1081 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1083 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
1085 /* Now setting the style again will change an item's state */
1086 r
= SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
1090 item
.mask
= LVIF_STATE
;
1091 item
.stateMask
= 0xffff;
1092 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1094 ok(item
.state
== 0x1aaa, "state %x\n", item
.state
);
1096 /* Toggle checkbox tests (bug 9934) */
1097 memset (&item
, 0xcc, sizeof(item
));
1098 item
.mask
= LVIF_STATE
;
1101 item
.state
= LVIS_FOCUSED
;
1102 item
.stateMask
= LVIS_FOCUSED
;
1103 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1107 item
.mask
= LVIF_STATE
;
1108 item
.stateMask
= 0xffff;
1109 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1111 ok(item
.state
== 0x1aab, "state %x\n", item
.state
);
1113 r
= SendMessageA(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
1115 r
= SendMessageA(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
1119 item
.mask
= LVIF_STATE
;
1120 item
.stateMask
= 0xffff;
1121 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1123 ok(item
.state
== 0x2aab, "state %x\n", item
.state
);
1125 r
= SendMessageA(hwnd
, WM_KEYDOWN
, VK_SPACE
, 0);
1127 r
= SendMessageA(hwnd
, WM_KEYUP
, VK_SPACE
, 0);
1131 item
.mask
= LVIF_STATE
;
1132 item
.stateMask
= 0xffff;
1133 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1135 ok(item
.state
== 0x1aab, "state %x\n", item
.state
);
1137 DestroyWindow(hwnd
);
1140 static void insert_column(HWND hwnd
, int idx
)
1145 memset(&column
, 0xcc, sizeof(column
));
1146 column
.mask
= LVCF_SUBITEM
;
1147 column
.iSubItem
= idx
;
1149 rc
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, idx
, (LPARAM
)&column
);
1153 static void insert_item(HWND hwnd
, int idx
)
1155 static CHAR text
[] = "foo";
1160 memset(&item
, 0xcc, sizeof (item
));
1161 item
.mask
= LVIF_TEXT
;
1164 item
.pszText
= text
;
1166 rc
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
1170 static void test_items(void)
1172 const LPARAM lparamTest
= 0x42;
1173 static CHAR text
[] = "Text";
1179 hwnd
= CreateWindowExA(0, "SysListView32", "foo", LVS_REPORT
,
1180 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
1181 ok(hwnd
!= NULL
, "failed to create listview window\n");
1184 * Test setting/getting item params
1187 /* Set up two columns */
1188 insert_column(hwnd
, 0);
1189 insert_column(hwnd
, 1);
1191 /* LVIS_SELECTED with zero stateMask */
1193 memset (&item
, 0, sizeof (item
));
1194 item
.mask
= LVIF_STATE
;
1195 item
.state
= LVIS_SELECTED
;
1199 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1202 memset (&item
, 0xcc, sizeof (item
));
1203 item
.mask
= LVIF_STATE
;
1204 item
.stateMask
= LVIS_SELECTED
;
1208 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1210 ok(item
.state
& LVIS_SELECTED
, "Expected LVIS_SELECTED\n");
1211 SendMessageA(hwnd
, LVM_DELETEITEM
, 0, 0);
1213 /* LVIS_SELECTED with zero stateMask */
1215 memset (&item
, 0, sizeof (item
));
1216 item
.mask
= LVIF_STATE
;
1217 item
.state
= LVIS_FOCUSED
;
1221 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1224 memset (&item
, 0xcc, sizeof (item
));
1225 item
.mask
= LVIF_STATE
;
1226 item
.stateMask
= LVIS_FOCUSED
;
1230 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1232 ok(item
.state
& LVIS_FOCUSED
, "Expected LVIS_FOCUSED\n");
1233 SendMessageA(hwnd
, LVM_DELETEITEM
, 0, 0);
1235 /* LVIS_CUT with LVIS_FOCUSED stateMask */
1237 memset (&item
, 0, sizeof (item
));
1238 item
.mask
= LVIF_STATE
;
1239 item
.state
= LVIS_CUT
;
1240 item
.stateMask
= LVIS_FOCUSED
;
1243 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1246 memset (&item
, 0xcc, sizeof (item
));
1247 item
.mask
= LVIF_STATE
;
1248 item
.stateMask
= LVIS_CUT
;
1252 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1254 ok(item
.state
& LVIS_CUT
, "Expected LVIS_CUT\n");
1255 SendMessageA(hwnd
, LVM_DELETEITEM
, 0, 0);
1257 /* Insert an item with just a param */
1258 memset (&item
, 0xcc, sizeof (item
));
1259 item
.mask
= LVIF_PARAM
;
1262 item
.lParam
= lparamTest
;
1263 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1266 /* Test getting of the param */
1267 memset (&item
, 0xcc, sizeof (item
));
1268 item
.mask
= LVIF_PARAM
;
1271 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1273 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1275 /* Set up a subitem */
1276 memset (&item
, 0xcc, sizeof (item
));
1277 item
.mask
= LVIF_TEXT
;
1280 item
.pszText
= text
;
1281 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1284 item
.mask
= LVIF_TEXT
;
1287 item
.pszText
= buffA
;
1288 item
.cchTextMax
= sizeof(buffA
);
1289 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1291 ok(!memcmp(item
.pszText
, text
, sizeof(text
)), "got text %s, expected %s\n", item
.pszText
, text
);
1293 /* set up with extra flag */
1294 /* 1. reset subitem text */
1295 item
.mask
= LVIF_TEXT
;
1298 item
.pszText
= NULL
;
1299 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1302 item
.mask
= LVIF_TEXT
;
1305 item
.pszText
= buffA
;
1307 item
.cchTextMax
= sizeof(buffA
);
1308 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1310 ok(item
.pszText
[0] == 0, "got %p\n", item
.pszText
);
1312 /* 2. set new text with extra flag specified */
1313 item
.mask
= LVIF_TEXT
| LVIF_DI_SETITEM
;
1316 item
.pszText
= text
;
1317 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1318 ok(r
== 1 || broken(r
== 0) /* NT4 */, "ret %d\n", r
);
1322 item
.mask
= LVIF_TEXT
;
1325 item
.pszText
= buffA
;
1327 item
.cchTextMax
= sizeof(buffA
);
1328 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1330 ok(!memcmp(item
.pszText
, text
, sizeof(text
)), "got %s, expected %s\n", item
.pszText
, text
);
1333 /* Query param from subitem: returns main item param */
1334 memset (&item
, 0xcc, sizeof (item
));
1335 item
.mask
= LVIF_PARAM
;
1338 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1340 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1342 /* Set up param on first subitem: no effect */
1343 memset (&item
, 0xcc, sizeof (item
));
1344 item
.mask
= LVIF_PARAM
;
1347 item
.lParam
= lparamTest
+1;
1348 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1351 /* Query param from subitem again: should still return main item param */
1352 memset (&item
, 0xcc, sizeof (item
));
1353 item
.mask
= LVIF_PARAM
;
1356 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1358 ok(item
.lParam
== lparamTest
, "got lParam %lx, expected %lx\n", item
.lParam
, lparamTest
);
1360 /**** Some tests of state highlighting ****/
1361 memset (&item
, 0xcc, sizeof (item
));
1362 item
.mask
= LVIF_STATE
;
1365 item
.state
= LVIS_SELECTED
;
1366 item
.stateMask
= LVIS_SELECTED
| LVIS_DROPHILITED
;
1367 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1370 item
.state
= LVIS_DROPHILITED
;
1371 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
1374 memset (&item
, 0xcc, sizeof (item
));
1375 item
.mask
= LVIF_STATE
;
1378 item
.stateMask
= -1;
1379 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1381 ok(item
.state
== LVIS_SELECTED
, "got state %x, expected %x\n", item
.state
, LVIS_SELECTED
);
1383 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1385 todo_wine
ok(item
.state
== LVIS_DROPHILITED
, "got state %x, expected %x\n", item
.state
, LVIS_DROPHILITED
);
1387 /* some notnull but meaningless masks */
1388 memset (&item
, 0, sizeof(item
));
1389 item
.mask
= LVIF_NORECOMPUTE
;
1392 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1394 memset (&item
, 0, sizeof(item
));
1395 item
.mask
= LVIF_DI_SETITEM
;
1398 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
1401 /* set text to callback value already having it */
1402 r
= SendMessageA(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
1404 memset (&item
, 0, sizeof (item
));
1405 item
.mask
= LVIF_TEXT
;
1406 item
.pszText
= LPSTR_TEXTCALLBACKA
;
1408 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
1410 memset (&item
, 0, sizeof (item
));
1412 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1414 item
.pszText
= LPSTR_TEXTCALLBACKA
;
1415 r
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0 , (LPARAM
) &item
);
1418 ok_sequence(sequences
, PARENT_SEQ_INDEX
, textcallback_set_again_parent_seq
,
1419 "check callback text comparison rule", FALSE
);
1421 DestroyWindow(hwnd
);
1424 static void test_columns(void)
1433 hwnd
= CreateWindowExA(0, "SysListView32", "foo", LVS_LIST
,
1434 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
1435 ok(hwnd
!= NULL
, "failed to create listview window\n");
1437 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
1438 ok(header
== NULL
, "got %p\n", header
);
1440 rc
= SendMessageA(hwnd
, LVM_GETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
1441 ok(rc
== 0, "got %d\n", rc
);
1443 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
1444 ok(header
== NULL
, "got %p\n", header
);
1446 DestroyWindow(hwnd
);
1448 hwnd
= CreateWindowExA(0, "SysListView32", "foo", LVS_REPORT
,
1449 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
1450 ok(hwnd
!= NULL
, "failed to create listview window\n");
1452 /* Add a column with no mask */
1453 memset(&column
, 0xcc, sizeof(column
));
1455 rc
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&column
);
1456 ok(rc
== 0, "Inserting column with no mask failed with %d\n", rc
);
1458 /* Check its width */
1459 rc
= SendMessageA(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
1460 ok(rc
== 10, "Inserting column with no mask failed to set width to 10 with %d\n", rc
);
1462 DestroyWindow(hwnd
);
1464 /* LVM_GETCOLUMNORDERARRAY */
1465 hwnd
= create_listview_control(LVS_REPORT
);
1466 subclass_header(hwnd
);
1468 memset(&column
, 0, sizeof(column
));
1469 column
.mask
= LVCF_WIDTH
;
1471 rc
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&column
);
1475 rc
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 1, (LPARAM
)&column
);
1478 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1480 rc
= SendMessageA(hwnd
, LVM_GETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
1482 ok(order
[0] == 0, "Expected order 0, got %d\n", order
[0]);
1483 ok(order
[1] == 1, "Expected order 1, got %d\n", order
[1]);
1485 rc
= SendMessageA(hwnd
, LVM_GETCOLUMNORDERARRAY
, 0, 0);
1488 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_getorderarray_seq
, "get order array", FALSE
);
1490 /* LVM_SETCOLUMNORDERARRAY */
1491 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1495 rc
= SendMessageA(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
1498 rc
= SendMessageA(hwnd
, LVM_SETCOLUMNORDERARRAY
, 0, 0);
1501 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_setorderarray_seq
, "set order array", FALSE
);
1503 /* after column added subitem is considered as present */
1504 insert_item(hwnd
, 0);
1506 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1508 item
.pszText
= buff
;
1509 item
.cchTextMax
= sizeof(buff
);
1512 item
.mask
= LVIF_TEXT
;
1513 memset(&g_itema
, 0, sizeof(g_itema
));
1514 rc
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
1516 ok(g_itema
.iSubItem
== 1, "got %d\n", g_itema
.iSubItem
);
1518 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
1519 "get subitem text after column added", FALSE
);
1521 DestroyWindow(hwnd
);
1524 /* test setting imagelist between WM_NCCREATE and WM_CREATE */
1525 static WNDPROC listviewWndProc
;
1526 static HIMAGELIST test_create_imagelist
;
1528 static LRESULT CALLBACK
create_test_wndproc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1532 if (uMsg
== WM_CREATE
)
1534 CREATESTRUCTA
*lpcs
= (CREATESTRUCTA
*)lParam
;
1535 lpcs
->style
|= LVS_REPORT
;
1537 ret
= CallWindowProcA(listviewWndProc
, hwnd
, uMsg
, wParam
, lParam
);
1538 if (uMsg
== WM_CREATE
) SendMessageA(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)test_create_imagelist
);
1542 static void test_create(void)
1553 cls
.cbSize
= sizeof(WNDCLASSEXA
);
1554 ok(GetClassInfoExA(GetModuleHandleA(NULL
), "SysListView32", &cls
), "GetClassInfoEx failed\n");
1555 listviewWndProc
= cls
.lpfnWndProc
;
1556 cls
.lpfnWndProc
= create_test_wndproc
;
1557 cls
.lpszClassName
= "MyListView32";
1558 ok(RegisterClassExA(&cls
), "RegisterClassEx failed\n");
1560 test_create_imagelist
= ImageList_Create(16, 16, 0, 5, 10);
1561 hList
= CreateWindowA("MyListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
, GetModuleHandleA(NULL
), 0);
1562 ok((HIMAGELIST
)SendMessageA(hList
, LVM_GETIMAGELIST
, 0, 0) == test_create_imagelist
, "Image list not obtained\n");
1563 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1565 if (!IsWindow(hHeader
))
1568 win_skip("LVM_GETHEADER not implemented. Skipping.\n");
1569 DestroyWindow(hList
);
1573 ok(IsWindow(hHeader
) && IsWindowVisible(hHeader
), "Listview not in report mode\n");
1574 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1575 DestroyWindow(hList
);
1577 /* header isn't created on LVS_ICON and LVS_LIST styles */
1578 hList
= CreateWindowA("SysListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
,
1579 GetModuleHandleA(NULL
), 0);
1580 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1581 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1582 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1584 memset(&col
, 0, sizeof(LVCOLUMNA
));
1585 col
.mask
= LVCF_WIDTH
;
1587 r
= SendMessageA(hList
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
1589 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1590 ok(IsWindow(hHeader
), "Header should be created\n");
1591 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1592 style
= GetWindowLongA(hHeader
, GWL_STYLE
);
1593 ok(!(style
& HDS_HIDDEN
), "Not expected HDS_HIDDEN\n");
1594 DestroyWindow(hList
);
1596 hList
= CreateWindowA("SysListView32", "Test", WS_VISIBLE
|LVS_LIST
, 0, 0, 100, 100, NULL
, NULL
,
1597 GetModuleHandleA(NULL
), 0);
1598 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1599 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1600 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1602 memset(&col
, 0, sizeof(LVCOLUMNA
));
1603 col
.mask
= LVCF_WIDTH
;
1605 r
= SendMessageA(hList
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
1607 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1608 ok(IsWindow(hHeader
), "Header should be created\n");
1609 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1610 DestroyWindow(hList
);
1612 /* try to switch LVS_ICON -> LVS_REPORT and back LVS_ICON -> LVS_REPORT */
1613 hList
= CreateWindowA("SysListView32", "Test", WS_VISIBLE
, 0, 0, 100, 100, NULL
, NULL
,
1614 GetModuleHandleA(NULL
), 0);
1615 ret
= SetWindowLongPtrA(hList
, GWL_STYLE
, GetWindowLongPtrA(hList
, GWL_STYLE
) | LVS_REPORT
);
1616 ok(ret
& WS_VISIBLE
, "Style wrong, should have WS_VISIBLE\n");
1617 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1618 ok(IsWindow(hHeader
), "Header should be created\n");
1619 ret
= SetWindowLongPtrA(hList
, GWL_STYLE
, GetWindowLongA(hList
, GWL_STYLE
) & ~LVS_REPORT
);
1620 ok((ret
& WS_VISIBLE
) && (ret
& LVS_REPORT
), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1621 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1622 ok(IsWindow(hHeader
), "Header should be created\n");
1623 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1624 DestroyWindow(hList
);
1626 /* try to switch LVS_LIST -> LVS_REPORT and back LVS_LIST -> LVS_REPORT */
1627 hList
= CreateWindowA("SysListView32", "Test", WS_VISIBLE
|LVS_LIST
, 0, 0, 100, 100, NULL
, NULL
,
1628 GetModuleHandleA(NULL
), 0);
1629 ret
= SetWindowLongPtrA(hList
, GWL_STYLE
,
1630 (GetWindowLongPtrA(hList
, GWL_STYLE
) & ~LVS_LIST
) | LVS_REPORT
);
1631 ok(((ret
& WS_VISIBLE
) && (ret
& LVS_LIST
)), "Style wrong, should have WS_VISIBLE|LVS_LIST\n");
1632 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1633 ok(IsWindow(hHeader
), "Header should be created\n");
1634 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1635 ret
= SetWindowLongPtrA(hList
, GWL_STYLE
,
1636 (GetWindowLongPtrA(hList
, GWL_STYLE
) & ~LVS_REPORT
) | LVS_LIST
);
1637 ok(((ret
& WS_VISIBLE
) && (ret
& LVS_REPORT
)), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1638 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1639 ok(IsWindow(hHeader
), "Header should be created\n");
1640 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1641 DestroyWindow(hList
);
1643 /* LVS_REPORT without WS_VISIBLE */
1644 hList
= CreateWindowA("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1645 GetModuleHandleA(NULL
), 0);
1646 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1647 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1648 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1650 memset(&col
, 0, sizeof(LVCOLUMNA
));
1651 col
.mask
= LVCF_WIDTH
;
1653 r
= SendMessageA(hList
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
1655 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1656 ok(IsWindow(hHeader
), "Header should be created\n");
1657 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1658 DestroyWindow(hList
);
1660 /* LVS_REPORT without WS_VISIBLE, try to show it */
1661 hList
= CreateWindowA("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1662 GetModuleHandleA(NULL
), 0);
1663 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1664 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1665 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1666 ShowWindow(hList
, SW_SHOW
);
1667 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1668 ok(IsWindow(hHeader
), "Header should be created\n");
1669 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1670 DestroyWindow(hList
);
1672 /* LVS_REPORT with LVS_NOCOLUMNHEADER */
1673 hList
= CreateWindowA("SysListView32", "Test", LVS_REPORT
|LVS_NOCOLUMNHEADER
|WS_VISIBLE
,
1674 0, 0, 100, 100, NULL
, NULL
, GetModuleHandleA(NULL
), 0);
1675 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1676 ok(IsWindow(hHeader
), "Header should be created\n");
1677 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1678 /* HDS_DRAGDROP set by default */
1679 ok(GetWindowLongPtrA(hHeader
, GWL_STYLE
) & HDS_DRAGDROP
, "Expected header to have HDS_DRAGDROP\n");
1680 DestroyWindow(hList
);
1682 /* setting LVS_EX_HEADERDRAGDROP creates header */
1683 hList
= CreateWindowA("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1684 GetModuleHandleA(NULL
), 0);
1685 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1686 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1687 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1688 SendMessageA(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_HEADERDRAGDROP
);
1689 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1690 ok(IsWindow(hHeader
) ||
1691 broken(!IsWindow(hHeader
)), /* 4.7x common controls */
1692 "Header should be created\n");
1693 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1694 DestroyWindow(hList
);
1696 /* setting LVS_EX_GRIDLINES creates header */
1697 hList
= CreateWindowA("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1698 GetModuleHandleA(NULL
), 0);
1699 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1700 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1701 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1702 SendMessageA(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_GRIDLINES
);
1703 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1704 ok(IsWindow(hHeader
) ||
1705 broken(!IsWindow(hHeader
)), /* 4.7x common controls */
1706 "Header should be created\n");
1707 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1708 DestroyWindow(hList
);
1710 /* setting LVS_EX_FULLROWSELECT creates header */
1711 hList
= CreateWindowA("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1712 GetModuleHandleA(NULL
), 0);
1713 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1714 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1715 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1716 SendMessageA(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_FULLROWSELECT
);
1717 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1718 ok(IsWindow(hHeader
) ||
1719 broken(!IsWindow(hHeader
)), /* 4.7x common controls */
1720 "Header should be created\n");
1721 ok(hHeader
== GetDlgItem(hList
, 0), "Expected header as dialog item\n");
1722 DestroyWindow(hList
);
1724 /* not report style accepts LVS_EX_HEADERDRAGDROP too */
1725 hList
= create_listview_control(LVS_ICON
);
1726 SendMessageA(hList
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_HEADERDRAGDROP
);
1727 r
= SendMessageA(hList
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
1728 ok(r
& LVS_EX_HEADERDRAGDROP
, "Expected LVS_EX_HEADERDRAGDROP to be set\n");
1729 DestroyWindow(hList
);
1731 /* requesting header info with LVM_GETSUBITEMRECT doesn't create it */
1732 hList
= CreateWindowA("SysListView32", "Test", LVS_REPORT
, 0, 0, 100, 100, NULL
, NULL
,
1733 GetModuleHandleA(NULL
), 0);
1734 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1735 ok(NULL
== GetDlgItem(hList
, 0), "NULL dialog item expected\n");
1737 rect
.left
= LVIR_BOUNDS
;
1739 rect
.right
= rect
.bottom
= -10;
1740 r
= SendMessageA(hList
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
1741 /* right value contains garbage, probably because header columns are not set up */
1742 expect(0, rect
.bottom
);
1745 hHeader
= (HWND
)SendMessageA(hList
, LVM_GETHEADER
, 0, 0);
1746 ok(!IsWindow(hHeader
), "Header shouldn't be created\n");
1747 ok(GetDlgItem(hList
, 0) == NULL
, "NULL dialog item expected\n");
1749 DestroyWindow(hList
);
1751 /* WM_MEASUREITEM should be sent when created with LVS_OWNERDRAWFIXED */
1752 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1753 hList
= create_listview_control(LVS_OWNERDRAWFIXED
| LVS_REPORT
);
1754 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_ownerdrawfixed_parent_seq
,
1755 "created with LVS_OWNERDRAWFIXED|LVS_REPORT - parent seq", FALSE
);
1756 DestroyWindow(hList
);
1759 static void test_redraw(void)
1766 hwnd
= create_listview_control(LVS_REPORT
);
1767 subclass_header(hwnd
);
1769 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1771 InvalidateRect(hwnd
, NULL
, TRUE
);
1773 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, redraw_listview_seq
, "redraw listview", FALSE
);
1775 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1777 /* forward WM_ERASEBKGND to parent on CLR_NONE background color */
1778 /* 1. Without backbuffer */
1779 res
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, CLR_NONE
);
1782 hdc
= GetWindowDC(hwndparent
);
1784 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1785 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1786 ok(r
== 1, "Expected not zero result\n");
1787 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, forward_erasebkgnd_parent_seq
,
1788 "forward WM_ERASEBKGND on CLR_NONE", FALSE
);
1790 res
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, CLR_DEFAULT
);
1793 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1794 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1796 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, empty_seq
,
1797 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE
);
1799 /* 2. With backbuffer */
1800 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_DOUBLEBUFFER
,
1801 LVS_EX_DOUBLEBUFFER
);
1802 res
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, CLR_NONE
);
1805 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1806 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1808 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, forward_erasebkgnd_parent_seq
,
1809 "forward WM_ERASEBKGND on CLR_NONE", FALSE
);
1811 res
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, CLR_DEFAULT
);
1814 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1815 r
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
1816 todo_wine
expect(1, r
);
1817 ok_sequence(sequences
, PARENT_FULL_SEQ_INDEX
, empty_seq
,
1818 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE
);
1820 ReleaseDC(hwndparent
, hdc
);
1822 DestroyWindow(hwnd
);
1825 static LRESULT WINAPI
cd_wndproc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
1827 COLORREF clr
, c0ffee
= RGB(0xc0, 0xff, 0xee);
1829 if(message
== WM_NOTIFY
) {
1830 NMHDR
*nmhdr
= (NMHDR
*)lParam
;
1831 if(nmhdr
->code
== NM_CUSTOMDRAW
) {
1832 NMLVCUSTOMDRAW
*nmlvcd
= (NMLVCUSTOMDRAW
*)nmhdr
;
1835 msg
.message
= message
;
1836 msg
.flags
= sent
|wparam
|lparam
|custdraw
;
1837 msg
.wParam
= wParam
;
1838 msg
.lParam
= lParam
;
1839 msg
.id
= nmhdr
->code
;
1840 msg
.stage
= nmlvcd
->nmcd
.dwDrawStage
;
1841 add_message(sequences
, PARENT_CD_SEQ_INDEX
, &msg
);
1843 switch(nmlvcd
->nmcd
.dwDrawStage
) {
1845 SetBkColor(nmlvcd
->nmcd
.hdc
, c0ffee
);
1846 return CDRF_NOTIFYITEMDRAW
|CDRF_NOTIFYPOSTPAINT
;
1847 case CDDS_ITEMPREPAINT
:
1848 nmlvcd
->clrTextBk
= CLR_DEFAULT
;
1849 nmlvcd
->clrText
= RGB(0, 255, 0);
1850 return CDRF_NOTIFYSUBITEMDRAW
|CDRF_NOTIFYPOSTPAINT
;
1851 case CDDS_ITEMPREPAINT
| CDDS_SUBITEM
:
1852 clr
= GetBkColor(nmlvcd
->nmcd
.hdc
);
1853 ok(nmlvcd
->clrTextBk
== CLR_DEFAULT
, "got 0x%x\n", nmlvcd
->clrTextBk
);
1854 ok(nmlvcd
->clrText
== RGB(0, 255, 0), "got 0x%x\n", nmlvcd
->clrText
);
1855 if (nmlvcd
->iSubItem
)
1856 todo_wine
ok(clr
== c0ffee
, "clr=%.8x\n", clr
);
1858 ok(clr
== c0ffee
, "clr=%.8x\n", clr
);
1859 return CDRF_NOTIFYPOSTPAINT
;
1860 case CDDS_ITEMPOSTPAINT
| CDDS_SUBITEM
:
1861 clr
= GetBkColor(nmlvcd
->nmcd
.hdc
);
1862 todo_wine
ok(clr
== c0ffee
, "clr=%.8x\n", clr
);
1863 ok(nmlvcd
->clrTextBk
== CLR_DEFAULT
, "got 0x%x\n", nmlvcd
->clrTextBk
);
1864 ok(nmlvcd
->clrText
== RGB(0, 255, 0), "got 0x%x\n", nmlvcd
->clrText
);
1865 return CDRF_DODEFAULT
;
1867 return CDRF_DODEFAULT
;
1871 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
1874 static void test_customdraw(void)
1879 hwnd
= create_listview_control(LVS_REPORT
);
1881 insert_column(hwnd
, 0);
1882 insert_column(hwnd
, 1);
1883 insert_item(hwnd
, 0);
1885 oldwndproc
= (WNDPROC
)SetWindowLongPtrA(hwndparent
, GWLP_WNDPROC
,
1886 (LONG_PTR
)cd_wndproc
);
1888 InvalidateRect(hwnd
, NULL
, TRUE
);
1892 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1893 InvalidateRect(hwnd
, NULL
, TRUE
);
1895 ok_sequence(sequences
, PARENT_CD_SEQ_INDEX
, parent_report_cd_seq
, "parent customdraw, LVS_REPORT", FALSE
);
1897 DestroyWindow(hwnd
);
1899 hwnd
= create_listview_control(LVS_LIST
);
1901 insert_column(hwnd
, 0);
1902 insert_column(hwnd
, 1);
1903 insert_item(hwnd
, 0);
1905 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1906 InvalidateRect(hwnd
, NULL
, TRUE
);
1908 ok_sequence(sequences
, PARENT_CD_SEQ_INDEX
, parent_list_cd_seq
, "parent customdraw, LVS_LIST", FALSE
);
1910 SetWindowLongPtrA(hwndparent
, GWLP_WNDPROC
, (LONG_PTR
)oldwndproc
);
1911 DestroyWindow(hwnd
);
1914 static void test_icon_spacing(void)
1916 /* LVM_SETICONSPACING */
1917 /* note: LVM_SETICONSPACING returns the previous icon spacing if successful */
1923 hwnd
= create_listview_control(LVS_ICON
);
1924 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1926 r
= SendMessageA(hwnd
, WM_NOTIFYFORMAT
, (WPARAM
)hwndparent
, NF_REQUERY
);
1927 expect(NFR_ANSI
, r
);
1929 /* reset the icon spacing to defaults */
1930 SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1, -1));
1932 /* now we can request what the defaults are */
1933 r
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1, -1));
1937 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1939 r
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(20, 30));
1940 ok(r
== MAKELONG(w
, h
) ||
1941 broken(r
== MAKELONG(w
, w
)), /* win98 */
1942 "Expected %d, got %d\n", MAKELONG(w
, h
), r
);
1944 r
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(25, 35));
1948 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
1949 DestroyWindow(hwnd
);
1952 expect(MAKELONG(20,30), r
);
1954 r
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(-1,-1));
1955 expect(MAKELONG(25,35), r
);
1957 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_icon_spacing_seq
, "test icon spacing seq", FALSE
);
1959 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1960 DestroyWindow(hwnd
);
1963 static void test_color(void)
1971 COLORREF colors
[4] = {RGB(0,0,0), RGB(100,50,200), CLR_NONE
, RGB(255,255,255)};
1973 hwnd
= create_listview_control(LVS_REPORT
);
1974 ok(hwnd
!= NULL
, "failed to create a listview window\n");
1976 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1978 for (i
= 0; i
< 4; i
++)
1982 r
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, color
);
1984 r
= SendMessageA(hwnd
, LVM_GETBKCOLOR
, 0, 0);
1987 r
= SendMessageA(hwnd
, LVM_SETTEXTCOLOR
, 0, color
);
1989 r
= SendMessageA(hwnd
, LVM_GETTEXTCOLOR
, 0, 0);
1992 r
= SendMessageA(hwnd
, LVM_SETTEXTBKCOLOR
, 0, color
);
1994 r
= SendMessageA(hwnd
, LVM_GETTEXTBKCOLOR
, 0, 0);
1998 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_color_seq
, "test color seq", FALSE
);
1999 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2001 /* invalidation test done separately to avoid a message chain mess */
2002 r
= ValidateRect(hwnd
, NULL
);
2004 r
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, colors
[0]);
2007 rect
.right
= rect
.bottom
= 1;
2008 r
= GetUpdateRect(hwnd
, &rect
, TRUE
);
2009 todo_wine
expect(FALSE
, r
);
2010 ok(rect
.right
== 0 && rect
.bottom
== 0, "got update rectangle\n");
2012 r
= ValidateRect(hwnd
, NULL
);
2014 r
= SendMessageA(hwnd
, LVM_SETTEXTCOLOR
, 0, colors
[0]);
2017 rect
.right
= rect
.bottom
= 1;
2018 r
= GetUpdateRect(hwnd
, &rect
, TRUE
);
2019 todo_wine
expect(FALSE
, r
);
2020 ok(rect
.right
== 0 && rect
.bottom
== 0, "got update rectangle\n");
2022 r
= ValidateRect(hwnd
, NULL
);
2024 r
= SendMessageA(hwnd
, LVM_SETTEXTBKCOLOR
, 0, colors
[0]);
2027 rect
.right
= rect
.bottom
= 1;
2028 r
= GetUpdateRect(hwnd
, &rect
, TRUE
);
2029 todo_wine
expect(FALSE
, r
);
2030 ok(rect
.right
== 0 && rect
.bottom
== 0, "got update rectangle\n");
2032 DestroyWindow(hwnd
);
2035 static void test_item_count(void)
2037 /* LVM_INSERTITEM, LVM_DELETEITEM, LVM_DELETEALLITEMS, LVM_GETITEMCOUNT */
2050 static CHAR item0text
[] = "item0";
2051 static CHAR item1text
[] = "item1";
2052 static CHAR item2text
[] = "item2";
2054 hwnd
= create_listview_control(LVS_REPORT
);
2055 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2057 /* resize in dpiaware manner to fit all 3 items added */
2059 hOldFont
= SelectObject(hdc
, GetStockObject(SYSTEM_FONT
));
2060 GetTextMetricsA(hdc
, &tm
);
2061 /* 2 extra pixels for bounds and header border */
2062 height
= tm
.tmHeight
+ 2;
2063 SelectObject(hdc
, hOldFont
);
2066 GetWindowRect(hwnd
, &rect
);
2067 /* 3 items + 1 header + 1 to be sure */
2068 MoveWindow(hwnd
, 0, 0, rect
.right
- rect
.left
, 5 * height
, FALSE
);
2070 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2072 r
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2076 item0
.mask
= LVIF_TEXT
;
2079 item0
.pszText
= item0text
;
2080 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item0
);
2083 /* [item0, item1] */
2084 item1
.mask
= LVIF_TEXT
;
2087 item1
.pszText
= item1text
;
2088 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item1
);
2091 /* [item0, item1, item2] */
2092 item2
.mask
= LVIF_TEXT
;
2095 item2
.pszText
= item2text
;
2096 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item2
);
2099 r
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2102 /* [item0, item1] */
2103 r
= SendMessageA(hwnd
, LVM_DELETEITEM
, 2, 0);
2106 r
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2110 r
= SendMessageA(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
2113 r
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2117 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item1
);
2120 /* [item0, item1] */
2121 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item1
);
2124 r
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2127 /* [item0, item1, item2] */
2128 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item2
);
2131 r
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2134 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_item_count_seq
, "test item count seq", FALSE
);
2136 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2137 DestroyWindow(hwnd
);
2140 static void test_item_position(void)
2142 /* LVM_SETITEMPOSITION/LVM_GETITEMPOSITION */
2151 static CHAR item0text
[] = "item0";
2152 static CHAR item1text
[] = "item1";
2153 static CHAR item2text
[] = "item2";
2155 hwnd
= create_listview_control(LVS_ICON
);
2156 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2158 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2161 item0
.mask
= LVIF_TEXT
;
2164 item0
.pszText
= item0text
;
2165 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item0
);
2168 /* [item0, item1] */
2169 item1
.mask
= LVIF_TEXT
;
2172 item1
.pszText
= item1text
;
2173 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item1
);
2176 /* [item0, item1, item2] */
2177 item2
.mask
= LVIF_TEXT
;
2180 item2
.pszText
= item2text
;
2181 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item2
);
2184 r
= SendMessageA(hwnd
, LVM_SETITEMPOSITION
, 1, MAKELPARAM(10,5));
2186 r
= SendMessageA(hwnd
, LVM_GETITEMPOSITION
, 1, (LPARAM
) &position
);
2188 expect2(10, 5, position
.x
, position
.y
);
2190 r
= SendMessageA(hwnd
, LVM_SETITEMPOSITION
, 2, MAKELPARAM(0,0));
2192 r
= SendMessageA(hwnd
, LVM_GETITEMPOSITION
, 2, (LPARAM
) &position
);
2194 expect2(0, 0, position
.x
, position
.y
);
2196 r
= SendMessageA(hwnd
, LVM_SETITEMPOSITION
, 0, MAKELPARAM(20,20));
2198 r
= SendMessageA(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
) &position
);
2200 expect2(20, 20, position
.x
, position
.y
);
2202 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_itempos_seq
, "test item position seq", TRUE
);
2204 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2205 DestroyWindow(hwnd
);
2208 static void test_getorigin(void)
2216 position
.x
= position
.y
= 0;
2218 hwnd
= create_listview_control(LVS_ICON
);
2219 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2220 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2222 r
= SendMessageA(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
2224 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2225 DestroyWindow(hwnd
);
2227 hwnd
= create_listview_control(LVS_SMALLICON
);
2228 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2229 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2231 r
= SendMessageA(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
2233 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2234 DestroyWindow(hwnd
);
2236 hwnd
= create_listview_control(LVS_LIST
);
2237 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2238 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2240 r
= SendMessageA(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
2242 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2243 DestroyWindow(hwnd
);
2245 hwnd
= create_listview_control(LVS_REPORT
);
2246 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2247 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2249 r
= SendMessageA(hwnd
, LVM_GETORIGIN
, 0, (LPARAM
)&position
);
2251 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2252 DestroyWindow(hwnd
);
2255 static void test_multiselect(void)
2257 typedef struct t_select_task
2268 int i
,j
,item_count
,selected_count
;
2269 static const int items
=5;
2275 static struct t_select_task task_list
[] = {
2276 { "using VK_DOWN", 0, VK_DOWN
, -1, -1 },
2277 { "using VK_UP", -1, VK_UP
, -1, -1 },
2278 { "using VK_END", 0, VK_END
, 1, -1 },
2279 { "using VK_HOME", -1, VK_HOME
, 1, -1 }
2282 hwnd
= create_listview_control(LVS_REPORT
);
2284 for (i
= 0; i
< items
; i
++)
2285 insert_item(hwnd
, 0);
2287 item_count
= (int)SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2288 expect(items
, item_count
);
2290 for (i
= 0; i
< 4; i
++) {
2293 task
= task_list
[i
];
2295 /* deselect all items */
2297 item
.stateMask
= LVIS_SELECTED
;
2298 SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2299 SendMessageA(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2301 /* set initial position */
2302 SendMessageA(hwnd
, LVM_SETSELECTIONMARK
, 0, (task
.initPos
== -1 ? item_count
-1 : task
.initPos
));
2304 item
.state
= LVIS_SELECTED
;
2305 item
.stateMask
= LVIS_SELECTED
;
2306 SendMessageA(hwnd
, LVM_SETITEMSTATE
, task
.initPos
== -1 ? item_count
-1 : task
.initPos
, (LPARAM
)&item
);
2308 selected_count
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2309 ok(selected_count
== 1, "expected 1, got %d\n", selected_count
);
2311 /* Set SHIFT key pressed */
2312 GetKeyboardState(kstate
);
2313 kstate
[VK_SHIFT
]=0x80;
2314 SetKeyboardState(kstate
);
2316 for (j
=1;j
<=(task
.count
== -1 ? item_count
: task
.count
);j
++) {
2317 r
= SendMessageA(hwnd
, WM_KEYDOWN
, task
.loopVK
, 0);
2319 r
= SendMessageA(hwnd
, WM_KEYUP
, task
.loopVK
, 0);
2323 selected_count
= (int)SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2325 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
);
2327 /* Set SHIFT key released */
2328 GetKeyboardState(kstate
);
2329 kstate
[VK_SHIFT
]=0x00;
2330 SetKeyboardState(kstate
);
2332 DestroyWindow(hwnd
);
2334 /* make multiple selection, then switch to LVS_SINGLESEL */
2335 hwnd
= create_listview_control(LVS_REPORT
);
2336 for (i
=0;i
<items
;i
++) {
2337 insert_item(hwnd
, 0);
2339 item_count
= (int)SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
2340 expect(items
,item_count
);
2342 /* try with NULL pointer */
2343 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, 0);
2346 /* select all, check notifications */
2348 item
.stateMask
= LVIS_SELECTED
;
2349 SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2351 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2353 item
.stateMask
= LVIS_SELECTED
;
2354 item
.state
= LVIS_SELECTED
;
2355 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2358 ok_sequence(sequences
, PARENT_SEQ_INDEX
, change_all_parent_seq
,
2359 "select all notification", FALSE
);
2361 /* select all again (all selected already) */
2362 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2364 memset(&g_nmlistview_changing
, 0xcc, sizeof(g_nmlistview_changing
));
2366 item
.stateMask
= LVIS_SELECTED
;
2367 item
.state
= LVIS_SELECTED
;
2368 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2371 ok(g_nmlistview_changing
.uNewState
== LVIS_SELECTED
, "got 0x%x\n", g_nmlistview_changing
.uNewState
);
2372 ok(g_nmlistview_changing
.uOldState
== LVIS_SELECTED
, "got 0x%x\n", g_nmlistview_changing
.uOldState
);
2373 ok(g_nmlistview_changing
.uChanged
== LVIF_STATE
, "got 0x%x\n", g_nmlistview_changing
.uChanged
);
2375 ok_sequence(sequences
, PARENT_SEQ_INDEX
, changing_all_parent_seq
,
2376 "select all notification 2", FALSE
);
2378 /* deselect all items */
2379 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2382 item
.stateMask
= LVIS_SELECTED
;
2383 SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2385 ok_sequence(sequences
, PARENT_SEQ_INDEX
, change_all_parent_seq
,
2386 "deselect all notification", FALSE
);
2388 /* deselect all items again */
2389 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2391 item
.stateMask
= LVIS_SELECTED
;
2392 SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2393 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "deselect all notification 2", FALSE
);
2395 /* any non-zero state value does the same */
2396 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2398 memset(&g_nmlistview_changing
, 0xcc, sizeof(g_nmlistview_changing
));
2400 item
.stateMask
= LVIS_SELECTED
;
2401 item
.state
= LVIS_CUT
;
2402 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2405 ok(g_nmlistview_changing
.uNewState
== 0, "got 0x%x\n", g_nmlistview_changing
.uNewState
);
2406 ok(g_nmlistview_changing
.uOldState
== 0, "got 0x%x\n", g_nmlistview_changing
.uOldState
);
2407 ok(g_nmlistview_changing
.uChanged
== LVIF_STATE
, "got 0x%x\n", g_nmlistview_changing
.uChanged
);
2409 ok_sequence(sequences
, PARENT_SEQ_INDEX
, changing_all_parent_seq
,
2410 "set state all notification 3", FALSE
);
2412 SendMessageA(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2413 for (i
= 0; i
< 3; i
++) {
2414 item
.state
= LVIS_SELECTED
;
2415 item
.stateMask
= LVIS_SELECTED
;
2416 SendMessageA(hwnd
, LVM_SETITEMSTATE
, i
, (LPARAM
)&item
);
2419 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2421 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2424 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2425 ok(!(style
& LVS_SINGLESEL
), "LVS_SINGLESEL isn't expected\n");
2426 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SINGLESEL
);
2427 /* check that style is accepted */
2428 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2429 ok(style
& LVS_SINGLESEL
, "LVS_SINGLESEL expected\n");
2432 r
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, i
, LVIS_SELECTED
);
2433 ok(r
& LVIS_SELECTED
, "Expected item %d to be selected\n", i
);
2435 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2437 SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2440 /* select one more */
2441 item
.state
= LVIS_SELECTED
;
2442 item
.stateMask
= LVIS_SELECTED
;
2443 SendMessageA(hwnd
, LVM_SETITEMSTATE
, 3, (LPARAM
)&item
);
2446 r
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, i
, LVIS_SELECTED
);
2447 ok(!(r
& LVIS_SELECTED
), "Expected item %d to be unselected\n", i
);
2450 r
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 3, LVIS_SELECTED
);
2451 ok(r
& LVIS_SELECTED
, "Expected item %d to be selected\n", i
);
2453 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2455 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2458 /* try to select all on LVS_SINGLESEL */
2459 memset(&item
, 0, sizeof(item
));
2460 item
.stateMask
= LVIS_SELECTED
;
2461 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2463 SendMessageA(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2465 item
.stateMask
= LVIS_SELECTED
;
2466 item
.state
= LVIS_SELECTED
;
2467 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2470 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2472 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2475 /* try to deselect all on LVS_SINGLESEL */
2476 item
.stateMask
= LVIS_SELECTED
;
2477 item
.state
= LVIS_SELECTED
;
2478 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2481 item
.stateMask
= LVIS_SELECTED
;
2483 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2485 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2488 /* 1. selection mark is update when new focused item is set */
2489 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2490 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_SINGLESEL
);
2492 r
= SendMessageA(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2495 item
.stateMask
= LVIS_FOCUSED
;
2496 item
.state
= LVIS_FOCUSED
;
2497 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
2500 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2503 /* it's not updated if already set */
2504 item
.stateMask
= LVIS_FOCUSED
;
2505 item
.state
= LVIS_FOCUSED
;
2506 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 1, (LPARAM
)&item
);
2509 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2512 r
= SendMessageA(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2515 item
.stateMask
= LVIS_FOCUSED
;
2516 item
.state
= LVIS_FOCUSED
;
2517 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 1, (LPARAM
)&item
);
2520 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2523 /* need to reset focused item first */
2524 item
.stateMask
= LVIS_FOCUSED
;
2526 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2529 item
.stateMask
= LVIS_FOCUSED
;
2530 item
.state
= LVIS_FOCUSED
;
2531 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 2, (LPARAM
)&item
);
2534 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2537 item
.stateMask
= LVIS_FOCUSED
;
2539 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2542 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2545 /* 2. same tests, with LVM_SETITEM */
2546 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2547 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_SINGLESEL
);
2549 r
= SendMessageA(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2552 item
.stateMask
= LVIS_FOCUSED
;
2553 item
.state
= LVIS_FOCUSED
;
2554 item
.mask
= LVIF_STATE
;
2555 item
.iItem
= item
.iSubItem
= 0;
2556 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
2559 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2562 /* it's not updated if already set */
2563 item
.stateMask
= LVIS_FOCUSED
;
2564 item
.state
= LVIS_FOCUSED
;
2565 item
.mask
= LVIF_STATE
;
2568 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
2571 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2574 r
= SendMessageA(hwnd
, LVM_SETSELECTIONMARK
, 0, -1);
2577 item
.stateMask
= LVIS_FOCUSED
;
2578 item
.state
= LVIS_FOCUSED
;
2579 item
.mask
= LVIF_STATE
;
2582 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
2585 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2588 /* need to reset focused item first */
2589 item
.stateMask
= LVIS_FOCUSED
;
2591 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2594 item
.stateMask
= LVIS_FOCUSED
;
2595 item
.state
= LVIS_FOCUSED
;
2596 item
.mask
= LVIF_STATE
;
2599 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
2602 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2605 item
.stateMask
= LVIS_FOCUSED
;
2607 r
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
2610 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2613 DestroyWindow(hwnd
);
2616 static void test_subitem_rect(void)
2624 /* test LVM_GETSUBITEMRECT for header */
2625 hwnd
= create_listview_control(LVS_REPORT
);
2626 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2627 /* add some columns */
2628 memset(&col
, 0, sizeof(LVCOLUMNA
));
2629 col
.mask
= LVCF_WIDTH
;
2631 r
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
2634 r
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 1, (LPARAM
)&col
);
2637 r
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 2, (LPARAM
)&col
);
2639 /* item = -1 means header, subitem index is 1 based */
2640 rect
.left
= LVIR_BOUNDS
;
2642 rect
.right
= rect
.bottom
= 0;
2643 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2646 rect
.left
= LVIR_BOUNDS
;
2648 rect
.right
= rect
.bottom
= 0;
2649 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2652 expect(100, rect
.left
);
2653 expect(250, rect
.right
);
2654 expect(3, rect
.top
);
2656 rect
.left
= LVIR_BOUNDS
;
2658 rect
.right
= rect
.bottom
= 0;
2659 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2662 expect(250, rect
.left
);
2663 expect(450, rect
.right
);
2664 expect(3, rect
.top
);
2666 /* item LVS_REPORT padding isn't applied to subitems */
2667 insert_item(hwnd
, 0);
2669 rect
.left
= LVIR_BOUNDS
;
2671 rect
.right
= rect
.bottom
= 0;
2672 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2674 expect(100, rect
.left
);
2675 expect(250, rect
.right
);
2677 rect
.left
= LVIR_ICON
;
2679 rect
.right
= rect
.bottom
= 0;
2680 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2682 /* no icon attached - zero width rectangle, with no left padding */
2683 expect(100, rect
.left
);
2684 expect(100, rect
.right
);
2686 rect
.left
= LVIR_LABEL
;
2688 rect
.right
= rect
.bottom
= 0;
2689 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2691 /* same as full LVIR_BOUNDS */
2692 expect(100, rect
.left
);
2693 expect(250, rect
.right
);
2695 SendMessageA(hwnd
, LVM_SCROLL
, 10, 0);
2697 rect
.left
= LVIR_BOUNDS
;
2699 rect
.right
= rect
.bottom
= 0;
2700 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2702 expect(90, rect
.left
);
2703 expect(240, rect
.right
);
2705 SendMessageA(hwnd
, LVM_SCROLL
, -10, 0);
2707 /* test header interaction */
2708 subclass_header(hwnd
);
2709 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
2711 rect
.left
= LVIR_BOUNDS
;
2713 rect
.right
= rect
.bottom
= 0;
2714 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2717 rect
.left
= LVIR_BOUNDS
;
2719 rect
.right
= rect
.bottom
= 0;
2720 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2723 rect
.left
= LVIR_BOUNDS
;
2725 rect
.right
= rect
.bottom
= 0;
2726 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, -10, (LPARAM
)&rect
);
2729 rect
.left
= LVIR_BOUNDS
;
2731 rect
.right
= rect
.bottom
= 0;
2732 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 20, (LPARAM
)&rect
);
2735 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getsubitemrect_seq
, "LVM_GETSUBITEMRECT negative index", FALSE
);
2737 DestroyWindow(hwnd
);
2739 /* test subitem rects after re-arranging columns */
2740 hwnd
= create_listview_control(LVS_REPORT
);
2741 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2742 memset(&col
, 0, sizeof(LVCOLUMNA
));
2743 col
.mask
= LVCF_WIDTH
;
2746 r
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
2750 r
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 1, (LPARAM
)&col
);
2754 r
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 2, (LPARAM
)&col
);
2757 insert_item(hwnd
, 0);
2758 insert_item(hwnd
, 1);
2760 /* wrong item is refused for main item */
2761 rect
.left
= LVIR_BOUNDS
;
2763 rect
.right
= rect
.bottom
= -1;
2764 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 2, (LPARAM
)&rect
);
2767 /* for subitems rectangle is calculated even if there's no item added */
2768 rect
.left
= LVIR_BOUNDS
;
2770 rect
.right
= rect
.bottom
= -1;
2771 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 1, (LPARAM
)&rect
);
2774 rect2
.left
= LVIR_BOUNDS
;
2776 rect2
.right
= rect2
.bottom
= -1;
2777 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 2, (LPARAM
)&rect2
);
2779 expect(rect
.right
, rect2
.right
);
2780 expect(rect
.left
, rect2
.left
);
2781 expect(rect
.bottom
, rect2
.top
);
2782 ok(rect2
.bottom
> rect2
.top
, "expected not zero height\n");
2784 arr
[0] = 1; arr
[1] = 0; arr
[2] = 2;
2785 r
= SendMessageA(hwnd
, LVM_SETCOLUMNORDERARRAY
, 3, (LPARAM
)arr
);
2788 rect
.left
= LVIR_BOUNDS
;
2790 rect
.right
= rect
.bottom
= -1;
2791 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2793 expect(0, rect
.left
);
2794 expect(600, rect
.right
);
2796 rect
.left
= LVIR_BOUNDS
;
2798 rect
.right
= rect
.bottom
= -1;
2799 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2801 expect(0, rect
.left
);
2802 expect(200, rect
.right
);
2804 rect2
.left
= LVIR_BOUNDS
;
2806 rect2
.right
= rect2
.bottom
= -1;
2807 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 1, (LPARAM
)&rect2
);
2809 expect(0, rect2
.left
);
2810 expect(200, rect2
.right
);
2811 /* items are of the same height */
2812 ok(rect2
.top
> 0, "expected positive item height\n");
2813 expect(rect
.bottom
, rect2
.top
);
2814 expect(rect
.bottom
* 2 - rect
.top
, rect2
.bottom
);
2816 rect
.left
= LVIR_BOUNDS
;
2818 rect
.right
= rect
.bottom
= -1;
2819 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, 0, (LPARAM
)&rect
);
2821 expect(300, rect
.left
);
2822 expect(600, rect
.right
);
2824 DestroyWindow(hwnd
);
2826 /* try it for non LVS_REPORT style */
2827 hwnd
= CreateWindowA("SysListView32", "Test", LVS_ICON
, 0, 0, 100, 100, NULL
, NULL
,
2828 GetModuleHandleA(NULL
), 0);
2829 rect
.left
= LVIR_BOUNDS
;
2831 rect
.right
= rect
.bottom
= -10;
2832 r
= SendMessageA(hwnd
, LVM_GETSUBITEMRECT
, -1, (LPARAM
)&rect
);
2834 /* rect is unchanged */
2835 expect(0, rect
.left
);
2836 expect(-10, rect
.right
);
2837 expect(1, rect
.top
);
2838 expect(-10, rect
.bottom
);
2839 DestroyWindow(hwnd
);
2842 /* comparison callback for test_sorting */
2843 static INT WINAPI
test_CallBackCompare(LPARAM first
, LPARAM second
, LPARAM lParam
)
2845 if (first
== second
) return 0;
2846 return (first
> second
? 1 : -1);
2849 static void test_sorting(void)
2855 static CHAR names
[][5] = {"A", "B", "C", "D", "0"};
2858 hwnd
= create_listview_control(LVS_REPORT
);
2859 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2861 /* insert some items */
2862 item
.mask
= LVIF_PARAM
| LVIF_STATE
;
2863 item
.state
= LVIS_SELECTED
;
2867 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
2870 item
.mask
= LVIF_PARAM
;
2874 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
2877 item
.mask
= LVIF_STATE
| LVIF_PARAM
;
2878 item
.state
= LVIS_SELECTED
;
2882 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
2885 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2888 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2891 r
= SendMessageA(hwnd
, LVM_SORTITEMS
, 0, (LPARAM
)test_CallBackCompare
);
2894 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
2896 r
= SendMessageA(hwnd
, LVM_GETSELECTIONMARK
, 0, 0);
2898 r
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_SELECTED
);
2900 r
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 1, LVIS_SELECTED
);
2901 expect(LVIS_SELECTED
, r
);
2902 r
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 2, LVIS_SELECTED
);
2903 expect(LVIS_SELECTED
, r
);
2905 DestroyWindow(hwnd
);
2907 /* switch to LVS_SORTASCENDING when some items added */
2908 hwnd
= create_listview_control(LVS_REPORT
);
2909 ok(hwnd
!= NULL
, "failed to create a listview window\n");
2911 item
.mask
= LVIF_TEXT
;
2914 item
.pszText
= names
[1];
2915 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
2918 item
.mask
= LVIF_TEXT
;
2921 item
.pszText
= names
[2];
2922 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
2925 item
.mask
= LVIF_TEXT
;
2928 item
.pszText
= names
[0];
2929 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
2932 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2933 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTASCENDING
);
2934 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
2935 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
2937 /* no sorting performed when switched to LVS_SORTASCENDING */
2938 item
.mask
= LVIF_TEXT
;
2940 item
.pszText
= buff
;
2941 item
.cchTextMax
= sizeof(buff
);
2942 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
2944 ok(lstrcmpA(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2947 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
2949 ok(lstrcmpA(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2952 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
2954 ok(lstrcmpA(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2956 /* adding new item doesn't resort list */
2957 item
.mask
= LVIF_TEXT
;
2960 item
.pszText
= names
[3];
2961 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
2964 item
.mask
= LVIF_TEXT
;
2966 item
.pszText
= buff
;
2967 item
.cchTextMax
= sizeof(buff
);
2968 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
2970 ok(lstrcmpA(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
2973 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
2975 ok(lstrcmpA(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
2978 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
2980 ok(lstrcmpA(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
2983 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
2985 ok(lstrcmpA(buff
, names
[3]) == 0, "Expected '%s', got '%s'\n", names
[3], buff
);
2987 /* corner case - item should be placed at first position */
2988 item
.mask
= LVIF_TEXT
;
2991 item
.pszText
= names
[4];
2992 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
2996 item
.pszText
= buff
;
2997 item
.cchTextMax
= sizeof(buff
);
2998 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
3000 ok(lstrcmpA(buff
, names
[4]) == 0, "Expected '%s', got '%s'\n", names
[4], buff
);
3003 item
.pszText
= buff
;
3004 item
.cchTextMax
= sizeof(buff
);
3005 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
3007 ok(lstrcmpA(buff
, names
[1]) == 0, "Expected '%s', got '%s'\n", names
[1], buff
);
3010 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
3012 ok(lstrcmpA(buff
, names
[2]) == 0, "Expected '%s', got '%s'\n", names
[2], buff
);
3015 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
3017 ok(lstrcmpA(buff
, names
[0]) == 0, "Expected '%s', got '%s'\n", names
[0], buff
);
3020 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
3022 ok(lstrcmpA(buff
, names
[3]) == 0, "Expected '%s', got '%s'\n", names
[3], buff
);
3024 DestroyWindow(hwnd
);
3027 static void test_ownerdata(void)
3029 static char test_str
[] = "test";
3032 LONG_PTR style
, ret
;
3036 /* it isn't possible to set LVS_OWNERDATA after creation */
3039 win_skip("set LVS_OWNERDATA after creation leads to crash on < 5.80\n");
3043 hwnd
= create_listview_control(LVS_REPORT
);
3044 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3045 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3046 ok(!(style
& LVS_OWNERDATA
) && style
, "LVS_OWNERDATA isn't expected\n");
3048 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3050 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_OWNERDATA
);
3051 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
3052 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
3053 "try to switch to LVS_OWNERDATA seq", FALSE
);
3055 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3056 ok(!(style
& LVS_OWNERDATA
), "LVS_OWNERDATA isn't expected\n");
3057 DestroyWindow(hwnd
);
3060 /* try to set LVS_OWNERDATA after creation just having it */
3061 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3062 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3063 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3064 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
3066 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3068 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_OWNERDATA
);
3069 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
3070 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
3071 "try to switch to LVS_OWNERDATA seq", FALSE
);
3072 DestroyWindow(hwnd
);
3074 /* try to remove LVS_OWNERDATA after creation just having it */
3077 win_skip("remove LVS_OWNERDATA after creation leads to crash on < 5.80\n");
3081 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3082 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3083 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3084 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
3086 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3088 ret
= SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_OWNERDATA
);
3089 ok(ret
== style
, "Expected set GWL_STYLE to succeed\n");
3090 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_ownerdata_switchto_seq
,
3091 "try to switch to LVS_OWNERDATA seq", FALSE
);
3092 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3093 ok(style
& LVS_OWNERDATA
, "LVS_OWNERDATA is expected\n");
3094 DestroyWindow(hwnd
);
3097 /* try select an item */
3098 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3099 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3100 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
3102 res
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
3104 memset(&item
, 0, sizeof(item
));
3105 item
.stateMask
= LVIS_SELECTED
;
3106 item
.state
= LVIS_SELECTED
;
3107 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
3109 res
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
3111 res
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
3113 DestroyWindow(hwnd
);
3115 /* LVM_SETITEM and LVM_SETITEMTEXT is unsupported on LVS_OWNERDATA */
3116 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3117 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3118 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
3120 res
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
3122 memset(&item
, 0, sizeof(item
));
3123 item
.mask
= LVIF_STATE
;
3125 item
.stateMask
= LVIS_SELECTED
;
3126 item
.state
= LVIS_SELECTED
;
3127 res
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
3129 memset(&item
, 0, sizeof(item
));
3130 item
.pszText
= test_str
;
3131 res
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
3133 DestroyWindow(hwnd
);
3135 /* check notifications after focused/selected changed */
3136 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3137 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3138 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 20, 0);
3141 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3143 memset(&item
, 0, sizeof(item
));
3144 item
.stateMask
= LVIS_SELECTED
;
3145 item
.state
= LVIS_SELECTED
;
3146 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
3149 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_select_focus_parent_seq
,
3150 "ownerdata select notification", TRUE
);
3152 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3154 memset(&item
, 0, sizeof(item
));
3155 item
.stateMask
= LVIS_FOCUSED
;
3156 item
.state
= LVIS_FOCUSED
;
3157 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
3160 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_select_focus_parent_seq
,
3161 "ownerdata focus notification", TRUE
);
3163 /* select all, check notifications */
3164 item
.stateMask
= LVIS_SELECTED
;
3166 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3169 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3171 item
.stateMask
= LVIS_SELECTED
;
3172 item
.state
= LVIS_SELECTED
;
3174 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
3175 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3177 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
3178 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
3179 ok(g_nmlistview
.uNewState
== LVIS_SELECTED
, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
3180 ok(g_nmlistview
.uOldState
== 0, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
3181 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
3182 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
3183 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
3185 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
3186 "ownerdata select all notification", FALSE
);
3188 /* select all again, note that all items are selected already */
3189 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3190 item
.stateMask
= LVIS_SELECTED
;
3191 item
.state
= LVIS_SELECTED
;
3193 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
3194 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3196 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
3197 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
3198 ok(g_nmlistview
.uNewState
== LVIS_SELECTED
, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
3199 ok(g_nmlistview
.uOldState
== 0, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
3200 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
3201 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
3202 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
3204 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
3205 "ownerdata select all notification", FALSE
);
3208 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3209 item
.stateMask
= LVIS_SELECTED
;
3212 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
3213 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3215 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
3216 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
3217 ok(g_nmlistview
.uNewState
== 0, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
3218 ok(g_nmlistview
.uOldState
== LVIS_SELECTED
, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
3219 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
3220 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
3221 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
3223 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_deselect_all_parent_seq
,
3224 "ownerdata deselect all notification", TRUE
);
3226 /* nothing selected, deselect all again */
3227 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3228 item
.stateMask
= LVIS_SELECTED
;
3231 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3234 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "ownerdata deselect all notification", FALSE
);
3236 /* select one, then deselect all */
3237 item
.stateMask
= LVIS_SELECTED
;
3238 item
.state
= LVIS_SELECTED
;
3239 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
3241 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3242 item
.stateMask
= LVIS_SELECTED
;
3245 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
3246 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3248 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
3249 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
3250 ok(g_nmlistview
.uNewState
== 0, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
3251 ok(g_nmlistview
.uOldState
== LVIS_SELECTED
, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
3252 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
3253 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
3254 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
3256 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_deselect_all_parent_seq
,
3257 "ownerdata select all notification", TRUE
);
3259 /* remove focused, try to focus all */
3260 item
.stateMask
= LVIS_FOCUSED
;
3261 item
.state
= LVIS_FOCUSED
;
3262 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
3264 item
.stateMask
= LVIS_FOCUSED
;
3266 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3268 item
.stateMask
= LVIS_FOCUSED
;
3269 res
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_FOCUSED
);
3272 /* setting all to focused returns failure value */
3273 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3274 item
.stateMask
= LVIS_FOCUSED
;
3275 item
.state
= LVIS_FOCUSED
;
3277 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3280 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3281 "ownerdata focus all notification", FALSE
);
3283 /* focus single item, remove all */
3284 item
.stateMask
= LVIS_FOCUSED
;
3285 item
.state
= LVIS_FOCUSED
;
3286 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
3288 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3289 item
.stateMask
= LVIS_FOCUSED
;
3292 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
3293 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3295 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
3296 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
3297 ok(g_nmlistview
.uNewState
== 0, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
3298 ok(g_nmlistview
.uOldState
== LVIS_FOCUSED
, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
3299 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
3300 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
3301 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
3303 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_defocus_all_parent_seq
,
3304 "ownerdata remove focus all notification", TRUE
);
3307 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3308 item
.stateMask
= LVIS_CUT
;
3309 item
.state
= LVIS_CUT
;
3311 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
3312 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3314 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
3315 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
3316 ok(g_nmlistview
.uNewState
== LVIS_CUT
, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
3317 ok(g_nmlistview
.uOldState
== 0, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
3318 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
3319 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
3320 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
3322 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
3323 "ownerdata cut all notification", FALSE
);
3325 /* all marked cut, try again */
3326 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3327 item
.stateMask
= LVIS_CUT
;
3328 item
.state
= LVIS_CUT
;
3330 memset(&g_nmlistview
, 0xcc, sizeof(g_nmlistview
));
3331 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, -1, (LPARAM
)&item
);
3333 ok(g_nmlistview
.iItem
== -1, "got item %d\n", g_nmlistview
.iItem
);
3334 ok(g_nmlistview
.iSubItem
== 0, "got subitem %d\n", g_nmlistview
.iSubItem
);
3335 ok(g_nmlistview
.uNewState
== LVIS_CUT
, "got new state 0x%08x\n", g_nmlistview
.uNewState
);
3336 ok(g_nmlistview
.uOldState
== 0, "got old state 0x%08x\n", g_nmlistview
.uOldState
);
3337 ok(g_nmlistview
.uChanged
== LVIF_STATE
, "got changed 0x%08x\n", g_nmlistview
.uChanged
);
3338 ok(g_nmlistview
.ptAction
.x
== 0 && g_nmlistview
.ptAction
.y
== 0, "got wrong ptAction value\n");
3339 ok(g_nmlistview
.lParam
== 0, "got wrong lparam\n");
3341 ok_sequence(sequences
, PARENT_SEQ_INDEX
, ownerdata_setstate_all_parent_seq
,
3342 "ownerdata cut all notification #2", FALSE
);
3344 DestroyWindow(hwnd
);
3346 /* check notifications on LVM_GETITEM */
3347 /* zero callback mask */
3348 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3349 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3350 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
3353 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3355 memset(&item
, 0, sizeof(item
));
3356 item
.stateMask
= LVIS_SELECTED
;
3357 item
.mask
= LVIF_STATE
;
3358 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3361 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3362 "ownerdata getitem selected state 1", FALSE
);
3364 /* non zero callback mask but not we asking for */
3365 res
= SendMessageA(hwnd
, LVM_SETCALLBACKMASK
, LVIS_OVERLAYMASK
, 0);
3368 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3370 memset(&item
, 0, sizeof(item
));
3371 item
.stateMask
= LVIS_SELECTED
;
3372 item
.mask
= LVIF_STATE
;
3373 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3376 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3377 "ownerdata getitem selected state 2", FALSE
);
3379 /* LVIS_OVERLAYMASK callback mask, asking for index */
3380 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3382 memset(&item
, 0, sizeof(item
));
3383 item
.stateMask
= LVIS_OVERLAYMASK
;
3384 item
.mask
= LVIF_STATE
;
3385 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3388 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
3389 "ownerdata getitem selected state 2", FALSE
);
3391 DestroyWindow(hwnd
);
3393 /* LVS_SORTASCENDING/LVS_SORTDESCENDING aren't compatible with LVS_OWNERDATA */
3394 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_SORTASCENDING
| LVS_REPORT
);
3395 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3396 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3397 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
3398 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
3399 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_SORTASCENDING
);
3400 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3401 ok(!(style
& LVS_SORTASCENDING
), "Expected LVS_SORTASCENDING not set\n");
3402 DestroyWindow(hwnd
);
3403 /* apparently it's allowed to switch these style on after creation */
3404 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3405 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3406 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3407 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
3408 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTASCENDING
);
3409 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3410 ok(style
& LVS_SORTASCENDING
, "Expected LVS_SORTASCENDING to be set\n");
3411 DestroyWindow(hwnd
);
3413 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3414 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3415 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3416 ok(style
& LVS_OWNERDATA
, "Expected LVS_OWNERDATA\n");
3417 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SORTDESCENDING
);
3418 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3419 ok(style
& LVS_SORTDESCENDING
, "Expected LVS_SORTDESCENDING to be set\n");
3420 DestroyWindow(hwnd
);
3422 /* The focused item is updated after the invalidation */
3423 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3424 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3425 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 3, 0);
3428 memset(&item
, 0, sizeof(item
));
3429 item
.stateMask
= LVIS_FOCUSED
;
3430 item
.state
= LVIS_FOCUSED
;
3431 res
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
3434 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3435 res
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 0, 0);
3437 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3438 "ownerdata setitemcount", FALSE
);
3440 res
= SendMessageA(hwnd
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
3442 DestroyWindow(hwnd
);
3445 static void test_norecompute(void)
3447 static CHAR testA
[] = "test";
3453 /* self containing control */
3454 hwnd
= create_listview_control(LVS_REPORT
);
3455 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3456 memset(&item
, 0, sizeof(item
));
3457 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
3459 item
.stateMask
= LVIS_SELECTED
;
3460 item
.state
= LVIS_SELECTED
;
3461 item
.pszText
= testA
;
3462 res
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3464 /* retrieve with LVIF_NORECOMPUTE */
3465 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
3467 item
.pszText
= buff
;
3468 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
3469 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3471 ok(lstrcmpA(buff
, testA
) == 0, "Expected (%s), got (%s)\n", testA
, buff
);
3473 item
.mask
= LVIF_TEXT
;
3475 item
.pszText
= LPSTR_TEXTCALLBACKA
;
3476 res
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3479 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
3481 item
.pszText
= buff
;
3482 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
3484 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3485 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3487 ok(item
.pszText
== LPSTR_TEXTCALLBACKA
, "Expected (%p), got (%p)\n",
3488 LPSTR_TEXTCALLBACKA
, (VOID
*)item
.pszText
);
3489 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "retrieve with LVIF_NORECOMPUTE seq", FALSE
);
3491 DestroyWindow(hwnd
);
3494 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3495 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3497 item
.mask
= LVIF_STATE
;
3498 item
.stateMask
= LVIS_SELECTED
;
3499 item
.state
= LVIS_SELECTED
;
3501 res
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3504 item
.mask
= LVIF_TEXT
| LVIF_NORECOMPUTE
;
3506 item
.pszText
= buff
;
3507 item
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
3508 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3509 res
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
3511 ok(item
.pszText
== LPSTR_TEXTCALLBACKA
, "Expected (%p), got (%p)\n",
3512 LPSTR_TEXTCALLBACKA
, (VOID
*)item
.pszText
);
3513 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "retrieve with LVIF_NORECOMPUTE seq 2", FALSE
);
3515 DestroyWindow(hwnd
);
3518 static void test_nosortheader(void)
3523 hwnd
= create_listview_control(LVS_REPORT
);
3524 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3526 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
3527 ok(IsWindow(header
), "header expected\n");
3529 style
= GetWindowLongPtrA(header
, GWL_STYLE
);
3530 ok(style
& HDS_BUTTONS
, "expected header to have HDS_BUTTONS\n");
3532 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3533 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_NOSORTHEADER
);
3534 /* HDS_BUTTONS retained */
3535 style
= GetWindowLongPtrA(header
, GWL_STYLE
);
3536 ok(style
& HDS_BUTTONS
, "expected header to retain HDS_BUTTONS\n");
3538 DestroyWindow(hwnd
);
3540 /* create with LVS_NOSORTHEADER */
3541 hwnd
= create_listview_control(LVS_NOSORTHEADER
| LVS_REPORT
);
3542 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3544 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
3545 ok(IsWindow(header
), "header expected\n");
3547 style
= GetWindowLongPtrA(header
, GWL_STYLE
);
3548 ok(!(style
& HDS_BUTTONS
), "expected header to have no HDS_BUTTONS\n");
3550 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3551 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_NOSORTHEADER
);
3552 /* not changed here */
3553 style
= GetWindowLongPtrA(header
, GWL_STYLE
);
3554 ok(!(style
& HDS_BUTTONS
), "expected header to have no HDS_BUTTONS\n");
3556 DestroyWindow(hwnd
);
3559 static void test_setredraw(void)
3567 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
3568 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3570 /* Passing WM_SETREDRAW to DefWinProc removes WS_VISIBLE.
3571 ListView seems to handle it internally without DefWinProc */
3573 /* default value first */
3574 ret
= SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3577 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3578 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
3579 ret
= SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3581 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
3582 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
3583 ret
= SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3586 /* check update rect after redrawing */
3587 ret
= SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3589 InvalidateRect(hwnd
, NULL
, FALSE
);
3590 RedrawWindow(hwnd
, NULL
, NULL
, RDW_UPDATENOW
);
3591 rect
.right
= rect
.bottom
= 1;
3592 GetUpdateRect(hwnd
, &rect
, FALSE
);
3593 expect(0, rect
.right
);
3594 expect(0, rect
.bottom
);
3597 hdc
= GetWindowDC(hwndparent
);
3598 ret
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
3600 ret
= SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3602 ret
= SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
3604 ret
= SendMessageA(hwnd
, WM_SETREDRAW
, TRUE
, 0);
3606 ReleaseDC(hwndparent
, hdc
);
3608 /* check notification messages to show that repainting is disabled */
3609 ret
= SendMessageA(hwnd
, LVM_SETITEMCOUNT
, 1, 0);
3611 ret
= SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3613 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3615 InvalidateRect(hwnd
, NULL
, TRUE
);
3617 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3618 "redraw after WM_SETREDRAW (FALSE)", FALSE
);
3620 ret
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, CLR_NONE
);
3622 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3623 InvalidateRect(hwnd
, NULL
, TRUE
);
3625 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
3626 "redraw after WM_SETREDRAW (FALSE) with CLR_NONE bkgnd", FALSE
);
3628 /* message isn't forwarded to header */
3629 subclass_header(hwnd
);
3630 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3631 ret
= SendMessageA(hwnd
, WM_SETREDRAW
, FALSE
, 0);
3633 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, setredraw_seq
,
3634 "WM_SETREDRAW: not forwarded to header", FALSE
);
3636 DestroyWindow(hwnd
);
3639 static void test_hittest(void)
3645 static CHAR text
[] = "1234567890ABCDEFGHIJKLMNOPQRST";
3649 HIMAGELIST himl
, himl2
;
3652 hwnd
= create_listview_control(LVS_REPORT
);
3653 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3655 /* LVS_REPORT with a single subitem (2 columns) */
3656 insert_column(hwnd
, 0);
3657 insert_column(hwnd
, 1);
3658 insert_item(hwnd
, 0);
3661 /* the only purpose of that line is to be as long as a half item rect */
3662 item
.pszText
= text
;
3663 r
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
3666 r
= SendMessageA(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
3668 r
= SendMessageA(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(100, 0));
3671 memset(&bounds
, 0, sizeof(bounds
));
3672 bounds
.left
= LVIR_BOUNDS
;
3673 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&bounds
);
3675 ok(bounds
.bottom
- bounds
.top
> 0, "Expected non zero item height\n");
3676 ok(bounds
.right
- bounds
.left
> 0, "Expected non zero item width\n");
3677 r
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, TRUE
, 0);
3679 ok(bounds
.bottom
- bounds
.top
== vert
,
3680 "Vertical spacing inconsistent (%d != %d)\n", bounds
.bottom
- bounds
.top
, vert
);
3681 r
= SendMessageA(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pos
);
3684 /* LVS_EX_FULLROWSELECT not set, no icons attached */
3686 /* outside columns by x position - valid is [0, 199] */
3688 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3689 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TOLEFT
, 0, FALSE
, FALSE
);
3690 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3692 x
= pos
.x
+ 50; /* column half width */
3693 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3694 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMLABEL
, 0, FALSE
, FALSE
);
3695 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3696 x
= pos
.x
+ 150; /* outside column */
3697 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3698 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
);
3699 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3700 y
= (bounds
.bottom
- bounds
.top
) / 2;
3701 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
);
3702 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3703 /* outside possible client rectangle (to right) */
3705 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3706 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
);
3707 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3708 y
= (bounds
.bottom
- bounds
.top
) / 2;
3709 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
);
3710 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3711 /* subitem returned with -1 item too */
3713 y
= bounds
.top
- vert
;
3714 test_lvm_subitemhittest(hwnd
, x
, y
, -1, 1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3715 test_lvm_subitemhittest(hwnd
, x
, y
- vert
+ 1, -1, 1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3716 /* return values appear to underflow with negative indices */
3720 test_lvm_subitemhittest(hwnd
, x
, y
, i
, 1, LVHT_ONITEMLABEL
, TRUE
, FALSE
, TRUE
);
3721 test_lvm_subitemhittest(hwnd
, x
, y
- vert
+ 1, i
, 1, LVHT_ONITEMLABEL
, TRUE
, FALSE
, TRUE
);
3725 /* parent client area is 100x100 by default */
3726 MoveWindow(hwnd
, 0, 0, 300, 100, FALSE
);
3727 x
= pos
.x
+ 150; /* outside column */
3728 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3729 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_NOWHERE
, 0, FALSE
, FALSE
);
3730 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3731 y
= (bounds
.bottom
- bounds
.top
) / 2;
3732 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_NOWHERE
, 0, FALSE
, TRUE
);
3733 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3734 /* the same with LVS_EX_FULLROWSELECT */
3735 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_FULLROWSELECT
);
3736 x
= pos
.x
+ 150; /* outside column */
3737 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3738 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEM
, LVHT_ONITEMLABEL
, FALSE
, FALSE
);
3739 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3740 y
= (bounds
.bottom
- bounds
.top
) / 2;
3741 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3742 MoveWindow(hwnd
, 0, 0, 100, 100, FALSE
);
3743 x
= pos
.x
+ 150; /* outside column */
3744 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3745 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
);
3746 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3747 y
= (bounds
.bottom
- bounds
.top
) / 2;
3748 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
);
3749 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 1, LVHT_ONITEMLABEL
, FALSE
, FALSE
, FALSE
);
3750 /* outside possible client rectangle (to right) */
3752 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3753 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, FALSE
);
3754 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3755 y
= (bounds
.bottom
- bounds
.top
) / 2;
3756 test_lvm_hittest(hwnd
, x
, y
, -1, LVHT_TORIGHT
, 0, FALSE
, TRUE
);
3757 test_lvm_subitemhittest(hwnd
, x
, y
, -1, -1, LVHT_NOWHERE
, FALSE
, FALSE
, FALSE
);
3758 /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
3759 himl
= ImageList_Create(16, 16, 0, 4, 4);
3760 ok(himl
!= NULL
, "failed to create imagelist\n");
3761 hbmp
= CreateBitmap(16, 16, 1, 1, NULL
);
3762 ok(hbmp
!= NULL
, "failed to create bitmap\n");
3763 r
= ImageList_Add(himl
, hbmp
, 0);
3764 ok(r
== 0, "should be zero\n");
3765 hbmp
= CreateBitmap(16, 16, 1, 1, NULL
);
3766 ok(hbmp
!= NULL
, "failed to create bitmap\n");
3767 r
= ImageList_Add(himl
, hbmp
, 0);
3768 ok(r
== 1, "should be one\n");
3770 r
= SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl
);
3773 item
.mask
= LVIF_IMAGE
;
3777 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
3781 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3782 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMSTATEICON
, 0, FALSE
, FALSE
);
3783 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
);
3784 y
= (bounds
.bottom
- bounds
.top
) / 2;
3785 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
);
3787 /* state icons indices are 1 based, check with valid index */
3788 item
.mask
= LVIF_STATE
;
3789 item
.state
= INDEXTOSTATEIMAGEMASK(1);
3790 item
.stateMask
= LVIS_STATEIMAGEMASK
;
3793 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
3797 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3798 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMSTATEICON
, 0, FALSE
, FALSE
);
3799 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
);
3800 y
= (bounds
.bottom
- bounds
.top
) / 2;
3801 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMSTATEICON
, FALSE
, FALSE
, FALSE
);
3803 himl2
= (HIMAGELIST
)SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, 0);
3804 ok(himl2
== himl
, "should return handle\n");
3806 r
= SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl
);
3810 y
= pos
.y
+ (bounds
.bottom
- bounds
.top
) / 2;
3811 test_lvm_hittest(hwnd
, x
, y
, 0, LVHT_ONITEMICON
, 0, FALSE
, FALSE
);
3812 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMICON
, FALSE
, FALSE
, FALSE
);
3813 y
= (bounds
.bottom
- bounds
.top
) / 2;
3814 test_lvm_subitemhittest(hwnd
, x
, y
, 0, 0, LVHT_ONITEMICON
, FALSE
, FALSE
, FALSE
);
3816 DestroyWindow(hwnd
);
3819 static void test_getviewrect(void)
3826 hwnd
= create_listview_control(LVS_REPORT
);
3827 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3830 r
= SendMessageA(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3833 insert_column(hwnd
, 0);
3834 insert_column(hwnd
, 1);
3836 memset(&item
, 0, sizeof(item
));
3839 SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3841 r
= SendMessageA(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
3843 r
= SendMessageA(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(120, 0));
3846 rect
.left
= rect
.right
= rect
.top
= rect
.bottom
= -1;
3847 r
= SendMessageA(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3849 /* left is set to (2e31-1) - XP SP2 */
3850 expect(0, rect
.right
);
3851 expect(0, rect
.top
);
3852 expect(0, rect
.bottom
);
3854 /* switch to LVS_ICON */
3855 SetWindowLongA(hwnd
, GWL_STYLE
, GetWindowLongA(hwnd
, GWL_STYLE
) & ~LVS_REPORT
);
3857 rect
.left
= rect
.right
= rect
.top
= rect
.bottom
= -1;
3858 r
= SendMessageA(hwnd
, LVM_GETVIEWRECT
, 0, (LPARAM
)&rect
);
3860 expect(0, rect
.left
);
3861 expect(0, rect
.top
);
3862 /* precise value differs for 2k, XP and Vista */
3863 ok(rect
.bottom
> 0, "Expected positive bottom value, got %d\n", rect
.bottom
);
3864 ok(rect
.right
> 0, "Expected positive right value, got %d\n", rect
.right
);
3866 DestroyWindow(hwnd
);
3869 static void test_getitemposition(void)
3876 hwnd
= create_listview_control(LVS_REPORT
);
3877 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3878 header
= subclass_header(hwnd
);
3880 /* LVS_REPORT, single item, no columns added */
3881 insert_item(hwnd
, 0);
3883 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3886 r
= SendMessageA(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3888 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getitemposition_seq1
, "get item position 1", FALSE
);
3890 /* LVS_REPORT, single item, single column */
3891 insert_column(hwnd
, 0);
3893 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
3896 r
= SendMessageA(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
3898 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, getitemposition_seq2
, "get item position 2", TRUE
);
3900 memset(&rect
, 0, sizeof(rect
));
3901 SendMessageA(header
, HDM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3904 /* offset by header height */
3905 expect(rect
.bottom
- rect
.top
, pt
.y
);
3907 DestroyWindow(hwnd
);
3910 static void test_columnscreation(void)
3915 hwnd
= create_listview_control(LVS_REPORT
);
3916 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3918 insert_item(hwnd
, 0);
3920 /* headers columns aren't created automatically */
3921 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
3922 ok(IsWindow(header
), "Expected header handle\n");
3923 r
= SendMessageA(header
, HDM_GETITEMCOUNT
, 0, 0);
3926 DestroyWindow(hwnd
);
3929 static void test_getitemrect(void)
3932 HIMAGELIST himl
, himl_ret
;
3941 /* rectangle isn't empty for empty text items */
3942 hwnd
= create_listview_control(LVS_LIST
);
3943 memset(&item
, 0, sizeof(item
));
3946 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3948 rect
.left
= LVIR_LABEL
;
3949 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3951 expect(0, rect
.left
);
3952 expect(0, rect
.top
);
3953 /* estimate it as width / height ratio */
3955 ok((rect
.right
/ rect
.bottom
) >= 5, "got right %d, bottom %d\n", rect
.right
, rect
.bottom
);
3956 DestroyWindow(hwnd
);
3958 hwnd
= create_listview_control(LVS_REPORT
);
3959 ok(hwnd
!= NULL
, "failed to create a listview window\n");
3962 memset(&item
, 0, sizeof(item
));
3965 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
3968 rect
.left
= LVIR_BOUNDS
;
3969 rect
.right
= rect
.top
= rect
.bottom
= -1;
3970 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3973 /* zero width rectangle with no padding */
3974 expect(0, rect
.left
);
3975 expect(0, rect
.right
);
3977 insert_column(hwnd
, 0);
3978 insert_column(hwnd
, 1);
3980 col
.mask
= LVCF_WIDTH
;
3982 r
= SendMessageA(hwnd
, LVM_SETCOLUMNA
, 0, (LPARAM
)&col
);
3985 col
.mask
= LVCF_WIDTH
;
3987 r
= SendMessageA(hwnd
, LVM_SETCOLUMNA
, 1, (LPARAM
)&col
);
3990 rect
.left
= LVIR_BOUNDS
;
3991 rect
.right
= rect
.top
= rect
.bottom
= -1;
3992 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
3995 /* still no left padding */
3996 expect(0, rect
.left
);
3997 expect(150, rect
.right
);
3999 rect
.left
= LVIR_SELECTBOUNDS
;
4000 rect
.right
= rect
.top
= rect
.bottom
= -1;
4001 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4004 expect(2, rect
.left
);
4006 rect
.left
= LVIR_LABEL
;
4007 rect
.right
= rect
.top
= rect
.bottom
= -1;
4008 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4010 /* padding, column width */
4011 expect(2, rect
.left
);
4012 expect(50, rect
.right
);
4014 /* no icons attached */
4015 rect
.left
= LVIR_ICON
;
4016 rect
.right
= rect
.top
= rect
.bottom
= -1;
4017 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4020 expect(2, rect
.left
);
4021 expect(2, rect
.right
);
4024 order
[0] = 1; order
[1] = 0;
4025 r
= SendMessageA(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
4028 r
= SendMessageA(hwnd
, LVM_GETITEMPOSITION
, 0, (LPARAM
)&pt
);
4030 /* 1 indexed column width + padding */
4032 /* rect is at zero too */
4033 rect
.left
= LVIR_BOUNDS
;
4034 rect
.right
= rect
.top
= rect
.bottom
= -1;
4035 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4037 expect(0, rect
.left
);
4038 /* just width sum */
4039 expect(150, rect
.right
);
4041 rect
.left
= LVIR_SELECTBOUNDS
;
4042 rect
.right
= rect
.top
= rect
.bottom
= -1;
4043 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4045 /* column width + padding */
4046 expect(102, rect
.left
);
4048 /* back to initial order */
4049 order
[0] = 0; order
[1] = 1;
4050 r
= SendMessageA(hwnd
, LVM_SETCOLUMNORDERARRAY
, 2, (LPARAM
)&order
);
4054 himl
= ImageList_Create(16, 16, 0, 2, 2);
4055 ok(himl
!= NULL
, "failed to create imagelist\n");
4056 hbm
= CreateBitmap(16, 16, 1, 1, NULL
);
4057 ok(hbm
!= NULL
, "failed to create bitmap\n");
4058 r
= ImageList_Add(himl
, hbm
, 0);
4060 hbm
= CreateBitmap(16, 16, 1, 1, NULL
);
4061 ok(hbm
!= NULL
, "failed to create bitmap\n");
4062 r
= ImageList_Add(himl
, hbm
, 0);
4065 r
= SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl
);
4068 item
.mask
= LVIF_STATE
;
4069 item
.state
= INDEXTOSTATEIMAGEMASK(1);
4070 item
.stateMask
= LVIS_STATEIMAGEMASK
;
4073 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
4077 rect
.left
= LVIR_ICON
;
4078 rect
.right
= rect
.top
= rect
.bottom
= -1;
4079 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4081 /* padding + stateicon width */
4082 expect(18, rect
.left
);
4083 expect(18, rect
.right
);
4085 rect
.left
= LVIR_LABEL
;
4086 rect
.right
= rect
.top
= rect
.bottom
= -1;
4087 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4089 /* padding + stateicon width -> column width */
4090 expect(18, rect
.left
);
4091 expect(50, rect
.right
);
4093 himl_ret
= (HIMAGELIST
)SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, 0);
4094 ok(himl_ret
== himl
, "got %p, expected %p\n", himl_ret
, himl
);
4096 r
= SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl
);
4099 item
.mask
= LVIF_STATE
| LVIF_IMAGE
;
4102 item
.stateMask
= ~0;
4105 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
4109 rect
.left
= LVIR_ICON
;
4110 rect
.right
= rect
.top
= rect
.bottom
= -1;
4111 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4113 /* padding, icon width */
4114 expect(2, rect
.left
);
4115 expect(18, rect
.right
);
4117 rect
.left
= LVIR_LABEL
;
4118 rect
.right
= rect
.top
= rect
.bottom
= -1;
4119 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4121 /* padding + icon width -> column width */
4122 expect(18, rect
.left
);
4123 expect(50, rect
.right
);
4126 rect
.left
= LVIR_SELECTBOUNDS
;
4127 rect
.right
= rect
.top
= rect
.bottom
= -1;
4128 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4130 /* padding, column width */
4131 expect(2, rect
.left
);
4132 expect(50, rect
.right
);
4134 /* try with indentation */
4135 item
.mask
= LVIF_INDENT
;
4139 r
= SendMessageA(hwnd
, LVM_SETITEMA
, 0, (LPARAM
)&item
);
4143 rect
.left
= LVIR_BOUNDS
;
4144 rect
.right
= rect
.top
= rect
.bottom
= -1;
4145 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4147 /* padding + 1 icon width, column width */
4148 expect(0, rect
.left
);
4149 expect(150, rect
.right
);
4152 rect
.left
= LVIR_SELECTBOUNDS
;
4153 rect
.right
= rect
.top
= rect
.bottom
= -1;
4154 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4156 /* padding + 1 icon width, column width */
4157 expect(2 + 16, rect
.left
);
4158 expect(50, rect
.right
);
4161 rect
.left
= LVIR_LABEL
;
4162 rect
.right
= rect
.top
= rect
.bottom
= -1;
4163 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4165 /* padding + 2 icon widths, column width */
4166 expect(2 + 16*2, rect
.left
);
4167 expect(50, rect
.right
);
4170 rect
.left
= LVIR_ICON
;
4171 rect
.right
= rect
.top
= rect
.bottom
= -1;
4172 r
= SendMessageA(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
)&rect
);
4174 /* padding + 1 icon width indentation, icon width */
4175 expect(2 + 16, rect
.left
);
4176 expect(34, rect
.right
);
4178 DestroyWindow(hwnd
);
4181 static void test_editbox(void)
4183 static CHAR testitemA
[] = "testitem";
4184 static CHAR testitem1A
[] = "testitem_quitelongname";
4185 static CHAR testitem2A
[] = "testITEM_quitelongname";
4186 static CHAR buffer
[25];
4187 HWND hwnd
, hwndedit
, hwndedit2
, header
;
4191 hwnd
= create_listview_control(LVS_EDITLABELS
| LVS_REPORT
);
4192 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4194 insert_column(hwnd
, 0);
4196 memset(&item
, 0, sizeof(item
));
4197 item
.mask
= LVIF_TEXT
;
4198 item
.pszText
= testitemA
;
4201 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
4204 /* test notifications without edit created */
4205 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4206 r
= SendMessageA(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_SETFOCUS
), (LPARAM
)0xdeadbeef);
4208 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
4209 "edit box WM_COMMAND (EN_SETFOCUS), no edit created", FALSE
);
4210 /* same thing but with valid window */
4211 hwndedit
= CreateWindowA("Edit", "Test edit", WS_VISIBLE
| WS_CHILD
, 0, 0, 20,
4212 10, hwnd
, (HMENU
)1, (HINSTANCE
)GetWindowLongPtrA(hwnd
, GWLP_HINSTANCE
), 0);
4213 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4214 r
= SendMessageA(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_SETFOCUS
), (LPARAM
)hwndedit
);
4216 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
4217 "edit box WM_COMMAND (EN_SETFOCUS), no edit created #2", FALSE
);
4218 DestroyWindow(hwndedit
);
4220 /* setting focus is necessary */
4222 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4223 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4225 /* test children Z-order after Edit box created */
4226 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
4227 ok(IsWindow(header
), "Expected header to be created\n");
4228 ok(GetTopWindow(hwnd
) == header
, "Expected header to be on top\n");
4229 ok(GetNextWindow(header
, GW_HWNDNEXT
) == hwndedit
, "got %p\n", GetNextWindow(header
, GW_HWNDNEXT
));
4231 /* modify initial string */
4232 r
= SendMessageA(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem1A
);
4235 /* edit window is resized and repositioned,
4236 check again for Z-order - it should be preserved */
4237 ok(GetTopWindow(hwnd
) == header
, "Expected header to be on top\n");
4238 ok(GetNextWindow(header
, GW_HWNDNEXT
) == hwndedit
, "got %p\n", GetNextWindow(header
, GW_HWNDNEXT
));
4240 /* return focus to listview */
4243 memset(&item
, 0, sizeof(item
));
4244 item
.mask
= LVIF_TEXT
;
4245 item
.pszText
= buffer
;
4246 item
.cchTextMax
= sizeof(buffer
);
4249 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
4252 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
4254 /* send LVM_EDITLABEL on already created edit */
4256 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4257 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4258 /* focus will be set to edit */
4259 ok(GetFocus() == hwndedit
, "Expected Edit window to be focused\n");
4260 hwndedit2
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4261 ok(IsWindow(hwndedit2
), "Expected Edit window to be created\n");
4263 /* creating label disabled when control isn't focused */
4265 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4266 todo_wine
ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
4268 /* check EN_KILLFOCUS handling */
4269 memset(&item
, 0, sizeof(item
));
4270 item
.pszText
= testitemA
;
4273 r
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
4277 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4278 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4279 /* modify edit and notify control that it lost focus */
4280 r
= SendMessageA(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem1A
);
4282 g_editbox_disp_info
.item
.pszText
= NULL
;
4283 r
= SendMessageA(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
4285 ok(g_editbox_disp_info
.item
.pszText
!= NULL
, "expected notification with not null text\n");
4287 memset(&item
, 0, sizeof(item
));
4288 item
.pszText
= buffer
;
4289 item
.cchTextMax
= sizeof(buffer
);
4292 r
= SendMessageA(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
4293 expect(lstrlenA(item
.pszText
), r
);
4294 ok(strcmp(buffer
, testitem1A
) == 0, "Expected item text to change\n");
4295 ok(!IsWindow(hwndedit
), "Expected Edit window to be freed\n");
4297 /* change item name to differ in casing only */
4299 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4300 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4301 /* modify edit and notify control that it lost focus */
4302 r
= SendMessageA(hwndedit
, WM_SETTEXT
, 0, (LPARAM
)testitem2A
);
4304 g_editbox_disp_info
.item
.pszText
= NULL
;
4305 r
= SendMessageA(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
4307 ok(g_editbox_disp_info
.item
.pszText
!= NULL
, "got %p\n", g_editbox_disp_info
.item
.pszText
);
4309 memset(&item
, 0, sizeof(item
));
4310 item
.pszText
= buffer
;
4311 item
.cchTextMax
= sizeof(buffer
);
4314 r
= SendMessageA(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
4315 expect(lstrlenA(item
.pszText
), r
);
4316 ok(strcmp(buffer
, testitem2A
) == 0, "got %s, expected %s\n", buffer
, testitem2A
);
4317 ok(!IsWindow(hwndedit
), "Expected Edit window to be freed\n");
4319 /* end edit without saving */
4321 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4322 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4323 r
= SendMessageA(hwndedit
, WM_KEYDOWN
, VK_ESCAPE
, 0);
4325 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
4326 "edit box - end edit, no change, escape", TRUE
);
4327 /* end edit with saving */
4329 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4330 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4331 r
= SendMessageA(hwndedit
, WM_KEYDOWN
, VK_RETURN
, 0);
4333 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
4334 "edit box - end edit, no change, return", TRUE
);
4336 memset(&item
, 0, sizeof(item
));
4337 item
.pszText
= buffer
;
4338 item
.cchTextMax
= sizeof(buffer
);
4341 r
= SendMessageA(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
4342 expect(lstrlenA(item
.pszText
), r
);
4343 ok(strcmp(buffer
, testitem2A
) == 0, "Expected item text to change\n");
4345 /* LVM_EDITLABEL with -1 destroys current edit */
4346 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_GETEDITCONTROL
, 0, 0);
4347 ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
4348 /* no edit present */
4349 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, -1, 0);
4350 ok(hwndedit
== NULL
, "Expected Edit window not to be created\n");
4351 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4352 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4354 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
4355 hwndedit2
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, -1, 0);
4356 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
4357 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
4358 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
4359 /* check another negative value */
4360 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4361 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4362 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
4363 hwndedit2
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, -2, 0);
4364 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
4365 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
4366 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
4367 /* and value greater than max item index */
4368 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4369 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4370 ok(GetFocus() == hwndedit
, "Expected Edit to be focused\n");
4371 r
= SendMessageA(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
4372 hwndedit2
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, r
, 0);
4373 ok(hwndedit2
== NULL
, "Expected Edit window not to be created\n");
4374 ok(!IsWindow(hwndedit
), "Expected Edit window to be destroyed\n");
4375 ok(GetFocus() == hwnd
, "Expected List to be focused\n");
4377 /* messaging tests */
4379 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4381 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4382 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4383 /* testing only sizing messages */
4384 ok_sequence(sequences
, EDITBOX_SEQ_INDEX
, editbox_create_pos
,
4385 "edit box create - sizing", FALSE
);
4387 /* WM_COMMAND with EN_KILLFOCUS isn't forwarded to parent */
4389 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4390 ok(IsWindow(hwndedit
), "Expected Edit window to be created\n");
4391 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4392 r
= SendMessageA(hwnd
, WM_COMMAND
, MAKEWPARAM(0, EN_KILLFOCUS
), (LPARAM
)hwndedit
);
4394 ok_sequence(sequences
, PARENT_SEQ_INDEX
, edit_end_nochange
,
4395 "edit box WM_COMMAND (EN_KILLFOCUS)", TRUE
);
4397 DestroyWindow(hwnd
);
4400 static void test_notifyformat(void)
4405 hwnd
= create_listview_control(LVS_REPORT
);
4406 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4408 /* CCM_GETUNICODEFORMAT == LVM_GETUNICODEFORMAT,
4409 CCM_SETUNICODEFORMAT == LVM_SETUNICODEFORMAT */
4410 r
= SendMessageA(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4412 SendMessageA(hwnd
, WM_NOTIFYFORMAT
, 0, NF_QUERY
);
4414 r
= SendMessageA(hwnd
, LVM_SETUNICODEFORMAT
, 1, 0);
4416 r
= SendMessageA(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4419 r
= SendMessageA(hwnd
, LVM_SETUNICODEFORMAT
, 0, 0);
4421 r
= SendMessageA(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4426 win_skip("LVM_GETUNICODEFORMAT is unsupported\n");
4427 DestroyWindow(hwnd
);
4431 DestroyWindow(hwnd
);
4433 /* test failure in parent WM_NOTIFYFORMAT */
4435 hwnd
= create_listview_control(LVS_REPORT
);
4436 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4437 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
4438 ok(IsWindow(header
), "expected header to be created\n");
4439 r
= SendMessageA(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4441 r
= SendMessageA(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4442 ok( r
== 1, "Expected 1, got %d\n", r
);
4443 r
= SendMessageA(hwnd
, WM_NOTIFYFORMAT
, 0, NF_QUERY
);
4444 ok(r
!= 0, "Expected valid format\n");
4446 notifyFormat
= NFR_UNICODE
;
4447 r
= SendMessageA(hwnd
, WM_NOTIFYFORMAT
, 0, NF_REQUERY
);
4448 expect(NFR_UNICODE
, r
);
4449 r
= SendMessageA(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4451 r
= SendMessageA(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4452 ok( r
== 1, "Expected 1, got %d\n", r
);
4454 notifyFormat
= NFR_ANSI
;
4455 r
= SendMessageA(hwnd
, WM_NOTIFYFORMAT
, 0, NF_REQUERY
);
4456 expect(NFR_ANSI
, r
);
4457 r
= SendMessageA(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4459 r
= SendMessageA(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4460 ok( r
== 1, "Expected 1, got %d\n", r
);
4462 DestroyWindow(hwnd
);
4464 hwndparentW
= create_parent_window(TRUE
);
4465 ok(IsWindow(hwndparentW
), "Unicode parent creation failed\n");
4466 if (!IsWindow(hwndparentW
)) return;
4469 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
4470 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4471 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
4472 ok(IsWindow(header
), "expected header to be created\n");
4473 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4475 r
= SendMessageA(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4477 DestroyWindow(hwnd
);
4478 /* receiving error code defaulting to ansi */
4480 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
4481 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4482 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
4483 ok(IsWindow(header
), "expected header to be created\n");
4484 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4486 r
= SendMessageA(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4488 DestroyWindow(hwnd
);
4489 /* receiving ansi code from unicode window, use it */
4490 notifyFormat
= NFR_ANSI
;
4491 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparentW
);
4492 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4493 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
4494 ok(IsWindow(header
), "expected header to be created\n");
4495 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4497 r
= SendMessageA(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4499 DestroyWindow(hwnd
);
4500 /* unicode listview with ansi parent window */
4502 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparent
);
4503 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4504 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
4505 ok(IsWindow(header
), "expected header to be created\n");
4506 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4508 r
= SendMessageA(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4510 DestroyWindow(hwnd
);
4511 /* unicode listview with ansi parent window, return error code */
4513 hwnd
= create_listview_controlW(LVS_REPORT
, hwndparent
);
4514 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4515 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
4516 ok(IsWindow(header
), "expected header to be created\n");
4517 r
= SendMessageW(hwnd
, LVM_GETUNICODEFORMAT
, 0, 0);
4519 r
= SendMessageA(header
, HDM_GETUNICODEFORMAT
, 0, 0);
4521 DestroyWindow(hwnd
);
4523 DestroyWindow(hwndparentW
);
4526 static void test_indentation(void)
4532 hwnd
= create_listview_control(LVS_REPORT
);
4533 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4535 memset(&item
, 0, sizeof(item
));
4536 item
.mask
= LVIF_INDENT
;
4538 item
.iIndent
= I_INDENTCALLBACK
;
4539 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
4542 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4545 item
.mask
= LVIF_INDENT
;
4546 r
= SendMessageA(hwnd
, LVM_GETITEMA
, 0, (LPARAM
)&item
);
4549 ok_sequence(sequences
, PARENT_SEQ_INDEX
, single_getdispinfo_parent_seq
,
4550 "get indent dispinfo", FALSE
);
4552 DestroyWindow(hwnd
);
4555 static INT CALLBACK
DummyCompareEx(LPARAM first
, LPARAM second
, LPARAM param
)
4560 static BOOL
is_below_comctl_5(void)
4565 hwnd
= create_listview_control(LVS_REPORT
);
4566 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4567 insert_item(hwnd
, 0);
4569 ret
= SendMessageA(hwnd
, LVM_SORTITEMSEX
, 0, (LPARAM
)&DummyCompareEx
);
4571 DestroyWindow(hwnd
);
4576 static void test_get_set_view(void)
4582 /* test style->view mapping */
4583 hwnd
= create_listview_control(LVS_REPORT
);
4584 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4586 ret
= SendMessageA(hwnd
, LVM_GETVIEW
, 0, 0);
4587 expect(LV_VIEW_DETAILS
, ret
);
4589 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
4591 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
& ~LVS_REPORT
);
4592 ret
= SendMessageA(hwnd
, LVM_GETVIEW
, 0, 0);
4593 expect(LV_VIEW_ICON
, ret
);
4595 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
4596 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SMALLICON
);
4597 ret
= SendMessageA(hwnd
, LVM_GETVIEW
, 0, 0);
4598 expect(LV_VIEW_SMALLICON
, ret
);
4600 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
4601 SetWindowLongPtrA(hwnd
, GWL_STYLE
, (style
& ~LVS_SMALLICON
) | LVS_LIST
);
4602 ret
= SendMessageA(hwnd
, LVM_GETVIEW
, 0, 0);
4603 expect(LV_VIEW_LIST
, ret
);
4605 /* switching view doesn't touch window style */
4606 ret
= SendMessageA(hwnd
, LVM_SETVIEW
, LV_VIEW_DETAILS
, 0);
4608 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
4609 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
4610 ret
= SendMessageA(hwnd
, LVM_SETVIEW
, LV_VIEW_ICON
, 0);
4612 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
4613 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
4614 ret
= SendMessageA(hwnd
, LVM_SETVIEW
, LV_VIEW_SMALLICON
, 0);
4616 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
4617 ok(style
& LVS_LIST
, "Expected style to be preserved\n");
4619 /* now change window style to see if view is remapped */
4620 style
= GetWindowLongPtrA(hwnd
, GWL_STYLE
);
4621 SetWindowLongPtrA(hwnd
, GWL_STYLE
, style
| LVS_SHOWSELALWAYS
);
4622 ret
= SendMessageA(hwnd
, LVM_GETVIEW
, 0, 0);
4623 expect(LV_VIEW_SMALLICON
, ret
);
4625 DestroyWindow(hwnd
);
4628 static void test_canceleditlabel(void)
4630 HWND hwnd
, hwndedit
;
4634 static CHAR test
[] = "test";
4635 static const CHAR test1
[] = "test1";
4637 hwnd
= create_listview_control(LVS_EDITLABELS
| LVS_REPORT
);
4638 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4640 insert_item(hwnd
, 0);
4642 /* try without edit created */
4643 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4644 ret
= SendMessageA(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
4646 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
4647 "cancel edit label without edit", FALSE
);
4649 /* cancel without data change */
4651 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4652 ok(IsWindow(hwndedit
), "Expected edit control to be created\n");
4653 ret
= SendMessageA(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
4655 ok(!IsWindow(hwndedit
), "Expected edit control to be destroyed\n");
4657 /* cancel after data change */
4658 memset(&itema
, 0, sizeof(itema
));
4659 itema
.pszText
= test
;
4660 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&itema
);
4663 hwndedit
= (HWND
)SendMessageA(hwnd
, LVM_EDITLABELA
, 0, 0);
4664 ok(IsWindow(hwndedit
), "Expected edit control to be created\n");
4665 ret
= SetWindowTextA(hwndedit
, test1
);
4667 ret
= SendMessageA(hwnd
, LVM_CANCELEDITLABEL
, 0, 0);
4669 ok(!IsWindow(hwndedit
), "Expected edit control to be destroyed\n");
4670 memset(&itema
, 0, sizeof(itema
));
4671 itema
.pszText
= buff
;
4672 itema
.cchTextMax
= sizeof(buff
)/sizeof(CHAR
);
4673 ret
= SendMessageA(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&itema
);
4675 ok(strcmp(buff
, test1
) == 0, "Expected label text not to change\n");
4677 DestroyWindow(hwnd
);
4680 static void test_mapidindex(void)
4685 /* LVM_MAPINDEXTOID unsupported with LVS_OWNERDATA */
4686 hwnd
= create_listview_control(LVS_OWNERDATA
| LVS_REPORT
);
4687 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4688 insert_item(hwnd
, 0);
4689 ret
= SendMessageA(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
4691 DestroyWindow(hwnd
);
4693 hwnd
= create_listview_control(LVS_REPORT
);
4694 ok(hwnd
!= NULL
, "failed to create a listview window\n");
4696 /* LVM_MAPINDEXTOID with invalid index */
4697 ret
= SendMessageA(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
4700 insert_item(hwnd
, 0);
4701 insert_item(hwnd
, 1);
4703 ret
= SendMessageA(hwnd
, LVM_MAPINDEXTOID
, -1, 0);
4705 ret
= SendMessageA(hwnd
, LVM_MAPINDEXTOID
, 2, 0);
4708 ret
= SendMessageA(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
4710 ret
= SendMessageA(hwnd
, LVM_MAPINDEXTOID
, 1, 0);
4712 /* remove 0 indexed item, id retained */
4713 SendMessageA(hwnd
, LVM_DELETEITEM
, 0, 0);
4714 ret
= SendMessageA(hwnd
, LVM_MAPINDEXTOID
, 0, 0);
4716 /* new id starts from previous value */
4717 insert_item(hwnd
, 1);
4718 ret
= SendMessageA(hwnd
, LVM_MAPINDEXTOID
, 1, 0);
4721 /* get index by id */
4722 ret
= SendMessageA(hwnd
, LVM_MAPIDTOINDEX
, -1, 0);
4724 ret
= SendMessageA(hwnd
, LVM_MAPIDTOINDEX
, 0, 0);
4726 ret
= SendMessageA(hwnd
, LVM_MAPIDTOINDEX
, 1, 0);
4728 ret
= SendMessageA(hwnd
, LVM_MAPIDTOINDEX
, 2, 0);
4731 DestroyWindow(hwnd
);
4734 static void test_getitemspacing(void)
4739 HIMAGELIST himl40
, himl80
;
4741 cx
= GetSystemMetrics(SM_CXICONSPACING
) - GetSystemMetrics(SM_CXICON
);
4742 cy
= GetSystemMetrics(SM_CYICONSPACING
) - GetSystemMetrics(SM_CYICON
);
4745 hwnd
= create_listview_control(LVS_ICON
);
4746 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4747 expect(cx
, LOWORD(ret
));
4748 expect(cy
, HIWORD(ret
));
4750 /* now try with icons */
4751 himl40
= ImageList_Create(40, 40, 0, 4, 4);
4752 ok(himl40
!= NULL
, "failed to create imagelist\n");
4753 himl80
= ImageList_Create(80, 80, 0, 4, 4);
4754 ok(himl80
!= NULL
, "failed to create imagelist\n");
4755 ret
= SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, (LPARAM
)himl40
);
4758 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4759 /* spacing + icon size returned */
4760 expect(cx
+ 40, LOWORD(ret
));
4761 expect(cy
+ 40, HIWORD(ret
));
4762 /* try changing icon size */
4763 SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, (LPARAM
)himl80
);
4765 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4766 /* spacing + icon size returned */
4767 expect(cx
+ 80, LOWORD(ret
));
4768 expect(cy
+ 80, HIWORD(ret
));
4770 /* set own icon spacing */
4771 ret
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(100, 100));
4772 expect(cx
+ 80, LOWORD(ret
));
4773 expect(cy
+ 80, HIWORD(ret
));
4775 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4776 /* set size returned */
4777 expect(100, LOWORD(ret
));
4778 expect(100, HIWORD(ret
));
4780 /* now change image list - icon spacing should be unaffected */
4781 SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, (LPARAM
)himl40
);
4783 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4784 /* set size returned */
4785 expect(100, LOWORD(ret
));
4786 expect(100, HIWORD(ret
));
4788 /* spacing = 0 - keep previous value */
4789 ret
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(0, -1));
4790 expect(100, LOWORD(ret
));
4791 expect(100, HIWORD(ret
));
4793 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4794 expect(100, LOWORD(ret
));
4796 expect(0xFFFF, HIWORD(ret
));
4798 if (sizeof(void*) == 8)
4800 /* NOTE: -1 is not treated the same as (DWORD)-1 by 64bit listview */
4801 ret
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, (DWORD
)-1);
4802 expect(100, LOWORD(ret
));
4803 expect(0xFFFF, HIWORD(ret
));
4805 ret
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, -1);
4806 expect(0xFFFF, LOWORD(ret
));
4807 expect(0xFFFF, HIWORD(ret
));
4811 ret
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, -1);
4812 expect(100, LOWORD(ret
));
4813 expect(0xFFFF, HIWORD(ret
));
4815 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4816 /* spacing + icon size returned */
4817 expect(cx
+ 40, LOWORD(ret
));
4818 expect(cy
+ 40, HIWORD(ret
));
4820 SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, 0);
4821 ImageList_Destroy(himl80
);
4822 DestroyWindow(hwnd
);
4824 hwnd
= create_listview_control(LVS_SMALLICON
);
4825 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4826 expect(cx
, LOWORD(ret
));
4827 expect(cy
, HIWORD(ret
));
4829 /* spacing does not depend on selected view type */
4830 ret
= SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, (LPARAM
)himl40
);
4833 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4834 /* spacing + icon size returned */
4835 expect(cx
+ 40, LOWORD(ret
));
4836 expect(cy
+ 40, HIWORD(ret
));
4838 SendMessageA(hwnd
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, 0);
4839 ImageList_Destroy(himl40
);
4840 DestroyWindow(hwnd
);
4842 hwnd
= create_listview_control(LVS_REPORT
);
4843 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4844 expect(cx
, LOWORD(ret
));
4845 expect(cy
, HIWORD(ret
));
4847 DestroyWindow(hwnd
);
4849 hwnd
= create_listview_control(LVS_LIST
);
4850 ret
= SendMessageA(hwnd
, LVM_GETITEMSPACING
, FALSE
, 0);
4851 expect(cx
, LOWORD(ret
));
4852 expect(cy
, HIWORD(ret
));
4854 DestroyWindow(hwnd
);
4857 static INT
get_current_font_height(HWND listview
)
4864 hwnd
= (HWND
)SendMessageA(listview
, LVM_GETHEADER
, 0, 0);
4868 hfont
= (HFONT
)SendMessageA(hwnd
, WM_GETFONT
, 0, 0);
4871 GetTextMetricsA(hdc
, &tm
);
4872 ReleaseDC(hwnd
, hdc
);
4878 oldfont
= SelectObject(hdc
, hfont
);
4879 GetTextMetricsA(hdc
, &tm
);
4880 SelectObject(hdc
, oldfont
);
4887 static void test_getcolumnwidth(void)
4896 /* default column width */
4897 hwnd
= create_listview_control(LVS_ICON
);
4898 ret
= SendMessageA(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
4900 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4901 SetWindowLongA(hwnd
, GWL_STYLE
, style
| LVS_LIST
);
4902 ret
= SendMessageA(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
4903 todo_wine
expect(8, ret
);
4904 style
= GetWindowLongA(hwnd
, GWL_STYLE
) & ~LVS_LIST
;
4905 SetWindowLongA(hwnd
, GWL_STYLE
, style
| LVS_REPORT
);
4907 ret
= SendMessageA(hwnd
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
4909 ret
= SendMessageA(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
4911 DestroyWindow(hwnd
);
4913 /* default column width with item added */
4914 hwnd
= create_listview_control(LVS_LIST
);
4915 memset(&itema
, 0, sizeof(itema
));
4916 SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&itema
);
4917 ret
= SendMessageA(hwnd
, LVM_GETCOLUMNWIDTH
, 0, 0);
4918 height
= get_current_font_height(hwnd
);
4919 ok((ret
/ height
) >= 6, "got width %d, height %d\n", ret
, height
);
4920 DestroyWindow(hwnd
);
4923 static void test_scrollnotify(void)
4928 hwnd
= create_listview_control(LVS_REPORT
);
4930 insert_column(hwnd
, 0);
4931 insert_column(hwnd
, 1);
4932 insert_item(hwnd
, 0);
4934 /* make it scrollable - resize */
4935 ret
= SendMessageA(hwnd
, LVM_SETCOLUMNWIDTH
, 0, MAKELPARAM(100, 0));
4937 ret
= SendMessageA(hwnd
, LVM_SETCOLUMNWIDTH
, 1, MAKELPARAM(100, 0));
4940 /* try with dummy call */
4941 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4942 ret
= SendMessageA(hwnd
, LVM_SCROLL
, 0, 0);
4944 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4945 "scroll notify 1", TRUE
);
4947 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4948 ret
= SendMessageA(hwnd
, LVM_SCROLL
, 1, 0);
4950 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4951 "scroll notify 2", TRUE
);
4953 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4954 ret
= SendMessageA(hwnd
, LVM_SCROLL
, 1, 1);
4956 ok_sequence(sequences
, PARENT_SEQ_INDEX
, scroll_parent_seq
,
4957 "scroll notify 3", TRUE
);
4959 DestroyWindow(hwnd
);
4962 static void test_LVS_EX_TRANSPARENTBKGND(void)
4968 hwnd
= create_listview_control(LVS_REPORT
);
4970 ret
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, RGB(0, 0, 0));
4973 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_TRANSPARENTBKGND
,
4974 LVS_EX_TRANSPARENTBKGND
);
4976 ret
= SendMessageA(hwnd
, LVM_GETBKCOLOR
, 0, 0);
4977 if (ret
!= CLR_NONE
)
4979 win_skip("LVS_EX_TRANSPARENTBKGND unsupported\n");
4980 DestroyWindow(hwnd
);
4984 /* try to set some back color and check this style bit */
4985 ret
= SendMessageA(hwnd
, LVM_SETBKCOLOR
, 0, RGB(0, 0, 0));
4987 ret
= SendMessageA(hwnd
, LVM_GETEXTENDEDLISTVIEWSTYLE
, 0, 0);
4988 ok(!(ret
& LVS_EX_TRANSPARENTBKGND
), "Expected LVS_EX_TRANSPARENTBKGND to unset\n");
4990 /* now test what this style actually does */
4991 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_TRANSPARENTBKGND
,
4992 LVS_EX_TRANSPARENTBKGND
);
4994 hdc
= GetWindowDC(hwndparent
);
4996 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
4997 SendMessageA(hwnd
, WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
4998 ok_sequence(sequences
, PARENT_SEQ_INDEX
, lvs_ex_transparentbkgnd_seq
,
4999 "LVS_EX_TRANSPARENTBKGND parent", FALSE
);
5001 ReleaseDC(hwndparent
, hdc
);
5003 DestroyWindow(hwnd
);
5006 static void test_approximate_viewrect(void)
5013 static CHAR test
[] = "abracadabra, a very long item label";
5015 hwnd
= create_listview_control(LVS_ICON
);
5016 himl
= ImageList_Create(40, 40, 0, 4, 4);
5017 ok(himl
!= NULL
, "failed to create imagelist\n");
5018 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
5019 ok(hbmp
!= NULL
, "failed to create bitmap\n");
5020 ret
= ImageList_Add(himl
, hbmp
, 0);
5022 ret
= SendMessageA(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
5025 itema
.mask
= LVIF_IMAGE
;
5029 ret
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&itema
);
5032 ret
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(75, 75));
5036 win_skip("LVM_SETICONSPACING unimplemented. Skipping.\n");
5040 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 11, MAKELPARAM(100,100));
5041 expect(MAKELONG(77,827), ret
);
5043 ret
= SendMessageA(hwnd
, LVM_SETICONSPACING
, 0, MAKELPARAM(50, 50));
5044 ok(ret
!= 0, "got 0\n");
5046 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 11, MAKELPARAM(100,100));
5047 expect(MAKELONG(102,302), ret
);
5049 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, -1, MAKELPARAM(100,100));
5050 expect(MAKELONG(52,52), ret
);
5052 itema
.pszText
= test
;
5053 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&itema
);
5055 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, -1, MAKELPARAM(100,100));
5056 expect(MAKELONG(52,52), ret
);
5058 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 0, MAKELPARAM(100,100));
5059 expect(MAKELONG(52,2), ret
);
5060 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 1, MAKELPARAM(100,100));
5061 expect(MAKELONG(52,52), ret
);
5062 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 2, MAKELPARAM(100,100));
5063 expect(MAKELONG(102,52), ret
);
5064 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 3, MAKELPARAM(100,100));
5065 expect(MAKELONG(102,102), ret
);
5066 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 4, MAKELPARAM(100,100));
5067 expect(MAKELONG(102,102), ret
);
5068 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 5, MAKELPARAM(100,100));
5069 expect(MAKELONG(102,152), ret
);
5070 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 6, MAKELPARAM(100,100));
5071 expect(MAKELONG(102,152), ret
);
5072 ret
= SendMessageA(hwnd
, LVM_APPROXIMATEVIEWRECT
, 7, MAKELPARAM(160,100));
5073 expect(MAKELONG(152,152), ret
);
5075 DestroyWindow(hwnd
);
5078 static void test_finditem(void)
5085 hwnd
= create_listview_control(LVS_REPORT
);
5086 insert_item(hwnd
, 0);
5088 memset(&fi
, 0, sizeof(fi
));
5090 /* full string search, inserted text was "foo" */
5092 fi
.flags
= LVFI_STRING
;
5094 r
= SendMessageA(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
5096 /* partial string search, inserted text was "foo" */
5098 fi
.flags
= LVFI_STRING
| LVFI_PARTIAL
;
5100 r
= SendMessageA(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
5102 /* partial string search, part after start char */
5104 fi
.flags
= LVFI_STRING
| LVFI_PARTIAL
;
5106 r
= SendMessageA(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
5109 /* try with LVFI_SUBSTRING */
5111 fi
.flags
= LVFI_SUBSTRING
;
5113 r
= SendMessageA(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
5116 win_skip("LVFI_SUBSTRING not supported\n");
5117 DestroyWindow(hwnd
);
5122 fi
.flags
= LVFI_SUBSTRING
;
5124 r
= SendMessageA(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
5127 fi
.flags
= LVFI_SUBSTRING
;
5129 r
= SendMessageA(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
5133 fi
.flags
= LVFI_SUBSTRING
| LVFI_STRING
;
5135 r
= SendMessageA(hwnd
, LVM_FINDITEMA
, -1, (LPARAM
)&fi
);
5138 DestroyWindow(hwnd
);
5141 static void test_LVS_EX_HEADERINALLVIEWS(void)
5146 hwnd
= create_listview_control(LVS_ICON
);
5148 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
5149 LVS_EX_HEADERINALLVIEWS
);
5151 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
5152 if (!IsWindow(header
))
5154 win_skip("LVS_EX_HEADERINALLVIEWS unsupported\n");
5155 DestroyWindow(hwnd
);
5159 /* LVS_NOCOLUMNHEADER works as before */
5160 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5161 SetWindowLongW(hwnd
, GWL_STYLE
, style
| LVS_NOCOLUMNHEADER
);
5162 style
= GetWindowLongA(header
, GWL_STYLE
);
5163 ok(style
& HDS_HIDDEN
, "Expected HDS_HIDDEN\n");
5164 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5165 SetWindowLongW(hwnd
, GWL_STYLE
, style
& ~LVS_NOCOLUMNHEADER
);
5166 style
= GetWindowLongA(header
, GWL_STYLE
);
5167 ok(!(style
& HDS_HIDDEN
), "Expected HDS_HIDDEN to be unset\n");
5169 /* try to remove style */
5170 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
, 0);
5171 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
5172 ok(IsWindow(header
), "Expected header to be created\n");
5173 style
= GetWindowLongA(header
, GWL_STYLE
);
5174 ok(!(style
& HDS_HIDDEN
), "HDS_HIDDEN not expected\n");
5176 DestroyWindow(hwnd
);
5178 /* check other styles */
5179 hwnd
= create_listview_control(LVS_LIST
);
5180 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
5181 LVS_EX_HEADERINALLVIEWS
);
5182 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
5183 ok(IsWindow(header
), "Expected header to be created\n");
5184 DestroyWindow(hwnd
);
5186 hwnd
= create_listview_control(LVS_SMALLICON
);
5187 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
5188 LVS_EX_HEADERINALLVIEWS
);
5189 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
5190 ok(IsWindow(header
), "Expected header to be created\n");
5191 DestroyWindow(hwnd
);
5193 hwnd
= create_listview_control(LVS_REPORT
);
5194 SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_HEADERINALLVIEWS
,
5195 LVS_EX_HEADERINALLVIEWS
);
5196 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
5197 ok(IsWindow(header
), "Expected header to be created\n");
5198 DestroyWindow(hwnd
);
5201 static void test_hover(void)
5206 hwnd
= create_listview_control(LVS_ICON
);
5207 SetForegroundWindow(hwndparent
);
5208 fg
= GetForegroundWindow();
5209 if (fg
!= hwndparent
)
5211 skip("Window is not in the foreground. Skipping hover tests.\n");
5212 DestroyWindow(hwnd
);
5216 /* test WM_MOUSEHOVER forwarding */
5217 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5218 r
= SendMessageA(hwnd
, WM_MOUSEHOVER
, 0, 0);
5220 ok_sequence(sequences
, PARENT_SEQ_INDEX
, hover_parent
, "NM_HOVER allow test", TRUE
);
5221 g_block_hover
= TRUE
;
5222 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5223 r
= SendMessageA(hwnd
, WM_MOUSEHOVER
, 0, 0);
5225 ok_sequence(sequences
, PARENT_SEQ_INDEX
, hover_parent
, "NM_HOVER block test", TRUE
);
5226 g_block_hover
= FALSE
;
5228 r
= SendMessageA(hwnd
, LVM_SETHOVERTIME
, 0, 500);
5229 expect(HOVER_DEFAULT
, r
);
5230 r
= SendMessageA(hwnd
, LVM_GETHOVERTIME
, 0, 0);
5233 DestroyWindow(hwnd
);
5236 static void test_destroynotify(void)
5241 hwnd
= create_listview_control(LVS_REPORT
);
5242 ok(hwnd
!= NULL
, "failed to create listview window\n");
5244 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5245 DestroyWindow(hwnd
);
5246 ok_sequence(sequences
, COMBINED_SEQ_INDEX
, listview_destroy
, "check destroy order", FALSE
);
5248 /* same for ownerdata list */
5249 hwnd
= create_listview_control(LVS_REPORT
|LVS_OWNERDATA
);
5250 ok(hwnd
!= NULL
, "failed to create listview window\n");
5252 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5253 DestroyWindow(hwnd
);
5254 ok_sequence(sequences
, COMBINED_SEQ_INDEX
, listview_ownerdata_destroy
, "check destroy order, ownerdata", FALSE
);
5256 hwnd
= create_listview_control(LVS_REPORT
|LVS_OWNERDATA
);
5257 ok(hwnd
!= NULL
, "failed to create listview window\n");
5259 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5260 ret
= SendMessageA(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
5261 ok(ret
== TRUE
, "got %d\n", ret
);
5262 ok_sequence(sequences
, COMBINED_SEQ_INDEX
, listview_ownerdata_deleteall
, "deleteall ownerdata", FALSE
);
5263 DestroyWindow(hwnd
);
5266 static void test_header_notification(void)
5268 static char textA
[] = "newtext";
5276 list
= create_listview_control(LVS_REPORT
);
5277 ok(list
!= NULL
, "failed to create listview window\n");
5279 memset(&col
, 0, sizeof(col
));
5280 col
.mask
= LVCF_WIDTH
;
5282 ret
= SendMessageA(list
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
5285 /* check list parent notification after header item changed,
5286 this test should be placed before header subclassing to avoid
5287 Listview -> Header messages to be logged */
5288 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5290 col
.mask
= LVCF_TEXT
;
5291 col
.pszText
= textA
;
5292 r
= SendMessageA(list
, LVM_SETCOLUMNA
, 0, (LPARAM
)&col
);
5295 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_header_changed_seq
,
5296 "header notify, listview", FALSE
);
5297 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
5298 "header notify, parent", FALSE
);
5300 header
= subclass_header(list
);
5302 ret
= SendMessageA(header
, HDM_GETITEMCOUNT
, 0, 0);
5305 memset(&item
, 0, sizeof(item
));
5306 item
.mask
= HDI_WIDTH
;
5307 ret
= SendMessageA(header
, HDM_GETITEMA
, 0, (LPARAM
)&item
);
5309 expect(100, item
.cxy
);
5311 nmh
.hdr
.hwndFrom
= header
;
5312 nmh
.hdr
.idFrom
= GetWindowLongPtrA(header
, GWLP_ID
);
5313 nmh
.hdr
.code
= HDN_ITEMCHANGEDA
;
5316 item
.mask
= HDI_WIDTH
;
5319 ret
= SendMessageA(list
, WM_NOTIFY
, 0, (LPARAM
)&nmh
);
5322 DestroyWindow(list
);
5325 static void test_header_notification2(void)
5327 static char textA
[] = "newtext";
5334 struct message parent_header_notify_seq
[] = {
5335 { WM_NOTIFY
, sent
|id
, 0, 0, 0 },
5339 list
= create_listview_control(LVS_REPORT
);
5340 ok(list
!= NULL
, "failed to create listview window\n");
5342 memset(&col
, 0, sizeof(col
));
5343 col
.mask
= LVCF_WIDTH
| LVCF_TEXT
;
5345 col
.pszText
= textA
;
5346 ret
= SendMessageA(list
, LVM_INSERTCOLUMNA
, 0, (LPARAM
)&col
);
5349 header
= (HWND
)SendMessageA(list
, LVM_GETHEADER
, 0, 0);
5350 ok(header
!= 0, "No header\n");
5351 memset(&itemW
, 0, sizeof(itemW
));
5352 itemW
.mask
= HDI_WIDTH
| HDI_ORDER
| HDI_TEXT
;
5353 itemW
.pszText
= buffer
;
5354 itemW
.cchTextMax
= sizeof(buffer
);
5355 ret
= SendMessageW(header
, HDM_GETITEMW
, 0, (LPARAM
)&itemW
);
5358 nmhdr
.hdr
.hwndFrom
= header
;
5359 nmhdr
.hdr
.idFrom
= GetWindowLongPtrW(header
, GWLP_ID
);
5362 nmhdr
.pitem
= &itemW
;
5364 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5365 nmhdr
.hdr
.code
= HDN_ITEMCHANGINGW
;
5366 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5367 ok(ret
== 0, "got %d\n", ret
);
5368 parent_header_notify_seq
[0].id
= HDN_ITEMCHANGINGA
;
5369 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_header_notify_seq
,
5370 "header notify, parent", TRUE
);
5372 ok(nmhdr
.hdr
.code
== HDN_ITEMCHANGINGA
, "Expected ANSI notification code\n");
5373 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5374 nmhdr
.hdr
.code
= HDN_ITEMCHANGEDW
;
5375 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5376 ok(ret
== 0, "got %d\n", ret
);
5377 parent_header_notify_seq
[0].id
= HDN_ITEMCHANGEDA
;
5378 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_header_notify_seq
,
5379 "header notify, parent", TRUE
);
5381 ok(nmhdr
.hdr
.code
== HDN_ITEMCHANGEDA
, "Expected ANSI notification code\n");
5382 /* HDN_ITEMCLICK sets focus to list, which generates messages we don't want to check */
5384 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5385 nmhdr
.hdr
.code
= HDN_ITEMCLICKW
;
5386 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5387 ok(ret
== 0, "got %d\n", ret
);
5388 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_header_click_seq
,
5389 "header notify, parent", FALSE
);
5390 ok(nmhdr
.hdr
.code
== HDN_ITEMCLICKA
, "Expected ANSI notification code\n");
5391 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5392 nmhdr
.hdr
.code
= HDN_ITEMDBLCLICKW
;
5393 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5394 ok(ret
== 0, "got %d\n", ret
);
5395 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
5396 "header notify, parent", FALSE
);
5397 ok(nmhdr
.hdr
.code
== HDN_ITEMDBLCLICKW
, "Expected Unicode notification code\n");
5398 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5399 nmhdr
.hdr
.code
= HDN_DIVIDERDBLCLICKW
;
5400 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5401 ok(ret
== 0, "got %d\n", ret
);
5402 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_header_divider_dclick_seq
,
5403 "header notify, parent", TRUE
);
5404 ok(nmhdr
.hdr
.code
== HDN_DIVIDERDBLCLICKA
, "Expected ANSI notification code\n");
5405 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5406 nmhdr
.hdr
.code
= HDN_BEGINTRACKW
;
5407 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5408 ok(ret
== 0, "got %d\n", ret
);
5409 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
5410 "header notify, parent", FALSE
);
5411 ok(nmhdr
.hdr
.code
== HDN_BEGINTRACKW
, "Expected Unicode notification code\n");
5412 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5413 nmhdr
.hdr
.code
= HDN_ENDTRACKW
;
5414 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5415 ok(ret
== 0, "got %d\n", ret
);
5416 parent_header_notify_seq
[0].id
= HDN_ENDTRACKA
;
5417 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_header_notify_seq
,
5418 "header notify, parent", FALSE
);
5419 ok(nmhdr
.hdr
.code
== HDN_ENDTRACKA
, "Expected ANSI notification code\n");
5420 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5421 nmhdr
.hdr
.code
= HDN_TRACKW
;
5422 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5423 ok(ret
== 0, "got %d\n", ret
);
5424 parent_header_notify_seq
[0].id
= HDN_TRACKA
;
5425 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_header_notify_seq
,
5426 "header notify, parent", FALSE
);
5427 ok(nmhdr
.hdr
.code
== HDN_TRACKA
, "Expected ANSI notification code\n");
5428 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5429 nmhdr
.hdr
.code
= HDN_BEGINDRAG
;
5430 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5431 ok(ret
== 1, "got %d\n", ret
);
5432 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
5433 "header notify, parent", FALSE
);
5434 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5435 nmhdr
.hdr
.code
= HDN_ENDDRAG
;
5436 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5437 ok(ret
== 0, "got %d\n", ret
);
5438 parent_header_notify_seq
[0].id
= HDN_ENDDRAG
;
5439 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_header_notify_seq
,
5440 "header notify, parent", FALSE
);
5441 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5442 nmhdr
.hdr
.code
= HDN_FILTERCHANGE
;
5443 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5444 ok(ret
== 0, "got %d\n", ret
);
5445 parent_header_notify_seq
[0].id
= HDN_FILTERCHANGE
;
5446 parent_header_notify_seq
[0].flags
|= optional
; /* NT4 does not send this message */
5447 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_header_notify_seq
,
5448 "header notify, parent", FALSE
);
5449 parent_header_notify_seq
[0].flags
&= ~optional
;
5450 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5451 nmhdr
.hdr
.code
= HDN_BEGINFILTEREDIT
;
5452 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5453 ok(ret
== 0, "got %d\n", ret
);
5454 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
5455 "header notify, parent", FALSE
);
5456 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5457 nmhdr
.hdr
.code
= HDN_ENDFILTEREDIT
;
5458 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5459 ok(ret
== 0, "got %d\n", ret
);
5460 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
5461 "header notify, parent", FALSE
);
5462 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5463 nmhdr
.hdr
.code
= HDN_ITEMSTATEICONCLICK
;
5464 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5465 ok(ret
== 0, "got %d\n", ret
);
5466 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
5467 "header notify, parent", FALSE
);
5468 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5469 nmhdr
.hdr
.code
= HDN_ITEMKEYDOWN
;
5470 ret
= SendMessageW(list
, WM_NOTIFY
, 0, (LPARAM
)&nmhdr
);
5471 ok(ret
== 0, "got %d\n", ret
);
5472 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
,
5473 "header notify, parent", FALSE
);
5475 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5477 DestroyWindow(list
);
5480 static void test_createdragimage(void)
5486 list
= create_listview_control(LVS_ICON
);
5487 ok(list
!= NULL
, "failed to create listview window\n");
5489 insert_item(list
, 0);
5492 himl
= (HIMAGELIST
)SendMessageA(list
, LVM_CREATEDRAGIMAGE
, 0, 0);
5493 ok(himl
== NULL
, "got %p\n", himl
);
5495 himl
= (HIMAGELIST
)SendMessageA(list
, LVM_CREATEDRAGIMAGE
, 0, (LPARAM
)&pt
);
5496 ok(himl
!= NULL
, "got %p\n", himl
);
5497 ImageList_Destroy(himl
);
5499 DestroyWindow(list
);
5502 static void test_dispinfo(void)
5504 static const char testA
[] = "TEST";
5510 hwnd
= create_listview_control(LVS_ICON
);
5511 ok(hwnd
!= NULL
, "failed to create listview window\n");
5513 insert_item(hwnd
, 0);
5515 memset(&item
, 0, sizeof(item
));
5516 item
.pszText
= LPSTR_TEXTCALLBACKA
;
5517 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
5520 g_disp_A_to_W
= TRUE
;
5521 item
.pszText
= (char*)buff
;
5522 item
.cchTextMax
= sizeof(buff
)/sizeof(WCHAR
);
5523 ret
= SendMessageA(hwnd
, LVM_GETITEMTEXTA
, 0, (LPARAM
)&item
);
5524 ok(ret
== sizeof(testA
)-1, "got %d, expected 4\n", ret
);
5525 g_disp_A_to_W
= FALSE
;
5527 ok(memcmp(item
.pszText
, testA
, sizeof(testA
)) == 0,
5528 "got %s, expected %s\n", item
.pszText
, testA
);
5530 DestroyWindow(hwnd
);
5533 static void test_LVM_SETITEMTEXT(void)
5535 static char testA
[] = "TEST";
5540 hwnd
= create_listview_control(LVS_ICON
);
5541 ok(hwnd
!= NULL
, "failed to create listview window\n");
5543 insert_item(hwnd
, 0);
5545 /* null item pointer */
5546 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, 0);
5549 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTW
, 0, 0);
5552 /* index out of bounds */
5553 item
.pszText
= testA
;
5554 item
.cchTextMax
= 0; /* ignored */
5557 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 1, (LPARAM
)&item
);
5560 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, -1, (LPARAM
)&item
);
5563 ret
= SendMessageA(hwnd
, LVM_SETITEMTEXTA
, 0, (LPARAM
)&item
);
5566 DestroyWindow(hwnd
);
5569 static void test_imagelists(void)
5572 HIMAGELIST himl1
, himl2
, himl3
;
5575 himl1
= ImageList_Create(40, 40, 0, 4, 4);
5576 himl2
= ImageList_Create(40, 40, 0, 4, 4);
5577 himl3
= ImageList_Create(40, 40, 0, 4, 4);
5578 ok(himl1
!= NULL
, "Failed to create imagelist\n");
5579 ok(himl2
!= NULL
, "Failed to create imagelist\n");
5580 ok(himl3
!= NULL
, "Failed to create imagelist\n");
5582 hwnd
= create_listview_control(LVS_REPORT
| LVS_SHAREIMAGELISTS
);
5583 header
= subclass_header(hwnd
);
5585 ok(header
!= NULL
, "Expected header\n");
5586 ret
= SendMessageA(header
, HDM_GETIMAGELIST
, 0, 0);
5587 ok(ret
== 0, "Expected no imagelist, got %p\n", (HIMAGELIST
)ret
);
5589 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5591 ret
= SendMessageW(hwnd
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, (LPARAM
)himl1
);
5592 ok(ret
== 0, "Expected no imagelist, got %p\n", (HIMAGELIST
)ret
);
5593 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_set_imagelist
,
5594 "set normal image list", FALSE
);
5596 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5598 ret
= SendMessageW(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl2
);
5599 ok(ret
== 0, "Expected no imagelist, got %p\n", (HIMAGELIST
)ret
);
5600 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_set_imagelist
,
5601 "set state image list", TRUE
);
5603 ret
= SendMessageA(header
, HDM_GETIMAGELIST
, 0, 0);
5604 ok(ret
== 0, "Expected no imagelist, got %p\n", (HIMAGELIST
)ret
);
5606 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5608 ret
= SendMessageW(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl3
);
5609 ok(ret
== 0, "Expected no imagelist, got %p\n", (HIMAGELIST
)ret
);
5610 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_header_set_imagelist
,
5611 "set small image list", FALSE
);
5613 ret
= SendMessageA(header
, HDM_GETIMAGELIST
, 0, 0);
5614 ok((HIMAGELIST
)ret
== himl3
, "Expected imagelist %p, got %p\n", himl3
, (HIMAGELIST
)ret
);
5615 DestroyWindow(hwnd
);
5617 hwnd
= create_listview_control(WS_VISIBLE
| LVS_ICON
);
5619 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5621 ret
= SendMessageW(hwnd
, LVM_SETIMAGELIST
, LVSIL_NORMAL
, (LPARAM
)himl1
);
5622 ok(ret
== 0, "Expected no imagelist, got %p\n", (HIMAGELIST
)ret
);
5623 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_set_imagelist
,
5624 "set normal image list", FALSE
);
5626 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5628 ret
= SendMessageW(hwnd
, LVM_SETIMAGELIST
, LVSIL_STATE
, (LPARAM
)himl2
);
5629 ok(ret
== 0, "Expected no imagelist, got %p\n", (HIMAGELIST
)ret
);
5630 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_set_imagelist
,
5631 "set state image list", FALSE
);
5633 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5635 ret
= SendMessageW(hwnd
, LVM_SETIMAGELIST
, LVSIL_SMALL
, (LPARAM
)himl3
);
5636 ok(ret
== 0, "Expected no imagelist, got %p\n", (HIMAGELIST
)ret
);
5637 ok_sequence(sequences
, LISTVIEW_SEQ_INDEX
, listview_set_imagelist
,
5638 "set small image list", FALSE
);
5640 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
5641 ok(header
== NULL
, "Expected no header, got %p\n", header
);
5643 SetWindowLongPtrA(hwnd
, GWL_STYLE
, GetWindowLongPtrA(hwnd
, GWL_STYLE
) | LVS_REPORT
);
5645 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
5646 ok(header
!= NULL
, "Expected header, got NULL\n");
5648 ret
= SendMessageA(header
, HDM_GETIMAGELIST
, 0, 0);
5649 ok((HIMAGELIST
)ret
== himl3
, "Expected imagelist %p, got %p\n", himl3
, (HIMAGELIST
)ret
);
5651 DestroyWindow(hwnd
);
5654 static void test_deleteitem(void)
5661 hwnd
= create_listview_control(LVS_REPORT
);
5663 insert_item(hwnd
, 0);
5664 insert_item(hwnd
, 0);
5665 insert_item(hwnd
, 0);
5666 insert_item(hwnd
, 0);
5667 insert_item(hwnd
, 0);
5669 g_focus_test_LVN_DELETEITEM
= TRUE
;
5671 /* delete focused item (not the last index) */
5672 item
.stateMask
= LVIS_FOCUSED
;
5673 item
.state
= LVIS_FOCUSED
;
5674 ret
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 2, (LPARAM
)&item
);
5675 ok(ret
== TRUE
, "got %d\n", ret
);
5676 ret
= SendMessageA(hwnd
, LVM_DELETEITEM
, 2, 0);
5677 ok(ret
== TRUE
, "got %d\n", ret
);
5678 /* next item gets focus */
5679 state
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 2, LVIS_FOCUSED
);
5680 ok(state
== LVIS_FOCUSED
, "got %x\n", state
);
5682 /* focus last item and delete it */
5683 item
.stateMask
= LVIS_FOCUSED
;
5684 item
.state
= LVIS_FOCUSED
;
5685 ret
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 3, (LPARAM
)&item
);
5686 ok(ret
== TRUE
, "got %d\n", ret
);
5687 ret
= SendMessageA(hwnd
, LVM_DELETEITEM
, 3, 0);
5688 ok(ret
== TRUE
, "got %d\n", ret
);
5689 /* new last item gets focus */
5690 state
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 2, LVIS_FOCUSED
);
5691 ok(state
== LVIS_FOCUSED
, "got %x\n", state
);
5693 /* focus first item and delete it */
5694 item
.stateMask
= LVIS_FOCUSED
;
5695 item
.state
= LVIS_FOCUSED
;
5696 ret
= SendMessageA(hwnd
, LVM_SETITEMSTATE
, 0, (LPARAM
)&item
);
5697 ok(ret
== TRUE
, "got %d\n", ret
);
5698 ret
= SendMessageA(hwnd
, LVM_DELETEITEM
, 0, 0);
5699 ok(ret
== TRUE
, "got %d\n", ret
);
5700 /* new first item gets focus */
5701 state
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_FOCUSED
);
5702 ok(state
== LVIS_FOCUSED
, "got %x\n", state
);
5704 g_focus_test_LVN_DELETEITEM
= FALSE
;
5706 DestroyWindow(hwnd
);
5709 static void test_insertitem(void)
5716 hwnd
= create_listview_control(LVS_REPORT
);
5718 /* insert item 0 focused */
5719 item
.mask
= LVIF_STATE
;
5720 item
.state
= LVIS_FOCUSED
;
5721 item
.stateMask
= LVIS_FOCUSED
;
5724 ret
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
5725 ok(ret
== 0, "got %d\n", ret
);
5727 state
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 0, LVIS_FOCUSED
);
5728 ok(state
== LVIS_FOCUSED
, "got %x\n", state
);
5730 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5732 /* insert item 1, focus shift */
5733 item
.mask
= LVIF_STATE
;
5734 item
.state
= LVIS_FOCUSED
;
5735 item
.stateMask
= LVIS_FOCUSED
;
5738 ret
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
5739 ok(ret
== 1, "got %d\n", ret
);
5741 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_insert_focused_seq
, "insert focused", TRUE
);
5743 state
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 1, LVIS_FOCUSED
);
5744 ok(state
== LVIS_FOCUSED
, "got %x\n", state
);
5746 /* insert item 2, no focus shift */
5747 item
.mask
= LVIF_STATE
;
5749 item
.stateMask
= LVIS_FOCUSED
;
5752 ret
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
)&item
);
5753 ok(ret
== 2, "got %d\n", ret
);
5755 state
= SendMessageA(hwnd
, LVM_GETITEMSTATE
, 1, LVIS_FOCUSED
);
5756 ok(state
== LVIS_FOCUSED
, "got %x\n", state
);
5758 DestroyWindow(hwnd
);
5761 static void test_header_proc(void)
5763 HWND hwnd
, header
, hdr
;
5764 WNDPROC proc1
, proc2
;
5766 hwnd
= create_listview_control(LVS_REPORT
);
5768 header
= (HWND
)SendMessageA(hwnd
, LVM_GETHEADER
, 0, 0);
5769 ok(header
!= NULL
, "got %p\n", header
);
5771 hdr
= CreateWindowExA(0, WC_HEADERA
, NULL
,
5772 WS_BORDER
|WS_VISIBLE
|HDS_BUTTONS
|HDS_HORZ
,
5774 NULL
, NULL
, NULL
, NULL
);
5775 ok(hdr
!= NULL
, "got %p\n", hdr
);
5777 proc1
= (WNDPROC
)GetWindowLongPtrW(header
, GWLP_WNDPROC
);
5778 proc2
= (WNDPROC
)GetWindowLongPtrW(hdr
, GWLP_WNDPROC
);
5779 ok(proc1
== proc2
, "got %p, expected %p\n", proc1
, proc2
);
5782 DestroyWindow(hwnd
);
5785 static void flush_events(void)
5789 int min_timeout
= 100;
5790 DWORD time
= GetTickCount() + diff
;
5794 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
5795 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
5796 diff
= time
- GetTickCount();
5800 static void test_oneclickactivate(void)
5802 TRACKMOUSEEVENT track
;
5803 char item1
[] = "item1";
5809 hwnd
= CreateWindowExA(0, "SysListView32", "foo", WS_VISIBLE
|WS_CHILD
|LVS_LIST
,
5810 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
5811 ok(hwnd
!= NULL
, "failed to create listview window\n");
5812 r
= SendMessageA(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, LVS_EX_ONECLICKACTIVATE
);
5813 ok(r
== 0, "should return zero\n");
5815 SetForegroundWindow(hwndparent
);
5817 fg
= GetForegroundWindow();
5818 if (fg
!= hwndparent
)
5820 skip("Window is not in the foreground. Skipping oneclickactivate tests.\n");
5821 DestroyWindow(hwnd
);
5825 item
.mask
= LVIF_TEXT
;
5829 item
.pszText
= item1
;
5830 r
= SendMessageA(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
5831 ok(r
== 0, "should not fail\n");
5833 GetWindowRect(hwnd
, &rect
);
5834 SetCursorPos(rect
.left
+5, rect
.top
+5);
5836 r
= SendMessageA(hwnd
, WM_MOUSEMOVE
, MAKELONG(1, 1), 0);
5839 track
.cbSize
= sizeof(track
);
5840 track
.dwFlags
= TME_QUERY
;
5841 _TrackMouseEvent(&track
);
5842 ok(track
.hwndTrack
== hwnd
, "hwndTrack != hwnd\n");
5843 ok(track
.dwFlags
== TME_LEAVE
, "dwFlags = %x\n", track
.dwFlags
);
5845 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
5847 r
= SendMessageA(hwnd
, WM_MOUSEHOVER
, MAKELONG(1, 1), 0);
5849 r
= SendMessageA(hwnd
, LVM_GETSELECTEDCOUNT
, 0, 0);
5852 DestroyWindow(hwnd
);
5855 START_TEST(listview
)
5858 BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
5860 ULONG_PTR ctx_cookie
;
5863 hComctl32
= GetModuleHandleA("comctl32.dll");
5864 pInitCommonControlsEx
= (void*)GetProcAddress(hComctl32
, "InitCommonControlsEx");
5865 if (pInitCommonControlsEx
)
5867 INITCOMMONCONTROLSEX iccex
;
5868 iccex
.dwSize
= sizeof(iccex
);
5869 iccex
.dwICC
= ICC_LISTVIEW_CLASSES
;
5870 pInitCommonControlsEx(&iccex
);
5873 InitCommonControls();
5875 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
5877 hwndparent
= create_parent_window(FALSE
);
5878 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
5880 g_is_below_5
= is_below_comctl_5();
5882 test_header_notification();
5883 test_header_notification2();
5890 test_icon_spacing();
5893 test_item_position();
5898 test_subitem_rect();
5902 test_nosortheader();
5906 test_getitemposition();
5907 test_columnscreation();
5909 test_notifyformat();
5911 test_getitemspacing();
5912 test_getcolumnwidth();
5913 test_approximate_viewrect();
5916 test_destroynotify();
5917 test_createdragimage();
5919 test_LVM_SETITEMTEXT();
5924 test_oneclickactivate();
5926 if (!load_v6_module(&ctx_cookie
, &hCtx
))
5928 DestroyWindow(hwndparent
);
5932 /* comctl32 version 6 tests start here */
5933 test_get_set_view();
5934 test_canceleditlabel();
5936 test_scrollnotify();
5937 test_LVS_EX_TRANSPARENTBKGND();
5938 test_LVS_EX_HEADERINALLVIEWS();
5944 unload_v6_module(ctx_cookie
, hCtx
);
5946 DestroyWindow(hwndparent
);