comctl32: Process WM_CHAR instead of WM_KEYDOWN for numbers in datetime.

This commit is contained in:
Lei Zhang 2008-11-25 14:03:36 -08:00 committed by Alexandre Julliard
parent 93aed4b078
commit 40bbe3da6f
1 changed files with 88 additions and 77 deletions

View File

@ -902,83 +902,6 @@ DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode)
FIXME ("Callbacks not implemented yet\n");
}
if (vkCode >= '0' && vkCode <= '9') {
/* this is a somewhat simplified version of what Windows does */
SYSTEMTIME *date = &infoPtr->date;
switch (infoPtr->fieldspec[fieldNum]) {
case ONEDIGITYEAR:
case TWODIGITYEAR:
date->wYear = date->wYear - (date->wYear%100) +
(date->wYear%10)*10 + (vkCode-'0');
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(
date->wDay,date->wMonth,date->wYear);
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case INVALIDFULLYEAR:
case FULLYEAR:
date->wYear = (date->wYear%1000)*10 + (vkCode-'0');
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(
date->wDay,date->wMonth,date->wYear);
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGITMONTH:
case TWODIGITMONTH:
if ((date->wMonth%10) > 1 || (vkCode-'0') > 2)
date->wMonth = vkCode-'0';
else
date->wMonth = (date->wMonth%10)*10+vkCode-'0';
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(
date->wDay,date->wMonth,date->wYear);
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGITDAY:
case TWODIGITDAY:
/* probably better checking here would help */
if ((date->wDay%10) >= 3 && (vkCode-'0') > 1)
date->wDay = vkCode-'0';
else
date->wDay = (date->wDay%10)*10+vkCode-'0';
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(
date->wDay,date->wMonth,date->wYear);
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGIT12HOUR:
case TWODIGIT12HOUR:
if ((date->wHour%10) > 1 || (vkCode-'0') > 2)
date->wHour = vkCode-'0';
else
date->wHour = (date->wHour%10)*10+vkCode-'0';
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGIT24HOUR:
case TWODIGIT24HOUR:
if ((date->wHour%10) > 2)
date->wHour = vkCode-'0';
else if ((date->wHour%10) == 2 && (vkCode-'0') > 3)
date->wHour = vkCode-'0';
else
date->wHour = (date->wHour%10)*10+vkCode-'0';
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGITMINUTE:
case TWODIGITMINUTE:
if ((date->wMinute%10) > 5)
date->wMinute = vkCode-'0';
else
date->wMinute = (date->wMinute%10)*10+vkCode-'0';
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGITSECOND:
case TWODIGITSECOND:
if ((date->wSecond%10) > 5)
date->wSecond = vkCode-'0';
else
date->wSecond = (date->wSecond%10)*10+vkCode-'0';
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
}
}
switch (vkCode) {
case VK_ADD:
case VK_UP:
@ -1025,6 +948,91 @@ DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode)
}
static LRESULT
DATETIME_Char (DATETIME_INFO *infoPtr, WPARAM vkCode, LPARAM keyData)
{
int fieldNum = infoPtr->select & DTHT_DATEFIELD;
if (vkCode >= '0' && vkCode <= '9') {
/* this is a somewhat simplified version of what Windows does */
SYSTEMTIME *date = &infoPtr->date;
switch (infoPtr->fieldspec[fieldNum]) {
case ONEDIGITYEAR:
case TWODIGITYEAR:
date->wYear = date->wYear - (date->wYear%100) +
(date->wYear%10)*10 + (vkCode-'0');
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(
date->wDay,date->wMonth,date->wYear);
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case INVALIDFULLYEAR:
case FULLYEAR:
date->wYear = (date->wYear%1000)*10 + (vkCode-'0');
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(
date->wDay,date->wMonth,date->wYear);
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGITMONTH:
case TWODIGITMONTH:
if ((date->wMonth%10) > 1 || (vkCode-'0') > 2)
date->wMonth = vkCode-'0';
else
date->wMonth = (date->wMonth%10)*10+vkCode-'0';
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(
date->wDay,date->wMonth,date->wYear);
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGITDAY:
case TWODIGITDAY:
/* probably better checking here would help */
if ((date->wDay%10) >= 3 && (vkCode-'0') > 1)
date->wDay = vkCode-'0';
else
date->wDay = (date->wDay%10)*10+vkCode-'0';
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(
date->wDay,date->wMonth,date->wYear);
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGIT12HOUR:
case TWODIGIT12HOUR:
if ((date->wHour%10) > 1 || (vkCode-'0') > 2)
date->wHour = vkCode-'0';
else
date->wHour = (date->wHour%10)*10+vkCode-'0';
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGIT24HOUR:
case TWODIGIT24HOUR:
if ((date->wHour%10) > 2)
date->wHour = vkCode-'0';
else if ((date->wHour%10) == 2 && (vkCode-'0') > 3)
date->wHour = vkCode-'0';
else
date->wHour = (date->wHour%10)*10+vkCode-'0';
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGITMINUTE:
case TWODIGITMINUTE:
if ((date->wMinute%10) > 5)
date->wMinute = vkCode-'0';
else
date->wMinute = (date->wMinute%10)*10+vkCode-'0';
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
case ONEDIGITSECOND:
case TWODIGITSECOND:
if ((date->wSecond%10) > 5)
date->wSecond = vkCode-'0';
else
date->wSecond = (date->wSecond%10)*10+vkCode-'0';
DATETIME_SendDateTimeChangeNotify (infoPtr);
break;
}
}
return 0;
}
static LRESULT
DATETIME_VScroll (DATETIME_INFO *infoPtr, WORD wScroll)
{
@ -1341,6 +1349,9 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_KEYDOWN:
return DATETIME_KeyDown (infoPtr, wParam);
case WM_CHAR:
return DATETIME_Char (infoPtr, wParam, lParam);
case WM_KILLFOCUS:
return DATETIME_KillFocus (infoPtr, (HWND)wParam);