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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 (const DATETIME_INFO
*infoPtr
, UINT code
);
133 static BOOL
DATETIME_SendDateTimeChangeNotify (const 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 (const 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
, const 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 if (lprgSysTimeArray
->wYear
< 1601 || lprgSysTimeArray
->wYear
> 30827 ||
165 lprgSysTimeArray
->wMonth
< 1 || lprgSysTimeArray
->wMonth
> 12 ||
166 lprgSysTimeArray
->wDayOfWeek
> 6 ||
167 lprgSysTimeArray
->wDay
< 1 || lprgSysTimeArray
->wDay
> 31 ||
168 lprgSysTimeArray
->wHour
> 23 ||
169 lprgSysTimeArray
->wMinute
> 59 ||
170 lprgSysTimeArray
->wSecond
> 59 ||
171 lprgSysTimeArray
->wMilliseconds
> 999
175 infoPtr
->dateValid
= TRUE
;
176 MONTHCAL_CopyTime (lprgSysTimeArray
, &infoPtr
->date
);
177 SendMessageW (infoPtr
->hMonthCal
, MCM_SETCURSEL
, 0, (LPARAM
)(&infoPtr
->date
));
178 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_CHECKED
, 0);
179 } else if ((infoPtr
->dwStyle
& DTS_SHOWNONE
) && (flag
== GDT_NONE
)) {
180 infoPtr
->dateValid
= FALSE
;
181 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_UNCHECKED
, 0);
186 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
192 * Split up a formattxt in actions.
193 * See ms documentation for the meaning of the letter codes/'specifiers'.
196 * *'dddddd' is handled as 'dddd' plus 'dd'.
197 * *unrecognized formats are strings (here given the type DT_STRING;
198 * start of the string is encoded in lower bits of DT_STRING.
199 * Therefore, 'string' ends finally up as '<show seconds>tring'.
203 DATETIME_UseFormat (DATETIME_INFO
*infoPtr
, LPCWSTR formattxt
)
207 int *nrFields
= &infoPtr
->nrFields
;
210 infoPtr
->fieldspec
[*nrFields
] = 0;
211 len
= strlenW(allowedformatchars
);
214 for (i
= 0; formattxt
[i
]; i
++) {
215 TRACE ("\n%d %c:", i
, formattxt
[i
]);
216 for (j
= 0; j
< len
; j
++) {
217 if (allowedformatchars
[j
]==formattxt
[i
]) {
218 TRACE ("%c[%d,%x]", allowedformatchars
[j
], *nrFields
, infoPtr
->fieldspec
[*nrFields
]);
219 if ((*nrFields
==0) && (infoPtr
->fieldspec
[*nrFields
]==0)) {
220 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
223 if (infoPtr
->fieldspec
[*nrFields
] >> 4 != j
) {
225 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
228 if ((infoPtr
->fieldspec
[*nrFields
] & 0x0f) == maxrepetition
[j
]) {
230 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
233 infoPtr
->fieldspec
[*nrFields
]++;
235 } /* if allowedformatchar */
238 /* char is not a specifier: handle char like a string */
240 if ((*nrFields
==0) && (infoPtr
->fieldspec
[*nrFields
]==0)) {
241 infoPtr
->fieldspec
[*nrFields
] = DT_STRING
+ k
;
242 infoPtr
->buflen
[*nrFields
] = 0;
243 } else if ((infoPtr
->fieldspec
[*nrFields
] & DT_STRING
) != DT_STRING
) {
245 infoPtr
->fieldspec
[*nrFields
] = DT_STRING
+ k
;
246 infoPtr
->buflen
[*nrFields
] = 0;
248 infoPtr
->textbuf
[k
] = formattxt
[i
];
250 infoPtr
->buflen
[*nrFields
]++;
253 if (*nrFields
== infoPtr
->nrFieldsAllocated
) {
254 FIXME ("out of memory; should reallocate. crash ahead.\n");
260 if (infoPtr
->fieldspec
[*nrFields
] != 0) (*nrFields
)++;
265 DATETIME_SetFormatW (DATETIME_INFO
*infoPtr
, LPCWSTR lpszFormat
)
268 WCHAR format_buf
[80];
271 if (infoPtr
->dwStyle
& DTS_LONGDATEFORMAT
)
272 format_item
= LOCALE_SLONGDATE
;
273 else if ((infoPtr
->dwStyle
& DTS_TIMEFORMAT
) == DTS_TIMEFORMAT
)
274 format_item
= LOCALE_STIMEFORMAT
;
275 else /* DTS_SHORTDATEFORMAT */
276 format_item
= LOCALE_SSHORTDATE
;
277 GetLocaleInfoW( GetSystemDefaultLCID(), format_item
, format_buf
, sizeof(format_buf
)/sizeof(format_buf
[0]));
278 lpszFormat
= format_buf
;
281 DATETIME_UseFormat (infoPtr
, lpszFormat
);
282 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
289 DATETIME_SetFormatA (DATETIME_INFO
*infoPtr
, LPCSTR lpszFormat
)
293 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFormat
, -1, NULL
, 0);
294 LPWSTR wstr
= Alloc(len
* sizeof(WCHAR
));
295 if (wstr
) MultiByteToWideChar(CP_ACP
, 0, lpszFormat
, -1, wstr
, len
);
296 retval
= DATETIME_SetFormatW (infoPtr
, wstr
);
301 return DATETIME_SetFormatW (infoPtr
, 0);
307 DATETIME_ReturnTxt (const DATETIME_INFO
*infoPtr
, int count
, LPWSTR result
, int resultSize
)
309 static const WCHAR fmt_dW
[] = { '%', 'd', 0 };
310 static const WCHAR fmt__2dW
[] = { '%', '.', '2', 'd', 0 };
311 static const WCHAR fmt__3sW
[] = { '%', '.', '3', 's', 0 };
312 SYSTEMTIME date
= infoPtr
->date
;
317 TRACE ("%d,%d\n", infoPtr
->nrFields
, count
);
318 if (count
>infoPtr
->nrFields
|| count
< 0) {
319 WARN ("buffer overrun, have %d want %d\n", infoPtr
->nrFields
, count
);
323 if (!infoPtr
->fieldspec
) return;
325 spec
= infoPtr
->fieldspec
[count
];
326 if (spec
& DT_STRING
) {
327 int txtlen
= infoPtr
->buflen
[count
];
329 if (txtlen
> resultSize
)
330 txtlen
= resultSize
- 1;
331 memcpy (result
, infoPtr
->textbuf
+ (spec
&~ DT_STRING
), txtlen
* sizeof(WCHAR
));
333 TRACE ("arg%d=%x->[%s]\n", count
, infoPtr
->fieldspec
[count
], debugstr_w(result
));
343 wsprintfW (result
, fmt_dW
, date
.wDay
);
346 wsprintfW (result
, fmt__2dW
, date
.wDay
);
349 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SABBREVDAYNAME1
+(date
.wDayOfWeek
+6)%7, result
, 4);
350 /*wsprintfW (result,"%.3s",days[date.wDayOfWeek]);*/
353 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SDAYNAME1
+(date
.wDayOfWeek
+6)%7, result
, resultSize
);
356 if (date
.wHour
== 0) {
362 wsprintfW (result
, fmt_dW
, date
.wHour
- (date
.wHour
> 12 ? 12 : 0));
365 if (date
.wHour
== 0) {
371 wsprintfW (result
, fmt__2dW
, date
.wHour
- (date
.wHour
> 12 ? 12 : 0));
374 wsprintfW (result
, fmt_dW
, date
.wHour
);
377 wsprintfW (result
, fmt__2dW
, date
.wHour
);
380 wsprintfW (result
, fmt_dW
, date
.wSecond
);
383 wsprintfW (result
, fmt__2dW
, date
.wSecond
);
386 wsprintfW (result
, fmt_dW
, date
.wMinute
);
389 wsprintfW (result
, fmt__2dW
, date
.wMinute
);
392 wsprintfW (result
, fmt_dW
, date
.wMonth
);
395 wsprintfW (result
, fmt__2dW
, date
.wMonth
);
398 GetLocaleInfoW(GetSystemDefaultLCID(), LOCALE_SMONTHNAME1
+date
.wMonth
-1,
399 buffer
, sizeof(buffer
)/sizeof(buffer
[0]));
400 wsprintfW (result
, fmt__3sW
, buffer
);
403 GetLocaleInfoW(GetSystemDefaultLCID(),LOCALE_SMONTHNAME1
+date
.wMonth
-1,
407 result
[0] = (date
.wHour
< 12 ? 'A' : 'P');
411 result
[0] = (date
.wHour
< 12 ? 'A' : 'P');
416 FIXME ("Not implemented\n");
421 wsprintfW (result
, fmt_dW
, date
.wYear
-10* (int) floor(date
.wYear
/10));
424 wsprintfW (result
, fmt__2dW
, date
.wYear
-100* (int) floor(date
.wYear
/100));
426 case INVALIDFULLYEAR
:
428 wsprintfW (result
, fmt_dW
, date
.wYear
);
432 TRACE ("arg%d=%x->[%s]\n", count
, infoPtr
->fieldspec
[count
], debugstr_w(result
));
435 /* Offsets of days in the week to the weekday of january 1 in a leap year. */
436 static const int DayOfWeekTable
[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
438 /* returns the day in the week(0 == sunday, 6 == saturday) */
439 /* day(1 == 1st, 2 == 2nd... etc), year is the year value */
440 static int DATETIME_CalculateDayOfWeek(DWORD day
, DWORD month
, DWORD year
)
444 return((year
+ year
/4 - year
/100 + year
/400 +
445 DayOfWeekTable
[month
-1] + day
) % 7);
448 static int wrap(int val
, int delta
, int minVal
, int maxVal
)
451 if (delta
== INT_MIN
|| val
< minVal
) return maxVal
;
452 if (delta
== INT_MAX
|| val
> maxVal
) return minVal
;
457 DATETIME_IncreaseField (DATETIME_INFO
*infoPtr
, int number
, int delta
)
459 SYSTEMTIME
*date
= &infoPtr
->date
;
461 TRACE ("%d\n", number
);
462 if ((number
> infoPtr
->nrFields
) || (number
< 0)) return;
464 if ((infoPtr
->fieldspec
[number
] & DTHT_DATEFIELD
) == 0) return;
466 switch (infoPtr
->fieldspec
[number
]) {
470 date
->wYear
= wrap(date
->wYear
, delta
, 1752, 9999);
471 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
477 date
->wMonth
= wrap(date
->wMonth
, delta
, 1, 12);
478 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
485 date
->wDay
= wrap(date
->wDay
, delta
, 1, MONTHCAL_MonthLength(date
->wMonth
, date
->wYear
));
486 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
496 date
->wHour
= wrap(date
->wHour
, delta
, 0, 23);
500 date
->wMinute
= wrap(date
->wMinute
, delta
, 0, 59);
504 date
->wSecond
= wrap(date
->wSecond
, delta
, 0, 59);
507 FIXME ("Not implemented\n");
511 /* FYI: On 1752/9/14 the calendar changed and England and the
512 * American colonies changed to the Gregorian calendar. This change
513 * involved having September 14th follow September 2nd. So no date
514 * algorithm works before that date.
516 if (10000 * date
->wYear
+ 100 * date
->wMonth
+ date
->wDay
< 17520914) {
528 DATETIME_ReturnFieldWidth (const DATETIME_INFO
*infoPtr
, HDC hdc
, int count
, SHORT
*fieldWidthPtr
)
530 /* fields are a fixed width, determined by the largest possible string */
531 /* presumably, these widths should be language dependent */
532 static const WCHAR fld_d1W
[] = { '2', 0 };
533 static const WCHAR fld_d2W
[] = { '2', '2', 0 };
534 static const WCHAR fld_d4W
[] = { '2', '2', '2', '2', 0 };
535 static const WCHAR fld_am1
[] = { 'A', 0 };
536 static const WCHAR fld_am2
[] = { 'A', 'M', 0 };
537 static const WCHAR fld_day
[] = { 'W', 'e', 'd', 'n', 'e', 's', 'd', 'a', 'y', 0 };
538 static const WCHAR fld_day3
[] = { 'W', 'e', 'd', 0 };
539 static const WCHAR fld_mon
[] = { 'S', 'e', 'p', 't', 'e', 'm', 'b', 'e', 'r', 0 };
540 static const WCHAR fld_mon3
[] = { 'D', 'e', 'c', 0 };
546 TRACE ("%d,%d\n", infoPtr
->nrFields
, count
);
547 if (count
>infoPtr
->nrFields
|| count
< 0) {
548 WARN ("buffer overrun, have %d want %d\n", infoPtr
->nrFields
, count
);
552 if (!infoPtr
->fieldspec
) return;
554 spec
= infoPtr
->fieldspec
[count
];
555 if (spec
& DT_STRING
) {
556 int txtlen
= infoPtr
->buflen
[count
];
560 memcpy (buffer
, infoPtr
->textbuf
+ (spec
&~ DT_STRING
), txtlen
* sizeof(WCHAR
));
573 /* these seem to use a two byte field */
583 case INVALIDFULLYEAR
:
610 GetTextExtentPoint32W (hdc
, bufptr
, strlenW(bufptr
), &size
);
611 *fieldWidthPtr
= size
.cx
;
615 DATETIME_Refresh (DATETIME_INFO
*infoPtr
, HDC hdc
)
619 RECT
*rcDraw
= &infoPtr
->rcDraw
;
620 RECT
*calbutton
= &infoPtr
->calbutton
;
621 RECT
*checkbox
= &infoPtr
->checkbox
;
623 COLORREF oldTextColor
;
624 SHORT fieldWidth
= 0;
626 /* draw control edge */
629 if (infoPtr
->dateValid
) {
630 HFONT oldFont
= SelectObject (hdc
, infoPtr
->hFont
);
631 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
634 DATETIME_ReturnTxt (infoPtr
, 0, txt
, sizeof(txt
)/sizeof(txt
[0]));
635 GetTextExtentPoint32W (hdc
, txt
, strlenW(txt
), &size
);
636 rcDraw
->bottom
= size
.cy
+ 2;
638 prevright
= checkbox
->right
= ((infoPtr
->dwStyle
& DTS_SHOWNONE
) ? 18 : 2);
640 for (i
= 0; i
< infoPtr
->nrFields
; i
++) {
641 DATETIME_ReturnTxt (infoPtr
, i
, txt
, sizeof(txt
)/sizeof(txt
[0]));
642 GetTextExtentPoint32W (hdc
, txt
, strlenW(txt
), &size
);
643 DATETIME_ReturnFieldWidth (infoPtr
, hdc
, i
, &fieldWidth
);
644 field
= &infoPtr
->fieldRect
[i
];
645 field
->left
= prevright
;
646 field
->right
= prevright
+ fieldWidth
;
647 field
->top
= rcDraw
->top
;
648 field
->bottom
= rcDraw
->bottom
;
649 prevright
= field
->right
;
651 if (infoPtr
->dwStyle
& WS_DISABLED
)
652 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrGrayText
);
653 else if ((infoPtr
->haveFocus
) && (i
== infoPtr
->select
)) {
654 /* fill if focussed */
655 HBRUSH hbr
= CreateSolidBrush (comctl32_color
.clrActiveCaption
);
656 FillRect(hdc
, field
, hbr
);
658 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrWindow
);
661 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrWindowText
);
663 /* draw the date text using the colour set above */
664 DrawTextW (hdc
, txt
, strlenW(txt
), field
, DT_RIGHT
| DT_VCENTER
| DT_SINGLELINE
);
665 SetTextColor (hdc
, oldTextColor
);
667 SetBkMode (hdc
, oldBkMode
);
668 SelectObject (hdc
, oldFont
);
671 if (!(infoPtr
->dwStyle
& DTS_UPDOWN
)) {
672 DrawFrameControl(hdc
, calbutton
, DFC_SCROLL
,
673 DFCS_SCROLLDOWN
| (infoPtr
->bCalDepressed
? DFCS_PUSHED
: 0) |
674 (infoPtr
->dwStyle
& WS_DISABLED
? DFCS_INACTIVE
: 0) );
680 DATETIME_HitTest (const DATETIME_INFO
*infoPtr
, POINT pt
)
684 TRACE ("%d, %d\n", pt
.x
, pt
.y
);
686 if (PtInRect (&infoPtr
->calbutton
, pt
)) return DTHT_MCPOPUP
;
687 if (PtInRect (&infoPtr
->checkbox
, pt
)) return DTHT_CHECKBOX
;
689 for (i
=0; i
< infoPtr
->nrFields
; i
++) {
690 if (PtInRect (&infoPtr
->fieldRect
[i
], pt
)) return i
;
698 DATETIME_LButtonDown (DATETIME_INFO
*infoPtr
, WORD wKey
, INT x
, INT y
)
705 old
= infoPtr
->select
;
706 new = DATETIME_HitTest (infoPtr
, pt
);
708 /* FIXME: might be conditions where we don't want to update infoPtr->select */
709 infoPtr
->select
= new;
711 SetFocus(infoPtr
->hwndSelf
);
713 if (infoPtr
->select
== DTHT_MCPOPUP
) {
715 SendMessageW(infoPtr
->hMonthCal
, MCM_GETMINREQRECT
, 0, (LPARAM
)&rcMonthCal
);
717 /* FIXME: button actually is only depressed during dropdown of the */
718 /* calendar control and when the mouse is over the button window */
719 infoPtr
->bCalDepressed
= TRUE
;
721 /* recalculate the position of the monthcal popup */
722 if(infoPtr
->dwStyle
& DTS_RIGHTALIGN
)
723 infoPtr
->monthcal_pos
.x
= infoPtr
->calbutton
.left
-
724 (rcMonthCal
.right
- rcMonthCal
.left
);
726 /* FIXME: this should be after the area reserved for the checkbox */
727 infoPtr
->monthcal_pos
.x
= infoPtr
->rcDraw
.left
;
729 infoPtr
->monthcal_pos
.y
= infoPtr
->rcClient
.bottom
;
730 ClientToScreen (infoPtr
->hwndSelf
, &(infoPtr
->monthcal_pos
));
731 SetWindowPos(infoPtr
->hMonthCal
, 0, infoPtr
->monthcal_pos
.x
,
732 infoPtr
->monthcal_pos
.y
, rcMonthCal
.right
- rcMonthCal
.left
,
733 rcMonthCal
.bottom
- rcMonthCal
.top
, 0);
735 if(IsWindowVisible(infoPtr
->hMonthCal
)) {
736 ShowWindow(infoPtr
->hMonthCal
, SW_HIDE
);
738 const SYSTEMTIME
*lprgSysTimeArray
= &infoPtr
->date
;
739 TRACE("update calendar %04d/%02d/%02d\n",
740 lprgSysTimeArray
->wYear
, lprgSysTimeArray
->wMonth
, lprgSysTimeArray
->wDay
);
741 SendMessageW(infoPtr
->hMonthCal
, MCM_SETCURSEL
, 0, (LPARAM
)(&infoPtr
->date
));
742 ShowWindow(infoPtr
->hMonthCal
, SW_SHOW
);
745 TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p\n",
746 infoPtr
->hwndSelf
, infoPtr
->hMonthCal
, infoPtr
->hwndNotify
, GetDesktopWindow ());
747 DATETIME_SendSimpleNotify (infoPtr
, DTN_DROPDOWN
);
750 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
757 DATETIME_LButtonUp (DATETIME_INFO
*infoPtr
, WORD wKey
)
759 if(infoPtr
->bCalDepressed
) {
760 infoPtr
->bCalDepressed
= FALSE
;
761 InvalidateRect(infoPtr
->hwndSelf
, &(infoPtr
->calbutton
), TRUE
);
769 DATETIME_Paint (DATETIME_INFO
*infoPtr
, HDC hdc
)
773 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
774 DATETIME_Refresh (infoPtr
, hdc
);
775 EndPaint (infoPtr
->hwndSelf
, &ps
);
777 DATETIME_Refresh (infoPtr
, hdc
);
784 DATETIME_Button_Command (DATETIME_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
786 if( HIWORD(wParam
) == BN_CLICKED
) {
787 DWORD state
= SendMessageW((HWND
)lParam
, BM_GETCHECK
, 0, 0);
788 infoPtr
->dateValid
= (state
== BST_CHECKED
);
789 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
797 DATETIME_Command (DATETIME_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
799 TRACE("hwndbutton = %p\n", infoPtr
->hwndCheckbut
);
800 if(infoPtr
->hwndCheckbut
== (HWND
)lParam
)
801 return DATETIME_Button_Command(infoPtr
, wParam
, lParam
);
807 DATETIME_Enable (DATETIME_INFO
*infoPtr
, BOOL bEnable
)
809 TRACE("%p %s\n", infoPtr
, bEnable
? "TRUE" : "FALSE");
811 infoPtr
->dwStyle
&= ~WS_DISABLED
;
813 infoPtr
->dwStyle
|= WS_DISABLED
;
819 DATETIME_EraseBackground (const DATETIME_INFO
*infoPtr
, HDC hdc
)
821 HBRUSH hBrush
, hSolidBrush
= NULL
;
824 if (infoPtr
->dwStyle
& WS_DISABLED
)
825 hBrush
= hSolidBrush
= CreateSolidBrush(comctl32_color
.clrBtnFace
);
828 hBrush
= (HBRUSH
)SendMessageW(infoPtr
->hwndNotify
, WM_CTLCOLOREDIT
,
829 (WPARAM
)hdc
, (LPARAM
)infoPtr
->hwndSelf
);
831 hBrush
= hSolidBrush
= CreateSolidBrush(comctl32_color
.clrWindow
);
834 GetClientRect (infoPtr
->hwndSelf
, &rc
);
836 FillRect (hdc
, &rc
, hBrush
);
839 DeleteObject(hSolidBrush
);
846 DATETIME_Notify (DATETIME_INFO
*infoPtr
, int idCtrl
, LPNMHDR lpnmh
)
848 TRACE ("Got notification %x from %p\n", lpnmh
->code
, lpnmh
->hwndFrom
);
849 TRACE ("info: %p %p %p\n", infoPtr
->hwndSelf
, infoPtr
->hMonthCal
, infoPtr
->hUpdown
);
851 if (lpnmh
->code
== MCN_SELECT
) {
852 ShowWindow(infoPtr
->hMonthCal
, SW_HIDE
);
853 infoPtr
->dateValid
= TRUE
;
854 SendMessageW (infoPtr
->hMonthCal
, MCM_GETCURSEL
, 0, (LPARAM
)&infoPtr
->date
);
855 TRACE("got from calendar %04d/%02d/%02d day of week %d\n",
856 infoPtr
->date
.wYear
, infoPtr
->date
.wMonth
, infoPtr
->date
.wDay
, infoPtr
->date
.wDayOfWeek
);
857 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_CHECKED
, 0);
858 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
859 DATETIME_SendDateTimeChangeNotify (infoPtr
);
861 if ((lpnmh
->hwndFrom
== infoPtr
->hUpdown
) && (lpnmh
->code
== UDN_DELTAPOS
)) {
862 LPNMUPDOWN lpnmud
= (LPNMUPDOWN
)lpnmh
;
863 TRACE("Delta pos %d\n", lpnmud
->iDelta
);
864 infoPtr
->pendingUpdown
= lpnmud
->iDelta
;
871 DATETIME_KeyDown (DATETIME_INFO
*infoPtr
, DWORD vkCode
, LPARAM flags
)
873 int fieldNum
= infoPtr
->select
& DTHT_DATEFIELD
;
876 if (!(infoPtr
->haveFocus
)) return 0;
877 if ((fieldNum
==0) && (infoPtr
->select
)) return 0;
879 if (infoPtr
->select
& FORMATCALLMASK
) {
880 FIXME ("Callbacks not implemented yet\n");
883 if (vkCode
>= '0' && vkCode
<= '9') {
884 /* this is a somewhat simplified version of what Windows does */
885 SYSTEMTIME
*date
= &infoPtr
->date
;
886 switch (infoPtr
->fieldspec
[fieldNum
]) {
889 date
->wYear
= date
->wYear
- (date
->wYear
%100) +
890 (date
->wYear
%10)*10 + (vkCode
-'0');
891 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
892 date
->wDay
,date
->wMonth
,date
->wYear
);
893 DATETIME_SendDateTimeChangeNotify (infoPtr
);
895 case INVALIDFULLYEAR
:
897 date
->wYear
= (date
->wYear
%1000)*10 + (vkCode
-'0');
898 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
899 date
->wDay
,date
->wMonth
,date
->wYear
);
900 DATETIME_SendDateTimeChangeNotify (infoPtr
);
904 if ((date
->wMonth
%10) > 1 || (vkCode
-'0') > 2)
905 date
->wMonth
= vkCode
-'0';
907 date
->wMonth
= (date
->wMonth
%10)*10+vkCode
-'0';
908 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
909 date
->wDay
,date
->wMonth
,date
->wYear
);
910 DATETIME_SendDateTimeChangeNotify (infoPtr
);
914 /* probably better checking here would help */
915 if ((date
->wDay
%10) >= 3 && (vkCode
-'0') > 1)
916 date
->wDay
= vkCode
-'0';
918 date
->wDay
= (date
->wDay
%10)*10+vkCode
-'0';
919 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
920 date
->wDay
,date
->wMonth
,date
->wYear
);
921 DATETIME_SendDateTimeChangeNotify (infoPtr
);
925 if ((date
->wHour
%10) > 1 || (vkCode
-'0') > 2)
926 date
->wHour
= vkCode
-'0';
928 date
->wHour
= (date
->wHour
%10)*10+vkCode
-'0';
929 DATETIME_SendDateTimeChangeNotify (infoPtr
);
933 if ((date
->wHour
%10) > 2)
934 date
->wHour
= vkCode
-'0';
935 else if ((date
->wHour
%10) == 2 && (vkCode
-'0') > 3)
936 date
->wHour
= vkCode
-'0';
938 date
->wHour
= (date
->wHour
%10)*10+vkCode
-'0';
939 DATETIME_SendDateTimeChangeNotify (infoPtr
);
943 if ((date
->wMinute
%10) > 5)
944 date
->wMinute
= vkCode
-'0';
946 date
->wMinute
= (date
->wMinute
%10)*10+vkCode
-'0';
947 DATETIME_SendDateTimeChangeNotify (infoPtr
);
951 if ((date
->wSecond
%10) > 5)
952 date
->wSecond
= vkCode
-'0';
954 date
->wSecond
= (date
->wSecond
%10)*10+vkCode
-'0';
955 DATETIME_SendDateTimeChangeNotify (infoPtr
);
963 DATETIME_IncreaseField (infoPtr
, fieldNum
, 1);
964 DATETIME_SendDateTimeChangeNotify (infoPtr
);
968 DATETIME_IncreaseField (infoPtr
, fieldNum
, -1);
969 DATETIME_SendDateTimeChangeNotify (infoPtr
);
972 DATETIME_IncreaseField (infoPtr
, fieldNum
, INT_MIN
);
973 DATETIME_SendDateTimeChangeNotify (infoPtr
);
976 DATETIME_IncreaseField (infoPtr
, fieldNum
, INT_MAX
);
977 DATETIME_SendDateTimeChangeNotify (infoPtr
);
981 if (infoPtr
->select
== 0) {
982 infoPtr
->select
= infoPtr
->nrFields
- 1;
987 } while ((infoPtr
->fieldspec
[infoPtr
->select
] & DT_STRING
) && (wrap
<2));
992 if (infoPtr
->select
==infoPtr
->nrFields
) {
996 } while ((infoPtr
->fieldspec
[infoPtr
->select
] & DT_STRING
) && (wrap
<2));
1000 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1007 DATETIME_VScroll (DATETIME_INFO
*infoPtr
, WORD wScroll
)
1009 int fieldNum
= infoPtr
->select
& DTHT_DATEFIELD
;
1011 if ((SHORT
)LOWORD(wScroll
) != SB_THUMBPOSITION
) return 0;
1012 if (!(infoPtr
->haveFocus
)) return 0;
1013 if ((fieldNum
==0) && (infoPtr
->select
)) return 0;
1015 if (infoPtr
->pendingUpdown
>= 0) {
1016 DATETIME_IncreaseField (infoPtr
, fieldNum
, 1);
1017 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1020 DATETIME_IncreaseField (infoPtr
, fieldNum
, -1);
1021 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1024 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1031 DATETIME_KillFocus (DATETIME_INFO
*infoPtr
, HWND lostFocus
)
1033 TRACE("lost focus to %p\n", lostFocus
);
1035 if (infoPtr
->haveFocus
) {
1036 DATETIME_SendSimpleNotify (infoPtr
, NM_KILLFOCUS
);
1037 infoPtr
->haveFocus
= 0;
1040 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
1047 DATETIME_NCCreate (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
1049 DWORD dwExStyle
= GetWindowLongW(hwnd
, GWL_EXSTYLE
);
1050 /* force control to have client edge */
1051 dwExStyle
|= WS_EX_CLIENTEDGE
;
1052 SetWindowLongW(hwnd
, GWL_EXSTYLE
, dwExStyle
);
1054 return DefWindowProcW(hwnd
, WM_NCCREATE
, 0, (LPARAM
)lpcs
);
1059 DATETIME_SetFocus (DATETIME_INFO
*infoPtr
, HWND lostFocus
)
1061 TRACE("got focus from %p\n", lostFocus
);
1063 if (infoPtr
->haveFocus
== 0) {
1064 DATETIME_SendSimpleNotify (infoPtr
, NM_SETFOCUS
);
1065 infoPtr
->haveFocus
= DTHT_GOTFOCUS
;
1068 InvalidateRect(infoPtr
->hwndSelf
, NULL
, FALSE
);
1075 DATETIME_SendDateTimeChangeNotify (const DATETIME_INFO
*infoPtr
)
1077 NMDATETIMECHANGE dtdtc
;
1079 dtdtc
.nmhdr
.hwndFrom
= infoPtr
->hwndSelf
;
1080 dtdtc
.nmhdr
.idFrom
= GetWindowLongPtrW(infoPtr
->hwndSelf
, GWLP_ID
);
1081 dtdtc
.nmhdr
.code
= DTN_DATETIMECHANGE
;
1083 dtdtc
.dwFlags
= (infoPtr
->dwStyle
& DTS_SHOWNONE
) ? GDT_NONE
: GDT_VALID
;
1085 MONTHCAL_CopyTime (&infoPtr
->date
, &dtdtc
.st
);
1086 return (BOOL
) SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
1087 (WPARAM
)dtdtc
.nmhdr
.idFrom
, (LPARAM
)&dtdtc
);
1092 DATETIME_SendSimpleNotify (const DATETIME_INFO
*infoPtr
, UINT code
)
1096 TRACE("%x\n", code
);
1097 nmhdr
.hwndFrom
= infoPtr
->hwndSelf
;
1098 nmhdr
.idFrom
= GetWindowLongPtrW(infoPtr
->hwndSelf
, GWLP_ID
);
1101 return (BOOL
) SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
1102 (WPARAM
)nmhdr
.idFrom
, (LPARAM
)&nmhdr
);
1106 DATETIME_Size (DATETIME_INFO
*infoPtr
, WORD flags
, INT width
, INT height
)
1109 infoPtr
->rcClient
.bottom
= height
;
1110 infoPtr
->rcClient
.right
= width
;
1112 TRACE("Height=%d, Width=%d\n", infoPtr
->rcClient
.bottom
, infoPtr
->rcClient
.right
);
1114 infoPtr
->rcDraw
= infoPtr
->rcClient
;
1116 if (infoPtr
->dwStyle
& DTS_UPDOWN
) {
1117 SetWindowPos(infoPtr
->hUpdown
, NULL
,
1118 infoPtr
->rcClient
.right
-14, 0,
1119 15, infoPtr
->rcClient
.bottom
- infoPtr
->rcClient
.top
,
1120 SWP_NOACTIVATE
| SWP_NOZORDER
);
1123 /* set the size of the button that drops the calendar down */
1124 /* FIXME: account for style that allows button on left side */
1125 infoPtr
->calbutton
.top
= infoPtr
->rcDraw
.top
;
1126 infoPtr
->calbutton
.bottom
= infoPtr
->rcDraw
.bottom
;
1127 infoPtr
->calbutton
.left
= infoPtr
->rcDraw
.right
-15;
1128 infoPtr
->calbutton
.right
= infoPtr
->rcDraw
.right
;
1131 /* set enable/disable button size for show none style being enabled */
1132 /* FIXME: these dimensions are completely incorrect */
1133 infoPtr
->checkbox
.top
= infoPtr
->rcDraw
.top
;
1134 infoPtr
->checkbox
.bottom
= infoPtr
->rcDraw
.bottom
;
1135 infoPtr
->checkbox
.left
= infoPtr
->rcDraw
.left
;
1136 infoPtr
->checkbox
.right
= infoPtr
->rcDraw
.left
+ 10;
1138 InvalidateRect(infoPtr
->hwndSelf
, NULL
, FALSE
);
1145 DATETIME_StyleChanged(DATETIME_INFO
*infoPtr
, WPARAM wStyleType
, const STYLESTRUCT
*lpss
)
1147 static const WCHAR buttonW
[] = { 'b', 'u', 't', 't', 'o', 'n', 0 };
1149 TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
1150 wStyleType
, lpss
->styleOld
, lpss
->styleNew
);
1152 if (wStyleType
!= GWL_STYLE
) return 0;
1154 infoPtr
->dwStyle
= lpss
->styleNew
;
1156 if ( !(lpss
->styleOld
& DTS_SHOWNONE
) && (lpss
->styleNew
& DTS_SHOWNONE
) ) {
1157 infoPtr
->hwndCheckbut
= CreateWindowExW (0, buttonW
, 0, WS_CHILD
| WS_VISIBLE
| BS_AUTOCHECKBOX
,
1158 2, 2, 13, 13, infoPtr
->hwndSelf
, 0,
1159 (HINSTANCE
)GetWindowLongPtrW (infoPtr
->hwndSelf
, GWLP_HINSTANCE
), 0);
1160 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, 1, 0);
1162 if ( (lpss
->styleOld
& DTS_SHOWNONE
) && !(lpss
->styleNew
& DTS_SHOWNONE
) ) {
1163 DestroyWindow(infoPtr
->hwndCheckbut
);
1164 infoPtr
->hwndCheckbut
= 0;
1166 if ( !(lpss
->styleOld
& DTS_UPDOWN
) && (lpss
->styleNew
& DTS_UPDOWN
) ) {
1167 infoPtr
->hUpdown
= CreateUpDownControl (WS_CHILD
| WS_BORDER
| WS_VISIBLE
, 120, 1, 20, 20,
1168 infoPtr
->hwndSelf
, 1, 0, 0, UD_MAXVAL
, UD_MINVAL
, 0);
1170 if ( (lpss
->styleOld
& DTS_UPDOWN
) && !(lpss
->styleNew
& DTS_UPDOWN
) ) {
1171 DestroyWindow(infoPtr
->hUpdown
);
1172 infoPtr
->hUpdown
= 0;
1175 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1181 DATETIME_SetFont (DATETIME_INFO
*infoPtr
, HFONT font
, BOOL repaint
)
1183 infoPtr
->hFont
= font
;
1184 if (repaint
) InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1190 DATETIME_Create (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
1192 static const WCHAR SysMonthCal32W
[] = { 'S', 'y', 's', 'M', 'o', 'n', 't', 'h', 'C', 'a', 'l', '3', '2', 0 };
1193 DATETIME_INFO
*infoPtr
= (DATETIME_INFO
*)Alloc (sizeof(DATETIME_INFO
));
1194 STYLESTRUCT ss
= { 0, lpcs
->style
};
1196 if (!infoPtr
) return -1;
1198 infoPtr
->hwndSelf
= hwnd
;
1199 infoPtr
->dwStyle
= lpcs
->style
;
1201 infoPtr
->nrFieldsAllocated
= 32;
1202 infoPtr
->fieldspec
= (int *) Alloc (infoPtr
->nrFieldsAllocated
* sizeof(int));
1203 infoPtr
->fieldRect
= (RECT
*) Alloc (infoPtr
->nrFieldsAllocated
* sizeof(RECT
));
1204 infoPtr
->buflen
= (int *) Alloc (infoPtr
->nrFieldsAllocated
* sizeof(int));
1205 infoPtr
->hwndNotify
= lpcs
->hwndParent
;
1206 infoPtr
->select
= -1; /* initially, nothing is selected */
1208 DATETIME_StyleChanged(infoPtr
, GWL_STYLE
, &ss
);
1209 DATETIME_SetFormatW (infoPtr
, 0);
1211 /* create the monthcal control */
1212 infoPtr
->hMonthCal
= CreateWindowExW (0, SysMonthCal32W
, 0, WS_BORDER
| WS_POPUP
| WS_CLIPSIBLINGS
,
1213 0, 0, 0, 0, infoPtr
->hwndSelf
, 0, 0, 0);
1215 /* initialize info structure */
1216 GetLocalTime (&infoPtr
->date
);
1217 infoPtr
->dateValid
= TRUE
;
1218 infoPtr
->hFont
= GetStockObject(DEFAULT_GUI_FONT
);
1220 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
1228 DATETIME_Destroy (DATETIME_INFO
*infoPtr
)
1230 if (infoPtr
->hwndCheckbut
)
1231 DestroyWindow(infoPtr
->hwndCheckbut
);
1232 if (infoPtr
->hUpdown
)
1233 DestroyWindow(infoPtr
->hUpdown
);
1234 if (infoPtr
->hMonthCal
)
1235 DestroyWindow(infoPtr
->hMonthCal
);
1236 SetWindowLongPtrW( infoPtr
->hwndSelf
, 0, 0 ); /* clear infoPtr */
1242 static LRESULT WINAPI
1243 DATETIME_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1245 DATETIME_INFO
*infoPtr
= ((DATETIME_INFO
*)GetWindowLongPtrW (hwnd
, 0));
1248 TRACE ("%x, %lx, %lx\n", uMsg
, wParam
, lParam
);
1250 if (!infoPtr
&& (uMsg
!= WM_CREATE
) && (uMsg
!= WM_NCCREATE
))
1251 return DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
1255 case DTM_GETSYSTEMTIME
:
1256 return DATETIME_GetSystemTime (infoPtr
, (SYSTEMTIME
*) lParam
);
1258 case DTM_SETSYSTEMTIME
:
1259 return DATETIME_SetSystemTime (infoPtr
, wParam
, (SYSTEMTIME
*) lParam
);
1262 ret
= SendMessageW (infoPtr
->hMonthCal
, MCM_GETRANGE
, wParam
, lParam
);
1263 return ret
? ret
: 1; /* bug emulation */
1266 return SendMessageW (infoPtr
->hMonthCal
, MCM_SETRANGE
, wParam
, lParam
);
1268 case DTM_SETFORMATA
:
1269 return DATETIME_SetFormatA (infoPtr
, (LPCSTR
)lParam
);
1271 case DTM_SETFORMATW
:
1272 return DATETIME_SetFormatW (infoPtr
, (LPCWSTR
)lParam
);
1274 case DTM_GETMONTHCAL
:
1275 return (LRESULT
)infoPtr
->hMonthCal
;
1277 case DTM_SETMCCOLOR
:
1278 return SendMessageW (infoPtr
->hMonthCal
, MCM_SETCOLOR
, wParam
, lParam
);
1280 case DTM_GETMCCOLOR
:
1281 return SendMessageW (infoPtr
->hMonthCal
, MCM_GETCOLOR
, wParam
, 0);
1284 return SendMessageW (infoPtr
->hMonthCal
, WM_SETFONT
, wParam
, lParam
);
1287 return SendMessageW (infoPtr
->hMonthCal
, WM_GETFONT
, wParam
, lParam
);
1290 return DATETIME_Notify (infoPtr
, (int)wParam
, (LPNMHDR
)lParam
);
1293 return DATETIME_Enable (infoPtr
, (BOOL
)wParam
);
1296 return DATETIME_EraseBackground (infoPtr
, (HDC
)wParam
);
1299 return DLGC_WANTARROWS
| DLGC_WANTCHARS
;
1301 case WM_PRINTCLIENT
:
1303 return DATETIME_Paint (infoPtr
, (HDC
)wParam
);
1306 return DATETIME_KeyDown (infoPtr
, wParam
, lParam
);
1309 return DATETIME_KillFocus (infoPtr
, (HWND
)wParam
);
1312 return DATETIME_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
1315 return DATETIME_SetFocus (infoPtr
, (HWND
)wParam
);
1318 return DATETIME_Size (infoPtr
, wParam
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
1320 case WM_LBUTTONDOWN
:
1321 return DATETIME_LButtonDown (infoPtr
, (WORD
)wParam
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
1324 return DATETIME_LButtonUp (infoPtr
, (WORD
)wParam
);
1327 return DATETIME_VScroll (infoPtr
, (WORD
)wParam
);
1330 return DATETIME_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
1333 return DATETIME_Destroy (infoPtr
);
1336 return DATETIME_Command (infoPtr
, wParam
, lParam
);
1338 case WM_STYLECHANGED
:
1339 return DATETIME_StyleChanged(infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
1342 return DATETIME_SetFont(infoPtr
, (HFONT
)wParam
, (BOOL
)lParam
);
1345 return (LRESULT
) infoPtr
->hFont
;
1348 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
1349 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
1350 uMsg
, wParam
, lParam
);
1351 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
1357 DATETIME_Register (void)
1361 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
1362 wndClass
.style
= CS_GLOBALCLASS
;
1363 wndClass
.lpfnWndProc
= DATETIME_WindowProc
;
1364 wndClass
.cbClsExtra
= 0;
1365 wndClass
.cbWndExtra
= sizeof(DATETIME_INFO
*);
1366 wndClass
.hCursor
= LoadCursorW (0, (LPCWSTR
)IDC_ARROW
);
1367 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
1368 wndClass
.lpszClassName
= DATETIMEPICK_CLASSW
;
1370 RegisterClassW (&wndClass
);
1375 DATETIME_Unregister (void)
1377 UnregisterClassW (DATETIMEPICK_CLASSW
, NULL
);