Commit 2c928de9 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/monthcal: Parameter fixes for MCM_SETSELRANGE handler: swap selection…

comctl32/monthcal: Parameter fixes for MCM_SETSELRANGE handler: swap selection bounds, store day of week.
parent 6d2a5e19
......@@ -1252,8 +1252,25 @@ MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, SYSTEMTIME *range)
old_range[0] = infoPtr->minSel;
old_range[1] = infoPtr->maxSel;
/* swap if min > max */
if(MONTHCAL_CompareSystemTime(&range[0], &range[1]) <= 0)
{
infoPtr->minSel = range[0];
infoPtr->maxSel = range[1];
}
else
{
infoPtr->minSel = range[1];
infoPtr->maxSel = range[0];
}
/* update day of week */
infoPtr->minSel.wDayOfWeek =
MONTHCAL_CalculateDayOfWeek(infoPtr->minSel.wDay, infoPtr->minSel.wMonth,
infoPtr->minSel.wYear);
infoPtr->maxSel.wDayOfWeek =
MONTHCAL_CalculateDayOfWeek(infoPtr->maxSel.wDay, infoPtr->maxSel.wMonth,
infoPtr->maxSel.wYear);
/* redraw if bounds changed */
/* FIXME: no actual need to redraw everything */
......
......@@ -1516,10 +1516,10 @@ static void test_monthcal_destroy(void)
ok_sequence(sequences, MONTHCAL_SEQ_INDEX, destroy_monthcal_multi_sel_style_seq, "Destroy monthcal (multi sel style)", FALSE);
}
static void test_monthcal_getselrange(void)
static void test_monthcal_selrange(void)
{
HWND hwnd;
SYSTEMTIME st, range[2];
SYSTEMTIME st, range[2], range2[2];
BOOL ret, old_comctl32 = FALSE;
hwnd = create_monthcal_control(MCS_MULTISELECT);
......@@ -1560,6 +1560,38 @@ static void test_monthcal_getselrange(void)
expect(st.wMilliseconds, range[1].wMilliseconds);
}
/* bounds are swapped if min > max */
memset(&range[0], 0, sizeof(range[0]));
range[0].wYear = 2009;
range[0].wMonth = 10;
range[0].wDay = 5;
range[1] = range[0];
range[1].wDay = 3;
ret = SendMessage(hwnd, MCM_SETSELRANGE, 0, (LPARAM)range);
expect(TRUE, ret);
ret = SendMessage(hwnd, MCM_GETSELRANGE, 0, (LPARAM)range2);
expect(TRUE, ret);
expect(range[1].wYear, range2[0].wYear);
expect(range[1].wMonth, range2[0].wMonth);
expect(range[1].wDay, range2[0].wDay);
expect(6, range2[0].wDayOfWeek);
expect(range[1].wHour, range2[0].wHour);
expect(range[1].wMinute, range2[0].wMinute);
expect(range[1].wSecond, range2[0].wSecond);
expect(range[1].wMilliseconds, range2[0].wMilliseconds);
expect(range[0].wYear, range2[1].wYear);
expect(range[0].wMonth, range2[1].wMonth);
expect(range[0].wDay, range2[1].wDay);
expect(1, range2[1].wDayOfWeek);
expect(range[0].wHour, range2[1].wHour);
expect(range[0].wMinute, range2[1].wMinute);
expect(range[0].wSecond, range2[1].wSecond);
expect(range[0].wMilliseconds, range2[1].wMilliseconds);
DestroyWindow(hwnd);
}
......@@ -1599,7 +1631,7 @@ START_TEST(monthcal)
test_monthcal_todaylink();
test_monthcal_size();
test_monthcal_maxselday();
test_monthcal_getselrange();
test_monthcal_selrange();
flush_sequences(sequences, NUM_MSG_SEQUENCES);
DestroyWindow(parent_wnd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment