- New implementation of SendMessage, ReceiveMessage, ReplyMessage functions
[wine] / dlls / comctl32 / datetime.c
1 /*
2  * Date and time picker control
3  *
4  * Copyright 1998 Eric Kohl
5  *
6  * NOTES
7  *   This is just a dummy control. An author is needed! Any volunteers?
8  *   I will only improve this control once in a while.
9  *     Eric <ekohl@abo.rhein-zeitung.de>
10  *
11  * TODO:
12  *   - All messages.
13  *   - All notifications.
14  *
15  */
16
17 #include "commctrl.h"
18 #include "datetime.h"
19 #include "win.h"
20 #include "debug.h"
21
22
23 #define DATETIME_GetInfoPtr(wndPtr) ((DATETIME_INFO *)wndPtr->wExtra[0])
24
25
26
27
28
29
30 static LRESULT
31 DATETIME_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
32 {
33     DATETIME_INFO *infoPtr;
34
35     /* allocate memory for info structure */
36     infoPtr = (DATETIME_INFO *)COMCTL32_Alloc (sizeof(DATETIME_INFO));
37     wndPtr->wExtra[0] = (DWORD)infoPtr;
38
39     if (infoPtr == NULL) {
40         ERR (datetime, "could not allocate info memory!\n");
41         return 0;
42     }
43
44     if ((DATETIME_INFO*)wndPtr->wExtra[0] != infoPtr) {
45         ERR (datetime, "pointer assignment error!\n");
46         return 0;
47     }
48
49     /* initialize info structure */
50
51
52
53     return 0;
54 }
55
56
57 static LRESULT
58 DATETIME_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
59 {
60     DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(wndPtr);
61
62     /* free datetime info data */
63     COMCTL32_Free (infoPtr);
64
65     return 0;
66 }
67
68
69
70
71 LRESULT WINAPI
72 DATETIME_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
73 {
74     WND *wndPtr = WIN_FindWndPtr(hwnd);
75
76     switch (uMsg)
77     {
78
79     case DTM_GETSYSTEMTIME:
80         FIXME (datetime, "Unimplemented msg DTM_GETSYSTEMTIME\n");
81         return GDT_VALID;
82
83     case DTM_SETSYSTEMTIME:
84         FIXME (datetime, "Unimplemented msg DTM_SETSYSTEMTIME\n");
85         return 1;
86
87     case DTM_GETRANGE:
88         FIXME (datetime, "Unimplemented msg DTM_GETRANGE\n");
89         return 0;
90
91     case DTM_SETRANGE:
92         FIXME (datetime, "Unimplemented msg DTM_SETRANGE\n");
93         return 1;
94
95     case DTM_SETFORMAT32A:
96         FIXME (datetime, "Unimplemented msg DTM_SETFORMAT32A\n");
97         return 1;
98
99     case DTM_SETFORMAT32W:
100         FIXME (datetime, "Unimplemented msg DTM_SETFORMAT32W\n");
101         return 1;
102
103     case DTM_SETMCCOLOR:
104         FIXME (datetime, "Unimplemented msg DTM_SETMCCOLOR\n");
105         return 0;
106
107     case DTM_GETMCCOLOR:
108         FIXME (datetime, "Unimplemented msg DTM_GETMCCOLOR\n");
109         return 0;
110
111     case DTM_GETMONTHCAL:
112         FIXME (datetime, "Unimplemented msg DTM_GETMONTHCAL\n");
113         return 0;
114
115     case DTM_SETMCFONT:
116         FIXME (datetime, "Unimplemented msg DTM_SETMCFONT\n");
117         return 0;
118
119     case DTM_GETMCFONT:
120         FIXME (datetime, "Unimplemented msg DTM_GETMCFONT\n");
121         return 0;
122
123         case WM_CREATE:
124             return DATETIME_Create (wndPtr, wParam, lParam);
125
126         case WM_DESTROY:
127             return DATETIME_Destroy (wndPtr, wParam, lParam);
128
129         default:
130             if (uMsg >= WM_USER)
131                 ERR (datetime, "unknown msg %04x wp=%08x lp=%08lx\n",
132                      uMsg, wParam, lParam);
133             return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
134     }
135     return 0;
136 }
137
138
139 VOID
140 DATETIME_Register (VOID)
141 {
142     WNDCLASS32A wndClass;
143
144     if (GlobalFindAtom32A (DATETIMEPICK_CLASS32A)) return;
145
146     ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
147     wndClass.style         = CS_GLOBALCLASS;
148     wndClass.lpfnWndProc   = (WNDPROC32)DATETIME_WindowProc;
149     wndClass.cbClsExtra    = 0;
150     wndClass.cbWndExtra    = sizeof(DATETIME_INFO *);
151     wndClass.hCursor       = LoadCursor32A (0, IDC_ARROW32A);
152     wndClass.hbrBackground = (HBRUSH32)(COLOR_WINDOW + 1);
153     wndClass.lpszClassName = DATETIMEPICK_CLASS32A;
154  
155     RegisterClass32A (&wndClass);
156 }
157
158
159 VOID
160 DATETIME_Unregister (VOID)
161 {
162     if (GlobalFindAtom32A (DATETIMEPICK_CLASS32A))
163         UnregisterClass32A (DATETIMEPICK_CLASS32A, (HINSTANCE32)NULL);
164 }
165