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

Last change on this file since 1036 was 496, checked in by cbratschi, 26 years ago

wine-990731 update

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