1998-11-08 12:30:27 +01:00
|
|
|
/*
|
|
|
|
* Date and time picker control
|
|
|
|
*
|
1999-03-12 18:42:50 +01:00
|
|
|
* Copyright 1998, 1999 Eric Kohl
|
2000-02-03 01:48:39 +01:00
|
|
|
* Copyright 1999, 2000 Alex Priem <alexp@sci.kun.nl>
|
2000-05-30 22:06:54 +02:00
|
|
|
* Copyright 2000 Chris Morgan <cmorgan@wpi.edu>
|
1998-11-08 12:30:27 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-11-08 12:30:27 +01:00
|
|
|
*
|
2004-10-22 21:52:08 +02:00
|
|
|
* NOTE
|
|
|
|
*
|
|
|
|
* This code was audited for completeness against the documented features
|
|
|
|
* of Comctl32.dll version 6.0 on Oct. 20, 2004, by Dimitrie O. Paun.
|
|
|
|
*
|
|
|
|
* Unless otherwise noted, we believe this code to be complete, as per
|
|
|
|
* the specification mentioned above.
|
|
|
|
* If you discover missing features, or bugs, please note them below.
|
|
|
|
*
|
1998-11-08 12:30:27 +01:00
|
|
|
* TODO:
|
2004-10-22 21:52:08 +02:00
|
|
|
* -- DTS_APPCANPARSE
|
|
|
|
* -- DTS_SHORTDATECENTURYFORMAT
|
|
|
|
* -- DTN_CLOSEUP
|
|
|
|
* -- DTN_FORMAT
|
|
|
|
* -- DTN_FORMATQUERY
|
|
|
|
* -- DTN_USERSTRING
|
|
|
|
* -- DTN_WMKEYDOWN
|
|
|
|
* -- FORMATCALLBACK
|
1998-11-08 12:30:27 +01:00
|
|
|
*/
|
|
|
|
|
2000-02-10 23:15:21 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 23:15:21 +01:00
|
|
|
#include <stdio.h>
|
2004-10-26 02:11:31 +02:00
|
|
|
#include <limits.h>
|
2000-02-10 23:15:21 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-03-16 11:53:11 +01:00
|
|
|
#include "winbase.h"
|
2000-05-30 22:06:54 +02:00
|
|
|
#include "wingdi.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "winnls.h"
|
1998-11-08 12:30:27 +01:00
|
|
|
#include "commctrl.h"
|
2003-09-17 22:15:21 +02:00
|
|
|
#include "comctl32.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2004-10-22 21:52:08 +02:00
|
|
|
#include "wine/unicode.h"
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(datetime);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-08-09 02:41:17 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
HWND hwndSelf;
|
|
|
|
HWND hMonthCal;
|
|
|
|
HWND hwndNotify;
|
|
|
|
HWND hUpdown;
|
2004-10-26 02:11:31 +02:00
|
|
|
DWORD dwStyle;
|
2004-10-22 21:52:08 +02:00
|
|
|
SYSTEMTIME date;
|
|
|
|
BOOL dateValid;
|
|
|
|
HWND hwndCheckbut;
|
|
|
|
RECT rcClient; /* rect around the edge of the window */
|
|
|
|
RECT rcDraw; /* rect inside of the border */
|
|
|
|
RECT checkbox; /* checkbox allowing the control to be enabled/disabled */
|
|
|
|
RECT calbutton; /* button that toggles the dropdown of the monthcal control */
|
|
|
|
BOOL bCalDepressed; /* TRUE = cal button is depressed */
|
2007-11-01 23:34:35 +01:00
|
|
|
int bDropdownEnabled;
|
2004-10-22 21:52:08 +02:00
|
|
|
int select;
|
|
|
|
HFONT hFont;
|
|
|
|
int nrFieldsAllocated;
|
|
|
|
int nrFields;
|
|
|
|
int haveFocus;
|
|
|
|
int *fieldspec;
|
|
|
|
RECT *fieldRect;
|
|
|
|
int *buflen;
|
|
|
|
WCHAR textbuf[256];
|
|
|
|
POINT monthcal_pos;
|
2005-04-14 13:31:17 +02:00
|
|
|
int pendingUpdown;
|
2000-08-09 02:41:17 +02:00
|
|
|
} DATETIME_INFO, *LPDATETIME_INFO;
|
|
|
|
|
|
|
|
/* in monthcal.c */
|
2000-10-15 02:28:00 +02:00
|
|
|
extern int MONTHCAL_MonthLength(int month, int year);
|
2000-08-09 02:41:17 +02:00
|
|
|
|
|
|
|
/* this list of defines is closely related to `allowedformatchars' defined
|
|
|
|
* in datetime.c; the high nibble indicates the `base type' of the format
|
2002-06-01 01:06:46 +02:00
|
|
|
* specifier.
|
2000-08-09 02:41:17 +02:00
|
|
|
* Do not change without first reading DATETIME_UseFormat.
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2000-08-09 02:41:17 +02:00
|
|
|
*/
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
#define DT_END_FORMAT 0
|
2000-08-09 02:41:17 +02:00
|
|
|
#define ONEDIGITDAY 0x01
|
|
|
|
#define TWODIGITDAY 0x02
|
|
|
|
#define THREECHARDAY 0x03
|
|
|
|
#define FULLDAY 0x04
|
|
|
|
#define ONEDIGIT12HOUR 0x11
|
|
|
|
#define TWODIGIT12HOUR 0x12
|
|
|
|
#define ONEDIGIT24HOUR 0x21
|
|
|
|
#define TWODIGIT24HOUR 0x22
|
|
|
|
#define ONEDIGITMINUTE 0x31
|
|
|
|
#define TWODIGITMINUTE 0x32
|
|
|
|
#define ONEDIGITMONTH 0x41
|
|
|
|
#define TWODIGITMONTH 0x42
|
|
|
|
#define THREECHARMONTH 0x43
|
|
|
|
#define FULLMONTH 0x44
|
|
|
|
#define ONEDIGITSECOND 0x51
|
|
|
|
#define TWODIGITSECOND 0x52
|
|
|
|
#define ONELETTERAMPM 0x61
|
|
|
|
#define TWOLETTERAMPM 0x62
|
|
|
|
#define ONEDIGITYEAR 0x71
|
|
|
|
#define TWODIGITYEAR 0x72
|
2003-05-14 00:04:40 +02:00
|
|
|
#define INVALIDFULLYEAR 0x73 /* FIXME - yyy is not valid - we'll treat it as yyyy */
|
|
|
|
#define FULLYEAR 0x74
|
2000-08-09 02:41:17 +02:00
|
|
|
#define FORMATCALLBACK 0x81 /* -> maximum of 0x80 callbacks possible */
|
|
|
|
#define FORMATCALLMASK 0x80
|
|
|
|
#define DT_STRING 0x0100
|
|
|
|
|
|
|
|
#define DTHT_DATEFIELD 0xff /* for hit-testing */
|
|
|
|
|
|
|
|
#define DTHT_NONE 0
|
|
|
|
#define DTHT_CHECKBOX 0x200 /* these should end at '00' , to make */
|
|
|
|
#define DTHT_MCPOPUP 0x300 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
|
|
|
|
#define DTHT_GOTFOCUS 0x400 /* tests for date-fields */
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2007-03-26 19:57:43 +02:00
|
|
|
static BOOL DATETIME_SendSimpleNotify (const DATETIME_INFO *infoPtr, UINT code);
|
|
|
|
static BOOL DATETIME_SendDateTimeChangeNotify (const DATETIME_INFO *infoPtr);
|
2000-02-03 01:48:39 +01:00
|
|
|
extern void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to);
|
2004-10-22 21:52:08 +02:00
|
|
|
static const WCHAR allowedformatchars[] = {'d', 'h', 'H', 'm', 'M', 's', 't', 'y', 'X', '\'', 0};
|
2003-05-14 00:04:40 +02:00
|
|
|
static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1,-1};
|
2000-02-03 01:48:39 +01:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static DWORD
|
2007-03-31 18:42:01 +02:00
|
|
|
DATETIME_GetSystemTime (const DATETIME_INFO *infoPtr, SYSTEMTIME *lprgSysTimeArray)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
if (!lprgSysTimeArray) return GDT_NONE;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if ((infoPtr->dwStyle & DTS_SHOWNONE) &&
|
|
|
|
(SendMessageW (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED))
|
1999-07-31 13:12:45 +02:00
|
|
|
return GDT_NONE;
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
return GDT_VALID;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static BOOL
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *lprgSysTimeArray)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
if (!lprgSysTimeArray) return 0;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
TRACE("%04d/%02d/%02d %02d:%02d:%02d\n",
|
|
|
|
lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay,
|
|
|
|
lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond);
|
|
|
|
|
|
|
|
if (flag == GDT_VALID) {
|
2007-03-15 22:26:59 +01:00
|
|
|
if (lprgSysTimeArray->wYear < 1601 || lprgSysTimeArray->wYear > 30827 ||
|
|
|
|
lprgSysTimeArray->wMonth < 1 || lprgSysTimeArray->wMonth > 12 ||
|
|
|
|
lprgSysTimeArray->wDayOfWeek > 6 ||
|
|
|
|
lprgSysTimeArray->wDay < 1 || lprgSysTimeArray->wDay > 31 ||
|
|
|
|
lprgSysTimeArray->wHour > 23 ||
|
|
|
|
lprgSysTimeArray->wMinute > 59 ||
|
|
|
|
lprgSysTimeArray->wSecond > 59 ||
|
|
|
|
lprgSysTimeArray->wMilliseconds > 999
|
|
|
|
)
|
|
|
|
return 0;
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
infoPtr->dateValid = TRUE;
|
|
|
|
MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
|
|
|
|
SendMessageW (infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
|
|
|
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
|
2007-03-18 20:39:40 +01:00
|
|
|
} else if ((infoPtr->dwStyle & DTS_SHOWNONE) && (flag == GDT_NONE)) {
|
2004-10-26 02:11:31 +02:00
|
|
|
infoPtr->dateValid = FALSE;
|
|
|
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0);
|
|
|
|
}
|
2007-03-18 20:39:40 +01:00
|
|
|
else
|
|
|
|
return 0;
|
2001-05-25 22:38:20 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
|
|
|
return TRUE;
|
2001-05-25 22:38:20 +02:00
|
|
|
}
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
/***
|
|
|
|
* Split up a formattxt in actions.
|
|
|
|
* See ms documentation for the meaning of the letter codes/'specifiers'.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* *'dddddd' is handled as 'dddd' plus 'dd'.
|
|
|
|
* *unrecognized formats are strings (here given the type DT_STRING;
|
|
|
|
* start of the string is encoded in lower bits of DT_STRING.
|
|
|
|
* Therefore, 'string' ends finally up as '<show seconds>tring'.
|
|
|
|
*
|
2000-02-03 01:48:39 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_UseFormat (DATETIME_INFO *infoPtr, LPCWSTR formattxt)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
unsigned int i;
|
|
|
|
int j, k, len;
|
|
|
|
int *nrFields = &infoPtr->nrFields;
|
|
|
|
|
|
|
|
*nrFields = 0;
|
|
|
|
infoPtr->fieldspec[*nrFields] = 0;
|
|
|
|
len = strlenW(allowedformatchars);
|
|
|
|
k = 0;
|
|
|
|
|
|
|
|
for (i = 0; formattxt[i]; i++) {
|
|
|
|
TRACE ("\n%d %c:", i, formattxt[i]);
|
|
|
|
for (j = 0; j < len; j++) {
|
|
|
|
if (allowedformatchars[j]==formattxt[i]) {
|
|
|
|
TRACE ("%c[%d,%x]", allowedformatchars[j], *nrFields, infoPtr->fieldspec[*nrFields]);
|
2000-02-03 01:48:39 +01:00
|
|
|
if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
|
2004-10-22 21:52:08 +02:00
|
|
|
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (infoPtr->fieldspec[*nrFields] >> 4 != j) {
|
|
|
|
(*nrFields)++;
|
|
|
|
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2004-10-22 21:52:08 +02:00
|
|
|
if ((infoPtr->fieldspec[*nrFields] & 0x0f) == maxrepetition[j]) {
|
|
|
|
(*nrFields)++;
|
|
|
|
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
infoPtr->fieldspec[*nrFields]++;
|
|
|
|
break;
|
|
|
|
} /* if allowedformatchar */
|
|
|
|
} /* for j */
|
|
|
|
|
|
|
|
/* char is not a specifier: handle char like a string */
|
|
|
|
if (j == len) {
|
|
|
|
if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
|
|
|
|
infoPtr->fieldspec[*nrFields] = DT_STRING + k;
|
|
|
|
infoPtr->buflen[*nrFields] = 0;
|
|
|
|
} else if ((infoPtr->fieldspec[*nrFields] & DT_STRING) != DT_STRING) {
|
|
|
|
(*nrFields)++;
|
|
|
|
infoPtr->fieldspec[*nrFields] = DT_STRING + k;
|
|
|
|
infoPtr->buflen[*nrFields] = 0;
|
|
|
|
}
|
|
|
|
infoPtr->textbuf[k] = formattxt[i];
|
|
|
|
k++;
|
|
|
|
infoPtr->buflen[*nrFields]++;
|
2000-02-03 01:48:39 +01:00
|
|
|
} /* if j=len */
|
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
if (*nrFields == infoPtr->nrFieldsAllocated) {
|
|
|
|
FIXME ("out of memory; should reallocate. crash ahead.\n");
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
2004-10-22 21:52:08 +02:00
|
|
|
} /* for i */
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
TRACE("\n");
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
if (infoPtr->fieldspec[*nrFields] != 0) (*nrFields)++;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static BOOL
|
|
|
|
DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR lpszFormat)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
if (!lpszFormat) {
|
|
|
|
WCHAR format_buf[80];
|
|
|
|
DWORD format_item;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if (infoPtr->dwStyle & DTS_LONGDATEFORMAT)
|
2004-10-22 21:52:08 +02:00
|
|
|
format_item = LOCALE_SLONGDATE;
|
2005-04-14 13:31:17 +02:00
|
|
|
else if ((infoPtr->dwStyle & DTS_TIMEFORMAT) == DTS_TIMEFORMAT)
|
2004-10-22 21:52:08 +02:00
|
|
|
format_item = LOCALE_STIMEFORMAT;
|
2000-05-30 22:06:54 +02:00
|
|
|
else /* DTS_SHORTDATEFORMAT */
|
2004-10-22 21:52:08 +02:00
|
|
|
format_item = LOCALE_SSHORTDATE;
|
|
|
|
GetLocaleInfoW( GetSystemDefaultLCID(), format_item, format_buf, sizeof(format_buf)/sizeof(format_buf[0]));
|
|
|
|
lpszFormat = format_buf;
|
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_UseFormat (infoPtr, lpszFormat);
|
2005-04-16 12:48:02 +02:00
|
|
|
InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2007-03-15 17:47:48 +01:00
|
|
|
return 1;
|
2004-10-22 21:52:08 +02:00
|
|
|
}
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static BOOL
|
|
|
|
DATETIME_SetFormatA (DATETIME_INFO *infoPtr, LPCSTR lpszFormat)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
if (lpszFormat) {
|
|
|
|
BOOL retval;
|
|
|
|
INT len = MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, NULL, 0);
|
|
|
|
LPWSTR wstr = Alloc(len * sizeof(WCHAR));
|
|
|
|
if (wstr) MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, wstr, len);
|
|
|
|
retval = DATETIME_SetFormatW (infoPtr, wstr);
|
|
|
|
Free (wstr);
|
2000-02-03 01:48:39 +01:00
|
|
|
return retval;
|
2004-10-22 21:52:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return DATETIME_SetFormatW (infoPtr, 0);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_ReturnTxt (const DATETIME_INFO *infoPtr, int count, LPWSTR result, int resultSize)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
static const WCHAR fmt_dW[] = { '%', 'd', 0 };
|
|
|
|
static const WCHAR fmt__2dW[] = { '%', '.', '2', 'd', 0 };
|
|
|
|
static const WCHAR fmt__3sW[] = { '%', '.', '3', 's', 0 };
|
|
|
|
SYSTEMTIME date = infoPtr->date;
|
|
|
|
int spec;
|
|
|
|
WCHAR buffer[80];
|
|
|
|
|
|
|
|
*result=0;
|
|
|
|
TRACE ("%d,%d\n", infoPtr->nrFields, count);
|
|
|
|
if (count>infoPtr->nrFields || count < 0) {
|
2000-02-03 01:48:39 +01:00
|
|
|
WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
|
|
|
|
return;
|
2004-10-22 21:52:08 +02:00
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
if (!infoPtr->fieldspec) return;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
spec = infoPtr->fieldspec[count];
|
|
|
|
if (spec & DT_STRING) {
|
|
|
|
int txtlen = infoPtr->buflen[count];
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2003-04-03 01:25:01 +02:00
|
|
|
if (txtlen > resultSize)
|
|
|
|
txtlen = resultSize - 1;
|
2004-10-22 21:52:08 +02:00
|
|
|
memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen * sizeof(WCHAR));
|
|
|
|
result[txtlen] = 0;
|
|
|
|
TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result));
|
2000-02-03 01:48:39 +01:00
|
|
|
return;
|
2004-10-22 21:52:08 +02:00
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
switch (spec) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case DT_END_FORMAT:
|
2004-10-22 21:52:08 +02:00
|
|
|
*result = 0;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITDAY:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt_dW, date.wDay);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITDAY:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt__2dW, date.wDay);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case THREECHARDAY:
|
2004-10-22 21:52:08 +02:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7, result, 4);
|
|
|
|
/*wsprintfW (result,"%.3s",days[date.wDayOfWeek]);*/
|
|
|
|
break;
|
2000-10-15 02:28:00 +02:00
|
|
|
case FULLDAY:
|
2004-10-22 21:52:08 +02:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDAYNAME1+(date.wDayOfWeek+6)%7, result, resultSize);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT12HOUR:
|
2005-04-15 18:10:39 +02:00
|
|
|
if (date.wHour == 0) {
|
|
|
|
result[0] = '1';
|
|
|
|
result[1] = '2';
|
|
|
|
result[2] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wsprintfW (result, fmt_dW, date.wHour - (date.wHour > 12 ? 12 : 0));
|
2004-10-22 21:52:08 +02:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGIT12HOUR:
|
2005-04-15 18:10:39 +02:00
|
|
|
if (date.wHour == 0) {
|
|
|
|
result[0] = '1';
|
|
|
|
result[1] = '2';
|
|
|
|
result[2] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wsprintfW (result, fmt__2dW, date.wHour - (date.wHour > 12 ? 12 : 0));
|
2004-10-22 21:52:08 +02:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT24HOUR:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt_dW, date.wHour);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGIT24HOUR:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt__2dW, date.wHour);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITSECOND:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt_dW, date.wSecond);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITSECOND:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt__2dW, date.wSecond);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMINUTE:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt_dW, date.wMinute);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITMINUTE:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt__2dW, date.wMinute);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMONTH:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt_dW, date.wMonth);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITMONTH:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt__2dW, date.wMonth);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case THREECHARMONTH:
|
2004-10-22 21:52:08 +02:00
|
|
|
GetLocaleInfoW(GetSystemDefaultLCID(), LOCALE_SMONTHNAME1+date.wMonth -1,
|
|
|
|
buffer, sizeof(buffer)/sizeof(buffer[0]));
|
|
|
|
wsprintfW (result, fmt__3sW, buffer);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FULLMONTH:
|
2004-10-22 21:52:08 +02:00
|
|
|
GetLocaleInfoW(GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
|
|
|
|
result, resultSize);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONELETTERAMPM:
|
2004-10-22 21:52:08 +02:00
|
|
|
result[0] = (date.wHour < 12 ? 'A' : 'P');
|
|
|
|
result[1] = 0;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWOLETTERAMPM:
|
2004-10-22 21:52:08 +02:00
|
|
|
result[0] = (date.wHour < 12 ? 'A' : 'P');
|
|
|
|
result[1] = 'M';
|
|
|
|
result[2] = 0;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FORMATCALLBACK:
|
2004-10-22 21:52:08 +02:00
|
|
|
FIXME ("Not implemented\n");
|
|
|
|
result[0] = 'x';
|
|
|
|
result[1] = 0;
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITYEAR:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt_dW, date.wYear-10* (int) floor(date.wYear/10));
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGITYEAR:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt__2dW, date.wYear-100* (int) floor(date.wYear/100));
|
|
|
|
break;
|
2003-05-14 00:04:40 +02:00
|
|
|
case INVALIDFULLYEAR:
|
2002-06-01 01:06:46 +02:00
|
|
|
case FULLYEAR:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt_dW, date.wYear);
|
|
|
|
break;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result));
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
2005-04-14 13:31:17 +02:00
|
|
|
/* Offsets of days in the week to the weekday of january 1 in a leap year. */
|
|
|
|
static const int DayOfWeekTable[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
|
|
|
|
|
|
|
|
/* returns the day in the week(0 == sunday, 6 == saturday) */
|
|
|
|
/* day(1 == 1st, 2 == 2nd... etc), year is the year value */
|
|
|
|
static int DATETIME_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year)
|
|
|
|
{
|
|
|
|
year-=(month < 3);
|
|
|
|
|
|
|
|
return((year + year/4 - year/100 + year/400 +
|
|
|
|
DayOfWeekTable[month-1] + day ) % 7);
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
static int wrap(int val, int delta, int minVal, int maxVal)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
val += delta;
|
|
|
|
if (delta == INT_MIN || val < minVal) return maxVal;
|
|
|
|
if (delta == INT_MAX || val > maxVal) return minVal;
|
|
|
|
return val;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static void
|
2004-10-26 02:11:31 +02:00
|
|
|
DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
SYSTEMTIME *date = &infoPtr->date;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
TRACE ("%d\n", number);
|
|
|
|
if ((number > infoPtr->nrFields) || (number < 0)) return;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if ((infoPtr->fieldspec[number] & DTHT_DATEFIELD) == 0) return;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
switch (infoPtr->fieldspec[number]) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITYEAR:
|
|
|
|
case TWODIGITYEAR:
|
|
|
|
case FULLYEAR:
|
2004-10-26 02:11:31 +02:00
|
|
|
date->wYear = wrap(date->wYear, delta, 1752, 9999);
|
2005-04-14 13:31:17 +02:00
|
|
|
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(date->wDay,date->wMonth,date->wYear);
|
2004-10-26 02:11:31 +02:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMONTH:
|
|
|
|
case TWODIGITMONTH:
|
|
|
|
case THREECHARMONTH:
|
|
|
|
case FULLMONTH:
|
2004-10-26 02:11:31 +02:00
|
|
|
date->wMonth = wrap(date->wMonth, delta, 1, 12);
|
2005-04-14 13:31:17 +02:00
|
|
|
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(date->wDay,date->wMonth,date->wYear);
|
2004-10-26 02:11:31 +02:00
|
|
|
delta = 0;
|
|
|
|
/* fall through */
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITDAY:
|
|
|
|
case TWODIGITDAY:
|
|
|
|
case THREECHARDAY:
|
2000-02-03 01:48:39 +01:00
|
|
|
case FULLDAY:
|
2004-10-26 02:11:31 +02:00
|
|
|
date->wDay = wrap(date->wDay, delta, 1, MONTHCAL_MonthLength(date->wMonth, date->wYear));
|
2005-04-14 13:31:17 +02:00
|
|
|
date->wDayOfWeek = DATETIME_CalculateDayOfWeek(date->wDay,date->wMonth,date->wYear);
|
2004-10-26 02:11:31 +02:00
|
|
|
break;
|
|
|
|
case ONELETTERAMPM:
|
|
|
|
case TWOLETTERAMPM:
|
|
|
|
delta *= 12;
|
|
|
|
/* fall through */
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGIT12HOUR:
|
|
|
|
case TWODIGIT12HOUR:
|
|
|
|
case ONEDIGIT24HOUR:
|
|
|
|
case TWODIGIT24HOUR:
|
2004-10-26 02:11:31 +02:00
|
|
|
date->wHour = wrap(date->wHour, delta, 0, 23);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case ONEDIGITMINUTE:
|
|
|
|
case TWODIGITMINUTE:
|
2004-10-26 02:11:31 +02:00
|
|
|
date->wMinute = wrap(date->wMinute, delta, 0, 59);
|
|
|
|
break;
|
|
|
|
case ONEDIGITSECOND:
|
|
|
|
case TWODIGITSECOND:
|
|
|
|
date->wSecond = wrap(date->wSecond, delta, 0, 59);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FORMATCALLBACK:
|
2004-10-26 02:11:31 +02:00
|
|
|
FIXME ("Not implemented\n");
|
|
|
|
break;
|
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
/* FYI: On 1752/9/14 the calendar changed and England and the
|
|
|
|
* American colonies changed to the Gregorian calendar. This change
|
|
|
|
* involved having September 14th follow September 2nd. So no date
|
|
|
|
* algorithm works before that date.
|
|
|
|
*/
|
|
|
|
if (10000 * date->wYear + 100 * date->wMonth + date->wDay < 17520914) {
|
|
|
|
date->wYear = 1752;
|
|
|
|
date->wMonth = 9;
|
|
|
|
date->wDay = 14;
|
|
|
|
date->wSecond = 0;
|
|
|
|
date->wMinute = 0;
|
|
|
|
date->wHour = 0;
|
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-14 13:31:17 +02:00
|
|
|
static void
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_ReturnFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count, SHORT *fieldWidthPtr)
|
2005-04-14 13:31:17 +02:00
|
|
|
{
|
|
|
|
/* fields are a fixed width, determined by the largest possible string */
|
|
|
|
/* presumably, these widths should be language dependent */
|
|
|
|
static const WCHAR fld_d1W[] = { '2', 0 };
|
|
|
|
static const WCHAR fld_d2W[] = { '2', '2', 0 };
|
|
|
|
static const WCHAR fld_d4W[] = { '2', '2', '2', '2', 0 };
|
|
|
|
static const WCHAR fld_am1[] = { 'A', 0 };
|
|
|
|
static const WCHAR fld_am2[] = { 'A', 'M', 0 };
|
|
|
|
static const WCHAR fld_day[] = { 'W', 'e', 'd', 'n', 'e', 's', 'd', 'a', 'y', 0 };
|
|
|
|
static const WCHAR fld_day3[] = { 'W', 'e', 'd', 0 };
|
|
|
|
static const WCHAR fld_mon[] = { 'S', 'e', 'p', 't', 'e', 'm', 'b', 'e', 'r', 0 };
|
|
|
|
static const WCHAR fld_mon3[] = { 'D', 'e', 'c', 0 };
|
|
|
|
int spec;
|
2006-10-20 21:39:22 +02:00
|
|
|
WCHAR buffer[80];
|
|
|
|
LPCWSTR bufptr;
|
2005-04-14 13:31:17 +02:00
|
|
|
SIZE size;
|
|
|
|
|
|
|
|
TRACE ("%d,%d\n", infoPtr->nrFields, count);
|
|
|
|
if (count>infoPtr->nrFields || count < 0) {
|
|
|
|
WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!infoPtr->fieldspec) return;
|
|
|
|
|
|
|
|
spec = infoPtr->fieldspec[count];
|
|
|
|
if (spec & DT_STRING) {
|
|
|
|
int txtlen = infoPtr->buflen[count];
|
|
|
|
|
|
|
|
if (txtlen > 79)
|
|
|
|
txtlen = 79;
|
|
|
|
memcpy (buffer, infoPtr->textbuf + (spec &~ DT_STRING), txtlen * sizeof(WCHAR));
|
|
|
|
buffer[txtlen] = 0;
|
|
|
|
bufptr = buffer;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (spec) {
|
|
|
|
case ONEDIGITDAY:
|
|
|
|
case ONEDIGIT12HOUR:
|
|
|
|
case ONEDIGIT24HOUR:
|
|
|
|
case ONEDIGITSECOND:
|
|
|
|
case ONEDIGITMINUTE:
|
|
|
|
case ONEDIGITMONTH:
|
|
|
|
case ONEDIGITYEAR:
|
|
|
|
/* these seem to use a two byte field */
|
|
|
|
case TWODIGITDAY:
|
|
|
|
case TWODIGIT12HOUR:
|
|
|
|
case TWODIGIT24HOUR:
|
|
|
|
case TWODIGITSECOND:
|
|
|
|
case TWODIGITMINUTE:
|
|
|
|
case TWODIGITMONTH:
|
|
|
|
case TWODIGITYEAR:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_d2W;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
case INVALIDFULLYEAR:
|
|
|
|
case FULLYEAR:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_d4W;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
case THREECHARDAY:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_day3;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
case FULLDAY:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_day;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
case THREECHARMONTH:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_mon3;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
case FULLMONTH:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_mon;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
case ONELETTERAMPM:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_am1;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
case TWOLETTERAMPM:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_am2;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
default:
|
2006-10-20 21:39:22 +02:00
|
|
|
bufptr = fld_d1W;
|
2005-04-14 13:31:17 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GetTextExtentPoint32W (hdc, bufptr, strlenW(bufptr), &size);
|
|
|
|
*fieldWidthPtr = size.cx;
|
|
|
|
}
|
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static void
|
|
|
|
DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
int i,prevright;
|
|
|
|
RECT *field;
|
|
|
|
RECT *rcDraw = &infoPtr->rcDraw;
|
|
|
|
RECT *calbutton = &infoPtr->calbutton;
|
|
|
|
RECT *checkbox = &infoPtr->checkbox;
|
|
|
|
SIZE size;
|
2004-12-17 19:50:11 +01:00
|
|
|
COLORREF oldTextColor;
|
2005-05-24 14:34:29 +02:00
|
|
|
SHORT fieldWidth = 0;
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
/* draw control edge */
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (infoPtr->dateValid) {
|
|
|
|
HFONT oldFont = SelectObject (hdc, infoPtr->hFont);
|
2004-12-17 19:50:11 +01:00
|
|
|
INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
|
2004-10-26 02:11:31 +02:00
|
|
|
WCHAR txt[80];
|
|
|
|
|
|
|
|
DATETIME_ReturnTxt (infoPtr, 0, txt, sizeof(txt)/sizeof(txt[0]));
|
|
|
|
GetTextExtentPoint32W (hdc, txt, strlenW(txt), &size);
|
|
|
|
rcDraw->bottom = size.cy + 2;
|
|
|
|
|
|
|
|
prevright = checkbox->right = ((infoPtr->dwStyle & DTS_SHOWNONE) ? 18 : 2);
|
|
|
|
|
|
|
|
for (i = 0; i < infoPtr->nrFields; i++) {
|
|
|
|
DATETIME_ReturnTxt (infoPtr, i, txt, sizeof(txt)/sizeof(txt[0]));
|
|
|
|
GetTextExtentPoint32W (hdc, txt, strlenW(txt), &size);
|
2005-04-14 13:31:17 +02:00
|
|
|
DATETIME_ReturnFieldWidth (infoPtr, hdc, i, &fieldWidth);
|
2004-10-26 02:11:31 +02:00
|
|
|
field = &infoPtr->fieldRect[i];
|
|
|
|
field->left = prevright;
|
2005-04-14 13:31:17 +02:00
|
|
|
field->right = prevright + fieldWidth;
|
2004-10-26 02:11:31 +02:00
|
|
|
field->top = rcDraw->top;
|
|
|
|
field->bottom = rcDraw->bottom;
|
|
|
|
prevright = field->right;
|
|
|
|
|
2004-12-17 19:50:11 +01:00
|
|
|
if (infoPtr->dwStyle & WS_DISABLED)
|
|
|
|
oldTextColor = SetTextColor (hdc, comctl32_color.clrGrayText);
|
|
|
|
else if ((infoPtr->haveFocus) && (i == infoPtr->select)) {
|
|
|
|
/* fill if focussed */
|
|
|
|
HBRUSH hbr = CreateSolidBrush (comctl32_color.clrActiveCaption);
|
2004-10-26 02:11:31 +02:00
|
|
|
FillRect(hdc, field, hbr);
|
|
|
|
DeleteObject (hbr);
|
2004-12-17 19:50:11 +01:00
|
|
|
oldTextColor = SetTextColor (hdc, comctl32_color.clrWindow);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
oldTextColor = SetTextColor (hdc, comctl32_color.clrWindowText);
|
|
|
|
|
|
|
|
/* draw the date text using the colour set above */
|
|
|
|
DrawTextW (hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
|
|
|
|
SetTextColor (hdc, oldTextColor);
|
2004-10-26 02:11:31 +02:00
|
|
|
}
|
2004-12-17 19:50:11 +01:00
|
|
|
SetBkMode (hdc, oldBkMode);
|
2004-10-26 02:11:31 +02:00
|
|
|
SelectObject (hdc, oldFont);
|
2000-05-30 22:06:54 +02:00
|
|
|
}
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if (!(infoPtr->dwStyle & DTS_UPDOWN)) {
|
|
|
|
DrawFrameControl(hdc, calbutton, DFC_SCROLL,
|
|
|
|
DFCS_SCROLLDOWN | (infoPtr->bCalDepressed ? DFCS_PUSHED : 0) |
|
|
|
|
(infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
|
|
|
|
}
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static INT
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_HitTest (const DATETIME_INFO *infoPtr, POINT pt)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
int i;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2006-10-13 15:34:21 +02:00
|
|
|
TRACE ("%d, %d\n", pt.x, pt.y);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
if (PtInRect (&infoPtr->calbutton, pt)) return DTHT_MCPOPUP;
|
|
|
|
if (PtInRect (&infoPtr->checkbox, pt)) return DTHT_CHECKBOX;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
for (i=0; i < infoPtr->nrFields; i++) {
|
|
|
|
if (PtInRect (&infoPtr->fieldRect[i], pt)) return i;
|
2000-05-30 22:06:54 +02:00
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
return DTHT_NONE;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
2004-11-24 19:28:31 +01:00
|
|
|
DATETIME_LButtonDown (DATETIME_INFO *infoPtr, WORD wKey, INT x, INT y)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-11-24 19:28:31 +01:00
|
|
|
POINT pt;
|
|
|
|
int old, new;
|
|
|
|
|
|
|
|
pt.x = x;
|
|
|
|
pt.y = y;
|
|
|
|
old = infoPtr->select;
|
|
|
|
new = DATETIME_HitTest (infoPtr, pt);
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
/* FIXME: might be conditions where we don't want to update infoPtr->select */
|
|
|
|
infoPtr->select = new;
|
|
|
|
|
2004-12-20 18:00:46 +01:00
|
|
|
SetFocus(infoPtr->hwndSelf);
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
if (infoPtr->select == DTHT_MCPOPUP) {
|
2004-12-20 18:00:46 +01:00
|
|
|
RECT rcMonthCal;
|
|
|
|
SendMessageW(infoPtr->hMonthCal, MCM_GETMINREQRECT, 0, (LPARAM)&rcMonthCal);
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
/* FIXME: button actually is only depressed during dropdown of the */
|
|
|
|
/* calendar control and when the mouse is over the button window */
|
|
|
|
infoPtr->bCalDepressed = TRUE;
|
|
|
|
|
|
|
|
/* recalculate the position of the monthcal popup */
|
|
|
|
if(infoPtr->dwStyle & DTS_RIGHTALIGN)
|
2004-12-20 18:00:46 +01:00
|
|
|
infoPtr->monthcal_pos.x = infoPtr->calbutton.left -
|
|
|
|
(rcMonthCal.right - rcMonthCal.left);
|
2004-10-26 02:11:31 +02:00
|
|
|
else
|
2004-12-20 18:00:46 +01:00
|
|
|
/* FIXME: this should be after the area reserved for the checkbox */
|
|
|
|
infoPtr->monthcal_pos.x = infoPtr->rcDraw.left;
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom;
|
|
|
|
ClientToScreen (infoPtr->hwndSelf, &(infoPtr->monthcal_pos));
|
2004-12-20 18:00:46 +01:00
|
|
|
SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x,
|
|
|
|
infoPtr->monthcal_pos.y, rcMonthCal.right - rcMonthCal.left,
|
|
|
|
rcMonthCal.bottom - rcMonthCal.top, 0);
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
if(IsWindowVisible(infoPtr->hMonthCal)) {
|
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_HIDE);
|
|
|
|
} else {
|
2007-03-26 19:57:43 +02:00
|
|
|
const SYSTEMTIME *lprgSysTimeArray = &infoPtr->date;
|
2004-10-26 02:11:31 +02:00
|
|
|
TRACE("update calendar %04d/%02d/%02d\n",
|
|
|
|
lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay);
|
|
|
|
SendMessageW(infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
|
2007-11-01 23:34:35 +01:00
|
|
|
|
|
|
|
if (infoPtr->bDropdownEnabled)
|
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_SHOW);
|
|
|
|
infoPtr->bDropdownEnabled = TRUE;
|
2004-10-26 02:11:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p\n",
|
|
|
|
infoPtr->hwndSelf, infoPtr->hMonthCal, infoPtr->hwndNotify, GetDesktopWindow ());
|
|
|
|
DATETIME_SendSimpleNotify (infoPtr, DTN_DROPDOWN);
|
2004-04-22 00:23:36 +02:00
|
|
|
}
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2004-12-17 19:50:11 +01:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
return 0;
|
2000-05-30 22:06:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2004-11-24 19:28:31 +01:00
|
|
|
DATETIME_LButtonUp (DATETIME_INFO *infoPtr, WORD wKey)
|
2000-05-30 22:06:54 +02:00
|
|
|
{
|
2004-12-09 15:07:59 +01:00
|
|
|
if(infoPtr->bCalDepressed) {
|
2004-10-22 21:52:08 +02:00
|
|
|
infoPtr->bCalDepressed = FALSE;
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, &(infoPtr->calbutton), TRUE);
|
|
|
|
}
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
return 0;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_Paint (DATETIME_INFO *infoPtr, HDC hdc)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
if (!hdc) {
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
hdc = BeginPaint (infoPtr->hwndSelf, &ps);
|
|
|
|
DATETIME_Refresh (infoPtr, hdc);
|
|
|
|
EndPaint (infoPtr->hwndSelf, &ps);
|
|
|
|
} else {
|
|
|
|
DATETIME_Refresh (infoPtr, hdc);
|
|
|
|
}
|
2007-11-01 23:34:35 +01:00
|
|
|
|
|
|
|
/* Not a click on the dropdown box, enabled it */
|
|
|
|
infoPtr->bDropdownEnabled = TRUE;
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2003-05-14 00:04:40 +02:00
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_Button_Command (DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
|
2003-05-14 00:04:40 +02:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
if( HIWORD(wParam) == BN_CLICKED) {
|
|
|
|
DWORD state = SendMessageW((HWND)lParam, BM_GETCHECK, 0, 0);
|
|
|
|
infoPtr->dateValid = (state == BST_CHECKED);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
2003-05-14 00:04:40 +02:00
|
|
|
}
|
2004-10-22 21:52:08 +02:00
|
|
|
return 0;
|
2003-05-14 00:04:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_Command (DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
|
2003-05-14 00:04:40 +02:00
|
|
|
{
|
|
|
|
TRACE("hwndbutton = %p\n", infoPtr->hwndCheckbut);
|
|
|
|
if(infoPtr->hwndCheckbut == (HWND)lParam)
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_Button_Command(infoPtr, wParam, lParam);
|
2003-05-14 00:04:40 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2004-12-17 19:50:11 +01:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_Enable (DATETIME_INFO *infoPtr, BOOL bEnable)
|
|
|
|
{
|
|
|
|
TRACE("%p %s\n", infoPtr, bEnable ? "TRUE" : "FALSE");
|
|
|
|
if (bEnable)
|
|
|
|
infoPtr->dwStyle &= ~WS_DISABLED;
|
|
|
|
else
|
|
|
|
infoPtr->dwStyle |= WS_DISABLED;
|
2007-06-21 11:24:16 +02:00
|
|
|
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
|
|
|
|
2004-12-17 19:50:11 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static LRESULT
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_EraseBackground (const DATETIME_INFO *infoPtr, HDC hdc)
|
2004-12-17 19:50:11 +01:00
|
|
|
{
|
|
|
|
HBRUSH hBrush, hSolidBrush = NULL;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
if (infoPtr->dwStyle & WS_DISABLED)
|
|
|
|
hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrBtnFace);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLOREDIT,
|
|
|
|
(WPARAM)hdc, (LPARAM)infoPtr->hwndSelf);
|
|
|
|
if (!hBrush)
|
|
|
|
hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
GetClientRect (infoPtr->hwndSelf, &rc);
|
|
|
|
|
|
|
|
FillRect (hdc, &rc, hBrush);
|
|
|
|
|
|
|
|
if (hSolidBrush)
|
|
|
|
DeleteObject(hSolidBrush);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_Notify (DATETIME_INFO *infoPtr, int idCtrl, LPNMHDR lpnmh)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom);
|
|
|
|
TRACE ("info: %p %p %p\n", infoPtr->hwndSelf, infoPtr->hMonthCal, infoPtr->hUpdown);
|
|
|
|
|
|
|
|
if (lpnmh->code == MCN_SELECT) {
|
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_HIDE);
|
|
|
|
infoPtr->dateValid = TRUE;
|
|
|
|
SendMessageW (infoPtr->hMonthCal, MCM_GETCURSEL, 0, (LPARAM)&infoPtr->date);
|
2005-04-14 13:31:17 +02:00
|
|
|
TRACE("got from calendar %04d/%02d/%02d day of week %d\n",
|
|
|
|
infoPtr->date.wYear, infoPtr->date.wMonth, infoPtr->date.wDay, infoPtr->date.wDayOfWeek);
|
2004-10-22 21:52:08 +02:00
|
|
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
}
|
2005-04-14 13:31:17 +02:00
|
|
|
if ((lpnmh->hwndFrom == infoPtr->hUpdown) && (lpnmh->code == UDN_DELTAPOS)) {
|
|
|
|
LPNMUPDOWN lpnmud = (LPNMUPDOWN)lpnmh;
|
|
|
|
TRACE("Delta pos %d\n", lpnmud->iDelta);
|
|
|
|
infoPtr->pendingUpdown = lpnmud->iDelta;
|
|
|
|
}
|
2004-10-22 21:52:08 +02:00
|
|
|
return 0;
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode, LPARAM flags)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
int fieldNum = infoPtr->select & DTHT_DATEFIELD;
|
|
|
|
int wrap = 0;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if (!(infoPtr->haveFocus)) return 0;
|
|
|
|
if ((fieldNum==0) && (infoPtr->select)) return 0;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if (infoPtr->select & FORMATCALLMASK) {
|
2000-02-03 01:48:39 +01:00
|
|
|
FIXME ("Callbacks not implemented yet\n");
|
2004-10-26 02:11:31 +02:00
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2005-04-16 12:48:02 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
switch (vkCode) {
|
2000-02-03 01:48:39 +01:00
|
|
|
case VK_ADD:
|
2002-06-01 01:06:46 +02:00
|
|
|
case VK_UP:
|
2004-10-26 02:11:31 +02:00
|
|
|
DATETIME_IncreaseField (infoPtr, fieldNum, 1);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
break;
|
2000-02-03 01:48:39 +01:00
|
|
|
case VK_SUBTRACT:
|
|
|
|
case VK_DOWN:
|
2004-10-26 02:11:31 +02:00
|
|
|
DATETIME_IncreaseField (infoPtr, fieldNum, -1);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
break;
|
2000-02-03 01:48:39 +01:00
|
|
|
case VK_HOME:
|
2004-10-26 02:11:31 +02:00
|
|
|
DATETIME_IncreaseField (infoPtr, fieldNum, INT_MIN);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
break;
|
2000-02-03 01:48:39 +01:00
|
|
|
case VK_END:
|
2004-10-26 02:11:31 +02:00
|
|
|
DATETIME_IncreaseField (infoPtr, fieldNum, INT_MAX);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case VK_LEFT:
|
2004-10-26 02:11:31 +02:00
|
|
|
do {
|
|
|
|
if (infoPtr->select == 0) {
|
|
|
|
infoPtr->select = infoPtr->nrFields - 1;
|
|
|
|
wrap++;
|
|
|
|
} else {
|
|
|
|
infoPtr->select--;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
2004-10-26 02:11:31 +02:00
|
|
|
} while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case VK_RIGHT:
|
2004-10-26 02:11:31 +02:00
|
|
|
do {
|
|
|
|
infoPtr->select++;
|
|
|
|
if (infoPtr->select==infoPtr->nrFields) {
|
|
|
|
infoPtr->select = 0;
|
|
|
|
wrap++;
|
|
|
|
}
|
|
|
|
} while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
|
|
|
|
break;
|
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2005-04-16 12:48:02 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
return 0;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-14 13:31:17 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_VScroll (DATETIME_INFO *infoPtr, WORD wScroll)
|
|
|
|
{
|
|
|
|
int fieldNum = infoPtr->select & DTHT_DATEFIELD;
|
|
|
|
|
|
|
|
if ((SHORT)LOWORD(wScroll) != SB_THUMBPOSITION) return 0;
|
|
|
|
if (!(infoPtr->haveFocus)) return 0;
|
|
|
|
if ((fieldNum==0) && (infoPtr->select)) return 0;
|
|
|
|
|
|
|
|
if (infoPtr->pendingUpdown >= 0) {
|
|
|
|
DATETIME_IncreaseField (infoPtr, fieldNum, 1);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
DATETIME_IncreaseField (infoPtr, fieldNum, -1);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
}
|
|
|
|
|
2005-04-15 16:08:39 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
2005-04-14 13:31:17 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_KillFocus (DATETIME_INFO *infoPtr, HWND lostFocus)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-12-20 18:00:46 +01:00
|
|
|
TRACE("lost focus to %p\n", lostFocus);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
if (infoPtr->haveFocus) {
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_SendSimpleNotify (infoPtr, NM_KILLFOCUS);
|
2000-02-03 01:48:39 +01:00
|
|
|
infoPtr->haveFocus = 0;
|
|
|
|
}
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-20 18:00:46 +01:00
|
|
|
static LRESULT
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_NCCreate (HWND hwnd, const CREATESTRUCTW *lpcs)
|
2004-12-20 18:00:46 +01:00
|
|
|
{
|
|
|
|
DWORD dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE);
|
|
|
|
/* force control to have client edge */
|
|
|
|
dwExStyle |= WS_EX_CLIENTEDGE;
|
|
|
|
SetWindowLongW(hwnd, GWL_EXSTYLE, dwExStyle);
|
|
|
|
|
|
|
|
return DefWindowProcW(hwnd, WM_NCCREATE, 0, (LPARAM)lpcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_SetFocus (DATETIME_INFO *infoPtr, HWND lostFocus)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-12-20 18:00:46 +01:00
|
|
|
TRACE("got focus from %p\n", lostFocus);
|
|
|
|
|
2007-11-01 23:34:35 +01:00
|
|
|
/* if monthcal is open and it loses focus, close monthcal */
|
|
|
|
if (infoPtr->hMonthCal && (lostFocus == infoPtr->hMonthCal) && \
|
|
|
|
IsWindowVisible(infoPtr->hMonthCal))
|
|
|
|
{
|
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_HIDE);
|
|
|
|
DATETIME_SendSimpleNotify(infoPtr, DTN_CLOSEUP);
|
|
|
|
/* note: this get triggered even if monthcal loses focus to a dropdown
|
|
|
|
* box click, which occurs without an intermediate WM_PAINT call
|
|
|
|
*/
|
|
|
|
infoPtr->bDropdownEnabled = FALSE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
if (infoPtr->haveFocus == 0) {
|
|
|
|
DATETIME_SendSimpleNotify (infoPtr, NM_SETFOCUS);
|
2000-05-30 22:06:54 +02:00
|
|
|
infoPtr->haveFocus = DTHT_GOTFOCUS;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
static BOOL
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_SendDateTimeChangeNotify (const DATETIME_INFO *infoPtr)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
NMDATETIMECHANGE dtdtc;
|
|
|
|
|
|
|
|
dtdtc.nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
dtdtc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
|
|
|
dtdtc.nmhdr.code = DTN_DATETIMECHANGE;
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
dtdtc.dwFlags = (infoPtr->dwStyle & DTS_SHOWNONE) ? GDT_NONE : GDT_VALID;
|
2004-10-22 21:52:08 +02:00
|
|
|
|
|
|
|
MONTHCAL_CopyTime (&infoPtr->date, &dtdtc.st);
|
|
|
|
return (BOOL) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
|
|
|
|
(WPARAM)dtdtc.nmhdr.idFrom, (LPARAM)&dtdtc);
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static BOOL
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_SendSimpleNotify (const DATETIME_INFO *infoPtr, UINT code)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
|
|
|
NMHDR nmhdr;
|
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
TRACE("%x\n", code);
|
|
|
|
nmhdr.hwndFrom = infoPtr->hwndSelf;
|
|
|
|
nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
|
1999-07-31 13:12:45 +02:00
|
|
|
nmhdr.code = code;
|
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
return (BOOL) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
|
2000-02-03 01:48:39 +01:00
|
|
|
(WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
|
1999-07-31 13:12:45 +02:00
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_Size (DATETIME_INFO *infoPtr, WORD flags, INT width, INT height)
|
2000-05-30 22:06:54 +02:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
/* set size */
|
|
|
|
infoPtr->rcClient.bottom = height;
|
|
|
|
infoPtr->rcClient.right = width;
|
|
|
|
|
2006-10-13 15:34:21 +02:00
|
|
|
TRACE("Height=%d, Width=%d\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right);
|
2004-10-26 02:11:31 +02:00
|
|
|
|
2004-12-20 18:00:46 +01:00
|
|
|
infoPtr->rcDraw = infoPtr->rcClient;
|
2005-04-14 13:31:17 +02:00
|
|
|
|
|
|
|
if (infoPtr->dwStyle & DTS_UPDOWN) {
|
2005-04-15 16:08:39 +02:00
|
|
|
SetWindowPos(infoPtr->hUpdown, NULL,
|
|
|
|
infoPtr->rcClient.right-14, 0,
|
|
|
|
15, infoPtr->rcClient.bottom - infoPtr->rcClient.top,
|
|
|
|
SWP_NOACTIVATE | SWP_NOZORDER);
|
2005-04-14 13:31:17 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* set the size of the button that drops the calendar down */
|
|
|
|
/* FIXME: account for style that allows button on left side */
|
|
|
|
infoPtr->calbutton.top = infoPtr->rcDraw.top;
|
|
|
|
infoPtr->calbutton.bottom= infoPtr->rcDraw.bottom;
|
|
|
|
infoPtr->calbutton.left = infoPtr->rcDraw.right-15;
|
|
|
|
infoPtr->calbutton.right = infoPtr->rcDraw.right;
|
|
|
|
}
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
/* set enable/disable button size for show none style being enabled */
|
|
|
|
/* FIXME: these dimensions are completely incorrect */
|
|
|
|
infoPtr->checkbox.top = infoPtr->rcDraw.top;
|
|
|
|
infoPtr->checkbox.bottom = infoPtr->rcDraw.bottom;
|
|
|
|
infoPtr->checkbox.left = infoPtr->rcDraw.left;
|
|
|
|
infoPtr->checkbox.right = infoPtr->rcDraw.left + 10;
|
|
|
|
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
return 0;
|
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
static LRESULT
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_StyleChanged(DATETIME_INFO *infoPtr, WPARAM wStyleType, const STYLESTRUCT *lpss)
|
2004-10-26 02:11:31 +02:00
|
|
|
{
|
|
|
|
static const WCHAR buttonW[] = { 'b', 'u', 't', 't', 'o', 'n', 0 };
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
|
2004-10-26 02:11:31 +02:00
|
|
|
wStyleType, lpss->styleOld, lpss->styleNew);
|
1999-03-12 18:42:50 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if (wStyleType != GWL_STYLE) return 0;
|
|
|
|
|
|
|
|
infoPtr->dwStyle = lpss->styleNew;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if ( !(lpss->styleOld & DTS_SHOWNONE) && (lpss->styleNew & DTS_SHOWNONE) ) {
|
|
|
|
infoPtr->hwndCheckbut = CreateWindowExW (0, buttonW, 0, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
|
|
|
|
2, 2, 13, 13, infoPtr->hwndSelf, 0,
|
|
|
|
(HINSTANCE)GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_HINSTANCE), 0);
|
|
|
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0);
|
|
|
|
}
|
|
|
|
if ( (lpss->styleOld & DTS_SHOWNONE) && !(lpss->styleNew & DTS_SHOWNONE) ) {
|
|
|
|
DestroyWindow(infoPtr->hwndCheckbut);
|
|
|
|
infoPtr->hwndCheckbut = 0;
|
|
|
|
}
|
|
|
|
if ( !(lpss->styleOld & DTS_UPDOWN) && (lpss->styleNew & DTS_UPDOWN) ) {
|
|
|
|
infoPtr->hUpdown = CreateUpDownControl (WS_CHILD | WS_BORDER | WS_VISIBLE, 120, 1, 20, 20,
|
|
|
|
infoPtr->hwndSelf, 1, 0, 0, UD_MAXVAL, UD_MINVAL, 0);
|
|
|
|
}
|
|
|
|
if ( (lpss->styleOld & DTS_UPDOWN) && !(lpss->styleNew & DTS_UPDOWN) ) {
|
|
|
|
DestroyWindow(infoPtr->hUpdown);
|
|
|
|
infoPtr->hUpdown = 0;
|
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
|
|
|
return 0;
|
2000-05-30 22:06:54 +02:00
|
|
|
}
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2005-08-22 11:20:36 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_SetFont (DATETIME_INFO *infoPtr, HFONT font, BOOL repaint)
|
|
|
|
{
|
|
|
|
infoPtr->hFont = font;
|
|
|
|
if (repaint) InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
static LRESULT
|
2007-03-26 19:57:43 +02:00
|
|
|
DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
|
2000-05-30 22:06:54 +02:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
static const WCHAR SysMonthCal32W[] = { 'S', 'y', 's', 'M', 'o', 'n', 't', 'h', 'C', 'a', 'l', '3', '2', 0 };
|
|
|
|
DATETIME_INFO *infoPtr = (DATETIME_INFO *)Alloc (sizeof(DATETIME_INFO));
|
|
|
|
STYLESTRUCT ss = { 0, lpcs->style };
|
|
|
|
|
|
|
|
if (!infoPtr) return -1;
|
|
|
|
|
|
|
|
infoPtr->hwndSelf = hwnd;
|
|
|
|
infoPtr->dwStyle = lpcs->style;
|
|
|
|
|
|
|
|
infoPtr->nrFieldsAllocated = 32;
|
|
|
|
infoPtr->fieldspec = (int *) Alloc (infoPtr->nrFieldsAllocated * sizeof(int));
|
|
|
|
infoPtr->fieldRect = (RECT *) Alloc (infoPtr->nrFieldsAllocated * sizeof(RECT));
|
|
|
|
infoPtr->buflen = (int *) Alloc (infoPtr->nrFieldsAllocated * sizeof(int));
|
|
|
|
infoPtr->hwndNotify = lpcs->hwndParent;
|
2004-12-17 19:50:11 +01:00
|
|
|
infoPtr->select = -1; /* initially, nothing is selected */
|
2007-11-01 23:34:35 +01:00
|
|
|
infoPtr->bDropdownEnabled = TRUE;
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
DATETIME_StyleChanged(infoPtr, GWL_STYLE, &ss);
|
|
|
|
DATETIME_SetFormatW (infoPtr, 0);
|
|
|
|
|
|
|
|
/* create the monthcal control */
|
|
|
|
infoPtr->hMonthCal = CreateWindowExW (0, SysMonthCal32W, 0, WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS,
|
|
|
|
0, 0, 0, 0, infoPtr->hwndSelf, 0, 0, 0);
|
|
|
|
|
|
|
|
/* initialize info structure */
|
2005-04-18 11:52:18 +02:00
|
|
|
GetLocalTime (&infoPtr->date);
|
2004-10-26 02:11:31 +02:00
|
|
|
infoPtr->dateValid = TRUE;
|
|
|
|
infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT);
|
|
|
|
|
|
|
|
SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
|
|
|
|
|
|
|
|
return 0;
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
|
1998-11-08 12:30:27 +01:00
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_Destroy (DATETIME_INFO *infoPtr)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
if (infoPtr->hwndCheckbut)
|
|
|
|
DestroyWindow(infoPtr->hwndCheckbut);
|
|
|
|
if (infoPtr->hUpdown)
|
|
|
|
DestroyWindow(infoPtr->hUpdown);
|
2004-10-22 21:52:08 +02:00
|
|
|
if (infoPtr->hMonthCal)
|
2004-04-22 00:23:36 +02:00
|
|
|
DestroyWindow(infoPtr->hMonthCal);
|
2004-10-22 21:52:08 +02:00
|
|
|
SetWindowLongPtrW( infoPtr->hwndSelf, 0, 0 ); /* clear infoPtr */
|
2003-09-22 23:32:33 +02:00
|
|
|
Free (infoPtr);
|
1998-11-08 12:30:27 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-31 16:41:43 +02:00
|
|
|
static LRESULT WINAPI
|
1999-02-26 12:11:13 +01:00
|
|
|
DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_INFO *infoPtr = ((DATETIME_INFO *)GetWindowLongPtrW (hwnd, 0));
|
2004-10-26 02:11:31 +02:00
|
|
|
LRESULT ret;
|
2004-10-22 21:52:08 +02:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE ("%x, %lx, %lx\n", uMsg, wParam, lParam);
|
2004-10-22 21:52:08 +02:00
|
|
|
|
2004-12-20 18:00:46 +01:00
|
|
|
if (!infoPtr && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE))
|
2004-10-22 21:52:08 +02:00
|
|
|
return DefWindowProcW( hwnd, uMsg, wParam, lParam );
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
switch (uMsg) {
|
1998-11-08 12:30:27 +01:00
|
|
|
|
1999-01-17 17:32:32 +01:00
|
|
|
case DTM_GETSYSTEMTIME:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_GetSystemTime (infoPtr, (SYSTEMTIME *) lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_SETSYSTEMTIME:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_SetSystemTime (infoPtr, wParam, (SYSTEMTIME *) lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_GETRANGE:
|
2004-10-26 02:11:31 +02:00
|
|
|
ret = SendMessageW (infoPtr->hMonthCal, MCM_GETRANGE, wParam, lParam);
|
|
|
|
return ret ? ret : 1; /* bug emulation */
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_SETRANGE:
|
2004-10-22 21:52:08 +02:00
|
|
|
return SendMessageW (infoPtr->hMonthCal, MCM_SETRANGE, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
case DTM_SETFORMATA:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_SetFormatA (infoPtr, (LPCSTR)lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
case DTM_SETFORMATW:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_SetFormatW (infoPtr, (LPCWSTR)lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
case DTM_GETMONTHCAL:
|
|
|
|
return (LRESULT)infoPtr->hMonthCal;
|
|
|
|
|
1999-01-17 17:32:32 +01:00
|
|
|
case DTM_SETMCCOLOR:
|
2004-10-22 21:52:08 +02:00
|
|
|
return SendMessageW (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_GETMCCOLOR:
|
2004-10-22 21:52:08 +02:00
|
|
|
return SendMessageW (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_SETMCFONT:
|
2004-10-26 02:11:31 +02:00
|
|
|
return SendMessageW (infoPtr->hMonthCal, WM_SETFONT, wParam, lParam);
|
1999-01-17 17:32:32 +01:00
|
|
|
|
|
|
|
case DTM_GETMCFONT:
|
2004-10-26 02:11:31 +02:00
|
|
|
return SendMessageW (infoPtr->hMonthCal, WM_GETFONT, wParam, lParam);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_Notify (infoPtr, (int)wParam, (LPNMHDR)lParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-12-17 19:50:11 +01:00
|
|
|
case WM_ENABLE:
|
|
|
|
return DATETIME_Enable (infoPtr, (BOOL)wParam);
|
|
|
|
|
|
|
|
case WM_ERASEBKGND:
|
|
|
|
return DATETIME_EraseBackground (infoPtr, (HDC)wParam);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_GETDLGCODE:
|
|
|
|
return DLGC_WANTARROWS | DLGC_WANTCHARS;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2005-11-08 13:52:35 +01:00
|
|
|
case WM_PRINTCLIENT:
|
1999-07-31 13:12:45 +02:00
|
|
|
case WM_PAINT:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_Paint (infoPtr, (HDC)wParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_KEYDOWN:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_KeyDown (infoPtr, wParam, lParam);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
case WM_KILLFOCUS:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_KillFocus (infoPtr, (HWND)wParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-12-20 18:00:46 +01:00
|
|
|
case WM_NCCREATE:
|
|
|
|
return DATETIME_NCCreate (hwnd, (LPCREATESTRUCTW)lParam);
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
case WM_SETFOCUS:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_SetFocus (infoPtr, (HWND)wParam);
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
case WM_SIZE:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_Size (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
|
2000-05-30 22:06:54 +02:00
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
case WM_LBUTTONDOWN:
|
2004-11-24 19:28:31 +01:00
|
|
|
return DATETIME_LButtonDown (infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam));
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
case WM_LBUTTONUP:
|
2004-11-24 19:28:31 +01:00
|
|
|
return DATETIME_LButtonUp (infoPtr, (WORD)wParam);
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2005-04-14 13:31:17 +02:00
|
|
|
case WM_VSCROLL:
|
|
|
|
return DATETIME_VScroll (infoPtr, (WORD)wParam);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_CREATE:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_Create (hwnd, (LPCREATESTRUCTW)lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_DESTROY:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_Destroy (infoPtr);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2003-05-14 00:04:40 +02:00
|
|
|
case WM_COMMAND:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_Command (infoPtr, wParam, lParam);
|
2003-05-14 00:04:40 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
case WM_STYLECHANGED:
|
|
|
|
return DATETIME_StyleChanged(infoPtr, wParam, (LPSTYLESTRUCT)lParam);
|
|
|
|
|
2005-08-22 11:20:36 +02:00
|
|
|
case WM_SETFONT:
|
|
|
|
return DATETIME_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
|
|
|
|
|
|
|
|
case WM_GETFONT:
|
|
|
|
return (LRESULT) infoPtr->hFont;
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
default:
|
2002-07-16 03:23:59 +02:00
|
|
|
if ((uMsg >= WM_USER) && (uMsg < WM_APP))
|
2007-05-24 16:41:17 +02:00
|
|
|
ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
|
1998-11-08 12:30:27 +01:00
|
|
|
uMsg, wParam, lParam);
|
2004-10-22 21:52:08 +02:00
|
|
|
return DefWindowProcW (hwnd, uMsg, wParam, lParam);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
void
|
1999-06-12 10:27:49 +02:00
|
|
|
DATETIME_Register (void)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
WNDCLASSW wndClass;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
ZeroMemory (&wndClass, sizeof(WNDCLASSW));
|
1998-11-08 12:30:27 +01:00
|
|
|
wndClass.style = CS_GLOBALCLASS;
|
2004-11-06 04:49:03 +01:00
|
|
|
wndClass.lpfnWndProc = DATETIME_WindowProc;
|
1998-11-08 12:30:27 +01:00
|
|
|
wndClass.cbClsExtra = 0;
|
|
|
|
wndClass.cbWndExtra = sizeof(DATETIME_INFO *);
|
2004-10-22 21:52:08 +02:00
|
|
|
wndClass.hCursor = LoadCursorW (0, (LPCWSTR)IDC_ARROW);
|
1999-02-26 12:11:13 +01:00
|
|
|
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
2004-10-22 21:52:08 +02:00
|
|
|
wndClass.lpszClassName = DATETIMEPICK_CLASSW;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
RegisterClassW (&wndClass);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
void
|
1999-06-12 10:27:49 +02:00
|
|
|
DATETIME_Unregister (void)
|
1998-11-08 12:30:27 +01:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
UnregisterClassW (DATETIMEPICK_CLASSW, NULL);
|
1998-11-08 12:30:27 +01:00
|
|
|
}
|