4 * Copyright 2006 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
27 static void test_images(void)
29 HWND hwnd
, hwndparent
= 0;
35 static CHAR hello
[] = "hello";
37 himl
= ImageList_Create(40, 40, 0, 4, 4);
38 ok(himl
!= NULL
, "failed to create imagelist\n");
40 hbmp
= CreateBitmap(40, 40, 1, 1, NULL
);
41 ok(hbmp
!= NULL
, "failed to create bitmap\n");
43 r
= ImageList_Add(himl
, hbmp
, 0);
44 ok(r
== 0, "should be zero\n");
46 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_OWNERDRAWFIXED
,
47 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
48 ok(hwnd
!= NULL
, "failed to create listview window\n");
50 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, 0, 0x940);
51 ok(r
== 0, "should return zero\n");
53 r
= SendMessage(hwnd
, LVM_SETIMAGELIST
, 0, (LPARAM
)himl
);
54 ok(r
== 0, "should return zero\n");
56 r
= SendMessage(hwnd
, LVM_SETICONSPACING
, 0, MAKELONG(100,50));
57 /* returns dimensions */
59 r
= SendMessage(hwnd
, LVM_GETITEMCOUNT
, 0, 0);
60 ok(r
== 0, "should be zero items\n");
62 item
.mask
= LVIF_IMAGE
| LVIF_TEXT
;
66 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
67 ok(r
== -1, "should fail\n");
71 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
72 ok(r
== 0, "should not fail\n");
74 memset(&r1
, 0, sizeof r1
);
76 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
) &r1
);
78 r
= SendMessage(hwnd
, LVM_DELETEALLITEMS
, 0, 0);
79 ok(r
== TRUE
, "should not fail\n");
83 r
= SendMessage(hwnd
, LVM_INSERTITEM
, 0, (LPARAM
) &item
);
84 ok(r
== 0, "should not fail\n");
86 memset(&r2
, 0, sizeof r2
);
88 r
= SendMessage(hwnd
, LVM_GETITEMRECT
, 0, (LPARAM
) &r2
);
90 ok(!memcmp(&r1
, &r2
, sizeof r1
), "rectangle should be the same\n");
95 static void test_checkboxes(void)
97 HWND hwnd
, hwndparent
= 0;
100 static CHAR text
[] = "Text",
104 hwnd
= CreateWindowEx(0, "SysListView32", "foo", LVS_REPORT
,
105 10, 10, 100, 200, hwndparent
, NULL
, NULL
, NULL
);
106 ok(hwnd
!= NULL
, "failed to create listview window\n");
108 /* first without LVS_EX_CHECKBOXES set and an item and check that state is preserved */
109 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
110 item
.stateMask
= 0xffff;
115 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
116 ok(r
== 0, "ret %ld\n", r
);
119 item
.mask
= LVIF_STATE
;
120 item
.stateMask
= 0xffff;
121 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
122 ok(item
.state
== 0xfccc, "state %x\n", item
.state
);
124 /* Don't set LVIF_STATE */
125 item
.mask
= LVIF_TEXT
;
126 item
.stateMask
= 0xffff;
131 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
132 ok(r
== 1, "ret %ld\n", r
);
135 item
.mask
= LVIF_STATE
;
136 item
.stateMask
= 0xffff;
137 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
138 ok(item
.state
== 0, "state %x\n", item
.state
);
140 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
141 ok(r
== 0, "should return zero\n");
143 /* Having turned on checkboxes, check that all existing items are set to 0x1000 (unchecked) */
145 item
.mask
= LVIF_STATE
;
146 item
.stateMask
= 0xffff;
147 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
148 ok(item
.state
== 0x1ccc, "state %x\n", item
.state
);
150 /* Now add an item without specifying a state and check that it's state goes to 0x1000 */
152 item
.mask
= LVIF_TEXT
;
154 item
.pszText
= text2
;
155 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
156 ok(r
== 2, "ret %ld\n", r
);
159 item
.mask
= LVIF_STATE
;
160 item
.stateMask
= 0xffff;
161 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
162 ok(item
.state
== 0x1000, "state %x\n", item
.state
);
164 /* Add a further item this time specifying a state and still it's state goes to 0x1000 */
166 item
.mask
= LVIF_TEXT
| LVIF_STATE
;
167 item
.stateMask
= 0xffff;
169 item
.pszText
= text3
;
170 r
= SendMessage(hwnd
, LVM_INSERTITEMA
, 0, (LPARAM
) &item
);
171 ok(r
== 3, "ret %ld\n", r
);
174 item
.mask
= LVIF_STATE
;
175 item
.stateMask
= 0xffff;
176 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
177 ok(item
.state
== 0x1aaa, "state %x\n", item
.state
);
179 /* Set an item's state to checked */
181 item
.mask
= LVIF_STATE
;
182 item
.stateMask
= 0xf000;
184 r
= SendMessage(hwnd
, LVM_SETITEMA
, 0, (LPARAM
) &item
);
187 item
.mask
= LVIF_STATE
;
188 item
.stateMask
= 0xffff;
189 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
190 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
192 /* Set the style again and check that doesn't change an item's state */
193 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
194 ok(r
== LVS_EX_CHECKBOXES
, "ret %lx\n", r
);
197 item
.mask
= LVIF_STATE
;
198 item
.stateMask
= 0xffff;
199 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
200 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
202 /* Unsetting the checkbox extended style doesn't change an item's state */
203 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, 0);
204 ok(r
== LVS_EX_CHECKBOXES
, "ret %lx\n", r
);
207 item
.mask
= LVIF_STATE
;
208 item
.stateMask
= 0xffff;
209 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
210 ok(item
.state
== 0x2aaa, "state %x\n", item
.state
);
212 /* Now setting the style again will change an item's state */
213 r
= SendMessage(hwnd
, LVM_SETEXTENDEDLISTVIEWSTYLE
, LVS_EX_CHECKBOXES
, LVS_EX_CHECKBOXES
);
214 ok(r
== 0, "ret %lx\n", r
);
217 item
.mask
= LVIF_STATE
;
218 item
.stateMask
= 0xffff;
219 r
= SendMessage(hwnd
, LVM_GETITEMA
, 0, (LPARAM
) &item
);
220 ok(item
.state
== 0x1aaa, "state %x\n", item
.state
);
227 INITCOMMONCONTROLSEX icc
;
230 icc
.dwSize
= sizeof icc
;
231 InitCommonControlsEx(&icc
);