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
47 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
49 static HWND parent_wnd
;
51 static const struct message create_parent_window_seq
[] = {
52 { WM_GETMINMAXINFO
, sent
},
53 { WM_NCCREATE
, sent
},
54 { WM_NCCALCSIZE
, sent
|wparam
, 0 },
56 { WM_SHOWWINDOW
, sent
|wparam
, 1 },
57 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0 },
58 { WM_QUERYNEWPALETTE
, sent
|optional
},
59 { WM_WINDOWPOSCHANGING
, sent
|wparam
|optional
, 0 },
60 { WM_WINDOWPOSCHANGED
, sent
|optional
},
61 { WM_ACTIVATEAPP
, sent
|wparam
, 1 },
62 { WM_NCACTIVATE
, sent
},
63 { WM_ACTIVATE
, sent
|wparam
, 1 },
64 { WM_IME_SETCONTEXT
, sent
|wparam
|defwinproc
|optional
, 1 },
65 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
66 { WM_SETFOCUS
, sent
|wparam
|defwinproc
, 0 },
67 /* Win9x adds SWP_NOZORDER below */
68 { WM_WINDOWPOSCHANGED
, sent
, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
69 { WM_NCCALCSIZE
, sent
|wparam
|optional
, 1 },
75 static const struct message create_monthcal_control_seq
[] = {
76 { WM_NOTIFYFORMAT
, sent
|lparam
, 0, NF_QUERY
},
77 { WM_QUERYUISTATE
, sent
|optional
},
79 { WM_PARENTNOTIFY
, sent
|wparam
, WM_CREATE
},
83 static const struct message create_monthcal_multi_sel_style_seq
[] = {
84 { WM_NOTIFYFORMAT
, sent
|lparam
, 0, NF_QUERY
},
85 { WM_QUERYUISTATE
, sent
|optional
},
87 { WM_PARENTNOTIFY
, sent
},
91 static const struct message monthcal_color_seq
[] = {
92 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, 0},
93 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, RGB(0,0,0)},
94 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, 0},
95 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, RGB(255,255,255)},
96 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_BACKGROUND
, 0},
98 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, 0},
99 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, RGB(0,0,0)},
100 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, 0},
101 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, RGB(255,255,255)},
102 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_MONTHBK
, 0},
104 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, 0},
105 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, RGB(0,0,0)},
106 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, 0},
107 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, RGB(255,255,255)},
108 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TEXT
, 0},
110 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, 0},
111 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, RGB(0,0,0)},
112 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, 0},
113 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, RGB(255,255,255)},
114 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLEBK
, 0},
116 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, 0},
117 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, RGB(0,0,0)},
118 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, 0},
119 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, RGB(255,255,255)},
120 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TITLETEXT
, 0},
122 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, 0},
123 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, RGB(0,0,0)},
124 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, 0},
125 { MCM_SETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, RGB(255,255,255)},
126 { MCM_GETCOLOR
, sent
|wparam
|lparam
, MCSC_TRAILINGTEXT
, 0},
130 static const struct message monthcal_curr_date_seq
[] = {
131 { MCM_SETCURSEL
, sent
|wparam
, 0},
132 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
133 { MCM_SETCURSEL
, sent
|wparam
, 0},
134 { MCM_SETCURSEL
, sent
|wparam
, 0},
135 { MCM_GETCURSEL
, sent
|wparam
, 0},
136 { MCM_GETCURSEL
, sent
|wparam
|lparam
, 0, 0},
140 static const struct message monthcal_first_day_seq
[] = {
141 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
143 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -5},
144 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
146 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -4},
147 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
149 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -3},
150 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
152 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -2},
153 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
155 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, -1},
156 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
158 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
159 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
161 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 1},
162 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
164 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 2},
165 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
167 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 3},
168 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
170 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 4},
171 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
173 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 5},
174 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
176 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 6},
177 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
179 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 7},
180 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
182 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 8},
183 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
185 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 9},
186 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
188 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 10},
189 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
191 { MCM_SETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 11},
192 { MCM_GETFIRSTDAYOFWEEK
, sent
|wparam
|lparam
, 0, 0},
196 static const struct message monthcal_unicode_seq
[] = {
197 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
198 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 1, 0},
199 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
200 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
201 { MCM_GETUNICODEFORMAT
, sent
|wparam
|lparam
, 0, 0},
202 { MCM_SETUNICODEFORMAT
, sent
|wparam
|lparam
, 1, 0},
206 static const struct message monthcal_hit_test_seq
[] = {
207 { MCM_SETCURSEL
, sent
|wparam
, 0},
208 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 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},
214 { MCM_HITTEST
, sent
|wparam
, 0},
215 { MCM_HITTEST
, sent
|wparam
, 0},
216 { MCM_HITTEST
, sent
|wparam
, 0},
217 { MCM_HITTEST
, sent
|wparam
, 0},
218 { MCM_HITTEST
, sent
|wparam
, 0},
219 { MCM_HITTEST
, sent
|wparam
, 0},
220 { MCM_HITTEST
, sent
|wparam
, 0},
221 { MCM_HITTEST
, sent
|wparam
, 0},
225 static const struct message monthcal_todaylink_seq
[] = {
226 { MCM_HITTEST
, sent
|wparam
, 0},
227 { MCM_SETTODAY
, sent
|wparam
, 0},
228 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
229 { MCM_GETTODAY
, sent
|wparam
, 0},
230 { WM_LBUTTONDOWN
, sent
|wparam
|lparam
, MK_LBUTTON
, MAKELONG(70, 370)},
231 { WM_CAPTURECHANGED
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
232 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
233 { MCM_GETCURSEL
, sent
|wparam
, 0},
237 static const struct message monthcal_today_seq
[] = {
238 { MCM_SETTODAY
, sent
|wparam
, 0},
239 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
240 { MCM_GETTODAY
, sent
|wparam
, 0},
241 { MCM_SETTODAY
, sent
|wparam
, 0},
242 { WM_PAINT
, sent
|wparam
|lparam
|defwinproc
, 0, 0},
243 { MCM_GETTODAY
, sent
|wparam
, 0},
247 static const struct message monthcal_scroll_seq
[] = {
248 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 2, 0},
249 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 3, 0},
250 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
251 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 12, 0},
252 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
253 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, 15, 0},
254 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
255 { MCM_SETMONTHDELTA
, sent
|wparam
|lparam
, -5, 0},
256 { MCM_GETMONTHDELTA
, sent
|wparam
|lparam
, 0, 0},
260 static const struct message monthcal_monthrange_seq
[] = {
261 { MCM_GETMONTHRANGE
, sent
|wparam
, GMR_VISIBLE
},
262 { MCM_GETMONTHRANGE
, sent
|wparam
, GMR_DAYSTATE
},
266 static const struct message monthcal_max_sel_day_seq
[] = {
267 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, 5, 0},
268 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
269 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, 15, 0},
270 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
271 { MCM_SETMAXSELCOUNT
, sent
|wparam
|lparam
, -1, 0},
272 { MCM_GETMAXSELCOUNT
, sent
|wparam
|lparam
, 0, 0},
276 /* expected message sequence for parent*/
277 static const struct message destroy_monthcal_parent_msgs_seq
[] = {
278 { WM_PARENTNOTIFY
, sent
|wparam
, WM_DESTROY
},
282 /* expected message sequence for child*/
283 static const struct message destroy_monthcal_child_msgs_seq
[] = {
284 { 0x0090, sent
|optional
}, /* Vista */
285 { WM_SHOWWINDOW
, sent
|wparam
|lparam
, 0, 0},
286 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0},
287 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0},
288 { WM_DESTROY
, sent
|wparam
|lparam
, 0, 0},
289 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, 0},
293 static const struct message destroy_monthcal_multi_sel_style_seq
[] = {
294 { 0x0090, sent
|optional
}, /* Vista */
295 { WM_SHOWWINDOW
, sent
|wparam
|lparam
, 0, 0},
296 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0},
297 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0},
298 { WM_DESTROY
, sent
|wparam
|lparam
, 0, 0},
299 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, 0},
303 /* expected message sequence for parent window*/
304 static const struct message destroy_parent_seq
[] = {
305 { 0x0090, sent
|optional
}, /* Vista */
306 { WM_WINDOWPOSCHANGING
, sent
|wparam
, 0},
307 { WM_WINDOWPOSCHANGED
, sent
|wparam
, 0},
308 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0},
309 { WM_IME_NOTIFY
, sent
|wparam
|lparam
|defwinproc
|optional
, 1, 0},
310 { WM_NCACTIVATE
, sent
|wparam
|optional
, 0},
311 { WM_ACTIVATE
, sent
|wparam
|optional
, 0},
312 { WM_NCACTIVATE
, sent
|wparam
|lparam
|optional
, 0, 0},
313 { WM_ACTIVATE
, sent
|wparam
|lparam
|optional
, 0, 0},
314 { WM_ACTIVATEAPP
, sent
|wparam
|optional
, 0},
315 { WM_KILLFOCUS
, sent
|wparam
|lparam
|optional
, 0, 0},
316 { WM_IME_SETCONTEXT
, sent
|wparam
|optional
, 0},
317 { WM_IME_NOTIFY
, sent
|wparam
|lparam
|defwinproc
|optional
, 1, 0},
318 { WM_DESTROY
, sent
|wparam
|lparam
, 0, 0},
319 { WM_NCDESTROY
, sent
|wparam
|lparam
, 0, 0},
323 static void test_monthcal(void)
326 SYSTEMTIME st
[2], st1
[2], today
;
327 int res
, month_range
;
329 hwnd
= CreateWindowA(MONTHCAL_CLASSA
, "MonthCal", WS_POPUP
| WS_VISIBLE
, CW_USEDEFAULT
,
330 0, 300, 300, 0, 0, NULL
, NULL
);
331 ok(hwnd
!= NULL
, "Failed to create MonthCal\n");
333 /* test range just after creation */
334 memset(&st
, 0xcc, sizeof(st
));
335 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st
) == 0, "No limits should be set\n");
337 expect(0, st
[0].wYear
);
338 expect(0, st
[0].wMonth
);
339 expect(0, st
[0].wDay
);
340 expect(0, st
[0].wDayOfWeek
);
341 expect(0, st
[0].wHour
);
342 expect(0, st
[0].wMinute
);
343 expect(0, st
[0].wSecond
);
344 expect(0, st
[0].wMilliseconds
);
346 expect(0, st
[1].wYear
);
347 expect(0, st
[1].wMonth
);
348 expect(0, st
[1].wDay
);
349 expect(0, st
[1].wDayOfWeek
);
350 expect(0, st
[1].wHour
);
351 expect(0, st
[1].wMinute
);
352 expect(0, st
[1].wSecond
);
353 expect(0, st
[1].wMilliseconds
);
355 GetSystemTime(&st
[0]);
358 SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&today
);
360 /* Invalid date/time */
362 /* Time should not matter */
363 st
[1].wHour
= st
[1].wMinute
= st
[1].wSecond
= 70;
364 st
[1].wMilliseconds
= 1200;
365 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set MAX limit\n");
366 /* invalid timestamp is written back with today data and msecs untouched */
367 expect(today
.wHour
, st
[1].wHour
);
368 expect(today
.wMinute
, st
[1].wMinute
);
369 expect(today
.wSecond
, st
[1].wSecond
);
370 expect(1200, st
[1].wMilliseconds
);
372 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
373 ok(st1
[0].wYear
!= 2000, "Lover limit changed\n");
374 /* invalid timestamp should be replaced with today data, except msecs */
375 expect(today
.wHour
, st1
[1].wHour
);
376 expect(today
.wMinute
, st1
[1].wMinute
);
377 expect(today
.wSecond
, st1
[1].wSecond
);
378 expect(1200, st1
[1].wMilliseconds
);
380 /* Invalid date/time with invalid milliseconds only */
381 GetSystemTime(&st
[0]);
383 /* Time should not matter */
384 st
[1].wMilliseconds
= 1200;
385 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set MAX limit\n");
386 /* invalid milliseconds field doesn't lead to invalid timestamp */
387 expect(st
[0].wHour
, st
[1].wHour
);
388 expect(st
[0].wMinute
, st
[1].wMinute
);
389 expect(st
[0].wSecond
, st
[1].wSecond
);
390 expect(1200, st
[1].wMilliseconds
);
392 GetSystemTime(&st
[0]);
395 ok(!SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Should have failed to set limits\n");
396 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
397 ok(st1
[0].wYear
!= 2000, "Lover limit changed\n");
398 ok(!SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Should have failed to set MAX limit\n");
399 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "No limits should be set\n");
400 ok(st1
[0].wYear
!= 2000, "Lover limit changed\n");
402 GetSystemTime(&st
[0]);
407 month_range
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
409 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Failed to set both min and max limits\n");
410 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
411 ok(res
== month_range
, "Invalid month range (%d)\n", res
);
412 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
), "Limits should be set\n");
415 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Failed to set both min and max limits\n");
416 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st1
);
417 ok(res
== month_range
, "Invalid month range (%d)\n", res
);
420 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Failed to set both min and max limits\n");
422 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
| GDTR_MAX
, (LPARAM
)st
), "Failed to set both min and max limits\n");
425 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
426 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "Only MAX limit should be set\n");
428 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
430 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
432 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set max limit\n");
433 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "Only MAX limit should be set\n");
435 /* set both limits, then set max < min */
436 GetSystemTime(&st
[0]);
439 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
|GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
440 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
), "Min limit expected\n");
442 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
443 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MAX
, "Max limit expected\n");
445 expect(0, st1
[0].wYear
);
446 expect(0, st1
[0].wMonth
);
447 expect(0, st1
[0].wDay
);
448 expect(0, st1
[0].wDayOfWeek
);
449 expect(0, st1
[0].wHour
);
450 expect(0, st1
[0].wMinute
);
451 expect(0, st1
[0].wSecond
);
452 expect(0, st1
[0].wMilliseconds
);
454 expect(st
[1].wYear
, st1
[1].wYear
);
455 expect(st
[1].wMonth
, st1
[1].wMonth
);
456 expect(st
[1].wDay
, st1
[1].wDay
);
457 expect(st
[1].wDayOfWeek
, st1
[1].wDayOfWeek
);
458 expect(st
[1].wHour
, st1
[1].wHour
);
459 expect(st
[1].wMinute
, st1
[1].wMinute
);
460 expect(st
[1].wSecond
, st1
[1].wSecond
);
461 expect(st
[1].wMilliseconds
, st1
[1].wMilliseconds
);
465 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
|GDTR_MAX
, (LPARAM
)st
), "Failed to set limits\n");
466 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == (GDTR_MIN
|GDTR_MAX
), "Min limit expected\n");
467 st
[0].wYear
++; /* start == end now */
468 ok(SendMessage(hwnd
, MCM_SETRANGE
, GDTR_MIN
, (LPARAM
)st
), "Failed to set limits\n");
469 ok(SendMessage(hwnd
, MCM_GETRANGE
, 0, (LPARAM
)st1
) == GDTR_MIN
, "Min limit expected\n");
471 expect(st
[0].wYear
, st1
[0].wYear
);
472 expect(st
[0].wMonth
, st1
[0].wMonth
);
473 expect(st
[0].wDay
, st1
[0].wDay
);
474 expect(st
[0].wDayOfWeek
, st1
[0].wDayOfWeek
);
475 expect(st
[0].wHour
, st1
[0].wHour
);
476 expect(st
[0].wMinute
, st1
[0].wMinute
);
477 expect(st
[0].wSecond
, st1
[0].wSecond
);
478 expect(st
[0].wMilliseconds
, st1
[0].wMilliseconds
);
480 expect(0, st1
[1].wYear
);
481 expect(0, st1
[1].wMonth
);
482 expect(0, st1
[1].wDay
);
483 expect(0, st1
[1].wDayOfWeek
);
484 expect(0, st1
[1].wHour
);
485 expect(0, st1
[1].wMinute
);
486 expect(0, st1
[1].wSecond
);
487 expect(0, st1
[1].wMilliseconds
);
492 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
494 static LONG defwndproc_counter
= 0;
498 /* log system messages, except for painting */
499 if (message
< WM_USER
&&
500 message
!= WM_PAINT
&&
501 message
!= WM_ERASEBKGND
&&
502 message
!= WM_NCPAINT
&&
503 message
!= WM_NCHITTEST
&&
504 message
!= WM_GETTEXT
&&
505 message
!= WM_GETICON
&&
506 message
!= WM_DEVICECHANGE
)
508 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd
, message
, wParam
, lParam
);
510 msg
.message
= message
;
511 msg
.flags
= sent
|wparam
|lparam
;
512 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
515 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
518 defwndproc_counter
++;
519 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
520 defwndproc_counter
--;
525 static BOOL
register_parent_wnd_class(void)
530 cls
.lpfnWndProc
= parent_wnd_proc
;
533 cls
.hInstance
= GetModuleHandleA(NULL
);
535 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
536 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
537 cls
.lpszMenuName
= NULL
;
538 cls
.lpszClassName
= "Month-Cal test parent class";
539 return RegisterClassA(&cls
);
542 static HWND
create_parent_window(void)
546 InitCommonControls();
548 /* flush message sequences, so we can check the new sequence by the end of function */
549 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
551 if (!register_parent_wnd_class())
554 hwnd
= CreateWindowEx(0, "Month-Cal test parent class",
555 "Month-Cal test parent window",
556 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
557 WS_MAXIMIZEBOX
| WS_VISIBLE
,
559 GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
563 /* check for message sequences */
564 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_parent_window_seq
, "create parent window", FALSE
);
569 static LRESULT WINAPI
monthcal_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
571 struct subclass_info
*info
= (struct subclass_info
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
572 static LONG defwndproc_counter
= 0;
576 msg
.message
= message
;
577 msg
.flags
= sent
|wparam
|lparam
;
578 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
581 add_message(sequences
, MONTHCAL_SEQ_INDEX
, &msg
);
583 defwndproc_counter
++;
584 ret
= CallWindowProcA(info
->oldproc
, hwnd
, message
, wParam
, lParam
);
585 defwndproc_counter
--;
590 static HWND
create_monthcal_control(DWORD style
)
592 struct subclass_info
*info
;
595 info
= HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info
));
599 hwnd
= CreateWindowEx(0,
602 WS_CHILD
| WS_BORDER
| WS_VISIBLE
| style
,
604 parent_wnd
, NULL
, GetModuleHandleA(NULL
), NULL
);
608 HeapFree(GetProcessHeap(), 0, info
);
612 info
->oldproc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
,
613 (LONG_PTR
)monthcal_subclass_proc
);
614 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)info
);
616 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)GetStockObject(SYSTEM_FONT
), 0);
622 /* Setter and Getters Tests */
624 static void test_monthcal_color(void)
629 hwnd
= create_monthcal_control(0);
631 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
633 /* Setter and Getters for color*/
634 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
635 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_BACKGROUND
, RGB(0,0,0));
637 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
638 expect(RGB(0,0,0), temp
);
639 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_BACKGROUND
, RGB(255,255,255));
641 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_BACKGROUND
, 0);
642 expect(RGB(255,255,255), temp
);
644 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
645 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_MONTHBK
, RGB(0,0,0));
647 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
648 expect(RGB(0,0,0), temp
);
649 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_MONTHBK
, RGB(255,255,255));
651 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_MONTHBK
, 0);
652 expect(RGB(255,255,255), temp
);
654 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
655 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TEXT
, RGB(0,0,0));
657 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
658 expect(RGB(0,0,0), temp
);
659 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TEXT
, RGB(255,255,255));
661 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TEXT
, 0);
662 expect(RGB(255,255,255), temp
);
664 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
665 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TITLEBK
, RGB(0,0,0));
667 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
668 expect(RGB(0,0,0), temp
);
669 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TITLEBK
, RGB(255,255,255));
671 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLEBK
, 0);
672 expect(RGB(255,255,255), temp
);
674 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
675 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TITLETEXT
, RGB(0,0,0));
677 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
678 expect(RGB(0,0,0), temp
);
679 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TITLETEXT
, RGB(255,255,255));
681 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TITLETEXT
, 0);
682 expect(RGB(255,255,255), temp
);
684 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
685 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TRAILINGTEXT
, RGB(0,0,0));
687 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
688 expect(RGB(0,0,0), temp
);
689 res
= SendMessage(hwnd
, MCM_SETCOLOR
, MCSC_TRAILINGTEXT
, RGB(255,255,255));
691 temp
= SendMessage(hwnd
, MCM_GETCOLOR
, MCSC_TRAILINGTEXT
, 0);
692 expect(RGB(255,255,255), temp
);
694 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_color_seq
, "monthcal color", FALSE
);
699 static void test_monthcal_currdate(void)
701 SYSTEMTIME st_original
, st_new
, st_test
;
705 hwnd
= create_monthcal_control(0);
707 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
709 /* Setter and Getters for current date selected */
710 st_original
.wYear
= 2000;
711 st_original
.wMonth
= 11;
712 st_original
.wDay
= 28;
713 st_original
.wHour
= 11;
714 st_original
.wMinute
= 59;
715 st_original
.wSecond
= 30;
716 st_original
.wMilliseconds
= 0;
717 st_original
.wDayOfWeek
= 0;
719 st_new
= st_test
= st_original
;
721 /* Should not validate the time */
722 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
725 /* Overflow matters, check for wDay */
727 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
730 /* correct wDay before checking for wMonth */
732 expect(st_original
.wDay
, st_test
.wDay
);
734 /* Overflow matters, check for wMonth */
736 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st_test
);
739 /* checking if gets the information right, modify st_new */
747 res
= SendMessage(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_new
);
750 /* st_new change to st_origin, above settings with overflow */
751 /* should not change the current settings */
752 expect(st_original
.wYear
, st_new
.wYear
);
753 expect(st_original
.wMonth
, st_new
.wMonth
);
754 expect(st_original
.wDay
, st_new
.wDay
);
755 expect(st_original
.wHour
, st_new
.wHour
);
756 expect(st_original
.wMinute
, st_new
.wMinute
);
757 expect(st_original
.wSecond
, st_new
.wSecond
);
759 /* lparam cannot be NULL */
760 res
= SendMessage(hwnd
, MCM_GETCURSEL
, 0, 0);
763 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_curr_date_seq
, "monthcal currDate", TRUE
);
768 static void test_monthcal_firstDay(void)
770 int res
, fday
, i
, prev
;
772 LCID lcid
= LOCALE_USER_DEFAULT
;
775 hwnd
= create_monthcal_control(0);
777 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
779 /* Setter and Getters for first day of week */
780 /* check for locale first day */
781 if(GetLocaleInfo(lcid
, LOCALE_IFIRSTDAYOFWEEK
, b
, 128)){
783 trace("fday: %d\n", fday
);
784 res
= SendMessage(hwnd
, MCM_GETFIRSTDAYOFWEEK
, 0, 0);
788 /* checking for the values that actually will be stored as */
789 /* current first day when we set a new value */
790 for (i
= -5; i
< 12; i
++){
791 res
= SendMessage(hwnd
, MCM_SETFIRSTDAYOFWEEK
, 0, (LPARAM
) i
);
793 res
= SendMessage(hwnd
, MCM_GETFIRSTDAYOFWEEK
, 0, 0);
797 expect(MAKELONG(fday
, FALSE
), res
);
799 /* out of range sets max first day of week, locale is ignored */
800 expect(MAKELONG(6, TRUE
), res
);
802 expect(MAKELONG(i
, TRUE
), res
);
806 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_first_day_seq
, "monthcal firstDay", FALSE
);
809 skip("Cannot retrieve first day of the week\n");
815 static void test_monthcal_unicode(void)
820 hwnd
= create_monthcal_control(0);
822 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
824 /* Setter and Getters for Unicode format */
826 /* getting the current settings */
827 temp
= SendMessage(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
829 /* setting to 1, should return previous settings */
830 res
= SendMessage(hwnd
, MCM_SETUNICODEFORMAT
, 1, 0);
833 /* current setting is 1, so, should return 1 */
834 res
= SendMessage(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
835 todo_wine
{expect(1, res
);}
837 /* setting to 0, should return previous settings */
838 res
= SendMessage(hwnd
, MCM_SETUNICODEFORMAT
, 0, 0);
839 todo_wine
{expect(1, res
);}
841 /* current setting is 0, so, it should return 0 */
842 res
= SendMessage(hwnd
, MCM_GETUNICODEFORMAT
, 0, 0);
845 /* should return previous settings */
846 res
= SendMessage(hwnd
, MCM_SETUNICODEFORMAT
, 1, 0);
849 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_unicode_seq
, "monthcal unicode", FALSE
);
854 static void test_monthcal_hittest(void)
856 typedef struct hittest_test
862 static const hittest_test_t title_hits
[] = {
864 { MCHT_TITLEBTNPREV
, 0 },
865 { MCHT_TITLEMONTH
, 1 },
866 { MCHT_TITLEYEAR
, 1 },
867 { MCHT_TITLEBTNNEXT
, 0 },
879 memset(&mchit
, 0, sizeof(MCHITTESTINFO
));
881 hwnd
= create_monthcal_control(0);
883 /* test with invalid structure size */
884 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
- 1;
887 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
888 expect(0, mchit
.pt
.x
);
889 expect(0, mchit
.pt
.y
);
891 expect(0, mchit
.uHit
);
892 /* test with invalid pointer */
893 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
)NULL
);
896 /* resize control to display single Calendar */
897 res
= SendMessage(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r
);
900 win_skip("Message MCM_GETMINREQRECT unsupported. Skipping.\n");
904 MoveWindow(hwnd
, 0, 0, r
.right
, r
.bottom
, FALSE
);
906 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
914 st
.wMilliseconds
= 0;
917 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st
);
920 /* (0, 0) is the top left of the control - title */
921 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
;
924 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
925 expect(0, mchit
.pt
.x
);
926 expect(0, mchit
.pt
.y
);
927 expect(mchit
.uHit
, res
);
928 expect_hex(MCHT_TITLE
, res
);
930 /* bottom right of the control and should not be active */
931 mchit
.pt
.x
= r
.right
;
932 mchit
.pt
.y
= r
.bottom
;
933 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
)&mchit
);
934 expect(r
.right
, mchit
.pt
.x
);
935 expect(r
.bottom
, mchit
.pt
.y
);
936 expect(mchit
.uHit
, res
);
937 todo_wine
expect_hex(MCHT_NOWHERE
, res
);
939 /* completely out of the control, should not be active */
940 mchit
.pt
.x
= 2 * r
.right
;
941 mchit
.pt
.y
= 2 * r
.bottom
;
942 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
943 expect(2 * r
.right
, mchit
.pt
.x
);
944 expect(2 * r
.bottom
, mchit
.pt
.y
);
945 expect(mchit
.uHit
, res
);
946 todo_wine
expect_hex(MCHT_NOWHERE
, res
);
948 /* in active area - day of the week */
949 mchit
.pt
.x
= r
.right
/ 2;
950 mchit
.pt
.y
= r
.bottom
/ 2;
951 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
952 expect(r
.right
/ 2, mchit
.pt
.x
);
953 expect(r
.bottom
/ 2, mchit
.pt
.y
);
954 expect(mchit
.uHit
, res
);
955 expect_hex(MCHT_CALENDARDATE
, res
);
957 /* in active area - day of the week #2 */
958 mchit
.pt
.x
= r
.right
/ 14; /* half of first day rect */
959 mchit
.pt
.y
= r
.bottom
/ 2;
960 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
961 expect(r
.right
/ 14, mchit
.pt
.x
);
962 expect(r
.bottom
/ 2, mchit
.pt
.y
);
963 expect(mchit
.uHit
, res
);
964 expect_hex(MCHT_CALENDARDATE
, res
);
966 /* in active area - date from prev month */
967 mchit
.pt
.x
= r
.right
/ 14; /* half of first day rect */
968 mchit
.pt
.y
= 6 * r
.bottom
/ 19;
969 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
970 expect(r
.right
/ 14, mchit
.pt
.x
);
971 expect(6 * r
.bottom
/ 19, mchit
.pt
.y
);
972 expect(mchit
.uHit
, res
);
973 expect_hex(MCHT_CALENDARDATEPREV
, res
);
976 /* (125, 115) is in active area - date from this month */
979 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
980 expect(125, mchit
.pt
.x
);
981 expect(115, mchit
.pt
.y
);
982 expect(mchit
.uHit
, res
);
983 expect(MCHT_CALENDARDATE
, res
);
986 /* in active area - background section of the title */
987 mchit
.pt
.x
= 2 * r
.right
/ 7;
988 mchit
.pt
.y
= 2 * r
.bottom
/ 19;
989 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
990 expect(2 * r
.right
/ 7, mchit
.pt
.x
);
991 expect(2 * r
.bottom
/ 19, mchit
.pt
.y
);
992 expect(mchit
.uHit
, res
);
993 expect_hex(MCHT_TITLEBK
, res
);
995 /* in active area - month section of the title */
996 mchit
.pt
.x
= r
.right
/ 2;
997 mchit
.pt
.y
= 2 * r
.bottom
/ 19;
998 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
999 expect(r
.right
/ 2, mchit
.pt
.x
);
1000 expect(2 * r
.bottom
/ 19, mchit
.pt
.y
);
1001 expect(mchit
.uHit
, res
);
1002 expect_hex(MCHT_TITLE
, res
);
1004 /* in active area - year section of the title */
1005 mchit
.pt
.x
= 3 * r
.right
/ 4;
1006 mchit
.pt
.y
= 2 * r
.bottom
/ 19;
1007 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1008 expect(3 * r
.right
/ 4, mchit
.pt
.x
);
1009 expect(2 * r
.bottom
/ 19, mchit
.pt
.y
);
1010 expect(mchit
.uHit
, res
);
1011 expect_hex(MCHT_TITLE
, res
);
1013 /* in active area - date from next month */
1014 mchit
.pt
.x
= 11 * r
.right
/ 14;
1015 mchit
.pt
.y
= 16 * r
.bottom
/ 19;
1016 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1017 expect(11 * r
.right
/ 14, mchit
.pt
.x
);
1018 expect(16 * r
.bottom
/ 19, mchit
.pt
.y
);
1019 expect(mchit
.uHit
, res
);
1020 expect_hex(MCHT_CALENDARDATENEXT
, res
);
1022 /* in active area - today link */
1023 mchit
.pt
.x
= r
.right
/ 14;
1024 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1025 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1026 expect(r
.right
/ 14, mchit
.pt
.x
);
1027 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1028 expect(mchit
.uHit
, res
);
1029 expect_hex(MCHT_TODAYLINK
, res
);
1031 /* in active area - today link */
1032 mchit
.pt
.x
= r
.right
/ 2;
1033 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1034 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1035 expect(r
.right
/ 2, mchit
.pt
.x
);
1036 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1037 expect(mchit
.uHit
, res
);
1038 expect_hex(MCHT_TODAYLINK
, res
);
1040 /* in active area - today link */
1041 mchit
.pt
.x
= r
.right
/ 10;
1042 mchit
.pt
.y
= 18 * r
.bottom
/ 19;
1043 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1044 expect(r
.right
/ 10, mchit
.pt
.x
);
1045 expect(18 * r
.bottom
/ 19, mchit
.pt
.y
);
1046 expect(mchit
.uHit
, res
);
1047 expect_hex(MCHT_TODAYLINK
, res
);
1049 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_hit_test_seq
, "monthcal hit test", TRUE
);
1051 /* The horizontal position of title bar elements depends on locale (y pos
1052 is constant), so we sample across a horizontal line and make sure we
1053 find all elements. */
1055 mchit
.pt
.y
= (5/2) * r
.bottom
/ 19;
1057 old_res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1059 for (x
= 0; x
< r
.right
; x
++){
1061 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1062 expect(x
, mchit
.pt
.x
);
1063 expect((5/2) * r
.bottom
/ 19, mchit
.pt
.y
);
1064 expect(mchit
.uHit
, res
);
1066 if (res
!= MCHT_TITLEBK
&& res
!= old_res
) {
1070 if (sizeof(title_hits
) / sizeof(title_hits
[0]) <= title_index
)
1073 if (title_hits
[title_index
].todo
) {
1075 ok(title_hits
[title_index
].ht
== res
, "Expected %x, got %x, pos %d\n",
1076 title_hits
[title_index
].ht
, res
, x
);
1078 else ok(title_hits
[title_index
].ht
== res
, "Expected %x, got %x, pos %d\n",
1079 title_hits
[title_index
].ht
, res
, x
);
1084 ok(r
.right
<= x
&& title_index
+ 1 == sizeof(title_hits
) / sizeof(title_hits
[0]),
1085 "Wrong title layout\n");
1087 DestroyWindow(hwnd
);
1090 static void test_monthcal_todaylink(void)
1092 MCHITTESTINFO mchit
;
1093 SYSTEMTIME st_test
, st_new
;
1098 memset(&mchit
, 0, sizeof(MCHITTESTINFO
));
1100 hwnd
= create_monthcal_control(0);
1102 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1104 /* (70, 370) is in active area - today link */
1105 mchit
.cbSize
= MCHITTESTINFO_V1_SIZE
;
1108 res
= SendMessage(hwnd
, MCM_HITTEST
, 0, (LPARAM
) & mchit
);
1109 expect(70, mchit
.pt
.x
);
1110 expect(370, mchit
.pt
.y
);
1111 expect(mchit
.uHit
, res
);
1112 todo_wine
{expect(MCHT_TODAYLINK
, res
);}
1113 if (70 != mchit
.pt
.x
|| 370 != mchit
.pt
.y
|| mchit
.uHit
!= res
1114 || MCHT_TODAYLINK
!= res
)
1119 st_test
.wYear
= 2005;
1120 memset(&st_new
, 0, sizeof(SYSTEMTIME
));
1122 SendMessage(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1124 res
= SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1126 expect(1, st_new
.wDay
);
1127 expect(1, st_new
.wMonth
);
1128 expect(2005, st_new
.wYear
);
1129 if (1 != res
|| 1 != st_new
.wDay
|| 1 != st_new
.wMonth
1130 || 2005 != st_new
.wYear
)
1134 skip("cannot perform today link test\n");
1138 res
= SendMessage(hwnd
, WM_LBUTTONDOWN
, MK_LBUTTON
, MAKELONG(70, 370));
1141 memset(&st_new
, 0, sizeof(SYSTEMTIME
));
1142 res
= SendMessage(hwnd
, MCM_GETCURSEL
, 0, (LPARAM
)&st_new
);
1144 expect(1, st_new
.wDay
);
1145 expect(1, st_new
.wMonth
);
1146 expect(2005, st_new
.wYear
);
1148 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_todaylink_seq
, "monthcal hit test", TRUE
);
1150 DestroyWindow(hwnd
);
1153 static void test_monthcal_today(void)
1155 SYSTEMTIME st_test
, st_new
;
1159 hwnd
= create_monthcal_control(0);
1161 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1163 /* Setter and Getters for "today" information */
1165 /* check for overflow, should be ok */
1167 st_test
.wMonth
= 38;
1172 SendMessage(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1174 res
= SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1177 /* st_test should not change */
1178 expect(38, st_test
.wDay
);
1179 expect(38, st_test
.wMonth
);
1181 /* st_new should change, overflow does not matter */
1182 expect(38, st_new
.wDay
);
1183 expect(38, st_new
.wMonth
);
1185 /* check for zero, should be ok*/
1189 SendMessage(hwnd
, MCM_SETTODAY
, 0, (LPARAM
)&st_test
);
1191 res
= SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st_new
);
1194 /* st_test should not change */
1195 expect(0, st_test
.wDay
);
1196 expect(0, st_test
.wMonth
);
1198 /* st_new should change to zero*/
1199 expect(0, st_new
.wDay
);
1200 expect(0, st_new
.wMonth
);
1202 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_today_seq
, "monthcal today", TRUE
);
1204 DestroyWindow(hwnd
);
1207 static void test_monthcal_scroll(void)
1212 hwnd
= create_monthcal_control(0);
1214 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1216 /* Setter and Getters for scroll rate */
1217 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, 2, 0);
1220 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, 3, 0);
1222 res
= SendMessage(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1225 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, 12, 0);
1227 res
= SendMessage(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1230 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, 15, 0);
1232 res
= SendMessage(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1235 res
= SendMessage(hwnd
, MCM_SETMONTHDELTA
, -5, 0);
1237 res
= SendMessage(hwnd
, MCM_GETMONTHDELTA
, 0, 0);
1240 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_scroll_seq
, "monthcal scroll", FALSE
);
1242 DestroyWindow(hwnd
);
1245 static void test_monthcal_monthrange(void)
1248 SYSTEMTIME st_visible
[2], st_daystate
[2], st
;
1251 hwnd
= create_monthcal_control(0);
1253 st_visible
[0].wYear
= 0;
1254 st_visible
[0].wMonth
= 0;
1255 st_visible
[0].wDay
= 0;
1256 st_daystate
[1] = st_daystate
[0] = st_visible
[1] = st_visible
[0];
1264 st
.wMilliseconds
= 0;
1267 res
= SendMessage(hwnd
, MCM_SETCURSEL
, 0, (LPARAM
)&st
);
1270 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1272 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_VISIBLE
, (LPARAM
)st_visible
);
1275 expect(2000, st_visible
[0].wYear
);
1276 expect(11, st_visible
[0].wMonth
);
1277 expect(1, st_visible
[0].wDay
);
1278 expect(2000, st_visible
[1].wYear
);
1279 expect(12, st_visible
[1].wMonth
);
1280 expect(31, st_visible
[1].wDay
);
1282 res
= SendMessage(hwnd
, MCM_GETMONTHRANGE
, GMR_DAYSTATE
, (LPARAM
)st_daystate
);
1285 expect(2000, st_daystate
[0].wYear
);
1286 expect(10, st_daystate
[0].wMonth
);
1287 expect(29, st_daystate
[0].wDay
);
1288 expect(2001, st_daystate
[1].wYear
);
1289 expect(1, st_daystate
[1].wMonth
);
1290 expect(6, st_daystate
[1].wDay
);
1293 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_monthrange_seq
, "monthcal monthrange", FALSE
);
1295 DestroyWindow(hwnd
);
1298 static void test_monthcal_maxselday(void)
1303 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1305 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1307 /* Setter and Getters for max selected days */
1308 res
= SendMessage(hwnd
, MCM_SETMAXSELCOUNT
, 5, 0);
1310 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1313 res
= SendMessage(hwnd
, MCM_SETMAXSELCOUNT
, 15, 0);
1315 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1318 res
= SendMessage(hwnd
, MCM_SETMAXSELCOUNT
, -1, 0);
1319 todo_wine
{expect(0, res
);}
1320 res
= SendMessage(hwnd
, MCM_GETMAXSELCOUNT
, 0, 0);
1321 todo_wine
{expect(15, res
);}
1323 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, monthcal_max_sel_day_seq
, "monthcal MaxSelDay", FALSE
);
1325 DestroyWindow(hwnd
);
1328 static void test_monthcal_size(void)
1332 HFONT hFont1
, hFont2
;
1336 hwnd
= create_monthcal_control(0);
1338 lstrcpyA(logfont
.lfFaceName
, "Arial");
1339 memset(&logfont
, 0, sizeof(logfont
));
1340 logfont
.lfHeight
= 12;
1341 hFont1
= CreateFontIndirectA(&logfont
);
1343 logfont
.lfHeight
= 24;
1344 hFont2
= CreateFontIndirectA(&logfont
);
1346 /* initialize to a font we can compare against */
1347 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)hFont1
, 0);
1348 res
= SendMessage(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r1
);
1350 /* check that setting a larger font results in an larger rect */
1351 SendMessage(hwnd
, WM_SETFONT
, (WPARAM
)hFont2
, 0);
1352 res
= SendMessage(hwnd
, MCM_GETMINREQRECT
, 0, (LPARAM
)&r2
);
1354 OffsetRect(&r1
, -r1
.left
, -r1
.top
);
1355 OffsetRect(&r2
, -r2
.left
, -r2
.top
);
1357 ok(r1
.bottom
< r2
.bottom
, "Failed to get larger rect with larger font\n");
1359 DestroyWindow(hwnd
);
1362 static void test_monthcal_create(void)
1366 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1368 hwnd
= create_monthcal_control(0);
1369 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_monthcal_control_seq
, "create monthcal control", TRUE
);
1371 DestroyWindow(hwnd
);
1373 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1374 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1375 ok_sequence(sequences
, PARENT_SEQ_INDEX
, create_monthcal_multi_sel_style_seq
, "create monthcal (multi sel style)", TRUE
);
1376 DestroyWindow(hwnd
);
1379 static void test_monthcal_destroy(void)
1383 hwnd
= create_monthcal_control(0);
1384 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1385 DestroyWindow(hwnd
);
1386 ok_sequence(sequences
, PARENT_SEQ_INDEX
, destroy_monthcal_parent_msgs_seq
, "Destroy monthcal (parent msg)", FALSE
);
1387 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, destroy_monthcal_child_msgs_seq
, "Destroy monthcal (child msg)", FALSE
);
1389 /* MCS_MULTISELECT */
1390 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1391 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1392 DestroyWindow(hwnd
);
1393 ok_sequence(sequences
, MONTHCAL_SEQ_INDEX
, destroy_monthcal_multi_sel_style_seq
, "Destroy monthcal (multi sel style)", FALSE
);
1396 static void test_monthcal_getselrange(void)
1399 SYSTEMTIME st
, range
[2];
1402 hwnd
= create_monthcal_control(MCS_MULTISELECT
);
1404 /* just after creation selection should start and end today */
1405 ret
= SendMessage(hwnd
, MCM_GETTODAY
, 0, (LPARAM
)&st
);
1408 ret
= SendMessage(hwnd
, MCM_GETSELRANGE
, 0, (LPARAM
)range
);
1410 expect(st
.wYear
, range
[0].wYear
);
1411 expect(st
.wMonth
, range
[0].wMonth
);
1412 expect(st
.wDay
, range
[0].wDay
);
1413 expect(st
.wDayOfWeek
, range
[0].wDayOfWeek
);
1414 expect(st
.wHour
, range
[0].wHour
);
1415 expect(st
.wMinute
, range
[0].wMinute
);
1416 expect(st
.wSecond
, range
[0].wSecond
);
1417 expect(st
.wMilliseconds
, range
[0].wMilliseconds
);
1419 expect(st
.wYear
, range
[1].wYear
);
1420 expect(st
.wMonth
, range
[1].wMonth
);
1421 expect(st
.wDay
, range
[1].wDay
);
1422 expect(st
.wDayOfWeek
, range
[1].wDayOfWeek
);
1423 expect(st
.wHour
, range
[1].wHour
);
1424 expect(st
.wMinute
, range
[1].wMinute
);
1425 expect(st
.wSecond
, range
[1].wSecond
);
1426 expect(st
.wMilliseconds
, range
[1].wMilliseconds
);
1428 DestroyWindow(hwnd
);
1431 START_TEST(monthcal
)
1434 BOOL (WINAPI
*pInitCommonControlsEx
)(const INITCOMMONCONTROLSEX
*);
1435 INITCOMMONCONTROLSEX iccex
;
1437 hComctl32
= GetModuleHandleA("comctl32.dll");
1438 pInitCommonControlsEx
= (void*)GetProcAddress(hComctl32
, "InitCommonControlsEx");
1439 if (!pInitCommonControlsEx
)
1441 skip("InitCommonControlsEx() is missing. Skipping the tests\n");
1444 iccex
.dwSize
= sizeof(iccex
);
1445 iccex
.dwICC
= ICC_DATE_CLASSES
;
1446 pInitCommonControlsEx(&iccex
);
1450 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
1452 parent_wnd
= create_parent_window();
1454 test_monthcal_create();
1455 test_monthcal_destroy();
1456 test_monthcal_color();
1457 test_monthcal_currdate();
1458 test_monthcal_firstDay();
1459 test_monthcal_unicode();
1460 test_monthcal_today();
1461 test_monthcal_scroll();
1462 test_monthcal_monthrange();
1463 test_monthcal_hittest();
1464 test_monthcal_todaylink();
1465 test_monthcal_size();
1466 test_monthcal_maxselday();
1467 test_monthcal_getselrange();
1469 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1470 DestroyWindow(parent_wnd
);
1471 ok_sequence(sequences
, PARENT_SEQ_INDEX
, destroy_parent_seq
, "Destroy parent window", FALSE
);