1 | /*
|
---|
2 | * Month calendar control
|
---|
3 | *
|
---|
4 | * Copyright 1998, 1999 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 "winbase.h"
|
---|
18 | #include "commctrl.h"
|
---|
19 | #include "monthcal.h"
|
---|
20 |
|
---|
21 |
|
---|
22 | #define MONTHCAL_GetInfoPtr(hwnd) ((MONTHCAL_INFO *)GetWindowLongA (hwnd, 0))
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 |
|
---|
29 | static LRESULT
|
---|
30 | MONTHCAL_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
31 | {
|
---|
32 | MONTHCAL_INFO *infoPtr;
|
---|
33 |
|
---|
34 | /* allocate memory for info structure */
|
---|
35 | infoPtr = (MONTHCAL_INFO *)COMCTL32_Alloc (sizeof(MONTHCAL_INFO));
|
---|
36 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
37 |
|
---|
38 |
|
---|
39 | /* initialize info structure */
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 | return 0;
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 | static LRESULT
|
---|
48 | MONTHCAL_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
49 | {
|
---|
50 | MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd);
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 | /* free ipaddress info data */
|
---|
58 | COMCTL32_Free (infoPtr);
|
---|
59 |
|
---|
60 | return 0;
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 | LRESULT WINAPI
|
---|
67 | MONTHCAL_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
68 | {
|
---|
69 | switch (uMsg)
|
---|
70 | {
|
---|
71 |
|
---|
72 |
|
---|
73 | case WM_CREATE:
|
---|
74 | return MONTHCAL_Create (hwnd, wParam, lParam);
|
---|
75 |
|
---|
76 | case WM_DESTROY:
|
---|
77 | return MONTHCAL_Destroy (hwnd, wParam, lParam);
|
---|
78 |
|
---|
79 | default:
|
---|
80 | // if (uMsg >= WM_USER)
|
---|
81 | // ERR (monthcal, "unknown msg %04x wp=%08x lp=%08lx\n",
|
---|
82 | // uMsg, wParam, lParam);
|
---|
83 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
---|
84 | }
|
---|
85 | return 0;
|
---|
86 | }
|
---|
87 |
|
---|
88 |
|
---|
89 | VOID
|
---|
90 | MONTHCAL_Register (VOID)
|
---|
91 | {
|
---|
92 | WNDCLASSA wndClass;
|
---|
93 |
|
---|
94 | if (GlobalFindAtomA (MONTHCAL_CLASSA)) return;
|
---|
95 |
|
---|
96 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
97 | wndClass.style = CS_GLOBALCLASS;
|
---|
98 | wndClass.lpfnWndProc = (WNDPROC)MONTHCAL_WindowProc;
|
---|
99 | wndClass.cbClsExtra = 0;
|
---|
100 | wndClass.cbWndExtra = sizeof(MONTHCAL_INFO *);
|
---|
101 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
102 | wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
---|
103 | wndClass.lpszClassName = MONTHCAL_CLASSA;
|
---|
104 |
|
---|
105 | RegisterClassA (&wndClass);
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | VOID
|
---|
110 | MONTHCAL_Unregister (VOID)
|
---|
111 | {
|
---|
112 | if (GlobalFindAtomA (MONTHCAL_CLASSA))
|
---|
113 | UnregisterClassA (MONTHCAL_CLASSA, (HINSTANCE)NULL);
|
---|
114 | }
|
---|
115 |
|
---|