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
30 #include "wine/test.h"
35 #define expect(expected, got) ok(expected == got, "Expected %d, got %d\n", expected, got);
36 #define expect_hex(expected, got) ok(expected == got, "Expected %x, got %x\n", expected, got);
38 #define NUM_MSG_SEQUENCES 2
39 #define PARENT_SEQ_INDEX 0
40 #define MONTHCAL_SEQ_INDEX 1
42 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
44 static HWND parent_wnd
;
46 static const struct message create_parent_window_seq
[] = {
47 { WM_GETMINMAXINFO
, sent
},
48 { WM_NCCREATE
, sent
},
49 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
51 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
52 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
53 { WM_QUERYNEWPALETTE
, sent
|optional
},
54 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, 0 },
55 { WM_WINDOWPOSCHANGED
, sent
|optional
},
56 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
57 { WM_NCACTIVATE
, sent
},
58 { WM_ACTIVATE
, sent
|wparam
, 1 },
59 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
60 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
61 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
62 /* Win9x adds SWP_NOZORDER below */
63 { WM_WINDOWPOSCHANGED
, sent
, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
64 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
70 static const struct message create_monthcal_control_seq
[] = {
71 { WM_NOTIFYFORMAT
, sent
|lparam
, 0, NF_QUERY
},
72 { WM_QUERYUISTATE
, sent
|optional
},
74 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
},
78 static const struct message create_monthcal_multi_sel_style_seq
[] = {
79 { WM_NOTIFYFORMAT
, sent
|lparam
, 0, NF_QUERY
},
80 { WM_QUERYUISTATE
, sent
|optional
},
82 { WM_PARENTNOTIFY
, sent
},
86 static const struct message monthcal_color_seq
[] = {
87 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, 0},
88 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, RGB(0,0,0)},
89 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, 0},
90 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, RGB(255,255,255)},
91 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, 0},
93 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, 0},
94 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, RGB(0,0,0)},
95 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, 0},
96 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, RGB(255,255,255)},
97 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, 0},
99 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, 0},
100 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, RGB(0,0,0)},
101 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, 0},
102 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, RGB(255,255,255)},
103 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, 0},
105 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, 0},
106 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, RGB(0,0,0)},
107 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, 0},
108 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, RGB(255,255,255)},
109 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, 0},
111 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, 0},
112 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, RGB(0,0,0)},
113 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, 0},
114 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, RGB(255,255,255)},
115 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, 0},
117 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, 0},
118 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, RGB(0,0,0)},
119 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, 0},
120 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, RGB(255,255,255)},
121 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, 0},
125 static const struct message monthcal_curr_date_seq
[] = {
126 { MCM_SETCURSEL
, sent
|wparam
, 0},
127 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
128 { MCM_SETCURSEL
, sent
|wparam
, 0},
129 { MCM_SETCURSEL
, sent
|wparam
, 0},
130 { MCM_GETCURSEL
, sent
|wparam
, 0},
131 { MCM_GETCURSEL
, sent
|wparam
|lparam
, 0, 0},
135 static const struct message monthcal_first_day_seq
[] = {
136 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
138 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -5},
139 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
141 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -4},
142 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
144 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -3},
145 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
147 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -2},
148 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
150 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -1},
151 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
153 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
154 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
156 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 1},
157 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
159 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 2},
160 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
162 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 3},
163 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
165 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 4},
166 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
168 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 5},
169 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
171 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 6},
172 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
174 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 7},
175 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
177 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 8},
178 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
180 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 9},
181 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
183 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 10},
184 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
186 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 11},
187 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
191 static const struct message monthcal_unicode_seq
[] = {
192 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
193 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 1, 0},
194 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
195 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
196 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
197 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 1, 0},
201 static const struct message monthcal_hit_test_seq
[] = {
202 { MCM_SETCURSEL
, sent
|wparam
, 0},
203 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
204 { MCM_HITTEST
, sent
|wparam
, 0},
205 { MCM_HITTEST
, sent
|wparam
, 0},
206 { MCM_HITTEST
, sent
|wparam
, 0},
207 { MCM_HITTEST
, sent
|wparam
, 0},
208 { MCM_HITTEST
, sent
|wparam
, 0},
209 { MCM_HITTEST
, sent
|wparam
, 0},
210 { MCM_HITTEST
, sent
|wparam
, 0},
211 { MCM_HITTEST
, sent
|wparam
, 0},
212 { MCM_HITTEST
, sent
|wparam
, 0},
213 { MCM_HITTEST
, sent
|wparam
, 0},
217 static const struct message monthcal_todaylink_seq
[] = {
218 { MCM_HITTEST
, sent
|wparam
, 0},
219 { MCM_SETTODAY
, sent
|wparam
, 0},
220 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
221 { MCM_GETTODAY
, sent
|wparam
, 0},
222 { WM_LBUTTONDOWN
, sent
|wparam
, MK_LBUTTON
},
223 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
224 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
225 { MCM_GETCURSEL
, sent
|wparam
, 0},
229 static const struct message monthcal_today_seq
[] = {
230 { MCM_SETTODAY
, sent
|wparam
, 0},
231 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
232 { MCM_GETTODAY
, sent
|wparam
, 0},
233 { MCM_SETTODAY
, sent
|wparam
, 0},
234 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
235 { MCM_GETTODAY
, sent
|wparam
, 0},
239 static const struct message monthcal_scroll_seq
[] = {
240 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 2, 0},
241 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 3, 0},
242 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
243 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 12, 0},
244 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
245 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 15, 0},
246 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
247 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, -5, 0},
248 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
252 static const struct message monthcal_monthrange_seq
[] = {
253 { MCM_GETMONTHRANGE
, sent
|wparam
, GMR_VISIBLE
},
254 { MCM_GETMONTHRANGE
, sent
|wparam
, GMR_DAYSTATE
},
258 static const struct message monthcal_max_sel_day_seq
[] = {
259 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, 5, 0},
260 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
261 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, 15, 0},
262 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
263 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, -1, 0},
264 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
268 /* expected message sequence for parent*/
269 static const struct message destroy_monthcal_parent_msgs_seq
[] = {
270 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
},
274 /* expected message sequence for child*/
275 static const struct message destroy_monthcal_child_msgs_seq
[] = {
276 { 0x0090, sent
|optional
}, /* Vista */
277 { WM_SHOWWINDOW
, sent
|wparam
|lparam
, 0, 0},
278 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0},
279 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0},
280 { WM_DESTROY
, sent
|wparam
|lparam
, 0, 0},
281 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, 0},
285 static const struct message destroy_monthcal_multi_sel_style_seq
[] = {
286 { 0x0090, sent
|optional
}, /* Vista */
287 { WM_SHOWWINDOW
, sent
|wparam
|lparam
, 0, 0},
288 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0},
289 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0},
290 { WM_DESTROY
, sent
|wparam
|lparam
, 0, 0},
291 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, 0},
295 /* expected message sequence for parent window*/
296 static const struct message destroy_parent_seq
[] = {
297 { 0x0090, sent
|optional
}, /* Vista */
298 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0},
299 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0},
300 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0},
301 { WM_IME_NOTIFY
, sent
|wparam
|lparam
|defwinproc
|optional
, 1, 0},
302 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0},
303 { WM_ACTIVATE
, sent
|wparam
|optional
, 0},
304 { WM_NCACTIVATE
, sent
|wparam
|lparam
|optional
, 0, 0},
305 { WM_ACTIVATE
, sent
|wparam
|lparam
|optional
, 0, 0},
306 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0},
307 { WM_KILLFOCUS
, sent
|wparam
|lparam
|optional
, 0, 0},
308 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0},
309 { WM_IME_NOTIFY
, sent
|wparam
|lparam
|defwinproc
|optional
, 1, 0},
310 { WM_DESTROY
, sent
|wparam
|lparam
, 0, 0},
311 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, 0},
315 static void test_monthcal(void)
318 SYSTEMTIME st
[2], st1
[2], today
;
319 int res
, month_range
;
322 hwnd
= CreateWindowA(MONTHCAL_CLASSA
, "MonthCal", WS_POPUP
| WS_VISIBLE
, CW_USEDEFAULT
,
323 0, 300, 300, 0, 0, NULL
, NULL
);
324 ok(hwnd
!= NULL
, "Failed to create MonthCal\n");
326 /* test range just after creation */
327 memset(&st
, 0xcc, sizeof(st
));
328 limits
= SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st
);
330 broken(limits
== GDTR_MIN
), /* comctl32 <= 4.70 */
331 "No limits should be set (%d)\n", limits
);
332 if (limits
== GDTR_MIN
)
334 win_skip("comctl32 <= 4.70 is broken\n");
339 ok(0 == st
[0].wYear
||
340 broken(1752 == st
[0].wYear
), /* comctl32 <= 4.72 */
341 "Expected 0, got %d\n", st
[0].wYear
);
342 ok(0 == st
[0].wMonth
||
343 broken(9 == st
[0].wMonth
), /* comctl32 <= 4.72 */
344 "Expected 0, got %d\n", st
[0].wMonth
);
345 ok(0 == st
[0].wDay
||
346 broken(14 == st
[0].wDay
), /* comctl32 <= 4.72 */
347 "Expected 0, got %d\n", st
[0].wDay
);
348 expect(0, st
[0].wDayOfWeek
);
349 expect(0, st
[0].wHour
);
350 expect(0, st
[0].wMinute
);
351 expect(0, st
[0].wSecond
);
352 expect(0, st
[0].wMilliseconds
);
354 expect(0, st
[1].wYear
);
355 expect(0, st
[1].wMonth
);
356 expect(0, st
[1].wDay
);
357 expect(0, st
[1].wDayOfWeek
);
358 expect(0, st
[1].wHour
);
359 expect(0, st
[1].wMinute
);
360 expect(0, st
[1].wSecond
);
361 expect(0, st
[1].wMilliseconds
);
363 GetSystemTime(&st
[0]);
366 SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&today
);
368 /* Invalid date/time */
370 /* Time should not matter */
371 st
[1].wHour
= st
[1].wMinute
= st
[1].wSecond
= 70;
372 st
[1].wMilliseconds
= 1200;
373 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set MAX limit\n");
374 /* invalid timestamp is written back with today data and msecs untouched */
375 expect(today
.wHour
, st
[1].wHour
);
376 expect(today
.wMinute
, st
[1].wMinute
);
377 expect(today
.wSecond
, st
[1].wSecond
);
378 expect(1200, st
[1].wMilliseconds
);
380 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
381 ok(st1
[0].wYear
!= 2000, "Lower limit changed\n");
382 /* invalid timestamp should be replaced with today data, except msecs */
383 expect(today
.wHour
, st1
[1].wHour
);
384 expect(today
.wMinute
, st1
[1].wMinute
);
385 expect(today
.wSecond
, st1
[1].wSecond
);
386 expect(1200, st1
[1].wMilliseconds
);
388 /* Invalid date/time with invalid milliseconds only */
389 GetSystemTime(&st
[0]);
391 /* Time should not matter */
392 st
[1].wMilliseconds
= 1200;
393 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set MAX limit\n");
394 /* invalid milliseconds field doesn't lead to invalid timestamp */
395 expect(st
[0].wHour
, st
[1].wHour
);
396 expect(st
[0].wMinute
, st
[1].wMinute
);
397 expect(st
[0].wSecond
, st
[1].wSecond
);
398 expect(1200, st
[1].wMilliseconds
);
400 GetSystemTime(&st
[0]);
403 ok(!SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Should have failed to set limits\n");
404 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
405 ok(st1
[0].wYear
!= 2000, "Lower limit changed\n");
406 ok(!SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Should have failed to set MAX limit\n");
407 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
408 ok(st1
[0].wYear
!= 2000, "Lower limit changed\n");
410 GetSystemTime(&st
[0]);
415 month_range
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
417 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Failed to set both min and max limits\n");
418 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
419 ok(res
== month_range
, "Invalid month range (%d)\n", res
);
420 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
), "Limits should be set\n");
423 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Failed to set both min and max limits\n");
424 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
425 ok(res
== month_range
, "Invalid month range (%d)\n", res
);
428 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Failed to set both min and max limits\n");
430 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Failed to set both min and max limits\n");
433 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
434 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "Only MAX limit should be set\n");
436 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
438 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
440 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
441 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "Only MAX limit should be set\n");
443 /* set both limits, then set max < min */
444 GetSystemTime(&st
[0]);
447 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
|GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
448 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
), "Min limit expected\n");
450 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
451 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "Max limit expected\n");
453 expect(0, st1
[0].wYear
);
454 expect(0, st1
[0].wMonth
);
455 expect(0, st1
[0].wDay
);
456 expect(0, st1
[0].wDayOfWeek
);
457 expect(0, st1
[0].wHour
);
458 expect(0, st1
[0].wMinute
);
459 expect(0, st1
[0].wSecond
);
460 expect(0, st1
[0].wMilliseconds
);
462 expect(st
[1].wYear
, st1
[1].wYear
);
463 expect(st
[1].wMonth
, st1
[1].wMonth
);
464 expect(st
[1].wDay
, st1
[1].wDay
);
465 expect(st
[1].wDayOfWeek
, st1
[1].wDayOfWeek
);
466 expect(st
[1].wHour
, st1
[1].wHour
);
467 expect(st
[1].wMinute
, st1
[1].wMinute
);
468 expect(st
[1].wSecond
, st1
[1].wSecond
);
469 expect(st
[1].wMilliseconds
, st1
[1].wMilliseconds
);
473 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
|GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
474 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
), "Min limit expected\n");
475 st
[0].wYear
++; /* start == end now */
476 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
, (LPARAM
)st
), "Failed to set limits\n");
477 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MIN
, "Min limit expected\n");
479 expect(st
[0].wYear
, st1
[0].wYear
);
480 expect(st
[0].wMonth
, st1
[0].wMonth
);
481 expect(st
[0].wDay
, st1
[0].wDay
);
482 expect(st
[0].wDayOfWeek
, st1
[0].wDayOfWeek
);
483 expect(st
[0].wHour
, st1
[0].wHour
);
484 expect(st
[0].wMinute
, st1
[0].wMinute
);
485 expect(st
[0].wSecond
, st1
[0].wSecond
);
486 expect(st
[0].wMilliseconds
, st1
[0].wMilliseconds
);
488 expect(0, st1
[1].wYear
);
489 expect(0, st1
[1].wMonth
);
490 expect(0, st1
[1].wDay
);
491 expect(0, st1
[1].wDayOfWeek
);
492 expect(0, st1
[1].wHour
);
493 expect(0, st1
[1].wMinute
);
494 expect(0, st1
[1].wSecond
);
495 expect(0, st1
[1].wMilliseconds
);
500 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
502 static LONG defwndproc_counter
= 0;
506 /* log system messages, except for painting */
507 if (message
< WM_USER
&&
508 message
!= WM_PAINT
&&
509 message
!= WM_ERASEBKGND
&&
510 message
!= WM_NCPAINT
&&
511 message
!= WM_NCHITTEST
&&
512 message
!= WM_GETTEXT
&&
513 message
!= WM_GETICON
&&
514 message
!= WM_DEVICECHANGE
)
516 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
518 msg
.message
= message
;
519 msg
.flags
= sent
|wparam
|lparam
;
520 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
523 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
526 defwndproc_counter
++;
527 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
528 defwndproc_counter
--;
533 static BOOL
register_parent_wnd_class(void)
538 cls
.lpfnWndProc
= parent_wnd_proc
;
541 cls
.hInstance
= GetModuleHandleA(NULL
);
543 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
544 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
545 cls
.lpszMenuName
= NULL
;
546 cls
.lpszClassName
= "Month-Cal test parent class";
547 return RegisterClassA(&cls
);
550 static HWND
create_parent_window(void)
554 InitCommonControls();
556 /* flush message sequences, so we can check the new sequence by the end of function */
557 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
559 if (!register_parent_wnd_class())
562 hwnd
= CreateWindowEx(0, "Month-Cal test parent class",
563 "Month-Cal test parent window",
564 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
565 WS_MAXIMIZEBOX
| WS_VISIBLE
,
567 GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
571 /* check for message sequences */
572 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_parent_window_seq
, "create parent window", FALSE
);
577 static LRESULT WINAPI
monthcal_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
579 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
580 static LONG defwndproc_counter
= 0;
584 msg
.message
= message
;
585 msg
.flags
= sent
|wparam
|lparam
;
586 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
589 add_message(sequences
, MONTHCAL_SEQ_INDEX
, &msg
);
591 /* some debug output for style changing */
592 if ((message
== WM_STYLECHANGING
||
593 message
== WM_STYLECHANGED
) && lParam
)
595 STYLESTRUCT
*style
= (STYLESTRUCT
*)lParam
;
596 trace("\told style: 0x%08x, new style: 0x%08x\n", style
->styleOld
, style
->styleNew
);
599 defwndproc_counter
++;
600 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
601 defwndproc_counter
--;
606 static HWND
create_monthcal_control(DWORD style
)
611 hwnd
= CreateWindowEx(0,
614 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
616 parent_wnd
, NULL
, GetModuleHandleA(NULL
), NULL
);
618 if (!hwnd
) return NULL
;
620 oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
621 (LONG_PTR
)monthcal_subclass_proc
);
622 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
624 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(SYSTEM_FONT
), 0);
630 /* Setter and Getters Tests */
632 static void test_monthcal_color(void)
637 hwnd
= create_monthcal_control(0);
639 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
641 /* Setter and Getters for color*/
642 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
643 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_BACKGROUND
, RGB(0,0,0));
645 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
646 expect(RGB(0,0,0), temp
);
647 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_BACKGROUND
, RGB(255,255,255));
649 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
650 expect(RGB(255,255,255), temp
);
652 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
653 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_MONTHBK
, RGB(0,0,0));
655 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
656 expect(RGB(0,0,0), temp
);
657 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_MONTHBK
, RGB(255,255,255));
659 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
660 expect(RGB(255,255,255), temp
);
662 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
663 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TEXT
, RGB(0,0,0));
665 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
666 expect(RGB(0,0,0), temp
);
667 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TEXT
, RGB(255,255,255));
669 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
670 expect(RGB(255,255,255), temp
);
672 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
673 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TITLEBK
, RGB(0,0,0));
675 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
676 expect(RGB(0,0,0), temp
);
677 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TITLEBK
, RGB(255,255,255));
679 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
680 expect(RGB(255,255,255), temp
);
682 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
683 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TITLETEXT
, RGB(0,0,0));
685 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
686 expect(RGB(0,0,0), temp
);
687 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TITLETEXT
, RGB(255,255,255));
689 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
690 expect(RGB(255,255,255), temp
);
692 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
693 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TRAILINGTEXT
, RGB(0,0,0));
695 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
696 expect(RGB(0,0,0), temp
);
697 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TRAILINGTEXT
, RGB(255,255,255));
699 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
700 expect(RGB(255,255,255), temp
);
702 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_color_seq
, "monthcal color", FALSE
);
707 static void test_monthcal_currdate(void)
709 SYSTEMTIME st_original
, st_new
, st_test
;
713 hwnd
= create_monthcal_control(0);
715 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
717 /* Setter and Getters for current date selected */
718 st_original
.wYear
= 2000;
719 st_original
.wMonth
= 11;
720 st_original
.wDay
= 28;
721 st_original
.wHour
= 11;
722 st_original
.wMinute
= 59;
723 st_original
.wSecond
= 30;
724 st_original
.wMilliseconds
= 0;
725 st_original
.wDayOfWeek
= 0;
727 st_new
= st_test
= st_original
;
729 /* Should not validate the time */
730 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
733 /* Overflow matters, check for wDay */
735 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
738 /* correct wDay before checking for wMonth */
740 expect(st_original
.wDay
, st_test
.wDay
);
742 /* Overflow matters, check for wMonth */
744 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
747 /* checking if gets the information right, modify st_new */
755 res
= SendMessage(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_new
);
758 /* st_new change to st_origin, above settings with overflow */
759 /* should not change the current settings */
760 expect(st_original
.wYear
, st_new
.wYear
);
761 expect(st_original
.wMonth
, st_new
.wMonth
);
762 expect(st_original
.wDay
, st_new
.wDay
);
763 ok(st_original
.wHour
== st_new
.wHour
||
764 broken(0 == st_new
.wHour
), /* comctl32 <= 4.70 */
765 "Expected %d, got %d\n", st_original
.wHour
, st_new
.wHour
);
766 ok(st_original
.wMinute
== st_new
.wMinute
||
767 broken(0 == st_new
.wMinute
), /* comctl32 <= 4.70 */
768 "Expected %d, got %d\n", st_original
.wMinute
, st_new
.wMinute
);
769 ok(st_original
.wSecond
== st_new
.wSecond
||
770 broken(0 == st_new
.wSecond
), /* comctl32 <= 4.70 */
771 "Expected %d, got %d\n", st_original
.wSecond
, st_new
.wSecond
);
773 /* lparam cannot be NULL */
774 res
= SendMessage(hwnd
, MCM_GETCURSEL
, 0, 0);
777 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_curr_date_seq
, "monthcal currDate", TRUE
);
779 /* December, 31, 9999 is the maximum allowed date */
780 memset(&st_new
, 0, sizeof(st_new
));
784 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_new
);
786 memset(&st_test
, 0, sizeof(st_test
));
787 res
= SendMessage(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_test
);
789 expect(st_new
.wYear
, st_test
.wYear
);
790 expect(st_new
.wMonth
, st_test
.wMonth
);
791 expect(st_new
.wDay
, st_test
.wDay
);
792 expect(st_new
.wHour
, st_test
.wHour
);
793 expect(st_new
.wMinute
, st_test
.wMinute
);
794 expect(st_new
.wSecond
, st_test
.wSecond
);
795 /* try one day later */
796 st_original
= st_new
;
797 st_new
.wYear
= 10000;
800 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_new
);
802 broken(1 == res
), /* comctl32 <= 4.72 */
803 "Expected 0, got %d\n", res
);
806 memset(&st_test
, 0, sizeof(st_test
));
807 res
= SendMessage(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_test
);
809 expect(st_original
.wYear
, st_test
.wYear
);
810 expect(st_original
.wMonth
, st_test
.wMonth
);
811 expect(st_original
.wDay
, st_test
.wDay
);
812 expect(st_original
.wHour
, st_test
.wHour
);
813 expect(st_original
.wMinute
, st_test
.wMinute
);
814 expect(st_original
.wSecond
, st_test
.wSecond
);
817 /* setting selection equal to current reports success even if out range */
818 memset(&st_new
, 0, sizeof(st_new
));
822 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_new
);
824 memset(&st_test
, 0, sizeof(st_test
));
825 st_test
.wYear
= 2009;
828 res
= SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
, (LPARAM
)&st_test
);
830 /* set to current again */
831 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_new
);
837 static void test_monthcal_firstDay(void)
839 int res
, fday
, i
, prev
;
841 LCID lcid
= LOCALE_USER_DEFAULT
;
844 hwnd
= create_monthcal_control(0);
846 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
848 /* Setter and Getters for first day of week */
849 /* check for locale first day */
850 if(GetLocaleInfoA(lcid
, LOCALE_IFIRSTDAYOFWEEK
, b
, 128)){
852 trace("fday: %d\n", fday
);
853 res
= SendMessage(hwnd
, MCM_GETFIRSTDAYOFWEEK
, 0, 0);
857 /* checking for the values that actually will be stored as */
858 /* current first day when we set a new value */
859 for (i
= -5; i
< 12; i
++){
860 res
= SendMessage(hwnd
, MCM_SETFIRSTDAYOFWEEK
, 0, i
);
862 res
= SendMessage(hwnd
, MCM_GETFIRSTDAYOFWEEK
, 0, 0);
866 expect(MAKELONG(fday
, FALSE
), res
);
868 /* out of range sets max first day of week, locale is ignored */
869 expect(MAKELONG(6, TRUE
), res
);
871 expect(MAKELONG(i
, TRUE
), res
);
875 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_first_day_seq
, "monthcal firstDay", FALSE
);
878 skip("Cannot retrieve first day of the week\n");
884 static void test_monthcal_unicode(void)
889 hwnd
= create_monthcal_control(0);
891 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
893 /* Setter and Getters for Unicode format */
895 /* getting the current settings */
896 temp
= SendMessage(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
898 /* setting to 1, should return previous settings */
899 res
= SendMessage(hwnd
, MCM_SETUNICODEFORMAT
, 1, 0);
902 /* current setting is 1, so, should return 1 */
903 res
= SendMessage(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
905 broken(0 == res
), /* comctl32 <= 4.70 */
906 "Expected 1, got %d\n", res
);
908 /* setting to 0, should return previous settings */
909 res
= SendMessage(hwnd
, MCM_SETUNICODEFORMAT
, 0, 0);
911 broken(0 == res
), /* comctl32 <= 4.70 */
912 "Expected 1, got %d\n", res
);
914 /* current setting is 0, so, it should return 0 */
915 res
= SendMessage(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
918 /* should return previous settings */
919 res
= SendMessage(hwnd
, MCM_SETUNICODEFORMAT
, 1, 0);
922 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_unicode_seq
, "monthcal unicode", FALSE
);
927 static void test_monthcal_hittest(void)
929 typedef struct hittest_test
935 static const hittest_test_t title_hits
[] = {
936 /* Start is the same everywhere */
938 { MCHT_TITLEBTNPREV
, 0 },
939 /* The middle piece is only tested for presence of items */
940 /* End is the same everywhere */
941 { MCHT_TITLEBTNNEXT
, 0 },
953 char yearmonth
[80], *locale_month
, *locale_year
;
954 int month_count
, year_count
;
957 memset(&mchit
, 0, sizeof(MCHITTESTINFO
));
959 hwnd
= create_monthcal_control(0);
961 /* test with invalid structure size */
962 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
- 1;
965 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
966 expect(0, mchit
.pt
.x
);
967 expect(0, mchit
.pt
.y
);
969 expect(0, mchit
.uHit
);
970 /* test with invalid pointer */
971 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, 0);
974 /* resize control to display single Calendar */
975 res
= SendMessage(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
978 win_skip("Message MCM_GETMINREQRECT unsupported. Skipping.\n");
982 MoveWindow(hwnd
, 0, 0, r
.right
, r
.bottom
, FALSE
);
984 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
992 st
.wMilliseconds
= 0;
995 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st
);
998 /* (0, 0) is the top left of the control - title */
999 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
;
1002 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1003 expect(0, mchit
.pt
.x
);
1004 expect(0, mchit
.pt
.y
);
1005 expect(mchit
.uHit
, res
);
1006 expect_hex(MCHT_TITLE
, res
);
1008 /* bottom right of the control and should not be active */
1009 mchit
.pt
.x
= r
.right
;
1010 mchit
.pt
.y
= r
.bottom
;
1011 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
1012 expect(r
.right
, mchit
.pt
.x
);
1013 expect(r
.bottom
, mchit
.pt
.y
);
1014 expect(mchit
.uHit
, res
);
1015 todo_wine
expect_hex(MCHT_NOWHERE
, res
);
1017 /* completely out of the control, should not be active */
1018 mchit
.pt
.x
= 2 * r
.right
;
1019 mchit
.pt
.y
= 2 * r
.bottom
;
1020 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1021 expect(2 * r
.right
, mchit
.pt
.x
);
1022 expect(2 * r
.bottom
, mchit
.pt
.y
);
1023 expect(mchit
.uHit
, res
);
1024 todo_wine
expect_hex(MCHT_NOWHERE
, res
);
1026 /* in active area - day of the week */
1027 mchit
.pt
.x
= r
.right
/ 2;
1028 mchit
.pt
.y
= r
.bottom
/ 2;
1029 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1030 expect(r
.right
/ 2, mchit
.pt
.x
);
1031 expect(r
.bottom
/ 2, mchit
.pt
.y
);
1032 expect(mchit
.uHit
, res
);
1033 expect_hex(MCHT_CALENDARDATE
, res
);
1035 /* in active area - day of the week #2 */
1036 mchit
.pt
.x
= r
.right
/ 14; /* half of first day rect */
1037 mchit
.pt
.y
= r
.bottom
/ 2;
1038 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1039 expect(r
.right
/ 14, mchit
.pt
.x
);
1040 expect(r
.bottom
/ 2, mchit
.pt
.y
);
1041 expect(mchit
.uHit
, res
);
1042 expect_hex(MCHT_CALENDARDATE
, res
);
1044 /* in active area - date from prev month */
1045 mchit
.pt
.x
= r
.right
/ 14; /* half of first day rect */
1046 mchit
.pt
.y
= 6 * r
.bottom
/ 19;
1047 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1048 expect(r
.right
/ 14, mchit
.pt
.x
);
1049 expect(6 * r
.bottom
/ 19, mchit
.pt
.y
);
1050 expect(mchit
.uHit
, res
);
1051 expect_hex(MCHT_CALENDARDATEPREV
, res
);
1054 /* (125, 115) is in active area - date from this month */
1057 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1058 expect(125, mchit
.pt
.x
);
1059 expect(115, mchit
.pt
.y
);
1060 expect(mchit
.uHit
, res
);
1061 expect(MCHT_CALENDARDATE
, res
);
1064 /* in active area - date from next month */
1065 mchit
.pt
.x
= 11 * r
.right
/ 14;
1066 mchit
.pt
.y
= 16 * r
.bottom
/ 19;
1067 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1068 expect(11 * r
.right
/ 14, mchit
.pt
.x
);
1069 expect(16 * r
.bottom
/ 19, mchit
.pt
.y
);
1070 expect(mchit
.uHit
, res
);
1071 expect_hex(MCHT_CALENDARDATENEXT
, res
);
1073 /* in active area - today link */
1074 mchit
.pt
.x
= r
.right
/ 14;
1075 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1076 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1077 expect(r
.right
/ 14, mchit
.pt
.x
);
1078 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1079 expect(mchit
.uHit
, res
);
1080 expect_hex(MCHT_TODAYLINK
, res
);
1082 /* in active area - today link */
1083 mchit
.pt
.x
= r
.right
/ 2;
1084 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1085 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1086 expect(r
.right
/ 2, mchit
.pt
.x
);
1087 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1088 expect(mchit
.uHit
, res
);
1089 expect_hex(MCHT_TODAYLINK
, res
);
1091 /* in active area - today link */
1092 mchit
.pt
.x
= r
.right
/ 10;
1093 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1094 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1095 expect(r
.right
/ 10, mchit
.pt
.x
);
1096 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1097 expect(mchit
.uHit
, res
);
1098 expect_hex(MCHT_TODAYLINK
, res
);
1100 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_hit_test_seq
, "monthcal hit test", TRUE
);
1102 /* The horizontal position of title bar elements depends on locale (y pos
1103 is constant), so we sample across a horizontal line and make sure we
1104 find all elements. */
1106 /* Get the format of the title */
1107 GetLocaleInfo(LOCALE_USER_DEFAULT
, LOCALE_SYEARMONTH
, yearmonth
, 80);
1108 /* Find out if we have a month and/or year */
1109 locale_year
= strstr(yearmonth
, "y");
1110 locale_month
= strstr(yearmonth
, "M");
1113 mchit
.pt
.y
= (5/2) * r
.bottom
/ 19;
1115 old_res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1116 expect_hex(title_hits
[title_index
].ht
, old_res
);
1118 in_the_middle
= FALSE
;
1119 month_count
= year_count
= 0;
1120 for (x
= 0; x
< r
.right
; x
++){
1122 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1123 expect(x
, mchit
.pt
.x
);
1124 expect((5/2) * r
.bottom
/ 19, mchit
.pt
.y
);
1125 expect(mchit
.uHit
, res
);
1126 if (res
!= old_res
) {
1128 if (old_res
== MCHT_TITLEBTNPREV
)
1129 in_the_middle
= TRUE
;
1131 if (res
== MCHT_TITLEBTNNEXT
)
1132 in_the_middle
= FALSE
;
1134 if (in_the_middle
) {
1135 if (res
== MCHT_TITLEMONTH
)
1137 else if (res
== MCHT_TITLEYEAR
)
1142 if (sizeof(title_hits
) / sizeof(title_hits
[0]) <= title_index
)
1145 if (title_hits
[title_index
].todo
) {
1147 ok(title_hits
[title_index
].ht
== res
, "Expected %x, got %x, pos %d\n",
1148 title_hits
[title_index
].ht
, res
, x
);
1150 ok(title_hits
[title_index
].ht
== res
, "Expected %x, got %x, pos %d\n",
1151 title_hits
[title_index
].ht
, res
, x
);
1158 /* There are some limits, even if LOCALE_SYEARMONTH contains rubbish
1159 * or no month/year indicators at all */
1161 todo_wine
ok(month_count
== 1, "Expected 1 month item, got %d\n", month_count
);
1163 ok(month_count
<= 1, "Too many month items: %d\n", month_count
);
1166 todo_wine
ok(year_count
== 1, "Expected 1 year item, got %d\n", year_count
);
1168 ok(year_count
<= 1, "Too many year items: %d\n", year_count
);
1170 todo_wine
ok(month_count
+ year_count
>= 1, "Not enough month and year items\n");
1172 ok(r
.right
<= x
&& title_index
+ 1 == sizeof(title_hits
) / sizeof(title_hits
[0]),
1173 "Wrong title layout\n");
1175 DestroyWindow(hwnd
);
1178 static void test_monthcal_todaylink(void)
1180 MCHITTESTINFO mchit
;
1181 SYSTEMTIME st_test
, st_new
;
1186 memset(&mchit
, 0, sizeof(MCHITTESTINFO
));
1188 hwnd
= create_monthcal_control(0);
1190 res
= SendMessage(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
1191 MoveWindow(hwnd
, 0, 0, r
.right
, r
.bottom
, FALSE
);
1193 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1195 /* hit active area - today link */
1196 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
;
1197 mchit
.pt
.x
= r
.right
/ 14;
1198 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1199 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1200 expect(r
.right
/ 14, mchit
.pt
.x
);
1201 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1202 expect(mchit
.uHit
, res
);
1203 expect(MCHT_TODAYLINK
, res
);
1207 st_test
.wYear
= 2005;
1209 SendMessage(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1211 memset(&st_new
, 0, sizeof(st_new
));
1212 res
= SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1214 expect(1, st_new
.wDay
);
1215 expect(1, st_new
.wMonth
);
1216 expect(2005, st_new
.wYear
);
1218 res
= SendMessage(hwnd
, WM_LBUTTONDOWN
, MK_LBUTTON
, MAKELONG(mchit
.pt
.x
, mchit
.pt
.y
));
1221 memset(&st_new
, 0, sizeof(st_new
));
1222 res
= SendMessage(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_new
);
1224 expect(1, st_new
.wDay
);
1225 expect(1, st_new
.wMonth
);
1226 expect(2005, st_new
.wYear
);
1228 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_todaylink_seq
, "monthcal hit test", TRUE
);
1230 DestroyWindow(hwnd
);
1233 static void test_monthcal_today(void)
1235 SYSTEMTIME st_test
, st_new
;
1239 hwnd
= create_monthcal_control(0);
1241 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1243 /* Setter and Getters for "today" information */
1245 /* check for overflow, should be ok */
1246 memset(&st_test
, 0, sizeof(st_test
));
1248 st_test
.wMonth
= 38;
1253 SendMessage(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1255 res
= SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1258 /* st_test should not change */
1259 expect(38, st_test
.wDay
);
1260 expect(38, st_test
.wMonth
);
1262 /* st_new should change, overflow does not matter */
1263 expect(38, st_new
.wDay
);
1264 expect(38, st_new
.wMonth
);
1266 /* check for zero, should be ok*/
1270 SendMessage(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1272 res
= SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1275 /* st_test should not change */
1276 expect(0, st_test
.wDay
);
1277 expect(0, st_test
.wMonth
);
1279 /* st_new should change to zero*/
1280 expect(0, st_new
.wDay
);
1281 expect(0, st_new
.wMonth
);
1283 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_today_seq
, "monthcal today", TRUE
);
1285 DestroyWindow(hwnd
);
1288 static void test_monthcal_scroll(void)
1293 hwnd
= create_monthcal_control(0);
1295 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1297 /* Setter and Getters for scroll rate */
1298 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, 2, 0);
1301 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, 3, 0);
1303 res
= SendMessage(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1306 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, 12, 0);
1308 res
= SendMessage(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1311 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, 15, 0);
1313 res
= SendMessage(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1316 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, -5, 0);
1318 res
= SendMessage(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1321 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_scroll_seq
, "monthcal scroll", FALSE
);
1323 DestroyWindow(hwnd
);
1326 static void test_monthcal_monthrange(void)
1329 SYSTEMTIME st_visible
[2], st_daystate
[2], st
;
1333 hwnd
= create_monthcal_control(0);
1335 st_visible
[0].wYear
= 0;
1336 st_visible
[0].wMonth
= 0;
1337 st_visible
[0].wDay
= 0;
1338 st_daystate
[1] = st_daystate
[0] = st_visible
[1] = st_visible
[0];
1346 st
.wMilliseconds
= 0;
1349 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st
);
1352 /* to be locale independent */
1353 SendMessage(hwnd
, MCM_SETFIRSTDAYOFWEEK
, 0, (LPARAM
)6);
1355 res
= SendMessage(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
1357 /* resize control to display two Calendars */
1358 MoveWindow(hwnd
, 0, 0, r
.right
, (5/2)*r
.bottom
, FALSE
);
1360 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1362 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st_visible
);
1366 expect(2000, st_visible
[0].wYear
);
1367 expect(11, st_visible
[0].wMonth
);
1368 expect(1, st_visible
[0].wDay
);
1369 expect(2000, st_visible
[1].wYear
);
1372 expect(12, st_visible
[1].wMonth
);
1373 expect(31, st_visible
[1].wDay
);
1375 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_DAYSTATE
, (LPARAM
)st_daystate
);
1379 expect(2000, st_daystate
[0].wYear
);
1380 expect(10, st_daystate
[0].wMonth
);
1381 expect(29, st_daystate
[0].wDay
);
1384 expect(2001, st_daystate
[1].wYear
);
1385 expect(1, st_daystate
[1].wMonth
);
1386 expect(6, st_daystate
[1].wDay
);
1389 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_monthrange_seq
, "monthcal monthrange", FALSE
);
1391 /* resize control to display single Calendar */
1392 MoveWindow(hwnd
, 0, 0, r
.right
, r
.bottom
, FALSE
);
1394 memset(&st
, 0, sizeof(st
));
1399 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st
);
1402 /* September 1752 has 19 days */
1403 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st_visible
);
1406 expect(1752, st_visible
[0].wYear
);
1407 expect(9, st_visible
[0].wMonth
);
1408 ok(14 == st_visible
[0].wDay
||
1409 broken(1 == st_visible
[0].wDay
), /* comctl32 <= 4.72 */
1410 "Expected 14, got %d\n", st_visible
[0].wDay
);
1412 expect(1752, st_visible
[1].wYear
);
1413 expect(9, st_visible
[1].wMonth
);
1414 expect(19, st_visible
[1].wDay
);
1416 DestroyWindow(hwnd
);
1419 static void test_monthcal_maxselday(void)
1425 hwnd
= create_monthcal_control(0);
1426 /* if no style specified default to 1 */
1427 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1429 res
= SendMessage(hwnd
, MCM_SETMAXSELCOUNT
, 5, 0);
1431 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1434 /* try to set style */
1435 style
= GetWindowLong(hwnd
, GWL_STYLE
);
1436 SetWindowLong(hwnd
, GWL_STYLE
, style
| MCS_MULTISELECT
);
1437 style
= GetWindowLong(hwnd
, GWL_STYLE
);
1438 ok(!(style
& MCS_MULTISELECT
), "Expected MCS_MULTISELECT not to be set\n");
1439 DestroyWindow(hwnd
);
1441 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1442 /* try to remove style */
1443 style
= GetWindowLong(hwnd
, GWL_STYLE
);
1444 SetWindowLong(hwnd
, GWL_STYLE
, style
& ~MCS_MULTISELECT
);
1445 style
= GetWindowLong(hwnd
, GWL_STYLE
);
1446 ok(style
& MCS_MULTISELECT
, "Expected MCS_MULTISELECT to be set\n");
1447 DestroyWindow(hwnd
);
1449 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1451 /* default width is a week */
1452 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1455 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1457 /* Setter and Getters for max selected days */
1458 res
= SendMessage(hwnd
, MCM_SETMAXSELCOUNT
, 5, 0);
1460 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1463 res
= SendMessage(hwnd
, MCM_SETMAXSELCOUNT
, 15, 0);
1465 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1468 /* test invalid value */
1469 res
= SendMessage(hwnd
, MCM_SETMAXSELCOUNT
, -1, 0);
1471 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1474 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_max_sel_day_seq
, "monthcal MaxSelDay", FALSE
);
1476 /* zero value is invalid too */
1477 res
= SendMessage(hwnd
, MCM_SETMAXSELCOUNT
, 0, 0);
1479 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1482 DestroyWindow(hwnd
);
1485 static void test_monthcal_size(void)
1489 HFONT hFont1
, hFont2
;
1493 hwnd
= create_monthcal_control(0);
1495 lstrcpyA(logfont
.lfFaceName
, "Arial");
1496 memset(&logfont
, 0, sizeof(logfont
));
1497 logfont
.lfHeight
= 12;
1498 hFont1
= CreateFontIndirectA(&logfont
);
1500 logfont
.lfHeight
= 24;
1501 hFont2
= CreateFontIndirectA(&logfont
);
1503 /* initialize to a font we can compare against */
1504 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)hFont1
, 0);
1505 res
= SendMessage(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r1
);
1506 ok(res
, "SendMessage(MCM_GETMINREQRECT) failed\n");
1508 /* check that setting a larger font results in an larger rect */
1509 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)hFont2
, 0);
1510 res
= SendMessage(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r2
);
1511 ok(res
, "SendMessage(MCM_GETMINREQRECT) failed\n");
1513 OffsetRect(&r1
, -r1
.left
, -r1
.top
);
1514 OffsetRect(&r2
, -r2
.left
, -r2
.top
);
1516 ok(r1
.bottom
< r2
.bottom
, "Failed to get larger rect with larger font\n");
1518 DestroyWindow(hwnd
);
1521 static void test_monthcal_create(void)
1525 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1527 hwnd
= create_monthcal_control(0);
1528 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_monthcal_control_seq
, "create monthcal control", TRUE
);
1530 DestroyWindow(hwnd
);
1532 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1533 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1534 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_monthcal_multi_sel_style_seq
, "create monthcal (multi sel style)", TRUE
);
1535 DestroyWindow(hwnd
);
1538 static void test_monthcal_destroy(void)
1542 hwnd
= create_monthcal_control(0);
1543 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1544 DestroyWindow(hwnd
);
1545 ok_sequence(sequences
, PARENT_SEQ_INDEX
, destroy_monthcal_parent_msgs_seq
, "Destroy monthcal (parent msg)", FALSE
);
1546 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, destroy_monthcal_child_msgs_seq
, "Destroy monthcal (child msg)", FALSE
);
1548 /* MCS_MULTISELECT */
1549 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1550 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1551 DestroyWindow(hwnd
);
1552 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, destroy_monthcal_multi_sel_style_seq
, "Destroy monthcal (multi sel style)", FALSE
);
1555 static void test_monthcal_selrange(void)
1558 SYSTEMTIME st
, range
[2], range2
[2];
1559 BOOL ret
, old_comctl32
= FALSE
;
1561 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1563 /* just after creation selection should start and end today */
1564 ret
= SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st
);
1567 memset(range
, 0xcc, sizeof(range
));
1568 ret
= SendMessage(hwnd
, MCM_GETSELRANGE
, 0, (LPARAM
)range
);
1570 expect(st
.wYear
, range
[0].wYear
);
1571 expect(st
.wMonth
, range
[0].wMonth
);
1572 expect(st
.wDay
, range
[0].wDay
);
1573 if (range
[0].wDayOfWeek
!= st
.wDayOfWeek
)
1575 win_skip("comctl32 <= 4.70 doesn't set some values\n");
1576 old_comctl32
= TRUE
;
1580 expect(st
.wDayOfWeek
, range
[0].wDayOfWeek
);
1581 expect(st
.wHour
, range
[0].wHour
);
1582 expect(st
.wMinute
, range
[0].wMinute
);
1583 expect(st
.wSecond
, range
[0].wSecond
);
1584 expect(st
.wMilliseconds
, range
[0].wMilliseconds
);
1587 expect(st
.wYear
, range
[1].wYear
);
1588 expect(st
.wMonth
, range
[1].wMonth
);
1589 expect(st
.wDay
, range
[1].wDay
);
1592 expect(st
.wDayOfWeek
, range
[1].wDayOfWeek
);
1593 expect(st
.wHour
, range
[1].wHour
);
1594 expect(st
.wMinute
, range
[1].wMinute
);
1595 expect(st
.wSecond
, range
[1].wSecond
);
1596 expect(st
.wMilliseconds
, range
[1].wMilliseconds
);
1599 /* bounds are swapped if min > max */
1600 memset(&range
[0], 0, sizeof(range
[0]));
1601 range
[0].wYear
= 2009;
1602 range
[0].wMonth
= 10;
1604 range
[1] = range
[0];
1607 ret
= SendMessage(hwnd
, MCM_SETSELRANGE
, 0, (LPARAM
)range
);
1610 ret
= SendMessage(hwnd
, MCM_GETSELRANGE
, 0, (LPARAM
)range2
);
1613 expect(range
[1].wYear
, range2
[0].wYear
);
1614 expect(range
[1].wMonth
, range2
[0].wMonth
);
1615 expect(range
[1].wDay
, range2
[0].wDay
);
1616 expect(6, range2
[0].wDayOfWeek
);
1617 expect(range
[1].wHour
, range2
[0].wHour
);
1618 expect(range
[1].wMinute
, range2
[0].wMinute
);
1619 expect(range
[1].wSecond
, range2
[0].wSecond
);
1620 expect(range
[1].wMilliseconds
, range2
[0].wMilliseconds
);
1622 expect(range
[0].wYear
, range2
[1].wYear
);
1623 expect(range
[0].wMonth
, range2
[1].wMonth
);
1624 expect(range
[0].wDay
, range2
[1].wDay
);
1625 expect(1, range2
[1].wDayOfWeek
);
1626 expect(range
[0].wHour
, range2
[1].wHour
);
1627 expect(range
[0].wMinute
, range2
[1].wMinute
);
1628 expect(range
[0].wSecond
, range2
[1].wSecond
);
1629 expect(range
[0].wMilliseconds
, range2
[1].wMilliseconds
);
1631 /* try with range larger than maximum configured */
1632 memset(&range
[0], 0, sizeof(range
[0]));
1633 range
[0].wYear
= 2009;
1634 range
[0].wMonth
= 10;
1636 range
[1] = range
[0];
1638 ret
= SendMessage(hwnd
, MCM_SETSELRANGE
, 0, (LPARAM
)range
);
1641 range
[1] = range
[0];
1642 /* default max. range is 7 days */
1645 ret
= SendMessage(hwnd
, MCM_SETSELRANGE
, 0, (LPARAM
)range
);
1648 ret
= SendMessage(hwnd
, MCM_GETSELRANGE
, 0, (LPARAM
)range2
);
1651 expect(range
[0].wYear
, range2
[0].wYear
);
1652 expect(range
[0].wMonth
, range2
[0].wMonth
);
1653 expect(range
[0].wDay
, range2
[0].wDay
);
1654 expect(range
[0].wYear
, range2
[1].wYear
);
1655 expect(range
[0].wMonth
, range2
[1].wMonth
);
1656 expect(range
[0].wDay
, range2
[1].wDay
);
1658 DestroyWindow(hwnd
);
1661 static void test_killfocus(void)
1666 hwnd
= create_monthcal_control(0);
1668 /* make parent invisible */
1669 style
= GetWindowLong(parent_wnd
, GWL_STYLE
);
1670 SetWindowLong(parent_wnd
, GWL_STYLE
, style
&~ WS_VISIBLE
);
1672 SendMessage(hwnd
, WM_KILLFOCUS
, (WPARAM
)GetDesktopWindow(), 0);
1674 style
= GetWindowLong(hwnd
, GWL_STYLE
);
1675 ok(style
& WS_VISIBLE
, "Expected WS_VISIBLE to be set\n");
1677 style
= GetWindowLong(parent_wnd
, GWL_STYLE
);
1678 SetWindowLong(parent_wnd
, GWL_STYLE
, style
| WS_VISIBLE
);
1680 DestroyWindow(hwnd
);
1683 START_TEST(monthcal
)
1686 BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
1687 INITCOMMONCONTROLSEX iccex
;
1689 hComctl32
= GetModuleHandleA("comctl32.dll");
1690 pInitCommonControlsEx
= (void*)GetProcAddress(hComctl32
, "InitCommonControlsEx");
1691 if (!pInitCommonControlsEx
)
1693 skip("InitCommonControlsEx() is missing. Skipping the tests\n");
1696 iccex
.dwSize
= sizeof(iccex
);
1697 iccex
.dwICC
= ICC_DATE_CLASSES
;
1698 pInitCommonControlsEx(&iccex
);
1702 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
1704 parent_wnd
= create_parent_window();
1706 test_monthcal_create();
1707 test_monthcal_destroy();
1708 test_monthcal_color();
1709 test_monthcal_currdate();
1710 test_monthcal_firstDay();
1711 test_monthcal_unicode();
1712 test_monthcal_today();
1713 test_monthcal_scroll();
1714 test_monthcal_monthrange();
1715 test_monthcal_hittest();
1716 test_monthcal_todaylink();
1717 test_monthcal_size();
1718 test_monthcal_maxselday();
1719 test_monthcal_selrange();
1722 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1723 DestroyWindow(parent_wnd
);
1724 ok_sequence(sequences
, PARENT_SEQ_INDEX
, destroy_parent_seq
, "Destroy parent window", FALSE
);