2 * comctl32 month calendar unit tests
4 * Copyright (C) 2006 Vitaliy Margolen
5 * Copyright (C) 2007 Farshad Agah
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define expect(expected, got) ok(expected == got, "Expected %d, got %d\n", expected, got);
25 #define expect_hex(expected, got) ok(expected == got, "Expected %x, got %x\n", expected, got);
26 #define expect_d(expected, got) ok(abs((expected) - (got)) <= 2, "Expected %d, got %d\n", expected, got);
28 #define NUM_MSG_SEQUENCES 2
29 #define PARENT_SEQ_INDEX 0
30 #define MONTHCAL_SEQ_INDEX 1
32 #define SEL_NOTIFY_TEST_ID 100
34 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
36 static HWND parent_wnd
;
38 static const struct message create_parent_window_seq
[] = {
39 { WM_GETMINMAXINFO
, sent
},
40 { WM_NCCREATE
, sent
},
41 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
43 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
44 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
45 { WM_QUERYNEWPALETTE
, sent
|optional
},
46 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, 0 },
47 { WM_WINDOWPOSCHANGED
, sent
|optional
},
48 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
49 { WM_NCACTIVATE
, sent
},
50 { WM_ACTIVATE
, sent
|wparam
, 1 },
51 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
52 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
53 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
54 /* Win9x adds SWP_NOZORDER below */
55 { WM_WINDOWPOSCHANGED
, sent
, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
56 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
62 static const struct message create_monthcal_control_seq
[] = {
63 { WM_NOTIFYFORMAT
, sent
|lparam
, 0, NF_QUERY
},
64 { WM_QUERYUISTATE
, sent
|optional
},
66 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
},
70 static const struct message create_monthcal_multi_sel_style_seq
[] = {
71 { WM_NOTIFYFORMAT
, sent
|lparam
, 0, NF_QUERY
},
72 { WM_QUERYUISTATE
, sent
|optional
},
74 { WM_PARENTNOTIFY
, sent
},
78 static const struct message monthcal_curr_date_seq
[] = {
79 { MCM_SETCURSEL
, sent
|wparam
, 0},
80 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
81 { MCM_SETCURSEL
, sent
|wparam
, 0},
82 { MCM_SETCURSEL
, sent
|wparam
, 0},
83 { MCM_GETCURSEL
, sent
|wparam
, 0},
84 { MCM_GETCURSEL
, sent
|wparam
|lparam
, 0, 0},
88 static const struct message monthcal_first_day_seq
[] = {
89 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
91 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -5},
92 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
94 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -4},
95 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
97 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -3},
98 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
100 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -2},
101 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
103 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -1},
104 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
106 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
107 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
109 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 1},
110 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
112 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 2},
113 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
115 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 3},
116 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
118 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 4},
119 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
121 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 5},
122 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
124 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 6},
125 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
127 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 7},
128 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
130 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 8},
131 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
133 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 9},
134 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
136 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 10},
137 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
139 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 11},
140 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
144 static const struct message monthcal_unicode_seq
[] = {
145 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
146 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 1, 0},
147 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
148 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
149 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
150 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 1, 0},
154 static const struct message monthcal_hit_test_seq
[] = {
155 { MCM_SETCURSEL
, sent
|wparam
, 0},
156 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
157 { MCM_HITTEST
, sent
|wparam
, 0},
158 { MCM_HITTEST
, sent
|wparam
, 0},
159 { MCM_HITTEST
, sent
|wparam
, 0},
160 { MCM_HITTEST
, sent
|wparam
, 0},
161 { MCM_HITTEST
, sent
|wparam
, 0},
162 { MCM_HITTEST
, sent
|wparam
, 0},
163 { MCM_HITTEST
, sent
|wparam
, 0},
164 { MCM_HITTEST
, sent
|wparam
, 0},
165 { MCM_HITTEST
, sent
|wparam
, 0},
166 { MCM_HITTEST
, sent
|wparam
, 0},
170 static const struct message monthcal_todaylink_seq
[] = {
171 { MCM_HITTEST
, sent
|wparam
, 0},
172 { MCM_SETTODAY
, sent
|wparam
, 0},
173 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
174 { MCM_GETTODAY
, sent
|wparam
, 0},
175 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
},
176 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
177 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
178 { MCM_GETCURSEL
, sent
|wparam
, 0},
182 static const struct message monthcal_today_seq
[] = {
183 { MCM_SETTODAY
, sent
|wparam
, 0},
184 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
185 { MCM_GETTODAY
, sent
|wparam
, 0},
186 { MCM_SETTODAY
, sent
|wparam
, 0},
187 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
188 { MCM_GETTODAY
, sent
|wparam
, 0},
192 static const struct message monthcal_scroll_seq
[] = {
193 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 2, 0},
194 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 3, 0},
195 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
196 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 12, 0},
197 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
198 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 15, 0},
199 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
200 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, -5, 0},
201 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
205 static const struct message monthcal_monthrange_seq
[] = {
206 { MCM_GETMONTHRANGE
, sent
|wparam
, GMR_VISIBLE
},
207 { MCM_GETMONTHRANGE
, sent
|wparam
, GMR_DAYSTATE
},
211 static const struct message monthcal_max_sel_day_seq
[] = {
212 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, 5, 0},
213 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
214 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, 15, 0},
215 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
216 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, -1, 0},
217 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
221 /* expected message sequence for parent*/
222 static const struct message destroy_monthcal_parent_msgs_seq
[] = {
223 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
},
227 /* expected message sequence for child*/
228 static const struct message destroy_monthcal_child_msgs_seq
[] = {
229 { 0x0090, sent
|optional
}, /* Vista */
230 { WM_SHOWWINDOW
, sent
|wparam
|lparam
, 0, 0},
231 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0},
232 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0},
233 { WM_DESTROY
, sent
|wparam
|lparam
, 0, 0},
234 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, 0},
238 static const struct message destroy_monthcal_multi_sel_style_seq
[] = {
239 { 0x0090, sent
|optional
}, /* Vista */
240 { WM_SHOWWINDOW
, sent
|wparam
|lparam
, 0, 0},
241 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0},
242 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0},
243 { WM_DESTROY
, sent
|wparam
|lparam
, 0, 0},
244 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, 0},
248 static void test_monthcal(void)
251 SYSTEMTIME st
[2], st1
[2], today
;
252 int res
, month_range
;
256 hwnd
= CreateWindowA(MONTHCAL_CLASSA
, "MonthCal", WS_POPUP
| WS_VISIBLE
, CW_USEDEFAULT
,
257 0, 300, 300, 0, 0, NULL
, NULL
);
258 ok(hwnd
!= NULL
, "Failed to create MonthCal\n");
260 /* test range just after creation */
261 memset(&st
, 0xcc, sizeof(st
));
262 limits
= SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st
);
264 broken(limits
== GDTR_MIN
), /* comctl32 <= 4.70 */
265 "No limits should be set (%d)\n", limits
);
266 if (limits
== GDTR_MIN
)
268 win_skip("comctl32 <= 4.70 is broken\n");
273 ok(0 == st
[0].wYear
||
274 broken(1752 == st
[0].wYear
), /* comctl32 <= 4.72 */
275 "Expected 0, got %d\n", st
[0].wYear
);
276 ok(0 == st
[0].wMonth
||
277 broken(9 == st
[0].wMonth
), /* comctl32 <= 4.72 */
278 "Expected 0, got %d\n", st
[0].wMonth
);
279 ok(0 == st
[0].wDay
||
280 broken(14 == st
[0].wDay
), /* comctl32 <= 4.72 */
281 "Expected 0, got %d\n", st
[0].wDay
);
282 expect(0, st
[0].wDayOfWeek
);
283 expect(0, st
[0].wHour
);
284 expect(0, st
[0].wMinute
);
285 expect(0, st
[0].wSecond
);
286 expect(0, st
[0].wMilliseconds
);
288 expect(0, st
[1].wYear
);
289 expect(0, st
[1].wMonth
);
290 expect(0, st
[1].wDay
);
291 expect(0, st
[1].wDayOfWeek
);
292 expect(0, st
[1].wHour
);
293 expect(0, st
[1].wMinute
);
294 expect(0, st
[1].wSecond
);
295 expect(0, st
[1].wMilliseconds
);
297 limits
= SendMessageA(hwnd
, MCM_GETRANGE
, 0, 0);
298 ok(limits
== 0, "got %u\n", limits
);
300 GetSystemTime(&st
[0]);
303 SendMessageA(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&today
);
305 /* Invalid date/time */
307 /* Time should not matter */
308 st
[1].wHour
= st
[1].wMinute
= st
[1].wSecond
= 70;
309 st
[1].wMilliseconds
= 1200;
310 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set MAX limit\n");
311 /* invalid timestamp is written back with today data and msecs untouched */
312 expect(today
.wHour
, st
[1].wHour
);
313 expect(today
.wMinute
, st
[1].wMinute
);
314 expect(today
.wSecond
, st
[1].wSecond
);
315 expect(1200, st
[1].wMilliseconds
);
317 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
318 ok(st1
[0].wYear
!= 2000, "Lower limit changed\n");
319 /* invalid timestamp should be replaced with today data, except msecs */
320 expect(today
.wHour
, st1
[1].wHour
);
321 expect(today
.wMinute
, st1
[1].wMinute
);
322 expect(today
.wSecond
, st1
[1].wSecond
);
323 expect(1200, st1
[1].wMilliseconds
);
325 /* Invalid date/time with invalid milliseconds only */
326 GetSystemTime(&st
[0]);
328 /* Time should not matter */
329 st
[1].wMilliseconds
= 1200;
330 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set MAX limit\n");
331 /* invalid milliseconds field doesn't lead to invalid timestamp */
332 expect(st
[0].wHour
, st
[1].wHour
);
333 expect(st
[0].wMinute
, st
[1].wMinute
);
334 expect(st
[0].wSecond
, st
[1].wSecond
);
335 expect(1200, st
[1].wMilliseconds
);
337 GetSystemTime(&st
[0]);
340 ok(!SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
),
341 "Should have failed to set limits\n");
342 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
343 ok(st1
[0].wYear
!= 2000, "Lower limit changed\n");
344 ok(!SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
),
345 "Should have failed to set MAX limit\n");
346 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
347 ok(st1
[0].wYear
!= 2000, "Lower limit changed\n");
349 GetSystemTime(&st
[0]);
354 month_range
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
356 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
),
357 "Failed to set both min and max limits\n");
358 res
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
359 ok(res
== month_range
, "Invalid month range (%d)\n", res
);
360 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
),
361 "Limits should be set\n");
364 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
),
365 "Failed to set both min and max limits\n");
366 res
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
367 ok(res
== month_range
, "Invalid month range (%d)\n", res
);
370 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
),
371 "Failed to set both min and max limits\n");
373 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
),
374 "Failed to set both min and max limits\n");
377 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
378 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
,
379 "Only MAX limit should be set\n");
381 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
383 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
385 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
386 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
,
387 "Only MAX limit should be set\n");
389 /* set both limits, then set max < min */
390 GetSystemTime(&st
[0]);
394 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
|GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
395 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
),
396 "Min limit expected\n");
398 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
399 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "Max limit expected\n");
401 expect(0, st1
[0].wYear
);
402 expect(0, st1
[0].wMonth
);
403 expect(0, st1
[0].wDay
);
404 expect(0, st1
[0].wDayOfWeek
);
405 expect(0, st1
[0].wHour
);
406 expect(0, st1
[0].wMinute
);
407 expect(0, st1
[0].wSecond
);
408 expect(0, st1
[0].wMilliseconds
);
410 expect(st
[1].wYear
, st1
[1].wYear
);
411 expect(st
[1].wMonth
, st1
[1].wMonth
);
412 expect(st
[1].wDay
, st1
[1].wDay
);
413 expect(st
[1].wDayOfWeek
, st1
[1].wDayOfWeek
);
414 expect(st
[1].wHour
, st1
[1].wHour
);
415 expect(st
[1].wMinute
, st1
[1].wMinute
);
416 expect(st
[1].wSecond
, st1
[1].wSecond
);
417 expect(st
[1].wMilliseconds
, st1
[1].wMilliseconds
);
421 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
|GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
422 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
),
423 "Min limit expected\n");
424 st
[0].wYear
++; /* start == end now */
425 ok(SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
, (LPARAM
)st
), "Failed to set limits\n");
426 ok(SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MIN
, "Min limit expected\n");
428 expect(st
[0].wYear
, st1
[0].wYear
);
429 expect(st
[0].wMonth
, st1
[0].wMonth
);
430 expect(st
[0].wDay
, st1
[0].wDay
);
431 expect(st
[0].wDayOfWeek
, st1
[0].wDayOfWeek
);
432 expect(st
[0].wHour
, st1
[0].wHour
);
433 expect(st
[0].wMinute
, st1
[0].wMinute
);
434 expect(st
[0].wSecond
, st1
[0].wSecond
);
435 expect(st
[0].wMilliseconds
, st1
[0].wMilliseconds
);
437 expect(0, st1
[1].wYear
);
438 expect(0, st1
[1].wMonth
);
439 expect(0, st1
[1].wDay
);
440 expect(0, st1
[1].wDayOfWeek
);
441 expect(0, st1
[1].wHour
);
442 expect(0, st1
[1].wMinute
);
443 expect(0, st1
[1].wSecond
);
444 expect(0, st1
[1].wMilliseconds
);
447 limits
= SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
);
448 ok(limits
== GDTR_MIN
, "got 0x%08x\n", limits
);
453 r
= SendMessageA(hwnd
, MCM_SETRANGE
, 0, (LPARAM
)st
);
454 ok(r
, "got %d\n", r
);
456 limits
= SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st
);
457 ok(limits
== 0, "got 0x%08x\n", limits
);
458 ok(st
[0].wYear
== 0 && st
[1].wYear
== 0, "got %u, %u\n", st
[0].wYear
, st
[1].wYear
);
460 /* flags are 0, set min limit */
465 r
= SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
, (LPARAM
)st
);
466 ok(r
, "got %d\n", r
);
468 limits
= SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
);
469 ok(limits
== GDTR_MIN
, "got 0x%08x\n", limits
);
470 ok(st1
[1].wYear
== 0, "got %u\n", st1
[1].wYear
);
472 /* now set max limit, check flags */
473 r
= SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
);
474 ok(r
, "got %d\n", r
);
476 limits
= SendMessageA(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
);
477 ok(limits
== GDTR_MAX
, "got 0x%08x\n", limits
);
478 ok(st1
[0].wYear
== 0, "got %u\n", st1
[0].wYear
);
483 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
485 static LONG defwndproc_counter
= 0;
489 /* log system messages, except for painting */
490 if (message
< WM_USER
&&
491 message
!= WM_PAINT
&&
492 message
!= WM_ERASEBKGND
&&
493 message
!= WM_NCPAINT
&&
494 message
!= WM_NCHITTEST
&&
495 message
!= WM_GETTEXT
&&
496 message
!= WM_GETICON
&&
497 message
!= WM_DEVICECHANGE
)
499 msg
.message
= message
;
500 msg
.flags
= sent
|wparam
|lparam
;
501 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
504 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
507 if (message
== WM_NOTIFY
)
509 NMHDR
*hdr
= (NMHDR
*)lParam
;
512 case MCN_GETDAYSTATE
:
514 NMDAYSTATE
*nmstate
= (NMDAYSTATE
*)lParam
;
515 static MONTHDAYSTATE months
[14] = { 0 };
517 ok(nmstate
->cDayState
> 0, "got %d\n", nmstate
->cDayState
);
518 ok(nmstate
->cDayState
<= 14, "got %d\n", nmstate
->cDayState
);
519 ok(nmstate
->prgDayState
!= NULL
, "got %p\n", nmstate
->prgDayState
);
521 nmstate
->prgDayState
= months
;
528 NMSELCHANGE
*nmchg
= (NMSELCHANGE
*)lParam
;
530 BOOL is_multisel
= GetWindowLongPtrA(nmchg
->nmhdr
.hwndFrom
, GWL_STYLE
) & MCS_MULTISELECT
;
532 if(GetWindowLongPtrA(nmchg
->nmhdr
.hwndFrom
, GWLP_ID
) != SEL_NOTIFY_TEST_ID
)
534 SendMessageA(nmchg
->nmhdr
.hwndFrom
, is_multisel
? MCM_GETSELRANGE
: MCM_GETCURSEL
,
537 expect(st
[0].wYear
, nmchg
->stSelStart
.wYear
);
538 expect(st
[0].wMonth
, nmchg
->stSelStart
.wMonth
);
539 expect(0, nmchg
->stSelStart
.wDayOfWeek
);
540 expect(st
[0].wDay
, nmchg
->stSelStart
.wDay
);
544 expect(st
[1].wYear
, nmchg
->stSelEnd
.wYear
);
545 expect(st
[1].wMonth
, nmchg
->stSelEnd
.wMonth
);
546 expect(0, nmchg
->stSelEnd
.wDayOfWeek
);
547 expect(st
[1].wDay
, nmchg
->stSelEnd
.wDay
);
550 ok(!(nmchg
->stSelEnd
.wYear
| nmchg
->stSelEnd
.wMonth
|
551 nmchg
->stSelEnd
.wDayOfWeek
| nmchg
->stSelEnd
.wDay
|
552 nmchg
->stSelEnd
.wHour
| nmchg
->stSelEnd
.wMinute
|
553 nmchg
->stSelEnd
.wSecond
| nmchg
->stSelEnd
.wMilliseconds
),
554 "Non-zero member in stSelEnd\n");
562 defwndproc_counter
++;
563 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
564 defwndproc_counter
--;
569 static BOOL
register_parent_wnd_class(void)
574 cls
.lpfnWndProc
= parent_wnd_proc
;
577 cls
.hInstance
= GetModuleHandleA(NULL
);
579 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
580 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
581 cls
.lpszMenuName
= NULL
;
582 cls
.lpszClassName
= "Month-Cal test parent class";
583 return RegisterClassA(&cls
);
586 static HWND
create_parent_window(void)
590 InitCommonControls();
592 /* flush message sequences, so we can check the new sequence by the end of function */
593 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
595 if (!register_parent_wnd_class())
598 hwnd
= CreateWindowExA(0, "Month-Cal test parent class", "Month-Cal test parent window",
599 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_VISIBLE
,
600 0, 0, 500, 500, GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
601 ok(hwnd
!= NULL
, "failed to create parent wnd\n");
603 /* check for message sequences */
604 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_parent_window_seq
, "create parent window", FALSE
);
609 static LRESULT WINAPI
monthcal_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
611 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
612 static LONG defwndproc_counter
= 0;
613 struct message msg
= { 0 };
616 msg
.message
= message
;
617 msg
.flags
= sent
|wparam
|lparam
;
618 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
621 add_message(sequences
, MONTHCAL_SEQ_INDEX
, &msg
);
623 /* some debug output for style changing */
624 if ((message
== WM_STYLECHANGING
||
625 message
== WM_STYLECHANGED
) && lParam
)
627 STYLESTRUCT
*style
= (STYLESTRUCT
*)lParam
;
628 trace("\told style: 0x%08x, new style: 0x%08x\n", style
->styleOld
, style
->styleNew
);
631 defwndproc_counter
++;
632 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
633 defwndproc_counter
--;
638 static HWND
create_monthcal_control(DWORD style
)
645 hwnd
= CreateWindowExA(0, MONTHCAL_CLASSA
, "", WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
646 0, 0, 300, 400, parent_wnd
, NULL
, GetModuleHandleA(NULL
), NULL
);
647 ok(hwnd
!= NULL
, "failed to create monthcal wnd\n");
648 if (!hwnd
) return NULL
;
650 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
651 (LONG_PTR
)monthcal_subclass_proc
);
652 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
654 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(SYSTEM_FONT
), 0);
656 /* make sure calendar grid is 2x1 */
657 ret
= SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&rect
);
658 ok(ret
, "got %d\n", ret
);
660 ret
= SetWindowPos(hwnd
, NULL
, 0, 0, rect
.right
* 5 / 2, rect
.bottom
* 3 / 2, SWP_NOMOVE
);
661 ok(ret
, "got %d\n", ret
);
667 /* Setter and Getters Tests */
669 static void test_color(void)
671 COLORREF color
, prev
;
674 hwnd
= create_monthcal_control(0);
676 /* invalid color index */
677 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
+ 1, 0);
679 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TRAILINGTEXT
+ 1, RGB(255,255,255));
682 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
683 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_BACKGROUND
, RGB(0,0,0));
685 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
686 expect(RGB(0,0,0), color
);
687 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_BACKGROUND
, RGB(255,255,255));
689 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
690 expect(RGB(255,255,255), color
);
692 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
693 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_MONTHBK
, RGB(0,0,0));
695 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
696 expect(RGB(0,0,0), color
);
697 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_MONTHBK
, RGB(255,255,255));
699 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
700 expect(RGB(255,255,255), color
);
702 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
703 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TEXT
, RGB(0,0,0));
705 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
706 expect(RGB(0,0,0), color
);
707 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TEXT
, RGB(255,255,255));
709 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
710 expect(RGB(255,255,255), color
);
712 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
713 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TITLEBK
, RGB(0,0,0));
715 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
716 expect(RGB(0,0,0), color
);
717 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TITLEBK
, RGB(255,255,255));
719 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
720 expect(RGB(255,255,255), color
);
722 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
723 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TITLETEXT
, RGB(0,0,0));
725 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
726 expect(RGB(0,0,0), color
);
727 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TITLETEXT
, RGB(255,255,255));
729 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
730 expect(RGB(255,255,255), color
);
732 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
733 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TRAILINGTEXT
, RGB(0,0,0));
735 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
736 expect(RGB(0,0,0), color
);
737 prev
= SendMessageA(hwnd
, MCM_SETCOLOR
, MCSC_TRAILINGTEXT
, RGB(255,255,255));
739 color
= SendMessageA(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
740 expect(RGB(255,255,255), color
);
745 static void test_currdate(void)
747 SYSTEMTIME st_original
, st_new
, st_test
;
751 hwnd
= create_monthcal_control(0);
753 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
755 /* Setter and Getters for current date selected */
756 st_original
.wYear
= 2000;
757 st_original
.wMonth
= 11;
758 st_original
.wDay
= 28;
759 st_original
.wHour
= 11;
760 st_original
.wMinute
= 59;
761 st_original
.wSecond
= 30;
762 st_original
.wMilliseconds
= 0;
763 st_original
.wDayOfWeek
= 0;
765 st_new
= st_test
= st_original
;
767 /* Should not validate the time */
768 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
771 /* Overflow matters, check for wDay */
773 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
776 /* correct wDay before checking for wMonth */
778 expect(st_original
.wDay
, st_test
.wDay
);
780 /* Overflow matters, check for wMonth */
782 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
785 /* checking if gets the information right, modify st_new */
793 res
= SendMessageA(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_new
);
796 /* st_new change to st_origin, above settings with overflow */
797 /* should not change the current settings */
798 expect(st_original
.wYear
, st_new
.wYear
);
799 expect(st_original
.wMonth
, st_new
.wMonth
);
800 expect(st_original
.wDay
, st_new
.wDay
);
801 ok(st_original
.wHour
== st_new
.wHour
||
802 broken(0 == st_new
.wHour
), /* comctl32 <= 4.70 */
803 "Expected %d, got %d\n", st_original
.wHour
, st_new
.wHour
);
804 ok(st_original
.wMinute
== st_new
.wMinute
||
805 broken(0 == st_new
.wMinute
), /* comctl32 <= 4.70 */
806 "Expected %d, got %d\n", st_original
.wMinute
, st_new
.wMinute
);
807 ok(st_original
.wSecond
== st_new
.wSecond
||
808 broken(0 == st_new
.wSecond
), /* comctl32 <= 4.70 */
809 "Expected %d, got %d\n", st_original
.wSecond
, st_new
.wSecond
);
811 /* lparam cannot be NULL */
812 res
= SendMessageA(hwnd
, MCM_GETCURSEL
, 0, 0);
815 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_curr_date_seq
, "monthcal currDate", TRUE
);
817 /* December, 31, 9999 is the maximum allowed date */
818 memset(&st_new
, 0, sizeof(st_new
));
822 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_new
);
824 memset(&st_test
, 0, sizeof(st_test
));
825 res
= SendMessageA(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_test
);
827 expect(st_new
.wYear
, st_test
.wYear
);
828 expect(st_new
.wMonth
, st_test
.wMonth
);
829 expect(st_new
.wDay
, st_test
.wDay
);
830 expect(st_new
.wHour
, st_test
.wHour
);
831 expect(st_new
.wMinute
, st_test
.wMinute
);
832 expect(st_new
.wSecond
, st_test
.wSecond
);
833 /* try one day later */
834 st_original
= st_new
;
835 st_new
.wYear
= 10000;
838 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_new
);
840 broken(1 == res
), /* comctl32 <= 4.72 */
841 "Expected 0, got %d\n", res
);
844 memset(&st_test
, 0, sizeof(st_test
));
845 res
= SendMessageA(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_test
);
847 expect(st_original
.wYear
, st_test
.wYear
);
848 expect(st_original
.wMonth
, st_test
.wMonth
);
849 expect(st_original
.wDay
, st_test
.wDay
);
850 expect(st_original
.wHour
, st_test
.wHour
);
851 expect(st_original
.wMinute
, st_test
.wMinute
);
852 expect(st_original
.wSecond
, st_test
.wSecond
);
855 /* setting selection equal to current reports success even if out range */
856 memset(&st_new
, 0, sizeof(st_new
));
860 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_new
);
862 memset(&st_test
, 0, sizeof(st_test
));
863 st_test
.wYear
= 2009;
866 res
= SendMessageA(hwnd
, MCM_SETRANGE
, GDTR_MIN
, (LPARAM
)&st_test
);
868 /* set to current again */
869 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_new
);
872 /* set with invalid day of week */
873 memset(&st_test
, 0, sizeof(st_test
));
874 st_test
.wYear
= 2009;
877 st_test
.wDayOfWeek
= 100;
878 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
881 memset(&st_test
, 0, sizeof(st_test
));
882 res
= SendMessageA(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_test
);
884 expect(2009, st_test
.wYear
);
885 expect(7, st_test
.wDay
);
886 expect(10, st_test
.wMonth
);
887 expect(3, st_test
.wDayOfWeek
);
892 static void test_firstDay(void)
894 int res
, fday
, i
, prev
;
895 CHAR b
[128], caltype
[3];
896 LCID lcid
= LOCALE_USER_DEFAULT
;
900 SetLastError(0xdeadbeef);
901 ret
= GetLocaleInfoA(lcid
, LOCALE_ICALENDARTYPE
, caltype
, 3);
903 skip("Must know local calendar type (%x)\n", GetLastError());
905 } else if (atoi(caltype
) != CAL_GREGORIAN
) {
906 skip("MonthCalendar Control only supports Gregorian calendar (type: %s)\n", caltype
);
910 hwnd
= create_monthcal_control(0);
912 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
914 /* Setter and Getters for first day of week */
915 /* check for locale first day */
916 if(GetLocaleInfoA(lcid
, LOCALE_IFIRSTDAYOFWEEK
, b
, 128)){
918 res
= SendMessageA(hwnd
, MCM_GETFIRSTDAYOFWEEK
, 0, 0);
922 /* checking for the values that actually will be stored as */
923 /* current first day when we set a new value */
924 for (i
= -5; i
< 12; i
++){
925 res
= SendMessageA(hwnd
, MCM_SETFIRSTDAYOFWEEK
, 0, i
);
927 res
= SendMessageA(hwnd
, MCM_GETFIRSTDAYOFWEEK
, 0, 0);
931 expect(MAKELONG(fday
, FALSE
), res
);
933 /* out of range sets max first day of week, locale is ignored */
934 expect(MAKELONG(6, TRUE
), res
);
936 expect(MAKELONG(i
, TRUE
), res
);
940 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_first_day_seq
, "monthcal firstDay", FALSE
);
943 skip("Cannot retrieve first day of the week\n");
949 static void test_unicode(void)
954 hwnd
= create_monthcal_control(0);
956 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
958 /* Setter and Getters for Unicode format */
960 /* getting the current settings */
961 temp
= SendMessageA(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
963 /* setting to 1, should return previous settings */
964 res
= SendMessageA(hwnd
, MCM_SETUNICODEFORMAT
, 1, 0);
967 /* current setting is 1, so, should return 1 */
968 res
= SendMessageA(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
970 broken(0 == res
), /* comctl32 <= 4.70 */
971 "Expected 1, got %d\n", res
);
973 /* setting to 0, should return previous settings */
974 res
= SendMessageA(hwnd
, MCM_SETUNICODEFORMAT
, 0, 0);
976 broken(0 == res
), /* comctl32 <= 4.70 */
977 "Expected 1, got %d\n", res
);
979 /* current setting is 0, so, it should return 0 */
980 res
= SendMessageA(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
983 /* should return previous settings */
984 res
= SendMessageA(hwnd
, MCM_SETUNICODEFORMAT
, 1, 0);
987 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_unicode_seq
, "monthcal unicode", FALSE
);
992 static void test_hittest(void)
994 typedef struct hittest_test
1000 static const hittest_test_t title_hits
[] = {
1001 /* Start is the same everywhere */
1002 { MCHT_TITLE
, FALSE
},
1003 { MCHT_TITLEBTNPREV
, FALSE
},
1004 /* The middle piece is only tested for presence of items */
1005 /* End is the same everywhere */
1006 { MCHT_TITLEBTNNEXT
, FALSE
},
1007 { MCHT_TITLE
, FALSE
},
1008 { MCHT_NOWHERE
, TRUE
}
1011 MCHITTESTINFO mchit
;
1018 char yearmonth
[80], *locale_month
, *locale_year
;
1019 int month_count
, year_count
;
1022 memset(&mchit
, 0, sizeof(MCHITTESTINFO
));
1024 hwnd
= create_monthcal_control(0);
1026 /* test with invalid structure size */
1027 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
- 1;
1030 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1031 expect(0, mchit
.pt
.x
);
1032 expect(0, mchit
.pt
.y
);
1034 expect(0, mchit
.uHit
);
1035 /* test with invalid pointer */
1036 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, 0);
1039 /* resize control to display single Calendar */
1040 res
= SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
1043 win_skip("Message MCM_GETMINREQRECT unsupported. Skipping.\n");
1044 DestroyWindow(hwnd
);
1047 MoveWindow(hwnd
, 0, 0, r
.right
, r
.bottom
, FALSE
);
1049 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1057 st
.wMilliseconds
= 0;
1060 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st
);
1063 /* (0, 0) is the top left of the control - title */
1064 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
;
1067 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1068 expect(0, mchit
.pt
.x
);
1069 expect(0, mchit
.pt
.y
);
1070 expect(mchit
.uHit
, res
);
1071 expect_hex(MCHT_TITLE
, res
);
1073 /* bottom right of the control and should not be active */
1074 mchit
.pt
.x
= r
.right
;
1075 mchit
.pt
.y
= r
.bottom
;
1076 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1077 expect(r
.right
, mchit
.pt
.x
);
1078 expect(r
.bottom
, mchit
.pt
.y
);
1079 expect(mchit
.uHit
, res
);
1080 todo_wine
expect_hex(MCHT_NOWHERE
, res
);
1082 /* completely out of the control, should not be active */
1083 mchit
.pt
.x
= 2 * r
.right
;
1084 mchit
.pt
.y
= 2 * r
.bottom
;
1085 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1086 expect(2 * r
.right
, mchit
.pt
.x
);
1087 expect(2 * r
.bottom
, mchit
.pt
.y
);
1088 expect(mchit
.uHit
, res
);
1089 todo_wine
expect_hex(MCHT_NOWHERE
, res
);
1091 /* in active area - day of the week */
1092 mchit
.pt
.x
= r
.right
/ 2;
1093 mchit
.pt
.y
= r
.bottom
/ 2;
1094 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1095 expect(r
.right
/ 2, mchit
.pt
.x
);
1096 expect(r
.bottom
/ 2, mchit
.pt
.y
);
1097 expect(mchit
.uHit
, res
);
1098 expect_hex(MCHT_CALENDARDATE
, res
);
1100 /* in active area - day of the week #2 */
1101 mchit
.pt
.x
= r
.right
/ 14; /* half of first day rect */
1102 mchit
.pt
.y
= r
.bottom
/ 2;
1103 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1104 expect(r
.right
/ 14, mchit
.pt
.x
);
1105 expect(r
.bottom
/ 2, mchit
.pt
.y
);
1106 expect(mchit
.uHit
, res
);
1107 expect_hex(MCHT_CALENDARDATE
, res
);
1109 /* in active area - date from prev month */
1110 mchit
.pt
.x
= r
.right
/ 14; /* half of first day rect */
1111 mchit
.pt
.y
= 6 * r
.bottom
/ 19;
1112 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1113 expect(r
.right
/ 14, mchit
.pt
.x
);
1114 expect(6 * r
.bottom
/ 19, mchit
.pt
.y
);
1115 expect(mchit
.uHit
, res
);
1116 expect_hex(MCHT_CALENDARDATEPREV
, res
);
1120 /* (125, 115) is in active area - date from this month */
1123 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1124 expect(125, mchit
.pt
.x
);
1125 expect(115, mchit
.pt
.y
);
1126 expect(mchit
.uHit
, res
);
1127 expect(MCHT_CALENDARDATE
, res
);
1130 /* in active area - date from next month */
1131 mchit
.pt
.x
= 11 * r
.right
/ 14;
1132 mchit
.pt
.y
= 16 * r
.bottom
/ 19;
1133 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1134 expect(11 * r
.right
/ 14, mchit
.pt
.x
);
1135 expect(16 * r
.bottom
/ 19, mchit
.pt
.y
);
1136 expect(mchit
.uHit
, res
);
1137 expect_hex(MCHT_CALENDARDATENEXT
, res
);
1139 /* in active area - today link */
1140 mchit
.pt
.x
= r
.right
/ 14;
1141 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1142 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1143 expect(r
.right
/ 14, mchit
.pt
.x
);
1144 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1145 expect(mchit
.uHit
, res
);
1146 expect_hex(MCHT_TODAYLINK
, res
);
1148 /* in active area - today link */
1149 mchit
.pt
.x
= r
.right
/ 2;
1150 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1151 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1152 expect(r
.right
/ 2, mchit
.pt
.x
);
1153 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1154 expect(mchit
.uHit
, res
);
1155 expect_hex(MCHT_TODAYLINK
, res
);
1157 /* in active area - today link */
1158 mchit
.pt
.x
= r
.right
/ 10;
1159 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1160 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1161 expect(r
.right
/ 10, mchit
.pt
.x
);
1162 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1163 expect(mchit
.uHit
, res
);
1164 expect_hex(MCHT_TODAYLINK
, res
);
1166 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_hit_test_seq
, "monthcal hit test", TRUE
);
1168 /* The horizontal position of title bar elements depends on locale (y pos
1169 is constant), so we sample across a horizontal line and make sure we
1170 find all elements. */
1172 /* Get the format of the title */
1173 GetLocaleInfoA(LOCALE_USER_DEFAULT
, LOCALE_SYEARMONTH
, yearmonth
, 80);
1174 /* Find out if we have a month and/or year */
1175 locale_year
= strstr(yearmonth
, "y");
1176 locale_month
= strstr(yearmonth
, "M");
1179 mchit
.pt
.y
= (5/2) * r
.bottom
/ 19;
1181 old_res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1182 expect_hex(title_hits
[title_index
].ht
, old_res
);
1184 in_the_middle
= FALSE
;
1185 month_count
= year_count
= 0;
1186 for (x
= 0; x
< r
.right
; x
++){
1188 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1189 expect(x
, mchit
.pt
.x
);
1190 expect((5/2) * r
.bottom
/ 19, mchit
.pt
.y
);
1191 expect(mchit
.uHit
, res
);
1192 if (res
!= old_res
) {
1194 if (old_res
== MCHT_TITLEBTNPREV
)
1195 in_the_middle
= TRUE
;
1197 if (res
== MCHT_TITLEBTNNEXT
)
1198 in_the_middle
= FALSE
;
1200 if (in_the_middle
) {
1201 if (res
== MCHT_TITLEMONTH
)
1203 else if (res
== MCHT_TITLEYEAR
)
1208 if (sizeof(title_hits
) / sizeof(title_hits
[0]) <= title_index
)
1211 todo_wine_if(title_hits
[title_index
].todo
)
1212 ok(title_hits
[title_index
].ht
== res
, "Expected %x, got %x, pos %d\n",
1213 title_hits
[title_index
].ht
, res
, x
);
1219 /* There are some limits, even if LOCALE_SYEARMONTH contains rubbish
1220 * or no month/year indicators at all */
1222 todo_wine
ok(month_count
== 1, "Expected 1 month item, got %d\n", month_count
);
1224 ok(month_count
<= 1, "Too many month items: %d\n", month_count
);
1227 todo_wine
ok(year_count
== 1, "Expected 1 year item, got %d\n", year_count
);
1229 ok(year_count
<= 1, "Too many year items: %d\n", year_count
);
1231 todo_wine
ok(month_count
+ year_count
>= 1, "Not enough month and year items\n");
1233 ok(r
.right
<= x
&& title_index
+ 1 == sizeof(title_hits
) / sizeof(title_hits
[0]),
1234 "Wrong title layout\n");
1236 DestroyWindow(hwnd
);
1239 static void test_todaylink(void)
1241 MCHITTESTINFO mchit
;
1242 SYSTEMTIME st_test
, st_new
;
1247 memset(&mchit
, 0, sizeof(MCHITTESTINFO
));
1249 hwnd
= create_monthcal_control(0);
1251 res
= SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
1253 MoveWindow(hwnd
, 0, 0, r
.right
, r
.bottom
, FALSE
);
1255 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1257 /* hit active area - today link */
1258 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
;
1259 mchit
.pt
.x
= r
.right
/ 14;
1260 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1261 res
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1262 expect(r
.right
/ 14, mchit
.pt
.x
);
1263 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1264 expect(mchit
.uHit
, res
);
1265 expect(MCHT_TODAYLINK
, res
);
1269 st_test
.wYear
= 2005;
1271 res
= SendMessageA(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1274 memset(&st_new
, 0, sizeof(st_new
));
1275 res
= SendMessageA(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1277 expect(1, st_new
.wDay
);
1278 expect(1, st_new
.wMonth
);
1279 expect(2005, st_new
.wYear
);
1281 res
= SendMessageA(hwnd
, WM_LBUTTONDOWN
, MK_LBUTTON
, MAKELONG(mchit
.pt
.x
, mchit
.pt
.y
));
1284 memset(&st_new
, 0, sizeof(st_new
));
1285 res
= SendMessageA(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_new
);
1287 expect(1, st_new
.wDay
);
1288 expect(1, st_new
.wMonth
);
1289 expect(2005, st_new
.wYear
);
1291 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_todaylink_seq
, "monthcal hit test", TRUE
);
1293 DestroyWindow(hwnd
);
1296 static void test_today(void)
1298 SYSTEMTIME st_test
, st_new
;
1302 hwnd
= create_monthcal_control(0);
1304 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1306 /* Setter and Getters for "today" information */
1308 /* check for overflow, should be ok */
1309 memset(&st_test
, 0, sizeof(st_test
));
1311 st_test
.wMonth
= 38;
1316 res
= SendMessageA(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1319 res
= SendMessageA(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1322 /* st_test should not change */
1323 expect(38, st_test
.wDay
);
1324 expect(38, st_test
.wMonth
);
1326 /* st_new should change, overflow does not matter */
1327 expect(38, st_new
.wDay
);
1328 expect(38, st_new
.wMonth
);
1330 /* check for zero, should be ok*/
1334 res
= SendMessageA(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1337 res
= SendMessageA(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1340 /* st_test should not change */
1341 expect(0, st_test
.wDay
);
1342 expect(0, st_test
.wMonth
);
1344 /* st_new should change to zero*/
1345 expect(0, st_new
.wDay
);
1346 expect(0, st_new
.wMonth
);
1348 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_today_seq
, "monthcal today", TRUE
);
1350 DestroyWindow(hwnd
);
1353 static void test_scroll(void)
1358 hwnd
= create_monthcal_control(0);
1360 res
= SendMessageA(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1363 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1365 /* Setter and Getters for scroll rate */
1366 res
= SendMessageA(hwnd
, MCM_SETMONTHDELTA
, 2, 0);
1369 res
= SendMessageA(hwnd
, MCM_SETMONTHDELTA
, 3, 0);
1371 res
= SendMessageA(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1374 res
= SendMessageA(hwnd
, MCM_SETMONTHDELTA
, 12, 0);
1376 res
= SendMessageA(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1379 res
= SendMessageA(hwnd
, MCM_SETMONTHDELTA
, 15, 0);
1381 res
= SendMessageA(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1384 res
= SendMessageA(hwnd
, MCM_SETMONTHDELTA
, -5, 0);
1386 res
= SendMessageA(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1389 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_scroll_seq
, "monthcal scroll", FALSE
);
1391 DestroyWindow(hwnd
);
1394 static void test_monthrange(void)
1397 SYSTEMTIME st_visible
[2], st_daystate
[2], st
;
1401 hwnd
= create_monthcal_control(0);
1403 memset(&st_visible
, 0, sizeof(st_visible
));
1404 memset(&st_daystate
, 0, sizeof(st_daystate
));
1412 st
.wMilliseconds
= 0;
1415 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st
);
1418 /* to be locale independent */
1419 SendMessageA(hwnd
, MCM_SETFIRSTDAYOFWEEK
, 0, (LPARAM
)6);
1421 res
= SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
1423 /* resize control to display two Calendars */
1424 MoveWindow(hwnd
, 0, 0, r
.right
, (5/2)*r
.bottom
, FALSE
);
1426 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1428 res
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st_visible
);
1430 expect(2000, st_visible
[0].wYear
);
1431 expect(11, st_visible
[0].wMonth
);
1432 expect(1, st_visible
[0].wDay
);
1433 expect(2000, st_visible
[1].wYear
);
1434 expect(12, st_visible
[1].wMonth
);
1435 expect(31, st_visible
[1].wDay
);
1437 res
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_DAYSTATE
, (LPARAM
)st_daystate
);
1439 expect(2000, st_daystate
[0].wYear
);
1440 expect(10, st_daystate
[0].wMonth
);
1441 expect(29, st_daystate
[0].wDay
);
1442 expect(2001, st_daystate
[1].wYear
);
1443 expect(1, st_daystate
[1].wMonth
);
1444 expect(6, st_daystate
[1].wDay
);
1446 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_monthrange_seq
, "monthcal monthrange", FALSE
);
1448 /* with null date array parameter */
1449 res
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, 0);
1452 res
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_DAYSTATE
, 0);
1455 /* resize control to display single Calendar */
1456 MoveWindow(hwnd
, 0, 0, r
.right
, r
.bottom
, FALSE
);
1458 memset(&st
, 0, sizeof(st
));
1463 res
= SendMessageA(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st
);
1466 /* September 1752 has 19 days */
1467 res
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st_visible
);
1470 expect(1752, st_visible
[0].wYear
);
1471 expect(9, st_visible
[0].wMonth
);
1472 ok(14 == st_visible
[0].wDay
||
1473 broken(1 == st_visible
[0].wDay
), /* comctl32 <= 4.72 */
1474 "Expected 14, got %d\n", st_visible
[0].wDay
);
1476 expect(1752, st_visible
[1].wYear
);
1477 expect(9, st_visible
[1].wMonth
);
1478 expect(19, st_visible
[1].wDay
);
1480 DestroyWindow(hwnd
);
1483 static void test_maxselday(void)
1489 hwnd
= create_monthcal_control(0);
1490 /* if no style specified default to 1 */
1491 res
= SendMessageA(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1493 res
= SendMessageA(hwnd
, MCM_SETMAXSELCOUNT
, 5, 0);
1495 res
= SendMessageA(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1498 /* try to set style */
1499 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1500 SetWindowLongA(hwnd
, GWL_STYLE
, style
| MCS_MULTISELECT
);
1501 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1502 ok(!(style
& MCS_MULTISELECT
), "Expected MCS_MULTISELECT not to be set\n");
1503 DestroyWindow(hwnd
);
1505 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1506 /* try to remove style */
1507 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1508 SetWindowLongA(hwnd
, GWL_STYLE
, style
& ~MCS_MULTISELECT
);
1509 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1510 ok(style
& MCS_MULTISELECT
, "Expected MCS_MULTISELECT to be set\n");
1511 DestroyWindow(hwnd
);
1513 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1515 /* default width is a week */
1516 res
= SendMessageA(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1519 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1521 /* Setter and Getters for max selected days */
1522 res
= SendMessageA(hwnd
, MCM_SETMAXSELCOUNT
, 5, 0);
1524 res
= SendMessageA(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1527 res
= SendMessageA(hwnd
, MCM_SETMAXSELCOUNT
, 15, 0);
1529 res
= SendMessageA(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1532 /* test invalid value */
1533 res
= SendMessageA(hwnd
, MCM_SETMAXSELCOUNT
, -1, 0);
1535 res
= SendMessageA(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1538 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_max_sel_day_seq
, "monthcal MaxSelDay", FALSE
);
1540 /* zero value is invalid too */
1541 res
= SendMessageA(hwnd
, MCM_SETMAXSELCOUNT
, 0, 0);
1543 res
= SendMessageA(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1546 DestroyWindow(hwnd
);
1549 static void test_size(void)
1553 HFONT hFont1
, hFont2
;
1557 hwnd
= create_monthcal_control(0);
1559 lstrcpyA(logfont
.lfFaceName
, "Arial");
1560 memset(&logfont
, 0, sizeof(logfont
));
1561 logfont
.lfHeight
= 12;
1562 hFont1
= CreateFontIndirectA(&logfont
);
1564 logfont
.lfHeight
= 24;
1565 hFont2
= CreateFontIndirectA(&logfont
);
1567 /* initialize to a font we can compare against */
1568 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)hFont1
, 0);
1569 res
= SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r1
);
1570 ok(res
, "SendMessageA(MCM_GETMINREQRECT) failed\n");
1572 /* check that setting a larger font results in an larger rect */
1573 SendMessageA(hwnd
, WM_SETFONT
, (WPARAM
)hFont2
, 0);
1574 res
= SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r2
);
1575 ok(res
, "SendMessageA(MCM_GETMINREQRECT) failed\n");
1577 OffsetRect(&r1
, -r1
.left
, -r1
.top
);
1578 OffsetRect(&r2
, -r2
.left
, -r2
.top
);
1580 ok(r1
.bottom
< r2
.bottom
, "Failed to get larger rect with larger font\n");
1582 DestroyWindow(hwnd
);
1585 static void test_create(void)
1589 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1591 hwnd
= create_monthcal_control(0);
1592 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_monthcal_control_seq
, "create monthcal control", TRUE
);
1594 DestroyWindow(hwnd
);
1596 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1597 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1598 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_monthcal_multi_sel_style_seq
, "create monthcal (multi sel style)", TRUE
);
1599 DestroyWindow(hwnd
);
1602 static void test_destroy(void)
1606 hwnd
= create_monthcal_control(0);
1607 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1608 DestroyWindow(hwnd
);
1609 ok_sequence(sequences
, PARENT_SEQ_INDEX
, destroy_monthcal_parent_msgs_seq
, "Destroy monthcal (parent msg)", FALSE
);
1610 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, destroy_monthcal_child_msgs_seq
, "Destroy monthcal (child msg)", FALSE
);
1612 /* MCS_MULTISELECT */
1613 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1614 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1615 DestroyWindow(hwnd
);
1616 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, destroy_monthcal_multi_sel_style_seq
, "Destroy monthcal (multi sel style)", FALSE
);
1619 static void test_selrange(void)
1622 SYSTEMTIME st
, range
[2], range2
[2];
1623 BOOL ret
, old_comctl32
= FALSE
;
1625 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1627 /* just after creation selection should start and end today */
1628 ret
= SendMessageA(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st
);
1631 memset(range
, 0xcc, sizeof(range
));
1632 ret
= SendMessageA(hwnd
, MCM_GETSELRANGE
, 0, (LPARAM
)range
);
1634 expect(st
.wYear
, range
[0].wYear
);
1635 expect(st
.wMonth
, range
[0].wMonth
);
1636 expect(st
.wDay
, range
[0].wDay
);
1637 if (range
[0].wDayOfWeek
!= st
.wDayOfWeek
)
1639 win_skip("comctl32 <= 4.70 doesn't set some values\n");
1640 old_comctl32
= TRUE
;
1644 expect(st
.wDayOfWeek
, range
[0].wDayOfWeek
);
1645 expect(st
.wHour
, range
[0].wHour
);
1646 expect(st
.wMinute
, range
[0].wMinute
);
1647 expect(st
.wSecond
, range
[0].wSecond
);
1648 expect(st
.wMilliseconds
, range
[0].wMilliseconds
);
1651 expect(st
.wYear
, range
[1].wYear
);
1652 expect(st
.wMonth
, range
[1].wMonth
);
1653 expect(st
.wDay
, range
[1].wDay
);
1656 expect(st
.wDayOfWeek
, range
[1].wDayOfWeek
);
1657 expect(st
.wHour
, range
[1].wHour
);
1658 expect(st
.wMinute
, range
[1].wMinute
);
1659 expect(st
.wSecond
, range
[1].wSecond
);
1660 expect(st
.wMilliseconds
, range
[1].wMilliseconds
);
1663 /* bounds are swapped if min > max */
1664 memset(&range
[0], 0, sizeof(range
[0]));
1665 range
[0].wYear
= 2009;
1666 range
[0].wMonth
= 10;
1668 range
[1] = range
[0];
1671 ret
= SendMessageA(hwnd
, MCM_SETSELRANGE
, 0, (LPARAM
)range
);
1674 ret
= SendMessageA(hwnd
, MCM_GETSELRANGE
, 0, (LPARAM
)range2
);
1677 expect(range
[1].wYear
, range2
[0].wYear
);
1678 expect(range
[1].wMonth
, range2
[0].wMonth
);
1679 expect(range
[1].wDay
, range2
[0].wDay
);
1680 expect(6, range2
[0].wDayOfWeek
);
1681 expect(range
[1].wHour
, range2
[0].wHour
);
1682 expect(range
[1].wMinute
, range2
[0].wMinute
);
1683 expect(range
[1].wSecond
, range2
[0].wSecond
);
1684 expect(range
[1].wMilliseconds
, range2
[0].wMilliseconds
);
1686 expect(range
[0].wYear
, range2
[1].wYear
);
1687 expect(range
[0].wMonth
, range2
[1].wMonth
);
1688 expect(range
[0].wDay
, range2
[1].wDay
);
1689 expect(1, range2
[1].wDayOfWeek
);
1690 expect(range
[0].wHour
, range2
[1].wHour
);
1691 expect(range
[0].wMinute
, range2
[1].wMinute
);
1692 expect(range
[0].wSecond
, range2
[1].wSecond
);
1693 expect(range
[0].wMilliseconds
, range2
[1].wMilliseconds
);
1695 /* try with range larger than maximum configured */
1696 memset(&range
[0], 0, sizeof(range
[0]));
1697 range
[0].wYear
= 2009;
1698 range
[0].wMonth
= 10;
1700 range
[1] = range
[0];
1702 ret
= SendMessageA(hwnd
, MCM_SETSELRANGE
, 0, (LPARAM
)range
);
1705 range
[1] = range
[0];
1706 /* default max. range is 7 days */
1709 ret
= SendMessageA(hwnd
, MCM_SETSELRANGE
, 0, (LPARAM
)range
);
1712 ret
= SendMessageA(hwnd
, MCM_GETSELRANGE
, 0, (LPARAM
)range2
);
1715 expect(range
[0].wYear
, range2
[0].wYear
);
1716 expect(range
[0].wMonth
, range2
[0].wMonth
);
1717 expect(range
[0].wDay
, range2
[0].wDay
);
1718 expect(range
[0].wYear
, range2
[1].wYear
);
1719 expect(range
[0].wMonth
, range2
[1].wMonth
);
1720 expect(range
[0].wDay
, range2
[1].wDay
);
1722 DestroyWindow(hwnd
);
1725 static void test_killfocus(void)
1730 hwnd
= create_monthcal_control(0);
1732 /* make parent invisible */
1733 style
= GetWindowLongA(parent_wnd
, GWL_STYLE
);
1734 SetWindowLongA(parent_wnd
, GWL_STYLE
, style
& ~WS_VISIBLE
);
1736 SendMessageA(hwnd
, WM_KILLFOCUS
, (WPARAM
)GetDesktopWindow(), 0);
1738 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1739 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
1741 style
= GetWindowLongA(parent_wnd
, GWL_STYLE
);
1742 SetWindowLongA(parent_wnd
, GWL_STYLE
, style
| WS_VISIBLE
);
1744 DestroyWindow(hwnd
);
1747 static void test_hittest_v6(void)
1749 MCHITTESTINFO mchit
;
1754 hwnd
= create_monthcal_control(0);
1755 SendMessageA(hwnd
, MCM_SETCALENDARBORDER
, TRUE
, 0);
1757 SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
1758 /* reserving some area around calendar */
1759 MoveWindow(hwnd
, 0, 0, r
.right
* 3 / 2, r
.bottom
* 3 / 2, FALSE
);
1760 mchit
.cbSize
= sizeof(MCHITTESTINFO
);
1761 mchit
.pt
.x
= mchit
.pt
.y
= 0;
1765 ret
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1768 win_skip("Only MCHITTESTINFO_V1 supported\n");
1769 DestroyWindow(hwnd
);
1772 todo_wine
expect_hex(MCHT_NOWHERE
, ret
);
1773 expect(-1, mchit
.iOffset
);
1774 expect(-1, mchit
.iRow
);
1775 expect(-1, mchit
.iCol
);
1777 MoveWindow(hwnd
, 0, 0, r
.right
, r
.bottom
, FALSE
);
1778 mchit
.pt
.x
= r
.right
/ 2;
1779 mchit
.pt
.y
= r
.bottom
/ 2;
1781 ret
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1782 expect_hex(MCHT_CALENDARDATE
, ret
);
1783 expect(0, mchit
.iOffset
);
1786 mchit
.pt
.x
= r
.right
/ (7*2);
1787 mchit
.pt
.y
= r
.bottom
/ 2;
1789 mchit
.iCol
= mchit
.iRow
= -1;
1791 mchit
.rc
.left
= mchit
.rc
.right
= mchit
.rc
.top
= mchit
.rc
.bottom
= -1;
1792 ret
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1793 expect_hex(MCHT_CALENDARDATE
, ret
);
1794 expect_hex(MCHT_CALENDARDATE
, mchit
.uHit
);
1795 expect(0, mchit
.iOffset
);
1796 expect(2, mchit
.iRow
);
1797 expect(0, mchit
.iCol
);
1798 /* returned a one day rectangle */
1799 expect_d(r
.right
/ 7, mchit
.rc
.right
- mchit
.rc
.left
);
1800 expect_d(r
.bottom
/ 10, mchit
.rc
.bottom
- mchit
.rc
.top
);
1806 mchit
.iCol
= mchit
.iRow
= -1;
1808 mchit
.rc
.left
= mchit
.rc
.right
= mchit
.rc
.top
= mchit
.rc
.bottom
= -1;
1809 ret
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1810 expect_hex(MCHT_TITLE
, ret
);
1811 expect_hex(MCHT_TITLE
, mchit
.uHit
);
1812 expect(0, mchit
.iOffset
);
1813 expect(-1, mchit
.iRow
);
1814 expect(-1, mchit
.iCol
);
1815 expect(0, mchit
.rc
.left
);
1816 expect(0, mchit
.rc
.top
);
1817 expect_d(r
.right
, mchit
.rc
.right
);
1818 ok(mchit
.rc
.bottom
> 0, "got %d\n", mchit
.rc
.bottom
);
1820 /* between two calendars */
1821 MoveWindow(hwnd
, 0, 0, r
.right
* 5/2, r
.bottom
, FALSE
);
1822 mchit
.pt
.x
= r
.right
/ (5*4);
1823 mchit
.pt
.y
= r
.bottom
/ 2;
1825 mchit
.iCol
= mchit
.iRow
= -2;
1827 mchit
.rc
.left
= mchit
.rc
.right
= mchit
.rc
.top
= mchit
.rc
.bottom
= -1;
1828 ret
= SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1829 todo_wine
expect_hex(MCHT_NOWHERE
, ret
);
1830 todo_wine
expect_hex(MCHT_NOWHERE
, mchit
.uHit
);
1831 expect(-2, mchit
.iOffset
);
1832 expect(-2, mchit
.iRow
);
1833 expect(-2, mchit
.iCol
);
1834 todo_wine
expect(0, mchit
.rc
.left
);
1835 todo_wine
expect(0, mchit
.rc
.top
);
1836 todo_wine
expect_d(r
.right
* 5/2, mchit
.rc
.right
);
1837 todo_wine
expect_d(r
.bottom
, mchit
.rc
.bottom
);
1839 DestroyWindow(hwnd
);
1842 static void test_get_set_border(void)
1847 hwnd
= create_monthcal_control(0);
1849 /* a non-default value */
1850 ret
= SendMessageA(hwnd
, MCM_SETCALENDARBORDER
, TRUE
, 10);
1853 ret
= SendMessageA(hwnd
, MCM_GETCALENDARBORDER
, 0, 0);
1857 skip("MCM_GET/SETCALENDARBORDER not supported\n");
1858 DestroyWindow(hwnd
);
1864 DestroyWindow(hwnd
);
1867 static void test_MCM_SIZERECTTOMIN(void)
1873 hwnd
= create_monthcal_control(0);
1875 ret
= SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r2
);
1878 win_skip("Message MCM_GETMINREQRECT unsupported. Skipping.\n");
1879 DestroyWindow(hwnd
);
1883 ret
= SendMessageA(hwnd
, MCM_SIZERECTTOMIN
, 0, 0);
1884 ok(ret
== 0, "got %d\n", ret
);
1887 ret
= SendMessageA(hwnd
, MCM_SIZERECTTOMIN
, 0, (LPARAM
)&r
);
1890 skip("Message MCM_SIZERECTTOMIN unsupported. Skipping.\n");
1891 DestroyWindow(hwnd
);
1894 ok(ret
== 1, "got %d\n", ret
);
1895 ok(r
.left
== 0 && r
.right
> 0, "got %d, %d\n", r
.left
, r
.right
);
1898 ret
= SendMessageA(hwnd
, MCM_SIZERECTTOMIN
, 0, (LPARAM
)&r
);
1899 ok(ret
== 1, "got %d\n", ret
);
1901 r2
.right
= (r2
.right
- r2
.left
) * 3;
1902 r2
.bottom
= (r2
.bottom
- r2
.top
) * 3;
1903 r2
.left
= r2
.top
= 0;
1904 ret
= SendMessageA(hwnd
, MCM_SIZERECTTOMIN
, 0, (LPARAM
)&r2
);
1905 ok(ret
== 1, "got %d\n", ret
);
1907 DestroyWindow(hwnd
);
1910 static void test_MCM_GETCALENDARCOUNT(void)
1915 hwnd
= create_monthcal_control(0);
1917 ret
= SendMessageA(hwnd
, MCM_GETCALENDARCOUNT
, 0, 0);
1920 win_skip("Message MCM_GETCALENDARCOUNT unsupported. Skipping.\n");
1921 DestroyWindow(hwnd
);
1927 DestroyWindow(hwnd
);
1930 static void test_daystate(void)
1932 MONTHDAYSTATE state
[4];
1937 /* without MCS_DAYSTATE */
1938 hwnd
= create_monthcal_control(0);
1940 ret
= SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
1943 /* resize control to display two Calendars */
1944 MoveWindow(hwnd
, 0, 0, r
.right
, (5/2)*r
.bottom
, FALSE
);
1946 ret
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_DAYSTATE
, 0);
1949 ret
= SendMessageA(hwnd
, MCM_SETDAYSTATE
, 4, (LPARAM
)&state
);
1952 ret
= SendMessageA(hwnd
, MCM_SETDAYSTATE
, 2, (LPARAM
)&state
);
1955 ret
= SendMessageA(hwnd
, MCM_SETDAYSTATE
, 0, 0);
1958 /* try to switch on */
1959 SetWindowLongA(hwnd
, GWL_STYLE
, GetWindowLongA(hwnd
, GWL_STYLE
) | MCS_DAYSTATE
);
1960 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1961 ok((style
& MCS_DAYSTATE
) == 0, "got 0x%08x\n", style
);
1963 DestroyWindow(hwnd
);
1965 /* with MCS_DAYSTATE */
1966 hwnd
= create_monthcal_control(MCS_DAYSTATE
);
1968 ret
= SendMessageA(hwnd
, MCM_GETMONTHRANGE
, GMR_DAYSTATE
, 0);
1971 ret
= SendMessageA(hwnd
, MCM_SETDAYSTATE
, 4, (LPARAM
)&state
);
1974 ret
= SendMessageA(hwnd
, MCM_SETDAYSTATE
, 2, (LPARAM
)&state
);
1977 ret
= SendMessageA(hwnd
, MCM_SETDAYSTATE
, 0, 0);
1980 /* try to switch off */
1981 SetWindowLongA(hwnd
, GWL_STYLE
, GetWindowLongA(hwnd
, GWL_STYLE
) & ~MCS_DAYSTATE
);
1982 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1983 ok((style
& MCS_DAYSTATE
) == MCS_DAYSTATE
, "got 0x%08x\n", style
);
1985 DestroyWindow(hwnd
);
1988 static void test_sel_notify(void)
1998 MCHITTESTINFO mchit
= {sizeof(MCHITTESTINFO
)};
2000 Monthcal_style styles
[] = {
2001 {MCS_NOTODAY
, "MCS_NOTODAY"},
2002 {MCS_NOTODAY
| MCS_MULTISELECT
, "MCS_NOTODAY | MCS_MULTISELECT"},
2003 {MCS_DAYSTATE
, "MCS_DAYSTATE"},
2004 {MCS_DAYSTATE
| MCS_MULTISELECT
, "MCS_DAYSTATE | MCS_MULTISELECT"}
2008 for(i
= 0; i
< sizeof styles
/ sizeof styles
[0]; i
++)
2010 hwnd
= create_monthcal_control(styles
[i
].val
);
2011 SetWindowLongPtrA(hwnd
, GWLP_ID
, SEL_NOTIFY_TEST_ID
);
2012 SendMessageA(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&rc
);
2013 MoveWindow(hwnd
, 0, 0, rc
.right
, rc
.bottom
, FALSE
);
2014 /* Simulate mouse click on some unselected day to generate
2015 MCN_SELECT and MCN_SELCHANGE notifications */
2016 mchit
.pt
.x
= rc
.right
/ 2;
2017 mchit
.pt
.y
= rc
.bottom
/ 2;
2018 SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
2019 SendMessageA(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st
);
2020 while(st
.wDay
== mchit
.st
.wDay
) /* Ensure that mchit.pt points to unselected day */
2023 SendMessageA(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
2025 SendMessageA(hwnd
, WM_LBUTTONDOWN
, 0, MAKELPARAM(mchit
.pt
.x
, mchit
.pt
.y
));
2026 SendMessageA(hwnd
, WM_LBUTTONUP
, 0, MAKELPARAM(mchit
.pt
.x
, mchit
.pt
.y
));
2027 DestroyWindow(hwnd
);
2031 START_TEST(monthcal
)
2033 BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
2034 INITCOMMONCONTROLSEX iccex
;
2037 ULONG_PTR ctx_cookie
;
2040 hComctl32
= GetModuleHandleA("comctl32.dll");
2041 pInitCommonControlsEx
= (void*)GetProcAddress(hComctl32
, "InitCommonControlsEx");
2042 if (!pInitCommonControlsEx
)
2044 win_skip("InitCommonControlsEx() is missing. Skipping the tests\n");
2047 iccex
.dwSize
= sizeof(iccex
);
2048 iccex
.dwICC
= ICC_DATE_CLASSES
;
2049 pInitCommonControlsEx(&iccex
);
2053 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
2055 parent_wnd
= create_parent_window();
2075 if (!load_v6_module(&ctx_cookie
, &hCtx
))
2077 DestroyWindow(parent_wnd
);
2082 test_get_set_border();
2083 test_MCM_SIZERECTTOMIN();
2084 test_MCM_GETCALENDARCOUNT();
2086 unload_v6_module(ctx_cookie
, hCtx
);
2088 DestroyWindow(parent_wnd
);