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 */
78 int nrFieldsAllocated
;
87 } DATETIME_INFO
, *LPDATETIME_INFO
;
90 extern int MONTHCAL_MonthLength(int month
, int year
);
91 extern int MONTHCAL_CalculateDayOfWeek(DWORD day
, DWORD month
, DWORD year
);
93 /* this list of defines is closely related to `allowedformatchars' defined
94 * in datetime.c; the high nibble indicates the `base type' of the format
96 * Do not change without first reading DATETIME_UseFormat.
100 #define DT_END_FORMAT 0
101 #define ONEDIGITDAY 0x01
102 #define TWODIGITDAY 0x02
103 #define THREECHARDAY 0x03
105 #define ONEDIGIT12HOUR 0x11
106 #define TWODIGIT12HOUR 0x12
107 #define ONEDIGIT24HOUR 0x21
108 #define TWODIGIT24HOUR 0x22
109 #define ONEDIGITMINUTE 0x31
110 #define TWODIGITMINUTE 0x32
111 #define ONEDIGITMONTH 0x41
112 #define TWODIGITMONTH 0x42
113 #define THREECHARMONTH 0x43
114 #define FULLMONTH 0x44
115 #define ONEDIGITSECOND 0x51
116 #define TWODIGITSECOND 0x52
117 #define ONELETTERAMPM 0x61
118 #define TWOLETTERAMPM 0x62
119 #define ONEDIGITYEAR 0x71
120 #define TWODIGITYEAR 0x72
121 #define INVALIDFULLYEAR 0x73 /* FIXME - yyy is not valid - we'll treat it as yyyy */
122 #define FULLYEAR 0x74
123 #define FORMATCALLBACK 0x81 /* -> maximum of 0x80 callbacks possible */
124 #define FORMATCALLMASK 0x80
125 #define DT_STRING 0x0100
127 #define DTHT_DATEFIELD 0xff /* for hit-testing */
130 #define DTHT_CHECKBOX 0x200 /* these should end at '00' , to make */
131 #define DTHT_MCPOPUP 0x300 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
132 #define DTHT_GOTFOCUS 0x400 /* tests for date-fields */
134 static BOOL
DATETIME_SendSimpleNotify (const DATETIME_INFO
*infoPtr
, UINT code
);
135 static BOOL
DATETIME_SendDateTimeChangeNotify (const DATETIME_INFO
*infoPtr
);
136 extern void MONTHCAL_CopyTime(const SYSTEMTIME
*from
, SYSTEMTIME
*to
);
137 static const WCHAR allowedformatchars
[] = {'d', 'h', 'H', 'm', 'M', 's', 't', 'y', 'X', 0};
138 static const int maxrepetition
[] = {4,2,2,2,4,2,2,4,-1};
142 DATETIME_GetSystemTime (const DATETIME_INFO
*infoPtr
, SYSTEMTIME
*systime
)
144 if (!systime
) return GDT_NONE
;
146 if ((infoPtr
->dwStyle
& DTS_SHOWNONE
) &&
147 (SendMessageW (infoPtr
->hwndCheckbut
, BM_GETCHECK
, 0, 0) == BST_UNCHECKED
))
150 *systime
= infoPtr
->date
;
157 DATETIME_SetSystemTime (DATETIME_INFO
*infoPtr
, DWORD flag
, const SYSTEMTIME
*systime
)
159 if (!systime
) return 0;
161 TRACE("%04d/%02d/%02d %02d:%02d:%02d\n",
162 systime
->wYear
, systime
->wMonth
, systime
->wDay
,
163 systime
->wHour
, systime
->wMinute
, systime
->wSecond
);
165 if (flag
== GDT_VALID
) {
166 if (systime
->wYear
< 1601 || systime
->wYear
> 30827 ||
167 systime
->wMonth
< 1 || systime
->wMonth
> 12 ||
168 systime
->wDay
< 1 || systime
->wDay
> 31 ||
169 systime
->wHour
> 23 ||
170 systime
->wMinute
> 59 ||
171 systime
->wSecond
> 59 ||
172 systime
->wMilliseconds
> 999
176 infoPtr
->dateValid
= TRUE
;
177 infoPtr
->date
= *systime
;
178 /* always store a valid day of week */
179 infoPtr
->date
.wDayOfWeek
=
180 MONTHCAL_CalculateDayOfWeek(infoPtr
->date
.wDay
, infoPtr
->date
.wMonth
,
181 infoPtr
->date
.wYear
);
183 SendMessageW (infoPtr
->hMonthCal
, MCM_SETCURSEL
, 0, (LPARAM
)(&infoPtr
->date
));
184 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_CHECKED
, 0);
185 } else if ((infoPtr
->dwStyle
& DTS_SHOWNONE
) && (flag
== GDT_NONE
)) {
186 infoPtr
->dateValid
= FALSE
;
187 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_UNCHECKED
, 0);
192 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
198 * Split up a formattxt in actions.
199 * See ms documentation for the meaning of the letter codes/'specifiers'.
202 * *'dddddd' is handled as 'dddd' plus 'dd'.
203 * *unrecognized formats are strings (here given the type DT_STRING;
204 * start of the string is encoded in lower bits of DT_STRING.
205 * Therefore, 'string' ends finally up as '<show seconds>tring'.
209 DATETIME_UseFormat (DATETIME_INFO
*infoPtr
, LPCWSTR formattxt
)
213 BOOL inside_literal
= FALSE
; /* inside '...' */
214 int *nrFields
= &infoPtr
->nrFields
;
217 infoPtr
->fieldspec
[*nrFields
] = 0;
218 len
= strlenW(allowedformatchars
);
221 for (i
= 0; formattxt
[i
]; i
++) {
222 TRACE ("\n%d %c:", i
, formattxt
[i
]);
223 if (!inside_literal
) {
224 for (j
= 0; j
< len
; j
++) {
225 if (allowedformatchars
[j
]==formattxt
[i
]) {
226 TRACE ("%c[%d,%x]", allowedformatchars
[j
], *nrFields
, infoPtr
->fieldspec
[*nrFields
]);
227 if ((*nrFields
==0) && (infoPtr
->fieldspec
[*nrFields
]==0)) {
228 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
231 if (infoPtr
->fieldspec
[*nrFields
] >> 4 != j
) {
233 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
236 if ((infoPtr
->fieldspec
[*nrFields
] & 0x0f) == maxrepetition
[j
]) {
238 infoPtr
->fieldspec
[*nrFields
] = (j
<<4) + 1;
241 infoPtr
->fieldspec
[*nrFields
]++;
243 } /* if allowedformatchar */
249 if (formattxt
[i
] == '\'')
251 inside_literal
= !inside_literal
;
255 /* char is not a specifier: handle char like a string */
257 if ((*nrFields
==0) && (infoPtr
->fieldspec
[*nrFields
]==0)) {
258 infoPtr
->fieldspec
[*nrFields
] = DT_STRING
+ k
;
259 infoPtr
->buflen
[*nrFields
] = 0;
260 } else if ((infoPtr
->fieldspec
[*nrFields
] & DT_STRING
) != DT_STRING
) {
262 infoPtr
->fieldspec
[*nrFields
] = DT_STRING
+ k
;
263 infoPtr
->buflen
[*nrFields
] = 0;
265 infoPtr
->textbuf
[k
] = formattxt
[i
];
267 infoPtr
->buflen
[*nrFields
]++;
270 if (*nrFields
== infoPtr
->nrFieldsAllocated
) {
271 FIXME ("out of memory; should reallocate. crash ahead.\n");
277 if (infoPtr
->fieldspec
[*nrFields
] != 0) (*nrFields
)++;
282 DATETIME_SetFormatW (DATETIME_INFO
*infoPtr
, LPCWSTR lpszFormat
)
285 WCHAR format_buf
[80];
288 if (infoPtr
->dwStyle
& DTS_LONGDATEFORMAT
)
289 format_item
= LOCALE_SLONGDATE
;
290 else if ((infoPtr
->dwStyle
& DTS_TIMEFORMAT
) == DTS_TIMEFORMAT
)
291 format_item
= LOCALE_STIMEFORMAT
;
292 else /* DTS_SHORTDATEFORMAT */
293 format_item
= LOCALE_SSHORTDATE
;
294 GetLocaleInfoW( GetSystemDefaultLCID(), format_item
, format_buf
, sizeof(format_buf
)/sizeof(format_buf
[0]));
295 lpszFormat
= format_buf
;
298 DATETIME_UseFormat (infoPtr
, lpszFormat
);
299 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
306 DATETIME_SetFormatA (DATETIME_INFO
*infoPtr
, LPCSTR lpszFormat
)
310 INT len
= MultiByteToWideChar(CP_ACP
, 0, lpszFormat
, -1, NULL
, 0);
311 LPWSTR wstr
= Alloc(len
* sizeof(WCHAR
));
312 if (wstr
) MultiByteToWideChar(CP_ACP
, 0, lpszFormat
, -1, wstr
, len
);
313 retval
= DATETIME_SetFormatW (infoPtr
, wstr
);
318 return DATETIME_SetFormatW (infoPtr
, 0);
324 DATETIME_ReturnTxt (const DATETIME_INFO
*infoPtr
, int count
, LPWSTR result
, int resultSize
)
326 static const WCHAR fmt_dW
[] = { '%', 'd', 0 };
327 static const WCHAR fmt__2dW
[] = { '%', '.', '2', 'd', 0 };
328 static const WCHAR fmt__3sW
[] = { '%', '.', '3', 's', 0 };
329 SYSTEMTIME date
= infoPtr
->date
;
334 TRACE ("%d,%d\n", infoPtr
->nrFields
, count
);
335 if (count
>infoPtr
->nrFields
|| count
< 0) {
336 WARN ("buffer overrun, have %d want %d\n", infoPtr
->nrFields
, count
);
340 if (!infoPtr
->fieldspec
) return;
342 spec
= infoPtr
->fieldspec
[count
];
343 if (spec
& DT_STRING
) {
344 int txtlen
= infoPtr
->buflen
[count
];
346 if (txtlen
> resultSize
)
347 txtlen
= resultSize
- 1;
348 memcpy (result
, infoPtr
->textbuf
+ (spec
&~ DT_STRING
), txtlen
* sizeof(WCHAR
));
350 TRACE ("arg%d=%x->[%s]\n", count
, infoPtr
->fieldspec
[count
], debugstr_w(result
));
360 wsprintfW (result
, fmt_dW
, date
.wDay
);
363 wsprintfW (result
, fmt__2dW
, date
.wDay
);
366 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SABBREVDAYNAME1
+(date
.wDayOfWeek
+6)%7, result
, 4);
367 /*wsprintfW (result,"%.3s",days[date.wDayOfWeek]);*/
370 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SDAYNAME1
+(date
.wDayOfWeek
+6)%7, result
, resultSize
);
373 if (date
.wHour
== 0) {
379 wsprintfW (result
, fmt_dW
, date
.wHour
- (date
.wHour
> 12 ? 12 : 0));
382 if (date
.wHour
== 0) {
388 wsprintfW (result
, fmt__2dW
, date
.wHour
- (date
.wHour
> 12 ? 12 : 0));
391 wsprintfW (result
, fmt_dW
, date
.wHour
);
394 wsprintfW (result
, fmt__2dW
, date
.wHour
);
397 wsprintfW (result
, fmt_dW
, date
.wSecond
);
400 wsprintfW (result
, fmt__2dW
, date
.wSecond
);
403 wsprintfW (result
, fmt_dW
, date
.wMinute
);
406 wsprintfW (result
, fmt__2dW
, date
.wMinute
);
409 wsprintfW (result
, fmt_dW
, date
.wMonth
);
412 wsprintfW (result
, fmt__2dW
, date
.wMonth
);
415 GetLocaleInfoW(GetSystemDefaultLCID(), LOCALE_SMONTHNAME1
+date
.wMonth
-1,
416 buffer
, sizeof(buffer
)/sizeof(buffer
[0]));
417 wsprintfW (result
, fmt__3sW
, buffer
);
420 GetLocaleInfoW(GetSystemDefaultLCID(),LOCALE_SMONTHNAME1
+date
.wMonth
-1,
424 result
[0] = (date
.wHour
< 12 ? 'A' : 'P');
428 result
[0] = (date
.wHour
< 12 ? 'A' : 'P');
433 FIXME ("Not implemented\n");
438 wsprintfW (result
, fmt_dW
, date
.wYear
-10* (int) floor(date
.wYear
/10));
441 wsprintfW (result
, fmt__2dW
, date
.wYear
-100* (int) floor(date
.wYear
/100));
443 case INVALIDFULLYEAR
:
445 wsprintfW (result
, fmt_dW
, date
.wYear
);
449 TRACE ("arg%d=%x->[%s]\n", count
, infoPtr
->fieldspec
[count
], debugstr_w(result
));
452 /* Offsets of days in the week to the weekday of january 1 in a leap year. */
453 static const int DayOfWeekTable
[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
455 /* returns the day in the week(0 == sunday, 6 == saturday) */
456 /* day(1 == 1st, 2 == 2nd... etc), year is the year value */
457 static int DATETIME_CalculateDayOfWeek(DWORD day
, DWORD month
, DWORD year
)
461 return((year
+ year
/4 - year
/100 + year
/400 +
462 DayOfWeekTable
[month
-1] + day
) % 7);
465 static int wrap(int val
, int delta
, int minVal
, int maxVal
)
468 if (delta
== INT_MIN
|| val
< minVal
) return maxVal
;
469 if (delta
== INT_MAX
|| val
> maxVal
) return minVal
;
474 DATETIME_IncreaseField (DATETIME_INFO
*infoPtr
, int number
, int delta
)
476 SYSTEMTIME
*date
= &infoPtr
->date
;
478 TRACE ("%d\n", number
);
479 if ((number
> infoPtr
->nrFields
) || (number
< 0)) return;
481 if ((infoPtr
->fieldspec
[number
] & DTHT_DATEFIELD
) == 0) return;
483 switch (infoPtr
->fieldspec
[number
]) {
487 date
->wYear
= wrap(date
->wYear
, delta
, 1752, 9999);
488 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
494 date
->wMonth
= wrap(date
->wMonth
, delta
, 1, 12);
495 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
502 date
->wDay
= wrap(date
->wDay
, delta
, 1, MONTHCAL_MonthLength(date
->wMonth
, date
->wYear
));
503 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(date
->wDay
,date
->wMonth
,date
->wYear
);
513 date
->wHour
= wrap(date
->wHour
, delta
, 0, 23);
517 date
->wMinute
= wrap(date
->wMinute
, delta
, 0, 59);
521 date
->wSecond
= wrap(date
->wSecond
, delta
, 0, 59);
524 FIXME ("Not implemented\n");
528 /* FYI: On 1752/9/14 the calendar changed and England and the
529 * American colonies changed to the Gregorian calendar. This change
530 * involved having September 14th follow September 2nd. So no date
531 * algorithm works before that date.
533 if (10000 * date
->wYear
+ 100 * date
->wMonth
+ date
->wDay
< 17520914) {
545 DATETIME_ReturnFieldWidth (const DATETIME_INFO
*infoPtr
, HDC hdc
, int count
, SHORT
*fieldWidthPtr
)
547 /* fields are a fixed width, determined by the largest possible string */
548 /* presumably, these widths should be language dependent */
549 static const WCHAR fld_d1W
[] = { '2', 0 };
550 static const WCHAR fld_d2W
[] = { '2', '2', 0 };
551 static const WCHAR fld_d4W
[] = { '2', '2', '2', '2', 0 };
552 static const WCHAR fld_am1
[] = { 'A', 0 };
553 static const WCHAR fld_am2
[] = { 'A', 'M', 0 };
554 static const WCHAR fld_day
[] = { 'W', 'e', 'd', 'n', 'e', 's', 'd', 'a', 'y', 0 };
555 static const WCHAR fld_day3
[] = { 'W', 'e', 'd', 0 };
556 static const WCHAR fld_mon
[] = { 'S', 'e', 'p', 't', 'e', 'm', 'b', 'e', 'r', 0 };
557 static const WCHAR fld_mon3
[] = { 'D', 'e', 'c', 0 };
563 TRACE ("%d,%d\n", infoPtr
->nrFields
, count
);
564 if (count
>infoPtr
->nrFields
|| count
< 0) {
565 WARN ("buffer overrun, have %d want %d\n", infoPtr
->nrFields
, count
);
569 if (!infoPtr
->fieldspec
) return;
571 spec
= infoPtr
->fieldspec
[count
];
572 if (spec
& DT_STRING
) {
573 int txtlen
= infoPtr
->buflen
[count
];
577 memcpy (buffer
, infoPtr
->textbuf
+ (spec
&~ DT_STRING
), txtlen
* sizeof(WCHAR
));
590 /* these seem to use a two byte field */
600 case INVALIDFULLYEAR
:
627 GetTextExtentPoint32W (hdc
, bufptr
, strlenW(bufptr
), &size
);
628 *fieldWidthPtr
= size
.cx
;
632 DATETIME_Refresh (DATETIME_INFO
*infoPtr
, HDC hdc
)
636 RECT
*rcDraw
= &infoPtr
->rcDraw
;
637 RECT
*calbutton
= &infoPtr
->calbutton
;
638 RECT
*checkbox
= &infoPtr
->checkbox
;
640 COLORREF oldTextColor
;
641 SHORT fieldWidth
= 0;
643 /* draw control edge */
646 if (infoPtr
->dateValid
) {
647 HFONT oldFont
= SelectObject (hdc
, infoPtr
->hFont
);
648 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
651 DATETIME_ReturnTxt (infoPtr
, 0, txt
, sizeof(txt
)/sizeof(txt
[0]));
652 GetTextExtentPoint32W (hdc
, txt
, strlenW(txt
), &size
);
653 rcDraw
->bottom
= size
.cy
+ 2;
655 prevright
= checkbox
->right
= ((infoPtr
->dwStyle
& DTS_SHOWNONE
) ? 18 : 2);
657 for (i
= 0; i
< infoPtr
->nrFields
; i
++) {
658 DATETIME_ReturnTxt (infoPtr
, i
, txt
, sizeof(txt
)/sizeof(txt
[0]));
659 GetTextExtentPoint32W (hdc
, txt
, strlenW(txt
), &size
);
660 DATETIME_ReturnFieldWidth (infoPtr
, hdc
, i
, &fieldWidth
);
661 field
= &infoPtr
->fieldRect
[i
];
662 field
->left
= prevright
;
663 field
->right
= prevright
+ fieldWidth
;
664 field
->top
= rcDraw
->top
;
665 field
->bottom
= rcDraw
->bottom
;
666 prevright
= field
->right
;
668 if (infoPtr
->dwStyle
& WS_DISABLED
)
669 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrGrayText
);
670 else if ((infoPtr
->haveFocus
) && (i
== infoPtr
->select
)) {
671 /* fill if focussed */
672 HBRUSH hbr
= CreateSolidBrush (comctl32_color
.clrActiveCaption
);
673 FillRect(hdc
, field
, hbr
);
675 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrWindow
);
678 oldTextColor
= SetTextColor (hdc
, comctl32_color
.clrWindowText
);
680 /* draw the date text using the colour set above */
681 DrawTextW (hdc
, txt
, strlenW(txt
), field
, DT_RIGHT
| DT_VCENTER
| DT_SINGLELINE
);
682 SetTextColor (hdc
, oldTextColor
);
684 SetBkMode (hdc
, oldBkMode
);
685 SelectObject (hdc
, oldFont
);
688 if (!(infoPtr
->dwStyle
& DTS_UPDOWN
)) {
689 DrawFrameControl(hdc
, calbutton
, DFC_SCROLL
,
690 DFCS_SCROLLDOWN
| (infoPtr
->bCalDepressed
? DFCS_PUSHED
: 0) |
691 (infoPtr
->dwStyle
& WS_DISABLED
? DFCS_INACTIVE
: 0) );
697 DATETIME_HitTest (const DATETIME_INFO
*infoPtr
, POINT pt
)
701 TRACE ("%d, %d\n", pt
.x
, pt
.y
);
703 if (PtInRect (&infoPtr
->calbutton
, pt
)) return DTHT_MCPOPUP
;
704 if (PtInRect (&infoPtr
->checkbox
, pt
)) return DTHT_CHECKBOX
;
706 for (i
=0; i
< infoPtr
->nrFields
; i
++) {
707 if (PtInRect (&infoPtr
->fieldRect
[i
], pt
)) return i
;
715 DATETIME_LButtonDown (DATETIME_INFO
*infoPtr
, INT x
, INT y
)
722 old
= infoPtr
->select
;
723 new = DATETIME_HitTest (infoPtr
, pt
);
725 /* FIXME: might be conditions where we don't want to update infoPtr->select */
726 infoPtr
->select
= new;
728 SetFocus(infoPtr
->hwndSelf
);
730 if (infoPtr
->select
== DTHT_MCPOPUP
) {
732 SendMessageW(infoPtr
->hMonthCal
, MCM_GETMINREQRECT
, 0, (LPARAM
)&rcMonthCal
);
734 /* FIXME: button actually is only depressed during dropdown of the */
735 /* calendar control and when the mouse is over the button window */
736 infoPtr
->bCalDepressed
= TRUE
;
738 /* recalculate the position of the monthcal popup */
739 if(infoPtr
->dwStyle
& DTS_RIGHTALIGN
)
740 infoPtr
->monthcal_pos
.x
= infoPtr
->calbutton
.left
-
741 (rcMonthCal
.right
- rcMonthCal
.left
);
743 /* FIXME: this should be after the area reserved for the checkbox */
744 infoPtr
->monthcal_pos
.x
= infoPtr
->rcDraw
.left
;
746 infoPtr
->monthcal_pos
.y
= infoPtr
->rcClient
.bottom
;
747 ClientToScreen (infoPtr
->hwndSelf
, &(infoPtr
->monthcal_pos
));
748 SetWindowPos(infoPtr
->hMonthCal
, 0, infoPtr
->monthcal_pos
.x
,
749 infoPtr
->monthcal_pos
.y
, rcMonthCal
.right
- rcMonthCal
.left
,
750 rcMonthCal
.bottom
- rcMonthCal
.top
, 0);
752 if(IsWindowVisible(infoPtr
->hMonthCal
)) {
753 ShowWindow(infoPtr
->hMonthCal
, SW_HIDE
);
755 const SYSTEMTIME
*lprgSysTimeArray
= &infoPtr
->date
;
756 TRACE("update calendar %04d/%02d/%02d\n",
757 lprgSysTimeArray
->wYear
, lprgSysTimeArray
->wMonth
, lprgSysTimeArray
->wDay
);
758 SendMessageW(infoPtr
->hMonthCal
, MCM_SETCURSEL
, 0, (LPARAM
)(&infoPtr
->date
));
760 if (infoPtr
->bDropdownEnabled
)
761 ShowWindow(infoPtr
->hMonthCal
, SW_SHOW
);
762 infoPtr
->bDropdownEnabled
= TRUE
;
765 TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p\n",
766 infoPtr
->hwndSelf
, infoPtr
->hMonthCal
, infoPtr
->hwndNotify
, GetDesktopWindow ());
767 DATETIME_SendSimpleNotify (infoPtr
, DTN_DROPDOWN
);
770 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
777 DATETIME_LButtonUp (DATETIME_INFO
*infoPtr
)
779 if(infoPtr
->bCalDepressed
) {
780 infoPtr
->bCalDepressed
= FALSE
;
781 InvalidateRect(infoPtr
->hwndSelf
, &(infoPtr
->calbutton
), TRUE
);
789 DATETIME_Paint (DATETIME_INFO
*infoPtr
, HDC hdc
)
793 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
794 DATETIME_Refresh (infoPtr
, hdc
);
795 EndPaint (infoPtr
->hwndSelf
, &ps
);
797 DATETIME_Refresh (infoPtr
, hdc
);
800 /* Not a click on the dropdown box, enabled it */
801 infoPtr
->bDropdownEnabled
= TRUE
;
808 DATETIME_Button_Command (DATETIME_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
810 if( HIWORD(wParam
) == BN_CLICKED
) {
811 DWORD state
= SendMessageW((HWND
)lParam
, BM_GETCHECK
, 0, 0);
812 infoPtr
->dateValid
= (state
== BST_CHECKED
);
813 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
821 DATETIME_Command (DATETIME_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
823 TRACE("hwndbutton = %p\n", infoPtr
->hwndCheckbut
);
824 if(infoPtr
->hwndCheckbut
== (HWND
)lParam
)
825 return DATETIME_Button_Command(infoPtr
, wParam
, lParam
);
831 DATETIME_Enable (DATETIME_INFO
*infoPtr
, BOOL bEnable
)
833 TRACE("%p %s\n", infoPtr
, bEnable
? "TRUE" : "FALSE");
835 infoPtr
->dwStyle
&= ~WS_DISABLED
;
837 infoPtr
->dwStyle
|= WS_DISABLED
;
839 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
846 DATETIME_EraseBackground (const DATETIME_INFO
*infoPtr
, HDC hdc
)
848 HBRUSH hBrush
, hSolidBrush
= NULL
;
851 if (infoPtr
->dwStyle
& WS_DISABLED
)
852 hBrush
= hSolidBrush
= CreateSolidBrush(comctl32_color
.clrBtnFace
);
855 hBrush
= (HBRUSH
)SendMessageW(infoPtr
->hwndNotify
, WM_CTLCOLOREDIT
,
856 (WPARAM
)hdc
, (LPARAM
)infoPtr
->hwndSelf
);
858 hBrush
= hSolidBrush
= CreateSolidBrush(comctl32_color
.clrWindow
);
861 GetClientRect (infoPtr
->hwndSelf
, &rc
);
863 FillRect (hdc
, &rc
, hBrush
);
866 DeleteObject(hSolidBrush
);
873 DATETIME_Notify (DATETIME_INFO
*infoPtr
, LPNMHDR lpnmh
)
875 TRACE ("Got notification %x from %p\n", lpnmh
->code
, lpnmh
->hwndFrom
);
876 TRACE ("info: %p %p %p\n", infoPtr
->hwndSelf
, infoPtr
->hMonthCal
, infoPtr
->hUpdown
);
878 if (lpnmh
->code
== MCN_SELECT
) {
879 ShowWindow(infoPtr
->hMonthCal
, SW_HIDE
);
880 infoPtr
->dateValid
= TRUE
;
881 SendMessageW (infoPtr
->hMonthCal
, MCM_GETCURSEL
, 0, (LPARAM
)&infoPtr
->date
);
882 TRACE("got from calendar %04d/%02d/%02d day of week %d\n",
883 infoPtr
->date
.wYear
, infoPtr
->date
.wMonth
, infoPtr
->date
.wDay
, infoPtr
->date
.wDayOfWeek
);
884 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, BST_CHECKED
, 0);
885 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
886 DATETIME_SendDateTimeChangeNotify (infoPtr
);
888 if ((lpnmh
->hwndFrom
== infoPtr
->hUpdown
) && (lpnmh
->code
== UDN_DELTAPOS
)) {
889 LPNMUPDOWN lpnmud
= (LPNMUPDOWN
)lpnmh
;
890 TRACE("Delta pos %d\n", lpnmud
->iDelta
);
891 infoPtr
->pendingUpdown
= lpnmud
->iDelta
;
898 DATETIME_KeyDown (DATETIME_INFO
*infoPtr
, DWORD vkCode
)
900 int fieldNum
= infoPtr
->select
& DTHT_DATEFIELD
;
903 if (!(infoPtr
->haveFocus
)) return 0;
904 if ((fieldNum
==0) && (infoPtr
->select
)) return 0;
906 if (infoPtr
->select
& FORMATCALLMASK
) {
907 FIXME ("Callbacks not implemented yet\n");
913 DATETIME_IncreaseField (infoPtr
, fieldNum
, 1);
914 DATETIME_SendDateTimeChangeNotify (infoPtr
);
918 DATETIME_IncreaseField (infoPtr
, fieldNum
, -1);
919 DATETIME_SendDateTimeChangeNotify (infoPtr
);
922 DATETIME_IncreaseField (infoPtr
, fieldNum
, INT_MIN
);
923 DATETIME_SendDateTimeChangeNotify (infoPtr
);
926 DATETIME_IncreaseField (infoPtr
, fieldNum
, INT_MAX
);
927 DATETIME_SendDateTimeChangeNotify (infoPtr
);
931 if (infoPtr
->select
== 0) {
932 infoPtr
->select
= infoPtr
->nrFields
- 1;
937 } while ((infoPtr
->fieldspec
[infoPtr
->select
] & DT_STRING
) && (wrap
<2));
942 if (infoPtr
->select
==infoPtr
->nrFields
) {
946 } while ((infoPtr
->fieldspec
[infoPtr
->select
] & DT_STRING
) && (wrap
<2));
950 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
957 DATETIME_Char (DATETIME_INFO
*infoPtr
, WPARAM vkCode
)
959 int fieldNum
= infoPtr
->select
& DTHT_DATEFIELD
;
961 if (vkCode
>= '0' && vkCode
<= '9') {
962 int num
= vkCode
-'0';
965 /* this is a somewhat simplified version of what Windows does */
966 SYSTEMTIME
*date
= &infoPtr
->date
;
967 switch (infoPtr
->fieldspec
[fieldNum
]) {
970 date
->wYear
= date
->wYear
- (date
->wYear
%100) +
971 (date
->wYear
%10)*10 + num
;
972 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
973 date
->wDay
,date
->wMonth
,date
->wYear
);
974 DATETIME_SendDateTimeChangeNotify (infoPtr
);
976 case INVALIDFULLYEAR
:
978 /* reset current year initialy */
979 date
->wYear
= ((date
->wYear
/1000) ? 0 : 1)*(date
->wYear
%1000)*10 + num
;
980 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
981 date
->wDay
,date
->wMonth
,date
->wYear
);
982 DATETIME_SendDateTimeChangeNotify (infoPtr
);
986 if ((date
->wMonth
%10) > 1 || num
> 2)
989 date
->wMonth
= (date
->wMonth
%10)*10+num
;
990 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
991 date
->wDay
,date
->wMonth
,date
->wYear
);
992 DATETIME_SendDateTimeChangeNotify (infoPtr
);
996 newDays
= (date
->wDay
%10)*10+num
;
997 if (newDays
> MONTHCAL_MonthLength(date
->wMonth
, date
->wYear
))
1000 date
->wDay
= newDays
;
1001 date
->wDayOfWeek
= DATETIME_CalculateDayOfWeek(
1002 date
->wDay
,date
->wMonth
,date
->wYear
);
1003 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1005 case ONEDIGIT12HOUR
:
1006 case TWODIGIT12HOUR
:
1007 if ((date
->wHour
%10) > 1 || num
> 2)
1010 date
->wHour
= (date
->wHour
%10)*10+num
;
1011 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1013 case ONEDIGIT24HOUR
:
1014 case TWODIGIT24HOUR
:
1015 if ((date
->wHour
%10) > 2)
1017 else if ((date
->wHour
%10) == 2 && num
> 3)
1020 date
->wHour
= (date
->wHour
%10)*10+num
;
1021 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1023 case ONEDIGITMINUTE
:
1024 case TWODIGITMINUTE
:
1025 if ((date
->wMinute
%10) > 5)
1026 date
->wMinute
= num
;
1028 date
->wMinute
= (date
->wMinute
%10)*10+num
;
1029 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1031 case ONEDIGITSECOND
:
1032 case TWODIGITSECOND
:
1033 if ((date
->wSecond
%10) > 5)
1034 date
->wSecond
= num
;
1036 date
->wSecond
= (date
->wSecond
%10)*10+num
;
1037 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1046 DATETIME_VScroll (DATETIME_INFO
*infoPtr
, WORD wScroll
)
1048 int fieldNum
= infoPtr
->select
& DTHT_DATEFIELD
;
1050 if ((SHORT
)LOWORD(wScroll
) != SB_THUMBPOSITION
) return 0;
1051 if (!(infoPtr
->haveFocus
)) return 0;
1052 if ((fieldNum
==0) && (infoPtr
->select
)) return 0;
1054 if (infoPtr
->pendingUpdown
>= 0) {
1055 DATETIME_IncreaseField (infoPtr
, fieldNum
, 1);
1056 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1059 DATETIME_IncreaseField (infoPtr
, fieldNum
, -1);
1060 DATETIME_SendDateTimeChangeNotify (infoPtr
);
1063 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1070 DATETIME_KillFocus (DATETIME_INFO
*infoPtr
, HWND lostFocus
)
1072 TRACE("lost focus to %p\n", lostFocus
);
1074 if (infoPtr
->haveFocus
) {
1075 DATETIME_SendSimpleNotify (infoPtr
, NM_KILLFOCUS
);
1076 infoPtr
->haveFocus
= 0;
1079 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
1086 DATETIME_NCCreate (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
1088 DWORD dwExStyle
= GetWindowLongW(hwnd
, GWL_EXSTYLE
);
1089 /* force control to have client edge */
1090 dwExStyle
|= WS_EX_CLIENTEDGE
;
1091 SetWindowLongW(hwnd
, GWL_EXSTYLE
, dwExStyle
);
1093 return DefWindowProcW(hwnd
, WM_NCCREATE
, 0, (LPARAM
)lpcs
);
1098 DATETIME_SetFocus (DATETIME_INFO
*infoPtr
, HWND lostFocus
)
1100 TRACE("got focus from %p\n", lostFocus
);
1102 /* if monthcal is open and it loses focus, close monthcal */
1103 if (infoPtr
->hMonthCal
&& (lostFocus
== infoPtr
->hMonthCal
) &&
1104 IsWindowVisible(infoPtr
->hMonthCal
))
1106 ShowWindow(infoPtr
->hMonthCal
, SW_HIDE
);
1107 DATETIME_SendSimpleNotify(infoPtr
, DTN_CLOSEUP
);
1108 /* note: this get triggered even if monthcal loses focus to a dropdown
1109 * box click, which occurs without an intermediate WM_PAINT call
1111 infoPtr
->bDropdownEnabled
= FALSE
;
1115 if (infoPtr
->haveFocus
== 0) {
1116 DATETIME_SendSimpleNotify (infoPtr
, NM_SETFOCUS
);
1117 infoPtr
->haveFocus
= DTHT_GOTFOCUS
;
1120 InvalidateRect(infoPtr
->hwndSelf
, NULL
, FALSE
);
1127 DATETIME_SendDateTimeChangeNotify (const DATETIME_INFO
*infoPtr
)
1129 NMDATETIMECHANGE dtdtc
;
1131 dtdtc
.nmhdr
.hwndFrom
= infoPtr
->hwndSelf
;
1132 dtdtc
.nmhdr
.idFrom
= GetWindowLongPtrW(infoPtr
->hwndSelf
, GWLP_ID
);
1133 dtdtc
.nmhdr
.code
= DTN_DATETIMECHANGE
;
1135 dtdtc
.dwFlags
= (infoPtr
->dwStyle
& DTS_SHOWNONE
) ? GDT_NONE
: GDT_VALID
;
1137 dtdtc
.st
= infoPtr
->date
;
1138 return (BOOL
) SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
1139 dtdtc
.nmhdr
.idFrom
, (LPARAM
)&dtdtc
);
1144 DATETIME_SendSimpleNotify (const DATETIME_INFO
*infoPtr
, UINT code
)
1148 TRACE("%x\n", code
);
1149 nmhdr
.hwndFrom
= infoPtr
->hwndSelf
;
1150 nmhdr
.idFrom
= GetWindowLongPtrW(infoPtr
->hwndSelf
, GWLP_ID
);
1153 return (BOOL
) SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
1154 nmhdr
.idFrom
, (LPARAM
)&nmhdr
);
1158 DATETIME_Size (DATETIME_INFO
*infoPtr
, INT width
, INT height
)
1161 infoPtr
->rcClient
.bottom
= height
;
1162 infoPtr
->rcClient
.right
= width
;
1164 TRACE("Height=%d, Width=%d\n", infoPtr
->rcClient
.bottom
, infoPtr
->rcClient
.right
);
1166 infoPtr
->rcDraw
= infoPtr
->rcClient
;
1168 if (infoPtr
->dwStyle
& DTS_UPDOWN
) {
1169 SetWindowPos(infoPtr
->hUpdown
, NULL
,
1170 infoPtr
->rcClient
.right
-14, 0,
1171 15, infoPtr
->rcClient
.bottom
- infoPtr
->rcClient
.top
,
1172 SWP_NOACTIVATE
| SWP_NOZORDER
);
1175 /* set the size of the button that drops the calendar down */
1176 /* FIXME: account for style that allows button on left side */
1177 infoPtr
->calbutton
.top
= infoPtr
->rcDraw
.top
;
1178 infoPtr
->calbutton
.bottom
= infoPtr
->rcDraw
.bottom
;
1179 infoPtr
->calbutton
.left
= infoPtr
->rcDraw
.right
-15;
1180 infoPtr
->calbutton
.right
= infoPtr
->rcDraw
.right
;
1183 /* set enable/disable button size for show none style being enabled */
1184 /* FIXME: these dimensions are completely incorrect */
1185 infoPtr
->checkbox
.top
= infoPtr
->rcDraw
.top
;
1186 infoPtr
->checkbox
.bottom
= infoPtr
->rcDraw
.bottom
;
1187 infoPtr
->checkbox
.left
= infoPtr
->rcDraw
.left
;
1188 infoPtr
->checkbox
.right
= infoPtr
->rcDraw
.left
+ 10;
1190 InvalidateRect(infoPtr
->hwndSelf
, NULL
, FALSE
);
1197 DATETIME_StyleChanged(DATETIME_INFO
*infoPtr
, WPARAM wStyleType
, const STYLESTRUCT
*lpss
)
1199 static const WCHAR buttonW
[] = { 'b', 'u', 't', 't', 'o', 'n', 0 };
1201 TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
1202 wStyleType
, lpss
->styleOld
, lpss
->styleNew
);
1204 if (wStyleType
!= GWL_STYLE
) return 0;
1206 infoPtr
->dwStyle
= lpss
->styleNew
;
1208 if ( !(lpss
->styleOld
& DTS_SHOWNONE
) && (lpss
->styleNew
& DTS_SHOWNONE
) ) {
1209 infoPtr
->hwndCheckbut
= CreateWindowExW (0, buttonW
, 0, WS_CHILD
| WS_VISIBLE
| BS_AUTOCHECKBOX
,
1210 2, 2, 13, 13, infoPtr
->hwndSelf
, 0,
1211 (HINSTANCE
)GetWindowLongPtrW (infoPtr
->hwndSelf
, GWLP_HINSTANCE
), 0);
1212 SendMessageW (infoPtr
->hwndCheckbut
, BM_SETCHECK
, 1, 0);
1214 if ( (lpss
->styleOld
& DTS_SHOWNONE
) && !(lpss
->styleNew
& DTS_SHOWNONE
) ) {
1215 DestroyWindow(infoPtr
->hwndCheckbut
);
1216 infoPtr
->hwndCheckbut
= 0;
1218 if ( !(lpss
->styleOld
& DTS_UPDOWN
) && (lpss
->styleNew
& DTS_UPDOWN
) ) {
1219 infoPtr
->hUpdown
= CreateUpDownControl (WS_CHILD
| WS_BORDER
| WS_VISIBLE
, 120, 1, 20, 20,
1220 infoPtr
->hwndSelf
, 1, 0, 0, UD_MAXVAL
, UD_MINVAL
, 0);
1222 if ( (lpss
->styleOld
& DTS_UPDOWN
) && !(lpss
->styleNew
& DTS_UPDOWN
) ) {
1223 DestroyWindow(infoPtr
->hUpdown
);
1224 infoPtr
->hUpdown
= 0;
1227 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1233 DATETIME_SetFont (DATETIME_INFO
*infoPtr
, HFONT font
, BOOL repaint
)
1235 infoPtr
->hFont
= font
;
1236 if (repaint
) InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
1242 DATETIME_Create (HWND hwnd
, const CREATESTRUCTW
*lpcs
)
1244 static const WCHAR SysMonthCal32W
[] = { 'S', 'y', 's', 'M', 'o', 'n', 't', 'h', 'C', 'a', 'l', '3', '2', 0 };
1245 DATETIME_INFO
*infoPtr
= Alloc (sizeof(DATETIME_INFO
));
1246 STYLESTRUCT ss
= { 0, lpcs
->style
};
1248 if (!infoPtr
) return -1;
1250 infoPtr
->hwndSelf
= hwnd
;
1251 infoPtr
->dwStyle
= lpcs
->style
;
1253 infoPtr
->nrFieldsAllocated
= 32;
1254 infoPtr
->fieldspec
= Alloc (infoPtr
->nrFieldsAllocated
* sizeof(int));
1255 infoPtr
->fieldRect
= Alloc (infoPtr
->nrFieldsAllocated
* sizeof(RECT
));
1256 infoPtr
->buflen
= Alloc (infoPtr
->nrFieldsAllocated
* sizeof(int));
1257 infoPtr
->hwndNotify
= lpcs
->hwndParent
;
1258 infoPtr
->select
= -1; /* initially, nothing is selected */
1259 infoPtr
->bDropdownEnabled
= TRUE
;
1261 DATETIME_StyleChanged(infoPtr
, GWL_STYLE
, &ss
);
1262 DATETIME_SetFormatW (infoPtr
, 0);
1264 /* create the monthcal control */
1265 infoPtr
->hMonthCal
= CreateWindowExW (0, SysMonthCal32W
, 0, WS_BORDER
| WS_POPUP
| WS_CLIPSIBLINGS
,
1266 0, 0, 0, 0, infoPtr
->hwndSelf
, 0, 0, 0);
1268 /* initialize info structure */
1269 GetLocalTime (&infoPtr
->date
);
1270 infoPtr
->dateValid
= TRUE
;
1271 infoPtr
->hFont
= GetStockObject(DEFAULT_GUI_FONT
);
1273 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
1281 DATETIME_Destroy (DATETIME_INFO
*infoPtr
)
1283 if (infoPtr
->hwndCheckbut
)
1284 DestroyWindow(infoPtr
->hwndCheckbut
);
1285 if (infoPtr
->hUpdown
)
1286 DestroyWindow(infoPtr
->hUpdown
);
1287 if (infoPtr
->hMonthCal
)
1288 DestroyWindow(infoPtr
->hMonthCal
);
1289 SetWindowLongPtrW( infoPtr
->hwndSelf
, 0, 0 ); /* clear infoPtr */
1295 static LRESULT WINAPI
1296 DATETIME_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1298 DATETIME_INFO
*infoPtr
= ((DATETIME_INFO
*)GetWindowLongPtrW (hwnd
, 0));
1301 TRACE ("%x, %lx, %lx\n", uMsg
, wParam
, lParam
);
1303 if (!infoPtr
&& (uMsg
!= WM_CREATE
) && (uMsg
!= WM_NCCREATE
))
1304 return DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
1308 case DTM_GETSYSTEMTIME
:
1309 return DATETIME_GetSystemTime (infoPtr
, (SYSTEMTIME
*) lParam
);
1311 case DTM_SETSYSTEMTIME
:
1312 return DATETIME_SetSystemTime (infoPtr
, wParam
, (SYSTEMTIME
*) lParam
);
1315 ret
= SendMessageW (infoPtr
->hMonthCal
, MCM_GETRANGE
, wParam
, lParam
);
1316 return ret
? ret
: 1; /* bug emulation */
1319 return SendMessageW (infoPtr
->hMonthCal
, MCM_SETRANGE
, wParam
, lParam
);
1321 case DTM_SETFORMATA
:
1322 return DATETIME_SetFormatA (infoPtr
, (LPCSTR
)lParam
);
1324 case DTM_SETFORMATW
:
1325 return DATETIME_SetFormatW (infoPtr
, (LPCWSTR
)lParam
);
1327 case DTM_GETMONTHCAL
:
1328 return (LRESULT
)infoPtr
->hMonthCal
;
1330 case DTM_SETMCCOLOR
:
1331 return SendMessageW (infoPtr
->hMonthCal
, MCM_SETCOLOR
, wParam
, lParam
);
1333 case DTM_GETMCCOLOR
:
1334 return SendMessageW (infoPtr
->hMonthCal
, MCM_GETCOLOR
, wParam
, 0);
1337 return SendMessageW (infoPtr
->hMonthCal
, WM_SETFONT
, wParam
, lParam
);
1340 return SendMessageW (infoPtr
->hMonthCal
, WM_GETFONT
, wParam
, lParam
);
1343 return DATETIME_Notify (infoPtr
, (LPNMHDR
)lParam
);
1346 return DATETIME_Enable (infoPtr
, (BOOL
)wParam
);
1349 return DATETIME_EraseBackground (infoPtr
, (HDC
)wParam
);
1352 return DLGC_WANTARROWS
| DLGC_WANTCHARS
;
1354 case WM_PRINTCLIENT
:
1356 return DATETIME_Paint (infoPtr
, (HDC
)wParam
);
1359 return DATETIME_KeyDown (infoPtr
, wParam
);
1362 return DATETIME_Char (infoPtr
, wParam
);
1365 return DATETIME_KillFocus (infoPtr
, (HWND
)wParam
);
1368 return DATETIME_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
1371 return DATETIME_SetFocus (infoPtr
, (HWND
)wParam
);
1374 return DATETIME_Size (infoPtr
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
1376 case WM_LBUTTONDOWN
:
1377 return DATETIME_LButtonDown (infoPtr
, (SHORT
)LOWORD(lParam
), (SHORT
)HIWORD(lParam
));
1380 return DATETIME_LButtonUp (infoPtr
);
1383 return DATETIME_VScroll (infoPtr
, (WORD
)wParam
);
1386 return DATETIME_Create (hwnd
, (LPCREATESTRUCTW
)lParam
);
1389 return DATETIME_Destroy (infoPtr
);
1392 return DATETIME_Command (infoPtr
, wParam
, lParam
);
1394 case WM_STYLECHANGED
:
1395 return DATETIME_StyleChanged(infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
1398 return DATETIME_SetFont(infoPtr
, (HFONT
)wParam
, (BOOL
)lParam
);
1401 return (LRESULT
) infoPtr
->hFont
;
1404 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
1405 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
1406 uMsg
, wParam
, lParam
);
1407 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
1413 DATETIME_Register (void)
1417 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
1418 wndClass
.style
= CS_GLOBALCLASS
;
1419 wndClass
.lpfnWndProc
= DATETIME_WindowProc
;
1420 wndClass
.cbClsExtra
= 0;
1421 wndClass
.cbWndExtra
= sizeof(DATETIME_INFO
*);
1422 wndClass
.hCursor
= LoadCursorW (0, (LPCWSTR
)IDC_ARROW
);
1423 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+ 1);
1424 wndClass
.lpszClassName
= DATETIMEPICK_CLASSW
;
1426 RegisterClassW (&wndClass
);
1431 DATETIME_Unregister (void)
1433 UnregisterClassW (DATETIMEPICK_CLASSW
, NULL
);