1c2c66affSColin Finck /*
2c2c66affSColin Finck * ListView tests
3c2c66affSColin Finck *
4c2c66affSColin Finck * Copyright 2006 Mike McCormack for CodeWeavers
5c2c66affSColin Finck * Copyright 2007 George Gov
6c2c66affSColin Finck * Copyright 2009-2014 Nikolay Sivov
7c2c66affSColin Finck *
8c2c66affSColin Finck * This library is free software; you can redistribute it and/or
9c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
10c2c66affSColin Finck * License as published by the Free Software Foundation; either
11c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
12c2c66affSColin Finck *
13c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
14c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
15c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16c2c66affSColin Finck * Lesser General Public License for more details.
17c2c66affSColin Finck *
18c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
19c2c66affSColin Finck * License along with this library; if not, write to the Free Software
20c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21c2c66affSColin Finck */
22c2c66affSColin Finck
23f37104daSAmine Khaldi #include <stdio.h>
24f37104daSAmine Khaldi #include <windows.h>
25f37104daSAmine Khaldi #include <commctrl.h>
26f37104daSAmine Khaldi
27f37104daSAmine Khaldi #include "wine/test.h"
28f37104daSAmine Khaldi #include "v6util.h"
29f37104daSAmine Khaldi #include "msg.h"
30f37104daSAmine Khaldi
31f37104daSAmine Khaldi static HIMAGELIST (WINAPI *pImageList_Create)(int, int, UINT, int, int);
32f37104daSAmine Khaldi static BOOL (WINAPI *pImageList_Destroy)(HIMAGELIST);
33f37104daSAmine Khaldi static int (WINAPI *pImageList_Add)(HIMAGELIST, HBITMAP, HBITMAP);
34f37104daSAmine Khaldi static BOOL (WINAPI *p_TrackMouseEvent)(TRACKMOUSEEVENT *);
35c2c66affSColin Finck
36c2c66affSColin Finck enum seq_index {
37c2c66affSColin Finck PARENT_SEQ_INDEX,
38c2c66affSColin Finck PARENT_FULL_SEQ_INDEX,
39c2c66affSColin Finck PARENT_CD_SEQ_INDEX,
40c2c66affSColin Finck LISTVIEW_SEQ_INDEX,
41c2c66affSColin Finck EDITBOX_SEQ_INDEX,
42c2c66affSColin Finck COMBINED_SEQ_INDEX,
43c2c66affSColin Finck NUM_MSG_SEQUENCES
44c2c66affSColin Finck };
45c2c66affSColin Finck
46c2c66affSColin Finck #define LISTVIEW_ID 0
47c2c66affSColin Finck #define HEADER_ID 1
48c2c66affSColin Finck
49c2c66affSColin Finck #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
50c2c66affSColin Finck #define expect2(expected1, expected2, got1, got2) ok(expected1 == got1 && expected2 == got2, \
51c2c66affSColin Finck "expected (%d,%d), got (%d,%d)\n", expected1, expected2, got1, got2)
52c2c66affSColin Finck
53c2c66affSColin Finck static const WCHAR testparentclassW[] =
54c2c66affSColin Finck {'L','i','s','t','v','i','e','w',' ','t','e','s','t',' ','p','a','r','e','n','t','W', 0};
55c2c66affSColin Finck
56c2c66affSColin Finck static HWND hwndparent, hwndparentW;
57c2c66affSColin Finck /* prevents edit box creation, LVN_BEGINLABELEDIT return value */
58c2c66affSColin Finck static BOOL blockEdit;
59c2c66affSColin Finck /* return nonzero on NM_HOVER */
60c2c66affSColin Finck static BOOL g_block_hover;
61c2c66affSColin Finck /* notification data for LVN_ITEMCHANGED */
62c2c66affSColin Finck static NMLISTVIEW g_nmlistview;
63c2c66affSColin Finck /* notification data for LVN_ITEMCHANGING */
64c2c66affSColin Finck static NMLISTVIEW g_nmlistview_changing;
65c2c66affSColin Finck /* format reported to control:
66c2c66affSColin Finck -1 falls to defproc, anything else returned */
67c2c66affSColin Finck static INT notifyFormat;
68c2c66affSColin Finck /* indicates we're running < 5.80 version */
69c2c66affSColin Finck static BOOL g_is_below_5;
70c2c66affSColin Finck /* item data passed to LVN_GETDISPINFOA */
71c2c66affSColin Finck static LVITEMA g_itema;
72c2c66affSColin Finck /* alter notification code A->W */
73c2c66affSColin Finck static BOOL g_disp_A_to_W;
74c2c66affSColin Finck /* dispinfo data sent with LVN_LVN_ENDLABELEDIT */
75c2c66affSColin Finck static NMLVDISPINFOA g_editbox_disp_info;
76c2c66affSColin Finck /* when this is set focus will be tested on LVN_DELETEITEM */
77c2c66affSColin Finck static BOOL g_focus_test_LVN_DELETEITEM;
785f7243b5SAmine Khaldi /* Whether to send WM_KILLFOCUS to the edit control during LVN_ENDLABELEDIT */
795f7243b5SAmine Khaldi static BOOL g_WM_KILLFOCUS_on_LVN_ENDLABELEDIT;
80c2c66affSColin Finck
81c2c66affSColin Finck static HWND subclass_editbox(HWND hwndListview);
82c2c66affSColin Finck
init_functions(void)83f37104daSAmine Khaldi static void init_functions(void)
84f37104daSAmine Khaldi {
85f37104daSAmine Khaldi HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
86f37104daSAmine Khaldi
87f37104daSAmine Khaldi #define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
88f37104daSAmine Khaldi X(ImageList_Create);
89f37104daSAmine Khaldi X(ImageList_Destroy);
90f37104daSAmine Khaldi X(ImageList_Add);
91f37104daSAmine Khaldi X(_TrackMouseEvent);
92f37104daSAmine Khaldi #undef X
93f37104daSAmine Khaldi }
94f37104daSAmine Khaldi
95c2c66affSColin Finck static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
96c2c66affSColin Finck
97c2c66affSColin Finck static const struct message create_ownerdrawfixed_parent_seq[] = {
98c2c66affSColin Finck { WM_NOTIFYFORMAT, sent },
99c2c66affSColin Finck { WM_QUERYUISTATE, sent|optional }, /* Win2K and higher */
100c2c66affSColin Finck { WM_MEASUREITEM, sent },
101c2c66affSColin Finck { WM_PARENTNOTIFY, sent },
102c2c66affSColin Finck { 0 }
103c2c66affSColin Finck };
104c2c66affSColin Finck
105c2c66affSColin Finck static const struct message redraw_listview_seq[] = {
106c2c66affSColin Finck { WM_PAINT, sent|id, 0, 0, LISTVIEW_ID },
107c2c66affSColin Finck { WM_PAINT, sent|id, 0, 0, HEADER_ID },
108c2c66affSColin Finck { WM_NCPAINT, sent|id|defwinproc, 0, 0, HEADER_ID },
109c2c66affSColin Finck { WM_ERASEBKGND, sent|id|defwinproc|optional, 0, 0, HEADER_ID },
110c2c66affSColin Finck { WM_NOTIFY, sent|id|defwinproc, 0, 0, LISTVIEW_ID },
111c2c66affSColin Finck { WM_NCPAINT, sent|id|defwinproc, 0, 0, LISTVIEW_ID },
112c2c66affSColin Finck { WM_ERASEBKGND, sent|id|defwinproc|optional, 0, 0, LISTVIEW_ID },
113c2c66affSColin Finck { 0 }
114c2c66affSColin Finck };
115c2c66affSColin Finck
116c2c66affSColin Finck static const struct message listview_icon_spacing_seq[] = {
117c2c66affSColin Finck { LVM_SETICONSPACING, sent|lparam, 0, MAKELPARAM(20, 30) },
118c2c66affSColin Finck { LVM_SETICONSPACING, sent|lparam, 0, MAKELPARAM(25, 35) },
119c2c66affSColin Finck { LVM_SETICONSPACING, sent|lparam, 0, MAKELPARAM(-1, -1) },
120c2c66affSColin Finck { 0 }
121c2c66affSColin Finck };
122c2c66affSColin Finck
123c2c66affSColin Finck static const struct message listview_color_seq[] = {
124c2c66affSColin Finck { LVM_SETBKCOLOR, sent|lparam, 0, RGB(0,0,0) },
125c2c66affSColin Finck { LVM_GETBKCOLOR, sent },
126c2c66affSColin Finck { LVM_SETTEXTCOLOR, sent|lparam, 0, RGB(0,0,0) },
127c2c66affSColin Finck { LVM_GETTEXTCOLOR, sent },
128c2c66affSColin Finck { LVM_SETTEXTBKCOLOR, sent|lparam, 0, RGB(0,0,0) },
129c2c66affSColin Finck { LVM_GETTEXTBKCOLOR, sent },
130c2c66affSColin Finck
131c2c66affSColin Finck { LVM_SETBKCOLOR, sent|lparam, 0, RGB(100,50,200) },
132c2c66affSColin Finck { LVM_GETBKCOLOR, sent },
133c2c66affSColin Finck { LVM_SETTEXTCOLOR, sent|lparam, 0, RGB(100,50,200) },
134c2c66affSColin Finck { LVM_GETTEXTCOLOR, sent },
135c2c66affSColin Finck { LVM_SETTEXTBKCOLOR, sent|lparam, 0, RGB(100,50,200) },
136c2c66affSColin Finck { LVM_GETTEXTBKCOLOR, sent },
137c2c66affSColin Finck
138c2c66affSColin Finck { LVM_SETBKCOLOR, sent|lparam, 0, CLR_NONE },
139c2c66affSColin Finck { LVM_GETBKCOLOR, sent },
140c2c66affSColin Finck { LVM_SETTEXTCOLOR, sent|lparam, 0, CLR_NONE },
141c2c66affSColin Finck { LVM_GETTEXTCOLOR, sent },
142c2c66affSColin Finck { LVM_SETTEXTBKCOLOR, sent|lparam, 0, CLR_NONE },
143c2c66affSColin Finck { LVM_GETTEXTBKCOLOR, sent },
144c2c66affSColin Finck
145c2c66affSColin Finck { LVM_SETBKCOLOR, sent|lparam, 0, RGB(255,255,255) },
146c2c66affSColin Finck { LVM_GETBKCOLOR, sent },
147c2c66affSColin Finck { LVM_SETTEXTCOLOR, sent|lparam, 0, RGB(255,255,255) },
148c2c66affSColin Finck { LVM_GETTEXTCOLOR, sent },
149c2c66affSColin Finck { LVM_SETTEXTBKCOLOR, sent|lparam, 0, RGB(255,255,255) },
150c2c66affSColin Finck { LVM_GETTEXTBKCOLOR, sent },
151c2c66affSColin Finck { 0 }
152c2c66affSColin Finck };
153c2c66affSColin Finck
154c2c66affSColin Finck static const struct message listview_item_count_seq[] = {
155c2c66affSColin Finck { LVM_GETITEMCOUNT, sent },
156c2c66affSColin Finck { LVM_INSERTITEMA, sent },
157c2c66affSColin Finck { LVM_INSERTITEMA, sent },
158c2c66affSColin Finck { LVM_INSERTITEMA, sent },
159c2c66affSColin Finck { LVM_GETITEMCOUNT, sent },
160c2c66affSColin Finck { LVM_DELETEITEM, sent|wparam, 2 },
161c2c66affSColin Finck { WM_NCPAINT, sent|optional },
162c2c66affSColin Finck { WM_ERASEBKGND, sent|optional },
163c2c66affSColin Finck { LVM_GETITEMCOUNT, sent },
164c2c66affSColin Finck { LVM_DELETEALLITEMS, sent },
165c2c66affSColin Finck { LVM_GETITEMCOUNT, sent },
166c2c66affSColin Finck { LVM_INSERTITEMA, sent },
167c2c66affSColin Finck { LVM_INSERTITEMA, sent },
168c2c66affSColin Finck { LVM_GETITEMCOUNT, sent },
169c2c66affSColin Finck { LVM_INSERTITEMA, sent },
170c2c66affSColin Finck { LVM_GETITEMCOUNT, sent },
171c2c66affSColin Finck { 0 }
172c2c66affSColin Finck };
173c2c66affSColin Finck
174c2c66affSColin Finck static const struct message listview_itempos_seq[] = {
175c2c66affSColin Finck { LVM_INSERTITEMA, sent },
176c2c66affSColin Finck { LVM_INSERTITEMA, sent },
177c2c66affSColin Finck { LVM_INSERTITEMA, sent },
178c2c66affSColin Finck { LVM_SETITEMPOSITION, sent|wparam|lparam, 1, MAKELPARAM(10,5) },
179c2c66affSColin Finck { WM_NCPAINT, sent|optional },
180c2c66affSColin Finck { WM_ERASEBKGND, sent|optional },
181c2c66affSColin Finck { LVM_GETITEMPOSITION, sent|wparam, 1 },
182c2c66affSColin Finck { LVM_SETITEMPOSITION, sent|wparam|lparam, 2, MAKELPARAM(0,0) },
183c2c66affSColin Finck { LVM_GETITEMPOSITION, sent|wparam, 2 },
184c2c66affSColin Finck { LVM_SETITEMPOSITION, sent|wparam|lparam, 0, MAKELPARAM(20,20) },
185c2c66affSColin Finck { LVM_GETITEMPOSITION, sent|wparam, 0 },
186c2c66affSColin Finck { 0 }
187c2c66affSColin Finck };
188c2c66affSColin Finck
189c2c66affSColin Finck static const struct message listview_ownerdata_switchto_seq[] = {
190c2c66affSColin Finck { WM_STYLECHANGING, sent },
191c2c66affSColin Finck { WM_STYLECHANGED, sent },
192c2c66affSColin Finck { 0 }
193c2c66affSColin Finck };
194c2c66affSColin Finck
195c2c66affSColin Finck static const struct message listview_getorderarray_seq[] = {
196c2c66affSColin Finck { LVM_GETCOLUMNORDERARRAY, sent|id|wparam, 2, 0, LISTVIEW_ID },
197c2c66affSColin Finck { HDM_GETORDERARRAY, sent|id|wparam, 2, 0, HEADER_ID },
198c2c66affSColin Finck { LVM_GETCOLUMNORDERARRAY, sent|id|wparam, 0, 0, LISTVIEW_ID },
199c2c66affSColin Finck { HDM_GETORDERARRAY, sent|id|wparam, 0, 0, HEADER_ID },
200c2c66affSColin Finck { 0 }
201c2c66affSColin Finck };
202c2c66affSColin Finck
203c2c66affSColin Finck static const struct message listview_setorderarray_seq[] = {
204c2c66affSColin Finck { LVM_SETCOLUMNORDERARRAY, sent|id|wparam, 2, 0, LISTVIEW_ID },
205c2c66affSColin Finck { HDM_SETORDERARRAY, sent|id|wparam, 2, 0, HEADER_ID },
206c2c66affSColin Finck { LVM_SETCOLUMNORDERARRAY, sent|id|wparam, 0, 0, LISTVIEW_ID },
207c2c66affSColin Finck { HDM_SETORDERARRAY, sent|id|wparam, 0, 0, HEADER_ID },
208c2c66affSColin Finck { 0 }
209c2c66affSColin Finck };
210c2c66affSColin Finck
211c2c66affSColin Finck static const struct message empty_seq[] = {
212c2c66affSColin Finck { 0 }
213c2c66affSColin Finck };
214c2c66affSColin Finck
2150d320bc2SAmine Khaldi static const struct message parent_focus_change_ownerdata_seq[] = {
2160d320bc2SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
2170d320bc2SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
2180d320bc2SAmine Khaldi { 0 }
2190d320bc2SAmine Khaldi };
2200d320bc2SAmine Khaldi
221c2c66affSColin Finck static const struct message forward_erasebkgnd_parent_seq[] = {
222c2c66affSColin Finck { WM_ERASEBKGND, sent },
223c2c66affSColin Finck { 0 }
224c2c66affSColin Finck };
225c2c66affSColin Finck
226c2c66affSColin Finck static const struct message ownerdata_select_focus_parent_seq[] = {
227c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
228c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
229c2c66affSColin Finck { WM_NOTIFY, sent|id|optional, 0, 0, LVN_GETDISPINFOA }, /* version 4.7x */
230c2c66affSColin Finck { 0 }
231c2c66affSColin Finck };
232c2c66affSColin Finck
233c2c66affSColin Finck static const struct message ownerdata_setstate_all_parent_seq[] = {
234c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
235c2c66affSColin Finck { 0 }
236c2c66affSColin Finck };
237c2c66affSColin Finck
238c2c66affSColin Finck static const struct message ownerdata_defocus_all_parent_seq[] = {
239c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
240c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
241c2c66affSColin Finck { WM_NOTIFY, sent|id|optional, 0, 0, LVN_GETDISPINFOA },
242c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
243c2c66affSColin Finck { 0 }
244c2c66affSColin Finck };
245c2c66affSColin Finck
246c2c66affSColin Finck static const struct message ownerdata_deselect_all_parent_seq[] = {
247c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ODCACHEHINT },
248c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
249c2c66affSColin Finck { 0 }
250c2c66affSColin Finck };
251c2c66affSColin Finck
252c2c66affSColin Finck static const struct message change_all_parent_seq[] = {
253c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
254c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
255c2c66affSColin Finck
256c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
257c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
258c2c66affSColin Finck
259c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
260c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
261c2c66affSColin Finck
262c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
263c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
264c2c66affSColin Finck
265c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
266c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
267c2c66affSColin Finck { 0 }
268c2c66affSColin Finck };
269c2c66affSColin Finck
270c2c66affSColin Finck static const struct message changing_all_parent_seq[] = {
271c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
272c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
273c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
274c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
275c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
276c2c66affSColin Finck { 0 }
277c2c66affSColin Finck };
278c2c66affSColin Finck
279c2c66affSColin Finck static const struct message textcallback_set_again_parent_seq[] = {
280c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
281c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
282c2c66affSColin Finck { 0 }
283c2c66affSColin Finck };
284c2c66affSColin Finck
285c2c66affSColin Finck static const struct message single_getdispinfo_parent_seq[] = {
286c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_GETDISPINFOA },
287c2c66affSColin Finck { 0 }
288c2c66affSColin Finck };
289c2c66affSColin Finck
290c2c66affSColin Finck static const struct message getitemposition_seq1[] = {
291c2c66affSColin Finck { LVM_GETITEMPOSITION, sent|id, 0, 0, LISTVIEW_ID },
292c2c66affSColin Finck { 0 }
293c2c66affSColin Finck };
294c2c66affSColin Finck
295c2c66affSColin Finck static const struct message getitemposition_seq2[] = {
296c2c66affSColin Finck { LVM_GETITEMPOSITION, sent|id, 0, 0, LISTVIEW_ID },
297c2c66affSColin Finck { HDM_GETITEMRECT, sent|id, 0, 0, HEADER_ID },
298c2c66affSColin Finck { 0 }
299c2c66affSColin Finck };
300c2c66affSColin Finck
301c2c66affSColin Finck static const struct message getsubitemrect_seq[] = {
302c2c66affSColin Finck { LVM_GETSUBITEMRECT, sent|id|wparam, -1, 0, LISTVIEW_ID },
303c2c66affSColin Finck { HDM_GETITEMRECT, sent|id, 0, 0, HEADER_ID },
304c2c66affSColin Finck { LVM_GETSUBITEMRECT, sent|id|wparam, 0, 0, LISTVIEW_ID },
305c2c66affSColin Finck { HDM_GETITEMRECT, sent|id, 0, 0, HEADER_ID },
306c2c66affSColin Finck { LVM_GETSUBITEMRECT, sent|id|wparam, -10, 0, LISTVIEW_ID },
307c2c66affSColin Finck { HDM_GETITEMRECT, sent|id, 0, 0, HEADER_ID },
308c2c66affSColin Finck { LVM_GETSUBITEMRECT, sent|id|wparam, 20, 0, LISTVIEW_ID },
309c2c66affSColin Finck { HDM_GETITEMRECT, sent|id, 0, 0, HEADER_ID },
310c2c66affSColin Finck { 0 }
311c2c66affSColin Finck };
312c2c66affSColin Finck
313c2c66affSColin Finck static const struct message editbox_create_pos[] = {
314c2c66affSColin Finck /* sequence sent after LVN_BEGINLABELEDIT */
315c2c66affSColin Finck /* next two are 4.7x specific */
316c2c66affSColin Finck { WM_WINDOWPOSCHANGING, sent },
317c2c66affSColin Finck { WM_WINDOWPOSCHANGED, sent|optional },
318c2c66affSColin Finck
319c2c66affSColin Finck { WM_WINDOWPOSCHANGING, sent|optional },
320c2c66affSColin Finck { WM_NCCALCSIZE, sent },
321c2c66affSColin Finck { WM_WINDOWPOSCHANGED, sent },
322c2c66affSColin Finck { WM_MOVE, sent|defwinproc },
323c2c66affSColin Finck { WM_SIZE, sent|defwinproc },
324c2c66affSColin Finck /* the rest is todo, skipped in 4.7x */
325c2c66affSColin Finck { WM_WINDOWPOSCHANGING, sent|optional },
326c2c66affSColin Finck { WM_WINDOWPOSCHANGED, sent|optional },
327c2c66affSColin Finck { 0 }
328c2c66affSColin Finck };
329c2c66affSColin Finck
330c2c66affSColin Finck static const struct message scroll_parent_seq[] = {
331c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_BEGINSCROLL },
332c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ENDSCROLL },
333c2c66affSColin Finck { 0 }
334c2c66affSColin Finck };
335c2c66affSColin Finck
336c2c66affSColin Finck static const struct message setredraw_seq[] = {
337c2c66affSColin Finck { WM_SETREDRAW, sent|id|wparam, FALSE, 0, LISTVIEW_ID },
338c2c66affSColin Finck { 0 }
339c2c66affSColin Finck };
340c2c66affSColin Finck
341c2c66affSColin Finck static const struct message lvs_ex_transparentbkgnd_seq[] = {
342c2c66affSColin Finck { WM_PRINTCLIENT, sent|lparam, 0, PRF_ERASEBKGND },
343c2c66affSColin Finck { 0 }
344c2c66affSColin Finck };
345c2c66affSColin Finck
346c2c66affSColin Finck static const struct message edit_end_nochange[] = {
347c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ENDLABELEDITA },
348c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, NM_CUSTOMDRAW }, /* todo */
349c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, NM_SETFOCUS },
350c2c66affSColin Finck { 0 }
351c2c66affSColin Finck };
352c2c66affSColin Finck
353c2c66affSColin Finck static const struct message hover_parent[] = {
354c2c66affSColin Finck { WM_GETDLGCODE, sent }, /* todo_wine */
355c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, NM_HOVER },
356c2c66affSColin Finck { 0 }
357c2c66affSColin Finck };
358c2c66affSColin Finck
359c2c66affSColin Finck static const struct message listview_destroy[] = {
360c2c66affSColin Finck { 0x0090, sent|optional }, /* Vista */
361c2c66affSColin Finck { WM_PARENTNOTIFY, sent },
362c2c66affSColin Finck { WM_SHOWWINDOW, sent },
363c2c66affSColin Finck { WM_WINDOWPOSCHANGING, sent },
364c2c66affSColin Finck { WM_WINDOWPOSCHANGED, sent|optional },
365c2c66affSColin Finck { WM_DESTROY, sent },
366c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_DELETEALLITEMS },
367c2c66affSColin Finck { WM_NCDESTROY, sent },
368c2c66affSColin Finck { 0 }
369c2c66affSColin Finck };
370c2c66affSColin Finck
371c2c66affSColin Finck static const struct message listview_ownerdata_destroy[] = {
372c2c66affSColin Finck { 0x0090, sent|optional }, /* Vista */
373c2c66affSColin Finck { WM_PARENTNOTIFY, sent },
374c2c66affSColin Finck { WM_SHOWWINDOW, sent },
375c2c66affSColin Finck { WM_WINDOWPOSCHANGING, sent },
376c2c66affSColin Finck { WM_WINDOWPOSCHANGED, sent|optional },
377c2c66affSColin Finck { WM_DESTROY, sent },
378c2c66affSColin Finck { WM_NCDESTROY, sent },
379c2c66affSColin Finck { 0 }
380c2c66affSColin Finck };
381c2c66affSColin Finck
382c2c66affSColin Finck static const struct message listview_ownerdata_deleteall[] = {
383c2c66affSColin Finck { LVM_DELETEALLITEMS, sent },
384c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_DELETEALLITEMS },
385c2c66affSColin Finck { 0 }
386c2c66affSColin Finck };
387c2c66affSColin Finck
388c2c66affSColin Finck static const struct message listview_header_changed_seq[] = {
389c2c66affSColin Finck { LVM_SETCOLUMNA, sent },
390c2c66affSColin Finck { WM_NOTIFY, sent|id|defwinproc, 0, 0, LISTVIEW_ID },
391c2c66affSColin Finck { WM_NOTIFY, sent|id|defwinproc, 0, 0, LISTVIEW_ID },
392c2c66affSColin Finck { 0 }
393c2c66affSColin Finck };
394c2c66affSColin Finck
395c2c66affSColin Finck static const struct message parent_header_click_seq[] = {
396c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_COLUMNCLICK },
397c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, HDN_ITEMCLICKA },
398c2c66affSColin Finck { 0 }
399c2c66affSColin Finck };
400c2c66affSColin Finck
401c2c66affSColin Finck static const struct message parent_header_divider_dclick_seq[] = {
402c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, HDN_ITEMCHANGINGA },
403c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, NM_CUSTOMDRAW },
404c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, NM_CUSTOMDRAW },
405c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, HDN_ITEMCHANGEDA },
406c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, HDN_DIVIDERDBLCLICKA },
407c2c66affSColin Finck { 0 }
408c2c66affSColin Finck };
409c2c66affSColin Finck
410c2c66affSColin Finck static const struct message listview_set_imagelist[] = {
411c2c66affSColin Finck { LVM_SETIMAGELIST, sent|id, 0, 0, LISTVIEW_ID },
412c2c66affSColin Finck { 0 }
413c2c66affSColin Finck };
414c2c66affSColin Finck
415c2c66affSColin Finck static const struct message listview_header_set_imagelist[] = {
416c2c66affSColin Finck { LVM_SETIMAGELIST, sent|id, 0, 0, LISTVIEW_ID },
417c2c66affSColin Finck { HDM_SETIMAGELIST, sent|id, 0, 0, HEADER_ID },
418c2c66affSColin Finck { 0 }
419c2c66affSColin Finck };
420c2c66affSColin Finck
421c2c66affSColin Finck static const struct message parent_insert_focused_seq[] = {
422c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
423c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
424c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
425c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
426c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, LVN_INSERTITEM },
427c2c66affSColin Finck { 0 }
428c2c66affSColin Finck };
429c2c66affSColin Finck
430c2c66affSColin Finck static const struct message parent_report_cd_seq[] = {
431c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_PREPAINT },
432c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT },
433c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT|CDDS_SUBITEM },
434c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT|CDDS_SUBITEM },
435c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT|CDDS_SUBITEM },
436c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT|CDDS_SUBITEM },
437c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT },
438c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_POSTPAINT },
439c2c66affSColin Finck { 0 }
440c2c66affSColin Finck };
441c2c66affSColin Finck
442c2c66affSColin Finck static const struct message parent_list_cd_seq[] = {
443c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_PREPAINT },
444c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPREPAINT },
445c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_ITEMPOSTPAINT },
446c2c66affSColin Finck { WM_NOTIFY, sent|id|custdraw, 0, 0, NM_CUSTOMDRAW, CDDS_POSTPAINT },
447c2c66affSColin Finck { 0 }
448c2c66affSColin Finck };
449c2c66affSColin Finck
4505f7243b5SAmine Khaldi static const struct message listview_end_label_edit[] = {
4515f7243b5SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, LVN_ENDLABELEDITA },
4525f7243b5SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING},
4535f7243b5SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
4545f7243b5SAmine Khaldi { WM_NOTIFY, sent|id|optional, 0, 0, NM_CUSTOMDRAW }, /* XP */
4555f7243b5SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, NM_SETFOCUS },
4565f7243b5SAmine Khaldi { 0 }
4575f7243b5SAmine Khaldi };
4585f7243b5SAmine Khaldi
4595f7243b5SAmine Khaldi static const struct message listview_end_label_edit_kill_focus[] = {
4605f7243b5SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, LVN_ENDLABELEDITA },
4615f7243b5SAmine Khaldi { WM_COMMAND, sent|id|optional, 0, 0, EN_KILLFOCUS }, /* todo: not sent by wine yet */
4625f7243b5SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGING },
4635f7243b5SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, LVN_ITEMCHANGED },
4645f7243b5SAmine Khaldi { WM_NOTIFY, sent|id|optional, 0, 0, NM_CUSTOMDRAW }, /* XP */
4655f7243b5SAmine Khaldi { WM_NOTIFY, sent|id, 0, 0, NM_SETFOCUS },
4665f7243b5SAmine Khaldi { 0 }
4675f7243b5SAmine Khaldi };
4685f7243b5SAmine Khaldi
parent_wnd_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)469c2c66affSColin Finck static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
470c2c66affSColin Finck {
471c2c66affSColin Finck static LONG defwndproc_counter = 0;
472c2c66affSColin Finck LRESULT ret;
473c2c66affSColin Finck struct message msg;
474c2c66affSColin Finck
475c2c66affSColin Finck msg.message = message;
476c2c66affSColin Finck msg.flags = sent|wparam|lparam;
477c2c66affSColin Finck if (defwndproc_counter) msg.flags |= defwinproc;
478c2c66affSColin Finck msg.wParam = wParam;
479c2c66affSColin Finck msg.lParam = lParam;
480c2c66affSColin Finck if (message == WM_NOTIFY && lParam) msg.id = ((NMHDR*)lParam)->code;
4815f7243b5SAmine Khaldi if (message == WM_COMMAND) msg.id = HIWORD(wParam);
482c2c66affSColin Finck
483c2c66affSColin Finck /* log system messages, except for painting */
484c2c66affSColin Finck if (message < WM_USER &&
485c2c66affSColin Finck message != WM_PAINT &&
486c2c66affSColin Finck message != WM_ERASEBKGND &&
487c2c66affSColin Finck message != WM_NCPAINT &&
488c2c66affSColin Finck message != WM_NCHITTEST &&
489c2c66affSColin Finck message != WM_GETTEXT &&
490c2c66affSColin Finck message != WM_GETICON &&
491c2c66affSColin Finck message != WM_DEVICECHANGE)
492c2c66affSColin Finck {
493c2c66affSColin Finck add_message(sequences, PARENT_SEQ_INDEX, &msg);
494c2c66affSColin Finck add_message(sequences, COMBINED_SEQ_INDEX, &msg);
495c2c66affSColin Finck }
496c2c66affSColin Finck add_message(sequences, PARENT_FULL_SEQ_INDEX, &msg);
497c2c66affSColin Finck
498c2c66affSColin Finck switch (message)
499c2c66affSColin Finck {
500c2c66affSColin Finck case WM_NOTIFY:
501c2c66affSColin Finck {
502c2c66affSColin Finck switch (((NMHDR*)lParam)->code)
503c2c66affSColin Finck {
504c2c66affSColin Finck case LVN_BEGINLABELEDITA:
505c2c66affSColin Finck {
506c2c66affSColin Finck HWND edit = NULL;
507c2c66affSColin Finck
508c2c66affSColin Finck /* subclass edit box */
509c2c66affSColin Finck if (!blockEdit)
510c2c66affSColin Finck edit = subclass_editbox(((NMHDR*)lParam)->hwndFrom);
511c2c66affSColin Finck
512c2c66affSColin Finck if (edit)
513c2c66affSColin Finck {
514c2c66affSColin Finck INT len = SendMessageA(edit, EM_GETLIMITTEXT, 0, 0);
515c2c66affSColin Finck ok(len == 259 || broken(len == 260) /* includes NULL in NT4 */,
516c2c66affSColin Finck "text limit %d, expected 259\n", len);
517c2c66affSColin Finck }
518c2c66affSColin Finck
519c2c66affSColin Finck return blockEdit;
520c2c66affSColin Finck }
521c2c66affSColin Finck case LVN_ENDLABELEDITA:
522c2c66affSColin Finck {
523c2c66affSColin Finck HWND edit;
524c2c66affSColin Finck
525c2c66affSColin Finck /* always accept new item text */
526c2c66affSColin Finck NMLVDISPINFOA *di = (NMLVDISPINFOA*)lParam;
527c2c66affSColin Finck g_editbox_disp_info = *di;
528c2c66affSColin Finck
529c2c66affSColin Finck /* edit control still available from this notification */
530c2c66affSColin Finck edit = (HWND)SendMessageA(((NMHDR*)lParam)->hwndFrom, LVM_GETEDITCONTROL, 0, 0);
531c2c66affSColin Finck ok(IsWindow(edit), "expected valid edit control handle\n");
532c2c66affSColin Finck ok((GetWindowLongA(edit, GWL_STYLE) & ES_MULTILINE) == 0, "edit is multiline\n");
533c2c66affSColin Finck
5345f7243b5SAmine Khaldi if (g_WM_KILLFOCUS_on_LVN_ENDLABELEDIT)
5355f7243b5SAmine Khaldi SendMessageA(edit, WM_KILLFOCUS, 0, 0);
5365f7243b5SAmine Khaldi
537c2c66affSColin Finck return TRUE;
538c2c66affSColin Finck }
539c2c66affSColin Finck case LVN_ITEMCHANGING:
540c2c66affSColin Finck {
541c2c66affSColin Finck NMLISTVIEW *nmlv = (NMLISTVIEW*)lParam;
542c2c66affSColin Finck g_nmlistview_changing = *nmlv;
543c2c66affSColin Finck }
544c2c66affSColin Finck break;
545c2c66affSColin Finck case LVN_ITEMCHANGED:
546c2c66affSColin Finck {
547c2c66affSColin Finck NMLISTVIEW *nmlv = (NMLISTVIEW*)lParam;
548c2c66affSColin Finck g_nmlistview = *nmlv;
549c2c66affSColin Finck }
550c2c66affSColin Finck break;
551c2c66affSColin Finck case LVN_GETDISPINFOA:
552c2c66affSColin Finck {
553c2c66affSColin Finck NMLVDISPINFOA *dispinfo = (NMLVDISPINFOA*)lParam;
554c2c66affSColin Finck g_itema = dispinfo->item;
555c2c66affSColin Finck
556c2c66affSColin Finck if (g_disp_A_to_W && (dispinfo->item.mask & LVIF_TEXT))
557c2c66affSColin Finck {
558c2c66affSColin Finck static const WCHAR testW[] = {'T','E','S','T',0};
559c2c66affSColin Finck dispinfo->hdr.code = LVN_GETDISPINFOW;
560c2c66affSColin Finck memcpy(dispinfo->item.pszText, testW, sizeof(testW));
561c2c66affSColin Finck }
562c2c66affSColin Finck
563c2c66affSColin Finck /* test control buffer size for text, 10 used to mask cases when control
564c2c66affSColin Finck is using caller buffer to process LVM_GETITEM for example */
565c2c66affSColin Finck if (dispinfo->item.mask & LVIF_TEXT && dispinfo->item.cchTextMax > 10)
566c2c66affSColin Finck ok(dispinfo->item.cchTextMax == 260 ||
567c2c66affSColin Finck broken(dispinfo->item.cchTextMax == 264) /* NT4 reports aligned size */,
568c2c66affSColin Finck "buffer size %d\n", dispinfo->item.cchTextMax);
569c2c66affSColin Finck }
570c2c66affSColin Finck break;
571c2c66affSColin Finck case LVN_DELETEITEM:
572c2c66affSColin Finck if (g_focus_test_LVN_DELETEITEM)
573c2c66affSColin Finck {
574c2c66affSColin Finck NMLISTVIEW *nmlv = (NMLISTVIEW*)lParam;
575c2c66affSColin Finck UINT state;
576c2c66affSColin Finck
577c2c66affSColin Finck state = SendMessageA(((NMHDR*)lParam)->hwndFrom, LVM_GETITEMSTATE, nmlv->iItem, LVIS_FOCUSED);
578c2c66affSColin Finck ok(state == 0, "got state %x\n", state);
579c2c66affSColin Finck }
580c2c66affSColin Finck break;
581c2c66affSColin Finck case NM_HOVER:
582c2c66affSColin Finck if (g_block_hover) return 1;
583c2c66affSColin Finck break;
584c2c66affSColin Finck }
585c2c66affSColin Finck break;
586c2c66affSColin Finck }
587c2c66affSColin Finck case WM_NOTIFYFORMAT:
588c2c66affSColin Finck {
589c2c66affSColin Finck /* force to return format */
590c2c66affSColin Finck if (lParam == NF_QUERY && notifyFormat != -1) return notifyFormat;
591c2c66affSColin Finck break;
592c2c66affSColin Finck }
593c2c66affSColin Finck }
594c2c66affSColin Finck
595c2c66affSColin Finck defwndproc_counter++;
596c2c66affSColin Finck if (IsWindowUnicode(hwnd))
597c2c66affSColin Finck ret = DefWindowProcW(hwnd, message, wParam, lParam);
598c2c66affSColin Finck else
599c2c66affSColin Finck ret = DefWindowProcA(hwnd, message, wParam, lParam);
600c2c66affSColin Finck defwndproc_counter--;
601c2c66affSColin Finck
602c2c66affSColin Finck return ret;
603c2c66affSColin Finck }
604c2c66affSColin Finck
register_parent_wnd_class(BOOL Unicode)605c2c66affSColin Finck static BOOL register_parent_wnd_class(BOOL Unicode)
606c2c66affSColin Finck {
607c2c66affSColin Finck WNDCLASSA clsA;
608c2c66affSColin Finck WNDCLASSW clsW;
609c2c66affSColin Finck
610c2c66affSColin Finck if (Unicode)
611c2c66affSColin Finck {
612c2c66affSColin Finck clsW.style = 0;
613c2c66affSColin Finck clsW.lpfnWndProc = parent_wnd_proc;
614c2c66affSColin Finck clsW.cbClsExtra = 0;
615c2c66affSColin Finck clsW.cbWndExtra = 0;
616c2c66affSColin Finck clsW.hInstance = GetModuleHandleW(NULL);
617c2c66affSColin Finck clsW.hIcon = 0;
618c2c66affSColin Finck clsW.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
619c2c66affSColin Finck clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
620c2c66affSColin Finck clsW.lpszMenuName = NULL;
621c2c66affSColin Finck clsW.lpszClassName = testparentclassW;
622c2c66affSColin Finck }
623c2c66affSColin Finck else
624c2c66affSColin Finck {
625c2c66affSColin Finck clsA.style = 0;
626c2c66affSColin Finck clsA.lpfnWndProc = parent_wnd_proc;
627c2c66affSColin Finck clsA.cbClsExtra = 0;
628c2c66affSColin Finck clsA.cbWndExtra = 0;
629c2c66affSColin Finck clsA.hInstance = GetModuleHandleA(NULL);
630c2c66affSColin Finck clsA.hIcon = 0;
631c2c66affSColin Finck clsA.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
632c2c66affSColin Finck clsA.hbrBackground = GetStockObject(WHITE_BRUSH);
633c2c66affSColin Finck clsA.lpszMenuName = NULL;
634c2c66affSColin Finck clsA.lpszClassName = "Listview test parent class";
635c2c66affSColin Finck }
636c2c66affSColin Finck
637c2c66affSColin Finck return Unicode ? RegisterClassW(&clsW) : RegisterClassA(&clsA);
638c2c66affSColin Finck }
639c2c66affSColin Finck
create_parent_window(BOOL Unicode)640c2c66affSColin Finck static HWND create_parent_window(BOOL Unicode)
641c2c66affSColin Finck {
642c2c66affSColin Finck static const WCHAR nameW[] = {'t','e','s','t','p','a','r','e','n','t','n','a','m','e','W',0};
643c2c66affSColin Finck HWND hwnd;
644c2c66affSColin Finck
645c2c66affSColin Finck if (!register_parent_wnd_class(Unicode))
646c2c66affSColin Finck return NULL;
647c2c66affSColin Finck
648c2c66affSColin Finck blockEdit = FALSE;
649c2c66affSColin Finck notifyFormat = -1;
650c2c66affSColin Finck
651c2c66affSColin Finck if (Unicode)
652c2c66affSColin Finck hwnd = CreateWindowExW(0, testparentclassW, nameW,
653c2c66affSColin Finck WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
654c2c66affSColin Finck WS_MAXIMIZEBOX | WS_VISIBLE,
655c2c66affSColin Finck 0, 0, 100, 100,
656c2c66affSColin Finck GetDesktopWindow(), NULL, GetModuleHandleW(NULL), NULL);
657c2c66affSColin Finck else
658c2c66affSColin Finck hwnd = CreateWindowExA(0, "Listview test parent class",
659c2c66affSColin Finck "Listview test parent window",
660c2c66affSColin Finck WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
661c2c66affSColin Finck WS_MAXIMIZEBOX | WS_VISIBLE,
662c2c66affSColin Finck 0, 0, 100, 100,
663c2c66affSColin Finck GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
664c2c66affSColin Finck SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
665c2c66affSColin Finck return hwnd;
666c2c66affSColin Finck }
667c2c66affSColin Finck
listview_subclass_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)668c2c66affSColin Finck static LRESULT WINAPI listview_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
669c2c66affSColin Finck {
670c2c66affSColin Finck WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
671c2c66affSColin Finck static LONG defwndproc_counter = 0;
672c2c66affSColin Finck LRESULT ret;
673c2c66affSColin Finck struct message msg;
674c2c66affSColin Finck
675c2c66affSColin Finck msg.message = message;
676c2c66affSColin Finck msg.flags = sent|wparam|lparam;
677c2c66affSColin Finck if (defwndproc_counter) msg.flags |= defwinproc;
678c2c66affSColin Finck msg.wParam = wParam;
679c2c66affSColin Finck msg.lParam = lParam;
680c2c66affSColin Finck msg.id = LISTVIEW_ID;
681c2c66affSColin Finck add_message(sequences, LISTVIEW_SEQ_INDEX, &msg);
682c2c66affSColin Finck add_message(sequences, COMBINED_SEQ_INDEX, &msg);
683c2c66affSColin Finck
684c2c66affSColin Finck defwndproc_counter++;
685c2c66affSColin Finck ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
686c2c66affSColin Finck defwndproc_counter--;
687c2c66affSColin Finck return ret;
688c2c66affSColin Finck }
689c2c66affSColin Finck
create_listview_control(DWORD style)690c2c66affSColin Finck static HWND create_listview_control(DWORD style)
691c2c66affSColin Finck {
692c2c66affSColin Finck WNDPROC oldproc;
693c2c66affSColin Finck HWND hwnd;
694c2c66affSColin Finck RECT rect;
695c2c66affSColin Finck
696c2c66affSColin Finck GetClientRect(hwndparent, &rect);
697c2c66affSColin Finck hwnd = CreateWindowExA(0, WC_LISTVIEWA, "foo",
698c2c66affSColin Finck WS_CHILD | WS_BORDER | WS_VISIBLE | style,
699c2c66affSColin Finck 0, 0, rect.right, rect.bottom,
700c2c66affSColin Finck hwndparent, NULL, GetModuleHandleA(NULL), NULL);
701c2c66affSColin Finck ok(hwnd != NULL, "gle=%d\n", GetLastError());
702c2c66affSColin Finck
703c2c66affSColin Finck if (!hwnd) return NULL;
704c2c66affSColin Finck
705c2c66affSColin Finck oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
706c2c66affSColin Finck (LONG_PTR)listview_subclass_proc);
707c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
708c2c66affSColin Finck
709c2c66affSColin Finck return hwnd;
710c2c66affSColin Finck }
711c2c66affSColin Finck
712c2c66affSColin Finck /* unicode listview window with specified parent */
create_listview_controlW(DWORD style,HWND parent)713c2c66affSColin Finck static HWND create_listview_controlW(DWORD style, HWND parent)
714c2c66affSColin Finck {
715c2c66affSColin Finck WNDPROC oldproc;
716c2c66affSColin Finck HWND hwnd;
717c2c66affSColin Finck RECT rect;
718c2c66affSColin Finck static const WCHAR nameW[] = {'f','o','o',0};
719c2c66affSColin Finck
720c2c66affSColin Finck GetClientRect(parent, &rect);
721c2c66affSColin Finck hwnd = CreateWindowExW(0, WC_LISTVIEWW, nameW,
722c2c66affSColin Finck WS_CHILD | WS_BORDER | WS_VISIBLE | style,
723c2c66affSColin Finck 0, 0, rect.right, rect.bottom,
724c2c66affSColin Finck parent, NULL, GetModuleHandleW(NULL), NULL);
725c2c66affSColin Finck ok(hwnd != NULL, "gle=%d\n", GetLastError());
726c2c66affSColin Finck
727c2c66affSColin Finck if (!hwnd) return NULL;
728c2c66affSColin Finck
729c2c66affSColin Finck oldproc = (WNDPROC)SetWindowLongPtrW(hwnd, GWLP_WNDPROC,
730c2c66affSColin Finck (LONG_PTR)listview_subclass_proc);
731c2c66affSColin Finck SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
732c2c66affSColin Finck
733c2c66affSColin Finck return hwnd;
734c2c66affSColin Finck }
735c2c66affSColin Finck
is_win_xp(void)736f37104daSAmine Khaldi static BOOL is_win_xp(void)
737f37104daSAmine Khaldi {
738f37104daSAmine Khaldi HWND hwnd, header;
739f37104daSAmine Khaldi BOOL ret;
740f37104daSAmine Khaldi
741f37104daSAmine Khaldi hwnd = create_listview_control(LVS_ICON);
742f37104daSAmine Khaldi SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_HEADERINALLVIEWS, LVS_EX_HEADERINALLVIEWS);
743f37104daSAmine Khaldi header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
744f37104daSAmine Khaldi ret = !IsWindow(header);
745f37104daSAmine Khaldi
746f37104daSAmine Khaldi DestroyWindow(hwnd);
747f37104daSAmine Khaldi
748f37104daSAmine Khaldi return ret;
749f37104daSAmine Khaldi }
750f37104daSAmine Khaldi
header_subclass_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)751c2c66affSColin Finck static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
752c2c66affSColin Finck {
753c2c66affSColin Finck WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
754c2c66affSColin Finck static LONG defwndproc_counter = 0;
755c2c66affSColin Finck struct message msg = { 0 };
756c2c66affSColin Finck LRESULT ret;
757c2c66affSColin Finck
758c2c66affSColin Finck msg.message = message;
759c2c66affSColin Finck msg.flags = sent|wparam|lparam;
760c2c66affSColin Finck if (defwndproc_counter) msg.flags |= defwinproc;
761c2c66affSColin Finck msg.wParam = wParam;
762c2c66affSColin Finck msg.lParam = lParam;
763c2c66affSColin Finck msg.id = HEADER_ID;
764c2c66affSColin Finck add_message(sequences, LISTVIEW_SEQ_INDEX, &msg);
765c2c66affSColin Finck
766c2c66affSColin Finck defwndproc_counter++;
767c2c66affSColin Finck ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
768c2c66affSColin Finck defwndproc_counter--;
769c2c66affSColin Finck return ret;
770c2c66affSColin Finck }
771c2c66affSColin Finck
subclass_header(HWND hwndListview)772c2c66affSColin Finck static HWND subclass_header(HWND hwndListview)
773c2c66affSColin Finck {
774c2c66affSColin Finck WNDPROC oldproc;
775c2c66affSColin Finck HWND hwnd;
776c2c66affSColin Finck
777c2c66affSColin Finck hwnd = (HWND)SendMessageA(hwndListview, LVM_GETHEADER, 0, 0);
778c2c66affSColin Finck oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
779c2c66affSColin Finck (LONG_PTR)header_subclass_proc);
780c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
781c2c66affSColin Finck
782c2c66affSColin Finck return hwnd;
783c2c66affSColin Finck }
784c2c66affSColin Finck
editbox_subclass_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)785c2c66affSColin Finck static LRESULT WINAPI editbox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
786c2c66affSColin Finck {
787c2c66affSColin Finck WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
788c2c66affSColin Finck static LONG defwndproc_counter = 0;
789c2c66affSColin Finck struct message msg = { 0 };
790c2c66affSColin Finck LRESULT ret;
791c2c66affSColin Finck
792c2c66affSColin Finck msg.message = message;
793c2c66affSColin Finck msg.flags = sent|wparam|lparam;
794c2c66affSColin Finck if (defwndproc_counter) msg.flags |= defwinproc;
795c2c66affSColin Finck msg.wParam = wParam;
796c2c66affSColin Finck msg.lParam = lParam;
797c2c66affSColin Finck
798c2c66affSColin Finck /* all we need is sizing */
799c2c66affSColin Finck if (message == WM_WINDOWPOSCHANGING ||
800c2c66affSColin Finck message == WM_NCCALCSIZE ||
801c2c66affSColin Finck message == WM_WINDOWPOSCHANGED ||
802c2c66affSColin Finck message == WM_MOVE ||
803c2c66affSColin Finck message == WM_SIZE)
804c2c66affSColin Finck {
805c2c66affSColin Finck add_message(sequences, EDITBOX_SEQ_INDEX, &msg);
806c2c66affSColin Finck }
807c2c66affSColin Finck
808c2c66affSColin Finck defwndproc_counter++;
809c2c66affSColin Finck ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
810c2c66affSColin Finck defwndproc_counter--;
811c2c66affSColin Finck return ret;
812c2c66affSColin Finck }
813c2c66affSColin Finck
subclass_editbox(HWND hwndListview)814c2c66affSColin Finck static HWND subclass_editbox(HWND hwndListview)
815c2c66affSColin Finck {
816c2c66affSColin Finck WNDPROC oldproc;
817c2c66affSColin Finck HWND hwnd;
818c2c66affSColin Finck
819c2c66affSColin Finck hwnd = (HWND)SendMessageA(hwndListview, LVM_GETEDITCONTROL, 0, 0);
820c2c66affSColin Finck oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC,
821c2c66affSColin Finck (LONG_PTR)editbox_subclass_proc);
822c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc);
823c2c66affSColin Finck
824c2c66affSColin Finck return hwnd;
825c2c66affSColin Finck }
826c2c66affSColin Finck
827c2c66affSColin Finck /* Performs a single LVM_HITTEST test */
test_lvm_hittest_(HWND hwnd,INT x,INT y,INT item,UINT flags,UINT broken_flags,BOOL todo_item,BOOL todo_flags,int line)828c2c66affSColin Finck static void test_lvm_hittest_(HWND hwnd, INT x, INT y, INT item, UINT flags, UINT broken_flags,
829c2c66affSColin Finck BOOL todo_item, BOOL todo_flags, int line)
830c2c66affSColin Finck {
831c2c66affSColin Finck LVHITTESTINFO lpht;
832c2c66affSColin Finck INT ret;
833c2c66affSColin Finck
834c2c66affSColin Finck lpht.pt.x = x;
835c2c66affSColin Finck lpht.pt.y = y;
836c2c66affSColin Finck lpht.iSubItem = 10;
837c2c66affSColin Finck
838c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_HITTEST, 0, (LPARAM)&lpht);
839c2c66affSColin Finck
840c2c66affSColin Finck todo_wine_if(todo_item)
841c2c66affSColin Finck {
842c2c66affSColin Finck ok_(__FILE__, line)(ret == item, "Expected %d retval, got %d\n", item, ret);
843c2c66affSColin Finck ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
844c2c66affSColin Finck ok_(__FILE__, line)(lpht.iSubItem == 10, "Expected subitem not overwrited\n");
845c2c66affSColin Finck }
846c2c66affSColin Finck
847c2c66affSColin Finck if (todo_flags)
848c2c66affSColin Finck {
849c2c66affSColin Finck todo_wine
850c2c66affSColin Finck ok_(__FILE__, line)(lpht.flags == flags, "Expected flags 0x%x, got 0x%x\n", flags, lpht.flags);
851c2c66affSColin Finck }
852c2c66affSColin Finck else if (broken_flags)
853c2c66affSColin Finck ok_(__FILE__, line)(lpht.flags == flags || broken(lpht.flags == broken_flags),
854c2c66affSColin Finck "Expected flags %x, got %x\n", flags, lpht.flags);
855c2c66affSColin Finck else
856c2c66affSColin Finck ok_(__FILE__, line)(lpht.flags == flags, "Expected flags 0x%x, got 0x%x\n", flags, lpht.flags);
857c2c66affSColin Finck }
858c2c66affSColin Finck
859c2c66affSColin Finck #define test_lvm_hittest(a,b,c,d,e,f,g,h) test_lvm_hittest_(a,b,c,d,e,f,g,h,__LINE__)
860c2c66affSColin Finck
861c2c66affSColin Finck /* Performs a single LVM_SUBITEMHITTEST test */
test_lvm_subitemhittest_(HWND hwnd,INT x,INT y,INT item,INT subitem,UINT flags,BOOL todo_item,BOOL todo_subitem,BOOL todo_flags,int line)862c2c66affSColin Finck static void test_lvm_subitemhittest_(HWND hwnd, INT x, INT y, INT item, INT subitem, UINT flags,
863c2c66affSColin Finck BOOL todo_item, BOOL todo_subitem, BOOL todo_flags, int line)
864c2c66affSColin Finck {
865c2c66affSColin Finck LVHITTESTINFO lpht;
866c2c66affSColin Finck INT ret;
867c2c66affSColin Finck
868c2c66affSColin Finck lpht.pt.x = x;
869c2c66affSColin Finck lpht.pt.y = y;
870c2c66affSColin Finck
871c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SUBITEMHITTEST, 0, (LPARAM)&lpht);
872c2c66affSColin Finck
873c2c66affSColin Finck todo_wine_if(todo_item)
874c2c66affSColin Finck {
875c2c66affSColin Finck ok_(__FILE__, line)(ret == item, "Expected %d retval, got %d\n", item, ret);
876c2c66affSColin Finck ok_(__FILE__, line)(lpht.iItem == item, "Expected %d item, got %d\n", item, lpht.iItem);
877c2c66affSColin Finck }
878c2c66affSColin Finck
879c2c66affSColin Finck todo_wine_if(todo_subitem)
880c2c66affSColin Finck ok_(__FILE__, line)(lpht.iSubItem == subitem, "Expected subitem %d, got %d\n", subitem, lpht.iSubItem);
881c2c66affSColin Finck
882c2c66affSColin Finck todo_wine_if(todo_flags)
883c2c66affSColin Finck ok_(__FILE__, line)(lpht.flags == flags, "Expected flags 0x%x, got 0x%x\n", flags, lpht.flags);
884c2c66affSColin Finck }
885c2c66affSColin Finck
886c2c66affSColin Finck #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__)
887c2c66affSColin Finck
test_images(void)888c2c66affSColin Finck static void test_images(void)
889c2c66affSColin Finck {
890c2c66affSColin Finck HWND hwnd;
891c2c66affSColin Finck INT r;
892c2c66affSColin Finck LVITEMA item;
893c2c66affSColin Finck HIMAGELIST himl;
894c2c66affSColin Finck HBITMAP hbmp;
895c2c66affSColin Finck RECT r1, r2;
896c2c66affSColin Finck static CHAR hello[] = "hello";
897c2c66affSColin Finck
898f37104daSAmine Khaldi himl = pImageList_Create(40, 40, 0, 4, 4);
899c2c66affSColin Finck ok(himl != NULL, "failed to create imagelist\n");
900c2c66affSColin Finck
901c2c66affSColin Finck hbmp = CreateBitmap(40, 40, 1, 1, NULL);
902c2c66affSColin Finck ok(hbmp != NULL, "failed to create bitmap\n");
903c2c66affSColin Finck
904f37104daSAmine Khaldi r = pImageList_Add(himl, hbmp, 0);
905c2c66affSColin Finck ok(r == 0, "should be zero\n");
906c2c66affSColin Finck
907f37104daSAmine Khaldi hwnd = CreateWindowExA(0, WC_LISTVIEWA, "foo", LVS_OWNERDRAWFIXED,
908c2c66affSColin Finck 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
909c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
910c2c66affSColin Finck
911c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
912c2c66affSColin Finck LVS_EX_UNDERLINEHOT | LVS_EX_FLATSB | LVS_EX_ONECLICKACTIVATE);
913c2c66affSColin Finck
914c2c66affSColin Finck ok(r == 0, "should return zero\n");
915c2c66affSColin Finck
916c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
917c2c66affSColin Finck ok(r == 0, "should return zero\n");
918c2c66affSColin Finck
919c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELONG(100,50));
920c2c66affSColin Finck ok(r != 0, "got 0\n");
921c2c66affSColin Finck
922c2c66affSColin Finck /* returns dimensions */
923c2c66affSColin Finck
924c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
925c2c66affSColin Finck ok(r == 0, "should be zero items\n");
926c2c66affSColin Finck
927c2c66affSColin Finck item.mask = LVIF_IMAGE | LVIF_TEXT;
928c2c66affSColin Finck item.iItem = 0;
929c2c66affSColin Finck item.iSubItem = 1;
930c2c66affSColin Finck item.iImage = 0;
931c2c66affSColin Finck item.pszText = 0;
932c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
933c2c66affSColin Finck ok(r == -1, "should fail\n");
934c2c66affSColin Finck
935c2c66affSColin Finck item.iSubItem = 0;
936c2c66affSColin Finck item.pszText = hello;
937c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
938c2c66affSColin Finck ok(r == 0, "should not fail\n");
939c2c66affSColin Finck
940c2c66affSColin Finck SetRect(&r1, LVIR_ICON, 0, 0, 0);
941c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r1);
942c2c66affSColin Finck expect(1, r);
943c2c66affSColin Finck
944c2c66affSColin Finck r = SendMessageA(hwnd, LVM_DELETEALLITEMS, 0, 0);
945c2c66affSColin Finck ok(r == TRUE, "should not fail\n");
946c2c66affSColin Finck
947c2c66affSColin Finck item.iSubItem = 0;
948c2c66affSColin Finck item.pszText = hello;
949c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
950c2c66affSColin Finck ok(r == 0, "should not fail\n");
951c2c66affSColin Finck
952c2c66affSColin Finck SetRect(&r2, LVIR_ICON, 0, 0, 0);
953c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r2);
954c2c66affSColin Finck expect(1, r);
955c2c66affSColin Finck
956c2c66affSColin Finck ok(EqualRect(&r1, &r2), "rectangle should be the same\n");
957c2c66affSColin Finck
958c2c66affSColin Finck DestroyWindow(hwnd);
959*0707475fSJustin Miller
960*0707475fSJustin Miller /* I_IMAGECALLBACK set for item, try to get image with invalid subitem. */
961*0707475fSJustin Miller hwnd = create_listview_control(LVS_REPORT);
962*0707475fSJustin Miller ok(hwnd != NULL, "Failed to create listview.\n");
963*0707475fSJustin Miller
964*0707475fSJustin Miller memset(&item, 0, sizeof(item));
965*0707475fSJustin Miller item.mask = LVIF_IMAGE;
966*0707475fSJustin Miller item.iImage = I_IMAGECALLBACK;
967*0707475fSJustin Miller r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
968*0707475fSJustin Miller ok(!r, "Failed to insert item.\n");
969*0707475fSJustin Miller
970*0707475fSJustin Miller flush_sequences(sequences, NUM_MSG_SEQUENCES);
971*0707475fSJustin Miller
972*0707475fSJustin Miller memset(&item, 0, sizeof(item));
973*0707475fSJustin Miller item.mask = LVIF_IMAGE;
974*0707475fSJustin Miller r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
975*0707475fSJustin Miller ok(r, "Failed to get item.\n");
976*0707475fSJustin Miller
977*0707475fSJustin Miller ok_sequence(sequences, PARENT_SEQ_INDEX, single_getdispinfo_parent_seq, "get image dispinfo 1", FALSE);
978*0707475fSJustin Miller
979*0707475fSJustin Miller flush_sequences(sequences, NUM_MSG_SEQUENCES);
980*0707475fSJustin Miller
981*0707475fSJustin Miller memset(&item, 0, sizeof(item));
982*0707475fSJustin Miller item.mask = LVIF_IMAGE;
983*0707475fSJustin Miller item.iSubItem = 1;
984*0707475fSJustin Miller r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
985*0707475fSJustin Miller ok(r, "Failed to get item.\n");
986*0707475fSJustin Miller
987*0707475fSJustin Miller ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "get image dispinfo 2", FALSE);
988*0707475fSJustin Miller
989*0707475fSJustin Miller DestroyWindow(hwnd);
990c2c66affSColin Finck }
991c2c66affSColin Finck
test_checkboxes(void)992c2c66affSColin Finck static void test_checkboxes(void)
993c2c66affSColin Finck {
994c2c66affSColin Finck HWND hwnd;
995c2c66affSColin Finck LVITEMA item;
996c2c66affSColin Finck DWORD r;
997c2c66affSColin Finck static CHAR text[] = "Text",
998c2c66affSColin Finck text2[] = "Text2",
999c2c66affSColin Finck text3[] = "Text3";
1000c2c66affSColin Finck
1001f37104daSAmine Khaldi hwnd = CreateWindowExA(0, WC_LISTVIEWA, "foo", LVS_REPORT,
1002c2c66affSColin Finck 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
1003c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
1004c2c66affSColin Finck
1005c2c66affSColin Finck /* first without LVS_EX_CHECKBOXES set and an item and check that state is preserved */
1006c2c66affSColin Finck item.mask = LVIF_TEXT | LVIF_STATE;
1007c2c66affSColin Finck item.stateMask = 0xffff;
1008c2c66affSColin Finck item.state = 0xfccc;
1009c2c66affSColin Finck item.iItem = 0;
1010c2c66affSColin Finck item.iSubItem = 0;
1011c2c66affSColin Finck item.pszText = text;
1012c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1013c2c66affSColin Finck expect(0, r);
1014c2c66affSColin Finck
1015c2c66affSColin Finck item.iItem = 0;
1016c2c66affSColin Finck item.mask = LVIF_STATE;
1017c2c66affSColin Finck item.stateMask = 0xffff;
1018c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1019c2c66affSColin Finck expect(1, r);
1020c2c66affSColin Finck ok(item.state == 0xfccc, "state %x\n", item.state);
1021c2c66affSColin Finck
1022c2c66affSColin Finck /* Don't set LVIF_STATE */
1023c2c66affSColin Finck item.mask = LVIF_TEXT;
1024c2c66affSColin Finck item.stateMask = 0xffff;
1025c2c66affSColin Finck item.state = 0xfccc;
1026c2c66affSColin Finck item.iItem = 1;
1027c2c66affSColin Finck item.iSubItem = 0;
1028c2c66affSColin Finck item.pszText = text;
1029c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1030c2c66affSColin Finck expect(1, r);
1031c2c66affSColin Finck
1032c2c66affSColin Finck item.iItem = 1;
1033c2c66affSColin Finck item.mask = LVIF_STATE;
1034c2c66affSColin Finck item.stateMask = 0xffff;
1035c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1036c2c66affSColin Finck expect(1, r);
1037c2c66affSColin Finck ok(item.state == 0, "state %x\n", item.state);
1038c2c66affSColin Finck
1039c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
1040c2c66affSColin Finck expect(0, r);
1041c2c66affSColin Finck
1042c2c66affSColin Finck /* Having turned on checkboxes, check that all existing items are set to 0x1000 (unchecked) */
1043c2c66affSColin Finck item.iItem = 0;
1044c2c66affSColin Finck item.mask = LVIF_STATE;
1045c2c66affSColin Finck item.stateMask = 0xffff;
1046c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1047c2c66affSColin Finck expect(1, r);
1048c2c66affSColin Finck if (item.state != 0x1ccc)
1049c2c66affSColin Finck {
1050c2c66affSColin Finck win_skip("LVS_EX_CHECKBOXES style is unavailable. Skipping.\n");
1051c2c66affSColin Finck DestroyWindow(hwnd);
1052c2c66affSColin Finck return;
1053c2c66affSColin Finck }
1054c2c66affSColin Finck
1055c2c66affSColin Finck /* Now add an item without specifying a state and check that its state goes to 0x1000 */
1056c2c66affSColin Finck item.iItem = 2;
1057c2c66affSColin Finck item.mask = LVIF_TEXT;
1058c2c66affSColin Finck item.state = 0;
1059c2c66affSColin Finck item.pszText = text2;
1060c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1061c2c66affSColin Finck expect(2, r);
1062c2c66affSColin Finck
1063c2c66affSColin Finck item.iItem = 2;
1064c2c66affSColin Finck item.mask = LVIF_STATE;
1065c2c66affSColin Finck item.stateMask = 0xffff;
1066c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1067c2c66affSColin Finck expect(1, r);
1068c2c66affSColin Finck ok(item.state == 0x1000, "state %x\n", item.state);
1069c2c66affSColin Finck
1070c2c66affSColin Finck /* Add a further item this time specifying a state and still its state goes to 0x1000 */
1071c2c66affSColin Finck item.iItem = 3;
1072c2c66affSColin Finck item.mask = LVIF_TEXT | LVIF_STATE;
1073c2c66affSColin Finck item.stateMask = 0xffff;
1074c2c66affSColin Finck item.state = 0x2aaa;
1075c2c66affSColin Finck item.pszText = text3;
1076c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1077c2c66affSColin Finck expect(3, r);
1078c2c66affSColin Finck
1079c2c66affSColin Finck item.iItem = 3;
1080c2c66affSColin Finck item.mask = LVIF_STATE;
1081c2c66affSColin Finck item.stateMask = 0xffff;
1082c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1083c2c66affSColin Finck expect(1, r);
1084c2c66affSColin Finck ok(item.state == 0x1aaa, "state %x\n", item.state);
1085c2c66affSColin Finck
1086c2c66affSColin Finck /* Set an item's state to checked */
1087c2c66affSColin Finck item.iItem = 3;
1088c2c66affSColin Finck item.mask = LVIF_STATE;
1089c2c66affSColin Finck item.stateMask = 0xf000;
1090c2c66affSColin Finck item.state = 0x2000;
1091c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1092c2c66affSColin Finck expect(1, r);
1093c2c66affSColin Finck
1094c2c66affSColin Finck item.iItem = 3;
1095c2c66affSColin Finck item.mask = LVIF_STATE;
1096c2c66affSColin Finck item.stateMask = 0xffff;
1097c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1098c2c66affSColin Finck expect(1, r);
1099c2c66affSColin Finck ok(item.state == 0x2aaa, "state %x\n", item.state);
1100c2c66affSColin Finck
1101c2c66affSColin Finck /* Check that only the bits we asked for are returned,
1102c2c66affSColin Finck * and that all the others are set to zero
1103c2c66affSColin Finck */
1104c2c66affSColin Finck item.iItem = 3;
1105c2c66affSColin Finck item.mask = LVIF_STATE;
1106c2c66affSColin Finck item.stateMask = 0xf000;
1107c2c66affSColin Finck item.state = 0xffff;
1108c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1109c2c66affSColin Finck expect(1, r);
1110c2c66affSColin Finck ok(item.state == 0x2000, "state %x\n", item.state);
1111c2c66affSColin Finck
1112c2c66affSColin Finck /* Set the style again and check that doesn't change an item's state */
1113c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
1114c2c66affSColin Finck ok(r == LVS_EX_CHECKBOXES, "ret %x\n", r);
1115c2c66affSColin Finck
1116c2c66affSColin Finck item.iItem = 3;
1117c2c66affSColin Finck item.mask = LVIF_STATE;
1118c2c66affSColin Finck item.stateMask = 0xffff;
1119c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1120c2c66affSColin Finck expect(1, r);
1121c2c66affSColin Finck ok(item.state == 0x2aaa, "state %x\n", item.state);
1122c2c66affSColin Finck
1123c2c66affSColin Finck /* Unsetting the checkbox extended style doesn't change an item's state */
1124c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, 0);
1125c2c66affSColin Finck ok(r == LVS_EX_CHECKBOXES, "ret %x\n", r);
1126c2c66affSColin Finck
1127c2c66affSColin Finck item.iItem = 3;
1128c2c66affSColin Finck item.mask = LVIF_STATE;
1129c2c66affSColin Finck item.stateMask = 0xffff;
1130c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1131c2c66affSColin Finck expect(1, r);
1132c2c66affSColin Finck ok(item.state == 0x2aaa, "state %x\n", item.state);
1133c2c66affSColin Finck
1134c2c66affSColin Finck /* Now setting the style again will change an item's state */
1135c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
1136c2c66affSColin Finck expect(0, r);
1137c2c66affSColin Finck
1138c2c66affSColin Finck item.iItem = 3;
1139c2c66affSColin Finck item.mask = LVIF_STATE;
1140c2c66affSColin Finck item.stateMask = 0xffff;
1141c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1142c2c66affSColin Finck expect(1, r);
1143c2c66affSColin Finck ok(item.state == 0x1aaa, "state %x\n", item.state);
1144c2c66affSColin Finck
1145c2c66affSColin Finck /* Toggle checkbox tests (bug 9934) */
1146c2c66affSColin Finck memset (&item, 0xcc, sizeof(item));
1147c2c66affSColin Finck item.mask = LVIF_STATE;
1148c2c66affSColin Finck item.iItem = 3;
1149c2c66affSColin Finck item.iSubItem = 0;
1150c2c66affSColin Finck item.state = LVIS_FOCUSED;
1151c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
1152c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1153c2c66affSColin Finck expect(1, r);
1154c2c66affSColin Finck
1155c2c66affSColin Finck item.iItem = 3;
1156c2c66affSColin Finck item.mask = LVIF_STATE;
1157c2c66affSColin Finck item.stateMask = 0xffff;
1158c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1159c2c66affSColin Finck expect(1, r);
1160c2c66affSColin Finck ok(item.state == 0x1aab, "state %x\n", item.state);
1161c2c66affSColin Finck
1162c2c66affSColin Finck r = SendMessageA(hwnd, WM_KEYDOWN, VK_SPACE, 0);
1163c2c66affSColin Finck expect(0, r);
1164c2c66affSColin Finck r = SendMessageA(hwnd, WM_KEYUP, VK_SPACE, 0);
1165c2c66affSColin Finck expect(0, r);
1166c2c66affSColin Finck
1167c2c66affSColin Finck item.iItem = 3;
1168c2c66affSColin Finck item.mask = LVIF_STATE;
1169c2c66affSColin Finck item.stateMask = 0xffff;
1170c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1171c2c66affSColin Finck expect(1, r);
1172c2c66affSColin Finck ok(item.state == 0x2aab, "state %x\n", item.state);
1173c2c66affSColin Finck
1174c2c66affSColin Finck r = SendMessageA(hwnd, WM_KEYDOWN, VK_SPACE, 0);
1175c2c66affSColin Finck expect(0, r);
1176c2c66affSColin Finck r = SendMessageA(hwnd, WM_KEYUP, VK_SPACE, 0);
1177c2c66affSColin Finck expect(0, r);
1178c2c66affSColin Finck
1179c2c66affSColin Finck item.iItem = 3;
1180c2c66affSColin Finck item.mask = LVIF_STATE;
1181c2c66affSColin Finck item.stateMask = 0xffff;
1182c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1183c2c66affSColin Finck expect(1, r);
1184c2c66affSColin Finck ok(item.state == 0x1aab, "state %x\n", item.state);
1185c2c66affSColin Finck
1186c2c66affSColin Finck DestroyWindow(hwnd);
1187c2c66affSColin Finck }
1188c2c66affSColin Finck
insert_column(HWND hwnd,int idx)1189c2c66affSColin Finck static void insert_column(HWND hwnd, int idx)
1190c2c66affSColin Finck {
1191c2c66affSColin Finck LVCOLUMNA column;
1192c2c66affSColin Finck INT rc;
1193c2c66affSColin Finck
1194c2c66affSColin Finck memset(&column, 0xcc, sizeof(column));
1195c2c66affSColin Finck column.mask = LVCF_SUBITEM;
1196c2c66affSColin Finck column.iSubItem = idx;
1197c2c66affSColin Finck
1198c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_INSERTCOLUMNA, idx, (LPARAM)&column);
1199c2c66affSColin Finck expect(idx, rc);
1200c2c66affSColin Finck }
1201c2c66affSColin Finck
insert_item(HWND hwnd,int idx)1202c2c66affSColin Finck static void insert_item(HWND hwnd, int idx)
1203c2c66affSColin Finck {
1204c2c66affSColin Finck static CHAR text[] = "foo";
1205c2c66affSColin Finck
1206c2c66affSColin Finck LVITEMA item;
1207c2c66affSColin Finck INT rc;
1208c2c66affSColin Finck
1209c2c66affSColin Finck memset(&item, 0xcc, sizeof (item));
1210c2c66affSColin Finck item.mask = LVIF_TEXT;
1211c2c66affSColin Finck item.iItem = idx;
1212c2c66affSColin Finck item.iSubItem = 0;
1213c2c66affSColin Finck item.pszText = text;
1214c2c66affSColin Finck
1215c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
1216c2c66affSColin Finck expect(idx, rc);
1217c2c66affSColin Finck }
1218c2c66affSColin Finck
test_items(void)1219c2c66affSColin Finck static void test_items(void)
1220c2c66affSColin Finck {
1221c2c66affSColin Finck const LPARAM lparamTest = 0x42;
1222c2c66affSColin Finck static CHAR text[] = "Text";
1223c2c66affSColin Finck char buffA[5];
1224c2c66affSColin Finck HWND hwnd;
1225c2c66affSColin Finck LVITEMA item;
1226c2c66affSColin Finck DWORD r;
1227c2c66affSColin Finck
1228f37104daSAmine Khaldi hwnd = CreateWindowExA(0, WC_LISTVIEWA, "foo", LVS_REPORT,
1229c2c66affSColin Finck 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
1230c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
1231c2c66affSColin Finck
1232c2c66affSColin Finck /*
1233c2c66affSColin Finck * Test setting/getting item params
1234c2c66affSColin Finck */
1235c2c66affSColin Finck
1236c2c66affSColin Finck /* Set up two columns */
1237c2c66affSColin Finck insert_column(hwnd, 0);
1238c2c66affSColin Finck insert_column(hwnd, 1);
1239c2c66affSColin Finck
1240c2c66affSColin Finck /* LVIS_SELECTED with zero stateMask */
1241c2c66affSColin Finck /* set */
1242c2c66affSColin Finck memset (&item, 0, sizeof (item));
1243c2c66affSColin Finck item.mask = LVIF_STATE;
1244c2c66affSColin Finck item.state = LVIS_SELECTED;
1245c2c66affSColin Finck item.stateMask = 0;
1246c2c66affSColin Finck item.iItem = 0;
1247c2c66affSColin Finck item.iSubItem = 0;
1248c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1249c2c66affSColin Finck expect(0, r);
1250c2c66affSColin Finck /* get */
1251c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1252c2c66affSColin Finck item.mask = LVIF_STATE;
1253c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
1254c2c66affSColin Finck item.state = 0;
1255c2c66affSColin Finck item.iItem = 0;
1256c2c66affSColin Finck item.iSubItem = 0;
1257c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1258c2c66affSColin Finck expect(1, r);
1259c2c66affSColin Finck ok(item.state & LVIS_SELECTED, "Expected LVIS_SELECTED\n");
1260c2c66affSColin Finck r = SendMessageA(hwnd, LVM_DELETEITEM, 0, 0);
1261c2c66affSColin Finck ok(r, "got %d\n", r);
1262c2c66affSColin Finck
1263c2c66affSColin Finck /* LVIS_SELECTED with zero stateMask */
1264c2c66affSColin Finck /* set */
1265c2c66affSColin Finck memset (&item, 0, sizeof (item));
1266c2c66affSColin Finck item.mask = LVIF_STATE;
1267c2c66affSColin Finck item.state = LVIS_FOCUSED;
1268c2c66affSColin Finck item.stateMask = 0;
1269c2c66affSColin Finck item.iItem = 0;
1270c2c66affSColin Finck item.iSubItem = 0;
1271c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1272c2c66affSColin Finck expect(0, r);
1273c2c66affSColin Finck /* get */
1274c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1275c2c66affSColin Finck item.mask = LVIF_STATE;
1276c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
1277c2c66affSColin Finck item.state = 0;
1278c2c66affSColin Finck item.iItem = 0;
1279c2c66affSColin Finck item.iSubItem = 0;
1280c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1281c2c66affSColin Finck expect(1, r);
1282c2c66affSColin Finck ok(item.state & LVIS_FOCUSED, "Expected LVIS_FOCUSED\n");
1283c2c66affSColin Finck r = SendMessageA(hwnd, LVM_DELETEITEM, 0, 0);
1284c2c66affSColin Finck ok(r, "got %d\n", r);
1285c2c66affSColin Finck
1286c2c66affSColin Finck /* LVIS_CUT with LVIS_FOCUSED stateMask */
1287c2c66affSColin Finck /* set */
1288c2c66affSColin Finck memset (&item, 0, sizeof (item));
1289c2c66affSColin Finck item.mask = LVIF_STATE;
1290c2c66affSColin Finck item.state = LVIS_CUT;
1291c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
1292c2c66affSColin Finck item.iItem = 0;
1293c2c66affSColin Finck item.iSubItem = 0;
1294c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1295c2c66affSColin Finck expect(0, r);
1296c2c66affSColin Finck /* get */
1297c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1298c2c66affSColin Finck item.mask = LVIF_STATE;
1299c2c66affSColin Finck item.stateMask = LVIS_CUT;
1300c2c66affSColin Finck item.state = 0;
1301c2c66affSColin Finck item.iItem = 0;
1302c2c66affSColin Finck item.iSubItem = 0;
1303c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1304c2c66affSColin Finck expect(1, r);
1305c2c66affSColin Finck ok(item.state & LVIS_CUT, "Expected LVIS_CUT\n");
1306c2c66affSColin Finck r = SendMessageA(hwnd, LVM_DELETEITEM, 0, 0);
1307c2c66affSColin Finck ok(r, "got %d\n", r);
1308c2c66affSColin Finck
1309c2c66affSColin Finck /* Insert an item with just a param */
1310c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1311c2c66affSColin Finck item.mask = LVIF_PARAM;
1312c2c66affSColin Finck item.iItem = 0;
1313c2c66affSColin Finck item.iSubItem = 0;
1314c2c66affSColin Finck item.lParam = lparamTest;
1315c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1316c2c66affSColin Finck expect(0, r);
1317c2c66affSColin Finck
1318c2c66affSColin Finck /* Test getting of the param */
1319c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1320c2c66affSColin Finck item.mask = LVIF_PARAM;
1321c2c66affSColin Finck item.iItem = 0;
1322c2c66affSColin Finck item.iSubItem = 0;
1323c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1324c2c66affSColin Finck expect(1, r);
1325c2c66affSColin Finck ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
1326c2c66affSColin Finck
1327c2c66affSColin Finck /* Set up a subitem */
1328c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1329c2c66affSColin Finck item.mask = LVIF_TEXT;
1330c2c66affSColin Finck item.iItem = 0;
1331c2c66affSColin Finck item.iSubItem = 1;
1332c2c66affSColin Finck item.pszText = text;
1333c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1334c2c66affSColin Finck expect(1, r);
1335c2c66affSColin Finck
1336c2c66affSColin Finck item.mask = LVIF_TEXT;
1337c2c66affSColin Finck item.iItem = 0;
1338c2c66affSColin Finck item.iSubItem = 1;
1339c2c66affSColin Finck item.pszText = buffA;
1340c2c66affSColin Finck item.cchTextMax = sizeof(buffA);
1341c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1342c2c66affSColin Finck expect(1, r);
1343c2c66affSColin Finck ok(!memcmp(item.pszText, text, sizeof(text)), "got text %s, expected %s\n", item.pszText, text);
1344c2c66affSColin Finck
1345c2c66affSColin Finck /* set up with extra flag */
1346c2c66affSColin Finck /* 1. reset subitem text */
1347c2c66affSColin Finck item.mask = LVIF_TEXT;
1348c2c66affSColin Finck item.iItem = 0;
1349c2c66affSColin Finck item.iSubItem = 1;
1350c2c66affSColin Finck item.pszText = NULL;
1351c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1352c2c66affSColin Finck expect(1, r);
1353c2c66affSColin Finck
1354c2c66affSColin Finck item.mask = LVIF_TEXT;
1355c2c66affSColin Finck item.iItem = 0;
1356c2c66affSColin Finck item.iSubItem = 1;
1357c2c66affSColin Finck item.pszText = buffA;
1358c2c66affSColin Finck buffA[0] = 'a';
1359c2c66affSColin Finck item.cchTextMax = sizeof(buffA);
1360c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1361c2c66affSColin Finck expect(1, r);
1362c2c66affSColin Finck ok(item.pszText[0] == 0, "got %p\n", item.pszText);
1363c2c66affSColin Finck
1364c2c66affSColin Finck /* 2. set new text with extra flag specified */
1365c2c66affSColin Finck item.mask = LVIF_TEXT | LVIF_DI_SETITEM;
1366c2c66affSColin Finck item.iItem = 0;
1367c2c66affSColin Finck item.iSubItem = 1;
1368c2c66affSColin Finck item.pszText = text;
1369c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1370c2c66affSColin Finck ok(r == 1 || broken(r == 0) /* NT4 */, "ret %d\n", r);
1371c2c66affSColin Finck
1372c2c66affSColin Finck if (r == 1)
1373c2c66affSColin Finck {
1374c2c66affSColin Finck item.mask = LVIF_TEXT;
1375c2c66affSColin Finck item.iItem = 0;
1376c2c66affSColin Finck item.iSubItem = 1;
1377c2c66affSColin Finck item.pszText = buffA;
1378c2c66affSColin Finck buffA[0] = 'a';
1379c2c66affSColin Finck item.cchTextMax = sizeof(buffA);
1380c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1381c2c66affSColin Finck expect(1, r);
1382c2c66affSColin Finck ok(!memcmp(item.pszText, text, sizeof(text)), "got %s, expected %s\n", item.pszText, text);
1383c2c66affSColin Finck }
1384c2c66affSColin Finck
1385c2c66affSColin Finck /* Query param from subitem: returns main item param */
1386c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1387c2c66affSColin Finck item.mask = LVIF_PARAM;
1388c2c66affSColin Finck item.iItem = 0;
1389c2c66affSColin Finck item.iSubItem = 1;
1390c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1391c2c66affSColin Finck expect(1, r);
1392c2c66affSColin Finck ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
1393c2c66affSColin Finck
1394c2c66affSColin Finck /* Set up param on first subitem: no effect */
1395c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1396c2c66affSColin Finck item.mask = LVIF_PARAM;
1397c2c66affSColin Finck item.iItem = 0;
1398c2c66affSColin Finck item.iSubItem = 1;
1399c2c66affSColin Finck item.lParam = lparamTest+1;
1400c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1401c2c66affSColin Finck expect(0, r);
1402c2c66affSColin Finck
1403c2c66affSColin Finck /* Query param from subitem again: should still return main item param */
1404c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1405c2c66affSColin Finck item.mask = LVIF_PARAM;
1406c2c66affSColin Finck item.iItem = 0;
1407c2c66affSColin Finck item.iSubItem = 1;
1408c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1409c2c66affSColin Finck expect(1, r);
1410c2c66affSColin Finck ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
1411c2c66affSColin Finck
1412c2c66affSColin Finck /**** Some tests of state highlighting ****/
1413c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1414c2c66affSColin Finck item.mask = LVIF_STATE;
1415c2c66affSColin Finck item.iItem = 0;
1416c2c66affSColin Finck item.iSubItem = 0;
1417c2c66affSColin Finck item.state = LVIS_SELECTED;
1418c2c66affSColin Finck item.stateMask = LVIS_SELECTED | LVIS_DROPHILITED;
1419c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1420c2c66affSColin Finck expect(1, r);
1421c2c66affSColin Finck item.iSubItem = 1;
1422c2c66affSColin Finck item.state = LVIS_DROPHILITED;
1423c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM) &item);
1424c2c66affSColin Finck expect(1, r);
1425c2c66affSColin Finck
1426c2c66affSColin Finck memset (&item, 0xcc, sizeof (item));
1427c2c66affSColin Finck item.mask = LVIF_STATE;
1428c2c66affSColin Finck item.iItem = 0;
1429c2c66affSColin Finck item.iSubItem = 0;
1430c2c66affSColin Finck item.stateMask = -1;
1431c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1432c2c66affSColin Finck expect(1, r);
1433c2c66affSColin Finck ok(item.state == LVIS_SELECTED, "got state %x, expected %x\n", item.state, LVIS_SELECTED);
1434c2c66affSColin Finck item.iSubItem = 1;
1435c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1436c2c66affSColin Finck expect(1, r);
1437c2c66affSColin Finck todo_wine ok(item.state == LVIS_DROPHILITED, "got state %x, expected %x\n", item.state, LVIS_DROPHILITED);
1438c2c66affSColin Finck
1439c2c66affSColin Finck /* some notnull but meaningless masks */
1440c2c66affSColin Finck memset (&item, 0, sizeof(item));
1441c2c66affSColin Finck item.mask = LVIF_NORECOMPUTE;
1442c2c66affSColin Finck item.iItem = 0;
1443c2c66affSColin Finck item.iSubItem = 0;
1444c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1445c2c66affSColin Finck expect(1, r);
1446c2c66affSColin Finck memset (&item, 0, sizeof(item));
1447c2c66affSColin Finck item.mask = LVIF_DI_SETITEM;
1448c2c66affSColin Finck item.iItem = 0;
1449c2c66affSColin Finck item.iSubItem = 0;
1450c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
1451c2c66affSColin Finck expect(1, r);
1452c2c66affSColin Finck
1453c2c66affSColin Finck /* set text to callback value already having it */
1454c2c66affSColin Finck r = SendMessageA(hwnd, LVM_DELETEALLITEMS, 0, 0);
1455c2c66affSColin Finck expect(TRUE, r);
1456c2c66affSColin Finck memset (&item, 0, sizeof (item));
1457c2c66affSColin Finck item.mask = LVIF_TEXT;
1458c2c66affSColin Finck item.pszText = LPSTR_TEXTCALLBACKA;
1459c2c66affSColin Finck item.iItem = 0;
1460c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
1461c2c66affSColin Finck expect(0, r);
1462c2c66affSColin Finck memset (&item, 0, sizeof (item));
1463c2c66affSColin Finck
1464c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1465c2c66affSColin Finck
1466c2c66affSColin Finck item.pszText = LPSTR_TEXTCALLBACKA;
1467c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0 , (LPARAM) &item);
1468c2c66affSColin Finck expect(TRUE, r);
1469c2c66affSColin Finck
1470c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, textcallback_set_again_parent_seq,
1471c2c66affSColin Finck "check callback text comparison rule", FALSE);
1472c2c66affSColin Finck
1473c2c66affSColin Finck DestroyWindow(hwnd);
1474c2c66affSColin Finck }
1475c2c66affSColin Finck
test_columns(void)1476c2c66affSColin Finck static void test_columns(void)
1477c2c66affSColin Finck {
1478c2c66affSColin Finck HWND hwnd, header;
1479c2c66affSColin Finck LVCOLUMNA column;
1480c2c66affSColin Finck LVITEMA item;
1481c2c66affSColin Finck INT order[2];
1482c2c66affSColin Finck CHAR buff[5];
1483c2c66affSColin Finck DWORD rc;
1484c2c66affSColin Finck
1485f37104daSAmine Khaldi hwnd = CreateWindowExA(0, WC_LISTVIEWA, "foo", LVS_LIST,
1486c2c66affSColin Finck 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
1487c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
1488c2c66affSColin Finck
1489c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
1490c2c66affSColin Finck ok(header == NULL, "got %p\n", header);
1491c2c66affSColin Finck
1492c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_GETCOLUMNORDERARRAY, 2, (LPARAM)&order);
1493c2c66affSColin Finck ok(rc == 0, "got %d\n", rc);
1494c2c66affSColin Finck
1495c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
1496c2c66affSColin Finck ok(header == NULL, "got %p\n", header);
1497c2c66affSColin Finck
1498c2c66affSColin Finck DestroyWindow(hwnd);
1499c2c66affSColin Finck
1500f37104daSAmine Khaldi hwnd = CreateWindowExA(0, WC_LISTVIEWA, "foo", LVS_REPORT,
1501c2c66affSColin Finck 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
1502c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
1503c2c66affSColin Finck
1504c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_DELETECOLUMN, -1, 0);
1505c2c66affSColin Finck ok(!rc, "got %d\n", rc);
1506c2c66affSColin Finck
1507c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_DELETECOLUMN, 0, 0);
1508c2c66affSColin Finck ok(!rc, "got %d\n", rc);
1509c2c66affSColin Finck
1510c2c66affSColin Finck /* Add a column with no mask */
1511c2c66affSColin Finck memset(&column, 0xcc, sizeof(column));
1512c2c66affSColin Finck column.mask = 0;
1513c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&column);
1514c2c66affSColin Finck ok(rc == 0, "Inserting column with no mask failed with %d\n", rc);
1515c2c66affSColin Finck
1516c2c66affSColin Finck /* Check its width */
1517c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
1518c2c66affSColin Finck ok(rc == 10, "Inserting column with no mask failed to set width to 10 with %d\n", rc);
1519c2c66affSColin Finck
1520c2c66affSColin Finck DestroyWindow(hwnd);
1521c2c66affSColin Finck
1522c2c66affSColin Finck /* LVM_GETCOLUMNORDERARRAY */
1523c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
1524c2c66affSColin Finck subclass_header(hwnd);
1525c2c66affSColin Finck
1526c2c66affSColin Finck memset(&column, 0, sizeof(column));
1527c2c66affSColin Finck column.mask = LVCF_WIDTH;
1528c2c66affSColin Finck column.cx = 100;
1529c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&column);
1530c2c66affSColin Finck expect(0, rc);
1531c2c66affSColin Finck
1532c2c66affSColin Finck column.cx = 200;
1533c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 1, (LPARAM)&column);
1534c2c66affSColin Finck expect(1, rc);
1535c2c66affSColin Finck
1536c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1537c2c66affSColin Finck
1538c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_GETCOLUMNORDERARRAY, 2, (LPARAM)&order);
1539c2c66affSColin Finck expect(1, rc);
1540c2c66affSColin Finck ok(order[0] == 0, "Expected order 0, got %d\n", order[0]);
1541c2c66affSColin Finck ok(order[1] == 1, "Expected order 1, got %d\n", order[1]);
1542c2c66affSColin Finck
1543c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_GETCOLUMNORDERARRAY, 0, 0);
1544c2c66affSColin Finck expect(0, rc);
1545c2c66affSColin Finck
1546c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_getorderarray_seq, "get order array", FALSE);
1547c2c66affSColin Finck
1548c2c66affSColin Finck /* LVM_SETCOLUMNORDERARRAY */
1549c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1550c2c66affSColin Finck
1551c2c66affSColin Finck order[0] = 0;
1552c2c66affSColin Finck order[1] = 1;
1553c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_SETCOLUMNORDERARRAY, 2, (LPARAM)&order);
1554c2c66affSColin Finck expect(1, rc);
1555c2c66affSColin Finck
1556c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_SETCOLUMNORDERARRAY, 0, 0);
1557c2c66affSColin Finck expect(0, rc);
1558c2c66affSColin Finck
1559c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_setorderarray_seq, "set order array", FALSE);
1560c2c66affSColin Finck
1561c2c66affSColin Finck /* after column added subitem is considered as present */
1562c2c66affSColin Finck insert_item(hwnd, 0);
1563c2c66affSColin Finck
1564c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1565c2c66affSColin Finck
1566c2c66affSColin Finck item.pszText = buff;
1567c2c66affSColin Finck item.cchTextMax = sizeof(buff);
1568c2c66affSColin Finck item.iItem = 0;
1569c2c66affSColin Finck item.iSubItem = 1;
1570c2c66affSColin Finck item.mask = LVIF_TEXT;
1571c2c66affSColin Finck memset(&g_itema, 0, sizeof(g_itema));
1572c2c66affSColin Finck rc = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
1573c2c66affSColin Finck expect(1, rc);
1574c2c66affSColin Finck ok(g_itema.iSubItem == 1, "got %d\n", g_itema.iSubItem);
1575c2c66affSColin Finck
1576c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, single_getdispinfo_parent_seq,
1577c2c66affSColin Finck "get subitem text after column added", FALSE);
1578c2c66affSColin Finck
1579c2c66affSColin Finck DestroyWindow(hwnd);
1580*0707475fSJustin Miller
1581*0707475fSJustin Miller /* Columns are not created right away. */
1582*0707475fSJustin Miller hwnd = create_listview_control(LVS_REPORT);
1583*0707475fSJustin Miller ok(hwnd != NULL, "Failed to create a listview window.\n");
1584*0707475fSJustin Miller
1585*0707475fSJustin Miller insert_item(hwnd, 0);
1586*0707475fSJustin Miller
1587*0707475fSJustin Miller header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
1588*0707475fSJustin Miller ok(IsWindow(header), "Expected header handle.\n");
1589*0707475fSJustin Miller rc = SendMessageA(header, HDM_GETITEMCOUNT, 0, 0);
1590*0707475fSJustin Miller ok(!rc, "Unexpected column count.\n");
1591*0707475fSJustin Miller
1592*0707475fSJustin Miller DestroyWindow(hwnd);
1593c2c66affSColin Finck }
1594c2c66affSColin Finck
1595c2c66affSColin Finck /* test setting imagelist between WM_NCCREATE and WM_CREATE */
1596c2c66affSColin Finck static WNDPROC listviewWndProc;
1597c2c66affSColin Finck static HIMAGELIST test_create_imagelist;
1598c2c66affSColin Finck
create_test_wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)1599c2c66affSColin Finck static LRESULT CALLBACK create_test_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1600c2c66affSColin Finck {
1601c2c66affSColin Finck LRESULT ret;
1602c2c66affSColin Finck
1603c2c66affSColin Finck if (uMsg == WM_CREATE)
1604c2c66affSColin Finck {
1605c2c66affSColin Finck CREATESTRUCTA *lpcs = (CREATESTRUCTA*)lParam;
1606c2c66affSColin Finck lpcs->style |= LVS_REPORT;
1607c2c66affSColin Finck }
1608c2c66affSColin Finck ret = CallWindowProcA(listviewWndProc, hwnd, uMsg, wParam, lParam);
1609c2c66affSColin Finck if (uMsg == WM_CREATE) SendMessageA(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)test_create_imagelist);
1610c2c66affSColin Finck return ret;
1611c2c66affSColin Finck }
1612c2c66affSColin Finck
1613f37104daSAmine Khaldi /* Header creation is delayed in classic implementation. */
1614f37104daSAmine Khaldi #define TEST_NO_HEADER(a) test_header_presence_(a, FALSE, __LINE__)
1615f37104daSAmine Khaldi #define TEST_HEADER_EXPECTED(a) test_header_presence_(a, TRUE, __LINE__)
1616f37104daSAmine Khaldi #define TEST_NO_HEADER2(a, b) test_header_presence_(a, b, __LINE__)
test_header_presence_(HWND hwnd,BOOL present,int line)1617f37104daSAmine Khaldi static void test_header_presence_(HWND hwnd, BOOL present, int line)
1618f37104daSAmine Khaldi {
1619f37104daSAmine Khaldi HWND header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
1620f37104daSAmine Khaldi
1621f37104daSAmine Khaldi if (present)
1622f37104daSAmine Khaldi {
1623f37104daSAmine Khaldi ok_(__FILE__, line)(IsWindow(header), "Header should have been created.\n");
1624f37104daSAmine Khaldi if (header) /* FIXME: remove when todo's are fixed */
1625f37104daSAmine Khaldi ok_(__FILE__, line)(header == GetDlgItem(hwnd, 0), "Dialog item expected.\n");
1626f37104daSAmine Khaldi }
1627f37104daSAmine Khaldi else
1628f37104daSAmine Khaldi {
1629f37104daSAmine Khaldi ok_(__FILE__, line)(!IsWindow(header), "Header shouldn't be created.\n");
1630f37104daSAmine Khaldi ok_(__FILE__, line)(NULL == GetDlgItem(hwnd, 0), "NULL dialog item expected.\n");
1631f37104daSAmine Khaldi }
1632f37104daSAmine Khaldi }
1633f37104daSAmine Khaldi
test_create(BOOL is_version_6)1634f37104daSAmine Khaldi static void test_create(BOOL is_version_6)
1635c2c66affSColin Finck {
16360d320bc2SAmine Khaldi static const WCHAR testtextW[] = {'t','e','s','t',' ','t','e','x','t',0};
16370d320bc2SAmine Khaldi char buff[16];
1638c2c66affSColin Finck HWND hList;
1639c2c66affSColin Finck HWND hHeader;
1640c2c66affSColin Finck LONG_PTR ret;
1641c2c66affSColin Finck LONG r;
1642c2c66affSColin Finck LVCOLUMNA col;
1643c2c66affSColin Finck RECT rect;
1644c2c66affSColin Finck WNDCLASSEXA cls;
1645c2c66affSColin Finck DWORD style;
1646f37104daSAmine Khaldi ATOM class;
1647f37104daSAmine Khaldi
1648f37104daSAmine Khaldi if (is_win_xp() && is_version_6)
1649f37104daSAmine Khaldi {
1650f37104daSAmine Khaldi win_skip("Skipping some tests on XP.\n");
1651f37104daSAmine Khaldi return;
1652f37104daSAmine Khaldi }
1653c2c66affSColin Finck
1654c2c66affSColin Finck cls.cbSize = sizeof(WNDCLASSEXA);
1655f37104daSAmine Khaldi r = GetClassInfoExA(GetModuleHandleA(NULL), WC_LISTVIEWA, &cls);
1656f37104daSAmine Khaldi ok(r, "Failed to get class info.\n");
1657c2c66affSColin Finck listviewWndProc = cls.lpfnWndProc;
1658c2c66affSColin Finck cls.lpfnWndProc = create_test_wndproc;
1659c2c66affSColin Finck cls.lpszClassName = "MyListView32";
1660f37104daSAmine Khaldi class = RegisterClassExA(&cls);
1661f37104daSAmine Khaldi ok(class, "Failed to register class.\n");
1662c2c66affSColin Finck
1663f37104daSAmine Khaldi test_create_imagelist = pImageList_Create(16, 16, 0, 5, 10);
1664c2c66affSColin Finck hList = CreateWindowA("MyListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
1665c2c66affSColin Finck ok((HIMAGELIST)SendMessageA(hList, LVM_GETIMAGELIST, 0, 0) == test_create_imagelist, "Image list not obtained\n");
1666c2c66affSColin Finck hHeader = (HWND)SendMessageA(hList, LVM_GETHEADER, 0, 0);
1667c2c66affSColin Finck ok(IsWindow(hHeader) && IsWindowVisible(hHeader), "Listview not in report mode\n");
1668c2c66affSColin Finck ok(hHeader == GetDlgItem(hList, 0), "Expected header as dialog item\n");
1669c2c66affSColin Finck DestroyWindow(hList);
1670c2c66affSColin Finck
1671c2c66affSColin Finck /* header isn't created on LVS_ICON and LVS_LIST styles */
1672f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
1673f37104daSAmine Khaldi TEST_NO_HEADER(hList);
1674f37104daSAmine Khaldi
1675c2c66affSColin Finck /* insert column */
1676c2c66affSColin Finck memset(&col, 0, sizeof(LVCOLUMNA));
1677c2c66affSColin Finck col.mask = LVCF_WIDTH;
1678c2c66affSColin Finck col.cx = 100;
1679c2c66affSColin Finck r = SendMessageA(hList, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
1680c2c66affSColin Finck expect(0, r);
1681f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1682c2c66affSColin Finck hHeader = (HWND)SendMessageA(hList, LVM_GETHEADER, 0, 0);
1683c2c66affSColin Finck style = GetWindowLongA(hHeader, GWL_STYLE);
1684c2c66affSColin Finck ok(!(style & HDS_HIDDEN), "Not expected HDS_HIDDEN\n");
1685c2c66affSColin Finck DestroyWindow(hList);
1686c2c66affSColin Finck
1687f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", WS_VISIBLE|LVS_LIST, 0, 0, 100, 100, NULL, NULL,
1688c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1689f37104daSAmine Khaldi TEST_NO_HEADER(hList);
1690c2c66affSColin Finck /* insert column */
1691c2c66affSColin Finck memset(&col, 0, sizeof(LVCOLUMNA));
1692c2c66affSColin Finck col.mask = LVCF_WIDTH;
1693c2c66affSColin Finck col.cx = 100;
1694c2c66affSColin Finck r = SendMessageA(hList, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
1695c2c66affSColin Finck expect(0, r);
1696f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1697c2c66affSColin Finck DestroyWindow(hList);
1698c2c66affSColin Finck
1699c2c66affSColin Finck /* try to switch LVS_ICON -> LVS_REPORT and back LVS_ICON -> LVS_REPORT */
1700f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL,
1701c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1702c2c66affSColin Finck ret = SetWindowLongPtrA(hList, GWL_STYLE, GetWindowLongPtrA(hList, GWL_STYLE) | LVS_REPORT);
1703c2c66affSColin Finck ok(ret & WS_VISIBLE, "Style wrong, should have WS_VISIBLE\n");
1704f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1705c2c66affSColin Finck ret = SetWindowLongPtrA(hList, GWL_STYLE, GetWindowLongA(hList, GWL_STYLE) & ~LVS_REPORT);
1706c2c66affSColin Finck ok((ret & WS_VISIBLE) && (ret & LVS_REPORT), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1707f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1708c2c66affSColin Finck DestroyWindow(hList);
1709c2c66affSColin Finck
1710c2c66affSColin Finck /* try to switch LVS_LIST -> LVS_REPORT and back LVS_LIST -> LVS_REPORT */
1711f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", WS_VISIBLE|LVS_LIST, 0, 0, 100, 100, NULL, NULL,
1712c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1713c2c66affSColin Finck ret = SetWindowLongPtrA(hList, GWL_STYLE,
1714c2c66affSColin Finck (GetWindowLongPtrA(hList, GWL_STYLE) & ~LVS_LIST) | LVS_REPORT);
1715c2c66affSColin Finck ok(((ret & WS_VISIBLE) && (ret & LVS_LIST)), "Style wrong, should have WS_VISIBLE|LVS_LIST\n");
1716f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1717f37104daSAmine Khaldi ret = SetWindowLongPtrA(hList, GWL_STYLE, (GetWindowLongPtrA(hList, GWL_STYLE) & ~LVS_REPORT) | LVS_LIST);
1718c2c66affSColin Finck ok(((ret & WS_VISIBLE) && (ret & LVS_REPORT)), "Style wrong, should have WS_VISIBLE|LVS_REPORT\n");
1719f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1720c2c66affSColin Finck DestroyWindow(hList);
1721c2c66affSColin Finck
1722c2c66affSColin Finck /* LVS_REPORT without WS_VISIBLE */
1723f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1724c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1725c2c66affSColin Finck hHeader = (HWND)SendMessageA(hList, LVM_GETHEADER, 0, 0);
1726f37104daSAmine Khaldi todo_wine_if(is_version_6)
1727f37104daSAmine Khaldi TEST_NO_HEADER2(hList, is_version_6);
1728f37104daSAmine Khaldi
1729c2c66affSColin Finck /* insert column */
1730c2c66affSColin Finck memset(&col, 0, sizeof(LVCOLUMNA));
1731c2c66affSColin Finck col.mask = LVCF_WIDTH;
1732c2c66affSColin Finck col.cx = 100;
1733c2c66affSColin Finck r = SendMessageA(hList, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
1734c2c66affSColin Finck expect(0, r);
1735f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1736c2c66affSColin Finck DestroyWindow(hList);
1737c2c66affSColin Finck
1738c2c66affSColin Finck /* LVS_REPORT without WS_VISIBLE, try to show it */
1739f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1740c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1741f37104daSAmine Khaldi todo_wine_if(is_version_6)
1742f37104daSAmine Khaldi TEST_NO_HEADER2(hList, is_version_6);
1743f37104daSAmine Khaldi
1744c2c66affSColin Finck ShowWindow(hList, SW_SHOW);
1745f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1746c2c66affSColin Finck DestroyWindow(hList);
1747c2c66affSColin Finck
1748c2c66affSColin Finck /* LVS_REPORT with LVS_NOCOLUMNHEADER */
1749f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", LVS_REPORT|LVS_NOCOLUMNHEADER|WS_VISIBLE,
1750c2c66affSColin Finck 0, 0, 100, 100, NULL, NULL, GetModuleHandleA(NULL), 0);
1751f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1752c2c66affSColin Finck hHeader = (HWND)SendMessageA(hList, LVM_GETHEADER, 0, 0);
1753c2c66affSColin Finck /* HDS_DRAGDROP set by default */
1754c2c66affSColin Finck ok(GetWindowLongPtrA(hHeader, GWL_STYLE) & HDS_DRAGDROP, "Expected header to have HDS_DRAGDROP\n");
1755c2c66affSColin Finck DestroyWindow(hList);
1756c2c66affSColin Finck
1757c2c66affSColin Finck /* setting LVS_EX_HEADERDRAGDROP creates header */
1758f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1759c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1760f37104daSAmine Khaldi todo_wine_if(is_version_6)
1761f37104daSAmine Khaldi TEST_NO_HEADER2(hList, is_version_6);
1762f37104daSAmine Khaldi
1763c2c66affSColin Finck SendMessageA(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_HEADERDRAGDROP);
1764f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1765c2c66affSColin Finck DestroyWindow(hList);
1766c2c66affSColin Finck
1767c2c66affSColin Finck /* setting LVS_EX_GRIDLINES creates header */
1768f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1769c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1770f37104daSAmine Khaldi todo_wine_if(is_version_6)
1771f37104daSAmine Khaldi TEST_NO_HEADER2(hList, is_version_6);
1772f37104daSAmine Khaldi
1773c2c66affSColin Finck SendMessageA(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_GRIDLINES);
1774f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1775c2c66affSColin Finck DestroyWindow(hList);
1776c2c66affSColin Finck
1777c2c66affSColin Finck /* setting LVS_EX_FULLROWSELECT creates header */
1778f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1779c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1780f37104daSAmine Khaldi todo_wine_if(is_version_6)
1781f37104daSAmine Khaldi TEST_NO_HEADER2(hList, is_version_6);
1782c2c66affSColin Finck SendMessageA(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);
1783f37104daSAmine Khaldi TEST_HEADER_EXPECTED(hList);
1784c2c66affSColin Finck DestroyWindow(hList);
1785c2c66affSColin Finck
1786c2c66affSColin Finck /* not report style accepts LVS_EX_HEADERDRAGDROP too */
1787c2c66affSColin Finck hList = create_listview_control(LVS_ICON);
1788c2c66affSColin Finck SendMessageA(hList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_HEADERDRAGDROP);
1789c2c66affSColin Finck r = SendMessageA(hList, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
1790c2c66affSColin Finck ok(r & LVS_EX_HEADERDRAGDROP, "Expected LVS_EX_HEADERDRAGDROP to be set\n");
1791c2c66affSColin Finck DestroyWindow(hList);
1792c2c66affSColin Finck
1793c2c66affSColin Finck /* requesting header info with LVM_GETSUBITEMRECT doesn't create it */
1794f37104daSAmine Khaldi hList = CreateWindowA(WC_LISTVIEWA, "Test", LVS_REPORT, 0, 0, 100, 100, NULL, NULL,
1795c2c66affSColin Finck GetModuleHandleA(NULL), 0);
1796f37104daSAmine Khaldi todo_wine_if(is_version_6)
1797f37104daSAmine Khaldi TEST_NO_HEADER2(hList, is_version_6);
1798c2c66affSColin Finck
1799c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, -10, -10);
1800c2c66affSColin Finck r = SendMessageA(hList, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
1801f37104daSAmine Khaldi ok(r == 1, "Unexpected ret value %d.\n", r);
1802c2c66affSColin Finck /* right value contains garbage, probably because header columns are not set up */
1803f37104daSAmine Khaldi ok(rect.bottom >= 0, "Unexpected rectangle.\n");
1804c2c66affSColin Finck
1805f37104daSAmine Khaldi todo_wine_if(is_version_6)
1806f37104daSAmine Khaldi TEST_NO_HEADER2(hList, is_version_6);
1807c2c66affSColin Finck DestroyWindow(hList);
1808c2c66affSColin Finck
1809c2c66affSColin Finck /* WM_MEASUREITEM should be sent when created with LVS_OWNERDRAWFIXED */
1810c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1811c2c66affSColin Finck hList = create_listview_control(LVS_OWNERDRAWFIXED | LVS_REPORT);
1812c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, create_ownerdrawfixed_parent_seq,
1813c2c66affSColin Finck "created with LVS_OWNERDRAWFIXED|LVS_REPORT - parent seq", FALSE);
1814c2c66affSColin Finck DestroyWindow(hList);
18150d320bc2SAmine Khaldi
18160d320bc2SAmine Khaldi /* Test that window text is preserved. */
18170d320bc2SAmine Khaldi hList = CreateWindowExA(0, WC_LISTVIEWA, "test text", WS_CHILD | WS_BORDER | WS_VISIBLE,
18180d320bc2SAmine Khaldi 0, 0, 100, 100, hwndparent, NULL, GetModuleHandleA(NULL), NULL);
18190d320bc2SAmine Khaldi ok(hList != NULL, "Failed to create ListView window.\n");
18200d320bc2SAmine Khaldi *buff = 0;
18210d320bc2SAmine Khaldi GetWindowTextA(hList, buff, sizeof(buff));
18220d320bc2SAmine Khaldi ok(!strcmp(buff, "test text"), "Unexpected window text %s.\n", buff);
18230d320bc2SAmine Khaldi DestroyWindow(hList);
18240d320bc2SAmine Khaldi
18250d320bc2SAmine Khaldi hList = CreateWindowExW(0, WC_LISTVIEWW, testtextW, WS_CHILD | WS_BORDER | WS_VISIBLE,
18260d320bc2SAmine Khaldi 0, 0, 100, 100, hwndparent, NULL, GetModuleHandleA(NULL), NULL);
18270d320bc2SAmine Khaldi ok(hList != NULL, "Failed to create ListView window.\n");
18280d320bc2SAmine Khaldi *buff = 0;
18290d320bc2SAmine Khaldi GetWindowTextA(hList, buff, sizeof(buff));
18300d320bc2SAmine Khaldi ok(!strcmp(buff, "test text"), "Unexpected window text %s.\n", buff);
18310d320bc2SAmine Khaldi DestroyWindow(hList);
1832f37104daSAmine Khaldi
1833f37104daSAmine Khaldi r = UnregisterClassA("MyListView32", NULL);
1834f37104daSAmine Khaldi ok(r, "Failed to unregister test class.\n");
1835c2c66affSColin Finck }
1836c2c66affSColin Finck
test_redraw(void)1837c2c66affSColin Finck static void test_redraw(void)
1838c2c66affSColin Finck {
1839c2c66affSColin Finck HWND hwnd;
1840c2c66affSColin Finck HDC hdc;
1841c2c66affSColin Finck BOOL res;
1842c2c66affSColin Finck DWORD r;
18435f7243b5SAmine Khaldi RECT rect;
1844c2c66affSColin Finck
1845c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
1846c2c66affSColin Finck subclass_header(hwnd);
1847c2c66affSColin Finck
1848c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1849c2c66affSColin Finck
1850c2c66affSColin Finck InvalidateRect(hwnd, NULL, TRUE);
1851c2c66affSColin Finck UpdateWindow(hwnd);
1852c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, redraw_listview_seq, "redraw listview", FALSE);
1853c2c66affSColin Finck
1854c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1855c2c66affSColin Finck
1856c2c66affSColin Finck /* forward WM_ERASEBKGND to parent on CLR_NONE background color */
1857c2c66affSColin Finck /* 1. Without backbuffer */
1858c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, CLR_NONE);
1859c2c66affSColin Finck expect(TRUE, res);
1860c2c66affSColin Finck
1861c2c66affSColin Finck hdc = GetWindowDC(hwndparent);
1862c2c66affSColin Finck
1863c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1864c2c66affSColin Finck r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1865c2c66affSColin Finck ok(r == 1, "Expected not zero result\n");
1866c2c66affSColin Finck ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, forward_erasebkgnd_parent_seq,
1867c2c66affSColin Finck "forward WM_ERASEBKGND on CLR_NONE", FALSE);
1868c2c66affSColin Finck
1869c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, CLR_DEFAULT);
1870c2c66affSColin Finck expect(TRUE, res);
1871c2c66affSColin Finck
1872c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1873c2c66affSColin Finck r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1874c2c66affSColin Finck expect(1, r);
1875c2c66affSColin Finck ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, empty_seq,
1876c2c66affSColin Finck "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE);
1877c2c66affSColin Finck
1878c2c66affSColin Finck /* 2. With backbuffer */
1879c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_DOUBLEBUFFER,
1880c2c66affSColin Finck LVS_EX_DOUBLEBUFFER);
1881c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, CLR_NONE);
1882c2c66affSColin Finck expect(TRUE, res);
1883c2c66affSColin Finck
1884c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1885c2c66affSColin Finck r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1886c2c66affSColin Finck expect(1, r);
1887c2c66affSColin Finck ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, forward_erasebkgnd_parent_seq,
1888c2c66affSColin Finck "forward WM_ERASEBKGND on CLR_NONE", FALSE);
1889c2c66affSColin Finck
1890c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, CLR_DEFAULT);
1891c2c66affSColin Finck expect(TRUE, res);
1892c2c66affSColin Finck
1893c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1894c2c66affSColin Finck r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
1895c2c66affSColin Finck todo_wine expect(1, r);
1896c2c66affSColin Finck ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, empty_seq,
1897c2c66affSColin Finck "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE);
1898c2c66affSColin Finck
1899c2c66affSColin Finck ReleaseDC(hwndparent, hdc);
1900c2c66affSColin Finck
19015f7243b5SAmine Khaldi /* test setting the window style to what it already was */
19025f7243b5SAmine Khaldi UpdateWindow(hwnd);
19035f7243b5SAmine Khaldi SetWindowLongA(hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE));
19045f7243b5SAmine Khaldi GetUpdateRect(hwnd, &rect, FALSE);
19055f7243b5SAmine Khaldi ok(rect.left == 0 && rect.top == 0 && rect.right == 0 && rect.bottom == 0,
19065f7243b5SAmine Khaldi "Expected empty update rect, got %s\n", wine_dbgstr_rect(&rect));
19075f7243b5SAmine Khaldi
1908c2c66affSColin Finck DestroyWindow(hwnd);
1909c2c66affSColin Finck }
1910c2c66affSColin Finck
cd_wndproc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)1911c2c66affSColin Finck static LRESULT WINAPI cd_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
1912c2c66affSColin Finck {
1913c2c66affSColin Finck COLORREF clr, c0ffee = RGB(0xc0, 0xff, 0xee);
1914c2c66affSColin Finck
1915c2c66affSColin Finck if(message == WM_NOTIFY) {
1916c2c66affSColin Finck NMHDR *nmhdr = (NMHDR*)lParam;
1917c2c66affSColin Finck if(nmhdr->code == NM_CUSTOMDRAW) {
1918c2c66affSColin Finck NMLVCUSTOMDRAW *nmlvcd = (NMLVCUSTOMDRAW*)nmhdr;
1919*0707475fSJustin Miller BOOL showsel_always = !!(GetWindowLongA(nmlvcd->nmcd.hdr.hwndFrom, GWL_STYLE) & LVS_SHOWSELALWAYS);
1920*0707475fSJustin Miller BOOL is_selected = !!(nmlvcd->nmcd.uItemState & CDIS_SELECTED);
1921c2c66affSColin Finck struct message msg;
1922c2c66affSColin Finck
1923c2c66affSColin Finck msg.message = message;
1924c2c66affSColin Finck msg.flags = sent|wparam|lparam|custdraw;
1925c2c66affSColin Finck msg.wParam = wParam;
1926c2c66affSColin Finck msg.lParam = lParam;
1927c2c66affSColin Finck msg.id = nmhdr->code;
1928c2c66affSColin Finck msg.stage = nmlvcd->nmcd.dwDrawStage;
1929c2c66affSColin Finck add_message(sequences, PARENT_CD_SEQ_INDEX, &msg);
1930c2c66affSColin Finck
1931c2c66affSColin Finck switch(nmlvcd->nmcd.dwDrawStage) {
1932c2c66affSColin Finck case CDDS_PREPAINT:
1933c2c66affSColin Finck SetBkColor(nmlvcd->nmcd.hdc, c0ffee);
1934c2c66affSColin Finck return CDRF_NOTIFYITEMDRAW|CDRF_NOTIFYPOSTPAINT;
1935c2c66affSColin Finck case CDDS_ITEMPREPAINT:
1936*0707475fSJustin Miller clr = GetBkColor(nmlvcd->nmcd.hdc);
1937*0707475fSJustin Miller todo_wine_if(nmlvcd->iSubItem)
1938*0707475fSJustin Miller ok(clr == c0ffee, "Unexpected background color %#x.\n", clr);
1939c2c66affSColin Finck nmlvcd->clrTextBk = CLR_DEFAULT;
1940c2c66affSColin Finck nmlvcd->clrText = RGB(0, 255, 0);
1941c2c66affSColin Finck return CDRF_NOTIFYSUBITEMDRAW|CDRF_NOTIFYPOSTPAINT;
1942c2c66affSColin Finck case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
1943c2c66affSColin Finck clr = GetBkColor(nmlvcd->nmcd.hdc);
1944*0707475fSJustin Miller todo_wine_if(showsel_always && is_selected && nmlvcd->iSubItem)
1945f37104daSAmine Khaldi {
1946*0707475fSJustin Miller ok(nmlvcd->clrTextBk == CLR_DEFAULT, "Unexpected text background %#x.\n", nmlvcd->clrTextBk);
1947*0707475fSJustin Miller ok(nmlvcd->clrText == RGB(0, 255, 0), "Unexpected text color %#x.\n", nmlvcd->clrText);
1948*0707475fSJustin Miller }
1949*0707475fSJustin Miller if (showsel_always && is_selected && nmlvcd->iSubItem)
1950*0707475fSJustin Miller ok(clr == GetSysColor(COLOR_3DFACE), "Unexpected background color %#x.\n", clr);
1951*0707475fSJustin Miller else
1952c2c66affSColin Finck todo_wine_if(nmlvcd->iSubItem)
1953c2c66affSColin Finck ok(clr == c0ffee, "clr=%.8x\n", clr);
1954c2c66affSColin Finck return CDRF_NOTIFYPOSTPAINT;
1955c2c66affSColin Finck case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
1956c2c66affSColin Finck clr = GetBkColor(nmlvcd->nmcd.hdc);
1957*0707475fSJustin Miller if (showsel_always && is_selected)
1958*0707475fSJustin Miller ok(clr == GetSysColor(COLOR_3DFACE), "Unexpected background color %#x.\n", clr);
1959*0707475fSJustin Miller else
1960*0707475fSJustin Miller {
1961*0707475fSJustin Miller todo_wine
1962*0707475fSJustin Miller ok(clr == c0ffee, "Unexpected background color %#x.\n", clr);
1963*0707475fSJustin Miller }
1964*0707475fSJustin Miller
1965*0707475fSJustin Miller todo_wine_if(showsel_always)
1966*0707475fSJustin Miller {
1967*0707475fSJustin Miller ok(nmlvcd->clrTextBk == CLR_DEFAULT, "Unexpected text background color %#x.\n", nmlvcd->clrTextBk);
1968c2c66affSColin Finck ok(nmlvcd->clrText == RGB(0, 255, 0), "got 0x%x\n", nmlvcd->clrText);
1969*0707475fSJustin Miller }
1970c2c66affSColin Finck return CDRF_DODEFAULT;
1971c2c66affSColin Finck }
1972c2c66affSColin Finck return CDRF_DODEFAULT;
1973c2c66affSColin Finck }
1974c2c66affSColin Finck }
1975c2c66affSColin Finck
1976c2c66affSColin Finck return DefWindowProcA(hwnd, message, wParam, lParam);
1977c2c66affSColin Finck }
1978c2c66affSColin Finck
test_customdraw(void)1979c2c66affSColin Finck static void test_customdraw(void)
1980c2c66affSColin Finck {
1981c2c66affSColin Finck HWND hwnd;
1982c2c66affSColin Finck WNDPROC oldwndproc;
1983f37104daSAmine Khaldi LVITEMA item;
1984c2c66affSColin Finck
1985c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
1986c2c66affSColin Finck
1987c2c66affSColin Finck insert_column(hwnd, 0);
1988c2c66affSColin Finck insert_column(hwnd, 1);
1989c2c66affSColin Finck insert_item(hwnd, 0);
1990c2c66affSColin Finck
1991c2c66affSColin Finck oldwndproc = (WNDPROC)SetWindowLongPtrA(hwndparent, GWLP_WNDPROC,
1992c2c66affSColin Finck (LONG_PTR)cd_wndproc);
1993c2c66affSColin Finck
1994c2c66affSColin Finck InvalidateRect(hwnd, NULL, TRUE);
1995c2c66affSColin Finck UpdateWindow(hwnd);
1996c2c66affSColin Finck
1997c2c66affSColin Finck /* message tests */
1998c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
1999c2c66affSColin Finck InvalidateRect(hwnd, NULL, TRUE);
2000c2c66affSColin Finck UpdateWindow(hwnd);
2001c2c66affSColin Finck ok_sequence(sequences, PARENT_CD_SEQ_INDEX, parent_report_cd_seq, "parent customdraw, LVS_REPORT", FALSE);
2002c2c66affSColin Finck
2003*0707475fSJustin Miller /* Check colors when item is selected. */
2004f37104daSAmine Khaldi item.mask = LVIF_STATE;
2005f37104daSAmine Khaldi item.stateMask = LVIS_SELECTED;
2006f37104daSAmine Khaldi item.state = LVIS_SELECTED;
2007f37104daSAmine Khaldi SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2008f37104daSAmine Khaldi
2009f37104daSAmine Khaldi flush_sequences(sequences, NUM_MSG_SEQUENCES);
2010f37104daSAmine Khaldi InvalidateRect(hwnd, NULL, TRUE);
2011f37104daSAmine Khaldi UpdateWindow(hwnd);
2012*0707475fSJustin Miller ok_sequence(sequences, PARENT_CD_SEQ_INDEX, parent_report_cd_seq,
2013*0707475fSJustin Miller "parent customdraw, item selected, LVS_REPORT, selection", FALSE);
2014*0707475fSJustin Miller
2015*0707475fSJustin Miller SetWindowLongW(hwnd, GWL_STYLE, GetWindowLongW(hwnd, GWL_STYLE) | LVS_SHOWSELALWAYS);
2016*0707475fSJustin Miller flush_sequences(sequences, NUM_MSG_SEQUENCES);
2017*0707475fSJustin Miller InvalidateRect(hwnd, NULL, TRUE);
2018*0707475fSJustin Miller UpdateWindow(hwnd);
2019*0707475fSJustin Miller ok_sequence(sequences, PARENT_CD_SEQ_INDEX, parent_report_cd_seq,
2020*0707475fSJustin Miller "parent customdraw, item selected, LVS_SHOWSELALWAYS, LVS_REPORT", FALSE);
2021f37104daSAmine Khaldi
2022c2c66affSColin Finck DestroyWindow(hwnd);
2023c2c66affSColin Finck
2024c2c66affSColin Finck hwnd = create_listview_control(LVS_LIST);
2025c2c66affSColin Finck
2026c2c66affSColin Finck insert_column(hwnd, 0);
2027c2c66affSColin Finck insert_column(hwnd, 1);
2028c2c66affSColin Finck insert_item(hwnd, 0);
2029c2c66affSColin Finck
2030c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2031c2c66affSColin Finck InvalidateRect(hwnd, NULL, TRUE);
2032c2c66affSColin Finck UpdateWindow(hwnd);
2033c2c66affSColin Finck ok_sequence(sequences, PARENT_CD_SEQ_INDEX, parent_list_cd_seq, "parent customdraw, LVS_LIST", FALSE);
2034c2c66affSColin Finck
2035c2c66affSColin Finck SetWindowLongPtrA(hwndparent, GWLP_WNDPROC, (LONG_PTR)oldwndproc);
2036c2c66affSColin Finck DestroyWindow(hwnd);
2037c2c66affSColin Finck }
2038c2c66affSColin Finck
test_icon_spacing(void)2039c2c66affSColin Finck static void test_icon_spacing(void)
2040c2c66affSColin Finck {
2041c2c66affSColin Finck /* LVM_SETICONSPACING */
2042c2c66affSColin Finck /* note: LVM_SETICONSPACING returns the previous icon spacing if successful */
2043c2c66affSColin Finck
2044c2c66affSColin Finck HWND hwnd;
2045c2c66affSColin Finck WORD w, h;
2046c2c66affSColin Finck INT r;
2047c2c66affSColin Finck
2048c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
2049c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2050c2c66affSColin Finck
2051c2c66affSColin Finck r = SendMessageA(hwnd, WM_NOTIFYFORMAT, (WPARAM)hwndparent, NF_REQUERY);
2052c2c66affSColin Finck expect(NFR_ANSI, r);
2053c2c66affSColin Finck
2054c2c66affSColin Finck /* reset the icon spacing to defaults */
2055c2c66affSColin Finck SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1, -1));
2056c2c66affSColin Finck
2057c2c66affSColin Finck /* now we can request what the defaults are */
2058c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1, -1));
2059c2c66affSColin Finck w = LOWORD(r);
2060c2c66affSColin Finck h = HIWORD(r);
2061c2c66affSColin Finck
2062c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2063c2c66affSColin Finck
2064c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(20, 30));
2065c2c66affSColin Finck ok(r == MAKELONG(w, h) ||
2066c2c66affSColin Finck broken(r == MAKELONG(w, w)), /* win98 */
2067c2c66affSColin Finck "Expected %d, got %d\n", MAKELONG(w, h), r);
2068c2c66affSColin Finck
2069c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(25, 35));
2070c2c66affSColin Finck expect(MAKELONG(20,30), r);
2071c2c66affSColin Finck
2072c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(-1,-1));
2073c2c66affSColin Finck expect(MAKELONG(25,35), r);
2074c2c66affSColin Finck
2075c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_icon_spacing_seq, "test icon spacing seq", FALSE);
2076c2c66affSColin Finck
2077c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2078c2c66affSColin Finck DestroyWindow(hwnd);
2079c2c66affSColin Finck }
2080c2c66affSColin Finck
test_color(void)2081c2c66affSColin Finck static void test_color(void)
2082c2c66affSColin Finck {
2083c2c66affSColin Finck RECT rect;
2084c2c66affSColin Finck HWND hwnd;
2085c2c66affSColin Finck DWORD r;
2086c2c66affSColin Finck int i;
2087c2c66affSColin Finck
2088c2c66affSColin Finck COLORREF color;
2089c2c66affSColin Finck COLORREF colors[4] = {RGB(0,0,0), RGB(100,50,200), CLR_NONE, RGB(255,255,255)};
2090c2c66affSColin Finck
2091c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
2092c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2093c2c66affSColin Finck
2094c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2095c2c66affSColin Finck
2096c2c66affSColin Finck for (i = 0; i < 4; i++)
2097c2c66affSColin Finck {
2098c2c66affSColin Finck color = colors[i];
2099c2c66affSColin Finck
2100c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, color);
2101c2c66affSColin Finck expect(TRUE, r);
2102c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETBKCOLOR, 0, 0);
2103c2c66affSColin Finck expect(color, r);
2104c2c66affSColin Finck
2105c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETTEXTCOLOR, 0, color);
2106c2c66affSColin Finck expect (TRUE, r);
2107c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETTEXTCOLOR, 0, 0);
2108c2c66affSColin Finck expect(color, r);
2109c2c66affSColin Finck
2110c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETTEXTBKCOLOR, 0, color);
2111c2c66affSColin Finck expect(TRUE, r);
2112c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETTEXTBKCOLOR, 0, 0);
2113c2c66affSColin Finck expect(color, r);
2114c2c66affSColin Finck }
2115c2c66affSColin Finck
2116c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_color_seq, "test color seq", FALSE);
2117c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2118c2c66affSColin Finck
2119c2c66affSColin Finck /* invalidation test done separately to avoid a message chain mess */
2120c2c66affSColin Finck r = ValidateRect(hwnd, NULL);
2121c2c66affSColin Finck expect(TRUE, r);
2122c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, colors[0]);
2123c2c66affSColin Finck expect(TRUE, r);
2124c2c66affSColin Finck
2125c2c66affSColin Finck rect.right = rect.bottom = 1;
2126c2c66affSColin Finck r = GetUpdateRect(hwnd, &rect, TRUE);
2127c2c66affSColin Finck todo_wine expect(FALSE, r);
2128c2c66affSColin Finck ok(rect.right == 0 && rect.bottom == 0, "got update rectangle\n");
2129c2c66affSColin Finck
2130c2c66affSColin Finck r = ValidateRect(hwnd, NULL);
2131c2c66affSColin Finck expect(TRUE, r);
2132c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETTEXTCOLOR, 0, colors[0]);
2133c2c66affSColin Finck expect(TRUE, r);
2134c2c66affSColin Finck
2135c2c66affSColin Finck rect.right = rect.bottom = 1;
2136c2c66affSColin Finck r = GetUpdateRect(hwnd, &rect, TRUE);
2137c2c66affSColin Finck todo_wine expect(FALSE, r);
2138c2c66affSColin Finck ok(rect.right == 0 && rect.bottom == 0, "got update rectangle\n");
2139c2c66affSColin Finck
2140c2c66affSColin Finck r = ValidateRect(hwnd, NULL);
2141c2c66affSColin Finck expect(TRUE, r);
2142c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETTEXTBKCOLOR, 0, colors[0]);
2143c2c66affSColin Finck expect(TRUE, r);
2144c2c66affSColin Finck
2145c2c66affSColin Finck rect.right = rect.bottom = 1;
2146c2c66affSColin Finck r = GetUpdateRect(hwnd, &rect, TRUE);
2147c2c66affSColin Finck todo_wine expect(FALSE, r);
2148c2c66affSColin Finck ok(rect.right == 0 && rect.bottom == 0, "got update rectangle\n");
2149c2c66affSColin Finck
2150c2c66affSColin Finck DestroyWindow(hwnd);
2151c2c66affSColin Finck }
2152c2c66affSColin Finck
test_item_count(void)2153c2c66affSColin Finck static void test_item_count(void)
2154c2c66affSColin Finck {
2155c2c66affSColin Finck /* LVM_INSERTITEM, LVM_DELETEITEM, LVM_DELETEALLITEMS, LVM_GETITEMCOUNT */
2156c2c66affSColin Finck
2157c2c66affSColin Finck HWND hwnd;
2158c2c66affSColin Finck DWORD r;
2159c2c66affSColin Finck HDC hdc;
2160c2c66affSColin Finck HFONT hOldFont;
2161c2c66affSColin Finck TEXTMETRICA tm;
2162c2c66affSColin Finck RECT rect;
2163c2c66affSColin Finck INT height;
2164c2c66affSColin Finck
2165c2c66affSColin Finck LVITEMA item0;
2166c2c66affSColin Finck LVITEMA item1;
2167c2c66affSColin Finck LVITEMA item2;
2168c2c66affSColin Finck static CHAR item0text[] = "item0";
2169c2c66affSColin Finck static CHAR item1text[] = "item1";
2170c2c66affSColin Finck static CHAR item2text[] = "item2";
2171c2c66affSColin Finck
2172c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
2173c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2174c2c66affSColin Finck
2175c2c66affSColin Finck /* resize in dpiaware manner to fit all 3 items added */
2176c2c66affSColin Finck hdc = GetDC(0);
2177c2c66affSColin Finck hOldFont = SelectObject(hdc, GetStockObject(SYSTEM_FONT));
2178c2c66affSColin Finck GetTextMetricsA(hdc, &tm);
2179c2c66affSColin Finck /* 2 extra pixels for bounds and header border */
2180c2c66affSColin Finck height = tm.tmHeight + 2;
2181c2c66affSColin Finck SelectObject(hdc, hOldFont);
2182c2c66affSColin Finck ReleaseDC(0, hdc);
2183c2c66affSColin Finck
2184c2c66affSColin Finck GetWindowRect(hwnd, &rect);
2185c2c66affSColin Finck /* 3 items + 1 header + 1 to be sure */
2186c2c66affSColin Finck MoveWindow(hwnd, 0, 0, rect.right - rect.left, 5 * height, FALSE);
2187c2c66affSColin Finck
2188c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2189c2c66affSColin Finck
2190c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2191c2c66affSColin Finck expect(0, r);
2192c2c66affSColin Finck
2193c2c66affSColin Finck /* [item0] */
2194c2c66affSColin Finck item0.mask = LVIF_TEXT;
2195c2c66affSColin Finck item0.iItem = 0;
2196c2c66affSColin Finck item0.iSubItem = 0;
2197c2c66affSColin Finck item0.pszText = item0text;
2198c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item0);
2199c2c66affSColin Finck expect(0, r);
2200c2c66affSColin Finck
2201c2c66affSColin Finck /* [item0, item1] */
2202c2c66affSColin Finck item1.mask = LVIF_TEXT;
2203c2c66affSColin Finck item1.iItem = 1;
2204c2c66affSColin Finck item1.iSubItem = 0;
2205c2c66affSColin Finck item1.pszText = item1text;
2206c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item1);
2207c2c66affSColin Finck expect(1, r);
2208c2c66affSColin Finck
2209c2c66affSColin Finck /* [item0, item1, item2] */
2210c2c66affSColin Finck item2.mask = LVIF_TEXT;
2211c2c66affSColin Finck item2.iItem = 2;
2212c2c66affSColin Finck item2.iSubItem = 0;
2213c2c66affSColin Finck item2.pszText = item2text;
2214c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item2);
2215c2c66affSColin Finck expect(2, r);
2216c2c66affSColin Finck
2217c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2218c2c66affSColin Finck expect(3, r);
2219c2c66affSColin Finck
2220c2c66affSColin Finck /* [item0, item1] */
2221c2c66affSColin Finck r = SendMessageA(hwnd, LVM_DELETEITEM, 2, 0);
2222c2c66affSColin Finck expect(TRUE, r);
2223c2c66affSColin Finck
2224c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2225c2c66affSColin Finck expect(2, r);
2226c2c66affSColin Finck
2227c2c66affSColin Finck /* [] */
2228c2c66affSColin Finck r = SendMessageA(hwnd, LVM_DELETEALLITEMS, 0, 0);
2229c2c66affSColin Finck expect(TRUE, r);
2230c2c66affSColin Finck
2231c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2232c2c66affSColin Finck expect(0, r);
2233c2c66affSColin Finck
2234c2c66affSColin Finck /* [item0] */
2235c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item1);
2236c2c66affSColin Finck expect(0, r);
2237c2c66affSColin Finck
2238c2c66affSColin Finck /* [item0, item1] */
2239c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item1);
2240c2c66affSColin Finck expect(1, r);
2241c2c66affSColin Finck
2242c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2243c2c66affSColin Finck expect(2, r);
2244c2c66affSColin Finck
2245c2c66affSColin Finck /* [item0, item1, item2] */
2246c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item2);
2247c2c66affSColin Finck expect(2, r);
2248c2c66affSColin Finck
2249c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2250c2c66affSColin Finck expect(3, r);
2251c2c66affSColin Finck
2252c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_item_count_seq, "test item count seq", FALSE);
2253c2c66affSColin Finck
2254c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2255c2c66affSColin Finck DestroyWindow(hwnd);
2256c2c66affSColin Finck }
2257c2c66affSColin Finck
test_item_position(void)2258c2c66affSColin Finck static void test_item_position(void)
2259c2c66affSColin Finck {
2260c2c66affSColin Finck /* LVM_SETITEMPOSITION/LVM_GETITEMPOSITION */
2261c2c66affSColin Finck
2262c2c66affSColin Finck HWND hwnd;
2263c2c66affSColin Finck DWORD r;
2264c2c66affSColin Finck POINT position;
2265c2c66affSColin Finck
2266c2c66affSColin Finck LVITEMA item0;
2267c2c66affSColin Finck LVITEMA item1;
2268c2c66affSColin Finck LVITEMA item2;
2269c2c66affSColin Finck static CHAR item0text[] = "item0";
2270c2c66affSColin Finck static CHAR item1text[] = "item1";
2271c2c66affSColin Finck static CHAR item2text[] = "item2";
2272c2c66affSColin Finck
2273c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
2274c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2275c2c66affSColin Finck
2276c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2277c2c66affSColin Finck
2278c2c66affSColin Finck /* [item0] */
2279c2c66affSColin Finck item0.mask = LVIF_TEXT;
2280c2c66affSColin Finck item0.iItem = 0;
2281c2c66affSColin Finck item0.iSubItem = 0;
2282c2c66affSColin Finck item0.pszText = item0text;
2283c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item0);
2284c2c66affSColin Finck expect(0, r);
2285c2c66affSColin Finck
2286c2c66affSColin Finck /* [item0, item1] */
2287c2c66affSColin Finck item1.mask = LVIF_TEXT;
2288c2c66affSColin Finck item1.iItem = 1;
2289c2c66affSColin Finck item1.iSubItem = 0;
2290c2c66affSColin Finck item1.pszText = item1text;
2291c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item1);
2292c2c66affSColin Finck expect(1, r);
2293c2c66affSColin Finck
2294c2c66affSColin Finck /* [item0, item1, item2] */
2295c2c66affSColin Finck item2.mask = LVIF_TEXT;
2296c2c66affSColin Finck item2.iItem = 2;
2297c2c66affSColin Finck item2.iSubItem = 0;
2298c2c66affSColin Finck item2.pszText = item2text;
2299c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item2);
2300c2c66affSColin Finck expect(2, r);
2301c2c66affSColin Finck
2302c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMPOSITION, 1, MAKELPARAM(10,5));
2303c2c66affSColin Finck expect(TRUE, r);
2304c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMPOSITION, 1, (LPARAM) &position);
2305c2c66affSColin Finck expect(TRUE, r);
2306c2c66affSColin Finck expect2(10, 5, position.x, position.y);
2307c2c66affSColin Finck
2308c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMPOSITION, 2, MAKELPARAM(0,0));
2309c2c66affSColin Finck expect(TRUE, r);
2310c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMPOSITION, 2, (LPARAM) &position);
2311c2c66affSColin Finck expect(TRUE, r);
2312c2c66affSColin Finck expect2(0, 0, position.x, position.y);
2313c2c66affSColin Finck
2314c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMPOSITION, 0, MAKELPARAM(20,20));
2315c2c66affSColin Finck expect(TRUE, r);
2316c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM) &position);
2317c2c66affSColin Finck expect(TRUE, r);
2318c2c66affSColin Finck expect2(20, 20, position.x, position.y);
2319c2c66affSColin Finck
2320c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_itempos_seq, "test item position seq", TRUE);
2321c2c66affSColin Finck
2322c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2323c2c66affSColin Finck DestroyWindow(hwnd);
2324c2c66affSColin Finck }
2325c2c66affSColin Finck
test_getorigin(void)2326c2c66affSColin Finck static void test_getorigin(void)
2327c2c66affSColin Finck {
2328c2c66affSColin Finck /* LVM_GETORIGIN */
2329c2c66affSColin Finck
2330c2c66affSColin Finck HWND hwnd;
2331c2c66affSColin Finck DWORD r;
2332c2c66affSColin Finck POINT position;
2333c2c66affSColin Finck
2334c2c66affSColin Finck position.x = position.y = 0;
2335c2c66affSColin Finck
2336c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
2337c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2338c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2339c2c66affSColin Finck
2340c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
2341c2c66affSColin Finck expect(TRUE, r);
2342c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2343c2c66affSColin Finck DestroyWindow(hwnd);
2344c2c66affSColin Finck
2345c2c66affSColin Finck hwnd = create_listview_control(LVS_SMALLICON);
2346c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2347c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2348c2c66affSColin Finck
2349c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
2350c2c66affSColin Finck expect(TRUE, r);
2351c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2352c2c66affSColin Finck DestroyWindow(hwnd);
2353c2c66affSColin Finck
2354c2c66affSColin Finck hwnd = create_listview_control(LVS_LIST);
2355c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2356c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2357c2c66affSColin Finck
2358c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
2359c2c66affSColin Finck expect(FALSE, r);
2360c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2361c2c66affSColin Finck DestroyWindow(hwnd);
2362c2c66affSColin Finck
2363c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
2364c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2365c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2366c2c66affSColin Finck
2367c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETORIGIN, 0, (LPARAM)&position);
2368c2c66affSColin Finck expect(FALSE, r);
2369c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2370c2c66affSColin Finck DestroyWindow(hwnd);
2371c2c66affSColin Finck }
2372c2c66affSColin Finck
test_multiselect(void)2373c2c66affSColin Finck static void test_multiselect(void)
2374c2c66affSColin Finck {
2375c2c66affSColin Finck typedef struct t_select_task
2376c2c66affSColin Finck {
2377c2c66affSColin Finck const char *descr;
2378c2c66affSColin Finck int initPos;
2379c2c66affSColin Finck int loopVK;
2380c2c66affSColin Finck int count;
2381c2c66affSColin Finck int result;
2382c2c66affSColin Finck } select_task;
2383c2c66affSColin Finck
2384c2c66affSColin Finck HWND hwnd;
2385c2c66affSColin Finck INT r;
2386c2c66affSColin Finck int i, j;
2387c2c66affSColin Finck static const int items=5;
2388c2c66affSColin Finck DWORD item_count;
2389c2c66affSColin Finck BYTE kstate[256];
2390c2c66affSColin Finck select_task task;
2391c2c66affSColin Finck LONG_PTR style;
2392c2c66affSColin Finck LVITEMA item;
2393c2c66affSColin Finck
2394c2c66affSColin Finck static struct t_select_task task_list[] = {
2395c2c66affSColin Finck { "using VK_DOWN", 0, VK_DOWN, -1, -1 },
2396c2c66affSColin Finck { "using VK_UP", -1, VK_UP, -1, -1 },
2397c2c66affSColin Finck { "using VK_END", 0, VK_END, 1, -1 },
2398c2c66affSColin Finck { "using VK_HOME", -1, VK_HOME, 1, -1 }
2399c2c66affSColin Finck };
2400c2c66affSColin Finck
2401c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
2402c2c66affSColin Finck
2403c2c66affSColin Finck for (i = 0; i < items; i++)
2404c2c66affSColin Finck insert_item(hwnd, 0);
2405c2c66affSColin Finck
2406c2c66affSColin Finck item_count = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2407c2c66affSColin Finck expect(items, item_count);
2408c2c66affSColin Finck
2409c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2410c2c66affSColin Finck ok(r == -1, "got %d\n", r);
2411c2c66affSColin Finck
2412c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, 0);
2413c2c66affSColin Finck ok(r == -1, "got %d\n", r);
2414c2c66affSColin Finck
2415c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, 0);
2416c2c66affSColin Finck ok(r == 0, "got %d\n", r);
2417c2c66affSColin Finck
2418c2c66affSColin Finck /* out of range index */
2419c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, items);
2420c2c66affSColin Finck ok(r == 0, "got %d\n", r);
2421c2c66affSColin Finck
2422c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2423c2c66affSColin Finck ok(r == 0, "got %d\n", r);
2424c2c66affSColin Finck
2425c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -2);
2426c2c66affSColin Finck ok(r == 0, "got %d\n", r);
2427c2c66affSColin Finck
2428c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2429c2c66affSColin Finck ok(r == 0, "got %d\n", r);
2430c2c66affSColin Finck
24315f7243b5SAmine Khaldi for (i = 0; i < ARRAY_SIZE(task_list); i++) {
2432c2c66affSColin Finck DWORD selected_count;
2433c2c66affSColin Finck LVITEMA item;
2434c2c66affSColin Finck
2435c2c66affSColin Finck task = task_list[i];
2436c2c66affSColin Finck
2437c2c66affSColin Finck /* deselect all items */
2438c2c66affSColin Finck item.state = 0;
2439c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2440c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2441c2c66affSColin Finck ok(r, "got %d\n", r);
2442c2c66affSColin Finck SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2443c2c66affSColin Finck
2444c2c66affSColin Finck /* set initial position */
2445c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, (task.initPos == -1 ? item_count -1 : task.initPos));
2446c2c66affSColin Finck ok(r, "got %d\n", r);
2447c2c66affSColin Finck
2448c2c66affSColin Finck item.state = LVIS_SELECTED;
2449c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2450c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, task.initPos == -1 ? item_count-1 : task.initPos, (LPARAM)&item);
2451c2c66affSColin Finck ok(r, "got %d\n", r);
2452c2c66affSColin Finck
2453c2c66affSColin Finck selected_count = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2454c2c66affSColin Finck ok(selected_count == 1, "expected 1, got %d\n", selected_count);
2455c2c66affSColin Finck
2456c2c66affSColin Finck /* Set SHIFT key pressed */
2457c2c66affSColin Finck GetKeyboardState(kstate);
2458c2c66affSColin Finck kstate[VK_SHIFT]=0x80;
2459c2c66affSColin Finck SetKeyboardState(kstate);
2460c2c66affSColin Finck
2461c2c66affSColin Finck for (j=1;j<=(task.count == -1 ? item_count : task.count);j++) {
2462c2c66affSColin Finck r = SendMessageA(hwnd, WM_KEYDOWN, task.loopVK, 0);
2463c2c66affSColin Finck expect(0,r);
2464c2c66affSColin Finck r = SendMessageA(hwnd, WM_KEYUP, task.loopVK, 0);
2465c2c66affSColin Finck expect(0,r);
2466c2c66affSColin Finck }
2467c2c66affSColin Finck
2468c2c66affSColin Finck selected_count = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2469c2c66affSColin Finck
2470c2c66affSColin Finck ok((task.result == -1 ? item_count : task.result) == selected_count,
2471c2c66affSColin Finck "Failed multiple selection %s. There should be %d selected items (is %d)\n",
2472c2c66affSColin Finck task.descr, item_count, selected_count);
2473c2c66affSColin Finck
2474c2c66affSColin Finck /* Set SHIFT key released */
2475c2c66affSColin Finck GetKeyboardState(kstate);
2476c2c66affSColin Finck kstate[VK_SHIFT]=0x00;
2477c2c66affSColin Finck SetKeyboardState(kstate);
2478c2c66affSColin Finck }
2479c2c66affSColin Finck DestroyWindow(hwnd);
2480c2c66affSColin Finck
2481c2c66affSColin Finck /* make multiple selection, then switch to LVS_SINGLESEL */
2482c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
2483c2c66affSColin Finck for (i=0;i<items;i++) {
2484c2c66affSColin Finck insert_item(hwnd, 0);
2485c2c66affSColin Finck }
2486c2c66affSColin Finck item_count = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
2487c2c66affSColin Finck expect(items,item_count);
2488c2c66affSColin Finck
2489c2c66affSColin Finck /* try with NULL pointer */
2490c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, 0);
2491c2c66affSColin Finck expect(FALSE, r);
2492c2c66affSColin Finck
2493c2c66affSColin Finck /* select all, check notifications */
2494c2c66affSColin Finck item.state = 0;
2495c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2496c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2497c2c66affSColin Finck ok(r, "got %d\n", r);
2498c2c66affSColin Finck
2499c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2500c2c66affSColin Finck
2501c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2502c2c66affSColin Finck item.state = LVIS_SELECTED;
2503c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2504c2c66affSColin Finck expect(TRUE, r);
2505c2c66affSColin Finck
2506c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, change_all_parent_seq,
2507c2c66affSColin Finck "select all notification", FALSE);
2508c2c66affSColin Finck
2509c2c66affSColin Finck /* select all again (all selected already) */
2510c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2511c2c66affSColin Finck
2512c2c66affSColin Finck memset(&g_nmlistview_changing, 0xcc, sizeof(g_nmlistview_changing));
2513c2c66affSColin Finck
2514c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2515c2c66affSColin Finck item.state = LVIS_SELECTED;
2516c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2517c2c66affSColin Finck expect(TRUE, r);
2518c2c66affSColin Finck
2519c2c66affSColin Finck ok(g_nmlistview_changing.uNewState == LVIS_SELECTED, "got 0x%x\n", g_nmlistview_changing.uNewState);
2520c2c66affSColin Finck ok(g_nmlistview_changing.uOldState == LVIS_SELECTED, "got 0x%x\n", g_nmlistview_changing.uOldState);
2521c2c66affSColin Finck ok(g_nmlistview_changing.uChanged == LVIF_STATE, "got 0x%x\n", g_nmlistview_changing.uChanged);
2522c2c66affSColin Finck
2523c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, changing_all_parent_seq,
2524c2c66affSColin Finck "select all notification 2", FALSE);
2525c2c66affSColin Finck
2526c2c66affSColin Finck /* deselect all items */
2527c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2528c2c66affSColin Finck
2529c2c66affSColin Finck item.state = 0;
2530c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2531c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2532c2c66affSColin Finck ok(r, "got %d\n", r);
2533c2c66affSColin Finck
2534c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, change_all_parent_seq,
2535c2c66affSColin Finck "deselect all notification", FALSE);
2536c2c66affSColin Finck
2537c2c66affSColin Finck /* deselect all items again */
2538c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2539c2c66affSColin Finck item.state = 0;
2540c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2541c2c66affSColin Finck SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2542c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "deselect all notification 2", FALSE);
2543c2c66affSColin Finck
2544c2c66affSColin Finck /* any non-zero state value does the same */
2545c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2546c2c66affSColin Finck
2547c2c66affSColin Finck memset(&g_nmlistview_changing, 0xcc, sizeof(g_nmlistview_changing));
2548c2c66affSColin Finck
2549c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2550c2c66affSColin Finck item.state = LVIS_CUT;
2551c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2552c2c66affSColin Finck expect(TRUE, r);
2553c2c66affSColin Finck
2554c2c66affSColin Finck ok(g_nmlistview_changing.uNewState == 0, "got 0x%x\n", g_nmlistview_changing.uNewState);
2555c2c66affSColin Finck ok(g_nmlistview_changing.uOldState == 0, "got 0x%x\n", g_nmlistview_changing.uOldState);
2556c2c66affSColin Finck ok(g_nmlistview_changing.uChanged == LVIF_STATE, "got 0x%x\n", g_nmlistview_changing.uChanged);
2557c2c66affSColin Finck
2558c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, changing_all_parent_seq,
2559c2c66affSColin Finck "set state all notification 3", FALSE);
2560c2c66affSColin Finck
2561c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2562c2c66affSColin Finck ok(r, "got %d\n", r);
2563c2c66affSColin Finck for (i = 0; i < 3; i++) {
2564c2c66affSColin Finck item.state = LVIS_SELECTED;
2565c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2566c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, i, (LPARAM)&item);
2567c2c66affSColin Finck ok(r, "got %d\n", r);
2568c2c66affSColin Finck }
2569c2c66affSColin Finck
2570c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2571c2c66affSColin Finck expect(3, r);
2572c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2573c2c66affSColin Finck expect(-1, r);
2574c2c66affSColin Finck
2575c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2576c2c66affSColin Finck ok(!(style & LVS_SINGLESEL), "LVS_SINGLESEL isn't expected\n");
2577c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SINGLESEL);
2578c2c66affSColin Finck /* check that style is accepted */
2579c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2580c2c66affSColin Finck ok(style & LVS_SINGLESEL, "LVS_SINGLESEL expected\n");
2581c2c66affSColin Finck
2582c2c66affSColin Finck for (i=0;i<3;i++) {
2583c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMSTATE, i, LVIS_SELECTED);
2584c2c66affSColin Finck ok(r & LVIS_SELECTED, "Expected item %d to be selected\n", i);
2585c2c66affSColin Finck }
2586c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2587c2c66affSColin Finck expect(3, r);
2588c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2589c2c66affSColin Finck ok(r == -1, "got %d\n", r);
2590c2c66affSColin Finck
2591c2c66affSColin Finck /* select one more */
2592c2c66affSColin Finck item.state = LVIS_SELECTED;
2593c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2594c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, 3, (LPARAM)&item);
2595c2c66affSColin Finck ok(r, "got %d\n", r);
2596c2c66affSColin Finck
2597c2c66affSColin Finck for (i=0;i<3;i++) {
2598c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMSTATE, i, LVIS_SELECTED);
2599c2c66affSColin Finck ok(!(r & LVIS_SELECTED), "Expected item %d to be unselected\n", i);
2600c2c66affSColin Finck }
2601c2c66affSColin Finck
2602c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMSTATE, 3, LVIS_SELECTED);
2603c2c66affSColin Finck ok(r & LVIS_SELECTED, "Expected item %d to be selected\n", i);
2604c2c66affSColin Finck
2605c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2606c2c66affSColin Finck expect(1, r);
2607c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2608c2c66affSColin Finck expect(-1, r);
2609c2c66affSColin Finck
2610c2c66affSColin Finck /* try to select all on LVS_SINGLESEL */
2611c2c66affSColin Finck memset(&item, 0, sizeof(item));
2612c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2613c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2614c2c66affSColin Finck expect(TRUE, r);
2615c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2616c2c66affSColin Finck ok(r == -1, "got %d\n", r);
2617c2c66affSColin Finck
2618c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2619c2c66affSColin Finck item.state = LVIS_SELECTED;
2620c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2621c2c66affSColin Finck expect(FALSE, r);
2622c2c66affSColin Finck
2623c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2624c2c66affSColin Finck expect(0, r);
2625c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2626c2c66affSColin Finck expect(-1, r);
2627c2c66affSColin Finck
2628c2c66affSColin Finck /* try to deselect all on LVS_SINGLESEL */
2629c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2630c2c66affSColin Finck item.state = LVIS_SELECTED;
2631c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2632c2c66affSColin Finck expect(TRUE, r);
2633c2c66affSColin Finck
2634c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
2635c2c66affSColin Finck item.state = 0;
2636c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2637c2c66affSColin Finck expect(TRUE, r);
2638c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
2639c2c66affSColin Finck expect(0, r);
2640c2c66affSColin Finck
2641c2c66affSColin Finck /* 1. selection mark is update when new focused item is set */
2642c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2643c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_SINGLESEL);
2644c2c66affSColin Finck
2645c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2646c2c66affSColin Finck expect(-1, r);
2647c2c66affSColin Finck
2648c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2649c2c66affSColin Finck item.state = LVIS_FOCUSED;
2650c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
2651c2c66affSColin Finck expect(TRUE, r);
2652c2c66affSColin Finck
2653c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2654c2c66affSColin Finck expect(0, r);
2655c2c66affSColin Finck
2656c2c66affSColin Finck /* it's not updated if already set */
2657c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2658c2c66affSColin Finck item.state = LVIS_FOCUSED;
2659c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, 1, (LPARAM)&item);
2660c2c66affSColin Finck expect(TRUE, r);
2661c2c66affSColin Finck
2662c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2663c2c66affSColin Finck expect(0, r);
2664c2c66affSColin Finck
2665c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2666c2c66affSColin Finck expect(0, r);
2667c2c66affSColin Finck
2668c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2669c2c66affSColin Finck item.state = LVIS_FOCUSED;
2670c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, 1, (LPARAM)&item);
2671c2c66affSColin Finck expect(TRUE, r);
2672c2c66affSColin Finck
2673c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2674c2c66affSColin Finck expect(-1, r);
2675c2c66affSColin Finck
2676c2c66affSColin Finck /* need to reset focused item first */
2677c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2678c2c66affSColin Finck item.state = 0;
2679c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2680c2c66affSColin Finck expect(TRUE, r);
2681c2c66affSColin Finck
2682c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2683c2c66affSColin Finck item.state = LVIS_FOCUSED;
2684c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, 2, (LPARAM)&item);
2685c2c66affSColin Finck expect(TRUE, r);
2686c2c66affSColin Finck
2687c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2688c2c66affSColin Finck expect(2, r);
2689c2c66affSColin Finck
2690c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2691c2c66affSColin Finck item.state = 0;
2692c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2693c2c66affSColin Finck expect(TRUE, r);
2694c2c66affSColin Finck
2695c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2696c2c66affSColin Finck expect(2, r);
2697c2c66affSColin Finck
2698c2c66affSColin Finck /* 2. same tests, with LVM_SETITEM */
2699c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
2700c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_SINGLESEL);
2701c2c66affSColin Finck
2702c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2703c2c66affSColin Finck expect(2, r);
2704c2c66affSColin Finck
2705c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2706c2c66affSColin Finck item.state = LVIS_FOCUSED;
2707c2c66affSColin Finck item.mask = LVIF_STATE;
2708c2c66affSColin Finck item.iItem = item.iSubItem = 0;
2709c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
2710c2c66affSColin Finck expect(TRUE, r);
2711c2c66affSColin Finck
2712c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2713c2c66affSColin Finck expect(0, r);
2714c2c66affSColin Finck
2715c2c66affSColin Finck /* it's not updated if already set */
2716c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2717c2c66affSColin Finck item.state = LVIS_FOCUSED;
2718c2c66affSColin Finck item.mask = LVIF_STATE;
2719c2c66affSColin Finck item.iItem = 1;
2720c2c66affSColin Finck item.iSubItem = 0;
2721c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
2722c2c66affSColin Finck expect(TRUE, r);
2723c2c66affSColin Finck
2724c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2725c2c66affSColin Finck expect(0, r);
2726c2c66affSColin Finck
2727c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETSELECTIONMARK, 0, -1);
2728c2c66affSColin Finck expect(0, r);
2729c2c66affSColin Finck
2730c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2731c2c66affSColin Finck item.state = LVIS_FOCUSED;
2732c2c66affSColin Finck item.mask = LVIF_STATE;
2733c2c66affSColin Finck item.iItem = 1;
2734c2c66affSColin Finck item.iSubItem = 0;
2735c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
2736c2c66affSColin Finck expect(TRUE, r);
2737c2c66affSColin Finck
2738c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2739c2c66affSColin Finck expect(-1, r);
2740c2c66affSColin Finck
2741c2c66affSColin Finck /* need to reset focused item first */
2742c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2743c2c66affSColin Finck item.state = 0;
2744c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2745c2c66affSColin Finck expect(TRUE, r);
2746c2c66affSColin Finck
2747c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2748c2c66affSColin Finck item.state = LVIS_FOCUSED;
2749c2c66affSColin Finck item.mask = LVIF_STATE;
2750c2c66affSColin Finck item.iItem = 2;
2751c2c66affSColin Finck item.iSubItem = 0;
2752c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
2753c2c66affSColin Finck expect(TRUE, r);
2754c2c66affSColin Finck
2755c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2756c2c66affSColin Finck expect(2, r);
2757c2c66affSColin Finck
2758c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
2759c2c66affSColin Finck item.state = 0;
2760c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
2761c2c66affSColin Finck expect(TRUE, r);
2762c2c66affSColin Finck
2763c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
2764c2c66affSColin Finck expect(2, r);
2765c2c66affSColin Finck
2766c2c66affSColin Finck DestroyWindow(hwnd);
2767c2c66affSColin Finck }
2768c2c66affSColin Finck
test_subitem_rect(void)2769c2c66affSColin Finck static void test_subitem_rect(void)
2770c2c66affSColin Finck {
2771c2c66affSColin Finck HWND hwnd;
2772c2c66affSColin Finck DWORD r;
2773c2c66affSColin Finck LVCOLUMNA col;
2774c2c66affSColin Finck RECT rect, rect2;
2775c2c66affSColin Finck INT arr[3];
2776c2c66affSColin Finck
2777c2c66affSColin Finck /* test LVM_GETSUBITEMRECT for header */
2778c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
2779c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2780c2c66affSColin Finck /* add some columns */
2781c2c66affSColin Finck memset(&col, 0, sizeof(LVCOLUMNA));
2782c2c66affSColin Finck col.mask = LVCF_WIDTH;
2783c2c66affSColin Finck col.cx = 100;
2784c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
2785c2c66affSColin Finck expect(0, r);
2786c2c66affSColin Finck col.cx = 150;
2787c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 1, (LPARAM)&col);
2788c2c66affSColin Finck expect(1, r);
2789c2c66affSColin Finck col.cx = 200;
2790c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 2, (LPARAM)&col);
2791c2c66affSColin Finck expect(2, r);
2792c2c66affSColin Finck /* item = -1 means header, subitem index is 1 based */
2793c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 0, 0, 0);
2794c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2795c2c66affSColin Finck expect(0, r);
2796c2c66affSColin Finck
2797c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
2798c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2799c2c66affSColin Finck expect(1, r);
2800c2c66affSColin Finck
2801c2c66affSColin Finck expect(100, rect.left);
2802c2c66affSColin Finck expect(250, rect.right);
2803c2c66affSColin Finck expect(3, rect.top);
2804c2c66affSColin Finck
2805c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 2, 0, 0);
2806c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2807c2c66affSColin Finck expect(1, r);
2808c2c66affSColin Finck
2809c2c66affSColin Finck expect(250, rect.left);
2810c2c66affSColin Finck expect(450, rect.right);
2811c2c66affSColin Finck expect(3, rect.top);
2812c2c66affSColin Finck
2813c2c66affSColin Finck /* item LVS_REPORT padding isn't applied to subitems */
2814c2c66affSColin Finck insert_item(hwnd, 0);
2815c2c66affSColin Finck
2816c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
2817c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2818c2c66affSColin Finck expect(1, r);
2819c2c66affSColin Finck expect(100, rect.left);
2820c2c66affSColin Finck expect(250, rect.right);
2821c2c66affSColin Finck
2822c2c66affSColin Finck SetRect(&rect, LVIR_ICON, 1, 0, 0);
2823c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2824c2c66affSColin Finck expect(1, r);
2825c2c66affSColin Finck /* no icon attached - zero width rectangle, with no left padding */
2826c2c66affSColin Finck expect(100, rect.left);
2827c2c66affSColin Finck expect(100, rect.right);
2828c2c66affSColin Finck
2829c2c66affSColin Finck SetRect(&rect, LVIR_LABEL, 1, 0, 0);
2830c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2831c2c66affSColin Finck expect(1, r);
2832c2c66affSColin Finck /* same as full LVIR_BOUNDS */
2833c2c66affSColin Finck expect(100, rect.left);
2834c2c66affSColin Finck expect(250, rect.right);
2835c2c66affSColin Finck
2836c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SCROLL, 10, 0);
2837c2c66affSColin Finck ok(r, "got %d\n", r);
2838c2c66affSColin Finck
2839c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
2840c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2841c2c66affSColin Finck expect(1, r);
2842c2c66affSColin Finck expect(90, rect.left);
2843c2c66affSColin Finck expect(240, rect.right);
2844c2c66affSColin Finck
2845c2c66affSColin Finck SendMessageA(hwnd, LVM_SCROLL, -10, 0);
2846c2c66affSColin Finck
2847c2c66affSColin Finck /* test header interaction */
2848c2c66affSColin Finck subclass_header(hwnd);
2849c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
2850c2c66affSColin Finck
2851c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
2852c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2853c2c66affSColin Finck expect(1, r);
2854c2c66affSColin Finck
2855c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
2856c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2857c2c66affSColin Finck expect(1, r);
2858c2c66affSColin Finck
2859c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
2860c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -10, (LPARAM)&rect);
2861c2c66affSColin Finck expect(1, r);
2862c2c66affSColin Finck
2863c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, 0, 0);
2864c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 20, (LPARAM)&rect);
2865c2c66affSColin Finck expect(1, r);
2866c2c66affSColin Finck
2867c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getsubitemrect_seq, "LVM_GETSUBITEMRECT negative index", FALSE);
2868c2c66affSColin Finck
2869c2c66affSColin Finck DestroyWindow(hwnd);
2870c2c66affSColin Finck
2871c2c66affSColin Finck /* test subitem rects after re-arranging columns */
2872c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
2873c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2874c2c66affSColin Finck memset(&col, 0, sizeof(LVCOLUMNA));
2875c2c66affSColin Finck col.mask = LVCF_WIDTH;
2876c2c66affSColin Finck
2877c2c66affSColin Finck col.cx = 100;
2878c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
2879c2c66affSColin Finck expect(0, r);
2880c2c66affSColin Finck
2881c2c66affSColin Finck col.cx = 200;
2882c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 1, (LPARAM)&col);
2883c2c66affSColin Finck expect(1, r);
2884c2c66affSColin Finck
2885c2c66affSColin Finck col.cx = 300;
2886c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 2, (LPARAM)&col);
2887c2c66affSColin Finck expect(2, r);
2888c2c66affSColin Finck
2889c2c66affSColin Finck insert_item(hwnd, 0);
2890c2c66affSColin Finck insert_item(hwnd, 1);
2891c2c66affSColin Finck
2892c2c66affSColin Finck /* wrong item is refused for main item */
2893c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 0, -1, -1);
2894c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 2, (LPARAM)&rect);
2895c2c66affSColin Finck expect(FALSE, r);
2896c2c66affSColin Finck
2897c2c66affSColin Finck /* for subitems rectangle is calculated even if there's no item added */
2898c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, -1, -1);
2899c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 1, (LPARAM)&rect);
2900c2c66affSColin Finck expect(TRUE, r);
2901c2c66affSColin Finck
2902c2c66affSColin Finck SetRect(&rect2, LVIR_BOUNDS, 1, -1, -1);
2903c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 2, (LPARAM)&rect2);
2904c2c66affSColin Finck expect(TRUE, r);
2905c2c66affSColin Finck expect(rect.right, rect2.right);
2906c2c66affSColin Finck expect(rect.left, rect2.left);
2907c2c66affSColin Finck expect(rect.bottom, rect2.top);
2908c2c66affSColin Finck ok(rect2.bottom > rect2.top, "expected not zero height\n");
2909c2c66affSColin Finck
2910c2c66affSColin Finck arr[0] = 1; arr[1] = 0; arr[2] = 2;
2911c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNORDERARRAY, 3, (LPARAM)arr);
2912c2c66affSColin Finck expect(TRUE, r);
2913c2c66affSColin Finck
2914c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 0, -1, -1);
2915c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2916c2c66affSColin Finck expect(TRUE, r);
2917c2c66affSColin Finck expect(0, rect.left);
2918c2c66affSColin Finck expect(600, rect.right);
2919c2c66affSColin Finck
2920c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, -1, -1);
2921c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2922c2c66affSColin Finck expect(TRUE, r);
2923c2c66affSColin Finck expect(0, rect.left);
2924c2c66affSColin Finck expect(200, rect.right);
2925c2c66affSColin Finck
2926c2c66affSColin Finck SetRect(&rect2, LVIR_BOUNDS, 1, -1, -1);
2927c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 1, (LPARAM)&rect2);
2928c2c66affSColin Finck expect(TRUE, r);
2929c2c66affSColin Finck expect(0, rect2.left);
2930c2c66affSColin Finck expect(200, rect2.right);
2931c2c66affSColin Finck /* items are of the same height */
2932c2c66affSColin Finck ok(rect2.top > 0, "expected positive item height\n");
2933c2c66affSColin Finck expect(rect.bottom, rect2.top);
2934c2c66affSColin Finck expect(rect.bottom * 2 - rect.top, rect2.bottom);
2935c2c66affSColin Finck
2936c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 2, -1, -1);
2937c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
2938c2c66affSColin Finck expect(TRUE, r);
2939c2c66affSColin Finck expect(300, rect.left);
2940c2c66affSColin Finck expect(600, rect.right);
2941c2c66affSColin Finck
2942c2c66affSColin Finck DestroyWindow(hwnd);
2943c2c66affSColin Finck
2944c2c66affSColin Finck /* try it for non LVS_REPORT style */
2945f37104daSAmine Khaldi hwnd = CreateWindowA(WC_LISTVIEWA, "Test", LVS_ICON, 0, 0, 100, 100, NULL, NULL,
2946c2c66affSColin Finck GetModuleHandleA(NULL), 0);
2947c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, 1, -10, -10);
2948c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSUBITEMRECT, -1, (LPARAM)&rect);
2949c2c66affSColin Finck expect(0, r);
2950c2c66affSColin Finck /* rect is unchanged */
2951c2c66affSColin Finck expect(0, rect.left);
2952c2c66affSColin Finck expect(-10, rect.right);
2953c2c66affSColin Finck expect(1, rect.top);
2954c2c66affSColin Finck expect(-10, rect.bottom);
2955c2c66affSColin Finck DestroyWindow(hwnd);
2956c2c66affSColin Finck }
2957c2c66affSColin Finck
2958c2c66affSColin Finck /* comparison callback for test_sorting */
test_CallBackCompare(LPARAM first,LPARAM second,LPARAM lParam)2959c2c66affSColin Finck static INT WINAPI test_CallBackCompare(LPARAM first, LPARAM second, LPARAM lParam)
2960c2c66affSColin Finck {
2961c2c66affSColin Finck if (first == second) return 0;
2962c2c66affSColin Finck return (first > second ? 1 : -1);
2963c2c66affSColin Finck }
2964c2c66affSColin Finck
test_sorting(void)2965c2c66affSColin Finck static void test_sorting(void)
2966c2c66affSColin Finck {
2967c2c66affSColin Finck HWND hwnd;
2968c2c66affSColin Finck LVITEMA item = {0};
2969c2c66affSColin Finck INT r;
2970c2c66affSColin Finck LONG_PTR style;
2971c2c66affSColin Finck static CHAR names[][5] = {"A", "B", "C", "D", "0"};
2972c2c66affSColin Finck CHAR buff[10];
2973c2c66affSColin Finck
2974c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
2975c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
2976c2c66affSColin Finck
2977c2c66affSColin Finck /* insert some items */
2978c2c66affSColin Finck item.mask = LVIF_PARAM | LVIF_STATE;
2979c2c66affSColin Finck item.state = LVIS_SELECTED;
2980c2c66affSColin Finck item.iItem = 0;
2981c2c66affSColin Finck item.iSubItem = 0;
2982c2c66affSColin Finck item.lParam = 3;
2983c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
2984c2c66affSColin Finck expect(0, r);
2985c2c66affSColin Finck
2986c2c66affSColin Finck item.mask = LVIF_PARAM;
2987c2c66affSColin Finck item.iItem = 1;
2988c2c66affSColin Finck item.iSubItem = 0;
2989c2c66affSColin Finck item.lParam = 2;
2990c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
2991c2c66affSColin Finck expect(1, r);
2992c2c66affSColin Finck
2993c2c66affSColin Finck item.mask = LVIF_STATE | LVIF_PARAM;
2994c2c66affSColin Finck item.state = LVIS_SELECTED;
2995c2c66affSColin Finck item.iItem = 2;
2996c2c66affSColin Finck item.iSubItem = 0;
2997c2c66affSColin Finck item.lParam = 4;
2998c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
2999c2c66affSColin Finck expect(2, r);
3000c2c66affSColin Finck
3001c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
3002c2c66affSColin Finck expect(-1, r);
3003c2c66affSColin Finck
3004c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
3005c2c66affSColin Finck expect(2, r);
3006c2c66affSColin Finck
3007c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SORTITEMS, 0, (LPARAM)test_CallBackCompare);
3008c2c66affSColin Finck expect(TRUE, r);
3009c2c66affSColin Finck
3010c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
3011c2c66affSColin Finck expect(2, r);
3012c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
3013c2c66affSColin Finck expect(-1, r);
3014c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMSTATE, 0, LVIS_SELECTED);
3015c2c66affSColin Finck expect(0, r);
3016c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMSTATE, 1, LVIS_SELECTED);
3017c2c66affSColin Finck expect(LVIS_SELECTED, r);
3018c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMSTATE, 2, LVIS_SELECTED);
3019c2c66affSColin Finck expect(LVIS_SELECTED, r);
3020c2c66affSColin Finck
3021c2c66affSColin Finck DestroyWindow(hwnd);
3022c2c66affSColin Finck
3023c2c66affSColin Finck /* switch to LVS_SORTASCENDING when some items added */
3024c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
3025c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3026c2c66affSColin Finck
3027c2c66affSColin Finck item.mask = LVIF_TEXT;
3028c2c66affSColin Finck item.iItem = 0;
3029c2c66affSColin Finck item.iSubItem = 0;
3030c2c66affSColin Finck item.pszText = names[1];
3031c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
3032c2c66affSColin Finck expect(0, r);
3033c2c66affSColin Finck
3034c2c66affSColin Finck item.mask = LVIF_TEXT;
3035c2c66affSColin Finck item.iItem = 1;
3036c2c66affSColin Finck item.iSubItem = 0;
3037c2c66affSColin Finck item.pszText = names[2];
3038c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
3039c2c66affSColin Finck expect(1, r);
3040c2c66affSColin Finck
3041c2c66affSColin Finck item.mask = LVIF_TEXT;
3042c2c66affSColin Finck item.iItem = 2;
3043c2c66affSColin Finck item.iSubItem = 0;
3044c2c66affSColin Finck item.pszText = names[0];
3045c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
3046c2c66affSColin Finck expect(2, r);
3047c2c66affSColin Finck
3048c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3049c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTASCENDING);
3050c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3051c2c66affSColin Finck ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
3052c2c66affSColin Finck
3053c2c66affSColin Finck /* no sorting performed when switched to LVS_SORTASCENDING */
3054c2c66affSColin Finck item.mask = LVIF_TEXT;
3055c2c66affSColin Finck item.iItem = 0;
3056c2c66affSColin Finck item.pszText = buff;
3057c2c66affSColin Finck item.cchTextMax = sizeof(buff);
3058c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3059c2c66affSColin Finck expect(TRUE, r);
3060c2c66affSColin Finck ok(lstrcmpA(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
3061c2c66affSColin Finck
3062c2c66affSColin Finck item.iItem = 1;
3063c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3064c2c66affSColin Finck expect(TRUE, r);
3065c2c66affSColin Finck ok(lstrcmpA(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
3066c2c66affSColin Finck
3067c2c66affSColin Finck item.iItem = 2;
3068c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3069c2c66affSColin Finck expect(TRUE, r);
3070c2c66affSColin Finck ok(lstrcmpA(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
3071c2c66affSColin Finck
3072c2c66affSColin Finck /* adding new item doesn't resort list */
3073c2c66affSColin Finck item.mask = LVIF_TEXT;
3074c2c66affSColin Finck item.iItem = 3;
3075c2c66affSColin Finck item.iSubItem = 0;
3076c2c66affSColin Finck item.pszText = names[3];
3077c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
3078c2c66affSColin Finck expect(3, r);
3079c2c66affSColin Finck
3080c2c66affSColin Finck item.mask = LVIF_TEXT;
3081c2c66affSColin Finck item.iItem = 0;
3082c2c66affSColin Finck item.pszText = buff;
3083c2c66affSColin Finck item.cchTextMax = sizeof(buff);
3084c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3085c2c66affSColin Finck expect(TRUE, r);
3086c2c66affSColin Finck ok(lstrcmpA(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
3087c2c66affSColin Finck
3088c2c66affSColin Finck item.iItem = 1;
3089c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3090c2c66affSColin Finck expect(TRUE, r);
3091c2c66affSColin Finck ok(lstrcmpA(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
3092c2c66affSColin Finck
3093c2c66affSColin Finck item.iItem = 2;
3094c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3095c2c66affSColin Finck expect(TRUE, r);
3096c2c66affSColin Finck ok(lstrcmpA(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
3097c2c66affSColin Finck
3098c2c66affSColin Finck item.iItem = 3;
3099c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3100c2c66affSColin Finck expect(TRUE, r);
3101c2c66affSColin Finck ok(lstrcmpA(buff, names[3]) == 0, "Expected '%s', got '%s'\n", names[3], buff);
3102c2c66affSColin Finck
3103c2c66affSColin Finck /* corner case - item should be placed at first position */
3104c2c66affSColin Finck item.mask = LVIF_TEXT;
3105c2c66affSColin Finck item.iItem = 4;
3106c2c66affSColin Finck item.iSubItem = 0;
3107c2c66affSColin Finck item.pszText = names[4];
3108c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
3109c2c66affSColin Finck expect(0, r);
3110c2c66affSColin Finck
3111c2c66affSColin Finck item.iItem = 0;
3112c2c66affSColin Finck item.pszText = buff;
3113c2c66affSColin Finck item.cchTextMax = sizeof(buff);
3114c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3115c2c66affSColin Finck expect(TRUE, r);
3116c2c66affSColin Finck ok(lstrcmpA(buff, names[4]) == 0, "Expected '%s', got '%s'\n", names[4], buff);
3117c2c66affSColin Finck
3118c2c66affSColin Finck item.iItem = 1;
3119c2c66affSColin Finck item.pszText = buff;
3120c2c66affSColin Finck item.cchTextMax = sizeof(buff);
3121c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3122c2c66affSColin Finck expect(TRUE, r);
3123c2c66affSColin Finck ok(lstrcmpA(buff, names[1]) == 0, "Expected '%s', got '%s'\n", names[1], buff);
3124c2c66affSColin Finck
3125c2c66affSColin Finck item.iItem = 2;
3126c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3127c2c66affSColin Finck expect(TRUE, r);
3128c2c66affSColin Finck ok(lstrcmpA(buff, names[2]) == 0, "Expected '%s', got '%s'\n", names[2], buff);
3129c2c66affSColin Finck
3130c2c66affSColin Finck item.iItem = 3;
3131c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3132c2c66affSColin Finck expect(TRUE, r);
3133c2c66affSColin Finck ok(lstrcmpA(buff, names[0]) == 0, "Expected '%s', got '%s'\n", names[0], buff);
3134c2c66affSColin Finck
3135c2c66affSColin Finck item.iItem = 4;
3136c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM) &item);
3137c2c66affSColin Finck expect(TRUE, r);
3138c2c66affSColin Finck ok(lstrcmpA(buff, names[3]) == 0, "Expected '%s', got '%s'\n", names[3], buff);
3139c2c66affSColin Finck
3140c2c66affSColin Finck DestroyWindow(hwnd);
3141c2c66affSColin Finck }
3142c2c66affSColin Finck
test_ownerdata(void)3143c2c66affSColin Finck static void test_ownerdata(void)
3144c2c66affSColin Finck {
3145c2c66affSColin Finck static char test_str[] = "test";
3146c2c66affSColin Finck
3147c2c66affSColin Finck HWND hwnd;
3148c2c66affSColin Finck LONG_PTR style, ret;
3149c2c66affSColin Finck DWORD res;
3150c2c66affSColin Finck LVITEMA item;
3151c2c66affSColin Finck
3152c2c66affSColin Finck /* it isn't possible to set LVS_OWNERDATA after creation */
3153c2c66affSColin Finck if (g_is_below_5)
3154c2c66affSColin Finck {
3155c2c66affSColin Finck win_skip("set LVS_OWNERDATA after creation leads to crash on < 5.80\n");
3156c2c66affSColin Finck }
3157c2c66affSColin Finck else
3158c2c66affSColin Finck {
3159c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
3160c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3161c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3162c2c66affSColin Finck ok(!(style & LVS_OWNERDATA) && style, "LVS_OWNERDATA isn't expected\n");
3163c2c66affSColin Finck
3164c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3165c2c66affSColin Finck
3166c2c66affSColin Finck ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_OWNERDATA);
3167c2c66affSColin Finck ok(ret == style, "Expected set GWL_STYLE to succeed\n");
3168c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
3169c2c66affSColin Finck "try to switch to LVS_OWNERDATA seq", FALSE);
3170c2c66affSColin Finck
3171c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3172c2c66affSColin Finck ok(!(style & LVS_OWNERDATA), "LVS_OWNERDATA isn't expected\n");
3173c2c66affSColin Finck DestroyWindow(hwnd);
3174c2c66affSColin Finck }
3175c2c66affSColin Finck
3176c2c66affSColin Finck /* try to set LVS_OWNERDATA after creation just having it */
3177c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3178c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3179c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3180c2c66affSColin Finck ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
3181c2c66affSColin Finck
3182c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3183c2c66affSColin Finck
3184c2c66affSColin Finck ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_OWNERDATA);
3185c2c66affSColin Finck ok(ret == style, "Expected set GWL_STYLE to succeed\n");
3186c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
3187c2c66affSColin Finck "try to switch to LVS_OWNERDATA seq", FALSE);
3188c2c66affSColin Finck DestroyWindow(hwnd);
3189c2c66affSColin Finck
3190c2c66affSColin Finck /* try to remove LVS_OWNERDATA after creation just having it */
3191c2c66affSColin Finck if (g_is_below_5)
3192c2c66affSColin Finck {
3193c2c66affSColin Finck win_skip("remove LVS_OWNERDATA after creation leads to crash on < 5.80\n");
3194c2c66affSColin Finck }
3195c2c66affSColin Finck else
3196c2c66affSColin Finck {
3197c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3198c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3199c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3200c2c66affSColin Finck ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
3201c2c66affSColin Finck
3202c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3203c2c66affSColin Finck
3204c2c66affSColin Finck ret = SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_OWNERDATA);
3205c2c66affSColin Finck ok(ret == style, "Expected set GWL_STYLE to succeed\n");
3206c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_ownerdata_switchto_seq,
3207c2c66affSColin Finck "try to switch to LVS_OWNERDATA seq", FALSE);
3208c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3209c2c66affSColin Finck ok(style & LVS_OWNERDATA, "LVS_OWNERDATA is expected\n");
3210c2c66affSColin Finck DestroyWindow(hwnd);
3211c2c66affSColin Finck }
3212c2c66affSColin Finck
3213c2c66affSColin Finck /* try select an item */
3214c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3215c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3216c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
3217c2c66affSColin Finck expect(1, res);
3218c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
3219c2c66affSColin Finck expect(0, res);
3220c2c66affSColin Finck memset(&item, 0, sizeof(item));
3221c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3222c2c66affSColin Finck item.state = LVIS_SELECTED;
3223c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
3224c2c66affSColin Finck expect(TRUE, res);
3225c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
3226c2c66affSColin Finck expect(1, res);
3227c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
3228c2c66affSColin Finck expect(1, res);
3229c2c66affSColin Finck DestroyWindow(hwnd);
3230c2c66affSColin Finck
3231c2c66affSColin Finck /* LVM_SETITEM and LVM_SETITEMTEXT is unsupported on LVS_OWNERDATA */
3232c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3233c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3234c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
3235c2c66affSColin Finck expect(1, res);
3236c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
3237c2c66affSColin Finck expect(1, res);
3238c2c66affSColin Finck memset(&item, 0, sizeof(item));
3239c2c66affSColin Finck item.mask = LVIF_STATE;
3240c2c66affSColin Finck item.iItem = 0;
3241c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3242c2c66affSColin Finck item.state = LVIS_SELECTED;
3243c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
3244c2c66affSColin Finck expect(FALSE, res);
3245c2c66affSColin Finck memset(&item, 0, sizeof(item));
3246c2c66affSColin Finck item.pszText = test_str;
3247c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&item);
3248c2c66affSColin Finck expect(FALSE, res);
3249c2c66affSColin Finck DestroyWindow(hwnd);
3250c2c66affSColin Finck
3251c2c66affSColin Finck /* check notifications after focused/selected changed */
3252c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3253c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3254c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 20, 0);
3255c2c66affSColin Finck expect(1, res);
3256c2c66affSColin Finck
3257c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3258c2c66affSColin Finck
3259c2c66affSColin Finck memset(&item, 0, sizeof(item));
3260c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3261c2c66affSColin Finck item.state = LVIS_SELECTED;
3262c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
3263c2c66affSColin Finck expect(TRUE, res);
3264c2c66affSColin Finck
3265c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_select_focus_parent_seq,
3266c2c66affSColin Finck "ownerdata select notification", TRUE);
3267c2c66affSColin Finck
3268c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3269c2c66affSColin Finck
3270c2c66affSColin Finck memset(&item, 0, sizeof(item));
3271c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
3272c2c66affSColin Finck item.state = LVIS_FOCUSED;
3273c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
3274c2c66affSColin Finck expect(TRUE, res);
3275c2c66affSColin Finck
3276c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_select_focus_parent_seq,
3277c2c66affSColin Finck "ownerdata focus notification", TRUE);
3278c2c66affSColin Finck
3279c2c66affSColin Finck /* select all, check notifications */
3280c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3281c2c66affSColin Finck item.state = 0;
3282c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3283c2c66affSColin Finck expect(TRUE, res);
3284c2c66affSColin Finck
3285c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3286c2c66affSColin Finck
3287c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3288c2c66affSColin Finck item.state = LVIS_SELECTED;
3289c2c66affSColin Finck
3290c2c66affSColin Finck memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
3291c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3292c2c66affSColin Finck expect(TRUE, res);
3293c2c66affSColin Finck ok(g_nmlistview.iItem == -1, "got item %d\n", g_nmlistview.iItem);
3294c2c66affSColin Finck ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem);
3295c2c66affSColin Finck ok(g_nmlistview.uNewState == LVIS_SELECTED, "got new state 0x%08x\n", g_nmlistview.uNewState);
3296c2c66affSColin Finck ok(g_nmlistview.uOldState == 0, "got old state 0x%08x\n", g_nmlistview.uOldState);
3297c2c66affSColin Finck ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged);
3298c2c66affSColin Finck ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n");
3299c2c66affSColin Finck ok(g_nmlistview.lParam == 0, "got wrong lparam\n");
3300c2c66affSColin Finck
3301c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_setstate_all_parent_seq,
3302c2c66affSColin Finck "ownerdata select all notification", FALSE);
3303c2c66affSColin Finck
3304c2c66affSColin Finck /* select all again, note that all items are selected already */
3305c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3306c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3307c2c66affSColin Finck item.state = LVIS_SELECTED;
3308c2c66affSColin Finck
3309c2c66affSColin Finck memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
3310c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3311c2c66affSColin Finck expect(TRUE, res);
3312c2c66affSColin Finck ok(g_nmlistview.iItem == -1, "got item %d\n", g_nmlistview.iItem);
3313c2c66affSColin Finck ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem);
3314c2c66affSColin Finck ok(g_nmlistview.uNewState == LVIS_SELECTED, "got new state 0x%08x\n", g_nmlistview.uNewState);
3315c2c66affSColin Finck ok(g_nmlistview.uOldState == 0, "got old state 0x%08x\n", g_nmlistview.uOldState);
3316c2c66affSColin Finck ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged);
3317c2c66affSColin Finck ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n");
3318c2c66affSColin Finck ok(g_nmlistview.lParam == 0, "got wrong lparam\n");
3319c2c66affSColin Finck
3320c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_setstate_all_parent_seq,
3321c2c66affSColin Finck "ownerdata select all notification", FALSE);
3322c2c66affSColin Finck
3323c2c66affSColin Finck /* deselect all */
3324c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3325c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3326c2c66affSColin Finck item.state = 0;
3327c2c66affSColin Finck
3328c2c66affSColin Finck memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
3329c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3330c2c66affSColin Finck expect(TRUE, res);
3331c2c66affSColin Finck ok(g_nmlistview.iItem == -1, "got item %d\n", g_nmlistview.iItem);
3332c2c66affSColin Finck ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem);
3333c2c66affSColin Finck ok(g_nmlistview.uNewState == 0, "got new state 0x%08x\n", g_nmlistview.uNewState);
3334c2c66affSColin Finck ok(g_nmlistview.uOldState == LVIS_SELECTED, "got old state 0x%08x\n", g_nmlistview.uOldState);
3335c2c66affSColin Finck ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged);
3336c2c66affSColin Finck ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n");
3337c2c66affSColin Finck ok(g_nmlistview.lParam == 0, "got wrong lparam\n");
3338c2c66affSColin Finck
3339c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_deselect_all_parent_seq,
3340c2c66affSColin Finck "ownerdata deselect all notification", TRUE);
3341c2c66affSColin Finck
3342c2c66affSColin Finck /* nothing selected, deselect all again */
3343c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3344c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3345c2c66affSColin Finck item.state = 0;
3346c2c66affSColin Finck
3347c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3348c2c66affSColin Finck expect(TRUE, res);
3349c2c66affSColin Finck
3350c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "ownerdata deselect all notification", FALSE);
3351c2c66affSColin Finck
3352c2c66affSColin Finck /* select one, then deselect all */
3353c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3354c2c66affSColin Finck item.state = LVIS_SELECTED;
3355c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
3356c2c66affSColin Finck expect(TRUE, res);
3357c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3358c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3359c2c66affSColin Finck item.state = 0;
3360c2c66affSColin Finck
3361c2c66affSColin Finck memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
3362c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3363c2c66affSColin Finck expect(TRUE, res);
3364c2c66affSColin Finck ok(g_nmlistview.iItem == -1, "got item %d\n", g_nmlistview.iItem);
3365c2c66affSColin Finck ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem);
3366c2c66affSColin Finck ok(g_nmlistview.uNewState == 0, "got new state 0x%08x\n", g_nmlistview.uNewState);
3367c2c66affSColin Finck ok(g_nmlistview.uOldState == LVIS_SELECTED, "got old state 0x%08x\n", g_nmlistview.uOldState);
3368c2c66affSColin Finck ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged);
3369c2c66affSColin Finck ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n");
3370c2c66affSColin Finck ok(g_nmlistview.lParam == 0, "got wrong lparam\n");
3371c2c66affSColin Finck
3372c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_deselect_all_parent_seq,
3373c2c66affSColin Finck "ownerdata select all notification", TRUE);
3374c2c66affSColin Finck
3375c2c66affSColin Finck /* remove focused, try to focus all */
3376c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
3377c2c66affSColin Finck item.state = LVIS_FOCUSED;
3378c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
3379c2c66affSColin Finck expect(TRUE, res);
3380c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
3381c2c66affSColin Finck item.state = 0;
3382c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3383c2c66affSColin Finck expect(TRUE, res);
3384c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
3385c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMSTATE, 0, LVIS_FOCUSED);
3386c2c66affSColin Finck expect(0, res);
3387c2c66affSColin Finck
3388c2c66affSColin Finck /* setting all to focused returns failure value */
3389c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3390c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
3391c2c66affSColin Finck item.state = LVIS_FOCUSED;
3392c2c66affSColin Finck
3393c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3394c2c66affSColin Finck expect(FALSE, res);
3395c2c66affSColin Finck
3396c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
3397c2c66affSColin Finck "ownerdata focus all notification", FALSE);
3398c2c66affSColin Finck
3399c2c66affSColin Finck /* focus single item, remove all */
3400c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
3401c2c66affSColin Finck item.state = LVIS_FOCUSED;
3402c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
3403c2c66affSColin Finck expect(TRUE, res);
3404c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3405c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
3406c2c66affSColin Finck item.state = 0;
3407c2c66affSColin Finck
3408c2c66affSColin Finck memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
3409c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3410c2c66affSColin Finck expect(TRUE, res);
3411c2c66affSColin Finck ok(g_nmlistview.iItem == -1, "got item %d\n", g_nmlistview.iItem);
3412c2c66affSColin Finck ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem);
3413c2c66affSColin Finck ok(g_nmlistview.uNewState == 0, "got new state 0x%08x\n", g_nmlistview.uNewState);
3414c2c66affSColin Finck ok(g_nmlistview.uOldState == LVIS_FOCUSED, "got old state 0x%08x\n", g_nmlistview.uOldState);
3415c2c66affSColin Finck ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged);
3416c2c66affSColin Finck ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n");
3417c2c66affSColin Finck ok(g_nmlistview.lParam == 0, "got wrong lparam\n");
3418c2c66affSColin Finck
3419c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_defocus_all_parent_seq,
3420c2c66affSColin Finck "ownerdata remove focus all notification", TRUE);
3421c2c66affSColin Finck
3422c2c66affSColin Finck /* set all cut */
3423c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3424c2c66affSColin Finck item.stateMask = LVIS_CUT;
3425c2c66affSColin Finck item.state = LVIS_CUT;
3426c2c66affSColin Finck
3427c2c66affSColin Finck memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
3428c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3429c2c66affSColin Finck expect(TRUE, res);
3430c2c66affSColin Finck ok(g_nmlistview.iItem == -1, "got item %d\n", g_nmlistview.iItem);
3431c2c66affSColin Finck ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem);
3432c2c66affSColin Finck ok(g_nmlistview.uNewState == LVIS_CUT, "got new state 0x%08x\n", g_nmlistview.uNewState);
3433c2c66affSColin Finck ok(g_nmlistview.uOldState == 0, "got old state 0x%08x\n", g_nmlistview.uOldState);
3434c2c66affSColin Finck ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged);
3435c2c66affSColin Finck ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n");
3436c2c66affSColin Finck ok(g_nmlistview.lParam == 0, "got wrong lparam\n");
3437c2c66affSColin Finck
3438c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_setstate_all_parent_seq,
3439c2c66affSColin Finck "ownerdata cut all notification", FALSE);
3440c2c66affSColin Finck
3441c2c66affSColin Finck /* all marked cut, try again */
3442c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3443c2c66affSColin Finck item.stateMask = LVIS_CUT;
3444c2c66affSColin Finck item.state = LVIS_CUT;
3445c2c66affSColin Finck
3446c2c66affSColin Finck memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
3447c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
3448c2c66affSColin Finck expect(TRUE, res);
3449c2c66affSColin Finck ok(g_nmlistview.iItem == -1, "got item %d\n", g_nmlistview.iItem);
3450c2c66affSColin Finck ok(g_nmlistview.iSubItem == 0, "got subitem %d\n", g_nmlistview.iSubItem);
3451c2c66affSColin Finck ok(g_nmlistview.uNewState == LVIS_CUT, "got new state 0x%08x\n", g_nmlistview.uNewState);
3452c2c66affSColin Finck ok(g_nmlistview.uOldState == 0, "got old state 0x%08x\n", g_nmlistview.uOldState);
3453c2c66affSColin Finck ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged);
3454c2c66affSColin Finck ok(g_nmlistview.ptAction.x == 0 && g_nmlistview.ptAction.y == 0, "got wrong ptAction value\n");
3455c2c66affSColin Finck ok(g_nmlistview.lParam == 0, "got wrong lparam\n");
3456c2c66affSColin Finck
3457c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, ownerdata_setstate_all_parent_seq,
3458c2c66affSColin Finck "ownerdata cut all notification #2", FALSE);
3459c2c66affSColin Finck
3460c2c66affSColin Finck DestroyWindow(hwnd);
3461c2c66affSColin Finck
3462c2c66affSColin Finck /* check notifications on LVM_GETITEM */
3463c2c66affSColin Finck /* zero callback mask */
3464c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3465c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3466c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
3467c2c66affSColin Finck expect(1, res);
3468c2c66affSColin Finck
3469c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3470c2c66affSColin Finck
3471c2c66affSColin Finck memset(&item, 0, sizeof(item));
3472c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3473c2c66affSColin Finck item.mask = LVIF_STATE;
3474c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
3475c2c66affSColin Finck expect(TRUE, res);
3476c2c66affSColin Finck
3477c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
3478c2c66affSColin Finck "ownerdata getitem selected state 1", FALSE);
3479c2c66affSColin Finck
3480c2c66affSColin Finck /* non zero callback mask but not we asking for */
3481c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETCALLBACKMASK, LVIS_OVERLAYMASK, 0);
3482c2c66affSColin Finck expect(TRUE, res);
3483c2c66affSColin Finck
3484c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3485c2c66affSColin Finck
3486c2c66affSColin Finck memset(&item, 0, sizeof(item));
3487c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3488c2c66affSColin Finck item.mask = LVIF_STATE;
3489c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
3490c2c66affSColin Finck expect(TRUE, res);
3491c2c66affSColin Finck
3492c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
3493c2c66affSColin Finck "ownerdata getitem selected state 2", FALSE);
3494c2c66affSColin Finck
3495c2c66affSColin Finck /* LVIS_OVERLAYMASK callback mask, asking for index */
3496c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3497c2c66affSColin Finck
3498c2c66affSColin Finck memset(&item, 0, sizeof(item));
3499c2c66affSColin Finck item.stateMask = LVIS_OVERLAYMASK;
3500c2c66affSColin Finck item.mask = LVIF_STATE;
3501c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
3502c2c66affSColin Finck expect(TRUE, res);
3503c2c66affSColin Finck
3504c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, single_getdispinfo_parent_seq,
3505c2c66affSColin Finck "ownerdata getitem selected state 2", FALSE);
3506c2c66affSColin Finck
3507c2c66affSColin Finck DestroyWindow(hwnd);
3508c2c66affSColin Finck
3509c2c66affSColin Finck /* LVS_SORTASCENDING/LVS_SORTDESCENDING aren't compatible with LVS_OWNERDATA */
3510c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_SORTASCENDING | LVS_REPORT);
3511c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3512c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3513c2c66affSColin Finck ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
3514c2c66affSColin Finck ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
3515c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_SORTASCENDING);
3516c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3517c2c66affSColin Finck ok(!(style & LVS_SORTASCENDING), "Expected LVS_SORTASCENDING not set\n");
3518c2c66affSColin Finck DestroyWindow(hwnd);
3519c2c66affSColin Finck /* apparently it's allowed to switch these style on after creation */
3520c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3521c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3522c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3523c2c66affSColin Finck ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
3524c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTASCENDING);
3525c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3526c2c66affSColin Finck ok(style & LVS_SORTASCENDING, "Expected LVS_SORTASCENDING to be set\n");
3527c2c66affSColin Finck DestroyWindow(hwnd);
3528c2c66affSColin Finck
3529c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3530c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3531c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3532c2c66affSColin Finck ok(style & LVS_OWNERDATA, "Expected LVS_OWNERDATA\n");
3533c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SORTDESCENDING);
3534c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3535c2c66affSColin Finck ok(style & LVS_SORTDESCENDING, "Expected LVS_SORTDESCENDING to be set\n");
3536c2c66affSColin Finck DestroyWindow(hwnd);
3537c2c66affSColin Finck
3538c2c66affSColin Finck /* The focused item is updated after the invalidation */
3539c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3540c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3541c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 3, 0);
3542c2c66affSColin Finck expect(TRUE, res);
3543c2c66affSColin Finck
3544c2c66affSColin Finck memset(&item, 0, sizeof(item));
3545c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
3546c2c66affSColin Finck item.state = LVIS_FOCUSED;
3547c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
3548c2c66affSColin Finck expect(TRUE, res);
3549c2c66affSColin Finck
3550c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3551c2c66affSColin Finck res = SendMessageA(hwnd, LVM_SETITEMCOUNT, 0, 0);
3552c2c66affSColin Finck expect(TRUE, res);
3553c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
3554c2c66affSColin Finck "ownerdata setitemcount", FALSE);
3555c2c66affSColin Finck
3556c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
3557c2c66affSColin Finck expect(-1, res);
3558c2c66affSColin Finck DestroyWindow(hwnd);
3559c2c66affSColin Finck }
3560c2c66affSColin Finck
test_norecompute(void)3561c2c66affSColin Finck static void test_norecompute(void)
3562c2c66affSColin Finck {
3563c2c66affSColin Finck static CHAR testA[] = "test";
3564c2c66affSColin Finck CHAR buff[10];
3565c2c66affSColin Finck LVITEMA item;
3566c2c66affSColin Finck HWND hwnd;
3567c2c66affSColin Finck DWORD res;
3568c2c66affSColin Finck
3569c2c66affSColin Finck /* self containing control */
3570c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
3571c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3572c2c66affSColin Finck memset(&item, 0, sizeof(item));
3573c2c66affSColin Finck item.mask = LVIF_TEXT | LVIF_STATE;
3574c2c66affSColin Finck item.iItem = 0;
3575c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3576c2c66affSColin Finck item.state = LVIS_SELECTED;
3577c2c66affSColin Finck item.pszText = testA;
3578c2c66affSColin Finck res = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
3579c2c66affSColin Finck expect(0, res);
3580c2c66affSColin Finck /* retrieve with LVIF_NORECOMPUTE */
3581c2c66affSColin Finck item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
3582c2c66affSColin Finck item.iItem = 0;
3583c2c66affSColin Finck item.pszText = buff;
35845f7243b5SAmine Khaldi item.cchTextMax = ARRAY_SIZE(buff);
3585c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
3586c2c66affSColin Finck expect(TRUE, res);
3587c2c66affSColin Finck ok(lstrcmpA(buff, testA) == 0, "Expected (%s), got (%s)\n", testA, buff);
3588c2c66affSColin Finck
3589c2c66affSColin Finck item.mask = LVIF_TEXT;
3590c2c66affSColin Finck item.iItem = 1;
3591c2c66affSColin Finck item.pszText = LPSTR_TEXTCALLBACKA;
3592c2c66affSColin Finck res = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
3593c2c66affSColin Finck expect(1, res);
3594c2c66affSColin Finck
3595c2c66affSColin Finck item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
3596c2c66affSColin Finck item.iItem = 1;
3597c2c66affSColin Finck item.pszText = buff;
35985f7243b5SAmine Khaldi item.cchTextMax = ARRAY_SIZE(buff);
3599c2c66affSColin Finck
3600c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3601c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
3602c2c66affSColin Finck expect(TRUE, res);
3603c2c66affSColin Finck ok(item.pszText == LPSTR_TEXTCALLBACKA, "Expected (%p), got (%p)\n",
3604c2c66affSColin Finck LPSTR_TEXTCALLBACKA, (VOID*)item.pszText);
3605c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "retrieve with LVIF_NORECOMPUTE seq", FALSE);
3606c2c66affSColin Finck
3607c2c66affSColin Finck DestroyWindow(hwnd);
3608c2c66affSColin Finck
3609c2c66affSColin Finck /* LVS_OWNERDATA */
3610c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3611c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3612c2c66affSColin Finck
3613c2c66affSColin Finck item.mask = LVIF_STATE;
3614c2c66affSColin Finck item.stateMask = LVIS_SELECTED;
3615c2c66affSColin Finck item.state = LVIS_SELECTED;
3616c2c66affSColin Finck item.iItem = 0;
3617c2c66affSColin Finck res = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
3618c2c66affSColin Finck expect(0, res);
3619c2c66affSColin Finck
3620c2c66affSColin Finck item.mask = LVIF_TEXT | LVIF_NORECOMPUTE;
3621c2c66affSColin Finck item.iItem = 0;
3622c2c66affSColin Finck item.pszText = buff;
36235f7243b5SAmine Khaldi item.cchTextMax = ARRAY_SIZE(buff);
3624c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3625c2c66affSColin Finck res = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
3626c2c66affSColin Finck expect(TRUE, res);
3627c2c66affSColin Finck ok(item.pszText == LPSTR_TEXTCALLBACKA, "Expected (%p), got (%p)\n",
3628c2c66affSColin Finck LPSTR_TEXTCALLBACKA, (VOID*)item.pszText);
3629c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "retrieve with LVIF_NORECOMPUTE seq 2", FALSE);
3630c2c66affSColin Finck
3631c2c66affSColin Finck DestroyWindow(hwnd);
3632c2c66affSColin Finck }
3633c2c66affSColin Finck
test_nosortheader(void)3634c2c66affSColin Finck static void test_nosortheader(void)
3635c2c66affSColin Finck {
3636c2c66affSColin Finck HWND hwnd, header;
3637c2c66affSColin Finck LONG_PTR style;
3638c2c66affSColin Finck
3639c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
3640c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3641c2c66affSColin Finck
3642c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
3643c2c66affSColin Finck ok(IsWindow(header), "header expected\n");
3644c2c66affSColin Finck
3645c2c66affSColin Finck style = GetWindowLongPtrA(header, GWL_STYLE);
3646c2c66affSColin Finck ok(style & HDS_BUTTONS, "expected header to have HDS_BUTTONS\n");
3647c2c66affSColin Finck
3648c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3649c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_NOSORTHEADER);
3650c2c66affSColin Finck /* HDS_BUTTONS retained */
3651c2c66affSColin Finck style = GetWindowLongPtrA(header, GWL_STYLE);
3652c2c66affSColin Finck ok(style & HDS_BUTTONS, "expected header to retain HDS_BUTTONS\n");
3653c2c66affSColin Finck
3654c2c66affSColin Finck DestroyWindow(hwnd);
3655c2c66affSColin Finck
3656c2c66affSColin Finck /* create with LVS_NOSORTHEADER */
3657c2c66affSColin Finck hwnd = create_listview_control(LVS_NOSORTHEADER | LVS_REPORT);
3658c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3659c2c66affSColin Finck
3660c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
3661c2c66affSColin Finck ok(IsWindow(header), "header expected\n");
3662c2c66affSColin Finck
3663c2c66affSColin Finck style = GetWindowLongPtrA(header, GWL_STYLE);
3664c2c66affSColin Finck ok(!(style & HDS_BUTTONS), "expected header to have no HDS_BUTTONS\n");
3665c2c66affSColin Finck
3666c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3667c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_NOSORTHEADER);
3668c2c66affSColin Finck /* not changed here */
3669c2c66affSColin Finck style = GetWindowLongPtrA(header, GWL_STYLE);
3670c2c66affSColin Finck ok(!(style & HDS_BUTTONS), "expected header to have no HDS_BUTTONS\n");
3671c2c66affSColin Finck
3672c2c66affSColin Finck DestroyWindow(hwnd);
3673c2c66affSColin Finck }
3674c2c66affSColin Finck
test_setredraw(void)3675c2c66affSColin Finck static void test_setredraw(void)
3676c2c66affSColin Finck {
3677c2c66affSColin Finck HWND hwnd;
3678c2c66affSColin Finck DWORD_PTR style;
3679c2c66affSColin Finck DWORD ret;
3680c2c66affSColin Finck HDC hdc;
3681c2c66affSColin Finck RECT rect;
3682c2c66affSColin Finck
3683c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
3684c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3685c2c66affSColin Finck
3686c2c66affSColin Finck /* Passing WM_SETREDRAW to DefWinProc removes WS_VISIBLE.
3687c2c66affSColin Finck ListView seems to handle it internally without DefWinProc */
3688c2c66affSColin Finck
3689c2c66affSColin Finck /* default value first */
3690c2c66affSColin Finck ret = SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3691c2c66affSColin Finck expect(0, ret);
3692c2c66affSColin Finck /* disable */
3693c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3694c2c66affSColin Finck ok(style & WS_VISIBLE, "Expected WS_VISIBLE to be set\n");
3695c2c66affSColin Finck ret = SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3696c2c66affSColin Finck expect(0, ret);
3697c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
3698c2c66affSColin Finck ok(style & WS_VISIBLE, "Expected WS_VISIBLE to be set\n");
3699c2c66affSColin Finck ret = SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3700c2c66affSColin Finck expect(0, ret);
3701c2c66affSColin Finck
3702c2c66affSColin Finck /* check update rect after redrawing */
3703c2c66affSColin Finck ret = SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3704c2c66affSColin Finck expect(0, ret);
3705c2c66affSColin Finck InvalidateRect(hwnd, NULL, FALSE);
3706c2c66affSColin Finck RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW);
3707c2c66affSColin Finck rect.right = rect.bottom = 1;
3708c2c66affSColin Finck GetUpdateRect(hwnd, &rect, FALSE);
3709c2c66affSColin Finck expect(0, rect.right);
3710c2c66affSColin Finck expect(0, rect.bottom);
3711c2c66affSColin Finck
3712c2c66affSColin Finck /* WM_ERASEBKGND */
3713c2c66affSColin Finck hdc = GetWindowDC(hwndparent);
3714c2c66affSColin Finck ret = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
3715c2c66affSColin Finck expect(TRUE, ret);
3716c2c66affSColin Finck ret = SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3717c2c66affSColin Finck expect(0, ret);
3718c2c66affSColin Finck ret = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
3719c2c66affSColin Finck expect(TRUE, ret);
3720c2c66affSColin Finck ret = SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3721c2c66affSColin Finck expect(0, ret);
3722c2c66affSColin Finck ReleaseDC(hwndparent, hdc);
3723c2c66affSColin Finck
3724c2c66affSColin Finck /* check notification messages to show that repainting is disabled */
3725c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
3726c2c66affSColin Finck expect(TRUE, ret);
3727c2c66affSColin Finck ret = SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3728c2c66affSColin Finck expect(0, ret);
3729c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3730c2c66affSColin Finck
3731c2c66affSColin Finck InvalidateRect(hwnd, NULL, TRUE);
3732c2c66affSColin Finck UpdateWindow(hwnd);
3733c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
3734c2c66affSColin Finck "redraw after WM_SETREDRAW (FALSE)", FALSE);
3735c2c66affSColin Finck
3736c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, CLR_NONE);
3737c2c66affSColin Finck expect(TRUE, ret);
3738c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3739c2c66affSColin Finck InvalidateRect(hwnd, NULL, TRUE);
3740c2c66affSColin Finck UpdateWindow(hwnd);
3741c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
3742c2c66affSColin Finck "redraw after WM_SETREDRAW (FALSE) with CLR_NONE bkgnd", FALSE);
3743c2c66affSColin Finck
3744c2c66affSColin Finck /* message isn't forwarded to header */
3745c2c66affSColin Finck subclass_header(hwnd);
3746c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
3747c2c66affSColin Finck ret = SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3748c2c66affSColin Finck expect(0, ret);
3749c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, setredraw_seq,
3750c2c66affSColin Finck "WM_SETREDRAW: not forwarded to header", FALSE);
3751c2c66affSColin Finck
3752c2c66affSColin Finck DestroyWindow(hwnd);
3753c2c66affSColin Finck }
3754c2c66affSColin Finck
test_hittest(void)3755c2c66affSColin Finck static void test_hittest(void)
3756c2c66affSColin Finck {
3757c2c66affSColin Finck HWND hwnd;
3758c2c66affSColin Finck DWORD r;
3759c2c66affSColin Finck RECT bounds;
3760c2c66affSColin Finck LVITEMA item;
3761c2c66affSColin Finck static CHAR text[] = "1234567890ABCDEFGHIJKLMNOPQRST";
3762c2c66affSColin Finck POINT pos;
3763c2c66affSColin Finck INT x, y, i;
3764c2c66affSColin Finck WORD vert;
3765c2c66affSColin Finck HIMAGELIST himl, himl2;
3766c2c66affSColin Finck HBITMAP hbmp;
3767c2c66affSColin Finck
3768c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
3769c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3770c2c66affSColin Finck
3771c2c66affSColin Finck /* LVS_REPORT with a single subitem (2 columns) */
3772c2c66affSColin Finck insert_column(hwnd, 0);
3773c2c66affSColin Finck insert_column(hwnd, 1);
3774c2c66affSColin Finck insert_item(hwnd, 0);
3775c2c66affSColin Finck
3776c2c66affSColin Finck item.iSubItem = 0;
3777c2c66affSColin Finck /* the only purpose of that line is to be as long as a half item rect */
3778c2c66affSColin Finck item.pszText = text;
3779c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&item);
3780c2c66affSColin Finck expect(TRUE, r);
3781c2c66affSColin Finck
3782c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0));
3783c2c66affSColin Finck expect(TRUE, r);
3784c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(100, 0));
3785c2c66affSColin Finck expect(TRUE, r);
3786c2c66affSColin Finck
3787c2c66affSColin Finck SetRect(&bounds, LVIR_BOUNDS, 0, 0, 0);
3788c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&bounds);
3789c2c66affSColin Finck expect(1, r);
3790c2c66affSColin Finck ok(bounds.bottom - bounds.top > 0, "Expected non zero item height\n");
3791c2c66affSColin Finck ok(bounds.right - bounds.left > 0, "Expected non zero item width\n");
3792c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMSPACING, TRUE, 0);
3793c2c66affSColin Finck vert = HIWORD(r);
3794c2c66affSColin Finck ok(bounds.bottom - bounds.top == vert,
3795c2c66affSColin Finck "Vertical spacing inconsistent (%d != %d)\n", bounds.bottom - bounds.top, vert);
3796c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pos);
3797c2c66affSColin Finck expect(TRUE, r);
3798c2c66affSColin Finck
3799c2c66affSColin Finck /* LVS_EX_FULLROWSELECT not set, no icons attached */
3800c2c66affSColin Finck
3801c2c66affSColin Finck /* outside columns by x position - valid is [0, 199] */
3802c2c66affSColin Finck x = -1;
3803c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3804c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TOLEFT, 0, FALSE, FALSE);
3805c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE);
3806c2c66affSColin Finck
3807c2c66affSColin Finck x = pos.x + 50; /* column half width */
3808c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3809c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMLABEL, 0, FALSE, FALSE);
3810c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3811c2c66affSColin Finck x = pos.x + 150; /* outside column */
3812c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3813c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, FALSE);
3814c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3815c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3816c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, TRUE);
3817c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3818c2c66affSColin Finck /* outside possible client rectangle (to right) */
3819c2c66affSColin Finck x = pos.x + 500;
3820c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3821c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, FALSE);
3822c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE);
3823c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3824c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, TRUE);
3825c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE);
3826c2c66affSColin Finck /* subitem returned with -1 item too */
3827c2c66affSColin Finck x = pos.x + 150;
3828c2c66affSColin Finck y = bounds.top - vert;
3829c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, -1, 1, LVHT_NOWHERE, FALSE, FALSE, FALSE);
3830c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y - vert + 1, -1, 1, LVHT_NOWHERE, FALSE, FALSE, FALSE);
3831c2c66affSColin Finck /* return values appear to underflow with negative indices */
3832c2c66affSColin Finck i = -2;
3833c2c66affSColin Finck y = y - vert;
3834c2c66affSColin Finck while (i > -10) {
3835c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, i, 1, LVHT_ONITEMLABEL, TRUE, FALSE, TRUE);
3836c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y - vert + 1, i, 1, LVHT_ONITEMLABEL, TRUE, FALSE, TRUE);
3837c2c66affSColin Finck y = y - vert;
3838c2c66affSColin Finck i--;
3839c2c66affSColin Finck }
3840c2c66affSColin Finck /* parent client area is 100x100 by default */
3841c2c66affSColin Finck MoveWindow(hwnd, 0, 0, 300, 100, FALSE);
3842c2c66affSColin Finck x = pos.x + 150; /* outside column */
3843c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3844c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_NOWHERE, 0, FALSE, FALSE);
3845c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3846c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3847c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_NOWHERE, 0, FALSE, TRUE);
3848c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3849c2c66affSColin Finck /* the same with LVS_EX_FULLROWSELECT */
3850c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);
3851c2c66affSColin Finck x = pos.x + 150; /* outside column */
3852c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3853c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEM, LVHT_ONITEMLABEL, FALSE, FALSE);
3854c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3855c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3856c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3857c2c66affSColin Finck MoveWindow(hwnd, 0, 0, 100, 100, FALSE);
3858c2c66affSColin Finck x = pos.x + 150; /* outside column */
3859c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3860c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, FALSE);
3861c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3862c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3863c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, TRUE);
3864c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, FALSE, FALSE, FALSE);
3865c2c66affSColin Finck /* outside possible client rectangle (to right) */
3866c2c66affSColin Finck x = pos.x + 500;
3867c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3868c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, FALSE);
3869c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE);
3870c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3871c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, 0, FALSE, TRUE);
3872c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, -1, -1, LVHT_NOWHERE, FALSE, FALSE, FALSE);
3873c2c66affSColin Finck /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
3874f37104daSAmine Khaldi himl = pImageList_Create(16, 16, 0, 4, 4);
3875c2c66affSColin Finck ok(himl != NULL, "failed to create imagelist\n");
3876c2c66affSColin Finck hbmp = CreateBitmap(16, 16, 1, 1, NULL);
3877c2c66affSColin Finck ok(hbmp != NULL, "failed to create bitmap\n");
3878f37104daSAmine Khaldi r = pImageList_Add(himl, hbmp, 0);
3879c2c66affSColin Finck ok(r == 0, "should be zero\n");
3880c2c66affSColin Finck hbmp = CreateBitmap(16, 16, 1, 1, NULL);
3881c2c66affSColin Finck ok(hbmp != NULL, "failed to create bitmap\n");
3882f37104daSAmine Khaldi r = pImageList_Add(himl, hbmp, 0);
3883c2c66affSColin Finck ok(r == 1, "should be one\n");
3884c2c66affSColin Finck
3885c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl);
3886c2c66affSColin Finck expect(0, r);
3887c2c66affSColin Finck
3888c2c66affSColin Finck item.mask = LVIF_IMAGE;
3889c2c66affSColin Finck item.iImage = 0;
3890c2c66affSColin Finck item.iItem = 0;
3891c2c66affSColin Finck item.iSubItem = 0;
3892c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
3893c2c66affSColin Finck expect(TRUE, r);
3894c2c66affSColin Finck /* on state icon */
3895c2c66affSColin Finck x = pos.x + 8;
3896c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3897c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, 0, FALSE, FALSE);
3898c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE);
3899c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3900c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE);
3901c2c66affSColin Finck
3902c2c66affSColin Finck /* state icons indices are 1 based, check with valid index */
3903c2c66affSColin Finck item.mask = LVIF_STATE;
3904c2c66affSColin Finck item.state = INDEXTOSTATEIMAGEMASK(1);
3905c2c66affSColin Finck item.stateMask = LVIS_STATEIMAGEMASK;
3906c2c66affSColin Finck item.iItem = 0;
3907c2c66affSColin Finck item.iSubItem = 0;
3908c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
3909c2c66affSColin Finck expect(TRUE, r);
3910c2c66affSColin Finck /* on state icon */
3911c2c66affSColin Finck x = pos.x + 8;
3912c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3913c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, 0, FALSE, FALSE);
3914c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE);
3915c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3916c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE);
3917c2c66affSColin Finck
3918c2c66affSColin Finck himl2 = (HIMAGELIST)SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, 0);
3919c2c66affSColin Finck ok(himl2 == himl, "should return handle\n");
3920c2c66affSColin Finck
3921c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl);
3922c2c66affSColin Finck expect(0, r);
3923c2c66affSColin Finck /* on item icon */
3924c2c66affSColin Finck x = pos.x + 8;
3925c2c66affSColin Finck y = pos.y + (bounds.bottom - bounds.top) / 2;
3926c2c66affSColin Finck test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMICON, 0, FALSE, FALSE);
3927c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMICON, FALSE, FALSE, FALSE);
3928c2c66affSColin Finck y = (bounds.bottom - bounds.top) / 2;
3929c2c66affSColin Finck test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMICON, FALSE, FALSE, FALSE);
3930c2c66affSColin Finck
3931c2c66affSColin Finck DestroyWindow(hwnd);
3932c2c66affSColin Finck }
3933c2c66affSColin Finck
test_getviewrect(void)3934c2c66affSColin Finck static void test_getviewrect(void)
3935c2c66affSColin Finck {
3936c2c66affSColin Finck HWND hwnd;
3937c2c66affSColin Finck DWORD r;
3938c2c66affSColin Finck RECT rect;
3939c2c66affSColin Finck LVITEMA item;
3940c2c66affSColin Finck
3941c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
3942c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3943c2c66affSColin Finck
3944c2c66affSColin Finck /* empty */
3945c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
3946c2c66affSColin Finck expect(TRUE, r);
3947c2c66affSColin Finck
3948c2c66affSColin Finck insert_column(hwnd, 0);
3949c2c66affSColin Finck insert_column(hwnd, 1);
3950c2c66affSColin Finck
3951c2c66affSColin Finck memset(&item, 0, sizeof(item));
3952c2c66affSColin Finck item.iItem = 0;
3953c2c66affSColin Finck item.iSubItem = 0;
3954c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
3955c2c66affSColin Finck ok(!r, "got %d\n", r);
3956c2c66affSColin Finck
3957c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0));
3958c2c66affSColin Finck expect(TRUE, r);
3959c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(120, 0));
3960c2c66affSColin Finck expect(TRUE, r);
3961c2c66affSColin Finck
3962c2c66affSColin Finck SetRect(&rect, -1, -1, -1, -1);
3963c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
3964c2c66affSColin Finck expect(TRUE, r);
3965c2c66affSColin Finck /* left is set to (2e31-1) - XP SP2 */
3966c2c66affSColin Finck expect(0, rect.right);
3967c2c66affSColin Finck expect(0, rect.top);
3968c2c66affSColin Finck expect(0, rect.bottom);
3969c2c66affSColin Finck
3970c2c66affSColin Finck /* switch to LVS_ICON */
3971c2c66affSColin Finck SetWindowLongA(hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) & ~LVS_REPORT);
3972c2c66affSColin Finck
3973c2c66affSColin Finck SetRect(&rect, -1, -1, -1, -1);
3974c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETVIEWRECT, 0, (LPARAM)&rect);
3975c2c66affSColin Finck expect(TRUE, r);
3976c2c66affSColin Finck expect(0, rect.left);
3977c2c66affSColin Finck expect(0, rect.top);
3978c2c66affSColin Finck /* precise value differs for 2k, XP and Vista */
3979c2c66affSColin Finck ok(rect.bottom > 0, "Expected positive bottom value, got %d\n", rect.bottom);
3980c2c66affSColin Finck ok(rect.right > 0, "Expected positive right value, got %d\n", rect.right);
3981c2c66affSColin Finck
3982c2c66affSColin Finck DestroyWindow(hwnd);
3983c2c66affSColin Finck }
3984c2c66affSColin Finck
test_getitemposition(void)3985c2c66affSColin Finck static void test_getitemposition(void)
3986c2c66affSColin Finck {
3987c2c66affSColin Finck HWND hwnd, header;
3988c2c66affSColin Finck DWORD r;
3989c2c66affSColin Finck POINT pt;
3990c2c66affSColin Finck RECT rect;
3991c2c66affSColin Finck
3992c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
3993c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
3994c2c66affSColin Finck header = subclass_header(hwnd);
3995c2c66affSColin Finck
3996c2c66affSColin Finck /* LVS_REPORT, single item, no columns added */
3997c2c66affSColin Finck insert_item(hwnd, 0);
3998c2c66affSColin Finck
3999c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4000c2c66affSColin Finck
4001c2c66affSColin Finck pt.x = pt.y = -1;
4002c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
4003c2c66affSColin Finck expect(TRUE, r);
4004c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getitemposition_seq1, "get item position 1", FALSE);
4005c2c66affSColin Finck
4006c2c66affSColin Finck /* LVS_REPORT, single item, single column */
4007c2c66affSColin Finck insert_column(hwnd, 0);
4008c2c66affSColin Finck
4009c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4010c2c66affSColin Finck
4011c2c66affSColin Finck pt.x = pt.y = -1;
4012c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
4013c2c66affSColin Finck expect(TRUE, r);
4014c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, getitemposition_seq2, "get item position 2", TRUE);
4015c2c66affSColin Finck
4016c2c66affSColin Finck SetRectEmpty(&rect);
4017c2c66affSColin Finck r = SendMessageA(header, HDM_GETITEMRECT, 0, (LPARAM)&rect);
4018c2c66affSColin Finck ok(r, "got %d\n", r);
4019c2c66affSColin Finck /* some padding? */
4020c2c66affSColin Finck expect(2, pt.x);
4021c2c66affSColin Finck /* offset by header height */
4022c2c66affSColin Finck expect(rect.bottom - rect.top, pt.y);
4023c2c66affSColin Finck
4024c2c66affSColin Finck DestroyWindow(hwnd);
4025c2c66affSColin Finck }
4026c2c66affSColin Finck
test_getitemrect(void)4027c2c66affSColin Finck static void test_getitemrect(void)
4028c2c66affSColin Finck {
4029c2c66affSColin Finck HWND hwnd;
4030c2c66affSColin Finck HIMAGELIST himl, himl_ret;
4031c2c66affSColin Finck HBITMAP hbm;
4032c2c66affSColin Finck RECT rect;
4033c2c66affSColin Finck DWORD r;
4034c2c66affSColin Finck LVITEMA item;
4035c2c66affSColin Finck LVCOLUMNA col;
4036c2c66affSColin Finck INT order[2];
4037c2c66affSColin Finck POINT pt;
4038c2c66affSColin Finck
4039c2c66affSColin Finck /* rectangle isn't empty for empty text items */
4040c2c66affSColin Finck hwnd = create_listview_control(LVS_LIST);
4041c2c66affSColin Finck memset(&item, 0, sizeof(item));
4042c2c66affSColin Finck item.mask = 0;
4043c2c66affSColin Finck item.iItem = 0;
4044c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
4045c2c66affSColin Finck expect(0, r);
4046c2c66affSColin Finck rect.left = LVIR_LABEL;
4047c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4048c2c66affSColin Finck expect(TRUE, r);
4049c2c66affSColin Finck expect(0, rect.left);
4050c2c66affSColin Finck expect(0, rect.top);
4051c2c66affSColin Finck /* estimate it as width / height ratio */
4052c2c66affSColin Finck todo_wine
4053c2c66affSColin Finck ok((rect.right / rect.bottom) >= 5, "got right %d, bottom %d\n", rect.right, rect.bottom);
4054c2c66affSColin Finck DestroyWindow(hwnd);
4055c2c66affSColin Finck
4056c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
4057c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4058c2c66affSColin Finck
4059c2c66affSColin Finck /* empty item */
4060c2c66affSColin Finck memset(&item, 0, sizeof(item));
4061c2c66affSColin Finck item.iItem = 0;
4062c2c66affSColin Finck item.iSubItem = 0;
4063c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
4064c2c66affSColin Finck expect(0, r);
4065c2c66affSColin Finck
4066c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, -1, -1, -1);
4067c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4068c2c66affSColin Finck expect(TRUE, r);
4069c2c66affSColin Finck
4070c2c66affSColin Finck /* zero width rectangle with no padding */
4071c2c66affSColin Finck expect(0, rect.left);
4072c2c66affSColin Finck expect(0, rect.right);
4073c2c66affSColin Finck
4074c2c66affSColin Finck insert_column(hwnd, 0);
4075c2c66affSColin Finck insert_column(hwnd, 1);
4076c2c66affSColin Finck
4077c2c66affSColin Finck col.mask = LVCF_WIDTH;
4078c2c66affSColin Finck col.cx = 50;
4079c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNA, 0, (LPARAM)&col);
4080c2c66affSColin Finck expect(TRUE, r);
4081c2c66affSColin Finck
4082c2c66affSColin Finck col.mask = LVCF_WIDTH;
4083c2c66affSColin Finck col.cx = 100;
4084c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNA, 1, (LPARAM)&col);
4085c2c66affSColin Finck expect(TRUE, r);
4086c2c66affSColin Finck
4087c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, -1, -1, -1);
4088c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4089c2c66affSColin Finck expect(TRUE, r);
4090c2c66affSColin Finck
4091c2c66affSColin Finck /* still no left padding */
4092c2c66affSColin Finck expect(0, rect.left);
4093c2c66affSColin Finck expect(150, rect.right);
4094c2c66affSColin Finck
4095c2c66affSColin Finck SetRect(&rect, LVIR_SELECTBOUNDS, -1, -1, -1);
4096c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4097c2c66affSColin Finck expect(TRUE, r);
4098c2c66affSColin Finck /* padding */
4099c2c66affSColin Finck expect(2, rect.left);
4100c2c66affSColin Finck
4101c2c66affSColin Finck SetRect(&rect, LVIR_LABEL, -1, -1, -1);
4102c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4103c2c66affSColin Finck expect(TRUE, r);
4104c2c66affSColin Finck /* padding, column width */
4105c2c66affSColin Finck expect(2, rect.left);
4106c2c66affSColin Finck expect(50, rect.right);
4107c2c66affSColin Finck
4108c2c66affSColin Finck /* no icons attached */
4109c2c66affSColin Finck SetRect(&rect, LVIR_ICON, -1, -1, -1);
4110c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4111c2c66affSColin Finck expect(TRUE, r);
4112c2c66affSColin Finck /* padding */
4113c2c66affSColin Finck expect(2, rect.left);
4114c2c66affSColin Finck expect(2, rect.right);
4115c2c66affSColin Finck
4116c2c66affSColin Finck /* change order */
4117c2c66affSColin Finck order[0] = 1; order[1] = 0;
4118c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNORDERARRAY, 2, (LPARAM)&order);
4119c2c66affSColin Finck expect(TRUE, r);
4120c2c66affSColin Finck pt.x = -1;
4121c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMPOSITION, 0, (LPARAM)&pt);
4122c2c66affSColin Finck expect(TRUE, r);
4123c2c66affSColin Finck /* 1 indexed column width + padding */
4124c2c66affSColin Finck expect(102, pt.x);
4125c2c66affSColin Finck /* rect is at zero too */
4126c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, -1, -1, -1);
4127c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4128c2c66affSColin Finck expect(TRUE, r);
4129c2c66affSColin Finck expect(0, rect.left);
4130c2c66affSColin Finck /* just width sum */
4131c2c66affSColin Finck expect(150, rect.right);
4132c2c66affSColin Finck
4133c2c66affSColin Finck SetRect(&rect, LVIR_SELECTBOUNDS, -1, -1, -1);
4134c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4135c2c66affSColin Finck expect(TRUE, r);
4136c2c66affSColin Finck /* column width + padding */
4137c2c66affSColin Finck expect(102, rect.left);
4138c2c66affSColin Finck
4139c2c66affSColin Finck /* back to initial order */
4140c2c66affSColin Finck order[0] = 0; order[1] = 1;
4141c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETCOLUMNORDERARRAY, 2, (LPARAM)&order);
4142c2c66affSColin Finck expect(TRUE, r);
4143c2c66affSColin Finck
4144c2c66affSColin Finck /* state icons */
4145f37104daSAmine Khaldi himl = pImageList_Create(16, 16, 0, 2, 2);
4146c2c66affSColin Finck ok(himl != NULL, "failed to create imagelist\n");
4147c2c66affSColin Finck hbm = CreateBitmap(16, 16, 1, 1, NULL);
4148c2c66affSColin Finck ok(hbm != NULL, "failed to create bitmap\n");
4149f37104daSAmine Khaldi r = pImageList_Add(himl, hbm, 0);
4150c2c66affSColin Finck expect(0, r);
4151c2c66affSColin Finck hbm = CreateBitmap(16, 16, 1, 1, NULL);
4152c2c66affSColin Finck ok(hbm != NULL, "failed to create bitmap\n");
4153f37104daSAmine Khaldi r = pImageList_Add(himl, hbm, 0);
4154c2c66affSColin Finck expect(1, r);
4155c2c66affSColin Finck
4156c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl);
4157c2c66affSColin Finck expect(0, r);
4158c2c66affSColin Finck
4159c2c66affSColin Finck item.mask = LVIF_STATE;
4160c2c66affSColin Finck item.state = INDEXTOSTATEIMAGEMASK(1);
4161c2c66affSColin Finck item.stateMask = LVIS_STATEIMAGEMASK;
4162c2c66affSColin Finck item.iItem = 0;
4163c2c66affSColin Finck item.iSubItem = 0;
4164c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
4165c2c66affSColin Finck expect(TRUE, r);
4166c2c66affSColin Finck
4167c2c66affSColin Finck /* icon bounds */
4168c2c66affSColin Finck SetRect(&rect, LVIR_ICON, -1, -1, -1);
4169c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4170c2c66affSColin Finck expect(TRUE, r);
4171c2c66affSColin Finck /* padding + stateicon width */
4172c2c66affSColin Finck expect(18, rect.left);
4173c2c66affSColin Finck expect(18, rect.right);
4174c2c66affSColin Finck /* label bounds */
4175c2c66affSColin Finck SetRect(&rect, LVIR_LABEL, -1, -1, -1);
4176c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4177c2c66affSColin Finck expect(TRUE, r);
4178c2c66affSColin Finck /* padding + stateicon width -> column width */
4179c2c66affSColin Finck expect(18, rect.left);
4180c2c66affSColin Finck expect(50, rect.right);
4181c2c66affSColin Finck
4182c2c66affSColin Finck himl_ret = (HIMAGELIST)SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, 0);
4183c2c66affSColin Finck ok(himl_ret == himl, "got %p, expected %p\n", himl_ret, himl);
4184c2c66affSColin Finck
4185c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl);
4186c2c66affSColin Finck expect(0, r);
4187c2c66affSColin Finck
4188c2c66affSColin Finck item.mask = LVIF_STATE | LVIF_IMAGE;
4189c2c66affSColin Finck item.iImage = 1;
4190c2c66affSColin Finck item.state = 0;
4191c2c66affSColin Finck item.stateMask = ~0;
4192c2c66affSColin Finck item.iItem = 0;
4193c2c66affSColin Finck item.iSubItem = 0;
4194c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
4195c2c66affSColin Finck expect(TRUE, r);
4196c2c66affSColin Finck
4197c2c66affSColin Finck /* icon bounds */
4198c2c66affSColin Finck SetRect(&rect, LVIR_ICON, -1, -1, -1);
4199c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4200c2c66affSColin Finck expect(TRUE, r);
4201c2c66affSColin Finck /* padding, icon width */
4202c2c66affSColin Finck expect(2, rect.left);
4203c2c66affSColin Finck expect(18, rect.right);
4204c2c66affSColin Finck /* label bounds */
4205c2c66affSColin Finck SetRect(&rect, LVIR_LABEL, -1, -1, -1);
4206c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4207c2c66affSColin Finck expect(TRUE, r);
4208c2c66affSColin Finck /* padding + icon width -> column width */
4209c2c66affSColin Finck expect(18, rect.left);
4210c2c66affSColin Finck expect(50, rect.right);
4211c2c66affSColin Finck
4212c2c66affSColin Finck /* select bounds */
4213c2c66affSColin Finck SetRect(&rect, LVIR_SELECTBOUNDS, -1, -1, -1);
4214c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4215c2c66affSColin Finck expect(TRUE, r);
4216c2c66affSColin Finck /* padding, column width */
4217c2c66affSColin Finck expect(2, rect.left);
4218c2c66affSColin Finck expect(50, rect.right);
4219c2c66affSColin Finck
4220c2c66affSColin Finck /* try with indentation */
4221c2c66affSColin Finck item.mask = LVIF_INDENT;
4222c2c66affSColin Finck item.iIndent = 1;
4223c2c66affSColin Finck item.iItem = 0;
4224c2c66affSColin Finck item.iSubItem = 0;
4225c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
4226c2c66affSColin Finck expect(TRUE, r);
4227c2c66affSColin Finck
4228c2c66affSColin Finck /* bounds */
4229c2c66affSColin Finck SetRect(&rect, LVIR_BOUNDS, -1, -1, -1);
4230c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4231c2c66affSColin Finck expect(TRUE, r);
4232c2c66affSColin Finck /* padding + 1 icon width, column width */
4233c2c66affSColin Finck expect(0, rect.left);
4234c2c66affSColin Finck expect(150, rect.right);
4235c2c66affSColin Finck
4236c2c66affSColin Finck /* select bounds */
4237c2c66affSColin Finck SetRect(&rect, LVIR_SELECTBOUNDS, -1, -1, -1);
4238c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4239c2c66affSColin Finck expect(TRUE, r);
4240c2c66affSColin Finck /* padding + 1 icon width, column width */
4241c2c66affSColin Finck expect(2 + 16, rect.left);
4242c2c66affSColin Finck expect(50, rect.right);
4243c2c66affSColin Finck
4244c2c66affSColin Finck /* label bounds */
4245c2c66affSColin Finck SetRect(&rect, LVIR_LABEL, -1, -1, -1);
4246c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4247c2c66affSColin Finck expect(TRUE, r);
4248c2c66affSColin Finck /* padding + 2 icon widths, column width */
4249c2c66affSColin Finck expect(2 + 16*2, rect.left);
4250c2c66affSColin Finck expect(50, rect.right);
4251c2c66affSColin Finck
4252c2c66affSColin Finck /* icon bounds */
4253c2c66affSColin Finck SetRect(&rect, LVIR_ICON, -1, -1, -1);
4254c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMRECT, 0, (LPARAM)&rect);
4255c2c66affSColin Finck expect(TRUE, r);
4256c2c66affSColin Finck /* padding + 1 icon width indentation, icon width */
4257c2c66affSColin Finck expect(2 + 16, rect.left);
4258c2c66affSColin Finck expect(34, rect.right);
4259c2c66affSColin Finck
4260c2c66affSColin Finck DestroyWindow(hwnd);
4261c2c66affSColin Finck }
4262c2c66affSColin Finck
test_editbox(void)4263c2c66affSColin Finck static void test_editbox(void)
4264c2c66affSColin Finck {
4265c2c66affSColin Finck static CHAR testitemA[] = "testitem";
4266c2c66affSColin Finck static CHAR testitem1A[] = "testitem_quitelongname";
4267c2c66affSColin Finck static CHAR testitem2A[] = "testITEM_quitelongname";
4268c2c66affSColin Finck static CHAR buffer[25];
4269c2c66affSColin Finck HWND hwnd, hwndedit, hwndedit2, header;
4270c2c66affSColin Finck LVITEMA item;
4271c2c66affSColin Finck INT r;
4272c2c66affSColin Finck
4273c2c66affSColin Finck hwnd = create_listview_control(LVS_EDITLABELS | LVS_REPORT);
4274c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4275c2c66affSColin Finck
4276c2c66affSColin Finck insert_column(hwnd, 0);
4277c2c66affSColin Finck
4278c2c66affSColin Finck memset(&item, 0, sizeof(item));
4279c2c66affSColin Finck item.mask = LVIF_TEXT;
4280c2c66affSColin Finck item.pszText = testitemA;
4281c2c66affSColin Finck item.iItem = 0;
4282c2c66affSColin Finck item.iSubItem = 0;
4283c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
4284c2c66affSColin Finck expect(0, r);
4285c2c66affSColin Finck
4286c2c66affSColin Finck /* test notifications without edit created */
4287c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4288c2c66affSColin Finck r = SendMessageA(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_SETFOCUS), (LPARAM)0xdeadbeef);
4289c2c66affSColin Finck expect(0, r);
4290c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
4291c2c66affSColin Finck "edit box WM_COMMAND (EN_SETFOCUS), no edit created", FALSE);
4292c2c66affSColin Finck /* same thing but with valid window */
4293f37104daSAmine Khaldi hwndedit = CreateWindowA(WC_EDITA, "Test edit", WS_VISIBLE | WS_CHILD, 0, 0, 20,
4294c2c66affSColin Finck 10, hwnd, (HMENU)1, (HINSTANCE)GetWindowLongPtrA(hwnd, GWLP_HINSTANCE), 0);
4295c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4296c2c66affSColin Finck r = SendMessageA(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_SETFOCUS), (LPARAM)hwndedit);
4297c2c66affSColin Finck expect(0, r);
4298c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
4299c2c66affSColin Finck "edit box WM_COMMAND (EN_SETFOCUS), no edit created #2", FALSE);
4300c2c66affSColin Finck DestroyWindow(hwndedit);
4301c2c66affSColin Finck
4302c2c66affSColin Finck /* setting focus is necessary */
4303c2c66affSColin Finck SetFocus(hwnd);
4304c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4305c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4306c2c66affSColin Finck
4307c2c66affSColin Finck /* test children Z-order after Edit box created */
4308c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
4309c2c66affSColin Finck ok(IsWindow(header), "Expected header to be created\n");
4310c2c66affSColin Finck ok(GetTopWindow(hwnd) == header, "Expected header to be on top\n");
4311c2c66affSColin Finck ok(GetNextWindow(header, GW_HWNDNEXT) == hwndedit, "got %p\n", GetNextWindow(header, GW_HWNDNEXT));
4312c2c66affSColin Finck
4313c2c66affSColin Finck /* modify initial string */
4314c2c66affSColin Finck r = SendMessageA(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem1A);
4315c2c66affSColin Finck expect(TRUE, r);
4316c2c66affSColin Finck
4317c2c66affSColin Finck /* edit window is resized and repositioned,
4318c2c66affSColin Finck check again for Z-order - it should be preserved */
4319c2c66affSColin Finck ok(GetTopWindow(hwnd) == header, "Expected header to be on top\n");
4320c2c66affSColin Finck ok(GetNextWindow(header, GW_HWNDNEXT) == hwndedit, "got %p\n", GetNextWindow(header, GW_HWNDNEXT));
4321c2c66affSColin Finck
4322c2c66affSColin Finck /* return focus to listview */
4323c2c66affSColin Finck SetFocus(hwnd);
4324c2c66affSColin Finck
4325c2c66affSColin Finck memset(&item, 0, sizeof(item));
4326c2c66affSColin Finck item.mask = LVIF_TEXT;
4327c2c66affSColin Finck item.pszText = buffer;
4328c2c66affSColin Finck item.cchTextMax = sizeof(buffer);
4329c2c66affSColin Finck item.iItem = 0;
4330c2c66affSColin Finck item.iSubItem = 0;
4331c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
4332c2c66affSColin Finck expect(TRUE, r);
4333c2c66affSColin Finck
4334c2c66affSColin Finck ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
4335c2c66affSColin Finck
4336c2c66affSColin Finck /* send LVM_EDITLABEL on already created edit */
4337c2c66affSColin Finck SetFocus(hwnd);
4338c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4339c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4340c2c66affSColin Finck /* focus will be set to edit */
4341c2c66affSColin Finck ok(GetFocus() == hwndedit, "Expected Edit window to be focused\n");
4342c2c66affSColin Finck hwndedit2 = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4343c2c66affSColin Finck ok(IsWindow(hwndedit2), "Expected Edit window to be created\n");
4344c2c66affSColin Finck
4345c2c66affSColin Finck /* creating label disabled when control isn't focused */
4346c2c66affSColin Finck SetFocus(0);
4347c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4348c2c66affSColin Finck todo_wine ok(hwndedit == NULL, "Expected Edit window not to be created\n");
4349c2c66affSColin Finck
4350c2c66affSColin Finck /* check EN_KILLFOCUS handling */
4351c2c66affSColin Finck memset(&item, 0, sizeof(item));
4352c2c66affSColin Finck item.pszText = testitemA;
4353c2c66affSColin Finck item.iItem = 0;
4354c2c66affSColin Finck item.iSubItem = 0;
4355c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&item);
4356c2c66affSColin Finck expect(TRUE, r);
4357c2c66affSColin Finck
4358c2c66affSColin Finck SetFocus(hwnd);
4359c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4360c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4361c2c66affSColin Finck /* modify edit and notify control that it lost focus */
4362c2c66affSColin Finck r = SendMessageA(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem1A);
4363c2c66affSColin Finck expect(TRUE, r);
4364c2c66affSColin Finck g_editbox_disp_info.item.pszText = NULL;
4365c2c66affSColin Finck r = SendMessageA(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit);
4366c2c66affSColin Finck expect(0, r);
4367c2c66affSColin Finck ok(g_editbox_disp_info.item.pszText != NULL, "expected notification with not null text\n");
4368c2c66affSColin Finck
4369c2c66affSColin Finck memset(&item, 0, sizeof(item));
4370c2c66affSColin Finck item.pszText = buffer;
4371c2c66affSColin Finck item.cchTextMax = sizeof(buffer);
4372c2c66affSColin Finck item.iItem = 0;
4373c2c66affSColin Finck item.iSubItem = 0;
4374c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
4375c2c66affSColin Finck expect(lstrlenA(item.pszText), r);
4376c2c66affSColin Finck ok(strcmp(buffer, testitem1A) == 0, "Expected item text to change\n");
4377c2c66affSColin Finck ok(!IsWindow(hwndedit), "Expected Edit window to be freed\n");
4378c2c66affSColin Finck
4379c2c66affSColin Finck /* change item name to differ in casing only */
4380c2c66affSColin Finck SetFocus(hwnd);
4381c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4382c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4383c2c66affSColin Finck /* modify edit and notify control that it lost focus */
4384c2c66affSColin Finck r = SendMessageA(hwndedit, WM_SETTEXT, 0, (LPARAM)testitem2A);
4385c2c66affSColin Finck expect(TRUE, r);
4386c2c66affSColin Finck g_editbox_disp_info.item.pszText = NULL;
4387c2c66affSColin Finck r = SendMessageA(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit);
4388c2c66affSColin Finck expect(0, r);
4389c2c66affSColin Finck ok(g_editbox_disp_info.item.pszText != NULL, "got %p\n", g_editbox_disp_info.item.pszText);
4390c2c66affSColin Finck
4391c2c66affSColin Finck memset(&item, 0, sizeof(item));
4392c2c66affSColin Finck item.pszText = buffer;
4393c2c66affSColin Finck item.cchTextMax = sizeof(buffer);
4394c2c66affSColin Finck item.iItem = 0;
4395c2c66affSColin Finck item.iSubItem = 0;
4396c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
4397c2c66affSColin Finck expect(lstrlenA(item.pszText), r);
4398c2c66affSColin Finck ok(strcmp(buffer, testitem2A) == 0, "got %s, expected %s\n", buffer, testitem2A);
4399c2c66affSColin Finck ok(!IsWindow(hwndedit), "Expected Edit window to be freed\n");
4400c2c66affSColin Finck
4401c2c66affSColin Finck /* end edit without saving */
4402c2c66affSColin Finck SetFocus(hwnd);
4403c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4404c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4405c2c66affSColin Finck r = SendMessageA(hwndedit, WM_KEYDOWN, VK_ESCAPE, 0);
4406c2c66affSColin Finck expect(0, r);
4407c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, edit_end_nochange,
4408c2c66affSColin Finck "edit box - end edit, no change, escape", TRUE);
4409c2c66affSColin Finck /* end edit with saving */
4410c2c66affSColin Finck SetFocus(hwnd);
4411c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4412c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4413c2c66affSColin Finck r = SendMessageA(hwndedit, WM_KEYDOWN, VK_RETURN, 0);
4414c2c66affSColin Finck expect(0, r);
4415c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, edit_end_nochange,
4416c2c66affSColin Finck "edit box - end edit, no change, return", TRUE);
4417c2c66affSColin Finck
4418c2c66affSColin Finck memset(&item, 0, sizeof(item));
4419c2c66affSColin Finck item.pszText = buffer;
4420c2c66affSColin Finck item.cchTextMax = sizeof(buffer);
4421c2c66affSColin Finck item.iItem = 0;
4422c2c66affSColin Finck item.iSubItem = 0;
4423c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
4424c2c66affSColin Finck expect(lstrlenA(item.pszText), r);
4425c2c66affSColin Finck ok(strcmp(buffer, testitem2A) == 0, "Expected item text to change\n");
4426c2c66affSColin Finck
4427c2c66affSColin Finck /* LVM_EDITLABEL with -1 destroys current edit */
4428c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_GETEDITCONTROL, 0, 0);
4429c2c66affSColin Finck ok(hwndedit == NULL, "Expected Edit window not to be created\n");
4430c2c66affSColin Finck /* no edit present */
4431c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, -1, 0);
4432c2c66affSColin Finck ok(hwndedit == NULL, "Expected Edit window not to be created\n");
4433c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4434c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4435c2c66affSColin Finck /* edit present */
4436c2c66affSColin Finck ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
4437c2c66affSColin Finck hwndedit2 = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, -1, 0);
4438c2c66affSColin Finck ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
4439c2c66affSColin Finck ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
4440c2c66affSColin Finck ok(GetFocus() == hwnd, "Expected List to be focused\n");
4441c2c66affSColin Finck /* check another negative value */
4442c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4443c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4444c2c66affSColin Finck ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
4445c2c66affSColin Finck hwndedit2 = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, -2, 0);
4446c2c66affSColin Finck ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
4447c2c66affSColin Finck ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
4448c2c66affSColin Finck ok(GetFocus() == hwnd, "Expected List to be focused\n");
4449c2c66affSColin Finck /* and value greater than max item index */
4450c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4451c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4452c2c66affSColin Finck ok(GetFocus() == hwndedit, "Expected Edit to be focused\n");
4453c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMCOUNT, 0, 0);
4454c2c66affSColin Finck hwndedit2 = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, r, 0);
4455c2c66affSColin Finck ok(hwndedit2 == NULL, "Expected Edit window not to be created\n");
4456c2c66affSColin Finck ok(!IsWindow(hwndedit), "Expected Edit window to be destroyed\n");
4457c2c66affSColin Finck ok(GetFocus() == hwnd, "Expected List to be focused\n");
4458c2c66affSColin Finck
4459c2c66affSColin Finck /* messaging tests */
4460c2c66affSColin Finck SetFocus(hwnd);
4461c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4462c2c66affSColin Finck blockEdit = FALSE;
4463c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4464c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4465c2c66affSColin Finck /* testing only sizing messages */
4466c2c66affSColin Finck ok_sequence(sequences, EDITBOX_SEQ_INDEX, editbox_create_pos,
4467c2c66affSColin Finck "edit box create - sizing", FALSE);
4468c2c66affSColin Finck
4469c2c66affSColin Finck /* WM_COMMAND with EN_KILLFOCUS isn't forwarded to parent */
4470c2c66affSColin Finck SetFocus(hwnd);
4471c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4472c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected Edit window to be created\n");
4473c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4474c2c66affSColin Finck r = SendMessageA(hwnd, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hwndedit);
4475c2c66affSColin Finck expect(0, r);
4476c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, edit_end_nochange,
4477c2c66affSColin Finck "edit box WM_COMMAND (EN_KILLFOCUS)", TRUE);
4478c2c66affSColin Finck
4479c2c66affSColin Finck DestroyWindow(hwnd);
4480c2c66affSColin Finck }
4481c2c66affSColin Finck
test_notifyformat(void)4482c2c66affSColin Finck static void test_notifyformat(void)
4483c2c66affSColin Finck {
4484c2c66affSColin Finck HWND hwnd, header;
4485c2c66affSColin Finck DWORD r;
4486c2c66affSColin Finck
4487c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
4488c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4489c2c66affSColin Finck
4490c2c66affSColin Finck /* CCM_GETUNICODEFORMAT == LVM_GETUNICODEFORMAT,
4491c2c66affSColin Finck CCM_SETUNICODEFORMAT == LVM_SETUNICODEFORMAT */
4492c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4493c2c66affSColin Finck expect(0, r);
4494c2c66affSColin Finck SendMessageA(hwnd, WM_NOTIFYFORMAT, 0, NF_QUERY);
4495c2c66affSColin Finck /* set */
4496c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETUNICODEFORMAT, 1, 0);
4497c2c66affSColin Finck expect(0, r);
4498c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
44990d320bc2SAmine Khaldi ok(r == 1, "Unexpected return value %d.\n", r);
4500c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETUNICODEFORMAT, 0, 0);
4501c2c66affSColin Finck expect(1, r);
4502c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4503c2c66affSColin Finck expect(0, r);
4504c2c66affSColin Finck
4505c2c66affSColin Finck DestroyWindow(hwnd);
4506c2c66affSColin Finck
4507c2c66affSColin Finck /* test failure in parent WM_NOTIFYFORMAT */
4508c2c66affSColin Finck notifyFormat = 0;
4509c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
4510c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4511c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
4512c2c66affSColin Finck ok(IsWindow(header), "expected header to be created\n");
4513c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4514c2c66affSColin Finck expect(0, r);
4515c2c66affSColin Finck r = SendMessageA(header, HDM_GETUNICODEFORMAT, 0, 0);
4516c2c66affSColin Finck ok( r == 1, "Expected 1, got %d\n", r );
4517c2c66affSColin Finck r = SendMessageA(hwnd, WM_NOTIFYFORMAT, 0, NF_QUERY);
4518c2c66affSColin Finck ok(r != 0, "Expected valid format\n");
4519c2c66affSColin Finck
4520c2c66affSColin Finck notifyFormat = NFR_UNICODE;
4521c2c66affSColin Finck r = SendMessageA(hwnd, WM_NOTIFYFORMAT, 0, NF_REQUERY);
4522c2c66affSColin Finck expect(NFR_UNICODE, r);
4523c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4524c2c66affSColin Finck expect(1, r);
4525c2c66affSColin Finck r = SendMessageA(header, HDM_GETUNICODEFORMAT, 0, 0);
4526c2c66affSColin Finck ok( r == 1, "Expected 1, got %d\n", r );
4527c2c66affSColin Finck
4528c2c66affSColin Finck notifyFormat = NFR_ANSI;
4529c2c66affSColin Finck r = SendMessageA(hwnd, WM_NOTIFYFORMAT, 0, NF_REQUERY);
4530c2c66affSColin Finck expect(NFR_ANSI, r);
4531c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4532c2c66affSColin Finck expect(0, r);
4533c2c66affSColin Finck r = SendMessageA(header, HDM_GETUNICODEFORMAT, 0, 0);
4534c2c66affSColin Finck ok( r == 1, "Expected 1, got %d\n", r );
4535c2c66affSColin Finck
4536c2c66affSColin Finck DestroyWindow(hwnd);
4537c2c66affSColin Finck
4538c2c66affSColin Finck hwndparentW = create_parent_window(TRUE);
4539c2c66affSColin Finck ok(IsWindow(hwndparentW), "Unicode parent creation failed\n");
4540c2c66affSColin Finck if (!IsWindow(hwndparentW)) return;
4541c2c66affSColin Finck
4542c2c66affSColin Finck notifyFormat = -1;
4543c2c66affSColin Finck hwnd = create_listview_controlW(LVS_REPORT, hwndparentW);
4544c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4545c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
4546c2c66affSColin Finck ok(IsWindow(header), "expected header to be created\n");
4547c2c66affSColin Finck r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4548c2c66affSColin Finck expect(1, r);
4549c2c66affSColin Finck r = SendMessageA(header, HDM_GETUNICODEFORMAT, 0, 0);
4550c2c66affSColin Finck expect(1, r);
4551c2c66affSColin Finck DestroyWindow(hwnd);
4552c2c66affSColin Finck /* receiving error code defaulting to ansi */
4553c2c66affSColin Finck notifyFormat = 0;
4554c2c66affSColin Finck hwnd = create_listview_controlW(LVS_REPORT, hwndparentW);
4555c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4556c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
4557c2c66affSColin Finck ok(IsWindow(header), "expected header to be created\n");
4558c2c66affSColin Finck r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4559c2c66affSColin Finck expect(0, r);
4560c2c66affSColin Finck r = SendMessageA(header, HDM_GETUNICODEFORMAT, 0, 0);
4561c2c66affSColin Finck expect(1, r);
4562c2c66affSColin Finck DestroyWindow(hwnd);
4563c2c66affSColin Finck /* receiving ansi code from unicode window, use it */
4564c2c66affSColin Finck notifyFormat = NFR_ANSI;
4565c2c66affSColin Finck hwnd = create_listview_controlW(LVS_REPORT, hwndparentW);
4566c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4567c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
4568c2c66affSColin Finck ok(IsWindow(header), "expected header to be created\n");
4569c2c66affSColin Finck r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4570c2c66affSColin Finck expect(0, r);
4571c2c66affSColin Finck r = SendMessageA(header, HDM_GETUNICODEFORMAT, 0, 0);
4572c2c66affSColin Finck expect(1, r);
4573c2c66affSColin Finck DestroyWindow(hwnd);
4574c2c66affSColin Finck /* unicode listview with ansi parent window */
4575c2c66affSColin Finck notifyFormat = -1;
4576c2c66affSColin Finck hwnd = create_listview_controlW(LVS_REPORT, hwndparent);
4577c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4578c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
4579c2c66affSColin Finck ok(IsWindow(header), "expected header to be created\n");
4580c2c66affSColin Finck r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4581c2c66affSColin Finck expect(0, r);
4582c2c66affSColin Finck r = SendMessageA(header, HDM_GETUNICODEFORMAT, 0, 0);
4583c2c66affSColin Finck expect(1, r);
4584c2c66affSColin Finck DestroyWindow(hwnd);
4585c2c66affSColin Finck /* unicode listview with ansi parent window, return error code */
4586c2c66affSColin Finck notifyFormat = 0;
4587c2c66affSColin Finck hwnd = create_listview_controlW(LVS_REPORT, hwndparent);
4588c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4589c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
4590c2c66affSColin Finck ok(IsWindow(header), "expected header to be created\n");
4591c2c66affSColin Finck r = SendMessageW(hwnd, LVM_GETUNICODEFORMAT, 0, 0);
4592c2c66affSColin Finck expect(0, r);
4593c2c66affSColin Finck r = SendMessageA(header, HDM_GETUNICODEFORMAT, 0, 0);
4594c2c66affSColin Finck expect(1, r);
4595c2c66affSColin Finck DestroyWindow(hwnd);
4596c2c66affSColin Finck
4597c2c66affSColin Finck DestroyWindow(hwndparentW);
4598c2c66affSColin Finck }
4599c2c66affSColin Finck
test_indentation(void)4600c2c66affSColin Finck static void test_indentation(void)
4601c2c66affSColin Finck {
4602c2c66affSColin Finck HWND hwnd;
4603c2c66affSColin Finck LVITEMA item;
4604c2c66affSColin Finck DWORD r;
4605c2c66affSColin Finck
4606c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
4607c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4608c2c66affSColin Finck
4609c2c66affSColin Finck memset(&item, 0, sizeof(item));
4610c2c66affSColin Finck item.mask = LVIF_INDENT;
4611c2c66affSColin Finck item.iItem = 0;
4612c2c66affSColin Finck item.iIndent = I_INDENTCALLBACK;
4613c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
4614c2c66affSColin Finck expect(0, r);
4615c2c66affSColin Finck
4616c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4617c2c66affSColin Finck
4618c2c66affSColin Finck item.iItem = 0;
4619c2c66affSColin Finck item.mask = LVIF_INDENT;
4620c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
4621c2c66affSColin Finck expect(TRUE, r);
4622c2c66affSColin Finck
4623c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, single_getdispinfo_parent_seq,
4624c2c66affSColin Finck "get indent dispinfo", FALSE);
4625c2c66affSColin Finck
4626*0707475fSJustin Miller /* Ask for iIndent with invalid subitem. */
4627*0707475fSJustin Miller flush_sequences(sequences, NUM_MSG_SEQUENCES);
4628*0707475fSJustin Miller
4629*0707475fSJustin Miller memset(&item, 0, sizeof(item));
4630*0707475fSJustin Miller item.mask = LVIF_INDENT;
4631*0707475fSJustin Miller item.iSubItem = 1;
4632*0707475fSJustin Miller r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
4633*0707475fSJustin Miller ok(r, "Failed to get item.\n");
4634*0707475fSJustin Miller
4635*0707475fSJustin Miller ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "get indent dispinfo 2", FALSE);
4636*0707475fSJustin Miller
4637c2c66affSColin Finck DestroyWindow(hwnd);
4638c2c66affSColin Finck }
4639c2c66affSColin Finck
DummyCompareEx(LPARAM first,LPARAM second,LPARAM param)4640c2c66affSColin Finck static INT CALLBACK DummyCompareEx(LPARAM first, LPARAM second, LPARAM param)
4641c2c66affSColin Finck {
4642c2c66affSColin Finck return 0;
4643c2c66affSColin Finck }
4644c2c66affSColin Finck
is_below_comctl_5(void)4645c2c66affSColin Finck static BOOL is_below_comctl_5(void)
4646c2c66affSColin Finck {
4647c2c66affSColin Finck HWND hwnd;
4648c2c66affSColin Finck BOOL ret;
4649c2c66affSColin Finck
4650c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
4651c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4652c2c66affSColin Finck insert_item(hwnd, 0);
4653c2c66affSColin Finck
4654c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SORTITEMSEX, 0, (LPARAM)&DummyCompareEx);
4655c2c66affSColin Finck
4656c2c66affSColin Finck DestroyWindow(hwnd);
4657c2c66affSColin Finck
4658c2c66affSColin Finck return !ret;
4659c2c66affSColin Finck }
4660c2c66affSColin Finck
test_get_set_view(void)4661c2c66affSColin Finck static void test_get_set_view(void)
4662c2c66affSColin Finck {
4663c2c66affSColin Finck HWND hwnd;
4664c2c66affSColin Finck DWORD ret;
4665c2c66affSColin Finck DWORD_PTR style;
4666c2c66affSColin Finck
4667c2c66affSColin Finck /* test style->view mapping */
4668c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
4669c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4670c2c66affSColin Finck
4671c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETVIEW, 0, 0);
4672c2c66affSColin Finck expect(LV_VIEW_DETAILS, ret);
4673c2c66affSColin Finck
4674c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
4675c2c66affSColin Finck /* LVS_ICON == 0 */
4676c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style & ~LVS_REPORT);
4677c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETVIEW, 0, 0);
4678c2c66affSColin Finck expect(LV_VIEW_ICON, ret);
4679c2c66affSColin Finck
4680c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
4681c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SMALLICON);
4682c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETVIEW, 0, 0);
4683c2c66affSColin Finck expect(LV_VIEW_SMALLICON, ret);
4684c2c66affSColin Finck
4685c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
4686c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, (style & ~LVS_SMALLICON) | LVS_LIST);
4687c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETVIEW, 0, 0);
4688c2c66affSColin Finck expect(LV_VIEW_LIST, ret);
4689c2c66affSColin Finck
4690c2c66affSColin Finck /* switching view doesn't touch window style */
4691c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETVIEW, LV_VIEW_DETAILS, 0);
4692c2c66affSColin Finck expect(1, ret);
4693c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
4694c2c66affSColin Finck ok(style & LVS_LIST, "Expected style to be preserved\n");
4695c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETVIEW, LV_VIEW_ICON, 0);
4696c2c66affSColin Finck expect(1, ret);
4697c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
4698c2c66affSColin Finck ok(style & LVS_LIST, "Expected style to be preserved\n");
4699c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETVIEW, LV_VIEW_SMALLICON, 0);
4700c2c66affSColin Finck expect(1, ret);
4701c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
4702c2c66affSColin Finck ok(style & LVS_LIST, "Expected style to be preserved\n");
4703c2c66affSColin Finck
4704c2c66affSColin Finck /* now change window style to see if view is remapped */
4705c2c66affSColin Finck style = GetWindowLongPtrA(hwnd, GWL_STYLE);
4706c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, style | LVS_SHOWSELALWAYS);
4707c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETVIEW, 0, 0);
4708c2c66affSColin Finck expect(LV_VIEW_SMALLICON, ret);
4709c2c66affSColin Finck
4710c2c66affSColin Finck DestroyWindow(hwnd);
4711c2c66affSColin Finck }
4712c2c66affSColin Finck
test_canceleditlabel(void)4713c2c66affSColin Finck static void test_canceleditlabel(void)
4714c2c66affSColin Finck {
4715c2c66affSColin Finck HWND hwnd, hwndedit;
4716c2c66affSColin Finck DWORD ret;
4717c2c66affSColin Finck CHAR buff[10];
4718c2c66affSColin Finck LVITEMA itema;
4719c2c66affSColin Finck static CHAR test[] = "test";
4720c2c66affSColin Finck static const CHAR test1[] = "test1";
4721c2c66affSColin Finck
4722c2c66affSColin Finck hwnd = create_listview_control(LVS_EDITLABELS | LVS_REPORT);
4723c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4724c2c66affSColin Finck
4725c2c66affSColin Finck insert_item(hwnd, 0);
4726c2c66affSColin Finck
4727c2c66affSColin Finck /* try without edit created */
4728c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
4729c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_CANCELEDITLABEL, 0, 0);
4730c2c66affSColin Finck expect(TRUE, ret);
4731c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
4732c2c66affSColin Finck "cancel edit label without edit", FALSE);
4733c2c66affSColin Finck
4734c2c66affSColin Finck /* cancel without data change */
4735c2c66affSColin Finck SetFocus(hwnd);
4736c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4737c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected edit control to be created\n");
4738c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_CANCELEDITLABEL, 0, 0);
4739c2c66affSColin Finck expect(TRUE, ret);
4740c2c66affSColin Finck ok(!IsWindow(hwndedit), "Expected edit control to be destroyed\n");
4741c2c66affSColin Finck
4742c2c66affSColin Finck /* cancel after data change */
4743c2c66affSColin Finck memset(&itema, 0, sizeof(itema));
4744c2c66affSColin Finck itema.pszText = test;
4745c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&itema);
4746c2c66affSColin Finck expect(TRUE, ret);
4747c2c66affSColin Finck SetFocus(hwnd);
4748c2c66affSColin Finck hwndedit = (HWND)SendMessageA(hwnd, LVM_EDITLABELA, 0, 0);
4749c2c66affSColin Finck ok(IsWindow(hwndedit), "Expected edit control to be created\n");
4750c2c66affSColin Finck ret = SetWindowTextA(hwndedit, test1);
4751c2c66affSColin Finck expect(1, ret);
4752c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_CANCELEDITLABEL, 0, 0);
4753c2c66affSColin Finck expect(TRUE, ret);
4754c2c66affSColin Finck ok(!IsWindow(hwndedit), "Expected edit control to be destroyed\n");
4755c2c66affSColin Finck memset(&itema, 0, sizeof(itema));
4756c2c66affSColin Finck itema.pszText = buff;
47575f7243b5SAmine Khaldi itema.cchTextMax = ARRAY_SIZE(buff);
4758c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&itema);
4759c2c66affSColin Finck expect(5, ret);
4760c2c66affSColin Finck ok(strcmp(buff, test1) == 0, "Expected label text not to change\n");
4761c2c66affSColin Finck
4762c2c66affSColin Finck DestroyWindow(hwnd);
4763c2c66affSColin Finck }
4764c2c66affSColin Finck
test_mapidindex(void)4765c2c66affSColin Finck static void test_mapidindex(void)
4766c2c66affSColin Finck {
4767c2c66affSColin Finck HWND hwnd;
4768c2c66affSColin Finck INT ret;
4769c2c66affSColin Finck
4770c2c66affSColin Finck /* LVM_MAPINDEXTOID unsupported with LVS_OWNERDATA */
4771c2c66affSColin Finck hwnd = create_listview_control(LVS_OWNERDATA | LVS_REPORT);
4772c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4773c2c66affSColin Finck insert_item(hwnd, 0);
4774c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPINDEXTOID, 0, 0);
4775c2c66affSColin Finck expect(-1, ret);
4776c2c66affSColin Finck DestroyWindow(hwnd);
4777c2c66affSColin Finck
4778c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
4779c2c66affSColin Finck ok(hwnd != NULL, "failed to create a listview window\n");
4780c2c66affSColin Finck
4781c2c66affSColin Finck /* LVM_MAPINDEXTOID with invalid index */
4782c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPINDEXTOID, 0, 0);
4783c2c66affSColin Finck expect(-1, ret);
4784c2c66affSColin Finck
4785c2c66affSColin Finck insert_item(hwnd, 0);
4786c2c66affSColin Finck insert_item(hwnd, 1);
4787c2c66affSColin Finck
4788c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPINDEXTOID, -1, 0);
4789c2c66affSColin Finck expect(-1, ret);
4790c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPINDEXTOID, 2, 0);
4791c2c66affSColin Finck expect(-1, ret);
4792c2c66affSColin Finck
4793c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPINDEXTOID, 0, 0);
4794c2c66affSColin Finck expect(0, ret);
4795c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPINDEXTOID, 1, 0);
4796c2c66affSColin Finck expect(1, ret);
4797c2c66affSColin Finck /* remove 0 indexed item, id retained */
4798c2c66affSColin Finck SendMessageA(hwnd, LVM_DELETEITEM, 0, 0);
4799c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPINDEXTOID, 0, 0);
4800c2c66affSColin Finck expect(1, ret);
4801c2c66affSColin Finck /* new id starts from previous value */
4802c2c66affSColin Finck insert_item(hwnd, 1);
4803c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPINDEXTOID, 1, 0);
4804c2c66affSColin Finck expect(2, ret);
4805c2c66affSColin Finck
4806c2c66affSColin Finck /* get index by id */
4807c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPIDTOINDEX, -1, 0);
4808c2c66affSColin Finck expect(-1, ret);
4809c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPIDTOINDEX, 0, 0);
4810c2c66affSColin Finck expect(-1, ret);
4811c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPIDTOINDEX, 1, 0);
4812c2c66affSColin Finck expect(0, ret);
4813c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_MAPIDTOINDEX, 2, 0);
4814c2c66affSColin Finck expect(1, ret);
4815c2c66affSColin Finck
4816c2c66affSColin Finck DestroyWindow(hwnd);
4817c2c66affSColin Finck }
4818c2c66affSColin Finck
test_getitemspacing(void)4819c2c66affSColin Finck static void test_getitemspacing(void)
4820c2c66affSColin Finck {
4821c2c66affSColin Finck HWND hwnd;
4822c2c66affSColin Finck DWORD ret;
4823c2c66affSColin Finck INT cx, cy;
4824c2c66affSColin Finck HIMAGELIST himl40, himl80;
4825c2c66affSColin Finck
4826c2c66affSColin Finck cx = GetSystemMetrics(SM_CXICONSPACING) - GetSystemMetrics(SM_CXICON);
4827c2c66affSColin Finck cy = GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON);
4828c2c66affSColin Finck
4829c2c66affSColin Finck /* LVS_ICON */
4830c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
4831c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4832c2c66affSColin Finck expect(cx, LOWORD(ret));
4833c2c66affSColin Finck expect(cy, HIWORD(ret));
4834c2c66affSColin Finck
4835c2c66affSColin Finck /* now try with icons */
4836f37104daSAmine Khaldi himl40 = pImageList_Create(40, 40, 0, 4, 4);
4837c2c66affSColin Finck ok(himl40 != NULL, "failed to create imagelist\n");
4838f37104daSAmine Khaldi himl80 = pImageList_Create(80, 80, 0, 4, 4);
4839c2c66affSColin Finck ok(himl80 != NULL, "failed to create imagelist\n");
4840c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl40);
4841c2c66affSColin Finck expect(0, ret);
4842c2c66affSColin Finck
4843c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4844c2c66affSColin Finck /* spacing + icon size returned */
4845c2c66affSColin Finck expect(cx + 40, LOWORD(ret));
4846c2c66affSColin Finck expect(cy + 40, HIWORD(ret));
4847c2c66affSColin Finck /* try changing icon size */
4848c2c66affSColin Finck SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl80);
4849c2c66affSColin Finck
4850c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4851c2c66affSColin Finck /* spacing + icon size returned */
4852c2c66affSColin Finck expect(cx + 80, LOWORD(ret));
4853c2c66affSColin Finck expect(cy + 80, HIWORD(ret));
4854c2c66affSColin Finck
4855c2c66affSColin Finck /* set own icon spacing */
4856c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(100, 100));
4857c2c66affSColin Finck expect(cx + 80, LOWORD(ret));
4858c2c66affSColin Finck expect(cy + 80, HIWORD(ret));
4859c2c66affSColin Finck
4860c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4861c2c66affSColin Finck /* set size returned */
4862c2c66affSColin Finck expect(100, LOWORD(ret));
4863c2c66affSColin Finck expect(100, HIWORD(ret));
4864c2c66affSColin Finck
4865c2c66affSColin Finck /* now change image list - icon spacing should be unaffected */
4866c2c66affSColin Finck SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl40);
4867c2c66affSColin Finck
4868c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4869c2c66affSColin Finck /* set size returned */
4870c2c66affSColin Finck expect(100, LOWORD(ret));
4871c2c66affSColin Finck expect(100, HIWORD(ret));
4872c2c66affSColin Finck
4873c2c66affSColin Finck /* spacing = 0 - keep previous value */
4874c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(0, -1));
4875c2c66affSColin Finck expect(100, LOWORD(ret));
4876c2c66affSColin Finck expect(100, HIWORD(ret));
4877c2c66affSColin Finck
4878c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4879c2c66affSColin Finck expect(100, LOWORD(ret));
4880c2c66affSColin Finck
4881c2c66affSColin Finck expect(0xFFFF, HIWORD(ret));
4882c2c66affSColin Finck
4883c2c66affSColin Finck if (sizeof(void*) == 8)
4884c2c66affSColin Finck {
4885c2c66affSColin Finck /* NOTE: -1 is not treated the same as (DWORD)-1 by 64bit listview */
4886c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETICONSPACING, 0, (DWORD)-1);
4887c2c66affSColin Finck expect(100, LOWORD(ret));
4888c2c66affSColin Finck expect(0xFFFF, HIWORD(ret));
4889c2c66affSColin Finck
4890c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETICONSPACING, 0, -1);
4891c2c66affSColin Finck expect(0xFFFF, LOWORD(ret));
4892c2c66affSColin Finck expect(0xFFFF, HIWORD(ret));
4893c2c66affSColin Finck }
4894c2c66affSColin Finck else
4895c2c66affSColin Finck {
4896c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETICONSPACING, 0, -1);
4897c2c66affSColin Finck expect(100, LOWORD(ret));
4898c2c66affSColin Finck expect(0xFFFF, HIWORD(ret));
4899c2c66affSColin Finck }
4900c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4901c2c66affSColin Finck /* spacing + icon size returned */
4902c2c66affSColin Finck expect(cx + 40, LOWORD(ret));
4903c2c66affSColin Finck expect(cy + 40, HIWORD(ret));
4904c2c66affSColin Finck
4905c2c66affSColin Finck SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, 0);
4906f37104daSAmine Khaldi pImageList_Destroy(himl80);
4907c2c66affSColin Finck DestroyWindow(hwnd);
4908c2c66affSColin Finck /* LVS_SMALLICON */
4909c2c66affSColin Finck hwnd = create_listview_control(LVS_SMALLICON);
4910c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4911c2c66affSColin Finck expect(cx, LOWORD(ret));
4912c2c66affSColin Finck expect(cy, HIWORD(ret));
4913c2c66affSColin Finck
4914c2c66affSColin Finck /* spacing does not depend on selected view type */
4915c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl40);
4916c2c66affSColin Finck expect(0, ret);
4917c2c66affSColin Finck
4918c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4919c2c66affSColin Finck /* spacing + icon size returned */
4920c2c66affSColin Finck expect(cx + 40, LOWORD(ret));
4921c2c66affSColin Finck expect(cy + 40, HIWORD(ret));
4922c2c66affSColin Finck
4923c2c66affSColin Finck SendMessageA(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, 0);
4924f37104daSAmine Khaldi pImageList_Destroy(himl40);
4925c2c66affSColin Finck DestroyWindow(hwnd);
4926c2c66affSColin Finck /* LVS_REPORT */
4927c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
4928c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4929c2c66affSColin Finck expect(cx, LOWORD(ret));
4930c2c66affSColin Finck expect(cy, HIWORD(ret));
4931c2c66affSColin Finck
4932c2c66affSColin Finck DestroyWindow(hwnd);
4933c2c66affSColin Finck /* LVS_LIST */
4934c2c66affSColin Finck hwnd = create_listview_control(LVS_LIST);
4935c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMSPACING, FALSE, 0);
4936c2c66affSColin Finck expect(cx, LOWORD(ret));
4937c2c66affSColin Finck expect(cy, HIWORD(ret));
4938c2c66affSColin Finck
4939c2c66affSColin Finck DestroyWindow(hwnd);
4940c2c66affSColin Finck }
4941c2c66affSColin Finck
get_current_font_height(HWND listview)4942c2c66affSColin Finck static INT get_current_font_height(HWND listview)
4943c2c66affSColin Finck {
4944c2c66affSColin Finck TEXTMETRICA tm;
4945c2c66affSColin Finck HFONT hfont;
4946c2c66affSColin Finck HWND hwnd;
4947c2c66affSColin Finck HDC hdc;
4948c2c66affSColin Finck
4949c2c66affSColin Finck hwnd = (HWND)SendMessageA(listview, LVM_GETHEADER, 0, 0);
4950c2c66affSColin Finck if (!hwnd)
4951c2c66affSColin Finck hwnd = listview;
4952c2c66affSColin Finck
4953c2c66affSColin Finck hfont = (HFONT)SendMessageA(hwnd, WM_GETFONT, 0, 0);
4954c2c66affSColin Finck if (!hfont) {
4955c2c66affSColin Finck hdc = GetDC(hwnd);
4956c2c66affSColin Finck GetTextMetricsA(hdc, &tm);
4957c2c66affSColin Finck ReleaseDC(hwnd, hdc);
4958c2c66affSColin Finck }
4959c2c66affSColin Finck else {
4960c2c66affSColin Finck HFONT oldfont;
4961c2c66affSColin Finck
4962c2c66affSColin Finck hdc = GetDC(0);
4963c2c66affSColin Finck oldfont = SelectObject(hdc, hfont);
4964c2c66affSColin Finck GetTextMetricsA(hdc, &tm);
4965c2c66affSColin Finck SelectObject(hdc, oldfont);
4966c2c66affSColin Finck ReleaseDC(0, hdc);
4967c2c66affSColin Finck }
4968c2c66affSColin Finck
4969c2c66affSColin Finck return tm.tmHeight;
4970c2c66affSColin Finck }
4971c2c66affSColin Finck
test_getcolumnwidth(void)4972c2c66affSColin Finck static void test_getcolumnwidth(void)
4973c2c66affSColin Finck {
4974c2c66affSColin Finck HWND hwnd;
4975c2c66affSColin Finck INT ret;
4976c2c66affSColin Finck DWORD_PTR style;
4977c2c66affSColin Finck LVCOLUMNA col;
4978c2c66affSColin Finck LVITEMA itema;
4979c2c66affSColin Finck INT height;
4980c2c66affSColin Finck
4981c2c66affSColin Finck /* default column width */
4982c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
4983c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
4984c2c66affSColin Finck expect(0, ret);
4985c2c66affSColin Finck style = GetWindowLongA(hwnd, GWL_STYLE);
4986c2c66affSColin Finck SetWindowLongA(hwnd, GWL_STYLE, style | LVS_LIST);
4987c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
4988c2c66affSColin Finck todo_wine expect(8, ret);
4989c2c66affSColin Finck style = GetWindowLongA(hwnd, GWL_STYLE) & ~LVS_LIST;
4990c2c66affSColin Finck SetWindowLongA(hwnd, GWL_STYLE, style | LVS_REPORT);
4991c2c66affSColin Finck col.mask = 0;
4992c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
4993c2c66affSColin Finck expect(0, ret);
4994c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
4995c2c66affSColin Finck expect(10, ret);
4996c2c66affSColin Finck DestroyWindow(hwnd);
4997c2c66affSColin Finck
4998c2c66affSColin Finck /* default column width with item added */
4999c2c66affSColin Finck hwnd = create_listview_control(LVS_LIST);
5000c2c66affSColin Finck memset(&itema, 0, sizeof(itema));
5001c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&itema);
5002c2c66affSColin Finck ok(!ret, "got %d\n", ret);
5003c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
5004c2c66affSColin Finck height = get_current_font_height(hwnd);
5005c2c66affSColin Finck ok((ret / height) >= 6, "got width %d, height %d\n", ret, height);
5006c2c66affSColin Finck DestroyWindow(hwnd);
5007c2c66affSColin Finck }
5008c2c66affSColin Finck
test_scrollnotify(void)5009c2c66affSColin Finck static void test_scrollnotify(void)
5010c2c66affSColin Finck {
5011c2c66affSColin Finck HWND hwnd;
5012c2c66affSColin Finck DWORD ret;
5013c2c66affSColin Finck
5014c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
5015c2c66affSColin Finck
5016c2c66affSColin Finck insert_column(hwnd, 0);
5017c2c66affSColin Finck insert_column(hwnd, 1);
5018c2c66affSColin Finck insert_item(hwnd, 0);
5019c2c66affSColin Finck
5020c2c66affSColin Finck /* make it scrollable - resize */
5021c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(100, 0));
5022c2c66affSColin Finck expect(TRUE, ret);
5023c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 1, MAKELPARAM(100, 0));
5024c2c66affSColin Finck expect(TRUE, ret);
5025c2c66affSColin Finck
5026c2c66affSColin Finck /* try with dummy call */
5027c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5028c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SCROLL, 0, 0);
5029c2c66affSColin Finck expect(TRUE, ret);
5030c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, scroll_parent_seq,
5031c2c66affSColin Finck "scroll notify 1", TRUE);
5032c2c66affSColin Finck
5033c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5034c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SCROLL, 1, 0);
5035c2c66affSColin Finck expect(TRUE, ret);
5036c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, scroll_parent_seq,
5037c2c66affSColin Finck "scroll notify 2", TRUE);
5038c2c66affSColin Finck
5039c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5040c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SCROLL, 1, 1);
5041c2c66affSColin Finck expect(TRUE, ret);
5042c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, scroll_parent_seq,
5043c2c66affSColin Finck "scroll notify 3", TRUE);
5044c2c66affSColin Finck
5045c2c66affSColin Finck DestroyWindow(hwnd);
5046c2c66affSColin Finck }
5047c2c66affSColin Finck
test_LVS_EX_TRANSPARENTBKGND(void)5048c2c66affSColin Finck static void test_LVS_EX_TRANSPARENTBKGND(void)
5049c2c66affSColin Finck {
5050c2c66affSColin Finck HWND hwnd;
5051c2c66affSColin Finck DWORD ret;
5052c2c66affSColin Finck HDC hdc;
5053c2c66affSColin Finck
5054c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
5055c2c66affSColin Finck
5056c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, RGB(0, 0, 0));
5057c2c66affSColin Finck expect(TRUE, ret);
5058c2c66affSColin Finck
5059c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_TRANSPARENTBKGND,
5060c2c66affSColin Finck LVS_EX_TRANSPARENTBKGND);
5061c2c66affSColin Finck
5062c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETBKCOLOR, 0, 0);
5063c2c66affSColin Finck if (ret != CLR_NONE)
5064c2c66affSColin Finck {
5065c2c66affSColin Finck win_skip("LVS_EX_TRANSPARENTBKGND unsupported\n");
5066c2c66affSColin Finck DestroyWindow(hwnd);
5067c2c66affSColin Finck return;
5068c2c66affSColin Finck }
5069c2c66affSColin Finck
5070c2c66affSColin Finck /* try to set some back color and check this style bit */
5071c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETBKCOLOR, 0, RGB(0, 0, 0));
5072c2c66affSColin Finck expect(TRUE, ret);
5073c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
5074c2c66affSColin Finck ok(!(ret & LVS_EX_TRANSPARENTBKGND), "Expected LVS_EX_TRANSPARENTBKGND to unset\n");
5075c2c66affSColin Finck
5076c2c66affSColin Finck /* now test what this style actually does */
5077c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_TRANSPARENTBKGND,
5078c2c66affSColin Finck LVS_EX_TRANSPARENTBKGND);
5079c2c66affSColin Finck
5080c2c66affSColin Finck hdc = GetWindowDC(hwndparent);
5081c2c66affSColin Finck
5082c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5083c2c66affSColin Finck SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
5084c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, lvs_ex_transparentbkgnd_seq,
5085c2c66affSColin Finck "LVS_EX_TRANSPARENTBKGND parent", FALSE);
5086c2c66affSColin Finck
5087c2c66affSColin Finck ReleaseDC(hwndparent, hdc);
5088c2c66affSColin Finck
5089c2c66affSColin Finck DestroyWindow(hwnd);
5090c2c66affSColin Finck }
5091c2c66affSColin Finck
test_approximate_viewrect(void)5092c2c66affSColin Finck static void test_approximate_viewrect(void)
5093c2c66affSColin Finck {
5094c2c66affSColin Finck static CHAR test[] = "abracadabra, a very long item label";
50950d320bc2SAmine Khaldi DWORD item_width, item_height, header_height;
50960d320bc2SAmine Khaldi static CHAR column_header[] = "Header";
50970d320bc2SAmine Khaldi unsigned const column_width = 100;
50980d320bc2SAmine Khaldi DWORD ret, item_count;
50990d320bc2SAmine Khaldi HIMAGELIST himl;
51000d320bc2SAmine Khaldi LVITEMA itema;
51010d320bc2SAmine Khaldi LVCOLUMNA col;
51020d320bc2SAmine Khaldi HBITMAP hbmp;
51030d320bc2SAmine Khaldi HWND hwnd;
5104c2c66affSColin Finck
51050d320bc2SAmine Khaldi /* LVS_ICON */
5106c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
5107f37104daSAmine Khaldi himl = pImageList_Create(40, 40, 0, 4, 4);
5108c2c66affSColin Finck ok(himl != NULL, "failed to create imagelist\n");
5109c2c66affSColin Finck hbmp = CreateBitmap(40, 40, 1, 1, NULL);
5110c2c66affSColin Finck ok(hbmp != NULL, "failed to create bitmap\n");
5111f37104daSAmine Khaldi ret = pImageList_Add(himl, hbmp, 0);
5112c2c66affSColin Finck expect(0, ret);
5113c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
5114c2c66affSColin Finck expect(0, ret);
5115c2c66affSColin Finck
5116c2c66affSColin Finck itema.mask = LVIF_IMAGE;
5117c2c66affSColin Finck itema.iImage = 0;
5118c2c66affSColin Finck itema.iItem = 0;
5119c2c66affSColin Finck itema.iSubItem = 0;
5120c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&itema);
5121c2c66affSColin Finck expect(0, ret);
5122c2c66affSColin Finck
5123c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(75, 75));
51240d320bc2SAmine Khaldi ok(ret != 0, "Unexpected return value %#x.\n", ret);
5125c2c66affSColin Finck
5126c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 11, MAKELPARAM(100,100));
5127c2c66affSColin Finck expect(MAKELONG(77,827), ret);
5128c2c66affSColin Finck
5129c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(50, 50));
5130c2c66affSColin Finck ok(ret != 0, "got 0\n");
5131c2c66affSColin Finck
5132c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 11, MAKELPARAM(100,100));
5133c2c66affSColin Finck expect(MAKELONG(102,302), ret);
5134c2c66affSColin Finck
5135c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -1, MAKELPARAM(100,100));
5136c2c66affSColin Finck expect(MAKELONG(52,52), ret);
5137c2c66affSColin Finck
5138c2c66affSColin Finck itema.pszText = test;
5139c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&itema);
5140c2c66affSColin Finck expect(TRUE, ret);
5141c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -1, MAKELPARAM(100,100));
5142c2c66affSColin Finck expect(MAKELONG(52,52), ret);
5143c2c66affSColin Finck
5144c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 0, MAKELPARAM(100,100));
5145c2c66affSColin Finck expect(MAKELONG(52,2), ret);
5146c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 1, MAKELPARAM(100,100));
5147c2c66affSColin Finck expect(MAKELONG(52,52), ret);
5148c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 2, MAKELPARAM(100,100));
5149c2c66affSColin Finck expect(MAKELONG(102,52), ret);
5150c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 3, MAKELPARAM(100,100));
5151c2c66affSColin Finck expect(MAKELONG(102,102), ret);
5152c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 4, MAKELPARAM(100,100));
5153c2c66affSColin Finck expect(MAKELONG(102,102), ret);
5154c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 5, MAKELPARAM(100,100));
5155c2c66affSColin Finck expect(MAKELONG(102,152), ret);
5156c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 6, MAKELPARAM(100,100));
5157c2c66affSColin Finck expect(MAKELONG(102,152), ret);
5158c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 7, MAKELPARAM(160,100));
5159c2c66affSColin Finck expect(MAKELONG(152,152), ret);
5160c2c66affSColin Finck
5161c2c66affSColin Finck DestroyWindow(hwnd);
51620d320bc2SAmine Khaldi
51630d320bc2SAmine Khaldi /* LVS_REPORT */
51640d320bc2SAmine Khaldi hwnd = create_listview_control(LVS_REPORT);
51650d320bc2SAmine Khaldi
51660d320bc2SAmine Khaldi /* Empty control without columns */
51670d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 0, MAKELPARAM(100, 100));
51680d320bc2SAmine Khaldi todo_wine
51690d320bc2SAmine Khaldi ok(LOWORD(ret) == 0, "Unexpected width %d.\n", LOWORD(ret));
51700d320bc2SAmine Khaldi ok(HIWORD(ret) != 0, "Unexpected height %d.\n", HIWORD(ret));
51710d320bc2SAmine Khaldi
51720d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 0, 0);
51730d320bc2SAmine Khaldi ok(LOWORD(ret) == 0, "Unexpected width %d.\n", LOWORD(ret));
51740d320bc2SAmine Khaldi todo_wine
51750d320bc2SAmine Khaldi ok(HIWORD(ret) != 0, "Unexpected height %d.\n", HIWORD(ret));
51760d320bc2SAmine Khaldi
51770d320bc2SAmine Khaldi header_height = HIWORD(ret);
51780d320bc2SAmine Khaldi
51790d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 1, 0);
51800d320bc2SAmine Khaldi ok(LOWORD(ret) == 0, "Unexpected width %d.\n", LOWORD(ret));
51810d320bc2SAmine Khaldi todo_wine
51820d320bc2SAmine Khaldi ok(HIWORD(ret) > header_height, "Unexpected height %d.\n", HIWORD(ret));
51830d320bc2SAmine Khaldi
51840d320bc2SAmine Khaldi item_height = HIWORD(ret) - header_height;
51850d320bc2SAmine Khaldi
51860d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -2, 0);
51870d320bc2SAmine Khaldi ok(LOWORD(ret) == 0, "Unexpected width %d.\n", LOWORD(ret));
51880d320bc2SAmine Khaldi ok(HIWORD(ret) == (header_height - 2 * item_height), "Unexpected height %d.\n", HIWORD(ret)) ;
51890d320bc2SAmine Khaldi
51900d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -1, 0);
51910d320bc2SAmine Khaldi ok(LOWORD(ret) == 0, "Unexpected width %d.\n", LOWORD(ret));
51920d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height, "Unexpected height.\n");
51930d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 2, 0);
51940d320bc2SAmine Khaldi ok(LOWORD(ret) == 0, "Unexpected width %d.\n", LOWORD(ret));
51950d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height + 2 * item_height, "Unexpected height %d.\n", HIWORD(ret));
51960d320bc2SAmine Khaldi
51970d320bc2SAmine Khaldi /* Insert column */
51980d320bc2SAmine Khaldi col.mask = LVCF_TEXT | LVCF_WIDTH;
51990d320bc2SAmine Khaldi col.pszText = column_header;
52000d320bc2SAmine Khaldi col.cx = column_width;
52010d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
52020d320bc2SAmine Khaldi ok(ret == 0, "Unexpected return value %d.\n", ret);
52030d320bc2SAmine Khaldi
52040d320bc2SAmine Khaldi /* Empty control with column */
52050d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 0, 0);
52060d320bc2SAmine Khaldi todo_wine {
52070d320bc2SAmine Khaldi ok(LOWORD(ret) >= column_width, "Unexpected width %d.\n", LOWORD(ret));
52080d320bc2SAmine Khaldi ok(HIWORD(ret) != 0, "Unexpected height %d.\n", HIWORD(ret));
52090d320bc2SAmine Khaldi }
52100d320bc2SAmine Khaldi header_height = HIWORD(ret);
52110d320bc2SAmine Khaldi item_width = LOWORD(ret);
52120d320bc2SAmine Khaldi
52130d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 1, 0);
52140d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52150d320bc2SAmine Khaldi todo_wine
52160d320bc2SAmine Khaldi ok(HIWORD(ret) > header_height, "Unexpected height %d.\n", HIWORD(ret));
52170d320bc2SAmine Khaldi
52180d320bc2SAmine Khaldi item_height = HIWORD(ret) - header_height;
52190d320bc2SAmine Khaldi
52200d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -2, 0);
52210d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52220d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height - 2 * item_height, "Unexpected height %d.\n", HIWORD(ret));
52230d320bc2SAmine Khaldi
52240d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -1, 0);
52250d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52260d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height, "Unexpected height %d.\n", HIWORD(ret));
52270d320bc2SAmine Khaldi
52280d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 2, 0);
52290d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52300d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height + 2 * item_height, "Unexpected height %d.\n", HIWORD(ret));
52310d320bc2SAmine Khaldi
52320d320bc2SAmine Khaldi for (item_count = 1; item_count <= 2; ++item_count)
52330d320bc2SAmine Khaldi {
52340d320bc2SAmine Khaldi itema.mask = LVIF_TEXT;
52350d320bc2SAmine Khaldi itema.iItem = 0;
52360d320bc2SAmine Khaldi itema.iSubItem = 0;
52370d320bc2SAmine Khaldi itema.pszText = test;
52380d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&itema);
52390d320bc2SAmine Khaldi ok(ret == 0, "Unexpected return value %d.\n", ret);
52400d320bc2SAmine Khaldi
52410d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 0, 0);
52420d320bc2SAmine Khaldi ok(LOWORD(ret) >= column_width, "Unexpected width %d.\n", LOWORD(ret));
52430d320bc2SAmine Khaldi todo_wine
52440d320bc2SAmine Khaldi ok(HIWORD(ret) != 0, "Unexpected height %d.\n", HIWORD(ret));
52450d320bc2SAmine Khaldi
52460d320bc2SAmine Khaldi header_height = HIWORD(ret);
52470d320bc2SAmine Khaldi item_width = LOWORD(ret);
52480d320bc2SAmine Khaldi
52490d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 1, 0);
52500d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d, item %d\n", LOWORD(ret), item_count - 1);
52510d320bc2SAmine Khaldi ok(HIWORD(ret) > header_height, "Unexpected height %d. item %d.\n", HIWORD(ret), item_count - 1);
52520d320bc2SAmine Khaldi
52530d320bc2SAmine Khaldi item_height = HIWORD(ret) - header_height;
52540d320bc2SAmine Khaldi
52550d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -2, 0);
52560d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52570d320bc2SAmine Khaldi todo_wine
52580d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height - 2 * item_height, "Unexpected height %d.\n", HIWORD(ret));
52590d320bc2SAmine Khaldi
52600d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -1, 0);
52610d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52620d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height + item_count * item_height, "Unexpected height %d.\n", HIWORD(ret));
52630d320bc2SAmine Khaldi
52640d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 2, 0);
52650d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52660d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height + 2 * item_height, "Unexpected height %d.\n", HIWORD(ret));
52670d320bc2SAmine Khaldi
52680d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, 2, MAKELONG(item_width * 2, header_height + 3 * item_height));
52690d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52700d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height + 2 * item_height, "Unexpected height %d.\n", HIWORD(ret));
52710d320bc2SAmine Khaldi
52720d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -2, MAKELONG(item_width * 2, 0));
52730d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52740d320bc2SAmine Khaldi todo_wine
52750d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height - 2 * item_height, "Unexpected height %d.\n", HIWORD(ret));
52760d320bc2SAmine Khaldi
52770d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_APPROXIMATEVIEWRECT, -2, MAKELONG(-1, -1));
52780d320bc2SAmine Khaldi ok(LOWORD(ret) == item_width, "Unexpected width %d.\n", LOWORD(ret));
52790d320bc2SAmine Khaldi todo_wine
52800d320bc2SAmine Khaldi ok(HIWORD(ret) == header_height - 2 * item_height, "Unexpected height %d.\n", HIWORD(ret));
52810d320bc2SAmine Khaldi }
52820d320bc2SAmine Khaldi
52830d320bc2SAmine Khaldi DestroyWindow(hwnd);
52840d320bc2SAmine Khaldi
5285c2c66affSColin Finck }
5286c2c66affSColin Finck
test_finditem(void)5287c2c66affSColin Finck static void test_finditem(void)
5288c2c66affSColin Finck {
5289c2c66affSColin Finck LVFINDINFOA fi;
5290c2c66affSColin Finck static char f[5];
5291c2c66affSColin Finck HWND hwnd;
5292c2c66affSColin Finck INT r;
5293c2c66affSColin Finck
5294c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
5295c2c66affSColin Finck insert_item(hwnd, 0);
5296c2c66affSColin Finck
5297c2c66affSColin Finck memset(&fi, 0, sizeof(fi));
5298c2c66affSColin Finck
5299c2c66affSColin Finck /* full string search, inserted text was "foo" */
5300c2c66affSColin Finck strcpy(f, "foo");
5301c2c66affSColin Finck fi.flags = LVFI_STRING;
5302c2c66affSColin Finck fi.psz = f;
5303c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5304c2c66affSColin Finck expect(0, r);
5305c2c66affSColin Finck
5306c2c66affSColin Finck fi.flags = LVFI_STRING | LVFI_PARTIAL;
5307c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5308c2c66affSColin Finck expect(0, r);
5309c2c66affSColin Finck
5310c2c66affSColin Finck fi.flags = LVFI_PARTIAL;
5311c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5312c2c66affSColin Finck expect(0, r);
5313c2c66affSColin Finck
5314c2c66affSColin Finck /* partial string search, inserted text was "foo" */
5315c2c66affSColin Finck strcpy(f, "fo");
5316c2c66affSColin Finck fi.flags = LVFI_STRING | LVFI_PARTIAL;
5317c2c66affSColin Finck fi.psz = f;
5318c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5319c2c66affSColin Finck expect(0, r);
5320c2c66affSColin Finck
5321c2c66affSColin Finck fi.flags = LVFI_STRING;
5322c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5323c2c66affSColin Finck expect(-1, r);
5324c2c66affSColin Finck
5325c2c66affSColin Finck fi.flags = LVFI_PARTIAL;
5326c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5327c2c66affSColin Finck expect(0, r);
5328c2c66affSColin Finck
5329c2c66affSColin Finck /* partial string search, part after start char */
5330c2c66affSColin Finck strcpy(f, "oo");
5331c2c66affSColin Finck fi.flags = LVFI_STRING | LVFI_PARTIAL;
5332c2c66affSColin Finck fi.psz = f;
5333c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5334c2c66affSColin Finck expect(-1, r);
5335c2c66affSColin Finck
5336c2c66affSColin Finck /* try with LVFI_SUBSTRING */
5337c2c66affSColin Finck strcpy(f, "fo");
5338c2c66affSColin Finck fi.flags = LVFI_SUBSTRING;
5339c2c66affSColin Finck fi.psz = f;
5340c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5341c2c66affSColin Finck expect(0, r);
5342c2c66affSColin Finck strcpy(f, "f");
5343c2c66affSColin Finck fi.flags = LVFI_SUBSTRING;
5344c2c66affSColin Finck fi.psz = f;
5345c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5346c2c66affSColin Finck expect(0, r);
5347c2c66affSColin Finck strcpy(f, "o");
5348c2c66affSColin Finck fi.flags = LVFI_SUBSTRING;
5349c2c66affSColin Finck fi.psz = f;
5350c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5351c2c66affSColin Finck expect(-1, r);
5352c2c66affSColin Finck
5353c2c66affSColin Finck strcpy(f, "o");
5354c2c66affSColin Finck fi.flags = LVFI_SUBSTRING | LVFI_PARTIAL;
5355c2c66affSColin Finck fi.psz = f;
5356c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5357c2c66affSColin Finck expect(-1, r);
5358c2c66affSColin Finck
5359c2c66affSColin Finck strcpy(f, "f");
5360c2c66affSColin Finck fi.flags = LVFI_SUBSTRING | LVFI_STRING;
5361c2c66affSColin Finck fi.psz = f;
5362c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5363c2c66affSColin Finck expect(0, r);
5364c2c66affSColin Finck
5365c2c66affSColin Finck fi.flags = LVFI_SUBSTRING | LVFI_PARTIAL;
5366c2c66affSColin Finck r = SendMessageA(hwnd, LVM_FINDITEMA, -1, (LPARAM)&fi);
5367c2c66affSColin Finck expect(0, r);
5368c2c66affSColin Finck
5369c2c66affSColin Finck DestroyWindow(hwnd);
5370c2c66affSColin Finck }
5371c2c66affSColin Finck
test_LVS_EX_HEADERINALLVIEWS(void)5372c2c66affSColin Finck static void test_LVS_EX_HEADERINALLVIEWS(void)
5373c2c66affSColin Finck {
5374c2c66affSColin Finck HWND hwnd, header;
5375c2c66affSColin Finck DWORD style;
5376c2c66affSColin Finck
5377c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
5378c2c66affSColin Finck
5379c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_HEADERINALLVIEWS,
5380c2c66affSColin Finck LVS_EX_HEADERINALLVIEWS);
5381c2c66affSColin Finck
5382c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
5383c2c66affSColin Finck if (!IsWindow(header))
5384c2c66affSColin Finck {
5385c2c66affSColin Finck win_skip("LVS_EX_HEADERINALLVIEWS unsupported\n");
5386c2c66affSColin Finck DestroyWindow(hwnd);
5387c2c66affSColin Finck return;
5388c2c66affSColin Finck }
5389c2c66affSColin Finck
5390c2c66affSColin Finck /* LVS_NOCOLUMNHEADER works as before */
5391c2c66affSColin Finck style = GetWindowLongA(hwnd, GWL_STYLE);
5392c2c66affSColin Finck SetWindowLongW(hwnd, GWL_STYLE, style | LVS_NOCOLUMNHEADER);
5393c2c66affSColin Finck style = GetWindowLongA(header, GWL_STYLE);
5394c2c66affSColin Finck ok(style & HDS_HIDDEN, "Expected HDS_HIDDEN\n");
5395c2c66affSColin Finck style = GetWindowLongA(hwnd, GWL_STYLE);
5396c2c66affSColin Finck SetWindowLongW(hwnd, GWL_STYLE, style & ~LVS_NOCOLUMNHEADER);
5397c2c66affSColin Finck style = GetWindowLongA(header, GWL_STYLE);
5398c2c66affSColin Finck ok(!(style & HDS_HIDDEN), "Expected HDS_HIDDEN to be unset\n");
5399c2c66affSColin Finck
5400c2c66affSColin Finck /* try to remove style */
5401c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_HEADERINALLVIEWS, 0);
5402c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
5403c2c66affSColin Finck ok(IsWindow(header), "Expected header to be created\n");
5404c2c66affSColin Finck style = GetWindowLongA(header, GWL_STYLE);
5405c2c66affSColin Finck ok(!(style & HDS_HIDDEN), "HDS_HIDDEN not expected\n");
5406c2c66affSColin Finck
5407c2c66affSColin Finck DestroyWindow(hwnd);
5408c2c66affSColin Finck
5409c2c66affSColin Finck /* check other styles */
5410c2c66affSColin Finck hwnd = create_listview_control(LVS_LIST);
5411c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_HEADERINALLVIEWS,
5412c2c66affSColin Finck LVS_EX_HEADERINALLVIEWS);
5413c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
5414c2c66affSColin Finck ok(IsWindow(header), "Expected header to be created\n");
5415c2c66affSColin Finck DestroyWindow(hwnd);
5416c2c66affSColin Finck
5417c2c66affSColin Finck hwnd = create_listview_control(LVS_SMALLICON);
5418c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_HEADERINALLVIEWS,
5419c2c66affSColin Finck LVS_EX_HEADERINALLVIEWS);
5420c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
5421c2c66affSColin Finck ok(IsWindow(header), "Expected header to be created\n");
5422c2c66affSColin Finck DestroyWindow(hwnd);
5423c2c66affSColin Finck
5424c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
5425c2c66affSColin Finck SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_HEADERINALLVIEWS,
5426c2c66affSColin Finck LVS_EX_HEADERINALLVIEWS);
5427c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
5428c2c66affSColin Finck ok(IsWindow(header), "Expected header to be created\n");
5429c2c66affSColin Finck DestroyWindow(hwnd);
5430c2c66affSColin Finck }
5431c2c66affSColin Finck
test_hover(void)5432c2c66affSColin Finck static void test_hover(void)
5433c2c66affSColin Finck {
5434c2c66affSColin Finck HWND hwnd, fg;
5435c2c66affSColin Finck DWORD r;
5436c2c66affSColin Finck
5437c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
5438c2c66affSColin Finck SetForegroundWindow(hwndparent);
5439c2c66affSColin Finck fg = GetForegroundWindow();
5440c2c66affSColin Finck if (fg != hwndparent)
5441c2c66affSColin Finck {
5442c2c66affSColin Finck skip("Window is not in the foreground. Skipping hover tests.\n");
5443c2c66affSColin Finck DestroyWindow(hwnd);
5444c2c66affSColin Finck return;
5445c2c66affSColin Finck }
5446c2c66affSColin Finck
5447c2c66affSColin Finck /* test WM_MOUSEHOVER forwarding */
5448c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5449c2c66affSColin Finck r = SendMessageA(hwnd, WM_MOUSEHOVER, 0, 0);
5450c2c66affSColin Finck expect(0, r);
5451c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, hover_parent, "NM_HOVER allow test", TRUE);
5452c2c66affSColin Finck g_block_hover = TRUE;
5453c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5454c2c66affSColin Finck r = SendMessageA(hwnd, WM_MOUSEHOVER, 0, 0);
5455c2c66affSColin Finck expect(0, r);
5456c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, hover_parent, "NM_HOVER block test", TRUE);
5457c2c66affSColin Finck g_block_hover = FALSE;
5458c2c66affSColin Finck
5459c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETHOVERTIME, 0, 500);
5460c2c66affSColin Finck expect(HOVER_DEFAULT, r);
5461c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETHOVERTIME, 0, 0);
5462c2c66affSColin Finck expect(500, r);
5463c2c66affSColin Finck
5464c2c66affSColin Finck DestroyWindow(hwnd);
5465c2c66affSColin Finck }
5466c2c66affSColin Finck
test_destroynotify(void)5467c2c66affSColin Finck static void test_destroynotify(void)
5468c2c66affSColin Finck {
5469c2c66affSColin Finck HWND hwnd;
5470c2c66affSColin Finck BOOL ret;
5471c2c66affSColin Finck
5472c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
5473c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
5474c2c66affSColin Finck
5475c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5476c2c66affSColin Finck DestroyWindow(hwnd);
5477c2c66affSColin Finck ok_sequence(sequences, COMBINED_SEQ_INDEX, listview_destroy, "check destroy order", FALSE);
5478c2c66affSColin Finck
5479c2c66affSColin Finck /* same for ownerdata list */
5480c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT|LVS_OWNERDATA);
5481c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
5482c2c66affSColin Finck
5483c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5484c2c66affSColin Finck DestroyWindow(hwnd);
5485c2c66affSColin Finck ok_sequence(sequences, COMBINED_SEQ_INDEX, listview_ownerdata_destroy, "check destroy order, ownerdata", FALSE);
5486c2c66affSColin Finck
5487c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT|LVS_OWNERDATA);
5488c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
5489c2c66affSColin Finck
5490c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5491c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_DELETEALLITEMS, 0, 0);
5492c2c66affSColin Finck ok(ret == TRUE, "got %d\n", ret);
5493c2c66affSColin Finck ok_sequence(sequences, COMBINED_SEQ_INDEX, listview_ownerdata_deleteall, "deleteall ownerdata", FALSE);
5494c2c66affSColin Finck DestroyWindow(hwnd);
5495c2c66affSColin Finck }
5496c2c66affSColin Finck
test_header_notification(void)5497c2c66affSColin Finck static void test_header_notification(void)
5498c2c66affSColin Finck {
5499c2c66affSColin Finck static char textA[] = "newtext";
5500c2c66affSColin Finck HWND list, header;
5501c2c66affSColin Finck HDITEMA item;
5502c2c66affSColin Finck NMHEADERA nmh;
5503c2c66affSColin Finck LVCOLUMNA col;
5504c2c66affSColin Finck DWORD ret;
5505c2c66affSColin Finck BOOL r;
5506c2c66affSColin Finck
5507c2c66affSColin Finck list = create_listview_control(LVS_REPORT);
5508c2c66affSColin Finck ok(list != NULL, "failed to create listview window\n");
5509c2c66affSColin Finck
5510c2c66affSColin Finck memset(&col, 0, sizeof(col));
5511c2c66affSColin Finck col.mask = LVCF_WIDTH;
5512c2c66affSColin Finck col.cx = 100;
5513c2c66affSColin Finck ret = SendMessageA(list, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
5514c2c66affSColin Finck expect(0, ret);
5515c2c66affSColin Finck
5516c2c66affSColin Finck /* check list parent notification after header item changed,
5517c2c66affSColin Finck this test should be placed before header subclassing to avoid
5518c2c66affSColin Finck Listview -> Header messages to be logged */
5519c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5520c2c66affSColin Finck
5521c2c66affSColin Finck col.mask = LVCF_TEXT;
5522c2c66affSColin Finck col.pszText = textA;
5523c2c66affSColin Finck r = SendMessageA(list, LVM_SETCOLUMNA, 0, (LPARAM)&col);
5524c2c66affSColin Finck expect(TRUE, r);
5525c2c66affSColin Finck
5526c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_header_changed_seq,
5527c2c66affSColin Finck "header notify, listview", FALSE);
5528c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
5529c2c66affSColin Finck "header notify, parent", FALSE);
5530c2c66affSColin Finck
5531c2c66affSColin Finck header = subclass_header(list);
5532c2c66affSColin Finck
5533c2c66affSColin Finck ret = SendMessageA(header, HDM_GETITEMCOUNT, 0, 0);
5534c2c66affSColin Finck expect(1, ret);
5535c2c66affSColin Finck
5536c2c66affSColin Finck memset(&item, 0, sizeof(item));
5537c2c66affSColin Finck item.mask = HDI_WIDTH;
5538c2c66affSColin Finck ret = SendMessageA(header, HDM_GETITEMA, 0, (LPARAM)&item);
5539c2c66affSColin Finck expect(1, ret);
5540c2c66affSColin Finck expect(100, item.cxy);
5541c2c66affSColin Finck
5542c2c66affSColin Finck nmh.hdr.hwndFrom = header;
5543c2c66affSColin Finck nmh.hdr.idFrom = GetWindowLongPtrA(header, GWLP_ID);
5544c2c66affSColin Finck nmh.hdr.code = HDN_ITEMCHANGEDA;
5545c2c66affSColin Finck nmh.iItem = 0;
5546c2c66affSColin Finck nmh.iButton = 0;
5547c2c66affSColin Finck item.mask = HDI_WIDTH;
5548c2c66affSColin Finck item.cxy = 50;
5549c2c66affSColin Finck nmh.pitem = &item;
5550c2c66affSColin Finck ret = SendMessageA(list, WM_NOTIFY, 0, (LPARAM)&nmh);
5551c2c66affSColin Finck expect(0, ret);
5552c2c66affSColin Finck
5553c2c66affSColin Finck DestroyWindow(list);
5554c2c66affSColin Finck }
5555c2c66affSColin Finck
test_header_notification2(void)5556c2c66affSColin Finck static void test_header_notification2(void)
5557c2c66affSColin Finck {
5558c2c66affSColin Finck static char textA[] = "newtext";
5559c2c66affSColin Finck HWND list, header;
5560c2c66affSColin Finck HDITEMW itemW;
5561c2c66affSColin Finck NMHEADERW nmhdr;
5562c2c66affSColin Finck LVCOLUMNA col;
5563c2c66affSColin Finck DWORD ret;
5564c2c66affSColin Finck WCHAR buffer[100];
5565c2c66affSColin Finck struct message parent_header_notify_seq[] = {
5566c2c66affSColin Finck { WM_NOTIFY, sent|id, 0, 0, 0 },
5567c2c66affSColin Finck { 0 }
5568c2c66affSColin Finck };
5569c2c66affSColin Finck
5570c2c66affSColin Finck list = create_listview_control(LVS_REPORT);
5571c2c66affSColin Finck ok(list != NULL, "failed to create listview window\n");
5572c2c66affSColin Finck
5573c2c66affSColin Finck memset(&col, 0, sizeof(col));
5574c2c66affSColin Finck col.mask = LVCF_WIDTH | LVCF_TEXT;
5575c2c66affSColin Finck col.cx = 100;
5576c2c66affSColin Finck col.pszText = textA;
5577c2c66affSColin Finck ret = SendMessageA(list, LVM_INSERTCOLUMNA, 0, (LPARAM)&col);
5578c2c66affSColin Finck expect(0, ret);
5579c2c66affSColin Finck
5580c2c66affSColin Finck header = (HWND)SendMessageA(list, LVM_GETHEADER, 0, 0);
5581c2c66affSColin Finck ok(header != 0, "No header\n");
5582c2c66affSColin Finck memset(&itemW, 0, sizeof(itemW));
5583c2c66affSColin Finck itemW.mask = HDI_WIDTH | HDI_ORDER | HDI_TEXT;
5584c2c66affSColin Finck itemW.pszText = buffer;
55855f7243b5SAmine Khaldi itemW.cchTextMax = ARRAY_SIZE(buffer);
5586c2c66affSColin Finck ret = SendMessageW(header, HDM_GETITEMW, 0, (LPARAM)&itemW);
5587c2c66affSColin Finck expect(1, ret);
5588c2c66affSColin Finck
5589c2c66affSColin Finck nmhdr.hdr.hwndFrom = header;
5590c2c66affSColin Finck nmhdr.hdr.idFrom = GetWindowLongPtrW(header, GWLP_ID);
5591c2c66affSColin Finck nmhdr.iItem = 0;
5592c2c66affSColin Finck nmhdr.iButton = 0;
5593c2c66affSColin Finck nmhdr.pitem = &itemW;
5594c2c66affSColin Finck
5595c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5596c2c66affSColin Finck nmhdr.hdr.code = HDN_ITEMCHANGINGW;
5597c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5598c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5599c2c66affSColin Finck parent_header_notify_seq[0].id = HDN_ITEMCHANGINGA;
5600c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_header_notify_seq,
5601c2c66affSColin Finck "header notify, parent", TRUE);
5602c2c66affSColin Finck todo_wine
5603c2c66affSColin Finck ok(nmhdr.hdr.code == HDN_ITEMCHANGINGA, "Expected ANSI notification code\n");
5604c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5605c2c66affSColin Finck nmhdr.hdr.code = HDN_ITEMCHANGEDW;
5606c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5607c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5608c2c66affSColin Finck parent_header_notify_seq[0].id = HDN_ITEMCHANGEDA;
5609c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_header_notify_seq,
5610c2c66affSColin Finck "header notify, parent", TRUE);
5611c2c66affSColin Finck todo_wine
5612c2c66affSColin Finck ok(nmhdr.hdr.code == HDN_ITEMCHANGEDA, "Expected ANSI notification code\n");
5613c2c66affSColin Finck /* HDN_ITEMCLICK sets focus to list, which generates messages we don't want to check */
5614c2c66affSColin Finck SetFocus(list);
5615c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5616c2c66affSColin Finck nmhdr.hdr.code = HDN_ITEMCLICKW;
5617c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5618c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5619c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_header_click_seq,
5620c2c66affSColin Finck "header notify, parent", FALSE);
5621c2c66affSColin Finck ok(nmhdr.hdr.code == HDN_ITEMCLICKA, "Expected ANSI notification code\n");
5622c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5623c2c66affSColin Finck nmhdr.hdr.code = HDN_ITEMDBLCLICKW;
5624c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5625c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5626c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
5627c2c66affSColin Finck "header notify, parent", FALSE);
5628c2c66affSColin Finck ok(nmhdr.hdr.code == HDN_ITEMDBLCLICKW, "Expected Unicode notification code\n");
5629c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5630c2c66affSColin Finck nmhdr.hdr.code = HDN_DIVIDERDBLCLICKW;
5631c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5632c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5633c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_header_divider_dclick_seq,
5634c2c66affSColin Finck "header notify, parent", TRUE);
5635c2c66affSColin Finck ok(nmhdr.hdr.code == HDN_DIVIDERDBLCLICKA, "Expected ANSI notification code\n");
5636c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5637c2c66affSColin Finck nmhdr.hdr.code = HDN_BEGINTRACKW;
5638c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5639c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5640c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
5641c2c66affSColin Finck "header notify, parent", FALSE);
5642c2c66affSColin Finck ok(nmhdr.hdr.code == HDN_BEGINTRACKW, "Expected Unicode notification code\n");
5643c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5644c2c66affSColin Finck nmhdr.hdr.code = HDN_ENDTRACKW;
5645c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5646c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5647c2c66affSColin Finck parent_header_notify_seq[0].id = HDN_ENDTRACKA;
5648c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_header_notify_seq,
5649c2c66affSColin Finck "header notify, parent", FALSE);
5650c2c66affSColin Finck ok(nmhdr.hdr.code == HDN_ENDTRACKA, "Expected ANSI notification code\n");
5651c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5652c2c66affSColin Finck nmhdr.hdr.code = HDN_TRACKW;
5653c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5654c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5655c2c66affSColin Finck parent_header_notify_seq[0].id = HDN_TRACKA;
5656c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_header_notify_seq,
5657c2c66affSColin Finck "header notify, parent", FALSE);
5658c2c66affSColin Finck ok(nmhdr.hdr.code == HDN_TRACKA, "Expected ANSI notification code\n");
5659c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5660c2c66affSColin Finck nmhdr.hdr.code = HDN_BEGINDRAG;
5661c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5662c2c66affSColin Finck ok(ret == 1, "got %d\n", ret);
5663c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
5664c2c66affSColin Finck "header notify, parent", FALSE);
5665c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5666c2c66affSColin Finck nmhdr.hdr.code = HDN_ENDDRAG;
5667c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5668c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5669c2c66affSColin Finck parent_header_notify_seq[0].id = HDN_ENDDRAG;
5670c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_header_notify_seq,
5671c2c66affSColin Finck "header notify, parent", FALSE);
5672c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5673c2c66affSColin Finck nmhdr.hdr.code = HDN_FILTERCHANGE;
5674c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5675c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5676c2c66affSColin Finck parent_header_notify_seq[0].id = HDN_FILTERCHANGE;
5677c2c66affSColin Finck parent_header_notify_seq[0].flags |= optional; /* NT4 does not send this message */
5678c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_header_notify_seq,
5679c2c66affSColin Finck "header notify, parent", FALSE);
5680c2c66affSColin Finck parent_header_notify_seq[0].flags &= ~optional;
5681c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5682c2c66affSColin Finck nmhdr.hdr.code = HDN_BEGINFILTEREDIT;
5683c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5684c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5685c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
5686c2c66affSColin Finck "header notify, parent", FALSE);
5687c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5688c2c66affSColin Finck nmhdr.hdr.code = HDN_ENDFILTEREDIT;
5689c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5690c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5691c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
5692c2c66affSColin Finck "header notify, parent", FALSE);
5693c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5694c2c66affSColin Finck nmhdr.hdr.code = HDN_ITEMSTATEICONCLICK;
5695c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5696c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5697c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
5698c2c66affSColin Finck "header notify, parent", FALSE);
5699c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5700c2c66affSColin Finck nmhdr.hdr.code = HDN_ITEMKEYDOWN;
5701c2c66affSColin Finck ret = SendMessageW(list, WM_NOTIFY, 0, (LPARAM)&nmhdr);
5702c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5703c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
5704c2c66affSColin Finck "header notify, parent", FALSE);
5705c2c66affSColin Finck
5706c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5707c2c66affSColin Finck
5708c2c66affSColin Finck DestroyWindow(list);
5709c2c66affSColin Finck }
5710c2c66affSColin Finck
test_createdragimage(void)5711c2c66affSColin Finck static void test_createdragimage(void)
5712c2c66affSColin Finck {
5713c2c66affSColin Finck HIMAGELIST himl;
5714c2c66affSColin Finck POINT pt;
5715c2c66affSColin Finck HWND list;
5716c2c66affSColin Finck
5717c2c66affSColin Finck list = create_listview_control(LVS_ICON);
5718c2c66affSColin Finck ok(list != NULL, "failed to create listview window\n");
5719c2c66affSColin Finck
5720c2c66affSColin Finck insert_item(list, 0);
5721c2c66affSColin Finck
5722c2c66affSColin Finck /* NULL point */
5723c2c66affSColin Finck himl = (HIMAGELIST)SendMessageA(list, LVM_CREATEDRAGIMAGE, 0, 0);
5724c2c66affSColin Finck ok(himl == NULL, "got %p\n", himl);
5725c2c66affSColin Finck
5726c2c66affSColin Finck himl = (HIMAGELIST)SendMessageA(list, LVM_CREATEDRAGIMAGE, 0, (LPARAM)&pt);
5727c2c66affSColin Finck ok(himl != NULL, "got %p\n", himl);
5728f37104daSAmine Khaldi pImageList_Destroy(himl);
5729c2c66affSColin Finck
5730c2c66affSColin Finck DestroyWindow(list);
5731c2c66affSColin Finck }
5732c2c66affSColin Finck
test_dispinfo(void)5733c2c66affSColin Finck static void test_dispinfo(void)
5734c2c66affSColin Finck {
5735c2c66affSColin Finck static const char testA[] = "TEST";
5736c2c66affSColin Finck WCHAR buff[10];
5737c2c66affSColin Finck LVITEMA item;
5738c2c66affSColin Finck HWND hwnd;
5739c2c66affSColin Finck DWORD ret;
5740c2c66affSColin Finck
5741c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
5742c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
5743c2c66affSColin Finck
5744c2c66affSColin Finck insert_item(hwnd, 0);
5745c2c66affSColin Finck
5746c2c66affSColin Finck memset(&item, 0, sizeof(item));
5747c2c66affSColin Finck item.pszText = LPSTR_TEXTCALLBACKA;
5748c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&item);
5749c2c66affSColin Finck expect(1, ret);
5750c2c66affSColin Finck
5751c2c66affSColin Finck g_disp_A_to_W = TRUE;
5752c2c66affSColin Finck item.pszText = (char*)buff;
57535f7243b5SAmine Khaldi item.cchTextMax = ARRAY_SIZE(buff);
5754c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_GETITEMTEXTA, 0, (LPARAM)&item);
5755c2c66affSColin Finck ok(ret == sizeof(testA)-1, "got %d, expected 4\n", ret);
5756c2c66affSColin Finck g_disp_A_to_W = FALSE;
5757c2c66affSColin Finck
5758c2c66affSColin Finck ok(memcmp(item.pszText, testA, sizeof(testA)) == 0,
5759c2c66affSColin Finck "got %s, expected %s\n", item.pszText, testA);
5760c2c66affSColin Finck
5761c2c66affSColin Finck DestroyWindow(hwnd);
5762c2c66affSColin Finck }
5763c2c66affSColin Finck
test_LVM_SETITEMTEXT(void)5764c2c66affSColin Finck static void test_LVM_SETITEMTEXT(void)
5765c2c66affSColin Finck {
5766c2c66affSColin Finck static char testA[] = "TEST";
5767c2c66affSColin Finck LVITEMA item;
5768c2c66affSColin Finck HWND hwnd;
5769c2c66affSColin Finck DWORD ret;
5770c2c66affSColin Finck
5771c2c66affSColin Finck hwnd = create_listview_control(LVS_ICON);
5772c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
5773c2c66affSColin Finck
5774c2c66affSColin Finck insert_item(hwnd, 0);
5775c2c66affSColin Finck
5776c2c66affSColin Finck /* null item pointer */
5777c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, 0);
5778c2c66affSColin Finck expect(FALSE, ret);
5779c2c66affSColin Finck
5780c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMTEXTW, 0, 0);
5781c2c66affSColin Finck expect(FALSE, ret);
5782c2c66affSColin Finck
5783c2c66affSColin Finck /* index out of bounds */
5784c2c66affSColin Finck item.pszText = testA;
5785c2c66affSColin Finck item.cchTextMax = 0; /* ignored */
5786c2c66affSColin Finck item.iSubItem = 0;
5787c2c66affSColin Finck
5788c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, 1, (LPARAM)&item);
5789c2c66affSColin Finck expect(FALSE, ret);
5790c2c66affSColin Finck
5791c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, -1, (LPARAM)&item);
5792c2c66affSColin Finck expect(FALSE, ret);
5793c2c66affSColin Finck
5794c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMTEXTA, 0, (LPARAM)&item);
5795c2c66affSColin Finck expect(TRUE, ret);
5796c2c66affSColin Finck
5797c2c66affSColin Finck DestroyWindow(hwnd);
5798c2c66affSColin Finck }
5799c2c66affSColin Finck
test_LVM_REDRAWITEMS(void)5800c2c66affSColin Finck static void test_LVM_REDRAWITEMS(void)
5801c2c66affSColin Finck {
5802c2c66affSColin Finck HWND list;
5803c2c66affSColin Finck DWORD ret;
5804c2c66affSColin Finck
5805c2c66affSColin Finck list = create_listview_control(LVS_ICON);
5806c2c66affSColin Finck ok(list != NULL, "failed to create listview window\n");
5807c2c66affSColin Finck
5808c2c66affSColin Finck ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 0);
5809c2c66affSColin Finck expect(TRUE, ret);
5810c2c66affSColin Finck
5811c2c66affSColin Finck insert_item(list, 0);
5812c2c66affSColin Finck
5813c2c66affSColin Finck ret = SendMessageA(list, LVM_REDRAWITEMS, -1, 0);
5814c2c66affSColin Finck expect(TRUE, ret);
5815c2c66affSColin Finck
5816c2c66affSColin Finck ret = SendMessageA(list, LVM_REDRAWITEMS, 0, -1);
5817c2c66affSColin Finck expect(TRUE, ret);
5818c2c66affSColin Finck
5819c2c66affSColin Finck ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 0);
5820c2c66affSColin Finck expect(TRUE, ret);
5821c2c66affSColin Finck
5822c2c66affSColin Finck ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 1);
5823c2c66affSColin Finck expect(TRUE, ret);
5824c2c66affSColin Finck
5825c2c66affSColin Finck ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 2);
5826c2c66affSColin Finck expect(TRUE, ret);
5827c2c66affSColin Finck
5828c2c66affSColin Finck ret = SendMessageA(list, LVM_REDRAWITEMS, 1, 0);
5829c2c66affSColin Finck expect(TRUE, ret);
5830c2c66affSColin Finck
5831c2c66affSColin Finck ret = SendMessageA(list, LVM_REDRAWITEMS, 2, 3);
5832c2c66affSColin Finck expect(TRUE, ret);
5833c2c66affSColin Finck
5834c2c66affSColin Finck DestroyWindow(list);
5835c2c66affSColin Finck }
5836c2c66affSColin Finck
test_imagelists(void)5837c2c66affSColin Finck static void test_imagelists(void)
5838c2c66affSColin Finck {
5839c2c66affSColin Finck HWND hwnd, header;
5840c2c66affSColin Finck HIMAGELIST himl1, himl2, himl3;
5841c2c66affSColin Finck LRESULT ret;
5842c2c66affSColin Finck
5843f37104daSAmine Khaldi himl1 = pImageList_Create(40, 40, 0, 4, 4);
5844f37104daSAmine Khaldi himl2 = pImageList_Create(40, 40, 0, 4, 4);
5845f37104daSAmine Khaldi himl3 = pImageList_Create(40, 40, 0, 4, 4);
5846c2c66affSColin Finck ok(himl1 != NULL, "Failed to create imagelist\n");
5847c2c66affSColin Finck ok(himl2 != NULL, "Failed to create imagelist\n");
5848c2c66affSColin Finck ok(himl3 != NULL, "Failed to create imagelist\n");
5849c2c66affSColin Finck
5850c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT | LVS_SHAREIMAGELISTS);
5851c2c66affSColin Finck header = subclass_header(hwnd);
5852c2c66affSColin Finck
5853c2c66affSColin Finck ok(header != NULL, "Expected header\n");
5854c2c66affSColin Finck ret = SendMessageA(header, HDM_GETIMAGELIST, 0, 0);
5855c2c66affSColin Finck ok(ret == 0, "Expected no imagelist, got %p\n", (HIMAGELIST)ret);
5856c2c66affSColin Finck
5857c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5858c2c66affSColin Finck
5859c2c66affSColin Finck ret = SendMessageW(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl1);
5860c2c66affSColin Finck ok(ret == 0, "Expected no imagelist, got %p\n", (HIMAGELIST)ret);
5861c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_set_imagelist,
5862c2c66affSColin Finck "set normal image list", FALSE);
5863c2c66affSColin Finck
5864c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5865c2c66affSColin Finck
5866c2c66affSColin Finck ret = SendMessageW(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl2);
5867c2c66affSColin Finck ok(ret == 0, "Expected no imagelist, got %p\n", (HIMAGELIST)ret);
5868c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_set_imagelist,
5869c2c66affSColin Finck "set state image list", TRUE);
5870c2c66affSColin Finck
5871c2c66affSColin Finck ret = SendMessageA(header, HDM_GETIMAGELIST, 0, 0);
5872c2c66affSColin Finck ok(ret == 0, "Expected no imagelist, got %p\n", (HIMAGELIST)ret);
5873c2c66affSColin Finck
5874c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5875c2c66affSColin Finck
5876c2c66affSColin Finck ret = SendMessageW(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl3);
5877c2c66affSColin Finck ok(ret == 0, "Expected no imagelist, got %p\n", (HIMAGELIST)ret);
5878c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_header_set_imagelist,
5879c2c66affSColin Finck "set small image list", FALSE);
5880c2c66affSColin Finck
5881c2c66affSColin Finck ret = SendMessageA(header, HDM_GETIMAGELIST, 0, 0);
5882c2c66affSColin Finck ok((HIMAGELIST)ret == himl3, "Expected imagelist %p, got %p\n", himl3, (HIMAGELIST)ret);
5883c2c66affSColin Finck DestroyWindow(hwnd);
5884c2c66affSColin Finck
5885c2c66affSColin Finck hwnd = create_listview_control(WS_VISIBLE | LVS_ICON);
5886c2c66affSColin Finck
5887c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5888c2c66affSColin Finck
5889c2c66affSColin Finck ret = SendMessageW(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl1);
5890c2c66affSColin Finck ok(ret == 0, "Expected no imagelist, got %p\n", (HIMAGELIST)ret);
5891c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_set_imagelist,
5892c2c66affSColin Finck "set normal image list", FALSE);
5893c2c66affSColin Finck
5894c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5895c2c66affSColin Finck
5896c2c66affSColin Finck ret = SendMessageW(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl2);
5897c2c66affSColin Finck ok(ret == 0, "Expected no imagelist, got %p\n", (HIMAGELIST)ret);
5898c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_set_imagelist,
5899c2c66affSColin Finck "set state image list", FALSE);
5900c2c66affSColin Finck
5901c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5902c2c66affSColin Finck
5903c2c66affSColin Finck ret = SendMessageW(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl3);
5904c2c66affSColin Finck ok(ret == 0, "Expected no imagelist, got %p\n", (HIMAGELIST)ret);
5905c2c66affSColin Finck ok_sequence(sequences, LISTVIEW_SEQ_INDEX, listview_set_imagelist,
5906c2c66affSColin Finck "set small image list", FALSE);
5907c2c66affSColin Finck
5908c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
5909c2c66affSColin Finck ok(header == NULL, "Expected no header, got %p\n", header);
5910c2c66affSColin Finck
5911c2c66affSColin Finck SetWindowLongPtrA(hwnd, GWL_STYLE, GetWindowLongPtrA(hwnd, GWL_STYLE) | LVS_REPORT);
5912c2c66affSColin Finck
5913c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
5914c2c66affSColin Finck ok(header != NULL, "Expected header, got NULL\n");
5915c2c66affSColin Finck
5916c2c66affSColin Finck ret = SendMessageA(header, HDM_GETIMAGELIST, 0, 0);
5917c2c66affSColin Finck ok((HIMAGELIST)ret == himl3, "Expected imagelist %p, got %p\n", himl3, (HIMAGELIST)ret);
5918c2c66affSColin Finck
5919c2c66affSColin Finck DestroyWindow(hwnd);
5920c2c66affSColin Finck }
5921c2c66affSColin Finck
test_deleteitem(void)5922c2c66affSColin Finck static void test_deleteitem(void)
5923c2c66affSColin Finck {
5924c2c66affSColin Finck LVITEMA item;
5925c2c66affSColin Finck UINT state;
5926c2c66affSColin Finck HWND hwnd;
5927c2c66affSColin Finck BOOL ret;
5928c2c66affSColin Finck
5929c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
5930c2c66affSColin Finck
5931c2c66affSColin Finck insert_item(hwnd, 0);
5932c2c66affSColin Finck insert_item(hwnd, 0);
5933c2c66affSColin Finck insert_item(hwnd, 0);
5934c2c66affSColin Finck insert_item(hwnd, 0);
5935c2c66affSColin Finck insert_item(hwnd, 0);
5936c2c66affSColin Finck
5937c2c66affSColin Finck g_focus_test_LVN_DELETEITEM = TRUE;
5938c2c66affSColin Finck
5939c2c66affSColin Finck /* delete focused item (not the last index) */
5940c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
5941c2c66affSColin Finck item.state = LVIS_FOCUSED;
5942c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMSTATE, 2, (LPARAM)&item);
5943c2c66affSColin Finck ok(ret == TRUE, "got %d\n", ret);
5944c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_DELETEITEM, 2, 0);
5945c2c66affSColin Finck ok(ret == TRUE, "got %d\n", ret);
5946c2c66affSColin Finck /* next item gets focus */
5947c2c66affSColin Finck state = SendMessageA(hwnd, LVM_GETITEMSTATE, 2, LVIS_FOCUSED);
5948c2c66affSColin Finck ok(state == LVIS_FOCUSED, "got %x\n", state);
5949c2c66affSColin Finck
5950c2c66affSColin Finck /* focus last item and delete it */
5951c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
5952c2c66affSColin Finck item.state = LVIS_FOCUSED;
5953c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMSTATE, 3, (LPARAM)&item);
5954c2c66affSColin Finck ok(ret == TRUE, "got %d\n", ret);
5955c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_DELETEITEM, 3, 0);
5956c2c66affSColin Finck ok(ret == TRUE, "got %d\n", ret);
5957c2c66affSColin Finck /* new last item gets focus */
5958c2c66affSColin Finck state = SendMessageA(hwnd, LVM_GETITEMSTATE, 2, LVIS_FOCUSED);
5959c2c66affSColin Finck ok(state == LVIS_FOCUSED, "got %x\n", state);
5960c2c66affSColin Finck
5961c2c66affSColin Finck /* focus first item and delete it */
5962c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
5963c2c66affSColin Finck item.state = LVIS_FOCUSED;
5964c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
5965c2c66affSColin Finck ok(ret == TRUE, "got %d\n", ret);
5966c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_DELETEITEM, 0, 0);
5967c2c66affSColin Finck ok(ret == TRUE, "got %d\n", ret);
5968c2c66affSColin Finck /* new first item gets focus */
5969c2c66affSColin Finck state = SendMessageA(hwnd, LVM_GETITEMSTATE, 0, LVIS_FOCUSED);
5970c2c66affSColin Finck ok(state == LVIS_FOCUSED, "got %x\n", state);
5971c2c66affSColin Finck
5972c2c66affSColin Finck g_focus_test_LVN_DELETEITEM = FALSE;
5973c2c66affSColin Finck
5974c2c66affSColin Finck DestroyWindow(hwnd);
5975c2c66affSColin Finck }
5976c2c66affSColin Finck
test_insertitem(void)5977c2c66affSColin Finck static void test_insertitem(void)
5978c2c66affSColin Finck {
5979c2c66affSColin Finck LVITEMA item;
5980c2c66affSColin Finck UINT state;
5981c2c66affSColin Finck HWND hwnd;
5982c2c66affSColin Finck INT ret;
5983c2c66affSColin Finck
5984c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
5985c2c66affSColin Finck
5986c2c66affSColin Finck /* insert item 0 focused */
5987c2c66affSColin Finck item.mask = LVIF_STATE;
5988c2c66affSColin Finck item.state = LVIS_FOCUSED;
5989c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
5990c2c66affSColin Finck item.iItem = 0;
5991c2c66affSColin Finck item.iSubItem = 0;
5992c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
5993c2c66affSColin Finck ok(ret == 0, "got %d\n", ret);
5994c2c66affSColin Finck
5995c2c66affSColin Finck state = SendMessageA(hwnd, LVM_GETITEMSTATE, 0, LVIS_FOCUSED);
5996c2c66affSColin Finck ok(state == LVIS_FOCUSED, "got %x\n", state);
5997c2c66affSColin Finck
5998c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
5999c2c66affSColin Finck
6000c2c66affSColin Finck /* insert item 1, focus shift */
6001c2c66affSColin Finck item.mask = LVIF_STATE;
6002c2c66affSColin Finck item.state = LVIS_FOCUSED;
6003c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
6004c2c66affSColin Finck item.iItem = 1;
6005c2c66affSColin Finck item.iSubItem = 0;
6006c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
6007c2c66affSColin Finck ok(ret == 1, "got %d\n", ret);
6008c2c66affSColin Finck
6009c2c66affSColin Finck ok_sequence(sequences, PARENT_SEQ_INDEX, parent_insert_focused_seq, "insert focused", TRUE);
6010c2c66affSColin Finck
6011c2c66affSColin Finck state = SendMessageA(hwnd, LVM_GETITEMSTATE, 1, LVIS_FOCUSED);
6012c2c66affSColin Finck ok(state == LVIS_FOCUSED, "got %x\n", state);
6013c2c66affSColin Finck
6014c2c66affSColin Finck /* insert item 2, no focus shift */
6015c2c66affSColin Finck item.mask = LVIF_STATE;
6016c2c66affSColin Finck item.state = 0;
6017c2c66affSColin Finck item.stateMask = LVIS_FOCUSED;
6018c2c66affSColin Finck item.iItem = 2;
6019c2c66affSColin Finck item.iSubItem = 0;
6020c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
6021c2c66affSColin Finck ok(ret == 2, "got %d\n", ret);
6022c2c66affSColin Finck
6023c2c66affSColin Finck state = SendMessageA(hwnd, LVM_GETITEMSTATE, 1, LVIS_FOCUSED);
6024c2c66affSColin Finck ok(state == LVIS_FOCUSED, "got %x\n", state);
6025c2c66affSColin Finck
6026c2c66affSColin Finck DestroyWindow(hwnd);
6027c2c66affSColin Finck }
6028c2c66affSColin Finck
test_header_proc(void)6029c2c66affSColin Finck static void test_header_proc(void)
6030c2c66affSColin Finck {
6031c2c66affSColin Finck HWND hwnd, header, hdr;
6032c2c66affSColin Finck WNDPROC proc1, proc2;
6033c2c66affSColin Finck
6034c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
6035c2c66affSColin Finck
6036c2c66affSColin Finck header = (HWND)SendMessageA(hwnd, LVM_GETHEADER, 0, 0);
6037c2c66affSColin Finck ok(header != NULL, "got %p\n", header);
6038c2c66affSColin Finck
6039c2c66affSColin Finck hdr = CreateWindowExA(0, WC_HEADERA, NULL,
6040c2c66affSColin Finck WS_BORDER|WS_VISIBLE|HDS_BUTTONS|HDS_HORZ,
6041c2c66affSColin Finck 0, 0, 0, 0,
6042c2c66affSColin Finck NULL, NULL, NULL, NULL);
6043c2c66affSColin Finck ok(hdr != NULL, "got %p\n", hdr);
6044c2c66affSColin Finck
6045c2c66affSColin Finck proc1 = (WNDPROC)GetWindowLongPtrW(header, GWLP_WNDPROC);
6046c2c66affSColin Finck proc2 = (WNDPROC)GetWindowLongPtrW(hdr, GWLP_WNDPROC);
6047c2c66affSColin Finck ok(proc1 == proc2, "got %p, expected %p\n", proc1, proc2);
6048c2c66affSColin Finck
6049c2c66affSColin Finck DestroyWindow(hdr);
6050c2c66affSColin Finck DestroyWindow(hwnd);
6051c2c66affSColin Finck }
6052c2c66affSColin Finck
flush_events(void)6053c2c66affSColin Finck static void flush_events(void)
6054c2c66affSColin Finck {
6055c2c66affSColin Finck MSG msg;
6056c2c66affSColin Finck int diff = 200;
6057c2c66affSColin Finck int min_timeout = 100;
6058c2c66affSColin Finck DWORD time = GetTickCount() + diff;
6059c2c66affSColin Finck
6060c2c66affSColin Finck while (diff > 0)
6061c2c66affSColin Finck {
6062c2c66affSColin Finck if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
6063c2c66affSColin Finck while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
6064c2c66affSColin Finck diff = time - GetTickCount();
6065c2c66affSColin Finck }
6066c2c66affSColin Finck }
6067c2c66affSColin Finck
test_oneclickactivate(void)6068c2c66affSColin Finck static void test_oneclickactivate(void)
6069c2c66affSColin Finck {
6070c2c66affSColin Finck TRACKMOUSEEVENT track;
6071c2c66affSColin Finck char item1[] = "item1";
6072c2c66affSColin Finck LVITEMA item;
6073c2c66affSColin Finck HWND hwnd, fg;
6074c2c66affSColin Finck RECT rect;
6075c2c66affSColin Finck INT r;
6076c2c66affSColin Finck POINT orig_pos;
6077c2c66affSColin Finck
6078f37104daSAmine Khaldi hwnd = CreateWindowExA(0, WC_LISTVIEWA, "foo", WS_VISIBLE|WS_CHILD|LVS_LIST,
6079c2c66affSColin Finck 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
6080c2c66affSColin Finck ok(hwnd != NULL, "failed to create listview window\n");
6081c2c66affSColin Finck r = SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_ONECLICKACTIVATE);
6082c2c66affSColin Finck ok(r == 0, "should return zero\n");
6083c2c66affSColin Finck
6084c2c66affSColin Finck SetForegroundWindow(hwndparent);
6085c2c66affSColin Finck flush_events();
6086c2c66affSColin Finck fg = GetForegroundWindow();
6087c2c66affSColin Finck if (fg != hwndparent)
6088c2c66affSColin Finck {
6089c2c66affSColin Finck skip("Window is not in the foreground. Skipping oneclickactivate tests.\n");
6090c2c66affSColin Finck DestroyWindow(hwnd);
6091c2c66affSColin Finck return;
6092c2c66affSColin Finck }
6093c2c66affSColin Finck
6094c2c66affSColin Finck item.mask = LVIF_TEXT;
6095c2c66affSColin Finck item.iItem = 0;
6096c2c66affSColin Finck item.iSubItem = 0;
6097c2c66affSColin Finck item.iImage = 0;
6098c2c66affSColin Finck item.pszText = item1;
6099c2c66affSColin Finck r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM) &item);
6100c2c66affSColin Finck ok(r == 0, "should not fail\n");
6101c2c66affSColin Finck
6102c2c66affSColin Finck GetWindowRect(hwnd, &rect);
6103c2c66affSColin Finck GetCursorPos(&orig_pos);
6104c2c66affSColin Finck SetCursorPos(rect.left+5, rect.top+5);
6105c2c66affSColin Finck flush_events();
6106c2c66affSColin Finck r = SendMessageA(hwnd, WM_MOUSEMOVE, MAKELONG(1, 1), 0);
6107c2c66affSColin Finck expect(0, r);
6108c2c66affSColin Finck
6109c2c66affSColin Finck track.cbSize = sizeof(track);
6110c2c66affSColin Finck track.dwFlags = TME_QUERY;
6111f37104daSAmine Khaldi p_TrackMouseEvent(&track);
6112c2c66affSColin Finck ok(track.hwndTrack == hwnd, "hwndTrack != hwnd\n");
6113c2c66affSColin Finck ok(track.dwFlags == TME_LEAVE, "dwFlags = %x\n", track.dwFlags);
6114c2c66affSColin Finck
6115c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
6116c2c66affSColin Finck expect(0, r);
6117c2c66affSColin Finck r = SendMessageA(hwnd, WM_MOUSEHOVER, MAKELONG(1, 1), 0);
6118c2c66affSColin Finck expect(0, r);
6119c2c66affSColin Finck r = SendMessageA(hwnd, LVM_GETSELECTEDCOUNT, 0, 0);
6120c2c66affSColin Finck expect(1, r);
6121c2c66affSColin Finck
6122c2c66affSColin Finck DestroyWindow(hwnd);
6123c2c66affSColin Finck SetCursorPos(orig_pos.x, orig_pos.y);
6124c2c66affSColin Finck }
6125c2c66affSColin Finck
test_callback_mask(void)6126c2c66affSColin Finck static void test_callback_mask(void)
6127c2c66affSColin Finck {
61280d320bc2SAmine Khaldi LVITEMA item;
6129c2c66affSColin Finck DWORD mask;
6130c2c66affSColin Finck HWND hwnd;
6131c2c66affSColin Finck BOOL ret;
6132c2c66affSColin Finck
6133c2c66affSColin Finck hwnd = create_listview_control(LVS_REPORT);
6134c2c66affSColin Finck
6135c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETCALLBACKMASK, ~0u, 0);
6136c2c66affSColin Finck ok(ret, "got %d\n", ret);
6137c2c66affSColin Finck
6138c2c66affSColin Finck ret = SendMessageA(hwnd, LVM_SETCALLBACKMASK, ~0u, 1);
6139c2c66affSColin Finck ok(ret, "got %d\n", ret);
6140c2c66affSColin Finck
6141c2c66affSColin Finck mask = SendMessageA(hwnd, LVM_GETCALLBACKMASK, 0, 0);
6142c2c66affSColin Finck ok(mask == ~0u, "got 0x%08x\n", mask);
6143c2c66affSColin Finck
6144*0707475fSJustin Miller /* Ask for state, invalid subitem. */
6145*0707475fSJustin Miller insert_item(hwnd, 0);
6146*0707475fSJustin Miller
6147*0707475fSJustin Miller ret = SendMessageA(hwnd, LVM_SETCALLBACKMASK, LVIS_FOCUSED, 0);
6148*0707475fSJustin Miller ok(ret, "Failed to set callback mask.\n");
6149*0707475fSJustin Miller
6150*0707475fSJustin Miller flush_sequences(sequences, NUM_MSG_SEQUENCES);
6151*0707475fSJustin Miller
6152*0707475fSJustin Miller memset(&item, 0, sizeof(item));
6153*0707475fSJustin Miller item.iSubItem = 1;
6154*0707475fSJustin Miller item.mask = LVIF_STATE;
6155*0707475fSJustin Miller item.stateMask = LVIS_SELECTED;
6156*0707475fSJustin Miller ret = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
6157*0707475fSJustin Miller ok(ret, "Failed to get item data.\n");
6158*0707475fSJustin Miller
6159*0707475fSJustin Miller memset(&item, 0, sizeof(item));
6160*0707475fSJustin Miller item.mask = LVIF_STATE;
6161*0707475fSJustin Miller item.stateMask = LVIS_SELECTED;
6162*0707475fSJustin Miller ret = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
6163*0707475fSJustin Miller ok(ret, "Failed to get item data.\n");
6164*0707475fSJustin Miller
6165*0707475fSJustin Miller ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent seq, callback mask/invalid subitem 1", TRUE);
6166*0707475fSJustin Miller
6167*0707475fSJustin Miller flush_sequences(sequences, NUM_MSG_SEQUENCES);
6168*0707475fSJustin Miller
6169*0707475fSJustin Miller memset(&item, 0, sizeof(item));
6170*0707475fSJustin Miller memset(&g_itema, 0, sizeof(g_itema));
6171*0707475fSJustin Miller item.iSubItem = 1;
6172*0707475fSJustin Miller item.mask = LVIF_STATE;
6173*0707475fSJustin Miller item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
6174*0707475fSJustin Miller ret = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
6175*0707475fSJustin Miller ok(ret, "Failed to get item data.\n");
6176*0707475fSJustin Miller ok(g_itema.iSubItem == 1, "Unexpected LVN_DISPINFO subitem %d.\n", g_itema.iSubItem);
6177*0707475fSJustin Miller ok(g_itema.stateMask == LVIS_FOCUSED, "Unexpected state mask %#x.\n", g_itema.stateMask);
6178*0707475fSJustin Miller
6179*0707475fSJustin Miller ok_sequence(sequences, PARENT_SEQ_INDEX, single_getdispinfo_parent_seq,
6180*0707475fSJustin Miller "parent seq, callback mask/invalid subitem 2", FALSE);
6181*0707475fSJustin Miller
6182c2c66affSColin Finck DestroyWindow(hwnd);
61830d320bc2SAmine Khaldi
61840d320bc2SAmine Khaldi /* LVS_OWNERDATA, mask LVIS_FOCUSED */
61850d320bc2SAmine Khaldi hwnd = create_listview_control(LVS_REPORT | LVS_OWNERDATA);
61860d320bc2SAmine Khaldi
61870d320bc2SAmine Khaldi mask = SendMessageA(hwnd, LVM_GETCALLBACKMASK, 0, 0);
61880d320bc2SAmine Khaldi ok(mask == 0, "Unexpected callback mask %#x.\n", mask);
61890d320bc2SAmine Khaldi
61900d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETCALLBACKMASK, LVIS_FOCUSED, 0);
61910d320bc2SAmine Khaldi ok(ret, "Failed to set callback mask, %d\n", ret);
61920d320bc2SAmine Khaldi
61930d320bc2SAmine Khaldi mask = SendMessageA(hwnd, LVM_GETCALLBACKMASK, 0, 0);
61940d320bc2SAmine Khaldi ok(mask == LVIS_FOCUSED, "Unexpected callback mask %#x.\n", mask);
61950d320bc2SAmine Khaldi
61960d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
61970d320bc2SAmine Khaldi ok(ret, "Failed to set item count.\n");
61980d320bc2SAmine Khaldi
61990d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
62000d320bc2SAmine Khaldi ok(ret == -1, "Unexpected selection mark, %d\n", ret);
62010d320bc2SAmine Khaldi
62020d320bc2SAmine Khaldi item.stateMask = LVIS_FOCUSED;
62030d320bc2SAmine Khaldi item.state = LVIS_FOCUSED;
62040d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
62050d320bc2SAmine Khaldi ok(ret, "Failed to set item state.\n");
62060d320bc2SAmine Khaldi
62070d320bc2SAmine Khaldi flush_sequences(sequences, NUM_MSG_SEQUENCES);
62080d320bc2SAmine Khaldi
62090d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
62100d320bc2SAmine Khaldi todo_wine
62110d320bc2SAmine Khaldi ok(ret == 0, "Unexpected focused item, ret %d\n", ret);
62120d320bc2SAmine Khaldi
62130d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
62140d320bc2SAmine Khaldi todo_wine
62150d320bc2SAmine Khaldi ok(ret == 0, "Unexpected selection mark, %d\n", ret);
62160d320bc2SAmine Khaldi
62170d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 0, 0);
62180d320bc2SAmine Khaldi ok(ret, "Failed to set item count.\n");
62190d320bc2SAmine Khaldi
62200d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
62210d320bc2SAmine Khaldi ok(ret == -1, "Unexpected focused item, ret %d\n", ret);
62220d320bc2SAmine Khaldi
62230d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
62240d320bc2SAmine Khaldi ok(ret == -1, "Unexpected selection mark, %d\n", ret);
62250d320bc2SAmine Khaldi
62260d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
62270d320bc2SAmine Khaldi ok(ret, "Failed to set item count.\n");
62280d320bc2SAmine Khaldi
62290d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
62300d320bc2SAmine Khaldi ok(ret == -1, "Unexpected focused item, ret %d\n", ret);
62310d320bc2SAmine Khaldi
62320d320bc2SAmine Khaldi ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent seq, owner data/focus 1", FALSE);
62330d320bc2SAmine Khaldi
62340d320bc2SAmine Khaldi /* LVS_OWNDERDATA, empty mask */
62350d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETCALLBACKMASK, 0, 0);
62360d320bc2SAmine Khaldi ok(ret, "Failed to set callback mask, %d\n", ret);
62370d320bc2SAmine Khaldi
62380d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
62390d320bc2SAmine Khaldi ok(ret, "Failed to set item count.\n");
62400d320bc2SAmine Khaldi
62410d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
62420d320bc2SAmine Khaldi ok(ret == -1, "Unexpected selection mark, %d\n", ret);
62430d320bc2SAmine Khaldi
62440d320bc2SAmine Khaldi item.stateMask = LVIS_FOCUSED;
62450d320bc2SAmine Khaldi item.state = LVIS_FOCUSED;
62460d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
62470d320bc2SAmine Khaldi ok(ret, "Failed to set item state.\n");
62480d320bc2SAmine Khaldi
62490d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
62500d320bc2SAmine Khaldi ok(ret == 0, "Unexpected selection mark, %d\n", ret);
62510d320bc2SAmine Khaldi
62520d320bc2SAmine Khaldi flush_sequences(sequences, NUM_MSG_SEQUENCES);
62530d320bc2SAmine Khaldi
62540d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
62550d320bc2SAmine Khaldi ok(ret == 0, "Unexpected focused item, ret %d\n", ret);
62560d320bc2SAmine Khaldi
62570d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 0, 0);
62580d320bc2SAmine Khaldi ok(ret, "Failed to set item count.\n");
62590d320bc2SAmine Khaldi
62600d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
62610d320bc2SAmine Khaldi ok(ret == -1, "Unexpected focused item, ret %d\n", ret);
62620d320bc2SAmine Khaldi
62630d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETSELECTIONMARK, 0, 0);
62640d320bc2SAmine Khaldi todo_wine
62650d320bc2SAmine Khaldi ok(ret == -1, "Unexpected selection mark, %d\n", ret);
62660d320bc2SAmine Khaldi
62670d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
62680d320bc2SAmine Khaldi ok(ret, "Failed to set item count.\n");
62690d320bc2SAmine Khaldi
62700d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
62710d320bc2SAmine Khaldi ok(ret == -1, "Unexpected focused item, ret %d\n", ret);
62720d320bc2SAmine Khaldi
62730d320bc2SAmine Khaldi ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "parent seq, owner data/focus 2", FALSE);
62740d320bc2SAmine Khaldi
62750d320bc2SAmine Khaldi /* 2 items, focus on index 0, reduce to 1 item. */
62760d320bc2SAmine Khaldi flush_sequences(sequences, NUM_MSG_SEQUENCES);
62770d320bc2SAmine Khaldi
62780d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 2, 0);
62790d320bc2SAmine Khaldi ok(ret, "Failed to set item count.\n");
62800d320bc2SAmine Khaldi
62810d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
62820d320bc2SAmine Khaldi ok(ret, "Failed to set item state.\n");
62830d320bc2SAmine Khaldi
62840d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
62850d320bc2SAmine Khaldi ok(ret == 0, "Unexpected focused item, ret %d\n", ret);
62860d320bc2SAmine Khaldi
62870d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_SETITEMCOUNT, 1, 0);
62880d320bc2SAmine Khaldi ok(ret, "Failed to set item count.\n");
62890d320bc2SAmine Khaldi
62900d320bc2SAmine Khaldi ret = SendMessageA(hwnd, LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
62910d320bc2SAmine Khaldi ok(ret == 0, "Unexpected focused item, ret %d\n", ret);
62920d320bc2SAmine Khaldi
62930d320bc2SAmine Khaldi ok_sequence(sequences, PARENT_SEQ_INDEX, parent_focus_change_ownerdata_seq,
62940d320bc2SAmine Khaldi "parent seq, owner data/focus 3", TRUE);
62950d320bc2SAmine Khaldi
62960d320bc2SAmine Khaldi DestroyWindow(hwnd);
62970d320bc2SAmine Khaldi }
62980d320bc2SAmine Khaldi
test_state_image(void)62990d320bc2SAmine Khaldi static void test_state_image(void)
63000d320bc2SAmine Khaldi {
63010d320bc2SAmine Khaldi static const DWORD styles[] =
63020d320bc2SAmine Khaldi {
63030d320bc2SAmine Khaldi LVS_ICON,
63040d320bc2SAmine Khaldi LVS_REPORT,
63050d320bc2SAmine Khaldi LVS_SMALLICON,
63060d320bc2SAmine Khaldi LVS_LIST,
63070d320bc2SAmine Khaldi };
63080d320bc2SAmine Khaldi int i;
63090d320bc2SAmine Khaldi
63105f7243b5SAmine Khaldi for (i = 0; i < ARRAY_SIZE(styles); i++)
63110d320bc2SAmine Khaldi {
63120d320bc2SAmine Khaldi static char text[] = "Item";
63130d320bc2SAmine Khaldi static char subtext[] = "Subitem";
63140d320bc2SAmine Khaldi char buff[16];
63150d320bc2SAmine Khaldi LVITEMA item;
63160d320bc2SAmine Khaldi HWND hwnd;
63170d320bc2SAmine Khaldi int r;
63180d320bc2SAmine Khaldi
63190d320bc2SAmine Khaldi hwnd = create_listview_control(styles[i]);
63200d320bc2SAmine Khaldi
63210d320bc2SAmine Khaldi insert_column(hwnd, 0);
63220d320bc2SAmine Khaldi insert_column(hwnd, 1);
63230d320bc2SAmine Khaldi
6324f37104daSAmine Khaldi item.mask = LVIF_TEXT | LVIF_PARAM;
63250d320bc2SAmine Khaldi item.iItem = 0;
63260d320bc2SAmine Khaldi item.iSubItem = 0;
63270d320bc2SAmine Khaldi item.pszText = text;
6328f37104daSAmine Khaldi item.lParam = 123456;
63290d320bc2SAmine Khaldi r = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
63300d320bc2SAmine Khaldi ok(r == 0, "Failed to insert an item.\n");
63310d320bc2SAmine Khaldi
63320d320bc2SAmine Khaldi item.mask = LVIF_STATE;
6333f37104daSAmine Khaldi item.state = INDEXTOSTATEIMAGEMASK(1) | LVIS_SELECTED | LVIS_FOCUSED;
6334f37104daSAmine Khaldi item.stateMask = LVIS_STATEIMAGEMASK | LVIS_SELECTED | LVIS_FOCUSED;
63350d320bc2SAmine Khaldi item.iItem = 0;
63360d320bc2SAmine Khaldi item.iSubItem = 0;
63370d320bc2SAmine Khaldi r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
63380d320bc2SAmine Khaldi ok(r, "Failed to set item state.\n");
63390d320bc2SAmine Khaldi
63400d320bc2SAmine Khaldi item.mask = LVIF_TEXT;
63410d320bc2SAmine Khaldi item.iItem = 0;
63420d320bc2SAmine Khaldi item.iSubItem = 1;
63430d320bc2SAmine Khaldi item.pszText = subtext;
63440d320bc2SAmine Khaldi r = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
63450d320bc2SAmine Khaldi ok(r, "Failed to set subitem text.\n");
63460d320bc2SAmine Khaldi
6347f37104daSAmine Khaldi item.mask = LVIF_STATE | LVIF_PARAM;
6348f37104daSAmine Khaldi item.stateMask = ~0u;
63490d320bc2SAmine Khaldi item.state = 0;
63500d320bc2SAmine Khaldi item.iItem = 0;
63510d320bc2SAmine Khaldi item.iSubItem = 0;
6352f37104daSAmine Khaldi item.lParam = 0;
63530d320bc2SAmine Khaldi r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
63540d320bc2SAmine Khaldi ok(r, "Failed to get item state.\n");
6355f37104daSAmine Khaldi ok(item.state == (INDEXTOSTATEIMAGEMASK(1) | LVIS_SELECTED | LVIS_FOCUSED),
6356f37104daSAmine Khaldi "Unexpected item state %#x.\n", item.state);
6357f37104daSAmine Khaldi ok(item.lParam == 123456, "Unexpected lParam %ld.\n", item.lParam);
63580d320bc2SAmine Khaldi
6359f37104daSAmine Khaldi item.mask = 0;
6360f37104daSAmine Khaldi item.stateMask = ~0u;
63610d320bc2SAmine Khaldi item.state = INDEXTOSTATEIMAGEMASK(2);
63620d320bc2SAmine Khaldi item.iItem = 0;
63630d320bc2SAmine Khaldi item.iSubItem = 1;
63640d320bc2SAmine Khaldi r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
63650d320bc2SAmine Khaldi ok(r, "Failed to get subitem state.\n");
6366f37104daSAmine Khaldi ok(item.state == INDEXTOSTATEIMAGEMASK(2), "Unexpected state %#x.\n", item.state);
6367f37104daSAmine Khaldi
6368f37104daSAmine Khaldi item.mask = LVIF_STATE | LVIF_PARAM;
6369f37104daSAmine Khaldi item.stateMask = ~0u;
6370f37104daSAmine Khaldi item.state = INDEXTOSTATEIMAGEMASK(2);
6371f37104daSAmine Khaldi item.iItem = 0;
6372f37104daSAmine Khaldi item.iSubItem = 1;
6373f37104daSAmine Khaldi item.lParam = 0;
6374f37104daSAmine Khaldi r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
6375f37104daSAmine Khaldi ok(r, "Failed to get subitem state.\n");
6376f37104daSAmine Khaldi ok(item.state == 0, "Unexpected state %#x.\n", item.state);
6377f37104daSAmine Khaldi ok(item.lParam == 123456, "Unexpected lParam %ld.\n", item.lParam);
6378f37104daSAmine Khaldi
6379f37104daSAmine Khaldi item.mask = LVIF_STATE;
6380f37104daSAmine Khaldi item.stateMask = LVIS_FOCUSED;
6381f37104daSAmine Khaldi item.state = 0;
6382f37104daSAmine Khaldi item.iItem = 0;
6383f37104daSAmine Khaldi item.iSubItem = 1;
6384f37104daSAmine Khaldi r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
6385f37104daSAmine Khaldi ok(r, "Failed to get subitem state.\n");
63860d320bc2SAmine Khaldi ok(item.state == 0, "Unexpected state %#x.\n", item.state);
63870d320bc2SAmine Khaldi
63880d320bc2SAmine Khaldi item.mask = LVIF_STATE;
6389f37104daSAmine Khaldi item.stateMask = ~0u;
63900d320bc2SAmine Khaldi item.state = INDEXTOSTATEIMAGEMASK(2);
63910d320bc2SAmine Khaldi item.iItem = 0;
63920d320bc2SAmine Khaldi item.iSubItem = 2;
63930d320bc2SAmine Khaldi r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
63940d320bc2SAmine Khaldi ok(r, "Failed to get subitem state.\n");
63950d320bc2SAmine Khaldi ok(item.state == 0, "Unexpected state %#x.\n", item.state);
63960d320bc2SAmine Khaldi
63970d320bc2SAmine Khaldi item.mask = LVIF_TEXT;
63980d320bc2SAmine Khaldi item.iItem = 0;
63990d320bc2SAmine Khaldi item.iSubItem = 1;
64000d320bc2SAmine Khaldi item.pszText = buff;
64010d320bc2SAmine Khaldi item.cchTextMax = sizeof(buff);
64020d320bc2SAmine Khaldi r = SendMessageA(hwnd, LVM_GETITEMA, 0, (LPARAM)&item);
64030d320bc2SAmine Khaldi ok(r, "Failed to get subitem text %d.\n", r);
64040d320bc2SAmine Khaldi ok(!strcmp(buff, subtext), "Unexpected subitem text %s.\n", buff);
64050d320bc2SAmine Khaldi
64060d320bc2SAmine Khaldi DestroyWindow(hwnd);
64070d320bc2SAmine Khaldi }
6408c2c66affSColin Finck }
6409c2c66affSColin Finck
test_LVSCW_AUTOSIZE(void)6410f37104daSAmine Khaldi static void test_LVSCW_AUTOSIZE(void)
6411f37104daSAmine Khaldi {
6412f37104daSAmine Khaldi int width, width2;
6413f37104daSAmine Khaldi HWND hwnd;
6414f37104daSAmine Khaldi BOOL ret;
6415f37104daSAmine Khaldi
6416f37104daSAmine Khaldi hwnd = create_listview_control(LVS_REPORT);
6417f37104daSAmine Khaldi ok(hwnd != NULL, "failed to create a listview window\n");
6418f37104daSAmine Khaldi
6419f37104daSAmine Khaldi insert_column(hwnd, 0);
6420f37104daSAmine Khaldi insert_column(hwnd, 1);
6421f37104daSAmine Khaldi insert_item(hwnd, 0);
6422f37104daSAmine Khaldi
6423f37104daSAmine Khaldi ret = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 0, LVSCW_AUTOSIZE);
6424f37104daSAmine Khaldi ok(ret, "Failed to set column width.\n");
6425f37104daSAmine Khaldi
6426f37104daSAmine Khaldi width = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
6427f37104daSAmine Khaldi ok(width > 0, "Unexpected column width %d.\n", width);
6428f37104daSAmine Khaldi
6429f37104daSAmine Khaldi /* Turn on checkboxes. */
6430f37104daSAmine Khaldi ret = SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
6431f37104daSAmine Khaldi ok(ret == 0, "Unexpected previous extended style.\n");
6432f37104daSAmine Khaldi
6433f37104daSAmine Khaldi ret = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 0, LVSCW_AUTOSIZE);
6434f37104daSAmine Khaldi ok(ret, "Failed to set column width.\n");
6435f37104daSAmine Khaldi
6436f37104daSAmine Khaldi width2 = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
6437f37104daSAmine Khaldi ok(width2 > 0, "Unexpected column width %d.\n", width2);
6438f37104daSAmine Khaldi ok(width2 > width, "Expected increased column width.\n");
6439f37104daSAmine Khaldi
6440f37104daSAmine Khaldi /* Turn off checkboxes. */
6441f37104daSAmine Khaldi ret = SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_CHECKBOXES, 0);
6442f37104daSAmine Khaldi ok(ret == LVS_EX_CHECKBOXES, "Unexpected previous extended style.\n");
6443f37104daSAmine Khaldi
6444f37104daSAmine Khaldi ret = SendMessageA(hwnd, LVM_SETCOLUMNWIDTH, 0, LVSCW_AUTOSIZE);
6445f37104daSAmine Khaldi ok(ret, "Failed to set column width.\n");
6446f37104daSAmine Khaldi
6447f37104daSAmine Khaldi width = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
6448f37104daSAmine Khaldi ok(width > 0, "Unexpected column width %d.\n", width2);
6449f37104daSAmine Khaldi ok(width2 > width, "Expected reduced column width.\n");
6450f37104daSAmine Khaldi
6451f37104daSAmine Khaldi DestroyWindow(hwnd);
6452f37104daSAmine Khaldi }
6453f37104daSAmine Khaldi
test_LVN_ENDLABELEDIT(void)64545f7243b5SAmine Khaldi static void test_LVN_ENDLABELEDIT(void)
64555f7243b5SAmine Khaldi {
64565f7243b5SAmine Khaldi WCHAR text[] = {'l','a','l','a',0};
64575f7243b5SAmine Khaldi HWND hwnd, hwndedit;
64585f7243b5SAmine Khaldi LVITEMW item = {0};
64595f7243b5SAmine Khaldi DWORD ret;
64605f7243b5SAmine Khaldi
64615f7243b5SAmine Khaldi hwnd = create_listview_control(LVS_REPORT | LVS_EDITLABELS);
64625f7243b5SAmine Khaldi
64635f7243b5SAmine Khaldi insert_column(hwnd, 0);
64645f7243b5SAmine Khaldi
64655f7243b5SAmine Khaldi item.mask = LVIF_TEXT;
64665f7243b5SAmine Khaldi item.pszText = text;
64675f7243b5SAmine Khaldi SendMessageW(hwnd, LVM_INSERTITEMW, 0, (LPARAM)&item);
64685f7243b5SAmine Khaldi
64695f7243b5SAmine Khaldi /* Test normal editing */
64705f7243b5SAmine Khaldi SetFocus(hwnd);
64715f7243b5SAmine Khaldi hwndedit = (HWND)SendMessageW(hwnd, LVM_EDITLABELW, 0, 0);
64725f7243b5SAmine Khaldi ok(hwndedit != NULL, "Failed to get edit control.\n");
64735f7243b5SAmine Khaldi
64745f7243b5SAmine Khaldi ret = SendMessageA(hwndedit, WM_SETTEXT, 0, (LPARAM)"test");
64755f7243b5SAmine Khaldi ok(ret, "Failed to set edit text.\n");
64765f7243b5SAmine Khaldi
64775f7243b5SAmine Khaldi flush_sequences(sequences, NUM_MSG_SEQUENCES);
64785f7243b5SAmine Khaldi
64795f7243b5SAmine Khaldi ret = SendMessageA(hwndedit, WM_KEYDOWN, VK_RETURN, 0);
64805f7243b5SAmine Khaldi ok_sequence(sequences, PARENT_SEQ_INDEX, listview_end_label_edit, "Label edit", FALSE);
64815f7243b5SAmine Khaldi
64825f7243b5SAmine Khaldi /* Test editing with kill focus */
64835f7243b5SAmine Khaldi SetFocus(hwnd);
64845f7243b5SAmine Khaldi hwndedit = (HWND)SendMessageW(hwnd, LVM_EDITLABELW, 0, 0);
64855f7243b5SAmine Khaldi ok(hwndedit != NULL, "Failed to get edit control.\n");
64865f7243b5SAmine Khaldi
64875f7243b5SAmine Khaldi ret = SendMessageA(hwndedit, WM_SETTEXT, 0, (LPARAM)"test2");
64885f7243b5SAmine Khaldi ok(ret, "Failed to set edit text.\n");
64895f7243b5SAmine Khaldi
64905f7243b5SAmine Khaldi flush_sequences(sequences, NUM_MSG_SEQUENCES);
64915f7243b5SAmine Khaldi
64925f7243b5SAmine Khaldi g_WM_KILLFOCUS_on_LVN_ENDLABELEDIT = TRUE;
64935f7243b5SAmine Khaldi ret = SendMessageA(hwndedit, WM_KEYDOWN, VK_RETURN, 0);
64945f7243b5SAmine Khaldi g_WM_KILLFOCUS_on_LVN_ENDLABELEDIT = FALSE;
64955f7243b5SAmine Khaldi
64965f7243b5SAmine Khaldi ok_sequence(sequences, PARENT_SEQ_INDEX, listview_end_label_edit_kill_focus,
64975f7243b5SAmine Khaldi "Label edit, kill focus", FALSE);
64985f7243b5SAmine Khaldi ok(GetFocus() == hwnd, "Unexpected focused window.\n");
64995f7243b5SAmine Khaldi
65005f7243b5SAmine Khaldi flush_sequences(sequences, NUM_MSG_SEQUENCES);
65015f7243b5SAmine Khaldi
65025f7243b5SAmine Khaldi DestroyWindow(hwnd);
65035f7243b5SAmine Khaldi }
65045f7243b5SAmine Khaldi
create_item_height_wndproc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)65055f7243b5SAmine Khaldi static LRESULT CALLBACK create_item_height_wndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
65065f7243b5SAmine Khaldi {
65075f7243b5SAmine Khaldi if (msg == WM_CREATE)
65085f7243b5SAmine Khaldi return 0;
65095f7243b5SAmine Khaldi
65105f7243b5SAmine Khaldi return CallWindowProcA(listviewWndProc, hwnd, msg, wParam, lParam);
65115f7243b5SAmine Khaldi }
65125f7243b5SAmine Khaldi
test_LVM_GETCOUNTPERPAGE(void)65135f7243b5SAmine Khaldi static void test_LVM_GETCOUNTPERPAGE(void)
65145f7243b5SAmine Khaldi {
65155f7243b5SAmine Khaldi static const DWORD styles[] = { LVS_ICON, LVS_LIST, LVS_REPORT, LVS_SMALLICON };
65165f7243b5SAmine Khaldi unsigned int i, j;
65175f7243b5SAmine Khaldi WNDCLASSEXA cls;
65185f7243b5SAmine Khaldi ATOM class;
65195f7243b5SAmine Khaldi HWND hwnd;
65205f7243b5SAmine Khaldi BOOL ret;
65215f7243b5SAmine Khaldi
65225f7243b5SAmine Khaldi cls.cbSize = sizeof(WNDCLASSEXA);
65235f7243b5SAmine Khaldi ret = GetClassInfoExA(GetModuleHandleA(NULL), WC_LISTVIEWA, &cls);
65245f7243b5SAmine Khaldi ok(ret, "Failed to get class info.\n");
65255f7243b5SAmine Khaldi listviewWndProc = cls.lpfnWndProc;
65265f7243b5SAmine Khaldi cls.lpfnWndProc = create_item_height_wndproc;
65275f7243b5SAmine Khaldi cls.lpszClassName = "CountPerPageClass";
65285f7243b5SAmine Khaldi class = RegisterClassExA(&cls);
65295f7243b5SAmine Khaldi ok(class, "Failed to register class.\n");
65305f7243b5SAmine Khaldi
65315f7243b5SAmine Khaldi for (i = 0; i < ARRAY_SIZE(styles); i++)
65325f7243b5SAmine Khaldi {
65335f7243b5SAmine Khaldi static char text[] = "item text";
65345f7243b5SAmine Khaldi LVITEMA item = { 0 };
65355f7243b5SAmine Khaldi UINT count, count2;
65365f7243b5SAmine Khaldi
65375f7243b5SAmine Khaldi hwnd = create_listview_control(styles[i]);
65385f7243b5SAmine Khaldi ok(hwnd != NULL, "Failed to create listview window.\n");
65395f7243b5SAmine Khaldi
65405f7243b5SAmine Khaldi count = SendMessageA(hwnd, LVM_GETCOUNTPERPAGE, 0, 0);
65415f7243b5SAmine Khaldi if (styles[i] == LVS_LIST || styles[i] == LVS_REPORT)
65425f7243b5SAmine Khaldi ok(count > 0 || broken(styles[i] == LVS_LIST && count == 0), "%u: unexpected count %u.\n", i, count);
65435f7243b5SAmine Khaldi else
65445f7243b5SAmine Khaldi ok(count == 0, "%u: unexpected count %u.\n", i, count);
65455f7243b5SAmine Khaldi
65465f7243b5SAmine Khaldi for (j = 0; j < 10; j++)
65475f7243b5SAmine Khaldi {
65485f7243b5SAmine Khaldi item.mask = LVIF_TEXT;
65495f7243b5SAmine Khaldi item.pszText = text;
65505f7243b5SAmine Khaldi SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item);
65515f7243b5SAmine Khaldi }
65525f7243b5SAmine Khaldi
65535f7243b5SAmine Khaldi count2 = SendMessageA(hwnd, LVM_GETCOUNTPERPAGE, 0, 0);
65545f7243b5SAmine Khaldi if (styles[i] == LVS_LIST || styles[i] == LVS_REPORT)
65555f7243b5SAmine Khaldi ok(count == count2, "%u: unexpected count %u.\n", i, count2);
65565f7243b5SAmine Khaldi else
65575f7243b5SAmine Khaldi ok(count2 == 10, "%u: unexpected count %u.\n", i, count2);
65585f7243b5SAmine Khaldi
65595f7243b5SAmine Khaldi DestroyWindow(hwnd);
65605f7243b5SAmine Khaldi
65615f7243b5SAmine Khaldi hwnd = CreateWindowA("CountPerPageClass", "Test", WS_VISIBLE | styles[i], 0, 0, 100, 100, NULL, NULL,
65625f7243b5SAmine Khaldi GetModuleHandleA(NULL), 0);
65635f7243b5SAmine Khaldi ok(hwnd != NULL, "Failed to create a window.\n");
65645f7243b5SAmine Khaldi
65655f7243b5SAmine Khaldi count = SendMessageA(hwnd, LVM_GETCOUNTPERPAGE, 0, 0);
65665f7243b5SAmine Khaldi ok(count == 0, "%u: unexpected count %u.\n", i, count);
65675f7243b5SAmine Khaldi
65685f7243b5SAmine Khaldi DestroyWindow(hwnd);
65695f7243b5SAmine Khaldi }
65705f7243b5SAmine Khaldi
65715f7243b5SAmine Khaldi ret = UnregisterClassA("CountPerPageClass", NULL);
65725f7243b5SAmine Khaldi ok(ret, "Failed to unregister test class.\n");
65735f7243b5SAmine Khaldi }
65745f7243b5SAmine Khaldi
test_item_state_change(void)65758addeea4SAmine Khaldi static void test_item_state_change(void)
65768addeea4SAmine Khaldi {
65778addeea4SAmine Khaldi static const DWORD styles[] = { LVS_ICON, LVS_LIST, LVS_REPORT, LVS_SMALLICON };
65788addeea4SAmine Khaldi LVITEMA item;
65798addeea4SAmine Khaldi HWND hwnd;
65808addeea4SAmine Khaldi DWORD res;
65818addeea4SAmine Khaldi int i;
65828addeea4SAmine Khaldi
65838addeea4SAmine Khaldi for (i = 0; i < ARRAY_SIZE(styles); i++)
65848addeea4SAmine Khaldi {
65858addeea4SAmine Khaldi hwnd = create_listview_control(styles[i]);
65868addeea4SAmine Khaldi
65878addeea4SAmine Khaldi insert_item(hwnd, 0);
65888addeea4SAmine Khaldi
65898addeea4SAmine Khaldi /* LVM_SETITEMSTATE with mask */
65908addeea4SAmine Khaldi memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
65918addeea4SAmine Khaldi memset(&item, 0, sizeof(item));
65928addeea4SAmine Khaldi item.mask = LVIF_STATE;
65938addeea4SAmine Khaldi item.stateMask = LVIS_SELECTED;
65948addeea4SAmine Khaldi item.state = LVIS_SELECTED;
65958addeea4SAmine Khaldi res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
65968addeea4SAmine Khaldi ok(res, "Failed to set item state.\n");
65978addeea4SAmine Khaldi
65988addeea4SAmine Khaldi ok(g_nmlistview.iItem == item.iItem, "Unexpected item %d.\n", g_nmlistview.iItem);
65998addeea4SAmine Khaldi ok(g_nmlistview.iSubItem == item.iSubItem, "Unexpected subitem %d.\n", g_nmlistview.iSubItem);
66008addeea4SAmine Khaldi ok(g_nmlistview.lParam == item.lParam, "Unexpected lParam.\n");
66018addeea4SAmine Khaldi ok(g_nmlistview.uNewState == LVIS_SELECTED, "got new state 0x%08x\n", g_nmlistview.uNewState);
66028addeea4SAmine Khaldi ok(g_nmlistview.uOldState == 0, "got old state 0x%08x\n", g_nmlistview.uOldState);
66038addeea4SAmine Khaldi ok(g_nmlistview.uChanged == LVIF_STATE, "got changed 0x%08x\n", g_nmlistview.uChanged);
66048addeea4SAmine Khaldi
66058addeea4SAmine Khaldi /* LVM_SETITEMSTATE 0 mask */
66068addeea4SAmine Khaldi memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
66078addeea4SAmine Khaldi memset(&item, 0, sizeof(item));
66088addeea4SAmine Khaldi item.stateMask = LVIS_SELECTED;
66098addeea4SAmine Khaldi item.state = 0;
66108addeea4SAmine Khaldi res = SendMessageA(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
66118addeea4SAmine Khaldi ok(res, "Failed to set item state.\n");
66128addeea4SAmine Khaldi
66138addeea4SAmine Khaldi ok(g_nmlistview.iItem == item.iItem, "Unexpected item %d.\n", g_nmlistview.iItem);
66148addeea4SAmine Khaldi ok(g_nmlistview.iSubItem == item.iSubItem, "Unexpected subitem %d.\n", g_nmlistview.iSubItem);
66158addeea4SAmine Khaldi ok(g_nmlistview.lParam == item.lParam, "Unexpected lParam.\n");
66168addeea4SAmine Khaldi ok(g_nmlistview.uNewState == 0, "Unexpected new state %#x.\n", g_nmlistview.uNewState);
66178addeea4SAmine Khaldi ok(g_nmlistview.uOldState == LVIS_SELECTED, "Unexpected old state %#x.\n", g_nmlistview.uOldState);
66188addeea4SAmine Khaldi ok(g_nmlistview.uChanged == LVIF_STATE, "Unexpected change mask %#x.\n", g_nmlistview.uChanged);
66198addeea4SAmine Khaldi
66208addeea4SAmine Khaldi /* LVM_SETITEM changes state */
66218addeea4SAmine Khaldi memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
66228addeea4SAmine Khaldi memset(&item, 0, sizeof(item));
66238addeea4SAmine Khaldi item.stateMask = LVIS_SELECTED;
66248addeea4SAmine Khaldi item.state = LVIS_SELECTED;
66258addeea4SAmine Khaldi item.mask = LVIF_STATE;
66268addeea4SAmine Khaldi res = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
66278addeea4SAmine Khaldi ok(res, "Failed to set item.\n");
66288addeea4SAmine Khaldi
66298addeea4SAmine Khaldi ok(g_nmlistview.iItem == item.iItem, "Unexpected item %d.\n", g_nmlistview.iItem);
66308addeea4SAmine Khaldi ok(g_nmlistview.iSubItem == item.iSubItem, "Unexpected subitem %d.\n", g_nmlistview.iSubItem);
66318addeea4SAmine Khaldi ok(g_nmlistview.lParam == item.lParam, "Unexpected lParam.\n");
66328addeea4SAmine Khaldi ok(g_nmlistview.uNewState == LVIS_SELECTED, "Unexpected new state %#x.\n", g_nmlistview.uNewState);
66338addeea4SAmine Khaldi ok(g_nmlistview.uOldState == 0, "Unexpected old state %#x.\n", g_nmlistview.uOldState);
66348addeea4SAmine Khaldi ok(g_nmlistview.uChanged == LVIF_STATE, "Unexpected change mask %#x.\n", g_nmlistview.uChanged);
66358addeea4SAmine Khaldi
66368addeea4SAmine Khaldi /* LVM_SETITEM no state changes */
66378addeea4SAmine Khaldi memset(&g_nmlistview, 0xcc, sizeof(g_nmlistview));
66388addeea4SAmine Khaldi memset(&item, 0, sizeof(item));
66398addeea4SAmine Khaldi item.lParam = 11;
66408addeea4SAmine Khaldi item.mask = LVIF_PARAM;
66418addeea4SAmine Khaldi res = SendMessageA(hwnd, LVM_SETITEMA, 0, (LPARAM)&item);
66428addeea4SAmine Khaldi ok(res, "Failed to set item.\n");
66438addeea4SAmine Khaldi
66448addeea4SAmine Khaldi ok(g_nmlistview.iItem == item.iItem, "Unexpected item %d.\n", g_nmlistview.iItem);
66458addeea4SAmine Khaldi ok(g_nmlistview.iSubItem == item.iSubItem, "Unexpected subitem %d.\n", g_nmlistview.iSubItem);
66468addeea4SAmine Khaldi ok(g_nmlistview.lParam == item.lParam, "Unexpected lParam.\n");
66478addeea4SAmine Khaldi ok(g_nmlistview.uNewState == 0, "Unexpected new state %#x.\n", g_nmlistview.uNewState);
66488addeea4SAmine Khaldi ok(g_nmlistview.uOldState == 0, "Unexpected old state %#x.\n", g_nmlistview.uOldState);
66498addeea4SAmine Khaldi ok(g_nmlistview.uChanged == LVIF_PARAM, "Unexpected change mask %#x.\n", g_nmlistview.uChanged);
66508addeea4SAmine Khaldi
66518addeea4SAmine Khaldi DestroyWindow(hwnd);
66528addeea4SAmine Khaldi }
66538addeea4SAmine Khaldi }
66548addeea4SAmine Khaldi
START_TEST(listview)6655c2c66affSColin Finck START_TEST(listview)
6656c2c66affSColin Finck {
6657c2c66affSColin Finck ULONG_PTR ctx_cookie;
6658c2c66affSColin Finck HANDLE hCtx;
6659c2c66affSColin Finck
6660f37104daSAmine Khaldi init_functions();
6661c2c66affSColin Finck
6662c2c66affSColin Finck init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
6663c2c66affSColin Finck
6664c2c66affSColin Finck hwndparent = create_parent_window(FALSE);
6665c2c66affSColin Finck flush_sequences(sequences, NUM_MSG_SEQUENCES);
6666c2c66affSColin Finck
6667c2c66affSColin Finck g_is_below_5 = is_below_comctl_5();
6668c2c66affSColin Finck
6669c2c66affSColin Finck test_header_notification();
6670c2c66affSColin Finck test_header_notification2();
6671c2c66affSColin Finck test_images();
6672c2c66affSColin Finck test_checkboxes();
6673c2c66affSColin Finck test_items();
6674f37104daSAmine Khaldi test_create(FALSE);
6675c2c66affSColin Finck test_redraw();
6676c2c66affSColin Finck test_customdraw();
6677c2c66affSColin Finck test_icon_spacing();
6678c2c66affSColin Finck test_color();
6679c2c66affSColin Finck test_item_count();
6680c2c66affSColin Finck test_item_position();
6681c2c66affSColin Finck test_columns();
6682c2c66affSColin Finck test_getorigin();
6683c2c66affSColin Finck test_multiselect();
6684c2c66affSColin Finck test_getitemrect();
6685c2c66affSColin Finck test_subitem_rect();
6686c2c66affSColin Finck test_sorting();
6687c2c66affSColin Finck test_ownerdata();
6688c2c66affSColin Finck test_norecompute();
6689c2c66affSColin Finck test_nosortheader();
6690c2c66affSColin Finck test_setredraw();
6691c2c66affSColin Finck test_hittest();
6692c2c66affSColin Finck test_getviewrect();
6693c2c66affSColin Finck test_getitemposition();
6694c2c66affSColin Finck test_editbox();
6695c2c66affSColin Finck test_notifyformat();
6696c2c66affSColin Finck test_indentation();
6697c2c66affSColin Finck test_getitemspacing();
6698c2c66affSColin Finck test_getcolumnwidth();
6699c2c66affSColin Finck test_approximate_viewrect();
6700c2c66affSColin Finck test_finditem();
6701c2c66affSColin Finck test_hover();
6702c2c66affSColin Finck test_destroynotify();
6703c2c66affSColin Finck test_createdragimage();
6704c2c66affSColin Finck test_dispinfo();
6705c2c66affSColin Finck test_LVM_SETITEMTEXT();
6706c2c66affSColin Finck test_LVM_REDRAWITEMS();
6707c2c66affSColin Finck test_imagelists();
6708c2c66affSColin Finck test_deleteitem();
6709c2c66affSColin Finck test_insertitem();
6710c2c66affSColin Finck test_header_proc();
6711c2c66affSColin Finck test_oneclickactivate();
6712c2c66affSColin Finck test_callback_mask();
67130d320bc2SAmine Khaldi test_state_image();
6714f37104daSAmine Khaldi test_LVSCW_AUTOSIZE();
67155f7243b5SAmine Khaldi test_LVN_ENDLABELEDIT();
67165f7243b5SAmine Khaldi test_LVM_GETCOUNTPERPAGE();
67178addeea4SAmine Khaldi test_item_state_change();
6718c2c66affSColin Finck
6719c2c66affSColin Finck if (!load_v6_module(&ctx_cookie, &hCtx))
6720c2c66affSColin Finck {
6721c2c66affSColin Finck DestroyWindow(hwndparent);
6722c2c66affSColin Finck return;
6723c2c66affSColin Finck }
6724c2c66affSColin Finck
6725f37104daSAmine Khaldi init_functions();
6726f37104daSAmine Khaldi
6727c2c66affSColin Finck /* comctl32 version 6 tests start here */
6728c2c66affSColin Finck test_get_set_view();
6729c2c66affSColin Finck test_canceleditlabel();
6730c2c66affSColin Finck test_mapidindex();
6731c2c66affSColin Finck test_scrollnotify();
6732c2c66affSColin Finck test_LVS_EX_TRANSPARENTBKGND();
6733c2c66affSColin Finck test_LVS_EX_HEADERINALLVIEWS();
6734c2c66affSColin Finck test_deleteitem();
6735c2c66affSColin Finck test_multiselect();
6736c2c66affSColin Finck test_insertitem();
6737c2c66affSColin Finck test_header_proc();
67380d320bc2SAmine Khaldi test_images();
67390d320bc2SAmine Khaldi test_checkboxes();
67400d320bc2SAmine Khaldi test_items();
6741f37104daSAmine Khaldi test_create(TRUE);
67420d320bc2SAmine Khaldi test_color();
67430d320bc2SAmine Khaldi test_columns();
67440d320bc2SAmine Khaldi test_sorting();
67450d320bc2SAmine Khaldi test_ownerdata();
67460d320bc2SAmine Khaldi test_norecompute();
67470d320bc2SAmine Khaldi test_nosortheader();
67480d320bc2SAmine Khaldi test_indentation();
67490d320bc2SAmine Khaldi test_finditem();
67500d320bc2SAmine Khaldi test_hover();
67510d320bc2SAmine Khaldi test_destroynotify();
67520d320bc2SAmine Khaldi test_createdragimage();
67530d320bc2SAmine Khaldi test_dispinfo();
67540d320bc2SAmine Khaldi test_LVM_SETITEMTEXT();
67550d320bc2SAmine Khaldi test_LVM_REDRAWITEMS();
67560d320bc2SAmine Khaldi test_oneclickactivate();
67570d320bc2SAmine Khaldi test_state_image();
6758f37104daSAmine Khaldi test_LVSCW_AUTOSIZE();
67595f7243b5SAmine Khaldi test_LVN_ENDLABELEDIT();
67605f7243b5SAmine Khaldi test_LVM_GETCOUNTPERPAGE();
67618addeea4SAmine Khaldi test_item_state_change();
6762c2c66affSColin Finck
6763c2c66affSColin Finck unload_v6_module(ctx_cookie, hCtx);
6764c2c66affSColin Finck
6765c2c66affSColin Finck DestroyWindow(hwndparent);
6766c2c66affSColin Finck }
6767