comctl32/monthcal: Fix some bugs with date range.
This commit is contained in:
parent
d66dcb4ff8
commit
a44f03518e
|
@ -36,9 +36,6 @@
|
|||
* -- handle resources better (doesn't work now);
|
||||
* -- take care of internationalization.
|
||||
* -- keyboard handling.
|
||||
* -- GetRange: At the moment, we copy ranges anyway, regardless of
|
||||
* infoPtr->rangeValid; an invalid range is simply filled
|
||||
* with zeros in SetRange. Is this the right behavior?
|
||||
* -- search for FIXME
|
||||
*/
|
||||
|
||||
|
@ -931,11 +928,11 @@ MONTHCAL_SetRange(MONTHCAL_INFO *infoPtr, SHORT limits, SYSTEMTIME *range)
|
|||
/* Only one limit set - we are done */
|
||||
if ((infoPtr->rangeValid & (GDTR_MIN | GDTR_MAX)) != (GDTR_MIN | GDTR_MAX))
|
||||
return TRUE;
|
||||
|
||||
|
||||
SystemTimeToFileTime(&infoPtr->maxDate, &ft_max);
|
||||
SystemTimeToFileTime(&infoPtr->minDate, &ft_min);
|
||||
|
||||
if (CompareFileTime(&ft_min, &ft_max) > 0)
|
||||
if (CompareFileTime(&ft_min, &ft_max) >= 0)
|
||||
{
|
||||
if ((limits & (GDTR_MIN | GDTR_MAX)) == (GDTR_MIN | GDTR_MAX))
|
||||
{
|
||||
|
@ -946,8 +943,11 @@ MONTHCAL_SetRange(MONTHCAL_INFO *infoPtr, SHORT limits, SYSTEMTIME *range)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Reset the other limit. */
|
||||
/* FIXME: native sets date&time to 0. Should we do this too? */
|
||||
static const SYSTEMTIME zero;
|
||||
|
||||
/* reset the other limit */
|
||||
if (limits & GDTR_MIN) infoPtr->maxDate = zero;
|
||||
if (limits & GDTR_MAX) infoPtr->minDate = zero;
|
||||
infoPtr->rangeValid &= limits & GDTR_MIN ? ~GDTR_MAX : ~GDTR_MIN ;
|
||||
}
|
||||
}
|
||||
|
@ -1873,10 +1873,6 @@ MONTHCAL_Create(HWND hwnd, LPCREATESTRUCTW lpcs)
|
|||
MONTHCAL_SetFirstDayOfWeek(infoPtr, -1);
|
||||
infoPtr->currentMonth = infoPtr->todaysDate.wMonth;
|
||||
infoPtr->currentYear = infoPtr->todaysDate.wYear;
|
||||
infoPtr->minDate = infoPtr->todaysDate;
|
||||
infoPtr->maxDate = infoPtr->todaysDate;
|
||||
infoPtr->maxDate.wYear = 2050;
|
||||
infoPtr->minDate.wYear = 1950;
|
||||
infoPtr->maxSelCount = 7;
|
||||
infoPtr->monthRange = 3;
|
||||
infoPtr->monthdayState = Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
|
||||
|
|
|
@ -328,6 +328,29 @@ static void test_monthcal(void)
|
|||
hwnd = CreateWindowA(MONTHCAL_CLASSA, "MonthCal", WS_POPUP | WS_VISIBLE, CW_USEDEFAULT,
|
||||
0, 300, 300, 0, 0, NULL, NULL);
|
||||
ok(hwnd != NULL, "Failed to create MonthCal\n");
|
||||
|
||||
/* test range just after creation */
|
||||
memset(&st, 0xcc, sizeof(st));
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st) == 0, "No limits should be set\n");
|
||||
|
||||
expect(0, st[0].wYear);
|
||||
expect(0, st[0].wMonth);
|
||||
expect(0, st[0].wDay);
|
||||
expect(0, st[0].wDayOfWeek);
|
||||
expect(0, st[0].wHour);
|
||||
expect(0, st[0].wMinute);
|
||||
expect(0, st[0].wSecond);
|
||||
expect(0, st[0].wMilliseconds);
|
||||
|
||||
expect(0, st[1].wYear);
|
||||
expect(0, st[1].wMonth);
|
||||
expect(0, st[1].wDay);
|
||||
expect(0, st[1].wDayOfWeek);
|
||||
expect(0, st[1].wHour);
|
||||
expect(0, st[1].wMinute);
|
||||
expect(0, st[1].wSecond);
|
||||
expect(0, st[1].wMilliseconds);
|
||||
|
||||
GetSystemTime(&st[0]);
|
||||
st[1] = st[0];
|
||||
|
||||
|
@ -380,6 +403,60 @@ static void test_monthcal(void)
|
|||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set max limit\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "Only MAX limit should be set\n");
|
||||
|
||||
/* set both limits, then set max < min */
|
||||
GetSystemTime(&st[0]);
|
||||
st[1] = st[0];
|
||||
st[1].wYear++;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN|GDTR_MAX, (LPARAM)st), "Failed to set limits\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == (GDTR_MIN|GDTR_MAX), "Min limit expected\n");
|
||||
st[1].wYear -= 2;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MAX, (LPARAM)st), "Failed to set limits\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MAX, "Max limit expected\n");
|
||||
|
||||
expect(0, st1[0].wYear);
|
||||
expect(0, st1[0].wMonth);
|
||||
expect(0, st1[0].wDay);
|
||||
expect(0, st1[0].wDayOfWeek);
|
||||
expect(0, st1[0].wHour);
|
||||
expect(0, st1[0].wMinute);
|
||||
expect(0, st1[0].wSecond);
|
||||
expect(0, st1[0].wMilliseconds);
|
||||
|
||||
expect(st[1].wYear, st1[1].wYear);
|
||||
expect(st[1].wMonth, st1[1].wMonth);
|
||||
expect(st[1].wDay, st1[1].wDay);
|
||||
expect(st[1].wDayOfWeek, st1[1].wDayOfWeek);
|
||||
expect(st[1].wHour, st1[1].wHour);
|
||||
expect(st[1].wMinute, st1[1].wMinute);
|
||||
expect(st[1].wSecond, st1[1].wSecond);
|
||||
expect(st[1].wMilliseconds, st1[1].wMilliseconds);
|
||||
|
||||
st[1] = st[0];
|
||||
st[1].wYear++;
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN|GDTR_MAX, (LPARAM)st), "Failed to set limits\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == (GDTR_MIN|GDTR_MAX), "Min limit expected\n");
|
||||
st[0].wYear++; /* start == end now */
|
||||
ok(SendMessage(hwnd, MCM_SETRANGE, GDTR_MIN, (LPARAM)st), "Failed to set limits\n");
|
||||
ok(SendMessage(hwnd, MCM_GETRANGE, 0, (LPARAM)st1) == GDTR_MIN, "Min limit expected\n");
|
||||
|
||||
expect(st[0].wYear, st1[0].wYear);
|
||||
expect(st[0].wMonth, st1[0].wMonth);
|
||||
expect(st[0].wDay, st1[0].wDay);
|
||||
expect(st[0].wDayOfWeek, st1[0].wDayOfWeek);
|
||||
expect(st[0].wHour, st1[0].wHour);
|
||||
expect(st[0].wMinute, st1[0].wMinute);
|
||||
expect(st[0].wSecond, st1[0].wSecond);
|
||||
expect(st[0].wMilliseconds, st1[0].wMilliseconds);
|
||||
|
||||
expect(0, st1[1].wYear);
|
||||
expect(0, st1[1].wMonth);
|
||||
expect(0, st1[1].wDay);
|
||||
expect(0, st1[1].wDayOfWeek);
|
||||
expect(0, st1[1].wHour);
|
||||
expect(0, st1[1].wMinute);
|
||||
expect(0, st1[1].wSecond);
|
||||
expect(0, st1[1].wMilliseconds);
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue