1 | /* $Id: monthcal.c,v 1.3 1999-06-10 16:22:01 achimha Exp $ */
|
---|
2 | /*
|
---|
3 | * Month calendar control
|
---|
4 | *
|
---|
5 | * Copyright 1998, 1999 Eric Kohl
|
---|
6 | * Copyright 1999 Achim Hasenmueller
|
---|
7 | *
|
---|
8 | * NOTES
|
---|
9 | * This is just a dummy control. An author is needed! Any volunteers?
|
---|
10 | * I will only improve this control once in a while.
|
---|
11 | * Eric <ekohl@abo.rhein-zeitung.de>
|
---|
12 | *
|
---|
13 | * TODO:
|
---|
14 | * - All messages.
|
---|
15 | * - All notifications.
|
---|
16 | *
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "winbase.h"
|
---|
20 | #include "commctrl.h"
|
---|
21 | #include "monthcal.h"
|
---|
22 |
|
---|
23 |
|
---|
24 | #define MONTHCAL_GetInfoPtr(hwnd) ((MONTHCAL_INFO *)GetWindowLongA (hwnd, 0))
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 |
|
---|
29 |
|
---|
30 |
|
---|
31 | static LRESULT
|
---|
32 | MONTHCAL_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
33 | {
|
---|
34 | MONTHCAL_INFO *infoPtr;
|
---|
35 |
|
---|
36 | /* allocate memory for info structure */
|
---|
37 | infoPtr = (MONTHCAL_INFO *)COMCTL32_Alloc (sizeof(MONTHCAL_INFO));
|
---|
38 | SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
|
---|
39 |
|
---|
40 |
|
---|
41 | /* initialize info structure */
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | return 0;
|
---|
46 | }
|
---|
47 |
|
---|
48 |
|
---|
49 | static LRESULT
|
---|
50 | MONTHCAL_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
51 | {
|
---|
52 | MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd);
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 | /* free ipaddress info data */
|
---|
60 | COMCTL32_Free (infoPtr);
|
---|
61 |
|
---|
62 | return 0;
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | LRESULT WINAPI
|
---|
69 | MONTHCAL_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
---|
70 | {
|
---|
71 | switch (uMsg)
|
---|
72 | {
|
---|
73 |
|
---|
74 |
|
---|
75 | case WM_CREATE:
|
---|
76 | return MONTHCAL_Create (hwnd, wParam, lParam);
|
---|
77 |
|
---|
78 | case WM_DESTROY:
|
---|
79 | return MONTHCAL_Destroy (hwnd, wParam, lParam);
|
---|
80 |
|
---|
81 | default:
|
---|
82 | // if (uMsg >= WM_USER)
|
---|
83 | // ERR (monthcal, "unknown msg %04x wp=%08x lp=%08lx\n",
|
---|
84 | // uMsg, wParam, lParam);
|
---|
85 | return DefWindowProcA (hwnd, uMsg, wParam, lParam);
|
---|
86 | }
|
---|
87 | return 0;
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | VOID
|
---|
92 | MONTHCAL_Register (VOID)
|
---|
93 | {
|
---|
94 | WNDCLASSA wndClass;
|
---|
95 |
|
---|
96 | if (GlobalFindAtomA (MONTHCAL_CLASSA)) return;
|
---|
97 |
|
---|
98 | ZeroMemory (&wndClass, sizeof(WNDCLASSA));
|
---|
99 | wndClass.style = CS_GLOBALCLASS;
|
---|
100 | wndClass.lpfnWndProc = (WNDPROC)MONTHCAL_WindowProc;
|
---|
101 | wndClass.cbClsExtra = 0;
|
---|
102 | wndClass.cbWndExtra = sizeof(MONTHCAL_INFO *);
|
---|
103 | wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
|
---|
104 | wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
---|
105 | wndClass.lpszClassName = MONTHCAL_CLASSA;
|
---|
106 |
|
---|
107 | RegisterClassA (&wndClass);
|
---|
108 | }
|
---|
109 |
|
---|
110 |
|
---|
111 | VOID
|
---|
112 | MONTHCAL_Unregister (VOID)
|
---|
113 | {
|
---|
114 | if (GlobalFindAtomA (MONTHCAL_CLASSA))
|
---|
115 | UnregisterClassA (MONTHCAL_CLASSA, (HINSTANCE)NULL);
|
---|
116 | }
|
---|
117 |
|
---|