Large-scale renaming of all Win32 functions and types to use the
[wine/multimedia.git] / dlls / comctl32 / animate.c
blobd8ac4affb1ffa8492c982271197e31aba0294b73
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.
17 #include "win.h"
18 #include "commctrl.h"
19 #include "animate.h"
20 #include "debug.h"
22 #define ANIMATE_GetInfoPtr(wndPtr) ((ANIMATE_INFO *)wndPtr->wExtra[0])
25 static BOOL
26 ANIMATE_LoadResA (ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpName)
28 HRSRC hrsrc;
29 HGLOBAL handle;
31 hrsrc = FindResourceA (hInst, lpName, "AVI");
32 if (!hrsrc)
33 return FALSE;
35 handle = LoadResource (hInst, hrsrc);
36 if (!handle)
37 return FALSE;
39 infoPtr->lpAvi = LockResource (handle);
40 if (!infoPtr->lpAvi)
41 return FALSE;
43 return TRUE;
47 static BOOL
48 ANIMATE_LoadFileA (ANIMATE_INFO *infoPtr, LPSTR lpName)
50 HANDLE handle;
52 infoPtr->hFile =
53 CreateFileA (lpName, GENERIC_READ, 0, NULL, OPEN_EXISTING,
54 FILE_ATTRIBUTE_NORMAL, 0);
55 if (!infoPtr->hFile)
56 return FALSE;
58 handle =
59 CreateFileMappingA (infoPtr->hFile, NULL, PAGE_READONLY | SEC_COMMIT,
60 0, 0, NULL);
61 if (!handle) {
62 CloseHandle (infoPtr->hFile);
63 infoPtr->hFile = 0;
64 return FALSE;
67 infoPtr->lpAvi = MapViewOfFile (handle, FILE_MAP_READ, 0, 0, 0);
68 if (!infoPtr->lpAvi) {
69 CloseHandle (infoPtr->hFile);
70 infoPtr->hFile = 0;
71 return FALSE;
74 return TRUE;
78 static VOID
79 ANIMATE_Free (ANIMATE_INFO *infoPtr)
81 if (infoPtr->hFile) {
82 UnmapViewOfFile (infoPtr->lpAvi);
83 CloseHandle (infoPtr->hFile);
84 infoPtr->lpAvi = NULL;
86 else {
87 GlobalFree ((HGLOBAL)infoPtr->lpAvi);
88 infoPtr->lpAvi = NULL;
93 static VOID
94 ANIMATE_GetAviInfo (infoPtr)
101 static LRESULT
102 ANIMATE_OpenA (WND *wndPtr, WPARAM wParam, LPARAM lParam)
104 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
105 HINSTANCE hInstance = (HINSTANCE)wParam;
107 ANIMATE_Free (infoPtr);
109 if (!lParam) {
110 TRACE (animate, "closing avi!\n");
111 return TRUE;
114 if (HIWORD(lParam)) {
115 FIXME (animate, "(\"%s\") empty stub!\n", (LPSTR)lParam);
117 if (ANIMATE_LoadResA (infoPtr, hInstance, (LPSTR)lParam)) {
119 FIXME (animate, "AVI resource found!\n");
122 else {
123 FIXME (animate, "No AVI resource found!\n");
124 if (ANIMATE_LoadFileA (infoPtr, (LPSTR)lParam)) {
125 FIXME (animate, "AVI file found!\n");
127 else {
128 FIXME (animate, "No AVI file found!\n");
129 return FALSE;
133 else {
134 FIXME (animate, "(%u) empty stub!\n", (WORD)LOWORD(lParam));
136 if (ANIMATE_LoadResA (infoPtr, hInstance,
137 MAKEINTRESOURCEA((INT)lParam))) {
138 FIXME (animate, "AVI resource found!\n");
140 else {
141 FIXME (animate, "No AVI resource found!\n");
142 return FALSE;
146 ANIMATE_GetAviInfo (infoPtr);
148 return TRUE;
152 /* << ANIMATE_Open32W >> */
155 static LRESULT
156 ANIMATE_Play (WND *wndPtr, WPARAM wParam, LPARAM lParam)
158 /* ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr); */
159 INT nFrom = (INT)LOWORD(lParam);
160 INT nTo = (INT)HIWORD(lParam);
161 INT nRepeat = (INT)wParam;
163 #if 0
164 /* nothing opened */
165 if (...)
166 return FALSE;
167 #endif
169 if (nRepeat == -1) {
171 FIXME (animate, "(loop from=%d to=%d) empty stub!\n",
172 nFrom, nTo);
175 else {
177 FIXME (animate, "(repeat=%d from=%d to=%d) empty stub!\n",
178 nRepeat, nFrom, nTo);
183 return TRUE;
187 static LRESULT
188 ANIMATE_Stop (WND *wndPtr, WPARAM wParam, LPARAM lParam)
190 /* ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr); */
192 #if 0
193 /* nothing opened */
194 if (...)
195 return FALSE;
196 #endif
198 return TRUE;
203 static LRESULT
204 ANIMATE_Create (WND *wndPtr, WPARAM wParam, LPARAM lParam)
206 ANIMATE_INFO *infoPtr;
208 /* allocate memory for info structure */
209 infoPtr = (ANIMATE_INFO *)COMCTL32_Alloc (sizeof(ANIMATE_INFO));
210 wndPtr->wExtra[0] = (DWORD)infoPtr;
212 if (infoPtr == NULL) {
213 ERR (animate, "could not allocate info memory!\n");
214 return 0;
217 if ((ANIMATE_INFO*)wndPtr->wExtra[0] != infoPtr) {
218 ERR (animate, "pointer assignment error!\n");
219 return 0;
222 /* set default settings */
225 return 0;
229 static LRESULT
230 ANIMATE_Destroy (WND *wndPtr, WPARAM wParam, LPARAM lParam)
232 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
235 /* free avi data */
236 ANIMATE_Free (infoPtr);
238 /* free animate info data */
239 COMCTL32_Free (infoPtr);
241 return 0;
245 #if 0
246 static LRESULT
247 ANIMATE_EraseBackground (WND *wndPtr, WPARAM wParam, LPARAM lParam)
249 ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(wndPtr);
251 HBRUSH32 hBrush = CreateSolidBrush32 (infoPtr->clrBk);
252 RECT32 rect;
254 GetClientRect32 (wndPtr->hwndSelf, &rect);
255 FillRect32 ((HDC32)wParam, &rect, hBrush);
256 DeleteObject32 (hBrush);
258 return TRUE;
260 #endif
264 LRESULT WINAPI
265 ANIMATE_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
267 WND *wndPtr = WIN_FindWndPtr(hwnd);
269 switch (uMsg)
271 case ACM_OPENA:
272 return ANIMATE_OpenA (wndPtr, wParam, lParam);
274 /* case ACM_OPEN32W: */
275 /* return ANIMATE_Open32W (wndPtr, wParam, lParam); */
277 case ACM_PLAY:
278 return ANIMATE_Play (wndPtr, wParam, lParam);
280 case ACM_STOP:
281 return ANIMATE_Stop (wndPtr, wParam, lParam);
284 case WM_CREATE:
285 return ANIMATE_Create (wndPtr, wParam, lParam);
287 case WM_DESTROY:
288 return ANIMATE_Destroy (wndPtr, wParam, lParam);
290 /* case WM_ERASEBKGND: */
291 /* return ANIMATE_EraseBackground (wndPtr, wParam, lParam); */
293 /* case WM_NCCREATE: */
294 /* case WM_NCHITTEST: */
295 /* case WM_PAINT: */
296 /* case WM_SIZE: */
297 /* case WM_STYLECHANGED: */
298 /* case WM_TIMER: */
300 default:
301 if (uMsg >= WM_USER)
302 ERR (animate, "unknown msg %04x wp=%08x lp=%08lx\n",
303 uMsg, wParam, lParam);
304 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
306 return 0;
310 VOID
311 ANIMATE_Register (VOID)
313 WNDCLASSA wndClass;
315 if (GlobalFindAtomA (ANIMATE_CLASSA)) return;
317 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
318 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
319 wndClass.lpfnWndProc = (WNDPROC)ANIMATE_WindowProc;
320 wndClass.cbClsExtra = 0;
321 wndClass.cbWndExtra = sizeof(ANIMATE_INFO *);
322 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
323 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
324 wndClass.lpszClassName = ANIMATE_CLASSA;
326 RegisterClassA (&wndClass);
330 VOID
331 ANIMATE_Unregister (VOID)
333 if (GlobalFindAtomA (ANIMATE_CLASSA))
334 UnregisterClassA (ANIMATE_CLASSA, (HINSTANCE)NULL);