source: trunk/src/comctl32/animate.c@ 60

Last change on this file since 60 was 60, checked in by achimha, 26 years ago

* empty log message *

File size: 6.4 KB
Line 
1/*
2 * Animation control
3 *
4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 1999 Achim Hasenmueller
6 *
7 * NOTES
8 * This is just a dummy control. An author is needed! Any volunteers?
9 * I will only improve this control once in a while.
10 * Eric <ekohl@abo.rhein-zeitung.de>
11 *
12 * TODO:
13 * - All messages.
14 * - All notifications.
15 */
16
17
18#include "winbase.h"
19#include "commctrl.h"
20#include "comctl32.h"
21#include "animate.h"
22
23
24#define ANIMATE_GetInfoPtr(hwnd) ((ANIMATE_INFO *)GetWindowLongA (hwnd, 0))
25
26
27static BOOL
28ANIMATE_LoadResA (ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpName)
29{
30 HRSRC hrsrc;
31 HGLOBAL handle;
32
33 hrsrc = FindResourceA (hInst, lpName, "AVI");
34 if (!hrsrc)
35 return FALSE;
36
37 handle = LoadResource (hInst, hrsrc);
38 if (!handle)
39 return FALSE;
40
41 infoPtr->lpAvi = LockResource (handle);
42 if (!infoPtr->lpAvi)
43 return FALSE;
44
45 return TRUE;
46}
47
48
49static BOOL
50ANIMATE_LoadFileA (ANIMATE_INFO *infoPtr, LPSTR lpName)
51{
52 HANDLE handle;
53
54 infoPtr->hFile =
55 CreateFileA (lpName, GENERIC_READ, 0, NULL, OPEN_EXISTING,
56 FILE_ATTRIBUTE_NORMAL, 0);
57 if (!infoPtr->hFile)
58 return FALSE;
59
60 handle =
61 CreateFileMappingA (infoPtr->hFile, NULL, PAGE_READONLY | SEC_COMMIT,
62 0, 0, NULL);
63 if (!handle) {
64 CloseHandle (infoPtr->hFile);
65 infoPtr->hFile = 0;
66 return FALSE;
67 }
68
69 infoPtr->lpAvi = MapViewOfFile (handle, FILE_MAP_READ, 0, 0, 0);
70 if (!infoPtr->lpAvi) {
71 CloseHandle (infoPtr->hFile);
72 infoPtr->hFile = 0;
73 return FALSE;
74 }
75
76 return TRUE;
77}
78
79
80static VOID
81ANIMATE_Free (ANIMATE_INFO *infoPtr)
82{
83 if (infoPtr->hFile) {
84 UnmapViewOfFile (infoPtr->lpAvi);
85 CloseHandle (infoPtr->hFile);
86 infoPtr->lpAvi = NULL;
87 }
88 else {
89 GlobalFree ((HGLOBAL)infoPtr->lpAvi);
90 infoPtr->lpAvi = NULL;
91 }
92}
93
94
95static VOID
96ANIMATE_GetAviInfo (infoPtr)
97{
98
99
100}
101
102
103static LRESULT
104ANIMATE_OpenA (HWND hwnd, WPARAM wParam, LPARAM lParam)
105{
106 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hwnd);
107 HINSTANCE hInstance = (HINSTANCE)wParam;
108
109 ANIMATE_Free (infoPtr);
110
111 if (!lParam) {
112// TRACE (animate, "closing avi!\n");
113 return TRUE;
114 }
115
116 if (HIWORD(lParam)) {
117// FIXME (animate, "(\"%s\") empty stub!\n", (LPSTR)lParam);
118
119 if (ANIMATE_LoadResA (infoPtr, hInstance, (LPSTR)lParam)) {
120
121// FIXME (animate, "AVI resource found!\n");
122
123 }
124 else {
125// FIXME (animate, "No AVI resource found!\n");
126 if (ANIMATE_LoadFileA (infoPtr, (LPSTR)lParam)) {
127// FIXME (animate, "AVI file found!\n");
128 }
129 else {
130// FIXME (animate, "No AVI file found!\n");
131 return FALSE;
132 }
133 }
134 }
135 else {
136// FIXME (animate, "(%u) empty stub!\n", (WORD)LOWORD(lParam));
137
138 if (ANIMATE_LoadResA (infoPtr, hInstance,
139 MAKEINTRESOURCEA((INT)lParam))) {
140// FIXME (animate, "AVI resource found!\n");
141 }
142 else {
143// FIXME (animate, "No AVI resource found!\n");
144 return FALSE;
145 }
146 }
147
148 ANIMATE_GetAviInfo (infoPtr);
149
150 return TRUE;
151}
152
153
154/* << ANIMATE_Open32W >> */
155
156
157static LRESULT
158ANIMATE_Play (HWND hwnd, WPARAM wParam, LPARAM lParam)
159{
160 /* ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hwnd); */
161 INT nFrom = (INT)LOWORD(lParam);
162 INT nTo = (INT)HIWORD(lParam);
163 INT nRepeat = (INT)wParam;
164
165#if 0
166 /* nothing opened */
167 if (...)
168 return FALSE;
169#endif
170
171 if (nRepeat == -1) {
172
173// FIXME (animate, "(loop from=%d to=%d) empty stub!\n",
174// nFrom, nTo);
175
176 }
177 else {
178
179// FIXME (animate, "(repeat=%d from=%d to=%d) empty stub!\n",
180// nRepeat, nFrom, nTo);
181
182 }
183
184
185 return TRUE;
186}
187
188
189static LRESULT
190ANIMATE_Stop (HWND hwnd, WPARAM wParam, LPARAM lParam)
191{
192 /* ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hwnd); */
193
194#if 0
195 /* nothing opened */
196 if (...)
197 return FALSE;
198#endif
199
200 return TRUE;
201}
202
203
204
205static LRESULT
206ANIMATE_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
207{
208 ANIMATE_INFO *infoPtr;
209
210 /* allocate memory for info structure */
211 infoPtr = (ANIMATE_INFO *)COMCTL32_Alloc (sizeof(ANIMATE_INFO));
212 if (!infoPtr) {
213// ERR (animate, "could not allocate info memory!\n");
214 return 0;
215 }
216
217 /* store pointer to info structure */
218 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
219
220
221 /* set default settings */
222
223
224 return 0;
225}
226
227
228static LRESULT
229ANIMATE_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
230{
231 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hwnd);
232
233
234 /* free avi data */
235 ANIMATE_Free (infoPtr);
236
237 /* free animate info data */
238 COMCTL32_Free (infoPtr);
239
240 return 0;
241}
242
243
244#if 0
245static LRESULT
246ANIMATE_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
247{
248 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hwnd);
249/*
250 HBRUSH32 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
251 RECT32 rect;
252
253 GetClientRect32 (wndPtr->hwndSelf, &rect);
254 FillRect32 ((HDC32)wParam, &rect, hBrush);
255 DeleteObject32 (hBrush);
256*/
257 return TRUE;
258}
259#endif
260
261
262
263LRESULT WINAPI
264ANIMATE_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
265{
266 switch (uMsg)
267 {
268 case ACM_OPENA:
269 return ANIMATE_OpenA (hwnd, wParam, lParam);
270
271/* case ACM_OPEN32W: */
272/* return ANIMATE_Open32W (hwnd, wParam, lParam); */
273
274 case ACM_PLAY:
275 return ANIMATE_Play (hwnd, wParam, lParam);
276
277 case ACM_STOP:
278 return ANIMATE_Stop (hwnd, wParam, lParam);
279
280
281 case WM_CREATE:
282 return ANIMATE_Create (hwnd, wParam, lParam);
283
284 case WM_DESTROY:
285 return ANIMATE_Destroy (hwnd, wParam, lParam);
286
287/* case WM_ERASEBKGND: */
288/* return ANIMATE_EraseBackground (hwnd, wParam, lParam); */
289
290/* case WM_NCCREATE: */
291/* case WM_NCHITTEST: */
292/* case WM_PAINT: */
293/* case WM_SIZE: */
294/* case WM_STYLECHANGED: */
295/* case WM_TIMER: */
296
297 default:
298// if (uMsg >= WM_USER)
299// ERR (animate, "unknown msg %04x wp=%08x lp=%08lx\n",
300// uMsg, wParam, lParam);
301 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
302 }
303 return 0;
304}
305
306
307VOID
308ANIMATE_Register (VOID)
309{
310 WNDCLASSA wndClass;
311
312 if (GlobalFindAtomA (ANIMATE_CLASSA)) return;
313
314 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
315 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
316 wndClass.lpfnWndProc = (WNDPROC)ANIMATE_WindowProc;
317 wndClass.cbClsExtra = 0;
318 wndClass.cbWndExtra = sizeof(ANIMATE_INFO *);
319 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
320 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
321 wndClass.lpszClassName = ANIMATE_CLASSA;
322
323 RegisterClassA (&wndClass);
324}
325
326
327VOID
328ANIMATE_Unregister (VOID)
329{
330 if (GlobalFindAtomA (ANIMATE_CLASSA))
331 UnregisterClassA (ANIMATE_CLASSA, (HINSTANCE)NULL);
332}
333
Note: See TracBrowser for help on using the repository browser.