Added missing includes (the PSP handling was incorrect, as the
[wine/testsucceed.git] / dlls / comctl32 / animate.c
blobfc5015925880e8a881e5c5c96fdc25f8ad00f56b
1 /*
2 * Animation control
4 * Copyright 1998 Eric Kohl
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>
11 * TODO:
12 * - All messages.
13 * - All notifications.
16 #include "windows.h"
17 #include "winnt.h"
18 #include "winbase.h"
19 #include "commctrl.h"
20 #include "animate.h"
21 #include "win.h"
22 #include "debug.h"
25 #define ANIMATE_GetInfoPtr(wndPtr) ((ANIMATE_INFO *)wndPtr->wExtra[0])
28 static BOOL32
29 ANIMATE_LoadRes32A (ANIMATE_INFO *infoPtr, HINSTANCE32 hInst, LPSTR lpName)
31 HRSRC32 hrsrc;
32 HGLOBAL32 handle;
34 hrsrc = FindResource32A (hInst, lpName, "AVI");
35 if (!hrsrc)
36 return FALSE;
38 handle = LoadResource32 (hInst, hrsrc);
39 if (!handle)
40 return FALSE;
42 infoPtr->lpAvi = LockResource32 (handle);
43 if (!infoPtr->lpAvi)
44 return FALSE;
46 return TRUE;
50 static BOOL32
51 ANIMATE_LoadFile32A (ANIMATE_INFO *infoPtr, LPSTR lpName)
53 HANDLE32 handle;
55 infoPtr->hFile =
56 CreateFile32A (lpName, GENERIC_READ, 0, NULL, OPEN_EXISTING,
57 FILE_ATTRIBUTE_NORMAL, 0);
58 if (!infoPtr->hFile)
59 return FALSE;
61 handle =
62 CreateFileMapping32A (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;
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;
77 return TRUE;
81 static VOID
82 ANIMATE_Free (ANIMATE_INFO *infoPtr)
84 if (infoPtr->hFile) {
85 UnmapViewOfFile (infoPtr->lpAvi);
86 CloseHandle (infoPtr->hFile);
87 infoPtr->lpAvi = NULL;
89 else {
90 GlobalFree32 ((HGLOBAL32)infoPtr->lpAvi);
91 infoPtr->lpAvi = NULL;
96 static VOID
97 ANIMATE_GetAviInfo (infoPtr)
104 static LRESULT
105 ANIMATE_Open32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
107 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
108 HINSTANCE32 hInstance = (HINSTANCE32)wParam;
110 ANIMATE_Free (infoPtr);
112 if (!lParam) {
113 TRACE (animate, "closing avi!\n");
114 return TRUE;
117 if (HIWORD(lParam)) {
118 FIXME (animate, "(\"%s\") empty stub!\n", (LPSTR)lParam);
120 if (ANIMATE_LoadRes32A (infoPtr, hInstance, (LPSTR)lParam)) {
122 FIXME (animate, "AVI resource found!\n");
125 else {
126 FIXME (animate, "No AVI resource found!\n");
127 if (ANIMATE_LoadFile32A (infoPtr, (LPSTR)lParam)) {
128 FIXME (animate, "AVI file found!\n");
130 else {
131 FIXME (animate, "No AVI file found!\n");
132 return FALSE;
136 else {
137 FIXME (animate, "(%u) empty stub!\n", (WORD)LOWORD(lParam));
139 if (ANIMATE_LoadRes32A (infoPtr, hInstance,
140 MAKEINTRESOURCE32A((INT32)lParam))) {
141 FIXME (animate, "AVI resource found!\n");
143 else {
144 FIXME (animate, "No AVI resource found!\n");
145 return FALSE;
149 ANIMATE_GetAviInfo (infoPtr);
151 return TRUE;
155 /* << ANIMATE_Open32W >> */
158 static LRESULT
159 ANIMATE_Play (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
161 /* ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr); */
162 INT32 nFrom = (INT32)LOWORD(lParam);
163 INT32 nTo = (INT32)HIWORD(lParam);
164 INT32 nRepeat = (INT32)wParam;
166 #if 0
167 /* nothing opened */
168 if (...)
169 return FALSE;
170 #endif
172 if (nRepeat == -1) {
174 FIXME (animate, "(loop from=%d to=%d) empty stub!\n",
175 nFrom, nTo);
178 else {
180 FIXME (animate, "(repeat=%d from=%d to=%d) empty stub!\n",
181 nRepeat, nFrom, nTo);
186 return TRUE;
190 static LRESULT
191 ANIMATE_Stop (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
193 /* ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr); */
195 #if 0
196 /* nothing opened */
197 if (...)
198 return FALSE;
199 #endif
201 return TRUE;
206 static LRESULT
207 ANIMATE_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
209 ANIMATE_INFO *infoPtr;
211 /* allocate memory for info structure */
212 infoPtr = (ANIMATE_INFO *)COMCTL32_Alloc (sizeof(ANIMATE_INFO));
213 wndPtr->wExtra[0] = (DWORD)infoPtr;
215 if (infoPtr == NULL) {
216 ERR (animate, "could not allocate info memory!\n");
217 return 0;
220 if ((ANIMATE_INFO*)wndPtr->wExtra[0] != infoPtr) {
221 ERR (animate, "pointer assignment error!\n");
222 return 0;
225 /* set default settings */
228 return 0;
232 static LRESULT
233 ANIMATE_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
235 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
238 /* free avi data */
239 ANIMATE_Free (infoPtr);
241 /* free animate info data */
242 COMCTL32_Free (infoPtr);
244 return 0;
248 #if 0
249 static LRESULT
250 ANIMATE_EraseBackground (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
252 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
254 HBRUSH32 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
255 RECT32 rect;
257 GetClientRect32 (wndPtr->hwndSelf, &rect);
258 FillRect32 ((HDC32)wParam, &rect, hBrush);
259 DeleteObject32 (hBrush);
261 return TRUE;
263 #endif
267 LRESULT WINAPI
268 ANIMATE_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
270 WND *wndPtr = WIN_FindWndPtr(hwnd);
272 switch (uMsg)
274 case ACM_OPEN32A:
275 return ANIMATE_Open32A (wndPtr, wParam, lParam);
277 /* case ACM_OPEN32W: */
278 /* return ANIMATE_Open32W (wndPtr, wParam, lParam); */
280 case ACM_PLAY:
281 return ANIMATE_Play (wndPtr, wParam, lParam);
283 case ACM_STOP:
284 return ANIMATE_Stop (wndPtr, wParam, lParam);
287 case WM_CREATE:
288 return ANIMATE_Create (wndPtr, wParam, lParam);
290 case WM_DESTROY:
291 return ANIMATE_Destroy (wndPtr, wParam, lParam);
293 /* case WM_ERASEBKGND: */
294 /* return ANIMATE_EraseBackground (wndPtr, wParam, lParam); */
296 /* case WM_NCCREATE: */
297 /* case WM_NCHITTEST: */
298 /* case WM_PAINT: */
299 /* case WM_SIZE: */
300 /* case WM_STYLECHANGED: */
301 /* case WM_TIMER: */
303 default:
304 if (uMsg >= WM_USER)
305 ERR (animate, "unknown msg %04x wp=%08x lp=%08lx\n",
306 uMsg, wParam, lParam);
307 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
309 return 0;
313 VOID
314 ANIMATE_Register (VOID)
316 WNDCLASS32A wndClass;
318 if (GlobalFindAtom32A (ANIMATE_CLASS32A)) return;
320 ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
321 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
322 wndClass.lpfnWndProc = (WNDPROC32)ANIMATE_WindowProc;
323 wndClass.cbClsExtra = 0;
324 wndClass.cbWndExtra = sizeof(ANIMATE_INFO *);
325 wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
326 wndClass.hbrBackground = (HBRUSH32)(COLOR_BTNFACE + 1);
327 wndClass.lpszClassName = ANIMATE_CLASS32A;
329 RegisterClass32A (&wndClass);
333 VOID
334 ANIMATE_Unregister (VOID)
336 if (GlobalFindAtom32A (ANIMATE_CLASS32A))
337 UnregisterClass32A (ANIMATE_CLASS32A, (HINSTANCE32)NULL);