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>
|
2012-03-08 12:34:38 +01:00
|
|
|
* Copyright 2012 Owen Rudge for CodeWeavers
|
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
|
|
|
*
|
|
|
|
* TODO:
|
2004-10-22 21:52:08 +02:00
|
|
|
* -- DTS_APPCANPARSE
|
|
|
|
* -- DTS_SHORTDATECENTURYFORMAT
|
|
|
|
* -- 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"
|
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 */
|
2013-10-22 00:16:08 +02:00
|
|
|
BOOL bDropdownEnabled;
|
2004-10-22 21:52:08 +02:00
|
|
|
int select;
|
2011-03-09 22:30:54 +01:00
|
|
|
WCHAR charsEntered[4];
|
|
|
|
int nCharsEntered;
|
2004-10-22 21:52:08 +02:00
|
|
|
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);
|
2009-10-11 02:28:09 +02:00
|
|
|
extern int MONTHCAL_CalculateDayOfWeek(SYSTEMTIME *date, BOOL inplace);
|
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 */
|
|
|
|
|
2009-10-08 22:00:49 +02:00
|
|
|
#define DTHT_NONE 0x1000
|
|
|
|
#define DTHT_CHECKBOX 0x2000 /* these should end at '00' , to make */
|
|
|
|
#define DTHT_MCPOPUP 0x3000 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
|
|
|
|
#define DTHT_GOTFOCUS 0x4000 /* tests for date-fields */
|
|
|
|
#define DTHT_NODATEMASK 0xf000 /* to mask check and drop down from others */
|
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);
|
2008-02-22 22:32:47 +01:00
|
|
|
static const WCHAR allowedformatchars[] = {'d', 'h', 'H', 'm', 'M', 's', 't', 'y', 'X', 0};
|
|
|
|
static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1};
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2012-03-08 12:34:13 +01:00
|
|
|
/* valid date limits */
|
|
|
|
static const SYSTEMTIME max_allowed_date = { /* wYear */ 9999, /* wMonth */ 12, /* wDayOfWeek */ 0, /* wDay */ 31 };
|
|
|
|
static const SYSTEMTIME min_allowed_date = { /* wYear */ 1752, /* wMonth */ 9, /* wDayOfWeek */ 0, /* wDay */ 14 };
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static DWORD
|
2009-09-25 21:41:08 +02:00
|
|
|
DATETIME_GetSystemTime (const DATETIME_INFO *infoPtr, SYSTEMTIME *systime)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2009-09-25 21:41:08 +02:00
|
|
|
if (!systime) 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;
|
|
|
|
|
2009-09-25 21:41:08 +02:00
|
|
|
*systime = infoPtr->date;
|
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
|
|
|
}
|
|
|
|
|
2012-03-08 12:34:13 +01:00
|
|
|
/* Checks value is within configured date range
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
*
|
|
|
|
* [I] infoPtr : valid pointer to control data
|
|
|
|
* [I] date : pointer to valid date data to check
|
|
|
|
*
|
|
|
|
* RETURN VALUE
|
|
|
|
*
|
|
|
|
* TRUE - date within configured range
|
|
|
|
* FALSE - date is outside configured range
|
|
|
|
*/
|
|
|
|
static BOOL DATETIME_IsDateInValidRange(const DATETIME_INFO *infoPtr, const SYSTEMTIME *date)
|
|
|
|
{
|
|
|
|
SYSTEMTIME range[2];
|
|
|
|
DWORD limits;
|
|
|
|
|
|
|
|
if ((MONTHCAL_CompareSystemTime(date, &max_allowed_date) == 1) ||
|
|
|
|
(MONTHCAL_CompareSystemTime(date, &min_allowed_date) == -1))
|
|
|
|
return FALSE;
|
|
|
|
|
2012-12-05 23:42:28 +01:00
|
|
|
limits = SendMessageW (infoPtr->hMonthCal, MCM_GETRANGE, 0, (LPARAM)range);
|
2012-03-08 12:34:13 +01:00
|
|
|
|
|
|
|
if (limits & GDTR_MAX)
|
|
|
|
{
|
|
|
|
if (MONTHCAL_CompareSystemTime(date, &range[1]) == 1)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (limits & GDTR_MIN)
|
|
|
|
{
|
|
|
|
if (MONTHCAL_CompareSystemTime(date, &range[0]) == -1)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-22 21:52:08 +02:00
|
|
|
static BOOL
|
2009-09-25 21:41:08 +02:00
|
|
|
DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, const SYSTEMTIME *systime)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2014-01-29 22:26:05 +01:00
|
|
|
if (!systime) return FALSE;
|
1999-07-31 13:12:45 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
TRACE("%04d/%02d/%02d %02d:%02d:%02d\n",
|
2009-09-25 21:41:08 +02:00
|
|
|
systime->wYear, systime->wMonth, systime->wDay,
|
|
|
|
systime->wHour, systime->wMinute, systime->wSecond);
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
if (flag == GDT_VALID) {
|
2012-12-15 15:43:16 +01:00
|
|
|
if (systime->wYear == 0 ||
|
|
|
|
systime->wMonth < 1 || systime->wMonth > 12 ||
|
|
|
|
systime->wDay < 1 ||
|
|
|
|
systime->wDay > MONTHCAL_MonthLength(systime->wMonth, systime->wYear) ||
|
|
|
|
systime->wHour > 23 ||
|
|
|
|
systime->wMinute > 59 ||
|
|
|
|
systime->wSecond > 59 ||
|
|
|
|
systime->wMilliseconds > 999
|
|
|
|
)
|
|
|
|
return FALSE;
|
2007-03-15 22:26:59 +01:00
|
|
|
|
2012-03-08 12:34:13 +01:00
|
|
|
/* Windows returns true if the date is valid but outside the limits set */
|
2014-03-15 13:05:35 +01:00
|
|
|
if (!DATETIME_IsDateInValidRange(infoPtr, systime))
|
2012-03-08 12:34:13 +01:00
|
|
|
return TRUE;
|
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
infoPtr->dateValid = TRUE;
|
2009-09-25 21:41:08 +02:00
|
|
|
infoPtr->date = *systime;
|
2009-10-01 01:11:00 +02:00
|
|
|
/* always store a valid day of week */
|
2009-10-11 02:28:09 +02:00
|
|
|
MONTHCAL_CalculateDayOfWeek(&infoPtr->date, TRUE);
|
2009-10-01 01:11:00 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
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
|
2009-10-01 01:11:00 +02:00
|
|
|
return FALSE;
|
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;
|
2008-02-22 22:32:47 +01:00
|
|
|
BOOL inside_literal = FALSE; /* inside '...' */
|
2004-10-22 21:52:08 +02:00
|
|
|
int *nrFields = &infoPtr->nrFields;
|
|
|
|
|
|
|
|
*nrFields = 0;
|
|
|
|
infoPtr->fieldspec[*nrFields] = 0;
|
2019-05-29 08:44:58 +02:00
|
|
|
len = lstrlenW(allowedformatchars);
|
2004-10-22 21:52:08 +02:00
|
|
|
k = 0;
|
|
|
|
|
|
|
|
for (i = 0; formattxt[i]; i++) {
|
|
|
|
TRACE ("\n%d %c:", i, formattxt[i]);
|
2008-02-22 22:32:47 +01:00
|
|
|
if (!inside_literal) {
|
|
|
|
for (j = 0; j < len; j++) {
|
|
|
|
if (allowedformatchars[j]==formattxt[i]) {
|
|
|
|
TRACE ("%c[%d,%x]", allowedformatchars[j], *nrFields, infoPtr->fieldspec[*nrFields]);
|
|
|
|
if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
|
|
|
|
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (infoPtr->fieldspec[*nrFields] >> 4 != j) {
|
|
|
|
(*nrFields)++;
|
|
|
|
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((infoPtr->fieldspec[*nrFields] & 0x0f) == maxrepetition[j]) {
|
|
|
|
(*nrFields)++;
|
|
|
|
infoPtr->fieldspec[*nrFields] = (j<<4) + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
infoPtr->fieldspec[*nrFields]++;
|
|
|
|
break;
|
|
|
|
} /* if allowedformatchar */
|
|
|
|
} /* for j */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
j = len;
|
|
|
|
|
|
|
|
if (formattxt[i] == '\'')
|
|
|
|
{
|
|
|
|
inside_literal = !inside_literal;
|
|
|
|
continue;
|
|
|
|
}
|
2004-10-22 21:52:08 +02:00
|
|
|
|
|
|
|
/* 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
|
2011-02-25 09:38:28 +01:00
|
|
|
DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR format)
|
2000-02-03 01:48:39 +01:00
|
|
|
{
|
2011-02-25 09:38:28 +01:00
|
|
|
WCHAR format_buf[80];
|
|
|
|
|
|
|
|
if (!format) {
|
2004-10-22 21:52:08 +02:00
|
|
|
DWORD format_item;
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2018-03-19 09:16:24 +01:00
|
|
|
if ((infoPtr->dwStyle & DTS_SHORTDATECENTURYFORMAT) == DTS_SHORTDATECENTURYFORMAT)
|
|
|
|
format_item = LOCALE_SSHORTDATE;
|
|
|
|
else if ((infoPtr->dwStyle & DTS_LONGDATEFORMAT) == DTS_LONGDATEFORMAT)
|
|
|
|
format_item = LOCALE_SLONGDATE;
|
|
|
|
else if ((infoPtr->dwStyle & DTS_TIMEFORMAT) == DTS_TIMEFORMAT)
|
|
|
|
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;
|
2018-02-26 23:29:13 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, format_item, format_buf, ARRAY_SIZE(format_buf));
|
2011-02-25 09:38:28 +01:00
|
|
|
format = format_buf;
|
2004-10-22 21:52:08 +02:00
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2011-02-25 09:38:28 +01:00
|
|
|
DATETIME_UseFormat (infoPtr, format);
|
2005-04-16 12:48:02 +02:00
|
|
|
InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2011-02-25 09:38:28 +01:00
|
|
|
return TRUE;
|
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:
|
2018-02-26 23:29:13 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SMONTHNAME1+date.wMonth -1, buffer, ARRAY_SIZE(buffer));
|
2004-10-22 21:52:08 +02:00
|
|
|
wsprintfW (result, fmt__3sW, buffer);
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case FULLMONTH:
|
2010-03-13 20:43:30 +01:00
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SMONTHNAME1+date.wMonth -1,
|
2004-10-22 21:52:08 +02:00
|
|
|
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;
|
2012-03-08 12:34:19 +01:00
|
|
|
SYSTEMTIME range[2];
|
|
|
|
DWORD limits;
|
|
|
|
BOOL min;
|
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:
|
2012-03-08 12:34:19 +01:00
|
|
|
if (delta == INT_MIN)
|
|
|
|
date->wYear = 1752;
|
|
|
|
else if (delta == INT_MAX)
|
|
|
|
date->wYear = 9999;
|
|
|
|
else
|
|
|
|
date->wYear = max(min(date->wYear + delta, 9999), 1752);
|
|
|
|
|
2011-03-31 21:41:00 +02:00
|
|
|
if (date->wDay > MONTHCAL_MonthLength(date->wMonth, date->wYear))
|
|
|
|
/* This can happen when moving away from a leap year. */
|
|
|
|
date->wDay = MONTHCAL_MonthLength(date->wMonth, date->wYear);
|
2009-10-11 15:05:36 +02:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
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);
|
2009-10-11 15:05:36 +02:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
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));
|
2009-10-11 15:05:36 +02:00
|
|
|
MONTHCAL_CalculateDayOfWeek(date, TRUE);
|
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
|
|
|
|
2012-03-08 12:34:19 +01:00
|
|
|
/* Ensure time is within bounds */
|
2012-12-05 23:42:28 +01:00
|
|
|
limits = SendMessageW (infoPtr->hMonthCal, MCM_GETRANGE, 0, (LPARAM)range);
|
2012-08-08 21:00:22 +02:00
|
|
|
min = delta < 0;
|
2012-03-08 12:34:19 +01:00
|
|
|
|
|
|
|
if (limits & (min ? GDTR_MIN : GDTR_MAX))
|
|
|
|
{
|
|
|
|
int i = (min ? 0 : 1);
|
|
|
|
|
|
|
|
if (MONTHCAL_CompareSystemTime(date, &range[i]) == (min ? -1 : 1))
|
|
|
|
{
|
|
|
|
date->wYear = range[i].wYear;
|
|
|
|
date->wMonth = range[i].wMonth;
|
|
|
|
date->wDayOfWeek = range[i].wDayOfWeek;
|
|
|
|
date->wDay = range[i].wDay;
|
|
|
|
date->wHour = range[i].wHour;
|
|
|
|
date->wMinute = range[i].wMinute;
|
|
|
|
date->wSecond = range[i].wSecond;
|
|
|
|
date->wMilliseconds = range[i].wMilliseconds;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2018-03-26 12:09:19 +02:00
|
|
|
static int DATETIME_GetFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count)
|
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 };
|
|
|
|
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;
|
|
|
|
|
2018-03-26 12:09:19 +02:00
|
|
|
if (!infoPtr->fieldspec) return 0;
|
2005-04-14 13:31:17 +02:00
|
|
|
|
|
|
|
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 THREECHARMONTH:
|
|
|
|
case FULLMONTH:
|
2009-10-08 23:19:33 +02:00
|
|
|
case THREECHARDAY:
|
|
|
|
case FULLDAY:
|
|
|
|
{
|
|
|
|
static const WCHAR fld_day[] = {'W','e','d','n','e','s','d','a','y',0};
|
|
|
|
static const WCHAR fld_abbrday[] = {'W','e','d',0};
|
|
|
|
static const WCHAR fld_mon[] = {'S','e','p','t','e','m','b','e','r',0};
|
|
|
|
static const WCHAR fld_abbrmon[] = {'D','e','c',0};
|
|
|
|
|
|
|
|
const WCHAR *fall;
|
|
|
|
LCTYPE lctype;
|
|
|
|
INT i, max_count;
|
|
|
|
LONG cx;
|
|
|
|
|
|
|
|
/* choose locale data type and fallback string */
|
|
|
|
switch (spec) {
|
|
|
|
case THREECHARDAY:
|
|
|
|
fall = fld_abbrday;
|
|
|
|
lctype = LOCALE_SABBREVDAYNAME1;
|
|
|
|
max_count = 7;
|
|
|
|
break;
|
|
|
|
case FULLDAY:
|
|
|
|
fall = fld_day;
|
|
|
|
lctype = LOCALE_SDAYNAME1;
|
|
|
|
max_count = 7;
|
|
|
|
break;
|
|
|
|
case THREECHARMONTH:
|
|
|
|
fall = fld_abbrmon;
|
|
|
|
lctype = LOCALE_SABBREVMONTHNAME1;
|
|
|
|
max_count = 12;
|
|
|
|
break;
|
2010-05-04 15:05:13 +02:00
|
|
|
default: /* FULLMONTH */
|
2009-10-08 23:19:33 +02:00
|
|
|
fall = fld_mon;
|
|
|
|
lctype = LOCALE_SMONTHNAME1;
|
|
|
|
max_count = 12;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cx = 0;
|
|
|
|
for (i = 0; i < max_count; i++)
|
|
|
|
{
|
|
|
|
if(GetLocaleInfoW(LOCALE_USER_DEFAULT, lctype + i,
|
2018-03-19 09:17:10 +01:00
|
|
|
buffer, ARRAY_SIZE(buffer)))
|
2009-10-08 23:19:33 +02:00
|
|
|
{
|
|
|
|
GetTextExtentPoint32W(hdc, buffer, lstrlenW(buffer), &size);
|
|
|
|
if (size.cx > cx) cx = size.cx;
|
|
|
|
}
|
|
|
|
else /* locale independent fallback on failure */
|
|
|
|
{
|
|
|
|
GetTextExtentPoint32W(hdc, fall, lstrlenW(fall), &size);
|
|
|
|
cx = size.cx;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-03-26 12:09:19 +02:00
|
|
|
return cx;
|
2009-10-08 23:19:33 +02:00
|
|
|
}
|
2005-04-14 13:31:17 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2019-05-29 08:44:58 +02:00
|
|
|
GetTextExtentPoint32W (hdc, bufptr, lstrlenW(bufptr), &size);
|
2018-03-26 12:09:19 +02:00
|
|
|
return size.cx;
|
2005-04-14 13:31:17 +02: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
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (infoPtr->dateValid) {
|
2009-10-08 22:38:38 +02:00
|
|
|
int i, prevright;
|
|
|
|
RECT *field;
|
|
|
|
RECT *rcDraw = &infoPtr->rcDraw;
|
|
|
|
SIZE size;
|
|
|
|
COLORREF oldTextColor;
|
2004-10-26 02:11:31 +02:00
|
|
|
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];
|
|
|
|
|
2018-02-26 23:29:13 +01:00
|
|
|
DATETIME_ReturnTxt (infoPtr, 0, txt, ARRAY_SIZE(txt));
|
2019-05-29 08:44:58 +02:00
|
|
|
GetTextExtentPoint32W (hdc, txt, lstrlenW(txt), &size);
|
2004-10-26 02:11:31 +02:00
|
|
|
rcDraw->bottom = size.cy + 2;
|
|
|
|
|
2009-10-08 22:38:38 +02:00
|
|
|
prevright = infoPtr->checkbox.right = ((infoPtr->dwStyle & DTS_SHOWNONE) ? 18 : 2);
|
2004-10-26 02:11:31 +02:00
|
|
|
|
|
|
|
for (i = 0; i < infoPtr->nrFields; i++) {
|
2018-02-26 23:29:13 +01:00
|
|
|
DATETIME_ReturnTxt (infoPtr, i, txt, ARRAY_SIZE(txt));
|
2019-05-29 08:44:58 +02:00
|
|
|
GetTextExtentPoint32W (hdc, txt, lstrlenW(txt), &size);
|
2004-10-26 02:11:31 +02:00
|
|
|
field = &infoPtr->fieldRect[i];
|
2009-10-08 22:38:38 +02:00
|
|
|
field->left = prevright;
|
2018-03-26 12:09:19 +02:00
|
|
|
field->right = prevright + DATETIME_GetFieldWidth (infoPtr, hdc, i);
|
2009-10-08 22:38:38 +02:00
|
|
|
field->top = rcDraw->top;
|
2004-10-26 02:11:31 +02:00
|
|
|
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)) {
|
2009-10-08 22:38:38 +02:00
|
|
|
RECT selection;
|
|
|
|
|
2009-10-08 22:00:49 +02:00
|
|
|
/* fill if focused */
|
2004-12-17 19:50:11 +01:00
|
|
|
HBRUSH hbr = CreateSolidBrush (comctl32_color.clrActiveCaption);
|
2009-10-08 22:38:38 +02:00
|
|
|
|
2011-03-09 22:30:54 +01:00
|
|
|
if (infoPtr->nCharsEntered)
|
|
|
|
{
|
|
|
|
memcpy(txt, infoPtr->charsEntered, infoPtr->nCharsEntered * sizeof(WCHAR));
|
|
|
|
txt[infoPtr->nCharsEntered] = 0;
|
2019-05-29 08:44:58 +02:00
|
|
|
GetTextExtentPoint32W (hdc, txt, lstrlenW(txt), &size);
|
2011-03-09 22:30:54 +01:00
|
|
|
}
|
|
|
|
|
2016-04-29 15:58:29 +02:00
|
|
|
SetRect(&selection, 0, 0, size.cx, size.cy);
|
2009-10-08 22:38:38 +02:00
|
|
|
/* center rectangle */
|
2009-10-08 23:49:10 +02:00
|
|
|
OffsetRect(&selection, (field->right + field->left - size.cx)/2,
|
|
|
|
(field->bottom - size.cy)/2);
|
2009-10-08 22:38:38 +02:00
|
|
|
|
|
|
|
FillRect(hdc, &selection, hbr);
|
2004-10-26 02:11:31 +02:00
|
|
|
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 */
|
2019-05-29 08:44:58 +02:00
|
|
|
DrawTextW (hdc, txt, lstrlenW(txt), field, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
2004-12-17 19:50:11 +01:00
|
|
|
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)) {
|
2009-10-08 22:38:38 +02:00
|
|
|
DrawFrameControl(hdc, &infoPtr->calbutton, DFC_SCROLL,
|
2004-10-26 02:11:31 +02:00
|
|
|
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
|
|
|
|
2016-11-22 00:38:39 +01:00
|
|
|
TRACE ("%s\n", wine_dbgstr_point(&pt));
|
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
|
|
|
|
2009-10-08 22:00:49 +02:00
|
|
|
for (i = 0; i < infoPtr->nrFields; i++) {
|
2004-10-22 21:52:08 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-11-22 18:04:02 +01:00
|
|
|
/* Returns index of the nearest preceding date field from given,
|
|
|
|
or -1 if none was found */
|
2009-10-08 22:00:49 +02:00
|
|
|
static int DATETIME_GetPrevDateField(const DATETIME_INFO *infoPtr, int i)
|
|
|
|
{
|
|
|
|
for(--i; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (infoPtr->fieldspec[i] & DTHT_DATEFIELD) return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2000-05-30 22:06:54 +02:00
|
|
|
|
2011-03-09 22:30:54 +01:00
|
|
|
static void
|
|
|
|
DATETIME_ApplySelectedField (DATETIME_INFO *infoPtr)
|
|
|
|
{
|
|
|
|
int fieldNum = infoPtr->select & DTHT_DATEFIELD;
|
2014-03-15 13:05:35 +01:00
|
|
|
int i, val = 0;
|
|
|
|
BOOL clamp_day = FALSE;
|
2011-03-09 22:30:54 +01:00
|
|
|
SYSTEMTIME date = infoPtr->date;
|
2012-03-08 12:34:23 +01:00
|
|
|
int oldyear;
|
2011-03-09 22:30:54 +01:00
|
|
|
|
|
|
|
if (infoPtr->select == -1 || infoPtr->nCharsEntered == 0)
|
|
|
|
return;
|
|
|
|
|
2012-03-08 12:34:33 +01:00
|
|
|
if ((infoPtr->fieldspec[fieldNum] == ONELETTERAMPM) ||
|
|
|
|
(infoPtr->fieldspec[fieldNum] == TWOLETTERAMPM))
|
|
|
|
val = infoPtr->charsEntered[0];
|
|
|
|
else {
|
|
|
|
for (i=0; i<infoPtr->nCharsEntered; i++)
|
|
|
|
val = val * 10 + infoPtr->charsEntered[i] - '0';
|
|
|
|
}
|
2011-03-09 22:30:54 +01:00
|
|
|
|
|
|
|
infoPtr->nCharsEntered = 0;
|
|
|
|
|
|
|
|
switch (infoPtr->fieldspec[fieldNum]) {
|
|
|
|
case ONEDIGITYEAR:
|
|
|
|
case TWODIGITYEAR:
|
2012-03-08 12:34:23 +01:00
|
|
|
oldyear = date.wYear;
|
2011-03-09 22:30:54 +01:00
|
|
|
date.wYear = date.wYear - (date.wYear%100) + val;
|
2012-03-08 12:34:23 +01:00
|
|
|
|
|
|
|
if (DATETIME_IsDateInValidRange(infoPtr, &date))
|
2014-03-15 13:05:35 +01:00
|
|
|
clamp_day = TRUE;
|
2012-03-08 12:34:23 +01:00
|
|
|
else
|
|
|
|
date.wYear = oldyear;
|
|
|
|
|
2011-03-09 22:30:54 +01:00
|
|
|
break;
|
|
|
|
case INVALIDFULLYEAR:
|
|
|
|
case FULLYEAR:
|
2012-03-08 12:34:23 +01:00
|
|
|
oldyear = date.wYear;
|
2011-03-09 22:30:54 +01:00
|
|
|
date.wYear = val;
|
2012-03-08 12:34:23 +01:00
|
|
|
|
|
|
|
if (DATETIME_IsDateInValidRange(infoPtr, &date))
|
2014-03-15 13:05:35 +01:00
|
|
|
clamp_day = TRUE;
|
2012-03-08 12:34:23 +01:00
|
|
|
else
|
|
|
|
date.wYear = oldyear;
|
|
|
|
|
2011-03-09 22:30:54 +01:00
|
|
|
break;
|
|
|
|
case ONEDIGITMONTH:
|
|
|
|
case TWODIGITMONTH:
|
|
|
|
date.wMonth = val;
|
2014-03-15 13:05:35 +01:00
|
|
|
clamp_day = TRUE;
|
2011-03-09 22:30:54 +01:00
|
|
|
break;
|
|
|
|
case ONEDIGITDAY:
|
|
|
|
case TWODIGITDAY:
|
|
|
|
date.wDay = val;
|
|
|
|
break;
|
|
|
|
case ONEDIGIT12HOUR:
|
|
|
|
case TWODIGIT12HOUR:
|
2012-03-08 12:34:38 +01:00
|
|
|
if (val >= 24)
|
|
|
|
val -= 20;
|
|
|
|
|
|
|
|
if (val >= 13)
|
|
|
|
date.wHour = val;
|
|
|
|
else if (val != 0) {
|
|
|
|
if (date.wHour >= 12) /* preserve current AM/PM state */
|
|
|
|
date.wHour = (val == 12 ? 12 : val + 12);
|
|
|
|
else
|
|
|
|
date.wHour = (val == 12 ? 0 : val);
|
|
|
|
}
|
|
|
|
break;
|
2011-03-09 22:30:54 +01:00
|
|
|
case ONEDIGIT24HOUR:
|
|
|
|
case TWODIGIT24HOUR:
|
|
|
|
date.wHour = val;
|
|
|
|
break;
|
|
|
|
case ONEDIGITMINUTE:
|
|
|
|
case TWODIGITMINUTE:
|
|
|
|
date.wMinute = val;
|
|
|
|
break;
|
|
|
|
case ONEDIGITSECOND:
|
|
|
|
case TWODIGITSECOND:
|
|
|
|
date.wSecond = val;
|
|
|
|
break;
|
2012-03-08 12:34:33 +01:00
|
|
|
case ONELETTERAMPM:
|
|
|
|
case TWOLETTERAMPM:
|
|
|
|
if (val == 'a' || val == 'A') {
|
|
|
|
if (date.wHour >= 12)
|
|
|
|
date.wHour -= 12;
|
|
|
|
} else if (val == 'p' || val == 'P') {
|
|
|
|
if (date.wHour < 12)
|
|
|
|
date.wHour += 12;
|
|
|
|
}
|
|
|
|
break;
|
2011-03-09 22:30:54 +01:00
|
|
|
}
|
|
|
|
|
2011-03-31 21:04:15 +02:00
|
|
|
if (clamp_day && date.wDay > MONTHCAL_MonthLength(date.wMonth, date.wYear))
|
|
|
|
date.wDay = MONTHCAL_MonthLength(date.wMonth, date.wYear);
|
|
|
|
|
2011-03-09 22:30:54 +01:00
|
|
|
if (DATETIME_SetSystemTime(infoPtr, GDT_VALID, &date))
|
|
|
|
DATETIME_SendDateTimeChangeNotify (infoPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
DATETIME_SetSelectedField (DATETIME_INFO *infoPtr, int select)
|
|
|
|
{
|
|
|
|
DATETIME_ApplySelectedField(infoPtr);
|
|
|
|
|
|
|
|
infoPtr->select = select;
|
|
|
|
infoPtr->nCharsEntered = 0;
|
|
|
|
}
|
|
|
|
|
1999-07-31 13:12:45 +02:00
|
|
|
static LRESULT
|
2008-07-21 21:11:56 +02:00
|
|
|
DATETIME_LButtonDown (DATETIME_INFO *infoPtr, INT x, INT y)
|
1999-07-31 13:12:45 +02:00
|
|
|
{
|
2004-11-24 19:28:31 +01:00
|
|
|
POINT pt;
|
2010-04-23 20:49:16 +02:00
|
|
|
int new;
|
2004-11-24 19:28:31 +01:00
|
|
|
|
|
|
|
pt.x = x;
|
|
|
|
pt.y = y;
|
|
|
|
new = DATETIME_HitTest (infoPtr, pt);
|
2004-10-26 02:11:31 +02:00
|
|
|
|
2004-12-20 18:00:46 +01:00
|
|
|
SetFocus(infoPtr->hwndSelf);
|
2004-10-26 02:11:31 +02:00
|
|
|
|
2009-10-08 22:00:49 +02:00
|
|
|
if (!(new & DTHT_NODATEMASK) || (new == DTHT_NONE))
|
|
|
|
{
|
|
|
|
if (new == DTHT_NONE)
|
|
|
|
new = infoPtr->nrFields - 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* hitting string part moves selection to next date field to left */
|
|
|
|
if (infoPtr->fieldspec[new] & DT_STRING)
|
|
|
|
{
|
|
|
|
new = DATETIME_GetPrevDateField(infoPtr, new);
|
|
|
|
if (new == -1) return 0;
|
|
|
|
}
|
|
|
|
/* never select full day of week */
|
|
|
|
if (infoPtr->fieldspec[new] == FULLDAY) return 0;
|
|
|
|
}
|
|
|
|
}
|
2011-03-09 22:30:54 +01:00
|
|
|
|
|
|
|
DATETIME_SetSelectedField(infoPtr, new);
|
2009-10-08 22:00:49 +02:00
|
|
|
|
2004-10-26 02:11:31 +02:00
|
|
|
if (infoPtr->select == DTHT_MCPOPUP) {
|
2004-12-20 18:00:46 +01:00
|
|
|
RECT rcMonthCal;
|
2010-10-05 14:03:33 +02:00
|
|
|
POINT pos;
|
2004-12-20 18:00:46 +01:00
|
|
|
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)
|
2010-10-05 14:03:33 +02:00
|
|
|
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 */
|
2010-10-05 14:03:33 +02:00
|
|
|
pos.x = infoPtr->rcDraw.left;
|
2004-10-26 02:11:31 +02:00
|
|
|
|
2010-10-05 14:03:33 +02:00
|
|
|
pos.y = infoPtr->rcClient.bottom;
|
|
|
|
OffsetRect( &rcMonthCal, pos.x, pos.y );
|
|
|
|
MapWindowPoints( infoPtr->hwndSelf, 0, (POINT *)&rcMonthCal, 2 );
|
|
|
|
SetWindowPos(infoPtr->hMonthCal, 0, rcMonthCal.left, rcMonthCal.top,
|
|
|
|
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);
|
2009-10-11 16:12:46 +02:00
|
|
|
infoPtr->bDropdownEnabled = FALSE;
|
|
|
|
DATETIME_SendSimpleNotify (infoPtr, DTN_CLOSEUP);
|
2004-10-26 02:11:31 +02:00
|
|
|
} 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
|
|
|
|
2009-10-11 16:12:46 +02:00
|
|
|
if (infoPtr->bDropdownEnabled) {
|
2007-11-01 23:34:35 +01:00
|
|
|
ShowWindow(infoPtr->hMonthCal, SW_SHOW);
|
2009-10-11 16:12:46 +02:00
|
|
|
DATETIME_SendSimpleNotify (infoPtr, DTN_DROPDOWN);
|
|
|
|
}
|
2007-11-01 23:34:35 +01:00
|
|
|
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 ());
|
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
|
2008-07-21 21:11:56 +02:00
|
|
|
DATETIME_LButtonUp (DATETIME_INFO *infoPtr)
|
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
|
2009-10-11 16:43:52 +02:00
|
|
|
DATETIME_Notify (DATETIME_INFO *infoPtr, const NMHDR *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);
|
2009-10-11 16:12:46 +02:00
|
|
|
DATETIME_SendSimpleNotify(infoPtr, DTN_CLOSEUP);
|
2004-10-22 21:52:08 +02:00
|
|
|
}
|
2005-04-14 13:31:17 +02:00
|
|
|
if ((lpnmh->hwndFrom == infoPtr->hUpdown) && (lpnmh->code == UDN_DELTAPOS)) {
|
2010-03-25 19:51:05 +01:00
|
|
|
const NM_UPDOWN *lpnmud = (const NM_UPDOWN*)lpnmh;
|
2005-04-14 13:31:17 +02:00
|
|
|
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
|
2008-07-21 21:11:56 +02:00
|
|
|
DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode)
|
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;
|
2011-03-09 22:30:54 +01:00
|
|
|
int new;
|
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:
|
2011-03-09 22:30:54 +01:00
|
|
|
infoPtr->nCharsEntered = 0;
|
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:
|
2011-03-09 22:30:54 +01:00
|
|
|
infoPtr->nCharsEntered = 0;
|
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:
|
2011-03-09 22:30:54 +01:00
|
|
|
infoPtr->nCharsEntered = 0;
|
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:
|
2011-03-09 22:30:54 +01:00
|
|
|
infoPtr->nCharsEntered = 0;
|
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:
|
2011-03-09 22:30:54 +01:00
|
|
|
new = infoPtr->select;
|
2004-10-26 02:11:31 +02:00
|
|
|
do {
|
2011-03-09 22:30:54 +01:00
|
|
|
if (new == 0) {
|
|
|
|
new = new - 1;
|
2004-10-26 02:11:31 +02:00
|
|
|
wrap++;
|
|
|
|
} else {
|
2011-03-09 22:30:54 +01:00
|
|
|
new--;
|
2000-02-03 01:48:39 +01:00
|
|
|
}
|
2011-03-09 22:30:54 +01:00
|
|
|
} while ((infoPtr->fieldspec[new] & DT_STRING) && (wrap<2));
|
|
|
|
if (new != infoPtr->select)
|
|
|
|
DATETIME_SetSelectedField(infoPtr, new);
|
2004-10-26 02:11:31 +02:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case VK_RIGHT:
|
2011-03-09 22:30:54 +01:00
|
|
|
new = infoPtr->select;
|
2004-10-26 02:11:31 +02:00
|
|
|
do {
|
2011-03-09 22:30:54 +01:00
|
|
|
new++;
|
|
|
|
if (new==infoPtr->nrFields) {
|
|
|
|
new = 0;
|
2004-10-26 02:11:31 +02:00
|
|
|
wrap++;
|
|
|
|
}
|
2011-03-09 22:30:54 +01:00
|
|
|
} while ((infoPtr->fieldspec[new] & DT_STRING) && (wrap<2));
|
|
|
|
if (new != infoPtr->select)
|
|
|
|
DATETIME_SetSelectedField(infoPtr, new);
|
2004-10-26 02:11:31 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-25 23:03:36 +01:00
|
|
|
static LRESULT
|
2008-12-27 08:51:39 +01:00
|
|
|
DATETIME_Char (DATETIME_INFO *infoPtr, WPARAM vkCode)
|
2008-11-25 23:03:36 +01:00
|
|
|
{
|
2012-03-08 12:34:33 +01:00
|
|
|
int fieldNum, fieldSpec;
|
2008-11-25 23:03:36 +01:00
|
|
|
|
2012-03-08 12:34:33 +01:00
|
|
|
fieldNum = infoPtr->select & DTHT_DATEFIELD;
|
|
|
|
fieldSpec = infoPtr->fieldspec[fieldNum];
|
|
|
|
|
|
|
|
if (fieldSpec == ONELETTERAMPM || fieldSpec == TWOLETTERAMPM) {
|
|
|
|
infoPtr->charsEntered[0] = vkCode;
|
|
|
|
infoPtr->nCharsEntered = 1;
|
|
|
|
|
|
|
|
DATETIME_ApplySelectedField(infoPtr);
|
|
|
|
} else if (vkCode >= '0' && vkCode <= '9') {
|
2011-03-09 22:30:54 +01:00
|
|
|
int maxChars;
|
|
|
|
|
|
|
|
infoPtr->charsEntered[infoPtr->nCharsEntered++] = vkCode;
|
|
|
|
|
|
|
|
if (fieldSpec == INVALIDFULLYEAR || fieldSpec == FULLYEAR)
|
|
|
|
maxChars = 4;
|
|
|
|
else
|
|
|
|
maxChars = 2;
|
|
|
|
|
2012-03-08 12:34:38 +01:00
|
|
|
if ((fieldSpec == ONEDIGIT12HOUR ||
|
|
|
|
fieldSpec == TWODIGIT12HOUR ||
|
|
|
|
fieldSpec == ONEDIGIT24HOUR ||
|
|
|
|
fieldSpec == TWODIGIT24HOUR) &&
|
|
|
|
(infoPtr->nCharsEntered == 1))
|
|
|
|
{
|
|
|
|
if (vkCode >= '3')
|
|
|
|
maxChars = 1;
|
|
|
|
}
|
|
|
|
|
2011-03-09 22:30:54 +01:00
|
|
|
if (maxChars == infoPtr->nCharsEntered)
|
|
|
|
DATETIME_ApplySelectedField(infoPtr);
|
2008-11-25 23:03:36 +01:00
|
|
|
}
|
2012-03-08 12:34:33 +01:00
|
|
|
|
2008-11-25 23:03:36 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2011-03-09 22:30:54 +01:00
|
|
|
DATETIME_SetSelectedField (infoPtr, -1);
|
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, 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 */
|
2007-12-31 17:29:57 +01:00
|
|
|
if (infoPtr->hMonthCal && (lostFocus == infoPtr->hMonthCal) &&
|
2007-11-01 23:34:35 +01:00
|
|
|
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;
|
|
|
|
|
2009-10-11 16:12:46 +02:00
|
|
|
dtdtc.dwFlags = infoPtr->dateValid ? GDT_VALID : GDT_NONE;
|
2004-10-22 21:52:08 +02:00
|
|
|
|
2009-09-25 21:41:08 +02:00
|
|
|
dtdtc.st = infoPtr->date;
|
2004-10-22 21:52:08 +02:00
|
|
|
return (BOOL) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
|
2007-12-29 16:37:34 +01:00
|
|
|
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,
|
2007-12-29 16:37:34 +01:00
|
|
|
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
|
2008-07-21 21:11:56 +02:00
|
|
|
DATETIME_Size (DATETIME_INFO *infoPtr, 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
|
|
|
|
2009-10-11 16:23:16 +02:00
|
|
|
static LRESULT
|
|
|
|
DATETIME_StyleChanging(DATETIME_INFO *infoPtr, WPARAM wStyleType, STYLESTRUCT *lpss)
|
|
|
|
{
|
|
|
|
TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
|
|
|
|
wStyleType, lpss->styleOld, lpss->styleNew);
|
|
|
|
|
|
|
|
/* block DTS_SHOWNONE change */
|
|
|
|
if ((lpss->styleNew ^ lpss->styleOld) & DTS_SHOWNONE)
|
|
|
|
{
|
|
|
|
if (lpss->styleOld & DTS_SHOWNONE)
|
|
|
|
lpss->styleNew |= DTS_SHOWNONE;
|
|
|
|
else
|
|
|
|
lpss->styleNew &= ~DTS_SHOWNONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
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) ) {
|
2009-10-11 16:43:52 +02:00
|
|
|
infoPtr->hwndCheckbut = CreateWindowExW (0, WC_BUTTONW, 0, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
|
2004-10-26 02:11:31 +02:00
|
|
|
2, 2, 13, 13, infoPtr->hwndSelf, 0,
|
|
|
|
(HINSTANCE)GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_HINSTANCE), 0);
|
2012-03-08 12:34:28 +01:00
|
|
|
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, infoPtr->dateValid ? 1 : 0, 0);
|
2004-10-26 02:11:31 +02:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2018-03-19 09:17:55 +01:00
|
|
|
static BOOL DATETIME_GetIdealSize(DATETIME_INFO *infoPtr, SIZE *size)
|
|
|
|
{
|
|
|
|
SIZE field_size;
|
|
|
|
RECT rect;
|
|
|
|
WCHAR txt[80];
|
|
|
|
HDC hdc;
|
|
|
|
HFONT oldFont;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
size->cx = size->cy = 0;
|
|
|
|
|
|
|
|
hdc = GetDC(infoPtr->hwndSelf);
|
|
|
|
oldFont = SelectObject(hdc, infoPtr->hFont);
|
|
|
|
|
|
|
|
/* Get text font height */
|
|
|
|
DATETIME_ReturnTxt(infoPtr, 0, txt, ARRAY_SIZE(txt));
|
2019-05-29 08:44:58 +02:00
|
|
|
GetTextExtentPoint32W(hdc, txt, lstrlenW(txt), &field_size);
|
2018-03-19 09:17:55 +01:00
|
|
|
size->cy = field_size.cy;
|
|
|
|
|
|
|
|
/* Get text font width */
|
|
|
|
for (i = 0; i < infoPtr->nrFields; i++)
|
|
|
|
{
|
2018-03-26 12:09:19 +02:00
|
|
|
size->cx += DATETIME_GetFieldWidth(infoPtr, hdc, i);
|
2018-03-19 09:17:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SelectObject(hdc, oldFont);
|
|
|
|
ReleaseDC(infoPtr->hwndSelf, hdc);
|
|
|
|
|
|
|
|
if (infoPtr->dwStyle & DTS_UPDOWN)
|
|
|
|
{
|
|
|
|
GetWindowRect(infoPtr->hUpdown, &rect);
|
|
|
|
size->cx += rect.right - rect.left;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size->cx += infoPtr->calbutton.right - infoPtr->calbutton.left;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (infoPtr->dwStyle & DTS_SHOWNONE)
|
|
|
|
{
|
|
|
|
size->cx += infoPtr->checkbox.right - infoPtr->checkbox.left;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add space between controls for them not to get too close */
|
|
|
|
size->cx += 12;
|
|
|
|
size->cy += 4;
|
|
|
|
|
|
|
|
TRACE("cx=%d cy=%d\n", size->cx, size->cy);
|
|
|
|
return TRUE;
|
|
|
|
}
|
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
|
|
|
{
|
2008-10-23 23:52:10 +02:00
|
|
|
DATETIME_INFO *infoPtr = Alloc (sizeof(DATETIME_INFO));
|
2004-10-26 02:11:31 +02:00
|
|
|
STYLESTRUCT ss = { 0, lpcs->style };
|
|
|
|
|
|
|
|
if (!infoPtr) return -1;
|
|
|
|
|
|
|
|
infoPtr->hwndSelf = hwnd;
|
|
|
|
infoPtr->dwStyle = lpcs->style;
|
|
|
|
|
|
|
|
infoPtr->nrFieldsAllocated = 32;
|
2008-10-23 23:52:10 +02:00
|
|
|
infoPtr->fieldspec = Alloc (infoPtr->nrFieldsAllocated * sizeof(int));
|
|
|
|
infoPtr->fieldRect = Alloc (infoPtr->nrFieldsAllocated * sizeof(RECT));
|
|
|
|
infoPtr->buflen = Alloc (infoPtr->nrFieldsAllocated * sizeof(int));
|
2004-10-26 02:11:31 +02:00
|
|
|
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 */
|
2009-10-01 19:35:44 +02:00
|
|
|
infoPtr->hMonthCal = CreateWindowExW (0, MONTHCAL_CLASSW, 0, WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS,
|
2004-10-26 02:11:31 +02:00
|
|
|
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 */
|
2009-12-05 19:42:19 +01:00
|
|
|
Free (infoPtr->buflen);
|
|
|
|
Free (infoPtr->fieldRect);
|
|
|
|
Free (infoPtr->fieldspec);
|
2003-09-22 23:32:33 +02:00
|
|
|
Free (infoPtr);
|
1998-11-08 12:30:27 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-02 09:20:05 +01:00
|
|
|
static INT
|
2010-07-31 23:53:58 +02:00
|
|
|
DATETIME_GetText (const DATETIME_INFO *infoPtr, INT count, LPWSTR dst)
|
2009-12-02 09:20:05 +01:00
|
|
|
{
|
|
|
|
WCHAR buf[80];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!dst || (count <= 0)) return 0;
|
|
|
|
|
|
|
|
dst[0] = 0;
|
|
|
|
for (i = 0; i < infoPtr->nrFields; i++)
|
|
|
|
{
|
2018-02-26 23:29:13 +01:00
|
|
|
DATETIME_ReturnTxt(infoPtr, i, buf, ARRAY_SIZE(buf));
|
2019-05-29 08:44:58 +02:00
|
|
|
if ((lstrlenW(dst) + lstrlenW(buf)) < count)
|
|
|
|
lstrcatW(dst, buf);
|
2009-12-02 09:20:05 +01:00
|
|
|
else break;
|
|
|
|
}
|
2019-05-29 08:44:58 +02:00
|
|
|
return lstrlenW(dst);
|
2009-12-02 09:20:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
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:
|
2016-03-14 18:19:26 +01:00
|
|
|
return SendMessageW (infoPtr->hMonthCal, MCM_GETRANGE, wParam, lParam);
|
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
|
|
|
|
2018-03-19 09:17:55 +01:00
|
|
|
case DTM_GETIDEALSIZE:
|
|
|
|
return DATETIME_GetIdealSize(infoPtr, (SIZE *)lParam);
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
case WM_NOTIFY:
|
2008-07-21 21:11:56 +02:00
|
|
|
return DATETIME_Notify (infoPtr, (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:
|
2008-07-21 21:11:56 +02:00
|
|
|
return DATETIME_KeyDown (infoPtr, wParam);
|
2000-02-03 01:48:39 +01:00
|
|
|
|
2008-11-25 23:03:36 +01:00
|
|
|
case WM_CHAR:
|
2008-12-27 08:51:39 +01:00
|
|
|
return DATETIME_Char (infoPtr, wParam);
|
2008-11-25 23:03:36 +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:
|
2008-07-21 21:11:56 +02:00
|
|
|
return DATETIME_Size (infoPtr, (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:
|
2008-07-21 21:11:56 +02:00
|
|
|
return DATETIME_LButtonDown (infoPtr, (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:
|
2008-07-21 21:11:56 +02:00
|
|
|
return DATETIME_LButtonUp (infoPtr);
|
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
|
|
|
|
2009-10-11 16:23:16 +02:00
|
|
|
case WM_STYLECHANGING:
|
|
|
|
return DATETIME_StyleChanging(infoPtr, wParam, (LPSTYLESTRUCT)lParam);
|
|
|
|
|
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;
|
|
|
|
|
2009-12-02 09:20:05 +01:00
|
|
|
case WM_GETTEXT:
|
|
|
|
return (LRESULT) DATETIME_GetText(infoPtr, wParam, (LPWSTR)lParam);
|
|
|
|
|
2009-10-08 20:05:13 +02:00
|
|
|
case WM_SETTEXT:
|
|
|
|
return CB_ERR;
|
|
|
|
|
2000-02-03 01:48:39 +01:00
|
|
|
default:
|
2008-07-22 00:18:09 +02:00
|
|
|
if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
|
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
|
|
|
}
|