Move Applications tab before Libraries tab.
[wine.git] / dlls / comctl32 / datetime.c
blob81a401186547a9ac7c6a5d3b7c87388e6ffc3a16
1 /*
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
22 * TODO:
23 * - All messages.
24 * - All notifications.
28 #include <math.h>
29 #include <string.h>
30 #include <stdarg.h>
31 #include <stdio.h>
33 #include "windef.h"
34 #include "winbase.h"
35 #include "wingdi.h"
36 #include "winuser.h"
37 #include "winnls.h"
38 #include "commctrl.h"
39 #include "comctl32.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(datetime);
44 typedef struct
46 HWND hMonthCal;
47 HWND hUpdown;
48 SYSTEMTIME date;
49 BOOL dateValid;
50 HWND hwndCheckbut;
51 RECT rcClient; /* rect around the edge of the window */
52 RECT rcDraw; /* rect inside of the border */
53 RECT checkbox; /* checkbox allowing the control to be enabled/disabled */
54 RECT calbutton; /* button that toggles the dropdown of the monthcal control */
55 BOOL bCalDepressed; /* TRUE = cal button is depressed */
56 int select;
57 HFONT hFont;
58 int nrFieldsAllocated;
59 int nrFields;
60 int haveFocus;
61 int *fieldspec;
62 RECT *fieldRect;
63 int *buflen;
64 char textbuf[256];
65 POINT monthcal_pos;
66 } DATETIME_INFO, *LPDATETIME_INFO;
68 /* in monthcal.c */
69 extern int MONTHCAL_MonthLength(int month, int year);
71 /* this list of defines is closely related to `allowedformatchars' defined
72 * in datetime.c; the high nibble indicates the `base type' of the format
73 * specifier.
74 * Do not change without first reading DATETIME_UseFormat.
78 #define DT_END_FORMAT 0
79 #define ONEDIGITDAY 0x01
80 #define TWODIGITDAY 0x02
81 #define THREECHARDAY 0x03
82 #define FULLDAY 0x04
83 #define ONEDIGIT12HOUR 0x11
84 #define TWODIGIT12HOUR 0x12
85 #define ONEDIGIT24HOUR 0x21
86 #define TWODIGIT24HOUR 0x22
87 #define ONEDIGITMINUTE 0x31
88 #define TWODIGITMINUTE 0x32
89 #define ONEDIGITMONTH 0x41
90 #define TWODIGITMONTH 0x42
91 #define THREECHARMONTH 0x43
92 #define FULLMONTH 0x44
93 #define ONEDIGITSECOND 0x51
94 #define TWODIGITSECOND 0x52
95 #define ONELETTERAMPM 0x61
96 #define TWOLETTERAMPM 0x62
97 #define ONEDIGITYEAR 0x71
98 #define TWODIGITYEAR 0x72
99 #define INVALIDFULLYEAR 0x73 /* FIXME - yyy is not valid - we'll treat it as yyyy */
100 #define FULLYEAR 0x74
101 #define FORMATCALLBACK 0x81 /* -> maximum of 0x80 callbacks possible */
102 #define FORMATCALLMASK 0x80
103 #define DT_STRING 0x0100
105 #define DTHT_DATEFIELD 0xff /* for hit-testing */
107 #define DTHT_NONE 0
108 #define DTHT_CHECKBOX 0x200 /* these should end at '00' , to make */
109 #define DTHT_MCPOPUP 0x300 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
110 #define DTHT_GOTFOCUS 0x400 /* tests for date-fields */
112 #define DATETIME_GetInfoPtr(hwnd) ((DATETIME_INFO *)GetWindowLongA (hwnd, 0))
114 static BOOL DATETIME_SendSimpleNotify (HWND hwnd, UINT code);
115 static BOOL DATETIME_SendDateTimeChangeNotify (HWND hwnd);
116 extern void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to);
117 static const char *allowedformatchars = {"dhHmMstyX'"};
118 static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1,-1};
121 static LRESULT
122 DATETIME_GetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam )
124 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
125 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
126 SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
128 TRACE("%04x %08lx\n",wParam,lParam);
129 if (!lParam) return GDT_NONE;
131 if ((dwStyle & DTS_SHOWNONE) &&
132 (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED))
133 return GDT_NONE;
135 MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray);
137 return GDT_VALID;
141 static LRESULT
142 DATETIME_SetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam )
144 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
145 SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
147 TRACE("%p %04x %08lx\n",hwnd, wParam, lParam);
148 if (!lParam) return 0;
150 TRACE("%04d/%02d/%02d %02d:%02d:%02d)\n",
151 lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay,
152 lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond);
154 if (wParam==GDT_VALID) {
155 infoPtr->dateValid = TRUE;
156 MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
157 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
158 } else if (wParam==GDT_NONE) {
159 infoPtr->dateValid = FALSE;
160 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0);
162 InvalidateRect(hwnd, NULL, TRUE);
163 return 1;
167 static LRESULT
168 DATETIME_GetRange (HWND hwnd, LPARAM lParam )
170 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
171 LRESULT ret;
173 TRACE("%08lx\n", lParam);
174 ret = SendMessageA (infoPtr->hMonthCal, MCM_GETRANGE, 0, lParam);
175 if (!ret) ret = 1; /* bug emulation... */
176 return ret;
179 static LRESULT
180 DATETIME_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam )
182 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
184 TRACE("%04x %08lx\n",wParam,lParam);
186 return SendMessageA (infoPtr->hMonthCal, MCM_SETRANGE, wParam, lParam);
189 static LRESULT
190 DATETIME_GetMonthCalColor (HWND hwnd, WPARAM wParam)
192 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
194 TRACE("%04x\n",wParam);
195 return SendMessageA (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0);
199 static LRESULT
200 DATETIME_SetMonthCalColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
202 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
204 TRACE("%04x %08lx\n",wParam,lParam);
205 return SendMessageA (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam);
209 /* FIXME: need to get way to force font into monthcal structure */
210 static LRESULT
211 DATETIME_GetMonthCal (HWND hwnd)
213 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
215 TRACE("\n");
216 return (LRESULT)infoPtr->hMonthCal;
221 /* FIXME: need to get way to force font into monthcal structure */
223 static LRESULT
224 DATETIME_GetMonthCalFont (HWND hwnd)
227 TRACE("\n");
228 return 0;
232 static LRESULT
233 DATETIME_SetMonthCalFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
236 TRACE("%04x %08lx\n",wParam,lParam);
237 return 0;
242 Split up a formattxt in actions.
243 See ms documentation for the meaning of the letter codes/'specifiers'.
245 Notes:
246 *'dddddd' is handled as 'dddd' plus 'dd'.
247 *unrecognized formats are strings (here given the type DT_STRING;
248 start of the string is encoded in lower bits of DT_STRING.
249 Therefore, 'string' ends finally up as '<show seconds>tring'.
254 static void
255 DATETIME_UseFormat (DATETIME_INFO *infoPtr, const char *formattxt)
257 int i,j,k,len;
258 int *nrFields=& infoPtr->nrFields;
260 TRACE ("%s\n",formattxt);
263 *nrFields=0;
264 infoPtr->fieldspec[*nrFields]=0;
265 len=strlen(allowedformatchars);
266 k=0;
268 for (i=0; i<strlen (formattxt); i++) {
269 TRACE ("\n%d %c:",i, formattxt[i]);
270 for (j=0; j<len; j++) {
271 if (allowedformatchars[j]==formattxt[i]) {
272 TRACE ("%c[%d,%x]",allowedformatchars[j], *nrFields,
273 infoPtr->fieldspec[*nrFields]);
274 if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
275 infoPtr->fieldspec[*nrFields]=(j<<4) +1;
276 break;
278 if (infoPtr->fieldspec[*nrFields]>>4!=j) {
279 (*nrFields)++;
280 infoPtr->fieldspec[*nrFields]=(j<<4) +1;
281 break;
283 if ((infoPtr->fieldspec[*nrFields] & 0x0f)==maxrepetition[j]) {
284 (*nrFields)++;
285 infoPtr->fieldspec[*nrFields]=(j<<4) +1;
286 break;
288 infoPtr->fieldspec[*nrFields]++;
289 break;
290 } /* if allowedformatchar */
291 } /* for j */
294 /* char is not a specifier: handle char like a string */
295 if (j==len) {
296 if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
297 infoPtr->fieldspec[*nrFields]=DT_STRING+k;
298 infoPtr->buflen[*nrFields]=0;
299 } else
300 if ((infoPtr->fieldspec[*nrFields] & DT_STRING)!=DT_STRING) {
301 (*nrFields)++;
302 infoPtr->fieldspec[*nrFields]=DT_STRING+k;
303 infoPtr->buflen[*nrFields]=0;
305 infoPtr->textbuf[k]=formattxt[i];
306 k++;
307 infoPtr->buflen[*nrFields]++;
308 } /* if j=len */
310 if (*nrFields==infoPtr->nrFieldsAllocated) {
311 FIXME ("out of memory; should reallocate. crash ahead.\n");
314 } /* for i */
316 TRACE("\n");
318 if (infoPtr->fieldspec[*nrFields]!=0) (*nrFields)++;
322 static LRESULT
323 DATETIME_SetFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
325 DATETIME_INFO *infoPtr= DATETIME_GetInfoPtr (hwnd);
326 char format_buf[80];
327 DWORD format_item;
329 TRACE("%04x %08lx\n",wParam,lParam);
330 if (!lParam) {
331 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
333 if (dwStyle & DTS_LONGDATEFORMAT)
334 format_item=LOCALE_SLONGDATE;
335 else if (dwStyle & DTS_TIMEFORMAT)
336 format_item=LOCALE_STIMEFORMAT;
337 else /* DTS_SHORTDATEFORMAT */
338 format_item=LOCALE_SSHORTDATE;
339 GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf));
340 DATETIME_UseFormat (infoPtr, format_buf);
342 else
343 DATETIME_UseFormat (infoPtr, (char *) lParam);
345 return infoPtr->nrFields;
349 static LRESULT
350 DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam)
353 TRACE("%04x %08lx\n",wParam,lParam);
354 if (lParam) {
355 LPSTR buf;
356 int retval;
357 int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL );
359 buf = (LPSTR) Alloc (len);
360 WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, buf, len, NULL, NULL );
361 retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf);
362 Free (buf);
363 return retval;
365 else
366 return DATETIME_SetFormat (hwnd, 0, 0);
371 static void
372 DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result, int resultSize)
374 SYSTEMTIME date = infoPtr->date;
375 int spec;
376 char buffer[80];
378 *result=0;
379 TRACE ("%d,%d\n", infoPtr->nrFields, count);
380 if ((count>infoPtr->nrFields) || (count<0)) {
381 WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
382 return;
385 if (!infoPtr->fieldspec) return;
387 spec=infoPtr->fieldspec[count];
388 if (spec & DT_STRING) {
389 int txtlen=infoPtr->buflen[count];
391 if (txtlen > resultSize)
392 txtlen = resultSize - 1;
393 memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen);
394 result[txtlen]=0;
395 TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
396 return;
400 switch (spec) {
401 case DT_END_FORMAT:
402 *result=0;
403 break;
404 case ONEDIGITDAY:
405 sprintf (result,"%d",date.wDay);
406 break;
407 case TWODIGITDAY:
408 sprintf (result,"%.2d",date.wDay);
409 break;
410 case THREECHARDAY:
411 GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7,
412 result,4);
413 /*sprintf (result,"%.3s",days[date.wDayOfWeek]);*/
414 break;
415 case FULLDAY:
416 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SDAYNAME1+ (date.wDayOfWeek+6)%7,
417 result, resultSize);
418 break;
419 case ONEDIGIT12HOUR:
420 if (date.wHour>12)
421 sprintf (result,"%d",date.wHour-12);
422 else
423 sprintf (result,"%d",date.wHour);
424 break;
425 case TWODIGIT12HOUR:
426 if (date.wHour>12)
427 sprintf (result,"%.2d",date.wHour-12);
428 else
429 sprintf (result,"%.2d",date.wHour);
430 break;
431 case ONEDIGIT24HOUR:
432 sprintf (result,"%d",date.wHour);
433 break;
434 case TWODIGIT24HOUR:
435 sprintf (result,"%.2d",date.wHour);
436 break;
437 case ONEDIGITSECOND:
438 sprintf (result,"%d",date.wSecond);
439 break;
440 case TWODIGITSECOND:
441 sprintf (result,"%.2d",date.wSecond);
442 break;
443 case ONEDIGITMINUTE:
444 sprintf (result,"%d",date.wMinute);
445 break;
446 case TWODIGITMINUTE:
447 sprintf (result,"%.2d",date.wMinute);
448 break;
449 case ONEDIGITMONTH:
450 sprintf (result,"%d",date.wMonth);
451 break;
452 case TWODIGITMONTH:
453 sprintf (result,"%.2d",date.wMonth);
454 break;
455 case THREECHARMONTH:
456 GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
457 buffer,sizeof(buffer));
458 sprintf (result,"%.3s",buffer);
459 break;
460 case FULLMONTH:
461 GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
462 result, resultSize);
463 break;
464 case ONELETTERAMPM:
465 if (date.wHour<12)
466 strcpy (result,"A");
467 else
468 strcpy (result,"P");
469 break;
470 case TWOLETTERAMPM:
471 if (date.wHour<12)
472 strcpy (result,"AM");
473 else
474 strcpy (result,"PM");
475 break;
476 case FORMATCALLBACK:
477 FIXME ("Not implemented\n");
478 strcpy (result,"xxx");
479 break;
480 case ONEDIGITYEAR:
481 sprintf (result,"%d",date.wYear-10* (int) floor(date.wYear/10));
482 break;
483 case TWODIGITYEAR:
484 sprintf (result,"%.2d",date.wYear-100* (int) floor(date.wYear/100));
485 break;
486 case INVALIDFULLYEAR:
487 case FULLYEAR:
488 sprintf (result,"%d",date.wYear);
489 break;
492 TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
496 static void
497 DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number)
499 SYSTEMTIME *date = &infoPtr->date;
500 int spec;
502 TRACE ("%d\n",number);
503 if ((number>infoPtr->nrFields) || (number<0)) return;
505 spec=infoPtr->fieldspec[number];
506 if ((spec & DTHT_DATEFIELD)==0) return;
508 switch (spec) {
509 case ONEDIGITDAY:
510 case TWODIGITDAY:
511 case THREECHARDAY:
512 case FULLDAY:
513 date->wDay++;
514 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
515 date->wDay=1;
516 break;
517 case ONEDIGIT12HOUR:
518 case TWODIGIT12HOUR:
519 case ONEDIGIT24HOUR:
520 case TWODIGIT24HOUR:
521 date->wHour++;
522 if (date->wHour>23) date->wHour=0;
523 break;
524 case ONEDIGITSECOND:
525 case TWODIGITSECOND:
526 date->wSecond++;
527 if (date->wSecond>59) date->wSecond=0;
528 break;
529 case ONEDIGITMINUTE:
530 case TWODIGITMINUTE:
531 date->wMinute++;
532 if (date->wMinute>59) date->wMinute=0;
533 break;
534 case ONEDIGITMONTH:
535 case TWODIGITMONTH:
536 case THREECHARMONTH:
537 case FULLMONTH:
538 date->wMonth++;
539 if (date->wMonth>12) date->wMonth=1;
540 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
541 date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
542 break;
543 case ONELETTERAMPM:
544 case TWOLETTERAMPM:
545 date->wHour+=12;
546 if (date->wHour>23) date->wHour-=24;
547 break;
548 case FORMATCALLBACK:
549 FIXME ("Not implemented\n");
550 break;
551 case ONEDIGITYEAR:
552 case TWODIGITYEAR:
553 case FULLYEAR:
554 date->wYear++;
555 break;
561 static void
562 DATETIME_DecreaseField (DATETIME_INFO *infoPtr, int number)
564 SYSTEMTIME *date = & infoPtr->date;
565 int spec;
567 TRACE ("%d\n",number);
568 if ((number>infoPtr->nrFields) || (number<0)) return;
570 spec = infoPtr->fieldspec[number];
571 if ((spec & DTHT_DATEFIELD)==0) return;
573 TRACE ("%x\n",spec);
575 switch (spec) {
576 case ONEDIGITDAY:
577 case TWODIGITDAY:
578 case THREECHARDAY:
579 case FULLDAY:
580 date->wDay--;
581 if (date->wDay<1)
582 date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
583 break;
584 case ONEDIGIT12HOUR:
585 case TWODIGIT12HOUR:
586 case ONEDIGIT24HOUR:
587 case TWODIGIT24HOUR:
588 if (date->wHour)
589 date->wHour--;
590 else
591 date->wHour=23;
592 break;
593 case ONEDIGITSECOND:
594 case TWODIGITSECOND:
595 if (date->wHour)
596 date->wSecond--;
597 else
598 date->wHour=59;
599 break;
600 case ONEDIGITMINUTE:
601 case TWODIGITMINUTE:
602 if (date->wMinute)
603 date->wMinute--;
604 else
605 date->wMinute=59;
606 break;
607 case ONEDIGITMONTH:
608 case TWODIGITMONTH:
609 case THREECHARMONTH:
610 case FULLMONTH:
611 if (date->wMonth>1)
612 date->wMonth--;
613 else
614 date->wMonth=12;
615 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
616 date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
617 break;
618 case ONELETTERAMPM:
619 case TWOLETTERAMPM:
620 if (date->wHour<12)
621 date->wHour+=12;
622 else
623 date->wHour-=12;
624 break;
625 case FORMATCALLBACK:
626 FIXME ("Not implemented\n");
627 break;
628 case ONEDIGITYEAR:
629 case TWODIGITYEAR:
630 case FULLYEAR:
631 date->wYear--;
632 break;
638 static void
639 DATETIME_ResetFieldDown (DATETIME_INFO *infoPtr, int number)
641 SYSTEMTIME *date = &infoPtr->date;
642 int spec;
644 TRACE ("%d\n",number);
645 if ((number>infoPtr->nrFields) || (number<0)) return;
647 spec = infoPtr->fieldspec[number];
648 if ((spec & DTHT_DATEFIELD)==0) return;
651 switch (spec) {
652 case ONEDIGITDAY:
653 case TWODIGITDAY:
654 case THREECHARDAY:
655 case FULLDAY:
656 date->wDay = 1;
657 break;
658 case ONEDIGIT12HOUR:
659 case TWODIGIT12HOUR:
660 case ONEDIGIT24HOUR:
661 case TWODIGIT24HOUR:
662 case ONELETTERAMPM:
663 case TWOLETTERAMPM:
664 date->wHour = 0;
665 break;
666 case ONEDIGITSECOND:
667 case TWODIGITSECOND:
668 date->wSecond = 0;
669 break;
670 case ONEDIGITMINUTE:
671 case TWODIGITMINUTE:
672 date->wMinute = 0;
673 break;
674 case ONEDIGITMONTH:
675 case TWODIGITMONTH:
676 case THREECHARMONTH:
677 case FULLMONTH:
678 date->wMonth = 1;
679 case FORMATCALLBACK:
680 FIXME ("Not implemented\n");
681 break;
682 case ONEDIGITYEAR:
683 case TWODIGITYEAR:
684 /* FYI: On 1752/9/14 the calendar changed and England and the
685 * American colonies changed to the Gregorian calendar. This change
686 * involved having September 14th follow September 2nd. So no date
687 * algorithm works before that date.
689 case FULLYEAR:
690 date->wSecond = 0;
691 date->wMinute = 0;
692 date->wHour = 0;
693 date->wDay = 14; /* overactive ms-programmers..*/
694 date->wMonth = 9;
695 date->wYear = 1752;
696 break;
702 static void
703 DATETIME_ResetFieldUp (DATETIME_INFO *infoPtr, int number)
705 SYSTEMTIME *date = & infoPtr->date;
706 int spec;
708 TRACE("%d \n",number);
709 if ((number>infoPtr->nrFields) || (number<0)) return;
711 spec=infoPtr->fieldspec[number];
712 if ((spec & DTHT_DATEFIELD)==0) return;
714 switch (spec) {
715 case ONEDIGITDAY:
716 case TWODIGITDAY:
717 case THREECHARDAY:
718 case FULLDAY:
719 date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
720 break;
721 case ONEDIGIT12HOUR:
722 case TWODIGIT12HOUR:
723 case ONEDIGIT24HOUR:
724 case TWODIGIT24HOUR:
725 case ONELETTERAMPM:
726 case TWOLETTERAMPM:
727 date->wHour=23;
728 break;
729 case ONEDIGITSECOND:
730 case TWODIGITSECOND:
731 date->wSecond=59;
732 break;
733 case ONEDIGITMINUTE:
734 case TWODIGITMINUTE:
735 date->wMinute=59;
736 break;
737 case ONEDIGITMONTH:
738 case TWODIGITMONTH:
739 case THREECHARMONTH:
740 case FULLMONTH:
741 date->wMonth=12;
742 case FORMATCALLBACK:
743 FIXME ("Not implemented\n");
744 break;
745 case ONEDIGITYEAR:
746 case TWODIGITYEAR:
747 case FULLYEAR:
748 date->wYear=9999; /* Y10K problem? naaah. */
749 break;
755 static void DATETIME_Refresh (HWND hwnd, HDC hdc)
758 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
759 int i,prevright;
760 RECT *field;
761 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
762 RECT *rcDraw = &infoPtr->rcDraw;
763 RECT *rcClient = &infoPtr->rcClient;
764 RECT *calbutton = &infoPtr->calbutton;
765 RECT *checkbox = &infoPtr->checkbox;
766 HBRUSH hbr;
767 SIZE size;
768 COLORREF oldBk, oldTextColor;
770 /* draw control edge */
771 TRACE("\n");
772 hbr = CreateSolidBrush(RGB(255, 255, 255));
773 FillRect(hdc, rcClient, hbr);
774 DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT);
775 DeleteObject(hbr);
777 if (infoPtr->dateValid) {
778 char txt[80];
779 HFONT oldFont;
780 oldFont = SelectObject (hdc, infoPtr->hFont);
782 DATETIME_ReturnTxt (infoPtr, 0, txt, sizeof(txt));
783 GetTextExtentPoint32A (hdc, txt, strlen (txt), &size);
784 rcDraw->bottom = size.cy+2;
786 if (dwStyle & DTS_SHOWNONE) checkbox->right = 18;
788 prevright = checkbox->right;
790 for (i=0; i<infoPtr->nrFields; i++) {
791 DATETIME_ReturnTxt (infoPtr, i, txt, sizeof(txt));
792 GetTextExtentPoint32A (hdc, txt, strlen (txt), &size);
793 field = & infoPtr->fieldRect[i];
794 field->left = prevright;
795 field->right = prevright+size.cx;
796 field->top = rcDraw->top;
797 field->bottom = rcDraw->bottom;
798 prevright = field->right;
800 if ((infoPtr->haveFocus) && (i==infoPtr->select)) {
801 hbr = CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION));
802 FillRect(hdc, field, hbr);
803 oldBk = SetBkColor (hdc, GetSysColor(COLOR_ACTIVECAPTION));
804 oldTextColor = SetTextColor (hdc, GetSysColor(COLOR_WINDOW));
805 DeleteObject (hbr);
806 DrawTextA ( hdc, txt, strlen(txt), field,
807 DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
808 SetBkColor (hdc, oldBk);
809 SetTextColor (hdc, oldTextColor);
811 else
812 DrawTextA ( hdc, txt, strlen(txt), field,
813 DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
816 SelectObject (hdc, oldFont);
819 if (!(dwStyle & DTS_UPDOWN)) {
820 DrawFrameControl(hdc, calbutton, DFC_SCROLL,
821 DFCS_SCROLLDOWN | (infoPtr->bCalDepressed ? DFCS_PUSHED : 0) |
822 (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
827 static LRESULT
828 DATETIME_HitTest (HWND hwnd, DATETIME_INFO *infoPtr, POINT pt)
830 int i, retval;
832 TRACE ("%ld, %ld\n",pt.x,pt.y);
834 retval = DTHT_NONE;
835 if (PtInRect (&infoPtr->calbutton, pt))
836 {retval = DTHT_MCPOPUP; TRACE("Hit in calbutton(DTHT_MCPOPUP)\n"); goto done; }
837 if (PtInRect (&infoPtr->checkbox, pt))
838 {retval = DTHT_CHECKBOX; TRACE("Hit in checkbox(DTHT_CHECKBOX)\n"); goto done; }
840 for (i=0; i<infoPtr->nrFields; i++) {
841 if (PtInRect (&infoPtr->fieldRect[i], pt)) {
842 retval = i;
843 TRACE("Hit in date text in field %d\n", i);
844 break;
848 done:
849 return retval;
853 static LRESULT
854 DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
856 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
857 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
858 int old, new;
859 POINT pt;
861 TRACE ("\n");
863 old = infoPtr->select;
864 pt.x = (INT)LOWORD(lParam);
865 pt.y = (INT)HIWORD(lParam);
867 new = DATETIME_HitTest (hwnd, infoPtr, pt);
869 /* FIXME: might be conditions where we don't want to update infoPtr->select */
870 infoPtr->select = new;
872 if (infoPtr->select != old) {
873 infoPtr->haveFocus = DTHT_GOTFOCUS;
876 if (infoPtr->select == DTHT_MCPOPUP) {
877 /* FIXME: button actually is only depressed during dropdown of the */
878 /* calendar control and when the mouse is over the button window */
879 infoPtr->bCalDepressed = TRUE;
881 /* recalculate the position of the monthcal popup */
882 if(dwStyle & DTS_RIGHTALIGN)
883 infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
884 infoPtr->calbutton.left) + 145);
885 else
886 infoPtr->monthcal_pos.x = 8;
888 infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom;
889 ClientToScreen (hwnd, &(infoPtr->monthcal_pos));
890 SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x,
891 infoPtr->monthcal_pos.y, 145, 150, 0);
893 if(IsWindowVisible(infoPtr->hMonthCal))
894 ShowWindow(infoPtr->hMonthCal, SW_HIDE);
895 else
896 ShowWindow(infoPtr->hMonthCal, SW_SHOW);
898 TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p, mcpp:%p\n",
899 hwnd,infoPtr->hMonthCal,
900 GetParent (infoPtr->hMonthCal),
901 GetDesktopWindow (),
902 GetParent (GetParent (infoPtr->hMonthCal)));
903 DATETIME_SendSimpleNotify (hwnd, DTN_DROPDOWN);
906 InvalidateRect(hwnd, NULL, FALSE);
908 return 0;
912 static LRESULT
913 DATETIME_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
915 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
917 TRACE("\n");
919 if(infoPtr->bCalDepressed == TRUE) {
920 infoPtr->bCalDepressed = FALSE;
921 InvalidateRect(hwnd, &(infoPtr->calbutton), TRUE);
924 return 0;
928 static LRESULT
929 DATETIME_Paint (HWND hwnd, WPARAM wParam)
931 HDC hdc;
932 PAINTSTRUCT ps;
934 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
935 DATETIME_Refresh (hwnd, hdc);
936 if(!wParam)
937 EndPaint (hwnd, &ps);
938 return 0;
942 static LRESULT
943 DATETIME_Button_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
945 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd);
947 switch(HIWORD(wParam)) {
948 case BN_CLICKED:
950 DWORD state = SendMessageA((HWND)lParam, BM_GETCHECK, 0, 0);
951 if(state == BST_CHECKED)
952 infoPtr->dateValid = TRUE;
953 else
954 infoPtr->dateValid = FALSE;
955 InvalidateRect(hwnd, NULL, TRUE);
956 return 0;
958 default:
959 return 0;
965 static LRESULT
966 DATETIME_Command (HWND hwnd, WPARAM wParam, LPARAM lParam)
968 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd);
970 TRACE("%08x %08lx\n", wParam, lParam);
971 TRACE("hwndbutton = %p\n", infoPtr->hwndCheckbut);
972 if(infoPtr->hwndCheckbut == (HWND)lParam)
973 return DATETIME_Button_Command(hwnd, wParam, lParam);
974 return 0;
977 static LRESULT
978 DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam)
980 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
981 LPNMHDR lpnmh = (LPNMHDR) lParam;
983 TRACE ("%x,%lx\n",wParam, lParam);
984 TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom);
985 TRACE ("info: %p %p %p\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown);
986 return 0;
990 static LRESULT
991 DATETIME_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
994 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
995 LPNMHDR lpnmh = (LPNMHDR) lParam;
997 TRACE ("%x,%lx\n",wParam, lParam);
998 TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom);
999 TRACE ("info: %p %p %p\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown);
1000 return 0;
1004 static LRESULT
1005 DATETIME_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
1007 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
1008 int FieldNum,wrap=0;
1010 TRACE("%x %lx %x\n",wParam, lParam, infoPtr->select);
1012 FieldNum = infoPtr->select & DTHT_DATEFIELD;
1014 if (!(infoPtr->haveFocus)) return 0;
1015 if ((FieldNum==0) && (infoPtr->select)) return 0;
1017 if (infoPtr->select & FORMATCALLMASK) {
1018 FIXME ("Callbacks not implemented yet\n");
1021 switch (wParam) {
1022 case VK_ADD:
1023 case VK_UP:
1024 DATETIME_IncreaseField (infoPtr,FieldNum);
1025 DATETIME_SendDateTimeChangeNotify (hwnd);
1026 break;
1027 case VK_SUBTRACT:
1028 case VK_DOWN:
1029 DATETIME_DecreaseField (infoPtr,FieldNum);
1030 DATETIME_SendDateTimeChangeNotify (hwnd);
1031 break;
1032 case VK_HOME:
1033 DATETIME_ResetFieldDown (infoPtr,FieldNum);
1034 DATETIME_SendDateTimeChangeNotify (hwnd);
1035 break;
1036 case VK_END:
1037 DATETIME_ResetFieldUp(infoPtr,FieldNum);
1038 DATETIME_SendDateTimeChangeNotify (hwnd);
1039 break;
1040 case VK_LEFT:
1041 do {
1042 if (infoPtr->select==0) {
1043 infoPtr->select = infoPtr->nrFields - 1;
1044 wrap++;
1045 } else
1046 infoPtr->select--;
1048 while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
1049 break;
1050 case VK_RIGHT:
1051 do {
1052 infoPtr->select++;
1053 if (infoPtr->select==infoPtr->nrFields) {
1054 infoPtr->select = 0;
1055 wrap++;
1058 while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
1059 break;
1062 InvalidateRect(hwnd, NULL, FALSE);
1064 return 0;
1068 static LRESULT
1069 DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1071 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
1073 TRACE ("\n");
1075 if (infoPtr->haveFocus) {
1076 DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS);
1077 infoPtr->haveFocus = 0;
1080 InvalidateRect (hwnd, NULL, TRUE);
1082 return 0;
1086 static LRESULT
1087 DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
1089 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
1091 TRACE ("\n");
1093 if (infoPtr->haveFocus==0) {
1094 DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS);
1095 infoPtr->haveFocus = DTHT_GOTFOCUS;
1098 InvalidateRect(hwnd, NULL, FALSE);
1100 return 0;
1104 static BOOL
1105 DATETIME_SendDateTimeChangeNotify (HWND hwnd)
1108 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
1109 NMDATETIMECHANGE dtdtc;
1111 TRACE ("\n");
1112 dtdtc.nmhdr.hwndFrom = hwnd;
1113 dtdtc.nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID);
1114 dtdtc.nmhdr.code = DTN_DATETIMECHANGE;
1116 if ((GetWindowLongA (hwnd, GWL_STYLE) & DTS_SHOWNONE))
1117 dtdtc.dwFlags = GDT_NONE;
1118 else
1119 dtdtc.dwFlags = GDT_VALID;
1121 MONTHCAL_CopyTime (&infoPtr->date, &dtdtc.st);
1122 return (BOOL) SendMessageA (GetParent (hwnd), WM_NOTIFY,
1123 (WPARAM)dtdtc.nmhdr.idFrom, (LPARAM)&dtdtc);
1127 static BOOL
1128 DATETIME_SendSimpleNotify (HWND hwnd, UINT code)
1130 NMHDR nmhdr;
1132 TRACE("%x\n",code);
1133 nmhdr.hwndFrom = hwnd;
1134 nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID);
1135 nmhdr.code = code;
1137 return (BOOL) SendMessageA (GetParent (hwnd), WM_NOTIFY,
1138 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1141 static LRESULT
1142 DATETIME_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1144 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd);
1145 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
1147 /* set size */
1148 infoPtr->rcClient.bottom = HIWORD(lParam);
1149 infoPtr->rcClient.right = LOWORD(lParam);
1151 TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right);
1153 /* use DrawEdge to adjust the size of rcEdge to get rcDraw */
1154 memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw));
1156 DrawEdge(NULL, &(infoPtr->rcDraw), EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1158 /* set the size of the button that drops the calendar down */
1159 /* FIXME: account for style that allows button on left side */
1160 infoPtr->calbutton.top = infoPtr->rcDraw.top;
1161 infoPtr->calbutton.bottom= infoPtr->rcDraw.bottom;
1162 infoPtr->calbutton.left = infoPtr->rcDraw.right-15;
1163 infoPtr->calbutton.right = infoPtr->rcDraw.right;
1165 /* set enable/disable button size for show none style being enabled */
1166 /* FIXME: these dimensions are completely incorrect */
1167 infoPtr->checkbox.top = infoPtr->rcDraw.top;
1168 infoPtr->checkbox.bottom = infoPtr->rcDraw.bottom;
1169 infoPtr->checkbox.left = infoPtr->rcDraw.left;
1170 infoPtr->checkbox.right = infoPtr->rcDraw.left + 10;
1172 /* update the position of the monthcal control */
1173 if(dwStyle & DTS_RIGHTALIGN)
1174 infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
1175 infoPtr->calbutton.left) + 145);
1176 else
1177 infoPtr->monthcal_pos.x = 8;
1179 infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom;
1180 ClientToScreen (hwnd, &(infoPtr->monthcal_pos));
1181 SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x,
1182 infoPtr->monthcal_pos.y,
1183 145, 150, 0);
1185 InvalidateRect(hwnd, NULL, FALSE);
1187 return 0;
1191 static LRESULT
1192 DATETIME_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1194 DATETIME_INFO *infoPtr;
1195 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1197 /* allocate memory for info structure */
1198 TRACE("%04x %08lx\n",wParam,lParam);
1199 infoPtr = (DATETIME_INFO *)Alloc (sizeof(DATETIME_INFO));
1200 if (infoPtr == NULL) {
1201 ERR("could not allocate info memory!\n");
1202 return 0;
1205 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1207 if (dwStyle & DTS_SHOWNONE) {
1208 infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0,
1209 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
1210 2,2,13,13,
1211 hwnd,
1212 0, (HINSTANCE)GetWindowLongA (hwnd, GWL_HINSTANCE), 0);
1213 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0);
1216 if (dwStyle & DTS_UPDOWN) {
1217 infoPtr->hUpdown=CreateUpDownControl (
1218 WS_CHILD | WS_BORDER | WS_VISIBLE,
1219 120,1,20,20,
1220 hwnd,1,0,0,
1221 UD_MAXVAL, UD_MINVAL, 0);
1224 infoPtr->fieldspec = (int *) Alloc (32*sizeof(int));
1225 infoPtr->fieldRect = (RECT *) Alloc (32*sizeof(RECT));
1226 infoPtr->buflen = (int *) Alloc (32*sizeof(int));
1227 infoPtr->nrFieldsAllocated = 32;
1229 DATETIME_SetFormat (hwnd, 0, 0);
1231 /* create the monthcal control */
1232 infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0,
1233 WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS,
1234 0, 0, 0, 0,
1235 GetParent(hwnd),
1236 0, 0, 0);
1238 /* initialize info structure */
1239 GetSystemTime (&infoPtr->date);
1240 infoPtr->dateValid = TRUE;
1241 infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT);
1242 return 0;
1246 static LRESULT
1247 DATETIME_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1249 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
1251 TRACE("\n");
1252 Free (infoPtr);
1253 SetWindowLongA( hwnd, 0, 0 );
1254 return 0;
1258 static LRESULT WINAPI
1259 DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1261 if (!DATETIME_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
1262 return DefWindowProcA( hwnd, uMsg, wParam, lParam );
1264 switch (uMsg)
1267 case DTM_GETSYSTEMTIME:
1268 return DATETIME_GetSystemTime (hwnd, wParam, lParam);
1270 case DTM_SETSYSTEMTIME:
1271 return DATETIME_SetSystemTime (hwnd, wParam, lParam);
1273 case DTM_GETRANGE:
1274 return DATETIME_GetRange(hwnd, lParam);
1276 case DTM_SETRANGE:
1277 return DATETIME_SetRange(hwnd, wParam, lParam);
1279 case DTM_SETFORMATA:
1280 return DATETIME_SetFormat (hwnd, wParam, lParam);
1282 case DTM_SETFORMATW:
1283 return DATETIME_SetFormatW (hwnd, wParam, lParam);
1285 case DTM_SETMCCOLOR:
1286 return DATETIME_SetMonthCalColor (hwnd, wParam, lParam);
1288 case DTM_GETMCCOLOR:
1289 return DATETIME_GetMonthCalColor (hwnd, wParam);
1291 case DTM_GETMONTHCAL:
1292 return DATETIME_GetMonthCal (hwnd);
1294 case DTM_SETMCFONT:
1295 return DATETIME_SetMonthCalFont (hwnd, wParam, lParam);
1297 case DTM_GETMCFONT:
1298 return DATETIME_GetMonthCalFont (hwnd);
1300 case WM_PARENTNOTIFY:
1301 return DATETIME_ParentNotify (hwnd, wParam, lParam);
1303 case WM_NOTIFY:
1304 return DATETIME_Notify (hwnd, wParam, lParam);
1306 case WM_GETDLGCODE:
1307 return DLGC_WANTARROWS | DLGC_WANTCHARS;
1309 case WM_PAINT:
1310 return DATETIME_Paint (hwnd, wParam);
1312 case WM_KEYDOWN:
1313 return DATETIME_KeyDown (hwnd, wParam, lParam);
1315 case WM_KILLFOCUS:
1316 return DATETIME_KillFocus (hwnd, wParam, lParam);
1318 case WM_SETFOCUS:
1319 return DATETIME_SetFocus (hwnd, wParam, lParam);
1321 case WM_SIZE:
1322 return DATETIME_Size (hwnd, wParam, lParam);
1324 case WM_LBUTTONDOWN:
1325 return DATETIME_LButtonDown (hwnd, wParam, lParam);
1327 case WM_LBUTTONUP:
1328 return DATETIME_LButtonUp (hwnd, wParam, lParam);
1330 case WM_CREATE:
1331 return DATETIME_Create (hwnd, wParam, lParam);
1333 case WM_DESTROY:
1334 return DATETIME_Destroy (hwnd, wParam, lParam);
1336 case WM_COMMAND:
1337 return DATETIME_Command (hwnd, wParam, lParam);
1339 default:
1340 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
1341 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
1342 uMsg, wParam, lParam);
1343 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1345 return 0;
1349 VOID
1350 DATETIME_Register (void)
1352 WNDCLASSA wndClass;
1354 TRACE("\n");
1355 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
1356 wndClass.style = CS_GLOBALCLASS;
1357 wndClass.lpfnWndProc = (WNDPROC)DATETIME_WindowProc;
1358 wndClass.cbClsExtra = 0;
1359 wndClass.cbWndExtra = sizeof(DATETIME_INFO *);
1360 wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW);
1361 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1362 wndClass.lpszClassName = DATETIMEPICK_CLASSA;
1364 RegisterClassA (&wndClass);
1368 VOID
1369 DATETIME_Unregister (void)
1371 TRACE("\n");
1372 UnregisterClassA (DATETIMEPICK_CLASSA, NULL);