1 /* 2 * comctl32 month calendar unit tests 3 * 4 * Copyright (C) 2006 Vitaliy Margolen 5 * Copyright (C) 2007 Farshad Agah 6 * 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. 11 * 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. 16 * 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 20 */ 21 22 #include <wine/test.h> 23 24 //#include <stdarg.h> 25 26 //#include "windef.h" 27 //#include "winbase.h" 28 #include <winuser.h> 29 #include <wingdi.h> 30 #include <winnls.h> 31 #include <commctrl.h> 32 33 #include "v6util.h" 34 //#include <assert.h> 35 //#include <windows.h> 36 #include "msg.h" 37 38 #define expect(expected, got) ok(expected == got, "Expected %d, got %d\n", expected, got); 39 #define expect_hex(expected, got) ok(expected == got, "Expected %x, got %x\n", expected, got); 40 #define expect_d(expected, got) ok(abs((expected) - (got)) <= 2, "Expected %d, got %d\n", expected, got); 41 42 #define NUM_MSG_SEQUENCES 2 43 #define PARENT_SEQ_INDEX 0 44 #define MONTHCAL_SEQ_INDEX 1 45 46 #define SEL_NOTIFY_TEST_ID 100 47 48 static struct msg_sequence *sequences[NUM_MSG_SEQUENCES]; 49 50 static HWND parent_wnd; 51 52 static const struct message create_parent_window_seq[] = { 53 { WM_GETMINMAXINFO, sent }, 54 { WM_NCCREATE, sent }, 55 { WM_NCCALCSIZE, sent|wparam, 0 }, 56 { WM_CREATE, sent }, 57 { WM_SHOWWINDOW, sent|wparam, 1 }, 58 { WM_WINDOWPOSCHANGING, sent|wparam, 0 }, 59 { WM_QUERYNEWPALETTE, sent|optional }, 60 { WM_WINDOWPOSCHANGING, sent|wparam|optional, 0 }, 61 { WM_WINDOWPOSCHANGED, sent|optional }, 62 { WM_ACTIVATEAPP, sent|wparam, 1 }, 63 { WM_NCACTIVATE, sent }, 64 { WM_ACTIVATE, sent|wparam, 1 }, 65 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, 66 { WM_IME_NOTIFY, sent|defwinproc|optional }, 67 { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, 68 /* Win9x adds SWP_NOZORDER below */ 69 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, 70 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, 71 { WM_SIZE, sent }, 72 { WM_MOVE, sent }, 73 { 0 } 74 }; 75 76 static const struct message create_monthcal_control_seq[] = { 77 { WM_NOTIFYFORMAT, sent|lparam, 0, NF_QUERY }, 78 { WM_QUERYUISTATE, sent|optional }, 79 { WM_GETFONT, sent }, 80 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE}, 81 { 0 } 82 }; 83 84 static const struct message create_monthcal_multi_sel_style_seq[] = { 85 { WM_NOTIFYFORMAT, sent|lparam, 0, NF_QUERY }, 86 { WM_QUERYUISTATE, sent|optional }, 87 { WM_GETFONT, sent }, 88 { WM_PARENTNOTIFY, sent }, 89 { 0 } 90 }; 91 92 static const struct message monthcal_curr_date_seq[] = { 93 { MCM_SETCURSEL, sent|wparam, 0}, 94 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0}, 95 { MCM_SETCURSEL, sent|wparam, 0}, 96 { MCM_SETCURSEL, sent|wparam, 0}, 97 { MCM_GETCURSEL, sent|wparam, 0}, 98 { MCM_GETCURSEL, sent|wparam|lparam, 0, 0}, 99 { 0 } 100 }; 101 102 static const struct message monthcal_first_day_seq[] = { 103 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 104 105 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -5}, 106 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 107 108 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -4}, 109 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 110 111 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -3}, 112 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 113 114 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -2}, 115 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 116 117 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, -1}, 118 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 119 120 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 121 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 122 123 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 1}, 124 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 125 126 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 2}, 127 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 128 129 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 3}, 130 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 131 132 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 4}, 133 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 134 135 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 5}, 136 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 137 138 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 6}, 139 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 140 141 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 7}, 142 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 143 144 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 8}, 145 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 146 147 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 9}, 148 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 149 150 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 10}, 151 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 152 153 { MCM_SETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 11}, 154 { MCM_GETFIRSTDAYOFWEEK, sent|wparam|lparam, 0, 0}, 155 { 0 } 156 }; 157 158 static const struct message monthcal_unicode_seq[] = { 159 { MCM_GETUNICODEFORMAT, sent|wparam|lparam, 0, 0}, 160 { MCM_SETUNICODEFORMAT, sent|wparam|lparam, 1, 0}, 161 { MCM_GETUNICODEFORMAT, sent|wparam|lparam, 0, 0}, 162 { MCM_SETUNICODEFORMAT, sent|wparam|lparam, 0, 0}, 163 { MCM_GETUNICODEFORMAT, sent|wparam|lparam, 0, 0}, 164 { MCM_SETUNICODEFORMAT, sent|wparam|lparam, 1, 0}, 165 { 0 } 166 }; 167 168 static const struct message monthcal_hit_test_seq[] = { 169 { MCM_SETCURSEL, sent|wparam, 0}, 170 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0}, 171 { MCM_HITTEST, sent|wparam, 0}, 172 { MCM_HITTEST, sent|wparam, 0}, 173 { MCM_HITTEST, sent|wparam, 0}, 174 { MCM_HITTEST, sent|wparam, 0}, 175 { MCM_HITTEST, sent|wparam, 0}, 176 { MCM_HITTEST, sent|wparam, 0}, 177 { MCM_HITTEST, sent|wparam, 0}, 178 { MCM_HITTEST, sent|wparam, 0}, 179 { MCM_HITTEST, sent|wparam, 0}, 180 { MCM_HITTEST, sent|wparam, 0}, 181 { 0 } 182 }; 183 184 static const struct message monthcal_todaylink_seq[] = { 185 { MCM_HITTEST, sent|wparam, 0}, 186 { MCM_SETTODAY, sent|wparam, 0}, 187 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0}, 188 { MCM_GETTODAY, sent|wparam, 0}, 189 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON}, 190 { WM_CAPTURECHANGED, sent|wparam|lparam|defwinproc, 0, 0}, 191 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0}, 192 { MCM_GETCURSEL, sent|wparam, 0}, 193 { 0 } 194 }; 195 196 static const struct message monthcal_today_seq[] = { 197 { MCM_SETTODAY, sent|wparam, 0}, 198 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0}, 199 { MCM_GETTODAY, sent|wparam, 0}, 200 { MCM_SETTODAY, sent|wparam, 0}, 201 { WM_PAINT, sent|wparam|lparam|defwinproc, 0, 0}, 202 { MCM_GETTODAY, sent|wparam, 0}, 203 { 0 } 204 }; 205 206 static const struct message monthcal_scroll_seq[] = { 207 { MCM_SETMONTHDELTA, sent|wparam|lparam, 2, 0}, 208 { MCM_SETMONTHDELTA, sent|wparam|lparam, 3, 0}, 209 { MCM_GETMONTHDELTA, sent|wparam|lparam, 0, 0}, 210 { MCM_SETMONTHDELTA, sent|wparam|lparam, 12, 0}, 211 { MCM_GETMONTHDELTA, sent|wparam|lparam, 0, 0}, 212 { MCM_SETMONTHDELTA, sent|wparam|lparam, 15, 0}, 213 { MCM_GETMONTHDELTA, sent|wparam|lparam, 0, 0}, 214 { MCM_SETMONTHDELTA, sent|wparam|lparam, -5, 0}, 215 { MCM_GETMONTHDELTA, sent|wparam|lparam, 0, 0}, 216 { 0 } 217 }; 218 219 static const struct message monthcal_monthrange_seq[] = { 220 { MCM_GETMONTHRANGE, sent|wparam, GMR_VISIBLE}, 221 { MCM_GETMONTHRANGE, sent|wparam, GMR_DAYSTATE}, 222 { 0 } 223 }; 224 225 static const struct message monthcal_max_sel_day_seq[] = { 226 { MCM_SETMAXSELCOUNT, sent|wparam|lparam, 5, 0}, 227 { MCM_GETMAXSELCOUNT, sent|wparam|lparam, 0, 0}, 228 { MCM_SETMAXSELCOUNT, sent|wparam|lparam, 15, 0}, 229 { MCM_GETMAXSELCOUNT, sent|wparam|lparam, 0, 0}, 230 { MCM_SETMAXSELCOUNT, sent|wparam|lparam, -1, 0}, 231 { MCM_GETMAXSELCOUNT, sent|wparam|lparam, 0, 0}, 232 { 0 } 233 }; 234 235 /* expected message sequence for parent*/ 236 static const struct message destroy_monthcal_parent_msgs_seq[] = { 237 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY}, 238 { 0 } 239 }; 240 241 /* expected message sequence for child*/ 242 static const struct message destroy_monthcal_child_msgs_seq[] = { 243 { 0x0090, sent|optional }, /* Vista */ 244 { WM_SHOWWINDOW, sent|wparam|lparam, 0, 0}, 245 { WM_WINDOWPOSCHANGING, sent|wparam, 0}, 246 { WM_WINDOWPOSCHANGED, sent|wparam, 0}, 247 { WM_DESTROY, sent|wparam|lparam, 0, 0}, 248 { WM_NCDESTROY, sent|wparam|lparam, 0, 0}, 249 { 0 } 250 }; 251 252 static const struct message destroy_monthcal_multi_sel_style_seq[] = { 253 { 0x0090, sent|optional }, /* Vista */ 254 { WM_SHOWWINDOW, sent|wparam|lparam, 0, 0}, 255 { WM_WINDOWPOSCHANGING, sent|wparam, 0}, 256 { WM_WINDOWPOSCHANGED, sent|wparam, 0}, 257 { WM_DESTROY, sent|wparam|lparam, 0, 0}, 258 { WM_NCDESTROY, sent|wparam|lparam, 0, 0}, 259 { 0 } 260 }; 261 262 static void test_monthcal(void) 263 { 264 HWND hwnd; 265 SYSTEMTIME st[2], st1[2], today; 266 int res, month_range; 267 DWORD limits; 268 BOOL r; 269 270 hwnd = CreateWindowA(MONTHCAL_CLASSA, "MonthCal", WS_POPUP | WS_VISIBLE, CW_USEDEFAULT, 271 0, 300, 300, 0, 0, NULL, NULL); 272 ok(hwnd != NULL, "Failed to create MonthCal\n"); 273 274 /* test range just after creation */ 275 memset(&st, 0xcc, sizeof(st)); 276 limits = SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st); 277 ok(limits == 0 || 278 broken(limits == GDTR_MIN), /* comctl32 <= 4.70 */ 279 "No limits should be set (%d)\n", limits); 280 if (limits == GDTR_MIN) 281 { 282 win_skip("comctl32 <= 4.70 is broken\n"); 283 DestroyWindow(hwnd); 284 return; 285 } 286 287 ok(0 == st[0].wYear || 288 broken(1752 == st[0].wYear), /* comctl32 <= 4.72 */ 289 "Expected 0, got %d\n", st[0].wYear); 290 ok(0 == st[0].wMonth || 291 broken(9 == st[0].wMonth), /* comctl32 <= 4.72 */ 292 "Expected 0, got %d\n", st[0].wMonth); 293 ok(0 == st[0].wDay || 294 broken(14 == st[0].wDay), /* comctl32 <= 4.72 */ 295 "Expected 0, got %d\n", st[0].wDay); 296 expect(0, st[0].wDayOfWeek); 297 expect(0, st[0].wHour); 298 expect(0, st[0].wMinute); 299 expect(0, st[0].wSecond); 300 expect(0, st[0].wMilliseconds); 301 302 expect(0, st[1].wYear); 303 expect(0, st[1].wMonth); 304 expect(0, st[1].wDay); 305 expect(0, st[1].wDayOfWeek); 306 expect(0, st[1].wHour); 307 expect(0, st[1].wMinute); 308 expect(0, st[1].wSecond); 309 expect(0, st[1].wMilliseconds); 310 311 limits = SendMessageA(hwnd, MCM_GETRANGE, 0, 0); 312 ok(limits == 0, "got %u\n", limits); 313 314 GetSystemTime(&st[0]); 315 st[1] = st[0]; 316 317 SendMessageA(hwnd, MCM_GETTODAY, 0, (LPARAM)&today); 318 319 /* Invalid date/time */ 320 st[0].wYear = 2000; 321 /* Time should not matter */ 322 st[1].wHour = st[1].wMinute = st[1].wSecond = 70; 323 st[1].wMilliseconds = 1200; 324 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set MAX limit\n"); 325 /* invalid timestamp is written back with today data and msecs untouched */ 326 expect(today.wHour, st[1].wHour); 327 expect(today.wMinute, st[1].wMinute); 328 expect(today.wSecond, st[1].wSecond); 329 expect(1200, st[1].wMilliseconds); 330 331 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n"); 332 ok(st1[0].wYear != 2000, "Lower limit changed\n"); 333 /* invalid timestamp should be replaced with today data, except msecs */ 334 expect(today.wHour, st1[1].wHour); 335 expect(today.wMinute, st1[1].wMinute); 336 expect(today.wSecond, st1[1].wSecond); 337 expect(1200, st1[1].wMilliseconds); 338 339 /* Invalid date/time with invalid milliseconds only */ 340 GetSystemTime(&st[0]); 341 st[1] = st[0]; 342 /* Time should not matter */ 343 st[1].wMilliseconds = 1200; 344 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set MAX limit\n"); 345 /* invalid milliseconds field doesn't lead to invalid timestamp */ 346 expect(st[0].wHour, st[1].wHour); 347 expect(st[0].wMinute, st[1].wMinute); 348 expect(st[0].wSecond, st[1].wSecond); 349 expect(1200, st[1].wMilliseconds); 350 351 GetSystemTime(&st[0]); 352 353 st[1].wMonth = 0; 354 ok(!SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), 355 "Should have failed to set limits\n"); 356 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n"); 357 ok(st1[0].wYear != 2000, "Lower limit changed\n"); 358 ok(!SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), 359 "Should have failed to set MAX limit\n"); 360 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "No limits should be set\n"); 361 ok(st1[0].wYear != 2000, "Lower limit changed\n"); 362 363 GetSystemTime(&st[0]); 364 st[0].wDay = 20; 365 st[0].wMonth = 5; 366 st[1] = st[0]; 367 368 month_range = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1); 369 st[1].wMonth--; 370 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), 371 "Failed to set both min and max limits\n"); 372 res = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1); 373 ok(res == month_range, "Invalid month range (%d)\n", res); 374 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == (GDTR_MIN|GDTR_MAX), 375 "Limits should be set\n"); 376 377 st[1].wMonth += 2; 378 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), 379 "Failed to set both min and max limits\n"); 380 res = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st1); 381 ok(res == month_range, "Invalid month range (%d)\n", res); 382 383 st[1].wYear --; 384 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), 385 "Failed to set both min and max limits\n"); 386 st[1].wYear += 1; 387 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN | GDTR_MAX, (LPARAM)st), 388 "Failed to set both min and max limits\n"); 389 390 st[1].wMonth -= 3; 391 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n"); 392 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, 393 "Only MAX limit should be set\n"); 394 st[1].wMonth += 4; 395 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n"); 396 st[1].wYear -= 3; 397 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n"); 398 st[1].wYear += 4; 399 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n"); 400 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, 401 "Only MAX limit should be set\n"); 402 403 /* set both limits, then set max < min */ 404 GetSystemTime(&st[0]); 405 st[0].wDay = 25; 406 st[1] = st[0]; 407 st[1].wYear++; 408 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN|GDTR_MAX, (LPARAM)st), "Failed to set limits\n"); 409 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == (GDTR_MIN|GDTR_MAX), 410 "Min limit expected\n"); 411 st[1].wYear -= 2; 412 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set limits\n"); 413 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "Max limit expected\n"); 414 415 expect(0, st1[0].wYear); 416 expect(0, st1[0].wMonth); 417 expect(0, st1[0].wDay); 418 expect(0, st1[0].wDayOfWeek); 419 expect(0, st1[0].wHour); 420 expect(0, st1[0].wMinute); 421 expect(0, st1[0].wSecond); 422 expect(0, st1[0].wMilliseconds); 423 424 expect(st[1].wYear, st1[1].wYear); 425 expect(st[1].wMonth, st1[1].wMonth); 426 expect(st[1].wDay, st1[1].wDay); 427 expect(st[1].wDayOfWeek, st1[1].wDayOfWeek); 428 expect(st[1].wHour, st1[1].wHour); 429 expect(st[1].wMinute, st1[1].wMinute); 430 expect(st[1].wSecond, st1[1].wSecond); 431 expect(st[1].wMilliseconds, st1[1].wMilliseconds); 432 433 st[1] = st[0]; 434 st[1].wYear++; 435 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN|GDTR_MAX, (LPARAM)st), "Failed to set limits\n"); 436 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == (GDTR_MIN|GDTR_MAX), 437 "Min limit expected\n"); 438 st[0].wYear++; /* start == end now */ 439 ok(SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN, (LPARAM)st), "Failed to set limits\n"); 440 ok(SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MIN, "Min limit expected\n"); 441 442 expect(st[0].wYear, st1[0].wYear); 443 expect(st[0].wMonth, st1[0].wMonth); 444 expect(st[0].wDay, st1[0].wDay); 445 expect(st[0].wDayOfWeek, st1[0].wDayOfWeek); 446 expect(st[0].wHour, st1[0].wHour); 447 expect(st[0].wMinute, st1[0].wMinute); 448 expect(st[0].wSecond, st1[0].wSecond); 449 expect(st[0].wMilliseconds, st1[0].wMilliseconds); 450 451 expect(0, st1[1].wYear); 452 expect(0, st1[1].wMonth); 453 expect(0, st1[1].wDay); 454 expect(0, st1[1].wDayOfWeek); 455 expect(0, st1[1].wHour); 456 expect(0, st1[1].wMinute); 457 expect(0, st1[1].wSecond); 458 expect(0, st1[1].wMilliseconds); 459 460 /* 0 limit flags */ 461 limits = SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1); 462 ok(limits == GDTR_MIN, "got 0x%08x\n", limits); 463 464 GetSystemTime(st); 465 st[1] = st[0]; 466 st[1].wYear++; 467 r = SendMessageA(hwnd, MCM_SETRANGE, 0, (LPARAM)st); 468 ok(r, "got %d\n", r); 469 470 limits = SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st); 471 ok(limits == 0, "got 0x%08x\n", limits); 472 ok(st[0].wYear == 0 && st[1].wYear == 0, "got %u, %u\n", st[0].wYear, st[1].wYear); 473 474 /* flags are 0, set min limit */ 475 GetSystemTime(st); 476 st[1] = st[0]; 477 st[1].wYear++; 478 479 r = SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN, (LPARAM)st); 480 ok(r, "got %d\n", r); 481 482 limits = SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1); 483 ok(limits == GDTR_MIN, "got 0x%08x\n", limits); 484 ok(st1[1].wYear == 0, "got %u\n", st1[1].wYear); 485 486 /* now set max limit, check flags */ 487 r = SendMessageA(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st); 488 ok(r, "got %d\n", r); 489 490 limits = SendMessageA(hwnd, MCM_GETRANGE, 0, (LPARAM)st1); 491 ok(limits == GDTR_MAX, "got 0x%08x\n", limits); 492 ok(st1[0].wYear == 0, "got %u\n", st1[0].wYear); 493 494 DestroyWindow(hwnd); 495 } 496 497 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 498 { 499 static LONG defwndproc_counter = 0; 500 LRESULT ret; 501 struct message msg; 502 503 /* log system messages, except for painting */ 504 if (message < WM_USER && 505 message != WM_PAINT && 506 message != WM_ERASEBKGND && 507 message != WM_NCPAINT && 508 message != WM_NCHITTEST && 509 message != WM_GETTEXT && 510 message != WM_GETICON && 511 message != WM_DEVICECHANGE) 512 { 513 msg.message = message; 514 msg.flags = sent|wparam|lparam; 515 if (defwndproc_counter) msg.flags |= defwinproc; 516 msg.wParam = wParam; 517 msg.lParam = lParam; 518 add_message(sequences, PARENT_SEQ_INDEX, &msg); 519 } 520 521 if (message == WM_NOTIFY) 522 { 523 NMHDR *hdr = (NMHDR*)lParam; 524 switch (hdr->code) 525 { 526 case MCN_GETDAYSTATE: 527 { 528 NMDAYSTATE *nmstate = (NMDAYSTATE*)lParam; 529 static MONTHDAYSTATE months[14] = { 0 }; 530 531 ok(nmstate->cDayState > 0, "got %d\n", nmstate->cDayState); 532 ok(nmstate->cDayState <= 14, "got %d\n", nmstate->cDayState); 533 ok(nmstate->prgDayState != NULL, "got %p\n", nmstate->prgDayState); 534 535 nmstate->prgDayState = months; 536 537 return TRUE; 538 } 539 case MCN_SELECT: 540 case MCN_SELCHANGE: 541 { 542 NMSELCHANGE *nmchg = (NMSELCHANGE*)lParam; 543 SYSTEMTIME st[2]; 544 BOOL is_multisel = GetWindowLongPtrA(nmchg->nmhdr.hwndFrom, GWL_STYLE) & MCS_MULTISELECT; 545 546 if(GetWindowLongPtrA(nmchg->nmhdr.hwndFrom, GWLP_ID) != SEL_NOTIFY_TEST_ID) 547 break; 548 SendMessageA(nmchg->nmhdr.hwndFrom, is_multisel ? MCM_GETSELRANGE : MCM_GETCURSEL, 549 0, (LPARAM)st); 550 551 expect(st[0].wYear, nmchg->stSelStart.wYear); 552 expect(st[0].wMonth, nmchg->stSelStart.wMonth); 553 expect(0, nmchg->stSelStart.wDayOfWeek); 554 expect(st[0].wDay, nmchg->stSelStart.wDay); 555 556 if(is_multisel) 557 { 558 expect(st[1].wYear, nmchg->stSelEnd.wYear); 559 expect(st[1].wMonth, nmchg->stSelEnd.wMonth); 560 expect(0, nmchg->stSelEnd.wDayOfWeek); 561 expect(st[1].wDay, nmchg->stSelEnd.wDay); 562 } 563 else 564 ok(!(nmchg->stSelEnd.wYear | nmchg->stSelEnd.wMonth | 565 nmchg->stSelEnd.wDayOfWeek | nmchg->stSelEnd.wDay | 566 nmchg->stSelEnd.wHour | nmchg->stSelEnd.wMinute | 567 nmchg->stSelEnd.wSecond | nmchg->stSelEnd.wMilliseconds), 568 "Non-zero member in stSelEnd\n"); 569 return TRUE; 570 } 571 default: 572 break; 573 } 574 } 575 576 defwndproc_counter++; 577 ret = DefWindowProcA(hwnd, message, wParam, lParam); 578 defwndproc_counter--; 579 580 return ret; 581 } 582 583 static BOOL register_parent_wnd_class(void) 584 { 585 WNDCLASSA cls; 586 587 cls.style = 0; 588 cls.lpfnWndProc = parent_wnd_proc; 589 cls.cbClsExtra = 0; 590 cls.cbWndExtra = 0; 591 cls.hInstance = GetModuleHandleA(NULL); 592 cls.hIcon = 0; 593 cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); 594 cls.hbrBackground = GetStockObject(WHITE_BRUSH); 595 cls.lpszMenuName = NULL; 596 cls.lpszClassName = "Month-Cal test parent class"; 597 return RegisterClassA(&cls); 598 } 599 600 static HWND create_parent_window(void) 601 { 602 HWND hwnd; 603 604 InitCommonControls(); 605 606 /* flush message sequences, so we can check the new sequence by the end of function */ 607 flush_sequences(sequences, NUM_MSG_SEQUENCES); 608 609 if (!register_parent_wnd_class()) 610 return NULL; 611 612 hwnd = CreateWindowExA(0, "Month-Cal test parent class", "Month-Cal test parent window", 613 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE, 614 0, 0, 500, 500, GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL); 615 ok(hwnd != NULL, "failed to create parent wnd\n"); 616 617 /* check for message sequences */ 618 ok_sequence(sequences, PARENT_SEQ_INDEX, create_parent_window_seq, "create parent window", FALSE); 619 620 return hwnd; 621 } 622 623 static LRESULT WINAPI monthcal_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 624 { 625 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); 626 static LONG defwndproc_counter = 0; 627 struct message msg = { 0 }; 628 LRESULT ret; 629 630 msg.message = message; 631 msg.flags = sent|wparam|lparam; 632 if (defwndproc_counter) msg.flags |= defwinproc; 633 msg.wParam = wParam; 634 msg.lParam = lParam; 635 add_message(sequences, MONTHCAL_SEQ_INDEX, &msg); 636 637 /* some debug output for style changing */ 638 if ((message == WM_STYLECHANGING || 639 message == WM_STYLECHANGED) && lParam) 640 { 641 STYLESTRUCT *style = (STYLESTRUCT*)lParam; 642 trace("\told style: 0x%08x, new style: 0x%08x\n", style->styleOld, style->styleNew); 643 } 644 645 defwndproc_counter++; 646 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); 647 defwndproc_counter--; 648 649 return ret; 650 } 651 652 static HWND create_monthcal_control(DWORD style) 653 { 654 WNDPROC oldproc; 655 RECT rect; 656 HWND hwnd; 657 BOOL ret; 658 659 hwnd = CreateWindowExA(0, MONTHCAL_CLASSA, "", WS_CHILD | WS_BORDER | WS_VISIBLE | style, 660 0, 0, 300, 400, parent_wnd, NULL, GetModuleHandleA(NULL), NULL); 661 ok(hwnd != NULL, "failed to create monthcal wnd\n"); 662 if (!hwnd) return NULL; 663 664 oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, 665 (LONG_PTR)monthcal_subclass_proc); 666 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); 667 668 SendMessageA(hwnd, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0); 669 670 /* make sure calendar grid is 2x1 */ 671 ret = SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&rect); 672 ok(ret, "got %d\n", ret); 673 674 ret = SetWindowPos(hwnd, NULL, 0, 0, rect.right * 5 / 2, rect.bottom * 3 / 2, SWP_NOMOVE); 675 ok(ret, "got %d\n", ret); 676 677 return hwnd; 678 } 679 680 681 /* Setter and Getters Tests */ 682 683 static void test_color(void) 684 { 685 COLORREF color, prev; 686 HWND hwnd; 687 688 hwnd = create_monthcal_control(0); 689 690 /* invalid color index */ 691 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TRAILINGTEXT + 1, 0); 692 expect(~0u, color); 693 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TRAILINGTEXT + 1, RGB(255,255,255)); 694 expect(~0u, prev); 695 696 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_BACKGROUND, 0); 697 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_BACKGROUND, RGB(0,0,0)); 698 expect(color, prev); 699 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_BACKGROUND, 0); 700 expect(RGB(0,0,0), color); 701 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_BACKGROUND, RGB(255,255,255)); 702 expect(color, prev); 703 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_BACKGROUND, 0); 704 expect(RGB(255,255,255), color); 705 706 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_MONTHBK, 0); 707 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_MONTHBK, RGB(0,0,0)); 708 expect(color, prev); 709 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_MONTHBK, 0); 710 expect(RGB(0,0,0), color); 711 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_MONTHBK, RGB(255,255,255)); 712 expect(color, prev); 713 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_MONTHBK, 0); 714 expect(RGB(255,255,255), color); 715 716 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TEXT, 0); 717 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TEXT, RGB(0,0,0)); 718 expect(color, prev); 719 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TEXT, 0); 720 expect(RGB(0,0,0), color); 721 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TEXT, RGB(255,255,255)); 722 expect(color, prev); 723 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TEXT, 0); 724 expect(RGB(255,255,255), color); 725 726 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TITLEBK, 0); 727 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TITLEBK, RGB(0,0,0)); 728 expect(color, prev); 729 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TITLEBK, 0); 730 expect(RGB(0,0,0), color); 731 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TITLEBK, RGB(255,255,255)); 732 expect(color, prev); 733 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TITLEBK, 0); 734 expect(RGB(255,255,255), color); 735 736 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TITLETEXT, 0); 737 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TITLETEXT, RGB(0,0,0)); 738 expect(color, prev); 739 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TITLETEXT, 0); 740 expect(RGB(0,0,0), color); 741 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TITLETEXT, RGB(255,255,255)); 742 expect(color, prev); 743 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TITLETEXT, 0); 744 expect(RGB(255,255,255), color); 745 746 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TRAILINGTEXT, 0); 747 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TRAILINGTEXT, RGB(0,0,0)); 748 expect(color, prev); 749 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TRAILINGTEXT, 0); 750 expect(RGB(0,0,0), color); 751 prev = SendMessageA(hwnd, MCM_SETCOLOR, MCSC_TRAILINGTEXT, RGB(255,255,255)); 752 expect(color, prev); 753 color = SendMessageA(hwnd, MCM_GETCOLOR, MCSC_TRAILINGTEXT, 0); 754 expect(RGB(255,255,255), color); 755 756 DestroyWindow(hwnd); 757 } 758 759 static void test_currdate(void) 760 { 761 SYSTEMTIME st_original, st_new, st_test; 762 int res; 763 HWND hwnd; 764 765 hwnd = create_monthcal_control(0); 766 767 flush_sequences(sequences, NUM_MSG_SEQUENCES); 768 769 /* Setter and Getters for current date selected */ 770 st_original.wYear = 2000; 771 st_original.wMonth = 11; 772 st_original.wDay = 28; 773 st_original.wHour = 11; 774 st_original.wMinute = 59; 775 st_original.wSecond = 30; 776 st_original.wMilliseconds = 0; 777 st_original.wDayOfWeek = 0; 778 779 st_new = st_test = st_original; 780 781 /* Should not validate the time */ 782 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_test); 783 expect(1,res); 784 785 /* Overflow matters, check for wDay */ 786 st_test.wDay += 4; 787 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_test); 788 expect(0,res); 789 790 /* correct wDay before checking for wMonth */ 791 st_test.wDay -= 4; 792 expect(st_original.wDay, st_test.wDay); 793 794 /* Overflow matters, check for wMonth */ 795 st_test.wMonth += 4; 796 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_test); 797 expect(0,res); 798 799 /* checking if gets the information right, modify st_new */ 800 st_new.wYear += 4; 801 st_new.wMonth += 4; 802 st_new.wDay += 4; 803 st_new.wHour += 4; 804 st_new.wMinute += 4; 805 st_new.wSecond += 4; 806 807 res = SendMessageA(hwnd, MCM_GETCURSEL, 0, (LPARAM)&st_new); 808 expect(1, res); 809 810 /* st_new change to st_origin, above settings with overflow */ 811 /* should not change the current settings */ 812 expect(st_original.wYear, st_new.wYear); 813 expect(st_original.wMonth, st_new.wMonth); 814 expect(st_original.wDay, st_new.wDay); 815 ok(st_original.wHour == st_new.wHour || 816 broken(0 == st_new.wHour), /* comctl32 <= 4.70 */ 817 "Expected %d, got %d\n", st_original.wHour, st_new.wHour); 818 ok(st_original.wMinute == st_new.wMinute || 819 broken(0 == st_new.wMinute), /* comctl32 <= 4.70 */ 820 "Expected %d, got %d\n", st_original.wMinute, st_new.wMinute); 821 ok(st_original.wSecond == st_new.wSecond || 822 broken(0 == st_new.wSecond), /* comctl32 <= 4.70 */ 823 "Expected %d, got %d\n", st_original.wSecond, st_new.wSecond); 824 825 /* lparam cannot be NULL */ 826 res = SendMessageA(hwnd, MCM_GETCURSEL, 0, 0); 827 expect(0, res); 828 829 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_curr_date_seq, "monthcal currDate", TRUE); 830 831 /* December, 31, 9999 is the maximum allowed date */ 832 memset(&st_new, 0, sizeof(st_new)); 833 st_new.wYear = 9999; 834 st_new.wMonth = 12; 835 st_new.wDay = 31; 836 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_new); 837 expect(1, res); 838 memset(&st_test, 0, sizeof(st_test)); 839 res = SendMessageA(hwnd, MCM_GETCURSEL, 0, (LPARAM)&st_test); 840 expect(1, res); 841 expect(st_new.wYear, st_test.wYear); 842 expect(st_new.wMonth, st_test.wMonth); 843 expect(st_new.wDay, st_test.wDay); 844 expect(st_new.wHour, st_test.wHour); 845 expect(st_new.wMinute, st_test.wMinute); 846 expect(st_new.wSecond, st_test.wSecond); 847 /* try one day later */ 848 st_original = st_new; 849 st_new.wYear = 10000; 850 st_new.wMonth = 1; 851 st_new.wDay = 1; 852 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_new); 853 ok(0 == res || 854 broken(1 == res), /* comctl32 <= 4.72 */ 855 "Expected 0, got %d\n", res); 856 if (0 == res) 857 { 858 memset(&st_test, 0, sizeof(st_test)); 859 res = SendMessageA(hwnd, MCM_GETCURSEL, 0, (LPARAM)&st_test); 860 expect(1, res); 861 expect(st_original.wYear, st_test.wYear); 862 expect(st_original.wMonth, st_test.wMonth); 863 expect(st_original.wDay, st_test.wDay); 864 expect(st_original.wHour, st_test.wHour); 865 expect(st_original.wMinute, st_test.wMinute); 866 expect(st_original.wSecond, st_test.wSecond); 867 } 868 869 /* setting selection equal to current reports success even if out range */ 870 memset(&st_new, 0, sizeof(st_new)); 871 st_new.wYear = 2009; 872 st_new.wDay = 5; 873 st_new.wMonth = 10; 874 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_new); 875 expect(1, res); 876 memset(&st_test, 0, sizeof(st_test)); 877 st_test.wYear = 2009; 878 st_test.wDay = 6; 879 st_test.wMonth = 10; 880 res = SendMessageA(hwnd, MCM_SETRANGE, GDTR_MIN, (LPARAM)&st_test); 881 expect(1, res); 882 /* set to current again */ 883 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_new); 884 expect(1, res); 885 886 /* set with invalid day of week */ 887 memset(&st_test, 0, sizeof(st_test)); 888 st_test.wYear = 2009; 889 st_test.wDay = 7; 890 st_test.wMonth = 10; 891 st_test.wDayOfWeek = 100; 892 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st_test); 893 expect(1, res); 894 895 memset(&st_test, 0, sizeof(st_test)); 896 res = SendMessageA(hwnd, MCM_GETCURSEL, 0, (LPARAM)&st_test); 897 expect(1, res); 898 expect(2009, st_test.wYear); 899 expect(7, st_test.wDay); 900 expect(10, st_test.wMonth); 901 expect(3, st_test.wDayOfWeek); 902 903 DestroyWindow(hwnd); 904 } 905 906 static void test_firstDay(void) 907 { 908 int res, fday, i, prev; 909 CHAR b[128], caltype[3]; 910 LCID lcid = LOCALE_USER_DEFAULT; 911 HWND hwnd; 912 LRESULT ret; 913 914 SetLastError(0xdeadbeef); 915 ret = GetLocaleInfoA(lcid, LOCALE_ICALENDARTYPE, caltype, 3); 916 if (ret == 0) { 917 skip("Must know local calendar type (%x)\n", GetLastError()); 918 return; 919 } else if (atoi(caltype) != CAL_GREGORIAN) { 920 skip("MonthCalendar Control only supports Gregorian calendar (type: %s)\n", caltype); 921 return; 922 } 923 924 hwnd = create_monthcal_control(0); 925 926 flush_sequences(sequences, NUM_MSG_SEQUENCES); 927 928 /* Setter and Getters for first day of week */ 929 /* check for locale first day */ 930 if(GetLocaleInfoA(lcid, LOCALE_IFIRSTDAYOFWEEK, b, 128)){ 931 fday = atoi(b); 932 res = SendMessageA(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0); 933 expect(fday, res); 934 prev = fday; 935 936 /* checking for the values that actually will be stored as */ 937 /* current first day when we set a new value */ 938 for (i = -5; i < 12; i++){ 939 res = SendMessageA(hwnd, MCM_SETFIRSTDAYOFWEEK, 0, i); 940 expect(prev, res); 941 res = SendMessageA(hwnd, MCM_GETFIRSTDAYOFWEEK, 0, 0); 942 prev = res; 943 944 if (i == -1){ 945 expect(MAKELONG(fday, FALSE), res); 946 }else if (i >= 7){ 947 /* out of range sets max first day of week, locale is ignored */ 948 expect(MAKELONG(6, TRUE), res); 949 }else{ 950 expect(MAKELONG(i, TRUE), res); 951 } 952 } 953 954 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_first_day_seq, "monthcal firstDay", FALSE); 955 956 }else{ 957 skip("Cannot retrieve first day of the week\n"); 958 } 959 960 DestroyWindow(hwnd); 961 } 962 963 static void test_unicode(void) 964 { 965 int res, temp; 966 HWND hwnd; 967 968 hwnd = create_monthcal_control(0); 969 970 flush_sequences(sequences, NUM_MSG_SEQUENCES); 971 972 /* Setter and Getters for Unicode format */ 973 974 /* getting the current settings */ 975 temp = SendMessageA(hwnd, MCM_GETUNICODEFORMAT, 0, 0); 976 977 /* setting to 1, should return previous settings */ 978 res = SendMessageA(hwnd, MCM_SETUNICODEFORMAT, 1, 0); 979 expect(temp, res); 980 981 /* current setting is 1, so, should return 1 */ 982 res = SendMessageA(hwnd, MCM_GETUNICODEFORMAT, 0, 0); 983 ok(1 == res || 984 broken(0 == res), /* comctl32 <= 4.70 */ 985 "Expected 1, got %d\n", res); 986 987 /* setting to 0, should return previous settings */ 988 res = SendMessageA(hwnd, MCM_SETUNICODEFORMAT, 0, 0); 989 ok(1 == res || 990 broken(0 == res), /* comctl32 <= 4.70 */ 991 "Expected 1, got %d\n", res); 992 993 /* current setting is 0, so, it should return 0 */ 994 res = SendMessageA(hwnd, MCM_GETUNICODEFORMAT, 0, 0); 995 expect(0, res); 996 997 /* should return previous settings */ 998 res = SendMessageA(hwnd, MCM_SETUNICODEFORMAT, 1, 0); 999 expect(0, res); 1000 1001 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_unicode_seq, "monthcal unicode", FALSE); 1002 1003 DestroyWindow(hwnd); 1004 } 1005 1006 static void test_hittest(void) 1007 { 1008 typedef struct hittest_test 1009 { 1010 UINT ht; 1011 BOOL todo; 1012 } hittest_test_t; 1013 1014 static const hittest_test_t title_hits[] = { 1015 /* Start is the same everywhere */ 1016 { MCHT_TITLE, FALSE }, 1017 { MCHT_TITLEBTNPREV, FALSE }, 1018 /* The middle piece is only tested for presence of items */ 1019 /* End is the same everywhere */ 1020 { MCHT_TITLEBTNNEXT, FALSE }, 1021 { MCHT_TITLE, FALSE }, 1022 { MCHT_NOWHERE, TRUE } 1023 }; 1024 1025 MCHITTESTINFO mchit; 1026 UINT res, old_res; 1027 SYSTEMTIME st; 1028 LONG x; 1029 UINT title_index; 1030 HWND hwnd; 1031 RECT r; 1032 char yearmonth[80], *locale_month, *locale_year; 1033 int month_count, year_count; 1034 BOOL in_the_middle; 1035 1036 memset(&mchit, 0, sizeof(MCHITTESTINFO)); 1037 1038 hwnd = create_monthcal_control(0); 1039 1040 /* test with invalid structure size */ 1041 mchit.cbSize = MCHITTESTINFO_V1_SIZE - 1; 1042 mchit.pt.x = 0; 1043 mchit.pt.y = 0; 1044 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1045 expect(0, mchit.pt.x); 1046 expect(0, mchit.pt.y); 1047 expect(~0u, res); 1048 expect(0, mchit.uHit); 1049 /* test with invalid pointer */ 1050 res = SendMessageA(hwnd, MCM_HITTEST, 0, 0); 1051 expect(~0u, res); 1052 1053 /* resize control to display single Calendar */ 1054 res = SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r); 1055 if (res == 0) 1056 { 1057 win_skip("Message MCM_GETMINREQRECT unsupported. Skipping.\n"); 1058 DestroyWindow(hwnd); 1059 return; 1060 } 1061 MoveWindow(hwnd, 0, 0, r.right, r.bottom, FALSE); 1062 1063 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1064 1065 st.wYear = 2007; 1066 st.wMonth = 4; 1067 st.wDay = 11; 1068 st.wHour = 1; 1069 st.wMinute = 0; 1070 st.wSecond = 0; 1071 st.wMilliseconds = 0; 1072 st.wDayOfWeek = 0; 1073 1074 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st); 1075 expect(1,res); 1076 1077 /* (0, 0) is the top left of the control - title */ 1078 mchit.cbSize = MCHITTESTINFO_V1_SIZE; 1079 mchit.pt.x = 0; 1080 mchit.pt.y = 0; 1081 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1082 expect(0, mchit.pt.x); 1083 expect(0, mchit.pt.y); 1084 expect(mchit.uHit, res); 1085 expect_hex(MCHT_TITLE, res); 1086 1087 /* bottom right of the control and should not be active */ 1088 mchit.pt.x = r.right; 1089 mchit.pt.y = r.bottom; 1090 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1091 expect(r.right, mchit.pt.x); 1092 expect(r.bottom, mchit.pt.y); 1093 expect(mchit.uHit, res); 1094 todo_wine expect_hex(MCHT_NOWHERE, res); 1095 1096 /* completely out of the control, should not be active */ 1097 mchit.pt.x = 2 * r.right; 1098 mchit.pt.y = 2 * r.bottom; 1099 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1100 expect(2 * r.right, mchit.pt.x); 1101 expect(2 * r.bottom, mchit.pt.y); 1102 expect(mchit.uHit, res); 1103 todo_wine expect_hex(MCHT_NOWHERE, res); 1104 1105 /* in active area - day of the week */ 1106 mchit.pt.x = r.right / 2; 1107 mchit.pt.y = r.bottom / 2; 1108 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1109 expect(r.right / 2, mchit.pt.x); 1110 expect(r.bottom / 2, mchit.pt.y); 1111 expect(mchit.uHit, res); 1112 expect_hex(MCHT_CALENDARDATE, res); 1113 1114 /* in active area - day of the week #2 */ 1115 mchit.pt.x = r.right / 14; /* half of first day rect */ 1116 mchit.pt.y = r.bottom / 2; 1117 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1118 expect(r.right / 14, mchit.pt.x); 1119 expect(r.bottom / 2, mchit.pt.y); 1120 expect(mchit.uHit, res); 1121 expect_hex(MCHT_CALENDARDATE, res); 1122 1123 /* in active area - date from prev month */ 1124 mchit.pt.x = r.right / 14; /* half of first day rect */ 1125 mchit.pt.y = 6 * r.bottom / 19; 1126 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1127 expect(r.right / 14, mchit.pt.x); 1128 expect(6 * r.bottom / 19, mchit.pt.y); 1129 expect(mchit.uHit, res); 1130 expect_hex(MCHT_CALENDARDATEPREV, res); 1131 1132 if (0) 1133 { 1134 /* (125, 115) is in active area - date from this month */ 1135 mchit.pt.x = 125; 1136 mchit.pt.y = 115; 1137 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1138 expect(125, mchit.pt.x); 1139 expect(115, mchit.pt.y); 1140 expect(mchit.uHit, res); 1141 expect(MCHT_CALENDARDATE, res); 1142 } 1143 1144 /* in active area - date from next month */ 1145 mchit.pt.x = 11 * r.right / 14; 1146 mchit.pt.y = 16 * r.bottom / 19; 1147 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1148 expect(11 * r.right / 14, mchit.pt.x); 1149 expect(16 * r.bottom / 19, mchit.pt.y); 1150 expect(mchit.uHit, res); 1151 expect_hex(MCHT_CALENDARDATENEXT, res); 1152 1153 /* in active area - today link */ 1154 mchit.pt.x = r.right / 14; 1155 mchit.pt.y = 18 * r.bottom / 19; 1156 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1157 expect(r.right / 14, mchit.pt.x); 1158 expect(18 * r.bottom / 19, mchit.pt.y); 1159 expect(mchit.uHit, res); 1160 expect_hex(MCHT_TODAYLINK, res); 1161 1162 /* in active area - today link */ 1163 mchit.pt.x = r.right / 2; 1164 mchit.pt.y = 18 * r.bottom / 19; 1165 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1166 expect(r.right / 2, mchit.pt.x); 1167 expect(18 * r.bottom / 19, mchit.pt.y); 1168 expect(mchit.uHit, res); 1169 expect_hex(MCHT_TODAYLINK, res); 1170 1171 /* in active area - today link */ 1172 mchit.pt.x = r.right / 10; 1173 mchit.pt.y = 18 * r.bottom / 19; 1174 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1175 expect(r.right / 10, mchit.pt.x); 1176 expect(18 * r.bottom / 19, mchit.pt.y); 1177 expect(mchit.uHit, res); 1178 expect_hex(MCHT_TODAYLINK, res); 1179 1180 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_hit_test_seq, "monthcal hit test", TRUE); 1181 1182 /* The horizontal position of title bar elements depends on locale (y pos 1183 is constant), so we sample across a horizontal line and make sure we 1184 find all elements. */ 1185 1186 /* Get the format of the title */ 1187 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SYEARMONTH, yearmonth, 80); 1188 /* Find out if we have a month and/or year */ 1189 locale_year = strstr(yearmonth, "y"); 1190 locale_month = strstr(yearmonth, "M"); 1191 1192 mchit.pt.x = 0; 1193 mchit.pt.y = (5/2) * r.bottom / 19; 1194 title_index = 0; 1195 old_res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1196 expect_hex(title_hits[title_index].ht, old_res); 1197 1198 in_the_middle = FALSE; 1199 month_count = year_count = 0; 1200 for (x = 0; x < r.right; x++){ 1201 mchit.pt.x = x; 1202 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1203 expect(x, mchit.pt.x); 1204 expect((5/2) * r.bottom / 19, mchit.pt.y); 1205 expect(mchit.uHit, res); 1206 if (res != old_res) { 1207 1208 if (old_res == MCHT_TITLEBTNPREV) 1209 in_the_middle = TRUE; 1210 1211 if (res == MCHT_TITLEBTNNEXT) 1212 in_the_middle = FALSE; 1213 1214 if (in_the_middle) { 1215 if (res == MCHT_TITLEMONTH) 1216 month_count++; 1217 else if (res == MCHT_TITLEYEAR) 1218 year_count++; 1219 } else { 1220 title_index++; 1221 1222 if (sizeof(title_hits) / sizeof(title_hits[0]) <= title_index) 1223 break; 1224 1225 todo_wine_if(title_hits[title_index].todo) 1226 ok(title_hits[title_index].ht == res, "Expected %x, got %x, pos %d\n", 1227 title_hits[title_index].ht, res, x); 1228 } 1229 old_res = res; 1230 } 1231 } 1232 1233 /* There are some limits, even if LOCALE_SYEARMONTH contains rubbish 1234 * or no month/year indicators at all */ 1235 if (locale_month) 1236 todo_wine ok(month_count == 1, "Expected 1 month item, got %d\n", month_count); 1237 else 1238 ok(month_count <= 1, "Too many month items: %d\n", month_count); 1239 1240 if (locale_year) 1241 todo_wine ok(year_count == 1, "Expected 1 year item, got %d\n", year_count); 1242 else 1243 ok(year_count <= 1, "Too many year items: %d\n", year_count); 1244 1245 todo_wine ok(month_count + year_count >= 1, "Not enough month and year items\n"); 1246 1247 ok(r.right <= x && title_index + 1 == sizeof(title_hits) / sizeof(title_hits[0]), 1248 "Wrong title layout\n"); 1249 1250 DestroyWindow(hwnd); 1251 } 1252 1253 static void test_todaylink(void) 1254 { 1255 MCHITTESTINFO mchit; 1256 SYSTEMTIME st_test, st_new; 1257 UINT res; 1258 HWND hwnd; 1259 RECT r; 1260 1261 memset(&mchit, 0, sizeof(MCHITTESTINFO)); 1262 1263 hwnd = create_monthcal_control(0); 1264 1265 res = SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r); 1266 expect(1, res); 1267 MoveWindow(hwnd, 0, 0, r.right, r.bottom, FALSE); 1268 1269 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1270 1271 /* hit active area - today link */ 1272 mchit.cbSize = MCHITTESTINFO_V1_SIZE; 1273 mchit.pt.x = r.right / 14; 1274 mchit.pt.y = 18 * r.bottom / 19; 1275 res = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1276 expect(r.right / 14, mchit.pt.x); 1277 expect(18 * r.bottom / 19, mchit.pt.y); 1278 expect(mchit.uHit, res); 1279 expect(MCHT_TODAYLINK, res); 1280 1281 st_test.wDay = 1; 1282 st_test.wMonth = 1; 1283 st_test.wYear = 2005; 1284 1285 res = SendMessageA(hwnd, MCM_SETTODAY, 0, (LPARAM)&st_test); 1286 expect(0, res); 1287 1288 memset(&st_new, 0, sizeof(st_new)); 1289 res = SendMessageA(hwnd, MCM_GETTODAY, 0, (LPARAM)&st_new); 1290 expect(1, res); 1291 expect(1, st_new.wDay); 1292 expect(1, st_new.wMonth); 1293 expect(2005, st_new.wYear); 1294 1295 res = SendMessageA(hwnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(mchit.pt.x, mchit.pt.y)); 1296 expect(0, res); 1297 1298 memset(&st_new, 0, sizeof(st_new)); 1299 res = SendMessageA(hwnd, MCM_GETCURSEL, 0, (LPARAM)&st_new); 1300 expect(1, res); 1301 expect(1, st_new.wDay); 1302 expect(1, st_new.wMonth); 1303 expect(2005, st_new.wYear); 1304 1305 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_todaylink_seq, "monthcal hit test", TRUE); 1306 1307 DestroyWindow(hwnd); 1308 } 1309 1310 static void test_today(void) 1311 { 1312 SYSTEMTIME st_test, st_new; 1313 int res; 1314 HWND hwnd; 1315 1316 hwnd = create_monthcal_control(0); 1317 1318 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1319 1320 /* Setter and Getters for "today" information */ 1321 1322 /* check for overflow, should be ok */ 1323 memset(&st_test, 0, sizeof(st_test)); 1324 st_test.wDay = 38; 1325 st_test.wMonth = 38; 1326 1327 st_new.wDay = 27; 1328 st_new.wMonth = 27; 1329 1330 res = SendMessageA(hwnd, MCM_SETTODAY, 0, (LPARAM)&st_test); 1331 expect(0, res); 1332 1333 res = SendMessageA(hwnd, MCM_GETTODAY, 0, (LPARAM)&st_new); 1334 expect(1, res); 1335 1336 /* st_test should not change */ 1337 expect(38, st_test.wDay); 1338 expect(38, st_test.wMonth); 1339 1340 /* st_new should change, overflow does not matter */ 1341 expect(38, st_new.wDay); 1342 expect(38, st_new.wMonth); 1343 1344 /* check for zero, should be ok*/ 1345 st_test.wDay = 0; 1346 st_test.wMonth = 0; 1347 1348 res = SendMessageA(hwnd, MCM_SETTODAY, 0, (LPARAM)&st_test); 1349 expect(0, res); 1350 1351 res = SendMessageA(hwnd, MCM_GETTODAY, 0, (LPARAM)&st_new); 1352 expect(1, res); 1353 1354 /* st_test should not change */ 1355 expect(0, st_test.wDay); 1356 expect(0, st_test.wMonth); 1357 1358 /* st_new should change to zero*/ 1359 expect(0, st_new.wDay); 1360 expect(0, st_new.wMonth); 1361 1362 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_today_seq, "monthcal today", TRUE); 1363 1364 DestroyWindow(hwnd); 1365 } 1366 1367 static void test_scroll(void) 1368 { 1369 int res; 1370 HWND hwnd; 1371 1372 hwnd = create_monthcal_control(0); 1373 1374 res = SendMessageA(hwnd, MCM_GETMONTHDELTA, 0, 0); 1375 expect(2, res); 1376 1377 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1378 1379 /* Setter and Getters for scroll rate */ 1380 res = SendMessageA(hwnd, MCM_SETMONTHDELTA, 2, 0); 1381 expect(0, res); 1382 1383 res = SendMessageA(hwnd, MCM_SETMONTHDELTA, 3, 0); 1384 expect(2, res); 1385 res = SendMessageA(hwnd, MCM_GETMONTHDELTA, 0, 0); 1386 expect(3, res); 1387 1388 res = SendMessageA(hwnd, MCM_SETMONTHDELTA, 12, 0); 1389 expect(3, res); 1390 res = SendMessageA(hwnd, MCM_GETMONTHDELTA, 0, 0); 1391 expect(12, res); 1392 1393 res = SendMessageA(hwnd, MCM_SETMONTHDELTA, 15, 0); 1394 expect(12, res); 1395 res = SendMessageA(hwnd, MCM_GETMONTHDELTA, 0, 0); 1396 expect(15, res); 1397 1398 res = SendMessageA(hwnd, MCM_SETMONTHDELTA, -5, 0); 1399 expect(15, res); 1400 res = SendMessageA(hwnd, MCM_GETMONTHDELTA, 0, 0); 1401 expect(-5, res); 1402 1403 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_scroll_seq, "monthcal scroll", FALSE); 1404 1405 DestroyWindow(hwnd); 1406 } 1407 1408 static void test_monthrange(void) 1409 { 1410 int res; 1411 SYSTEMTIME st_visible[2], st_daystate[2], st; 1412 HWND hwnd; 1413 RECT r; 1414 1415 hwnd = create_monthcal_control(0); 1416 1417 memset(&st_visible, 0, sizeof(st_visible)); 1418 memset(&st_daystate, 0, sizeof(st_daystate)); 1419 1420 st.wYear = 2000; 1421 st.wMonth = 11; 1422 st.wDay = 28; 1423 st.wHour = 11; 1424 st.wMinute = 59; 1425 st.wSecond = 30; 1426 st.wMilliseconds = 0; 1427 st.wDayOfWeek = 0; 1428 1429 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st); 1430 expect(1,res); 1431 1432 /* to be locale independent */ 1433 SendMessageA(hwnd, MCM_SETFIRSTDAYOFWEEK, 0, (LPARAM)6); 1434 1435 res = SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r); 1436 expect(TRUE, res); 1437 /* resize control to display two Calendars */ 1438 MoveWindow(hwnd, 0, 0, r.right, (5/2)*r.bottom, FALSE); 1439 1440 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1441 1442 res = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st_visible); 1443 expect(2, res); 1444 expect(2000, st_visible[0].wYear); 1445 expect(11, st_visible[0].wMonth); 1446 expect(1, st_visible[0].wDay); 1447 expect(2000, st_visible[1].wYear); 1448 expect(12, st_visible[1].wMonth); 1449 expect(31, st_visible[1].wDay); 1450 1451 res = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_DAYSTATE, (LPARAM)st_daystate); 1452 expect(4, res); 1453 expect(2000, st_daystate[0].wYear); 1454 expect(10, st_daystate[0].wMonth); 1455 expect(29, st_daystate[0].wDay); 1456 expect(2001, st_daystate[1].wYear); 1457 expect(1, st_daystate[1].wMonth); 1458 expect(6, st_daystate[1].wDay); 1459 1460 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_monthrange_seq, "monthcal monthrange", FALSE); 1461 1462 /* with null date array parameter */ 1463 res = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, 0); 1464 expect(2, res); 1465 1466 res = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_DAYSTATE, 0); 1467 expect(4, res); 1468 1469 /* resize control to display single Calendar */ 1470 MoveWindow(hwnd, 0, 0, r.right, r.bottom, FALSE); 1471 1472 memset(&st, 0, sizeof(st)); 1473 st.wMonth = 9; 1474 st.wYear = 1752; 1475 st.wDay = 14; 1476 1477 res = SendMessageA(hwnd, MCM_SETCURSEL, 0, (LPARAM)&st); 1478 expect(1, res); 1479 1480 /* September 1752 has 19 days */ 1481 res = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_VISIBLE, (LPARAM)st_visible); 1482 expect(1, res); 1483 1484 expect(1752, st_visible[0].wYear); 1485 expect(9, st_visible[0].wMonth); 1486 ok(14 == st_visible[0].wDay || 1487 broken(1 == st_visible[0].wDay), /* comctl32 <= 4.72 */ 1488 "Expected 14, got %d\n", st_visible[0].wDay); 1489 1490 expect(1752, st_visible[1].wYear); 1491 expect(9, st_visible[1].wMonth); 1492 expect(19, st_visible[1].wDay); 1493 1494 DestroyWindow(hwnd); 1495 } 1496 1497 static void test_maxselday(void) 1498 { 1499 int res; 1500 HWND hwnd; 1501 DWORD style; 1502 1503 hwnd = create_monthcal_control(0); 1504 /* if no style specified default to 1 */ 1505 res = SendMessageA(hwnd, MCM_GETMAXSELCOUNT, 0, 0); 1506 expect(1, res); 1507 res = SendMessageA(hwnd, MCM_SETMAXSELCOUNT, 5, 0); 1508 expect(0, res); 1509 res = SendMessageA(hwnd, MCM_GETMAXSELCOUNT, 0, 0); 1510 expect(1, res); 1511 1512 /* try to set style */ 1513 style = GetWindowLongA(hwnd, GWL_STYLE); 1514 SetWindowLongA(hwnd, GWL_STYLE, style | MCS_MULTISELECT); 1515 style = GetWindowLongA(hwnd, GWL_STYLE); 1516 ok(!(style & MCS_MULTISELECT), "Expected MCS_MULTISELECT not to be set\n"); 1517 DestroyWindow(hwnd); 1518 1519 hwnd = create_monthcal_control(MCS_MULTISELECT); 1520 /* try to remove style */ 1521 style = GetWindowLongA(hwnd, GWL_STYLE); 1522 SetWindowLongA(hwnd, GWL_STYLE, style & ~MCS_MULTISELECT); 1523 style = GetWindowLongA(hwnd, GWL_STYLE); 1524 ok(style & MCS_MULTISELECT, "Expected MCS_MULTISELECT to be set\n"); 1525 DestroyWindow(hwnd); 1526 1527 hwnd = create_monthcal_control(MCS_MULTISELECT); 1528 1529 /* default width is a week */ 1530 res = SendMessageA(hwnd, MCM_GETMAXSELCOUNT, 0, 0); 1531 expect(7, res); 1532 1533 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1534 1535 /* Setter and Getters for max selected days */ 1536 res = SendMessageA(hwnd, MCM_SETMAXSELCOUNT, 5, 0); 1537 expect(1, res); 1538 res = SendMessageA(hwnd, MCM_GETMAXSELCOUNT, 0, 0); 1539 expect(5, res); 1540 1541 res = SendMessageA(hwnd, MCM_SETMAXSELCOUNT, 15, 0); 1542 expect(1, res); 1543 res = SendMessageA(hwnd, MCM_GETMAXSELCOUNT, 0, 0); 1544 expect(15, res); 1545 1546 /* test invalid value */ 1547 res = SendMessageA(hwnd, MCM_SETMAXSELCOUNT, -1, 0); 1548 expect(0, res); 1549 res = SendMessageA(hwnd, MCM_GETMAXSELCOUNT, 0, 0); 1550 expect(15, res); 1551 1552 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_max_sel_day_seq, "monthcal MaxSelDay", FALSE); 1553 1554 /* zero value is invalid too */ 1555 res = SendMessageA(hwnd, MCM_SETMAXSELCOUNT, 0, 0); 1556 expect(0, res); 1557 res = SendMessageA(hwnd, MCM_GETMAXSELCOUNT, 0, 0); 1558 expect(15, res); 1559 1560 DestroyWindow(hwnd); 1561 } 1562 1563 static void test_size(void) 1564 { 1565 int res; 1566 RECT r1, r2; 1567 HFONT hFont1, hFont2; 1568 LOGFONTA logfont; 1569 HWND hwnd; 1570 1571 hwnd = create_monthcal_control(0); 1572 1573 lstrcpyA(logfont.lfFaceName, "Arial"); 1574 memset(&logfont, 0, sizeof(logfont)); 1575 logfont.lfHeight = 12; 1576 hFont1 = CreateFontIndirectA(&logfont); 1577 1578 logfont.lfHeight = 24; 1579 hFont2 = CreateFontIndirectA(&logfont); 1580 1581 /* initialize to a font we can compare against */ 1582 SendMessageA(hwnd, WM_SETFONT, (WPARAM)hFont1, 0); 1583 res = SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r1); 1584 ok(res, "SendMessageA(MCM_GETMINREQRECT) failed\n"); 1585 1586 /* check that setting a larger font results in an larger rect */ 1587 SendMessageA(hwnd, WM_SETFONT, (WPARAM)hFont2, 0); 1588 res = SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r2); 1589 ok(res, "SendMessageA(MCM_GETMINREQRECT) failed\n"); 1590 1591 OffsetRect(&r1, -r1.left, -r1.top); 1592 OffsetRect(&r2, -r2.left, -r2.top); 1593 1594 ok(r1.bottom < r2.bottom, "Failed to get larger rect with larger font\n"); 1595 1596 DestroyWindow(hwnd); 1597 } 1598 1599 static void test_create(void) 1600 { 1601 HWND hwnd; 1602 1603 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1604 1605 hwnd = create_monthcal_control(0); 1606 ok_sequence(sequences, PARENT_SEQ_INDEX, create_monthcal_control_seq, "create monthcal control", TRUE); 1607 1608 DestroyWindow(hwnd); 1609 1610 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1611 hwnd = create_monthcal_control(MCS_MULTISELECT); 1612 ok_sequence(sequences, PARENT_SEQ_INDEX, create_monthcal_multi_sel_style_seq, "create monthcal (multi sel style)", TRUE); 1613 DestroyWindow(hwnd); 1614 } 1615 1616 static void test_destroy(void) 1617 { 1618 HWND hwnd; 1619 1620 hwnd = create_monthcal_control(0); 1621 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1622 DestroyWindow(hwnd); 1623 ok_sequence(sequences, PARENT_SEQ_INDEX, destroy_monthcal_parent_msgs_seq, "Destroy monthcal (parent msg)", FALSE); 1624 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, destroy_monthcal_child_msgs_seq, "Destroy monthcal (child msg)", FALSE); 1625 1626 /* MCS_MULTISELECT */ 1627 hwnd = create_monthcal_control(MCS_MULTISELECT); 1628 flush_sequences(sequences, NUM_MSG_SEQUENCES); 1629 DestroyWindow(hwnd); 1630 ok_sequence(sequences, MONTHCAL_SEQ_INDEX, destroy_monthcal_multi_sel_style_seq, "Destroy monthcal (multi sel style)", FALSE); 1631 } 1632 1633 static void test_selrange(void) 1634 { 1635 HWND hwnd; 1636 SYSTEMTIME st, range[2], range2[2]; 1637 BOOL ret, old_comctl32 = FALSE; 1638 1639 hwnd = create_monthcal_control(MCS_MULTISELECT); 1640 1641 /* just after creation selection should start and end today */ 1642 ret = SendMessageA(hwnd, MCM_GETTODAY, 0, (LPARAM)&st); 1643 expect(TRUE, ret); 1644 1645 memset(range, 0xcc, sizeof(range)); 1646 ret = SendMessageA(hwnd, MCM_GETSELRANGE, 0, (LPARAM)range); 1647 expect(TRUE, ret); 1648 expect(st.wYear, range[0].wYear); 1649 expect(st.wMonth, range[0].wMonth); 1650 expect(st.wDay, range[0].wDay); 1651 if (range[0].wDayOfWeek != st.wDayOfWeek) 1652 { 1653 win_skip("comctl32 <= 4.70 doesn't set some values\n"); 1654 old_comctl32 = TRUE; 1655 } 1656 else 1657 { 1658 expect(st.wDayOfWeek, range[0].wDayOfWeek); 1659 expect(st.wHour, range[0].wHour); 1660 expect(st.wMinute, range[0].wMinute); 1661 expect(st.wSecond, range[0].wSecond); 1662 expect(st.wMilliseconds, range[0].wMilliseconds); 1663 } 1664 1665 expect(st.wYear, range[1].wYear); 1666 expect(st.wMonth, range[1].wMonth); 1667 expect(st.wDay, range[1].wDay); 1668 if (!old_comctl32) 1669 { 1670 expect(st.wDayOfWeek, range[1].wDayOfWeek); 1671 expect(st.wHour, range[1].wHour); 1672 expect(st.wMinute, range[1].wMinute); 1673 expect(st.wSecond, range[1].wSecond); 1674 expect(st.wMilliseconds, range[1].wMilliseconds); 1675 } 1676 1677 /* bounds are swapped if min > max */ 1678 memset(&range[0], 0, sizeof(range[0])); 1679 range[0].wYear = 2009; 1680 range[0].wMonth = 10; 1681 range[0].wDay = 5; 1682 range[1] = range[0]; 1683 range[1].wDay = 3; 1684 1685 ret = SendMessageA(hwnd, MCM_SETSELRANGE, 0, (LPARAM)range); 1686 expect(TRUE, ret); 1687 1688 ret = SendMessageA(hwnd, MCM_GETSELRANGE, 0, (LPARAM)range2); 1689 expect(TRUE, ret); 1690 1691 expect(range[1].wYear, range2[0].wYear); 1692 expect(range[1].wMonth, range2[0].wMonth); 1693 expect(range[1].wDay, range2[0].wDay); 1694 expect(6, range2[0].wDayOfWeek); 1695 expect(range[1].wHour, range2[0].wHour); 1696 expect(range[1].wMinute, range2[0].wMinute); 1697 expect(range[1].wSecond, range2[0].wSecond); 1698 expect(range[1].wMilliseconds, range2[0].wMilliseconds); 1699 1700 expect(range[0].wYear, range2[1].wYear); 1701 expect(range[0].wMonth, range2[1].wMonth); 1702 expect(range[0].wDay, range2[1].wDay); 1703 expect(1, range2[1].wDayOfWeek); 1704 expect(range[0].wHour, range2[1].wHour); 1705 expect(range[0].wMinute, range2[1].wMinute); 1706 expect(range[0].wSecond, range2[1].wSecond); 1707 expect(range[0].wMilliseconds, range2[1].wMilliseconds); 1708 1709 /* try with range larger than maximum configured */ 1710 memset(&range[0], 0, sizeof(range[0])); 1711 range[0].wYear = 2009; 1712 range[0].wMonth = 10; 1713 range[0].wDay = 1; 1714 range[1] = range[0]; 1715 1716 ret = SendMessageA(hwnd, MCM_SETSELRANGE, 0, (LPARAM)range); 1717 expect(TRUE, ret); 1718 1719 range[1] = range[0]; 1720 /* default max. range is 7 days */ 1721 range[1].wDay = 8; 1722 1723 ret = SendMessageA(hwnd, MCM_SETSELRANGE, 0, (LPARAM)range); 1724 expect(FALSE, ret); 1725 1726 ret = SendMessageA(hwnd, MCM_GETSELRANGE, 0, (LPARAM)range2); 1727 expect(TRUE, ret); 1728 1729 expect(range[0].wYear, range2[0].wYear); 1730 expect(range[0].wMonth, range2[0].wMonth); 1731 expect(range[0].wDay, range2[0].wDay); 1732 expect(range[0].wYear, range2[1].wYear); 1733 expect(range[0].wMonth, range2[1].wMonth); 1734 expect(range[0].wDay, range2[1].wDay); 1735 1736 DestroyWindow(hwnd); 1737 } 1738 1739 static void test_killfocus(void) 1740 { 1741 HWND hwnd; 1742 DWORD style; 1743 1744 hwnd = create_monthcal_control(0); 1745 1746 /* make parent invisible */ 1747 style = GetWindowLongA(parent_wnd, GWL_STYLE); 1748 SetWindowLongA(parent_wnd, GWL_STYLE, style & ~WS_VISIBLE); 1749 1750 SendMessageA(hwnd, WM_KILLFOCUS, (WPARAM)GetDesktopWindow(), 0); 1751 1752 style = GetWindowLongA(hwnd, GWL_STYLE); 1753 ok(style & WS_VISIBLE, "Expected WS_VISIBLE to be set\n"); 1754 1755 style = GetWindowLongA(parent_wnd, GWL_STYLE); 1756 SetWindowLongA(parent_wnd, GWL_STYLE, style | WS_VISIBLE); 1757 1758 DestroyWindow(hwnd); 1759 } 1760 1761 static void test_hittest_v6(void) 1762 { 1763 MCHITTESTINFO mchit; 1764 DWORD ret; 1765 HWND hwnd; 1766 RECT r; 1767 1768 hwnd = create_monthcal_control(0); 1769 SendMessageA(hwnd, MCM_SETCALENDARBORDER, TRUE, 0); 1770 1771 SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r); 1772 /* reserving some area around calendar */ 1773 MoveWindow(hwnd, 0, 0, r.right * 3 / 2, r.bottom * 3 / 2, FALSE); 1774 mchit.cbSize = sizeof(MCHITTESTINFO); 1775 mchit.pt.x = mchit.pt.y = 0; 1776 mchit.iOffset = -1; 1777 mchit.iRow = -1; 1778 mchit.iCol = -1; 1779 ret = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1780 if (ret == ~0u) 1781 { 1782 win_skip("Only MCHITTESTINFO_V1 supported\n"); 1783 DestroyWindow(hwnd); 1784 return; 1785 } 1786 todo_wine expect_hex(MCHT_NOWHERE, ret); 1787 expect(-1, mchit.iOffset); 1788 expect(-1, mchit.iRow); 1789 expect(-1, mchit.iCol); 1790 1791 MoveWindow(hwnd, 0, 0, r.right, r.bottom, FALSE); 1792 mchit.pt.x = r.right / 2; 1793 mchit.pt.y = r.bottom / 2; 1794 mchit.iOffset = -1; 1795 ret = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1796 expect_hex(MCHT_CALENDARDATE, ret); 1797 expect(0, mchit.iOffset); 1798 1799 /* over day area */ 1800 mchit.pt.x = r.right / (7*2); 1801 mchit.pt.y = r.bottom / 2; 1802 mchit.iOffset = -1; 1803 mchit.iCol = mchit.iRow = -1; 1804 mchit.uHit = 0; 1805 mchit.rc.left = mchit.rc.right = mchit.rc.top = mchit.rc.bottom = -1; 1806 ret = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1807 expect_hex(MCHT_CALENDARDATE, ret); 1808 expect_hex(MCHT_CALENDARDATE, mchit.uHit); 1809 expect(0, mchit.iOffset); 1810 expect(2, mchit.iRow); 1811 expect(0, mchit.iCol); 1812 /* returned a one day rectangle */ 1813 expect_d(r.right / 7, mchit.rc.right - mchit.rc.left); 1814 expect_d(r.bottom / 10, mchit.rc.bottom - mchit.rc.top); 1815 1816 /* title */ 1817 mchit.pt.x = 1; 1818 mchit.pt.y = 1; 1819 mchit.iOffset = -1; 1820 mchit.iCol = mchit.iRow = -1; 1821 mchit.uHit = 0; 1822 mchit.rc.left = mchit.rc.right = mchit.rc.top = mchit.rc.bottom = -1; 1823 ret = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1824 expect_hex(MCHT_TITLE, ret); 1825 expect_hex(MCHT_TITLE, mchit.uHit); 1826 expect(0, mchit.iOffset); 1827 expect(-1, mchit.iRow); 1828 expect(-1, mchit.iCol); 1829 expect(0, mchit.rc.left); 1830 expect(0, mchit.rc.top); 1831 expect_d(r.right, mchit.rc.right); 1832 ok(mchit.rc.bottom > 0, "got %d\n", mchit.rc.bottom); 1833 1834 /* between two calendars */ 1835 MoveWindow(hwnd, 0, 0, r.right * 5/2, r.bottom, FALSE); 1836 mchit.pt.x = r.right / (5*4); 1837 mchit.pt.y = r.bottom / 2; 1838 mchit.iOffset = -2; 1839 mchit.iCol = mchit.iRow = -2; 1840 mchit.uHit = ~0; 1841 mchit.rc.left = mchit.rc.right = mchit.rc.top = mchit.rc.bottom = -1; 1842 ret = SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 1843 todo_wine expect_hex(MCHT_NOWHERE, ret); 1844 todo_wine expect_hex(MCHT_NOWHERE, mchit.uHit); 1845 expect(-2, mchit.iOffset); 1846 expect(-2, mchit.iRow); 1847 expect(-2, mchit.iCol); 1848 todo_wine expect(0, mchit.rc.left); 1849 todo_wine expect(0, mchit.rc.top); 1850 todo_wine expect_d(r.right * 5/2, mchit.rc.right); 1851 todo_wine expect_d(r.bottom, mchit.rc.bottom); 1852 1853 DestroyWindow(hwnd); 1854 } 1855 1856 static void test_get_set_border(void) 1857 { 1858 HWND hwnd; 1859 DWORD ret; 1860 1861 hwnd = create_monthcal_control(0); 1862 1863 /* a non-default value */ 1864 ret = SendMessageA(hwnd, MCM_SETCALENDARBORDER, TRUE, 10); 1865 expect(0, ret); 1866 1867 ret = SendMessageA(hwnd, MCM_GETCALENDARBORDER, 0, 0); 1868 1869 if (ret != 10) 1870 { 1871 skip("MCM_GET/SETCALENDARBORDER not supported\n"); 1872 DestroyWindow(hwnd); 1873 return; 1874 } 1875 1876 expect(10, ret); 1877 1878 DestroyWindow(hwnd); 1879 } 1880 1881 static void test_MCM_SIZERECTTOMIN(void) 1882 { 1883 HWND hwnd; 1884 DWORD ret; 1885 RECT r, r2; 1886 1887 hwnd = create_monthcal_control(0); 1888 1889 ret = SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r2); 1890 if (ret == 0) 1891 { 1892 win_skip("Message MCM_GETMINREQRECT unsupported. Skipping.\n"); 1893 DestroyWindow(hwnd); 1894 return; 1895 } 1896 1897 ret = SendMessageA(hwnd, MCM_SIZERECTTOMIN, 0, 0); 1898 ok(ret == 0, "got %d\n", ret); 1899 1900 SetRectEmpty(&r); 1901 ret = SendMessageA(hwnd, MCM_SIZERECTTOMIN, 0, (LPARAM)&r); 1902 if (ret == 0) 1903 { 1904 skip("Message MCM_SIZERECTTOMIN unsupported. Skipping.\n"); 1905 DestroyWindow(hwnd); 1906 return; 1907 } 1908 ok(ret == 1, "got %d\n", ret); 1909 ok(r.left == 0 && r.right > 0, "got %d, %d\n", r.left, r.right); 1910 1911 r = r2; 1912 ret = SendMessageA(hwnd, MCM_SIZERECTTOMIN, 0, (LPARAM)&r); 1913 ok(ret == 1, "got %d\n", ret); 1914 1915 r2.right = (r2.right - r2.left) * 3; 1916 r2.bottom = (r2.bottom - r2.top) * 3; 1917 r2.left = r2.top = 0; 1918 ret = SendMessageA(hwnd, MCM_SIZERECTTOMIN, 0, (LPARAM)&r2); 1919 ok(ret == 1, "got %d\n", ret); 1920 1921 DestroyWindow(hwnd); 1922 } 1923 1924 static void test_MCM_GETCALENDARCOUNT(void) 1925 { 1926 HWND hwnd; 1927 DWORD ret; 1928 1929 hwnd = create_monthcal_control(0); 1930 1931 ret = SendMessageA(hwnd, MCM_GETCALENDARCOUNT, 0, 0); 1932 if (ret == 0) 1933 { 1934 win_skip("Message MCM_GETCALENDARCOUNT unsupported. Skipping.\n"); 1935 DestroyWindow(hwnd); 1936 return; 1937 } 1938 1939 expect(2, ret); 1940 1941 DestroyWindow(hwnd); 1942 } 1943 1944 static void test_daystate(void) 1945 { 1946 MONTHDAYSTATE state[4]; 1947 DWORD ret, style; 1948 HWND hwnd; 1949 RECT r; 1950 1951 /* without MCS_DAYSTATE */ 1952 hwnd = create_monthcal_control(0); 1953 1954 ret = SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&r); 1955 expect(TRUE, ret); 1956 1957 /* resize control to display two Calendars */ 1958 MoveWindow(hwnd, 0, 0, r.right, (5/2)*r.bottom, FALSE); 1959 1960 ret = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_DAYSTATE, 0); 1961 expect(4, ret); 1962 1963 ret = SendMessageA(hwnd, MCM_SETDAYSTATE, 4, (LPARAM)&state); 1964 expect(0, ret); 1965 1966 ret = SendMessageA(hwnd, MCM_SETDAYSTATE, 2, (LPARAM)&state); 1967 expect(0, ret); 1968 1969 ret = SendMessageA(hwnd, MCM_SETDAYSTATE, 0, 0); 1970 expect(0, ret); 1971 1972 /* try to switch on */ 1973 SetWindowLongA(hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) | MCS_DAYSTATE); 1974 style = GetWindowLongA(hwnd, GWL_STYLE); 1975 ok((style & MCS_DAYSTATE) == 0, "got 0x%08x\n", style); 1976 1977 DestroyWindow(hwnd); 1978 1979 /* with MCS_DAYSTATE */ 1980 hwnd = create_monthcal_control(MCS_DAYSTATE); 1981 1982 ret = SendMessageA(hwnd, MCM_GETMONTHRANGE, GMR_DAYSTATE, 0); 1983 expect(4, ret); 1984 1985 ret = SendMessageA(hwnd, MCM_SETDAYSTATE, 4, (LPARAM)&state); 1986 expect(1, ret); 1987 1988 ret = SendMessageA(hwnd, MCM_SETDAYSTATE, 2, (LPARAM)&state); 1989 expect(0, ret); 1990 1991 ret = SendMessageA(hwnd, MCM_SETDAYSTATE, 0, 0); 1992 expect(0, ret); 1993 1994 /* try to switch off */ 1995 SetWindowLongA(hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) & ~MCS_DAYSTATE); 1996 style = GetWindowLongA(hwnd, GWL_STYLE); 1997 ok((style & MCS_DAYSTATE) == MCS_DAYSTATE, "got 0x%08x\n", style); 1998 1999 DestroyWindow(hwnd); 2000 } 2001 2002 static void test_sel_notify(void) 2003 { 2004 typedef struct 2005 { 2006 DWORD val; 2007 const char* name; 2008 } Monthcal_style; 2009 2010 HWND hwnd; 2011 RECT rc; 2012 MCHITTESTINFO mchit = {sizeof(MCHITTESTINFO)}; 2013 SYSTEMTIME st; 2014 Monthcal_style styles[] = { 2015 {MCS_NOTODAY, "MCS_NOTODAY"}, 2016 {MCS_NOTODAY | MCS_MULTISELECT, "MCS_NOTODAY | MCS_MULTISELECT"}, 2017 {MCS_DAYSTATE, "MCS_DAYSTATE"}, 2018 {MCS_DAYSTATE | MCS_MULTISELECT, "MCS_DAYSTATE | MCS_MULTISELECT"} 2019 }; 2020 int i; 2021 2022 for(i = 0; i < sizeof styles / sizeof styles[0]; i++) 2023 { 2024 hwnd = create_monthcal_control(styles[i].val); 2025 SetWindowLongPtrA(hwnd, GWLP_ID, SEL_NOTIFY_TEST_ID); 2026 SendMessageA(hwnd, MCM_GETMINREQRECT, 0, (LPARAM)&rc); 2027 MoveWindow(hwnd, 0, 0, rc.right, rc.bottom, FALSE); 2028 /* Simulate mouse click on some unselected day to generate 2029 MCN_SELECT and MCN_SELCHANGE notifications */ 2030 mchit.pt.x = rc.right / 2; 2031 mchit.pt.y = rc.bottom / 2; 2032 SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 2033 SendMessageA(hwnd, MCM_GETCURSEL, 0, (LPARAM)&st); 2034 while(st.wDay == mchit.st.wDay) /* Ensure that mchit.pt points to unselected day */ 2035 { 2036 mchit.pt.y++; 2037 SendMessageA(hwnd, MCM_HITTEST, 0, (LPARAM)&mchit); 2038 } 2039 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, MAKELPARAM(mchit.pt.x, mchit.pt.y)); 2040 SendMessageA(hwnd, WM_LBUTTONUP, 0, MAKELPARAM(mchit.pt.x, mchit.pt.y)); 2041 DestroyWindow(hwnd); 2042 } 2043 } 2044 2045 START_TEST(monthcal) 2046 { 2047 BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*); 2048 INITCOMMONCONTROLSEX iccex; 2049 HMODULE hComctl32; 2050 2051 ULONG_PTR ctx_cookie; 2052 HANDLE hCtx; 2053 2054 hComctl32 = GetModuleHandleA("comctl32.dll"); 2055 pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx"); 2056 if (!pInitCommonControlsEx) 2057 { 2058 win_skip("InitCommonControlsEx() is missing. Skipping the tests\n"); 2059 return; 2060 } 2061 iccex.dwSize = sizeof(iccex); 2062 iccex.dwICC = ICC_DATE_CLASSES; 2063 pInitCommonControlsEx(&iccex); 2064 2065 test_monthcal(); 2066 2067 init_msg_sequences(sequences, NUM_MSG_SEQUENCES); 2068 2069 parent_wnd = create_parent_window(); 2070 2071 test_create(); 2072 test_destroy(); 2073 test_color(); 2074 test_currdate(); 2075 test_firstDay(); 2076 test_unicode(); 2077 test_today(); 2078 test_scroll(); 2079 test_monthrange(); 2080 test_hittest(); 2081 test_todaylink(); 2082 test_size(); 2083 test_maxselday(); 2084 test_selrange(); 2085 test_killfocus(); 2086 test_daystate(); 2087 test_sel_notify(); 2088 2089 if (!load_v6_module(&ctx_cookie, &hCtx)) 2090 { 2091 DestroyWindow(parent_wnd); 2092 return; 2093 } 2094 2095 test_hittest_v6(); 2096 test_get_set_border(); 2097 test_MCM_SIZERECTTOMIN(); 2098 test_MCM_GETCALENDARCOUNT(); 2099 2100 unload_v6_module(ctx_cookie, hCtx); 2101 2102 DestroyWindow(parent_wnd); 2103 } 2104