2 * Date and time picker control
4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 1999, 2000 Alex Priem <alexp@sci.kun.nl>
6 * Copyright 2000 Chris Morgan <cmorgan@wpi.edu>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * This code was audited for completeness against the documented features
25 * of Comctl32.dll version 6.0 on Oct. 20, 2004, by Dimitrie O. Paun.
27 * Unless otherwise noted, we believe this code to be complete, as per
28 * the specification mentioned above.
29 * If you discover missing features, or bugs, please note them below.
33 * -- DTS_SHORTDATECENTURYFORMAT
55 #include "wine/debug.h"
56 #include "wine/unicode.h"
58 WINE_DEFAULT_DEBUG_CHANNEL(datetime
);
70 RECT rcClient
; /* rect around the edge of the window */
71 RECT rcDraw
; /* rect inside of the border */
72 RECT checkbox
; /* checkbox allowing the control to be enabled/disabled */
73 RECT calbutton
; /* button that toggles the dropdown of the monthcal control */
74 BOOL bCalDepressed
; /* TRUE = cal button is depressed */
77 int nrFieldsAllocated
;
86 } DATETIME_INFO
, *LPDATETIME_INFO
;
89 extern int MONTHCAL_MonthLength(int month
, int year
);
91 /* this list of defines is closely related to `allowedformatchars' defined
92 * in datetime.c; the high nibble indicates the `base type' of the format
94 * Do not change without first reading DATETIME_UseFormat.
98 #define DT_END_FORMAT 0
99 #define ONEDIGITDAY 0x01
100 #define TWODIGITDAY 0x02
101 #define THREECHARDAY 0x03
103 #define ONEDIGIT12HOUR 0x11
104 #define TWODIGIT12HOUR 0x12
105 #define ONEDIGIT24HOUR 0x21
106 #define TWODIGIT24HOUR 0x22
107 #define ONEDIGITMINUTE 0x31
108 #define TWODIGITMINUTE 0x32
109 #define ONEDIGITMONTH 0x41
110 #define TWODIGITMONTH 0x42
111 #define THREECHARMONTH 0x43
112 #define FULLMONTH 0x44
113 #define ONEDIGITSECOND 0x51
114 #define TWODIGITSECOND 0x52
115 #define ONELETTERAMPM 0x61
116 #define TWOLETTERAMPM 0x62
117 #define ONEDIGITYEAR 0x71
118 #define TWODIGITYEAR 0x72
119 #define INVALIDFULLYEAR 0x73 /* FIXME - yyy is not valid - we'll treat it as yyyy */
120 #define FULLYEAR 0x74
121 #define FORMATCALLBACK 0x81 /* -> maximum of 0x80 callbacks possible */
122 #define FORMATCALLMASK 0x80
123 #define DT_STRING 0x0100
125 #define DTHT_DATEFIELD 0xff /* for hit-testing */
128 #define DTHT_CHECKBOX 0x200 /* these should end at '00' , to make */
129 #define DTHT_MCPOPUP 0x300 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
130 #define DTHT_GOTFOCUS 0x400 /* tests for date-fields */
132 static BOOL
DATETIME_SendSimpleNotify (DATETIME_INFO
*infoPtr
, UINT code
);
133 static BOOL
DATETIME_SendDateTimeChangeNotify (DATETIME_INFO
*infoPtr
);
134 extern void MONTHCAL_CopyTime(const SYSTEMTIME
*from
, SYSTEMTIME
*to
);
135 static const WCHAR allowedformatchars
[] = {'d', 'h', 'H', 'm', 'M', 's', 't', 'y', 'X', '\'', 0};
136 static const int maxrepetition
[] = {4,2,2,2,4,2,2,4,-1,-1};
140 DATETIME_GetSystemTime (DATETIME_INFO
*infoPtr
, SYSTEMTIME
*lprgSysTimeArray
)
142 if (!lprgSysTimeArray
) return GDT_NONE
;
144 if ((infoPtr
->dwStyle
& DTS_SHOWNONE
) &&
145 (SendMessageW (infoPtr
->hwndCheckbut
, BM_GETCHECK
, 0, 0) == BST_UNCHECKED
))
148 MONTHCAL_CopyTime (&infoPtr
->date
, lprgSysTimeArray
);
155 DATETIME_SetSystemTime (DATETIME_INFO
*infoPtr
, DWORD flag
, SYSTEMTIME
*lprgSysTimeArray
)
157 if (!lprgSysTimeArray
) return 0;
159 TRACE("%04d/%02d/%02d %02d:%02d:%02d\n",
160 lprgSysTimeArray
->wYear
, lprgSysTimeArray
->wMonth
, lprgSysTimeArray
->wDay
,
161 lprgSysTimeArray
->wHour
, lprgSysTimeArray
->wMinute
, lprgSysTimeArray
->wSecond
);
163 if (flag
== GDT_VALID
) {
164 infoPtr
->dateValid
= TRUE
;
165 MONTHCAL_CopyTime (lprgSysTimeArray
, &infoPtr
->date
);
166 SendMessageW (infoPtr
->hMonthCal
, MCM_SETCURSEL
, 0, (LPARAM
)(&infoPtr
->date
));
167 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_CHECKED
, 0);
168 } else if (flag
== GDT_NONE
) {
169 infoPtr
->dateValid
= FALSE
;
170 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_UNCHECKED
, 0);
173 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
179 * Split up a formattxt in actions.
180 * See ms documentation for the meaning of the letter codes/'specifiers'.
183 * *'dddddd' is handled as 'dddd' plus 'dd'.
184 * *unrecognized formats are strings (here given the type DT_STRING;
185 * start of the string is encoded in lower bits of DT_STRING.
186 * Therefore, 'string' ends finally up as '<show seconds>tring'.
190 DATETIME_UseFormat (DATETIME_INFO
*infoPtr
, LPCWSTR formattxt
)
194 int *nrFields
= &infoPtr
->nrFields
;
197 infoPtr
->fieldspec
[*nrFields
] = 0;
198 len
= strlenW(allowedformatchars
);
201 for (i
= 0; formattxt
[i
]; i
++) {
202 TRACE ("\n%d %c:", i
, formattxt
[i
]);
203 for (j
= 0; j
< len
; j
++) {
204 if (allowedformatchars
[j
]==formattxt
[i
]) {
205 TRACE ("%c[%d,%x]", allowedformatchars
[j
], *nrFields
, infoPtr
->fieldspec
[*nrFields
]);
206 if ((*nrFields
==0) && (infoPtr
->fieldspec
[*nrFields
]==0)) {
207 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
210 if (infoPtr
->fieldspec
[*nrFields
] >> 4 != j
) {
212 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
215 if ((infoPtr
->fieldspec
[*nrFields
] & 0x0f) == maxrepetition
[j
]) {
217 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
220 infoPtr
->fieldspec
[*nrFields
]++;
222 } /* if allowedformatchar */
225 /* char is not a specifier: handle char like a string */
227 if ((*nrFields
==0) && (infoPtr
->fieldspec
[*nrFields
]==0)) {
228 infoPtr
->fieldspec
[*nrFields
] = DT_STRING
+ k
;
229 infoPtr
->buflen
[*nrFields
] = 0;
230 } else if ((infoPtr
->fieldspec
[*nrFields
] & DT_STRING
) != DT_STRING
) {
232 infoPtr
->fieldspec
[*nrFields
] = DT_STRING
+ k
;
233 infoPtr
->buflen
[*nrFields
] = 0;
235 infoPtr
->textbuf
[k
] = formattxt
[i
];
237 infoPtr
->buflen
[*nrFields
]++;
240 if (*nrFields
== infoPtr
->nrFieldsAllocated
) {
241 FIXME ("out of memory; should reallocate. crash ahead.\n");
247 if (infoPtr
->fieldspec
[*nrFields
] != 0) (*nrFields
)++;
252 DATETIME_SetFormatW (DATETIME_INFO
*infoPtr
, LPCWSTR lpszFormat
)
255 WCHAR format_buf
[80];
258 if (infoPtr
->dwStyle
& DTS_LONGDATEFORMAT
)
259 format_item
= LOCALE_SLONGDATE
;
260 else if ((infoPtr
->dwStyle
& DTS_TIMEFORMAT
) == DTS_TIMEFORMAT
)
261 format_item
= LOCALE_STIMEFORMAT
;
262 else /* DTS_SHORTDATEFORMAT */
263 format_item
= LOCALE_SSHORTDATE
;
264 GetLocaleInfoW( GetSystemDefaultLCID(), format_item
, format_buf
, sizeof(format_buf
)/sizeof(format_buf
[0]));
265 lpszFormat
= format_buf
;
268 DATETIME_UseFormat (infoPtr
, lpszFormat
);
269 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
271 return infoPtr
->nrFields
;
276 DATETIME_SetFormatA (DATETIME_INFO
*infoPtr
, LPCSTR lpszFormat
)
280 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFormat
, -1, NULL
, 0);
281 LPWSTR wstr
= Alloc(len
* sizeof(WCHAR
));
282 if (wstr
) MultiByteToWideChar(CP_ACP
, 0, lpszFormat
, -1, wstr
, len
);
283 retval
= DATETIME_SetFormatW (infoPtr
, wstr
);
288 return DATETIME_SetFormatW (infoPtr
, 0);
294 DATETIME_ReturnTxt (DATETIME_INFO
*infoPtr
, int count
, LPWSTR result
, int resultSize
)
296 static const WCHAR fmt_dW
[] = { '%', 'd', 0 };
297 static const WCHAR fmt__2dW
[] = { '%', '.', '2', 'd', 0 };
298 static const WCHAR fmt__3sW
[] = { '%', '.', '3', 's', 0 };
299 SYSTEMTIME date
= infoPtr
->date
;
304 TRACE ("%d,%d\n", infoPtr
->nrFields
, count
);
305 if (count
>infoPtr
->nrFields
|| count
< 0) {
306 WARN ("buffer overrun, have %d want %d\n", infoPtr
->nrFields
, count
);
310 if (!infoPtr
->fieldspec
) return;
312 spec
= infoPtr
->fieldspec
[count
];
313 if (spec
& DT_STRING
) {
314 int txtlen
= infoPtr
->buflen
[count
];
316 if (txtlen
> resultSize
)
317 txtlen
= resultSize
- 1;
318 memcpy (result
, infoPtr
->textbuf
+ (spec
&~ DT_STRING
), txtlen
* sizeof(WCHAR
));
320 TRACE ("arg%d=%x->[%s]\n", count
, infoPtr
->fieldspec
[count
], debugstr_w(result
));
330 wsprintfW (result
, fmt_dW
, date
.wDay
);
333 wsprintfW (result
, fmt__2dW
, date
.wDay
);
336 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SABBREVDAYNAME1
+(date
.wDayOfWeek
+6)%7, result
, 4);
337 /*wsprintfW (result,"%.3s",days[date.wDayOfWeek]);*/
340 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SDAYNAME1
+(date
.wDayOfWeek
+6)%7, result
, resultSize
);
343 if (date
.wHour
== 0) {
349 wsprintfW (result
, fmt_dW
, date
.wHour
- (date
.wHour
> 12 ? 12 : 0));
352 if (date
.wHour
== 0) {
358 wsprintfW (result
, fmt__2dW
, date
.wHour
- (date
.wHour
> 12 ? 12 : 0));
361 wsprintfW (result
, fmt_dW
, date
.wHour
);
364 wsprintfW (result
, fmt__2dW
, date
.wHour
);
367 wsprintfW (result
, fmt_dW
, date
.wSecond
);
370 wsprintfW (result
, fmt__2dW
, date
.wSecond
);
373 wsprintfW (result
, fmt_dW
, date
.wMinute
);
376 wsprintfW (result
, fmt__2dW
, date
.wMinute
);
379 wsprintfW (result
, fmt_dW
, date
.wMonth
);
382 wsprintfW (result
, fmt__2dW
, date
.wMonth
);
385 GetLocaleInfoW(GetSystemDefaultLCID(), LOCALE_SMONTHNAME1
+date
.wMonth
-1,
386 buffer
, sizeof(buffer
)/sizeof(buffer
[0]));
387 wsprintfW (result
, fmt__3sW
, buffer
);
390 GetLocaleInfoW(GetSystemDefaultLCID(),LOCALE_SMONTHNAME1
+date
.wMonth
-1,
394 result
[0] = (date
.wHour
< 12 ? 'A' : 'P');
398 result
[0] = (date
.wHour
< 12 ? 'A' : 'P');
403 FIXME ("Not implemented\n");
408 wsprintfW (result
, fmt_dW
, date
.wYear
-10* (int) floor(date
.wYear
/10));
411 wsprintfW (result
, fmt__2dW
, date
.wYear
-100* (int) floor(date
.wYear
/100));
413 case INVALIDFULLYEAR
:
415 wsprintfW (result
, fmt_dW
, date
.wYear
);
419 TRACE ("arg%d=%x->[%s]\n", count
, infoPtr
->fieldspec
[count
], debugstr_w(result
));
422 /* Offsets of days in the week to the weekday of january 1 in a leap year. */
423 static const int DayOfWeekTable
[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
425 /* returns the day in the week(0 == sunday, 6 == saturday) */
426 /* day(1 == 1st, 2 == 2nd... etc), year is the year value */
427 static int DATETIME_CalculateDayOfWeek(DWORD day
, DWORD month
, DWORD year
)
431 return((year
+ year
/4 - year
/100 + year
/400 +
432 DayOfWeekTable
[month
-1] + day
) % 7);
435 static int wrap(int val
, int delta
, int minVal
, int maxVal
)
438 if (delta
== INT_MIN
|| val
< minVal
) return maxVal
;
439 if (delta
== INT_MAX
|| val
> maxVal
) return minVal
;
444 DATETIME_IncreaseField (DATETIME_INFO
*infoPtr
, int number
, int delta
)
446 SYSTEMTIME
*date
= &infoPtr
->date
;
448 TRACE ("%d\n", number
);
449 if ((number
> infoPtr
->nrFields
) || (number
< 0)) return;
451 if ((infoPtr
->fieldspec
[number
] & DTHT_DATEFIELD
) == 0) return;
453 switch (infoPtr
->fieldspec
[number
]) {
457 date
->wYear
= wrap(date
->wYear
, delta
, 1752, 9999);
458 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
464 date
->wMonth
= wrap(date
->wMonth
, delta
, 1, 12);
465 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
472 date
->wDay
= wrap(date
->wDay
, delta
, 1, MONTHCAL_MonthLength(date
->wMonth
, date
->wYear
));
473 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
483 date
->wHour
= wrap(date
->wHour
, delta
, 0, 23);
487 date
->wMinute
= wrap(date
->wMinute
, delta
, 0, 59);
491 date
->wSecond
= wrap(date
->wSecond
, delta
, 0, 59);
494 FIXME ("Not implemented\n");
498 /* FYI: On 1752/9/14 the calendar changed and England and the
499 * American colonies changed to the Gregorian calendar. This change
500 * involved having September 14th follow September 2nd. So no date
501 * algorithm works before that date.
503 if (10000 * date
->wYear
+ 100 * date
->wMonth
+ date
->wDay
< 17520914) {
515 DATETIME_ReturnFieldWidth (DATETIME_INFO
*infoPtr
, HDC hdc
, int count
, SHORT
*fieldWidthPtr
)
517 /* fields are a fixed width, determined by the largest possible string */
518 /* presumably, these widths should be language dependent */
519 static const WCHAR fld_d1W
[] = { '2', 0 };
520 static const WCHAR fld_d2W
[] = { '2', '2', 0 };
521 static const WCHAR fld_d4W
[] = { '2', '2', '2', '2', 0 };
522 static const WCHAR fld_am1
[] = { 'A', 0 };
523 static const WCHAR fld_am2
[] = { 'A', 'M', 0 };
524 static const WCHAR fld_day
[] = { 'W', 'e', 'd', 'n', 'e', 's', 'd', 'a', 'y', 0 };
525 static const WCHAR fld_day3
[] = { 'W', 'e', 'd', 0 };
526 static const WCHAR fld_mon
[] = { 'S', 'e', 'p', 't', 'e', 'm', 'b', 'e', 'r', 0 };
527 static const WCHAR fld_mon3
[] = { 'D', 'e', 'c', 0 };
529 WCHAR buffer
[80], *bufptr
;
532 TRACE ("%d,%d\n", infoPtr
->nrFields
, count
);
533 if (count
>infoPtr
->nrFields
|| count
< 0) {
534 WARN ("buffer overrun, have %d want %d\n", infoPtr
->nrFields
, count
);
538 if (!infoPtr
->fieldspec
) return;
540 spec
= infoPtr
->fieldspec
[count
];
541 if (spec
& DT_STRING
) {
542 int txtlen
= infoPtr
->buflen
[count
];
546 memcpy (buffer
, infoPtr
->textbuf
+ (spec
&~ DT_STRING
), txtlen
* sizeof(WCHAR
));
559 /* these seem to use a two byte field */
567 bufptr
= (WCHAR
*)fld_d2W
;
569 case INVALIDFULLYEAR
:
571 bufptr
= (WCHAR
*)fld_d4W
;
574 bufptr
= (WCHAR
*)fld_day3
;
577 bufptr
= (WCHAR
*)fld_day
;
580 bufptr
= (WCHAR
*)fld_mon3
;
583 bufptr
= (WCHAR
*)fld_mon
;
586 bufptr
= (WCHAR
*)fld_am1
;
589 bufptr
= (WCHAR
*)fld_am2
;
592 bufptr
= (WCHAR
*)fld_d1W
;
596 GetTextExtentPoint32W (hdc
, bufptr
, strlenW(bufptr
), &size
);
597 *fieldWidthPtr
= size
.cx
;
601 DATETIME_Refresh (DATETIME_INFO
*infoPtr
, HDC hdc
)
605 RECT
*rcDraw
= &infoPtr
->rcDraw
;
606 RECT
*calbutton
= &infoPtr
->calbutton
;
607 RECT
*checkbox
= &infoPtr
->checkbox
;
609 COLORREF oldTextColor
;
610 SHORT fieldWidth
= 0;
612 /* draw control edge */
615 if (infoPtr
->dateValid
) {
616 HFONT oldFont
= SelectObject (hdc
, infoPtr
->hFont
);
617 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
620 DATETIME_ReturnTxt (infoPtr
, 0, txt
, sizeof(txt
)/sizeof(txt
[0]));
621 GetTextExtentPoint32W (hdc
, txt
, strlenW(txt
), &size
);
622 rcDraw
->bottom
= size
.cy
+ 2;
624 prevright
= checkbox
->right
= ((infoPtr
->dwStyle
& DTS_SHOWNONE
) ? 18 : 2);
626 for (i
= 0; i
< infoPtr
->nrFields
; i
++) {
627 DATETIME_ReturnTxt (infoPtr
, i
, txt
, sizeof(txt
)/sizeof(txt
[0]));
628 GetTextExtentPoint32W (hdc
, txt
, strlenW(txt
), &size
);
629 DATETIME_ReturnFieldWidth (infoPtr
, hdc
, i
, &fieldWidth
);
630 field
= &infoPtr
->fieldRect
[i
];
631 field
->left
= prevright
;
632 field
->right
= prevright
+ fieldWidth
;
633 field
->top
= rcDraw
->top
;
634 field
->bottom
= rcDraw
->bottom
;
635 prevright
= field
->right
;
637 if (infoPtr
->dwStyle
& WS_DISABLED
)
638 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrGrayText
);
639 else if ((infoPtr
->haveFocus
) && (i
== infoPtr
->select
)) {
640 /* fill if focussed */
641 HBRUSH hbr
= CreateSolidBrush (comctl32_color
.clrActiveCaption
);
642 FillRect(hdc
, field
, hbr
);
644 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrWindow
);
647 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrWindowText
);
649 /* draw the date text using the colour set above */
650 DrawTextW (hdc
, txt
, strlenW(txt
), field
, DT_RIGHT
| DT_VCENTER
| DT_SINGLELINE
);
651 SetTextColor (hdc
, oldTextColor
);
653 SetBkMode (hdc
, oldBkMode
);
654 SelectObject (hdc
, oldFont
);
657 if (!(infoPtr
->dwStyle
& DTS_UPDOWN
)) {
658 DrawFrameControl(hdc
, calbutton
, DFC_SCROLL
,
659 DFCS_SCROLLDOWN
| (infoPtr
->bCalDepressed
? DFCS_PUSHED
: 0) |
660 (infoPtr
->dwStyle
& WS_DISABLED
? DFCS_INACTIVE
: 0) );
666 DATETIME_HitTest (DATETIME_INFO
*infoPtr
, POINT pt
)
670 TRACE ("%ld, %ld\n", pt
.x
, pt
.y
);
672 if (PtInRect (&infoPtr
->calbutton
, pt
)) return DTHT_MCPOPUP
;
673 if (PtInRect (&infoPtr
->checkbox
, pt
)) return DTHT_CHECKBOX
;
675 for (i
=0; i
< infoPtr
->nrFields
; i
++) {
676 if (PtInRect (&infoPtr
->fieldRect
[i
], pt
)) return i
;
684 DATETIME_LButtonDown (DATETIME_INFO
*infoPtr
, WORD wKey
, INT x
, INT y
)
691 old
= infoPtr
->select
;
692 new = DATETIME_HitTest (infoPtr
, pt
);
694 /* FIXME: might be conditions where we don't want to update infoPtr->select */
695 infoPtr
->select
= new;
697 SetFocus(infoPtr
->hwndSelf
);
699 if (infoPtr
->select
== DTHT_MCPOPUP
) {
701 SendMessageW(infoPtr
->hMonthCal
, MCM_GETMINREQRECT
, 0, (LPARAM
)&rcMonthCal
);
703 /* FIXME: button actually is only depressed during dropdown of the */
704 /* calendar control and when the mouse is over the button window */
705 infoPtr
->bCalDepressed
= TRUE
;
707 /* recalculate the position of the monthcal popup */
708 if(infoPtr
->dwStyle
& DTS_RIGHTALIGN
)
709 infoPtr
->monthcal_pos
.x
= infoPtr
->calbutton
.left
-
710 (rcMonthCal
.right
- rcMonthCal
.left
);
712 /* FIXME: this should be after the area reserved for the checkbox */
713 infoPtr
->monthcal_pos
.x
= infoPtr
->rcDraw
.left
;
715 infoPtr
->monthcal_pos
.y
= infoPtr
->rcClient
.bottom
;
716 ClientToScreen (infoPtr
->hwndSelf
, &(infoPtr
->monthcal_pos
));
717 SetWindowPos(infoPtr
->hMonthCal
, 0, infoPtr
->monthcal_pos
.x
,
718 infoPtr
->monthcal_pos
.y
, rcMonthCal
.right
- rcMonthCal
.left
,
719 rcMonthCal
.bottom
- rcMonthCal
.top
, 0);
721 if(IsWindowVisible(infoPtr
->hMonthCal
)) {
722 ShowWindow(infoPtr
->hMonthCal
, SW_HIDE
);
724 SYSTEMTIME
*lprgSysTimeArray
= &infoPtr
->date
;
725 TRACE("update calendar %04d/%02d/%02d\n",
726 lprgSysTimeArray
->wYear
, lprgSysTimeArray
->wMonth
, lprgSysTimeArray
->wDay
);
727 SendMessageW(infoPtr
->hMonthCal
, MCM_SETCURSEL
, 0, (LPARAM
)(&infoPtr
->date
));
728 ShowWindow(infoPtr
->hMonthCal
, SW_SHOW
);
731 TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p\n",
732 infoPtr
->hwndSelf
, infoPtr
->hMonthCal
, infoPtr
->hwndNotify
, GetDesktopWindow ());
733 DATETIME_SendSimpleNotify (infoPtr
, DTN_DROPDOWN
);
736 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
743 DATETIME_LButtonUp (DATETIME_INFO
*infoPtr
, WORD wKey
)
745 if(infoPtr
->bCalDepressed
) {
746 infoPtr
->bCalDepressed
= FALSE
;
747 InvalidateRect(infoPtr
->hwndSelf
, &(infoPtr
->calbutton
), TRUE
);
755 DATETIME_Paint (DATETIME_INFO
*infoPtr
, HDC hdc
)
759 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
760 DATETIME_Refresh (infoPtr
, hdc
);
761 EndPaint (infoPtr
->hwndSelf
, &ps
);
763 DATETIME_Refresh (infoPtr
, hdc
);
770 DATETIME_Button_Command (DATETIME_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
772 if( HIWORD(wParam
) == BN_CLICKED
) {
773 DWORD state
= SendMessageW((HWND
)lParam
, BM_GETCHECK
, 0, 0);
774 infoPtr
->dateValid
= (state
== BST_CHECKED
);
775 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
783 DATETIME_Command (DATETIME_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
785 TRACE("hwndbutton = %p\n", infoPtr
->hwndCheckbut
);
786 if(infoPtr
->hwndCheckbut
== (HWND
)lParam
)
787 return DATETIME_Button_Command(infoPtr
, wParam
, lParam
);
793 DATETIME_Enable (DATETIME_INFO
*infoPtr
, BOOL bEnable
)
795 TRACE("%p %s\n", infoPtr
, bEnable
? "TRUE" : "FALSE");
797 infoPtr
->dwStyle
&= ~WS_DISABLED
;
799 infoPtr
->dwStyle
|= WS_DISABLED
;
805 DATETIME_EraseBackground (DATETIME_INFO
*infoPtr
, HDC hdc
)
807 HBRUSH hBrush
, hSolidBrush
= NULL
;
810 if (infoPtr
->dwStyle
& WS_DISABLED
)
811 hBrush
= hSolidBrush
= CreateSolidBrush(comctl32_color
.clrBtnFace
);
814 hBrush
= (HBRUSH
)SendMessageW(infoPtr
->hwndNotify
, WM_CTLCOLOREDIT
,
815 (WPARAM
)hdc
, (LPARAM
)infoPtr
->hwndSelf
);
817 hBrush
= hSolidBrush
= CreateSolidBrush(comctl32_color
.clrWindow
);
820 GetClientRect (infoPtr
->hwndSelf
, &rc
);
822 FillRect (hdc
, &rc
, hBrush
);
825 DeleteObject(hSolidBrush
);
832 DATETIME_Notify (DATETIME_INFO
*infoPtr
, int idCtrl
, LPNMHDR lpnmh
)
834 TRACE ("Got notification %x from %p\n", lpnmh
->code
, lpnmh
->hwndFrom
);
835 TRACE ("info: %p %p %p\n", infoPtr
->hwndSelf
, infoPtr
->hMonthCal
, infoPtr
->hUpdown
);
837 if (lpnmh
->code
== MCN_SELECT
) {
838 ShowWindow(infoPtr
->hMonthCal
, SW_HIDE
);
839 infoPtr
->dateValid
= TRUE
;
840 SendMessageW (infoPtr
->hMonthCal
, MCM_GETCURSEL
, 0, (LPARAM
)&infoPtr
->date
);
841 TRACE("got from calendar %04d/%02d/%02d day of week %d\n",
842 infoPtr
->date
.wYear
, infoPtr
->date
.wMonth
, infoPtr
->date
.wDay
, infoPtr
->date
.wDayOfWeek
);
843 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_CHECKED
, 0);
844 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
845 DATETIME_SendDateTimeChangeNotify (infoPtr
);
847 if ((lpnmh
->hwndFrom
== infoPtr
->hUpdown
) && (lpnmh
->code
== UDN_DELTAPOS
)) {
848 LPNMUPDOWN lpnmud
= (LPNMUPDOWN
)lpnmh
;
849 TRACE("Delta pos %d\n", lpnmud
->iDelta
);
850 infoPtr
->pendingUpdown
= lpnmud
->iDelta
;
857 DATETIME_KeyDown (DATETIME_INFO
*infoPtr
, DWORD vkCode
, LPARAM flags
)
859 int fieldNum
= infoPtr
->select
& DTHT_DATEFIELD
;
862 if (!(infoPtr
->haveFocus
)) return 0;
863 if ((fieldNum
==0) && (infoPtr
->select
)) return 0;
865 if (infoPtr
->select
& FORMATCALLMASK
) {
866 FIXME ("Callbacks not implemented yet\n");
869 if (vkCode
>= '0' && vkCode
<= '9') {
870 /* this is a somewhat simplified version of what Windows does */
871 SYSTEMTIME
*date
= &infoPtr
->date
;
872 switch (infoPtr
->fieldspec
[fieldNum
]) {
875 date
->wYear
= date
->wYear
- (date
->wYear
%100) +
876 (date
->wYear
%10)*10 + (vkCode
-'0');
877 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
878 date
->wDay
,date
->wMonth
,date
->wYear
);
879 DATETIME_SendDateTimeChangeNotify (infoPtr
);
881 case INVALIDFULLYEAR
:
883 date
->wYear
= (date
->wYear
%1000)*10 + (vkCode
-'0');
884 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
885 date
->wDay
,date
->wMonth
,date
->wYear
);
886 DATETIME_SendDateTimeChangeNotify (infoPtr
);
890 if ((date
->wMonth
%10) > 1 || (vkCode
-'0') > 2)
891 date
->wMonth
= vkCode
-'0';
893 date
->wMonth
= (date
->wMonth
%10)*10+vkCode
-'0';
894 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
895 date
->wDay
,date
->wMonth
,date
->wYear
);
896 DATETIME_SendDateTimeChangeNotify (infoPtr
);
900 /* probably better checking here would help */
901 if ((date
->wDay
%10) >= 3 && (vkCode
-'0') > 1)
902 date
->wDay
= vkCode
-'0';
904 date
->wDay
= (date
->wDay
%10)*10+vkCode
-'0';
905 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
906 date
->wDay
,date
->wMonth
,date
->wYear
);
907 DATETIME_SendDateTimeChangeNotify (infoPtr
);
911 if ((date
->wHour
%10) > 1 || (vkCode
-'0') > 2)
912 date
->wHour
= vkCode
-'0';
914 date
->wHour
= (date
->wHour
%10)*10+vkCode
-'0';
915 DATETIME_SendDateTimeChangeNotify (infoPtr
);
919 if ((date
->wHour
%10) > 2)
920 date
->wHour
= vkCode
-'0';
921 else if ((date
->wHour
%10) == 2 && (vkCode
-'0') > 3)
922 date
->wHour
= vkCode
-'0';
924 date
->wHour
= (date
->wHour
%10)*10+vkCode
-'0';
925 DATETIME_SendDateTimeChangeNotify (infoPtr
);
929 if ((date
->wMinute
%10) > 5)
930 date
->wMinute
= vkCode
-'0';
932 date
->wMinute
= (date
->wMinute
%10)*10+vkCode
-'0';
933 DATETIME_SendDateTimeChangeNotify (infoPtr
);
937 if ((date
->wSecond
%10) > 5)
938 date
->wSecond
= vkCode
-'0';
940 date
->wSecond
= (date
->wSecond
%10)*10+vkCode
-'0';
941 DATETIME_SendDateTimeChangeNotify (infoPtr
);
949 DATETIME_IncreaseField (infoPtr
, fieldNum
, 1);
950 DATETIME_SendDateTimeChangeNotify (infoPtr
);
954 DATETIME_IncreaseField (infoPtr
, fieldNum
, -1);
955 DATETIME_SendDateTimeChangeNotify (infoPtr
);
958 DATETIME_IncreaseField (infoPtr
, fieldNum
, INT_MIN
);
959 DATETIME_SendDateTimeChangeNotify (infoPtr
);
962 DATETIME_IncreaseField (infoPtr
, fieldNum
, INT_MAX
);
963 DATETIME_SendDateTimeChangeNotify (infoPtr
);
967 if (infoPtr
->select
== 0) {
968 infoPtr
->select
= infoPtr
->nrFields
- 1;
973 } while ((infoPtr
->fieldspec
[infoPtr
->select
] & DT_STRING
) && (wrap
<2));
978 if (infoPtr
->select
==infoPtr
->nrFields
) {
982 } while ((infoPtr
->fieldspec
[infoPtr
->select
] & DT_STRING
) && (wrap
<2));
986 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
993 DATETIME_VScroll (DATETIME_INFO
*infoPtr
, WORD wScroll
)
995 int fieldNum
= infoPtr
->select
& DTHT_DATEFIELD
;
997 if ((SHORT
)LOWORD(wScroll
) != SB_THUMBPOSITION
) return 0;
998 if (!(infoPtr
->haveFocus
)) return 0;
999 if ((fieldNum
==0) && (infoPtr
->select
)) return 0;
1001 if (infoPtr
->pendingUpdown
>= 0) {
1002 DATETIME_IncreaseField (infoPtr
, fieldNum
, 1);
1003 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1006 DATETIME_IncreaseField (infoPtr
, fieldNum
, -1);
1007 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1010 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1017 DATETIME_KillFocus (DATETIME_INFO
*infoPtr
, HWND lostFocus
)
1019 TRACE("lost focus to %p\n", lostFocus
);
1021 if (infoPtr
->haveFocus
) {
1022 DATETIME_SendSimpleNotify (infoPtr
, NM_KILLFOCUS
);
1023 infoPtr
->haveFocus
= 0;
1026 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
1033 DATETIME_NCCreate (HWND hwnd
, LPCREATESTRUCTW lpcs
)
1035 DWORD dwExStyle
= GetWindowLongW(hwnd
, GWL_EXSTYLE
);
1036 /* force control to have client edge */
1037 dwExStyle
|= WS_EX_CLIENTEDGE
;
1038 SetWindowLongW(hwnd
, GWL_EXSTYLE
, dwExStyle
);
1040 return DefWindowProcW(hwnd
, WM_NCCREATE
, 0, (LPARAM
)lpcs
);
1045 DATETIME_SetFocus (DATETIME_INFO
*infoPtr
, HWND lostFocus
)
1047 TRACE("got focus from %p\n", lostFocus
);
1049 if (infoPtr
->haveFocus
== 0) {
1050 DATETIME_SendSimpleNotify (infoPtr
, NM_SETFOCUS
);
1051 infoPtr
->haveFocus
= DTHT_GOTFOCUS
;
1054 InvalidateRect(infoPtr
->hwndSelf
, NULL
, FALSE
);
1061 DATETIME_SendDateTimeChangeNotify (DATETIME_INFO
*infoPtr
)
1063 NMDATETIMECHANGE dtdtc
;
1065 dtdtc
.nmhdr
.hwndFrom
= infoPtr
->hwndSelf
;
1066 dtdtc
.nmhdr
.idFrom
= GetWindowLongPtrW(infoPtr
->hwndSelf
, GWLP_ID
);
1067 dtdtc
.nmhdr
.code
= DTN_DATETIMECHANGE
;
1069 dtdtc
.dwFlags
= (infoPtr
->dwStyle
& DTS_SHOWNONE
) ? GDT_NONE
: GDT_VALID
;
1071 MONTHCAL_CopyTime (&infoPtr
->date
, &dtdtc
.st
);
1072 return (BOOL
) SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
1073 (WPARAM
)dtdtc
.nmhdr
.idFrom
, (LPARAM
)&dtdtc
);
1078 DATETIME_SendSimpleNotify (DATETIME_INFO
*infoPtr
, UINT code
)
1082 TRACE("%x\n", code
);
1083 nmhdr
.hwndFrom
= infoPtr
->hwndSelf
;
1084 nmhdr
.idFrom
= GetWindowLongPtrW(infoPtr
->hwndSelf
, GWLP_ID
);
1087 return (BOOL
) SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
1088 (WPARAM
)nmhdr
.idFrom
, (LPARAM
)&nmhdr
);
1092 DATETIME_Size (DATETIME_INFO
*infoPtr
, WORD flags
, INT width
, INT height
)
1095 infoPtr
->rcClient
.bottom
= height
;
1096 infoPtr
->rcClient
.right
= width
;
1098 TRACE("Height=%ld, Width=%ld\n", infoPtr
->rcClient
.bottom
, infoPtr
->rcClient
.right
);
1100 infoPtr
->rcDraw
= infoPtr
->rcClient
;
1102 if (infoPtr
->dwStyle
& DTS_UPDOWN
) {
1103 SetWindowPos(infoPtr
->hUpdown
, NULL
,
1104 infoPtr
->rcClient
.right
-14, 0,
1105 15, infoPtr
->rcClient
.bottom
- infoPtr
->rcClient
.top
,
1106 SWP_NOACTIVATE
| SWP_NOZORDER
);
1109 /* set the size of the button that drops the calendar down */
1110 /* FIXME: account for style that allows button on left side */
1111 infoPtr
->calbutton
.top
= infoPtr
->rcDraw
.top
;
1112 infoPtr
->calbutton
.bottom
= infoPtr
->rcDraw
.bottom
;
1113 infoPtr
->calbutton
.left
= infoPtr
->rcDraw
.right
-15;
1114 infoPtr
->calbutton
.right
= infoPtr
->rcDraw
.right
;
1117 /* set enable/disable button size for show none style being enabled */
1118 /* FIXME: these dimensions are completely incorrect */
1119 infoPtr
->checkbox
.top
= infoPtr
->rcDraw
.top
;
1120 infoPtr
->checkbox
.bottom
= infoPtr
->rcDraw
.bottom
;
1121 infoPtr
->checkbox
.left
= infoPtr
->rcDraw
.left
;
1122 infoPtr
->checkbox
.right
= infoPtr
->rcDraw
.left
+ 10;
1124 InvalidateRect(infoPtr
->hwndSelf
, NULL
, FALSE
);
1131 DATETIME_StyleChanged(DATETIME_INFO
*infoPtr
, WPARAM wStyleType
, LPSTYLESTRUCT lpss
)
1133 static const WCHAR buttonW
[] = { 'b', 'u', 't', 't', 'o', 'n', 0 };
1135 TRACE("(styletype=%x, styleOld=0x%08lx, styleNew=0x%08lx)\n",
1136 wStyleType
, lpss
->styleOld
, lpss
->styleNew
);
1138 if (wStyleType
!= GWL_STYLE
) return 0;
1140 infoPtr
->dwStyle
= lpss
->styleNew
;
1142 if ( !(lpss
->styleOld
& DTS_SHOWNONE
) && (lpss
->styleNew
& DTS_SHOWNONE
) ) {
1143 infoPtr
->hwndCheckbut
= CreateWindowExW (0, buttonW
, 0, WS_CHILD
| WS_VISIBLE
| BS_AUTOCHECKBOX
,
1144 2, 2, 13, 13, infoPtr
->hwndSelf
, 0,
1145 (HINSTANCE
)GetWindowLongPtrW (infoPtr
->hwndSelf
, GWLP_HINSTANCE
), 0);
1146 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, 1, 0);
1148 if ( (lpss
->styleOld
& DTS_SHOWNONE
) && !(lpss
->styleNew
& DTS_SHOWNONE
) ) {
1149 DestroyWindow(infoPtr
->hwndCheckbut
);
1150 infoPtr
->hwndCheckbut
= 0;
1152 if ( !(lpss
->styleOld
& DTS_UPDOWN
) && (lpss
->styleNew
& DTS_UPDOWN
) ) {
1153 infoPtr
->hUpdown
= CreateUpDownControl (WS_CHILD
| WS_BORDER
| WS_VISIBLE
, 120, 1, 20, 20,
1154 infoPtr
->hwndSelf
, 1, 0, 0, UD_MAXVAL
, UD_MINVAL
, 0);
1156 if ( (lpss
->styleOld
& DTS_UPDOWN
) && !(lpss
->styleNew
& DTS_UPDOWN
) ) {
1157 DestroyWindow(infoPtr
->hUpdown
);
1158 infoPtr
->hUpdown
= 0;
1161 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1167 DATETIME_SetFont (DATETIME_INFO
*infoPtr
, HFONT font
, BOOL repaint
)
1169 infoPtr
->hFont
= font
;
1170 if (repaint
) InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1176 DATETIME_Create (HWND hwnd
, LPCREATESTRUCTW lpcs
)
1178 static const WCHAR SysMonthCal32W
[] = { 'S', 'y', 's', 'M', 'o', 'n', 't', 'h', 'C', 'a', 'l', '3', '2', 0 };
1179 DATETIME_INFO
*infoPtr
= (DATETIME_INFO
*)Alloc (sizeof(DATETIME_INFO
));
1180 STYLESTRUCT ss
= { 0, lpcs
->style
};
1182 if (!infoPtr
) return -1;
1184 infoPtr
->hwndSelf
= hwnd
;
1185 infoPtr
->dwStyle
= lpcs
->style
;
1187 infoPtr
->nrFieldsAllocated
= 32;
1188 infoPtr
->fieldspec
= (int *) Alloc (infoPtr
->nrFieldsAllocated
* sizeof(int));
1189 infoPtr
->fieldRect
= (RECT
*) Alloc (infoPtr
->nrFieldsAllocated
* sizeof(RECT
));
1190 infoPtr
->buflen
= (int *) Alloc (infoPtr
->nrFieldsAllocated
* sizeof(int));
1191 infoPtr
->hwndNotify
= lpcs
->hwndParent
;
1192 infoPtr
->select
= -1; /* initially, nothing is selected */
1194 DATETIME_StyleChanged(infoPtr
, GWL_STYLE
, &ss
);
1195 DATETIME_SetFormatW (infoPtr
, 0);
1197 /* create the monthcal control */
1198 infoPtr
->hMonthCal
= CreateWindowExW (0, SysMonthCal32W
, 0, WS_BORDER
| WS_POPUP
| WS_CLIPSIBLINGS
,
1199 0, 0, 0, 0, infoPtr
->hwndSelf
, 0, 0, 0);
1201 /* initialize info structure */
1202 GetLocalTime (&infoPtr
->date
);
1203 infoPtr
->dateValid
= TRUE
;
1204 infoPtr
->hFont
= GetStockObject(DEFAULT_GUI_FONT
);
1206 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
1214 DATETIME_Destroy (DATETIME_INFO
*infoPtr
)
1216 if (infoPtr
->hwndCheckbut
)
1217 DestroyWindow(infoPtr
->hwndCheckbut
);
1218 if (infoPtr
->hUpdown
)
1219 DestroyWindow(infoPtr
->hUpdown
);
1220 if (infoPtr
->hMonthCal
)
1221 DestroyWindow(infoPtr
->hMonthCal
);
1222 SetWindowLongPtrW( infoPtr
->hwndSelf
, 0, 0 ); /* clear infoPtr */
1228 static LRESULT WINAPI
1229 DATETIME_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1231 DATETIME_INFO
*infoPtr
= ((DATETIME_INFO
*)GetWindowLongPtrW (hwnd
, 0));
1234 TRACE ("%x, %x, %lx\n", uMsg
, wParam
, lParam
);
1236 if (!infoPtr
&& (uMsg
!= WM_CREATE
) && (uMsg
!= WM_NCCREATE
))
1237 return DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
1241 case DTM_GETSYSTEMTIME
:
1242 return DATETIME_GetSystemTime (infoPtr
, (SYSTEMTIME
*) lParam
);
1244 case DTM_SETSYSTEMTIME
:
1245 return DATETIME_SetSystemTime (infoPtr
, wParam
, (SYSTEMTIME
*) lParam
);
1248 ret
= SendMessageW (infoPtr
->hMonthCal
, MCM_GETRANGE
, wParam
, lParam
);
1249 return ret
? ret
: 1; /* bug emulation */
1252 return SendMessageW (infoPtr
->hMonthCal
, MCM_SETRANGE
, wParam
, lParam
);
1254 case DTM_SETFORMATA
:
1255 return DATETIME_SetFormatA (infoPtr
, (LPCSTR
)lParam
);
1257 case DTM_SETFORMATW
:
1258 return DATETIME_SetFormatW (infoPtr
, (LPCWSTR
)lParam
);
1260 case DTM_GETMONTHCAL
:
1261 return (LRESULT
)infoPtr
->hMonthCal
;
1263 case DTM_SETMCCOLOR
:
1264 return SendMessageW (infoPtr
->hMonthCal
, MCM_SETCOLOR
, wParam
, lParam
);
1266 case DTM_GETMCCOLOR
:
1267 return SendMessageW (infoPtr
->hMonthCal
, MCM_GETCOLOR
, wParam
, 0);
1270 return SendMessageW (infoPtr
->hMonthCal
, WM_SETFONT
, wParam
, lParam
);
1273 return SendMessageW (infoPtr
->hMonthCal
, WM_GETFONT
, wParam
, lParam
);
1276 return DATETIME_Notify (infoPtr
, (int)wParam
, (LPNMHDR
)lParam
);
1279 return DATETIME_Enable (infoPtr
, (BOOL
)wParam
);
1282 return DATETIME_EraseBackground (infoPtr
, (HDC
)wParam
);
1285 return DLGC_WANTARROWS
| DLGC_WANTCHARS
;
1287 case WM_PRINTCLIENT
:
1289 return DATETIME_Paint (infoPtr
, (HDC
)wParam
);
1292 return DATETIME_KeyDown (infoPtr
, wParam
, lParam
);
1295 return DATETIME_KillFocus (infoPtr
, (HWND
)wParam
);
1298 return DATETIME_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
1301 return DATETIME_SetFocus (infoPtr
, (HWND
)wParam
);
1304 return DATETIME_Size (infoPtr
, wParam
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
1306 case WM_LBUTTONDOWN
:
1307 return DATETIME_LButtonDown (infoPtr
, (WORD
)wParam
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
1310 return DATETIME_LButtonUp (infoPtr
, (WORD
)wParam
);
1313 return DATETIME_VScroll (infoPtr
, (WORD
)wParam
);
1316 return DATETIME_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
1319 return DATETIME_Destroy (infoPtr
);
1322 return DATETIME_Command (infoPtr
, wParam
, lParam
);
1324 case WM_STYLECHANGED
:
1325 return DATETIME_StyleChanged(infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
1328 return DATETIME_SetFont(infoPtr
, (HFONT
)wParam
, (BOOL
)lParam
);
1331 return (LRESULT
) infoPtr
->hFont
;
1334 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
1335 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
1336 uMsg
, wParam
, lParam
);
1337 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
1343 DATETIME_Register (void)
1347 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
1348 wndClass
.style
= CS_GLOBALCLASS
;
1349 wndClass
.lpfnWndProc
= DATETIME_WindowProc
;
1350 wndClass
.cbClsExtra
= 0;
1351 wndClass
.cbWndExtra
= sizeof(DATETIME_INFO
*);
1352 wndClass
.hCursor
= LoadCursorW (0, (LPCWSTR
)IDC_ARROW
);
1353 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
1354 wndClass
.lpszClassName
= DATETIMEPICK_CLASSW
;
1356 RegisterClassW (&wndClass
);
1361 DATETIME_Unregister (void)
1363 UnregisterClassW (DATETIMEPICK_CLASSW
, NULL
);