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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 */
|
|
|
|
int select;
|
|
|
|
HFONT hFont;
|
|
|
|
int nrFieldsAllocated;
|
|
|
|
int nrFields;
|
|
|
|
int haveFocus;
|
|
|
|
int *fieldspec;
|
|
|
|
RECT *fieldRect;
|
|
|
|
int *buflen;
|
|
|
|
WCHAR textbuf[256];
|
|
|
|
POINT monthcal_pos;
|
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
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static BOOL DATETIME_SendSimpleNotify (DATETIME_INFO *infoPtr, UINT code);
|
|
|
|
static BOOL DATETIME_SendDateTimeChangeNotify (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
|
|
|
|
DATETIME_GetSystemTime (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
|
|
|
|
DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, 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) {
|
|
|
|
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);
|
|
|
|
} else if (flag == GDT_NONE) {
|
|
|
|
infoPtr->dateValid = FALSE;
|
|
|
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 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;
|
2004-10-26 02:11:31 +02:00
|
|
|
else if (infoPtr->dwStyle & 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);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
return infoPtr->nrFields;
|
|
|
|
}
|
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
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_ReturnTxt (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:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt_dW, date.wHour - (date.wHour > 12 ? 12 : 0));
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case TWODIGIT12HOUR:
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt__2dW, date.wHour - (date.wHour > 12 ? 12 : 0));
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
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));
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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 *rcClient = &infoPtr->rcClient;
|
|
|
|
RECT *calbutton = &infoPtr->calbutton;
|
|
|
|
RECT *checkbox = &infoPtr->checkbox;
|
|
|
|
HBRUSH hbr;
|
|
|
|
SIZE size;
|
|
|
|
COLORREF oldBk, oldTextColor;
|
|
|
|
|
|
|
|
/* draw control edge */
|
|
|
|
TRACE("\n");
|
|
|
|
hbr = CreateSolidBrush(RGB(255, 255, 255));
|
|
|
|
FillRect(hdc, rcClient, hbr);
|
|
|
|
DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT);
|
|
|
|
DeleteObject(hbr);
|
|
|
|
|
|
|
|
if (infoPtr->dateValid) {
|
|
|
|
HFONT oldFont = SelectObject (hdc, infoPtr->hFont);
|
|
|
|
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);
|
|
|
|
field = &infoPtr->fieldRect[i];
|
|
|
|
field->left = prevright;
|
|
|
|
field->right = prevright+size.cx;
|
|
|
|
field->top = rcDraw->top;
|
|
|
|
field->bottom = rcDraw->bottom;
|
|
|
|
prevright = field->right;
|
|
|
|
|
|
|
|
if ((infoPtr->haveFocus) && (i == infoPtr->select)) {
|
|
|
|
hbr = CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION));
|
|
|
|
FillRect(hdc, field, hbr);
|
|
|
|
oldBk = SetBkColor (hdc, GetSysColor(COLOR_ACTIVECAPTION));
|
|
|
|
oldTextColor = SetTextColor (hdc, GetSysColor(COLOR_WINDOW));
|
|
|
|
DeleteObject (hbr);
|
|
|
|
DrawTextW (hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
|
|
|
|
SetBkColor (hdc, oldBk);
|
2000-02-03 01:48:39 +01:00
|
|
|
SetTextColor (hdc, oldTextColor);
|
2004-10-26 02:11:31 +02:00
|
|
|
} else
|
|
|
|
DrawTextW ( hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
|
|
|
|
}
|
|
|
|
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
|
|
|
|
DATETIME_HitTest (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
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
TRACE ("%ld, %ld\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-10-22 21:52:08 +02:00
|
|
|
DATETIME_LButtonDown (DATETIME_INFO *infoPtr, WORD wKey, POINTS pts)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-10-26 02:11:31 +02:00
|
|
|
POINT pt = { pts.x, pts.y };
|
|
|
|
int old = infoPtr->select;
|
|
|
|
int new = DATETIME_HitTest (infoPtr, pt);
|
|
|
|
|
|
|
|
/* FIXME: might be conditions where we don't want to update infoPtr->select */
|
|
|
|
infoPtr->select = new;
|
|
|
|
|
|
|
|
if (infoPtr->select != old)
|
|
|
|
infoPtr->haveFocus = DTHT_GOTFOCUS;
|
|
|
|
|
|
|
|
if (infoPtr->select == DTHT_MCPOPUP) {
|
|
|
|
/* 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)
|
|
|
|
infoPtr->monthcal_pos.x = infoPtr->rcClient.right -
|
|
|
|
((infoPtr->calbutton.right - infoPtr->calbutton.left) + 200);
|
|
|
|
else
|
|
|
|
infoPtr->monthcal_pos.x = 8;
|
|
|
|
|
|
|
|
infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom;
|
|
|
|
ClientToScreen (infoPtr->hwndSelf, &(infoPtr->monthcal_pos));
|
|
|
|
/* FIXME My Windoze has cx=about 200, but it probably depends on font size etc */
|
|
|
|
SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x, infoPtr->monthcal_pos.y, 200, 150, 0);
|
|
|
|
|
|
|
|
if(IsWindowVisible(infoPtr->hMonthCal)) {
|
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_HIDE);
|
|
|
|
} else {
|
|
|
|
SYSTEMTIME *lprgSysTimeArray = &infoPtr->date;
|
|
|
|
TRACE("update calendar %04d/%02d/%02d\n",
|
|
|
|
lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay);
|
|
|
|
SendMessageW(infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
|
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_SHOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-10-26 02:11:31 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
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-10-22 21:52:08 +02:00
|
|
|
DATETIME_LButtonUp (DATETIME_INFO *infoPtr, WORD wKey, POINTS pts)
|
2000-05-30 22:06:54 +02:00
|
|
|
{
|
2004-10-22 21:52:08 +02:00
|
|
|
if(infoPtr->bCalDepressed == TRUE) {
|
|
|
|
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);
|
|
|
|
}
|
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
|
|
|
|
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);
|
|
|
|
TRACE("got from calendar %04d/%02d/%02d\n",
|
|
|
|
infoPtr->date.wYear, infoPtr->date.wMonth, infoPtr->date.wDay);
|
|
|
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
|
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
}
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-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
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_SendDateTimeChangeNotify (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
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_SendSimpleNotify (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;
|
|
|
|
|
|
|
|
TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right);
|
|
|
|
|
|
|
|
/* use DrawEdge to adjust the size of rcEdge to get rcDraw */
|
|
|
|
memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw));
|
|
|
|
|
|
|
|
DrawEdge(NULL, &(infoPtr->rcDraw), EDGE_SUNKEN, BF_RECT | BF_ADJUST);
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* update the position of the monthcal control */
|
|
|
|
if(infoPtr->dwStyle & DTS_RIGHTALIGN)
|
|
|
|
infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
|
|
|
|
infoPtr->calbutton.left) + 145);
|
|
|
|
else
|
|
|
|
infoPtr->monthcal_pos.x = 8;
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom;
|
|
|
|
ClientToScreen (infoPtr->hwndSelf, &(infoPtr->monthcal_pos));
|
|
|
|
SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x, infoPtr->monthcal_pos.y, 145, 150, 0);
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
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
|
|
|
|
DATETIME_StyleChanged(DATETIME_INFO *infoPtr, WPARAM wStyleType, LPSTYLESTRUCT lpss)
|
|
|
|
{
|
|
|
|
static const WCHAR buttonW[] = { 'b', 'u', 't', 't', 'o', 'n', 0 };
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
TRACE("(styletype=%x, styleOld=0x%08lx, styleNew=0x%08lx)\n",
|
|
|
|
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
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
static LRESULT
|
2004-10-22 21:52:08 +02:00
|
|
|
DATETIME_Create (HWND hwnd, LPCREATESTRUCTW 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;
|
|
|
|
|
|
|
|
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 */
|
|
|
|
GetSystemTime (&infoPtr->date);
|
|
|
|
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
|
|
|
|
|
|
|
TRACE ("%x, %x, %lx\n", uMsg, wParam, lParam);
|
|
|
|
|
|
|
|
if (!infoPtr && (uMsg != WM_CREATE))
|
|
|
|
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
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_GETDLGCODE:
|
|
|
|
return DLGC_WANTARROWS | DLGC_WANTCHARS;
|
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
|
|
|
|
|
|
|
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-10-22 21:52:08 +02:00
|
|
|
return DATETIME_LButtonDown (infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
|
1998-11-08 12:30:27 +01:00
|
|
|
|
2000-05-30 22:06:54 +02:00
|
|
|
case WM_LBUTTONUP:
|
2004-10-22 21:52:08 +02:00
|
|
|
return DATETIME_LButtonUp (infoPtr, (WORD)wParam, MAKEPOINTS(lParam));
|
2000-05-30 22:06:54 +02:00
|
|
|
|
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);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
default:
|
2002-07-16 03:23:59 +02:00
|
|
|
if ((uMsg >= WM_USER) && (uMsg < WM_APP))
|
1999-06-12 17:45:58 +02:00
|
|
|
ERR("unknown msg %04x wp=%08x 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
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
1999-02-26 12:11:13 +01:00
|
|
|
wndClass.lpfnWndProc = (WNDPROC)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
|
|
|
}
|