Changeset 5630 for trunk/src/comctl32/animate.c
- Timestamp:
- Apr 29, 2001, 12:30:59 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/animate.c
r5418 r5630 4 4 * 5 5 * Copyright 1998, 1999 Eric Kohl 6 * 6 * 1999 Eric Pouech 7 7 * 8 8 * NOTES … … 15 15 */ 16 16 17 17 #include <string.h> 18 18 #include "winbase.h" 19 19 #include "commctrl.h" 20 20 #include "vfw.h" 21 21 #include "mmsystem.h" 22 #include "services.h"23 22 #include "debugtools.h" 24 23 #ifdef __WIN32OS2__ … … 31 30 { 32 31 #ifdef __WIN32OS2__ 33 COMCTL32_HEADER header; 34 #endif 35 36 /* pointer to msvideo functions. it's easier to put them here. 37 * to be correct, they should be defined on a per process basis, but 38 * this would required a per process storage. We're using a per object 39 * storage instead, which is not efficient on memory usage, but 40 * will lead to less bugs in the future 41 */ 42 #ifdef __WIN32OS2__ 43 HIC (* WINAPI fnICOpen)(DWORD, DWORD, UINT); 44 LRESULT (* WINAPI fnICClose)(HIC); 45 LRESULT (* WINAPI fnICSendMessage)(HIC, UINT, DWORD, DWORD); 46 DWORD (* WINAPIV fnICDecompress)(HIC,DWORD,LPBITMAPINFOHEADER,LPVOID,LPBITMAPINFOHEADER,LPVOID); 47 48 HMMIO (* WINAPI fnmmioOpenA)(LPSTR,MMIOINFO*,DWORD); 49 HMMIO (* WINAPI fnmmioOpenW)(LPSTR,MMIOINFO*,DWORD); 50 MMRESULT (* WINAPI fnmmioClose)(HMMIO,UINT); 51 UINT (* WINAPI fnmmioAscend)(HMMIO,MMCKINFO*,UINT); 52 UINT (* WINAPI fnmmioDescend)(HMMIO,MMCKINFO*,const MMCKINFO*,UINT); 53 LONG (* WINAPI fnmmioSeek)(HMMIO,LONG,INT); 54 LONG (* WINAPI fnmmioRead)(HMMIO,HPSTR,LONG); 55 #else 56 HIC WINAPI (*fnICOpen)(DWORD, DWORD, UINT); 57 LRESULT WINAPI (*fnICClose)(HIC); 58 LRESULT WINAPI (*fnICSendMessage)(HIC, UINT, DWORD, DWORD); 59 DWORD WINAPIV (*fnICDecompress)(HIC,DWORD,LPBITMAPINFOHEADER,LPVOID,LPBITMAPINFOHEADER,LPVOID); 60 61 HMMIO WINAPI (*fnmmioOpenA)(LPSTR,MMIOINFO*,DWORD); 62 MMRESULT WINAPI (*fnmmioClose)(HMMIO,UINT); 63 UINT WINAPI (*fnmmioAscend)(HMMIO,MMCKINFO*,UINT); 64 UINT WINAPI (*fnmmioDescend)(HMMIO,MMCKINFO*,const MMCKINFO*,UINT); 65 LONG WINAPI (*fnmmioSeek)(HMMIO,LONG,INT); 66 LONG WINAPI (*fnmmioRead)(HMMIO,HPSTR,LONG); 67 #endif 68 32 COMCTL32_HEADER header; 33 #endif 69 34 /* reference to input stream (file or resource) */ 70 HGLOBAL 71 HMMIO hMMio;/* handle to mmio stream */72 HWND 35 HGLOBAL hRes; 36 HMMIO hMMio; /* handle to mmio stream */ 37 HWND hWnd; 73 38 /* information on the loaded AVI file */ 74 MainAVIHeader 75 AVIStreamHeader 76 LPBITMAPINFOHEADER 77 LPDWORD 39 MainAVIHeader mah; 40 AVIStreamHeader ash; 41 LPBITMAPINFOHEADER inbih; 42 LPDWORD lpIndex; 78 43 /* data for the decompressor */ 79 HIC 80 LPBITMAPINFOHEADER 81 LPVOID 82 LPVOID 44 HIC hic; 45 LPBITMAPINFOHEADER outbih; 46 LPVOID indata; 47 LPVOID outdata; 83 48 /* data for the background mechanism */ 84 CRITICAL_SECTION 85 HANDLE 86 UINT 49 CRITICAL_SECTION cs; 50 HANDLE hThread; 51 UINT uTimer; 87 52 /* data for playing the file */ 88 int 89 int 90 int 91 int 53 int nFromFrame; 54 int nToFrame; 55 int nLoop; 56 int currFrame; 92 57 /* tranparency info*/ 93 COLORREF transparentColor;94 HBRUSH 95 HBITMAP 58 COLORREF transparentColor; 59 HBRUSH hbrushBG; 60 HBITMAP hbmPrevFrame; 96 61 } ANIMATE_INFO; 97 62 98 63 #define ANIMATE_GetInfoPtr(hWnd) ((ANIMATE_INFO *)GetWindowLongA(hWnd, 0)) 99 #define ANIMATE_COLOR_NONE 0xffffffff 100 101 HMODULE hModWinmm; 64 #define ANIMATE_COLOR_NONE 0xffffffff 102 65 103 66 static void ANIMATE_Notify(ANIMATE_INFO* infoPtr, UINT notif) 104 67 { 105 SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND, 106 MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif), 107 68 SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND, 69 MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif), 70 (LPARAM)infoPtr->hWnd); 108 71 } 109 72 … … 114 77 #endif 115 78 { 116 HRSRC 117 MMIOINFO 118 LPVOID 119 79 HRSRC hrsrc; 80 MMIOINFO mminfo; 81 LPVOID lpAvi; 82 120 83 #ifdef __WIN32OS2__ 121 84 if (unicode) … … 127 90 #endif 128 91 if (!hrsrc) 129 130 92 return FALSE; 93 131 94 infoPtr->hRes = LoadResource(hInst, hrsrc); 132 95 if (!infoPtr->hRes) 133 134 96 return FALSE; 97 135 98 lpAvi = LockResource(infoPtr->hRes); 136 99 if (!lpAvi) 137 138 100 return FALSE; 101 139 102 memset(&mminfo, 0, sizeof(mminfo)); 140 103 mminfo.fccIOProc = FOURCC_MEM; 141 104 mminfo.pchBuffer = (LPSTR)lpAvi; 142 105 mminfo.cchBuffer = SizeofResource(hInst, hrsrc); 143 infoPtr->hMMio = infoPtr->fnmmioOpenA(NULL, &mminfo, MMIO_READ); 144 106 infoPtr->hMMio = mmioOpenA(NULL, &mminfo, MMIO_READ); 145 107 if (!infoPtr->hMMio) { 146 147 108 GlobalFree((HGLOBAL)lpAvi); 109 return FALSE; 148 110 } 149 111 … … 160 122 #ifdef __WIN32OS2__ 161 123 if (unicode) 162 infoPtr->hMMio = infoPtr->fnmmioOpenW(lpName,NULL,MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);124 infoPtr->hMMio = mmioOpenW(lpName,NULL,MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 163 125 else 164 infoPtr->hMMio = infoPtr->fnmmioOpenA((LPSTR)lpName,NULL,MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);126 infoPtr->hMMio = mmioOpenA((LPSTR)lpName,NULL,MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 165 127 #else 166 infoPtr->hMMio = infoPtr->fnmmioOpenA((LPSTR)lpName, NULL, 167 MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 168 #endif 169 128 infoPtr->hMMio = mmioOpenA((LPSTR)lpName, NULL, 129 MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 130 #endif 170 131 if (!infoPtr->hMMio) 171 172 132 return FALSE; 133 173 134 return TRUE; 174 135 } … … 180 141 181 142 /* should stop playing */ 182 if (infoPtr->hThread) 143 if (infoPtr->hThread) 183 144 { 184 145 if (!TerminateThread(infoPtr->hThread,0)) 185 146 WARN("could not destroy animation thread!\n"); 186 147 infoPtr->hThread = 0; 187 148 } 188 149 if (infoPtr->uTimer) { 189 190 150 KillTimer(infoPtr->hWnd, infoPtr->uTimer); 151 infoPtr->uTimer = 0; 191 152 } 192 153 … … 202 163 { 203 164 if (infoPtr->hMMio) { 204 205 infoPtr->fnmmioClose(infoPtr->hMMio, 0);206 207 208 209 210 211 212 213 214 215 (infoPtr->fnICClose)(infoPtr->hic);216 217 218 219 220 221 222 223 224 225 165 ANIMATE_DoStop(infoPtr); 166 mmioClose(infoPtr->hMMio, 0); 167 if (infoPtr->hRes) { 168 FreeResource(infoPtr->hRes); 169 infoPtr->hRes = 0; 170 } 171 if (infoPtr->lpIndex) { 172 HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex); 173 infoPtr->lpIndex = NULL; 174 } 175 if (infoPtr->hic) { 176 ICClose(infoPtr->hic); 177 infoPtr->hic = 0; 178 } 179 if (infoPtr->inbih) { 180 HeapFree(GetProcessHeap(), 0, infoPtr->inbih); 181 infoPtr->inbih = NULL; 182 } 183 if (infoPtr->outbih) { 184 HeapFree(GetProcessHeap(), 0, infoPtr->outbih); 185 infoPtr->outbih = NULL; 186 } 226 187 if( infoPtr->indata ) 227 188 { 228 189 HeapFree(GetProcessHeap(), 0, infoPtr->indata); 229 190 infoPtr->indata = NULL; 230 191 } 231 192 if( infoPtr->outdata ) 232 193 { 233 194 HeapFree(GetProcessHeap(), 0, infoPtr->outdata); 234 195 infoPtr->outdata = NULL; 235 196 } 236 197 if( infoPtr->hbmPrevFrame ) 237 198 { 238 199 DeleteObject(infoPtr->hbmPrevFrame); 239 200 infoPtr->hbmPrevFrame = 0; 240 201 } 241 242 243 244 245 246 247 248 } 249 infoPtr->transparentColor = ANIMATE_COLOR_NONE; 202 infoPtr->indata = infoPtr->outdata = NULL; 203 infoPtr->hWnd = 0; 204 infoPtr->hMMio = 0; 205 206 memset(&infoPtr->mah, 0, sizeof(infoPtr->mah)); 207 memset(&infoPtr->ash, 0, sizeof(infoPtr->ash)); 208 infoPtr->nFromFrame = infoPtr->nToFrame = infoPtr->nLoop = infoPtr->currFrame = 0; 209 } 210 infoPtr->transparentColor = ANIMATE_COLOR_NONE; 250 211 } 251 212 252 213 static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSource) 253 { 214 { 254 215 HDC hdcMask; 255 216 HBITMAP hbmMask; 256 HBITMAP hbmOld; 257 217 HBITMAP hbmOld; 218 258 219 /* create a transparency mask */ 259 220 hdcMask = CreateCompatibleDC(hdcDest); 260 hbmMask = CreateBitmap(infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, 1,1,NULL); 261 hbmOld = SelectObject(hdcMask, hbmMask); 221 hbmMask = CreateBitmap(infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, 1,1,NULL); 222 hbmOld = SelectObject(hdcMask, hbmMask); 262 223 263 224 SetBkColor(hdcSource,infoPtr->transparentColor); 264 225 BitBlt(hdcMask,0,0,infoPtr->inbih->biWidth, infoPtr->inbih->biHeight,hdcSource,0,0,SRCCOPY); 265 226 266 227 /* mask the source bitmap */ 267 SetBkColor(hdcSource, RGB(0,0,0)); 268 SetTextColor(hdcSource, RGB(255,255,255)); 228 SetBkColor(hdcSource, RGB(0,0,0)); 229 SetTextColor(hdcSource, RGB(255,255,255)); 269 230 BitBlt(hdcSource, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND); 270 231 271 232 /* mask the destination bitmap */ 272 SetBkColor(hdcDest, RGB(255,255,255)); 273 SetTextColor(hdcDest, RGB(0,0,0)); 233 SetBkColor(hdcDest, RGB(255,255,255)); 234 SetTextColor(hdcDest, RGB(0,0,0)); 274 235 BitBlt(hdcDest, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND); 275 236 … … 297 258 298 259 if (!hDC || !infoPtr->inbih) 299 260 return TRUE; 300 261 301 262 if (infoPtr->hic ) … … 305 266 306 267 nWidth = infoPtr->outbih->biWidth; 307 nHeight = infoPtr->outbih->biHeight; 268 nHeight = infoPtr->outbih->biHeight; 308 269 } else 309 { 270 { 310 271 pBitmapData = infoPtr->indata; 311 272 pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih; 312 273 313 274 nWidth = infoPtr->inbih->biWidth; 314 nHeight = infoPtr->inbih->biHeight; 315 } 275 nHeight = infoPtr->inbih->biHeight; 276 } 316 277 317 278 if(!infoPtr->hbmPrevFrame) … … 320 281 } 321 282 322 SetDIBits(hDC, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, (LPBITMAPINFO)pBitmapInfo, DIB_RGB_COLORS); 323 283 SetDIBits(hDC, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, (LPBITMAPINFO)pBitmapInfo, DIB_RGB_COLORS); 284 324 285 hdcMem = CreateCompatibleDC(hDC); 325 286 hbmOld = SelectObject(hdcMem, infoPtr->hbmPrevFrame); 326 287 327 /* 328 * we need to get the transparent color even without ACS_TRANSPARENT, 288 /* 289 * we need to get the transparent color even without ACS_TRANSPARENT, 329 290 * because the style can be changed later on and the color should always 330 * be obtained in the first frame 291 * be obtained in the first frame 331 292 */ 332 293 if(infoPtr->transparentColor == ANIMATE_COLOR_NONE) 333 294 { 334 295 infoPtr->transparentColor = GetPixel(hdcMem,0,0); 335 } 336 337 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 338 { 296 } 297 298 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 299 { 339 300 HDC hdcFinal = CreateCompatibleDC(hDC); 340 301 HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight); 341 302 HBITMAP hbmOld2 = SelectObject(hdcFinal, hbmFinal); 342 303 RECT rect; 343 304 344 305 rect.left = 0; 345 306 rect.top = 0; 346 307 rect.right = nWidth; 347 308 rect.bottom = nHeight; 348 309 349 310 if(!infoPtr->hbrushBG) 350 311 infoPtr->hbrushBG = GetCurrentObject(hDC, OBJ_BRUSH); … … 359 320 infoPtr->hbmPrevFrame = hbmFinal; 360 321 } 361 362 if (GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_CENTER) 322 323 if (GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_CENTER) 363 324 { 364 RECT rect; 325 RECT rect; 365 326 366 327 GetWindowRect(infoPtr->hWnd, &rect); 367 nOffsetX = ((rect.right - rect.left) - nWidth)/2; 368 nOffsetY = ((rect.bottom - rect.top) - nHeight)/2; 369 } 370 BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY); 328 nOffsetX = ((rect.right - rect.left) - nWidth)/2; 329 nOffsetY = ((rect.bottom - rect.top) - nHeight)/2; 330 } 331 BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY); 371 332 372 333 SelectObject(hdcMem, hbmOld); … … 377 338 static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr) 378 339 { 379 HDC 340 HDC hDC; 380 341 381 342 TRACE("Drawing frame %d (loop %d)\n", infoPtr->currFrame, infoPtr->nLoop); … … 383 344 EnterCriticalSection(&infoPtr->cs); 384 345 385 infoPtr->fnmmioSeek(infoPtr->hMMio, infoPtr->lpIndex[infoPtr->currFrame], SEEK_SET);386 infoPtr->fnmmioRead(infoPtr->hMMio, infoPtr->indata, infoPtr->ash.dwSuggestedBufferSize);387 346 mmioSeek(infoPtr->hMMio, infoPtr->lpIndex[infoPtr->currFrame], SEEK_SET); 347 mmioRead(infoPtr->hMMio, infoPtr->indata, infoPtr->ash.dwSuggestedBufferSize); 348 388 349 if (infoPtr->hic && 389 (infoPtr->fnICDecompress)(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata, 390 infoPtr->outbih, infoPtr->outdata) != ICERR_OK) { 350 ICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata, 351 infoPtr->outbih, infoPtr->outdata) != ICERR_OK) { 352 LeaveCriticalSection(&infoPtr->cs); 353 WARN("Decompression error\n"); 354 return FALSE; 355 } 356 357 if ((hDC = GetDC(infoPtr->hWnd)) != 0) { 358 ANIMATE_PaintFrame(infoPtr, hDC); 359 ReleaseDC(infoPtr->hWnd, hDC); 360 } 361 362 if (infoPtr->currFrame++ >= infoPtr->nToFrame) { 363 infoPtr->currFrame = infoPtr->nFromFrame; 364 if (infoPtr->nLoop != -1) { 365 if (--infoPtr->nLoop == 0) { 366 ANIMATE_DoStop(infoPtr); 367 } 368 } 369 } 391 370 LeaveCriticalSection(&infoPtr->cs); 392 WARN("Decompression error\n");393 return FALSE;394 }395 396 if ((hDC = GetDC(infoPtr->hWnd)) != 0) {397 ANIMATE_PaintFrame(infoPtr, hDC);398 ReleaseDC(infoPtr->hWnd, hDC);399 }400 401 if (infoPtr->currFrame++ >= infoPtr->nToFrame) {402 infoPtr->currFrame = infoPtr->nFromFrame;403 if (infoPtr->nLoop != -1) {404 if (--infoPtr->nLoop == 0) {405 ANIMATE_DoStop(infoPtr);406 }407 }408 }409 LeaveCriticalSection(&infoPtr->cs);410 371 411 372 return TRUE; … … 414 375 static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_) 415 376 { 416 ANIMATE_INFO* 377 ANIMATE_INFO* infoPtr = (ANIMATE_INFO*)ptr_; 417 378 HDC hDC; 418 379 419 380 if(!infoPtr) 420 381 { … … 424 385 425 386 while(1) 426 { 427 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 387 { 388 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 428 389 { 429 390 hDC = GetDC(infoPtr->hWnd); 391 /* sometimes the animation window will be destroyed in between 392 * by the main program, so a ReleaseDC() error msg is possible */ 430 393 infoPtr->hbrushBG = SendMessageA(GetParent(infoPtr->hWnd),WM_CTLCOLORSTATIC,hDC, infoPtr->hWnd); 431 394 ReleaseDC(infoPtr->hWnd,hDC); 432 395 } 433 434 EnterCriticalSection(&infoPtr->cs);435 ANIMATE_DrawFrame(infoPtr);436 LeaveCriticalSection(&infoPtr->cs);437 396 397 EnterCriticalSection(&infoPtr->cs); 398 ANIMATE_DrawFrame(infoPtr); 399 LeaveCriticalSection(&infoPtr->cs); 400 438 401 /* time is in microseconds, we should convert it to milliseconds */ 439 402 Sleep((infoPtr->mah.dwMicroSecPerFrame+500)/1000); 440 }403 } 441 404 return TRUE; 442 405 } … … 448 411 /* nothing opened */ 449 412 if (!infoPtr->hMMio) 450 413 return FALSE; 451 414 452 415 if (infoPtr->hThread || infoPtr->uTimer) { 453 454 416 FIXME("Already playing ? what should I do ??\n"); 417 ANIMATE_DoStop(infoPtr); 455 418 } 456 419 … … 460 423 461 424 if (infoPtr->nToFrame == 0xFFFF) 462 463 464 TRACE("(repeat=%d from=%d to=%d);\n", 465 425 infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1; 426 427 TRACE("(repeat=%d from=%d to=%d);\n", 428 infoPtr->nLoop, infoPtr->nFromFrame, infoPtr->nToFrame); 466 429 467 430 if (infoPtr->nFromFrame >= infoPtr->nToFrame || 468 469 431 infoPtr->nToFrame >= infoPtr->mah.dwTotalFrames) 432 return FALSE; 470 433 471 434 infoPtr->currFrame = infoPtr->nFromFrame; 472 435 473 436 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TIMER) { 474 475 476 437 TRACE("Using a timer\n"); 438 /* create a timer to display AVI */ 439 infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL); 477 440 } else { 478 441 DWORD threadID; 479 442 480 443 TRACE("Using an animation thread\n"); 481 444 infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr,0,0 &threadID); 482 445 if(!infoPtr->hThread) … … 485 448 return FALSE; 486 449 } 487 488 } 489 450 451 } 452 490 453 ANIMATE_Notify(infoPtr, ACN_START); 491 454 … … 496 459 static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr) 497 460 { 498 MMCKINFO 499 MMCKINFO 500 MMCKINFO 501 MMCKINFO 502 DWORD 503 DWORD 504 505 if ( infoPtr->fnmmioDescend(infoPtr->hMMio, &ckMainRIFF, NULL, 0) != 0) {506 507 461 MMCKINFO ckMainRIFF; 462 MMCKINFO mmckHead; 463 MMCKINFO mmckList; 464 MMCKINFO mmckInfo; 465 DWORD numFrame; 466 DWORD insize; 467 468 if (mmioDescend(infoPtr->hMMio, &ckMainRIFF, NULL, 0) != 0) { 469 WARN("Can't find 'RIFF' chunk\n"); 470 return FALSE; 508 471 } 509 472 510 473 if ((ckMainRIFF.ckid != FOURCC_RIFF) || 511 512 513 474 (ckMainRIFF.fccType != mmioFOURCC('A', 'V', 'I', ' '))) { 475 WARN("Can't find 'AVI ' chunk\n"); 476 return FALSE; 514 477 } 515 478 516 479 mmckHead.fccType = mmioFOURCC('h', 'd', 'r', 'l'); 517 if ( infoPtr->fnmmioDescend(infoPtr->hMMio, &mmckHead, &ckMainRIFF, MMIO_FINDLIST) != 0) {518 519 480 if (mmioDescend(infoPtr->hMMio, &mmckHead, &ckMainRIFF, MMIO_FINDLIST) != 0) { 481 WARN("Can't find 'hdrl' list\n"); 482 return FALSE; 520 483 } 521 484 522 485 mmckInfo.ckid = mmioFOURCC('a', 'v', 'i', 'h'); 523 if (infoPtr->fnmmioDescend(infoPtr->hMMio, &mmckInfo, &mmckHead, MMIO_FINDCHUNK) != 0) { 524 WARN("Can't find 'avih' chunk\n"); 525 return FALSE; 526 } 527 528 infoPtr->fnmmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->mah, sizeof(infoPtr->mah)); 529 TRACE("mah.dwMicroSecPerFrame=%ld\n", infoPtr->mah.dwMicroSecPerFrame); 530 TRACE("mah.dwMaxBytesPerSec=%ld\n", infoPtr->mah.dwMaxBytesPerSec); 531 TRACE("mah.dwPaddingGranularity=%ld\n", infoPtr->mah.dwPaddingGranularity); 532 TRACE("mah.dwFlags=%ld\n", infoPtr->mah.dwFlags); 533 TRACE("mah.dwTotalFrames=%ld\n", infoPtr->mah.dwTotalFrames); 534 TRACE("mah.dwInitialFrames=%ld\n", infoPtr->mah.dwInitialFrames); 535 TRACE("mah.dwStreams=%ld\n", infoPtr->mah.dwStreams); 536 TRACE("mah.dwSuggestedBufferSize=%ld\n", infoPtr->mah.dwSuggestedBufferSize); 537 TRACE("mah.dwWidth=%ld\n", infoPtr->mah.dwWidth); 538 TRACE("mah.dwHeight=%ld\n", infoPtr->mah.dwHeight); 539 infoPtr->fnmmioAscend(infoPtr->hMMio, &mmckInfo, 0); 486 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckHead, MMIO_FINDCHUNK) != 0) { 487 WARN("Can't find 'avih' chunk\n"); 488 return FALSE; 489 } 490 491 mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->mah, sizeof(infoPtr->mah)); 492 493 TRACE("mah.dwMicroSecPerFrame=%ld\n", infoPtr->mah.dwMicroSecPerFrame); 494 TRACE("mah.dwMaxBytesPerSec=%ld\n", infoPtr->mah.dwMaxBytesPerSec); 495 TRACE("mah.dwPaddingGranularity=%ld\n", infoPtr->mah.dwPaddingGranularity); 496 TRACE("mah.dwFlags=%ld\n", infoPtr->mah.dwFlags); 497 TRACE("mah.dwTotalFrames=%ld\n", infoPtr->mah.dwTotalFrames); 498 TRACE("mah.dwInitialFrames=%ld\n", infoPtr->mah.dwInitialFrames); 499 TRACE("mah.dwStreams=%ld\n", infoPtr->mah.dwStreams); 500 TRACE("mah.dwSuggestedBufferSize=%ld\n", infoPtr->mah.dwSuggestedBufferSize); 501 TRACE("mah.dwWidth=%ld\n", infoPtr->mah.dwWidth); 502 TRACE("mah.dwHeight=%ld\n", infoPtr->mah.dwHeight); 503 504 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); 540 505 541 506 mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l'); 542 if ( infoPtr->fnmmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) != 0) {543 544 507 if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) != 0) { 508 WARN("Can't find 'strl' list\n"); 509 return FALSE; 545 510 } 546 511 547 512 mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'h'); 548 if (infoPtr->fnmmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { 549 WARN("Can't find 'strh' chunk\n"); 550 return FALSE; 551 } 552 553 infoPtr->fnmmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->ash, sizeof(infoPtr->ash)); 554 TRACE("ash.fccType='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccType)), 555 HIBYTE(LOWORD(infoPtr->ash.fccType)), 556 LOBYTE(HIWORD(infoPtr->ash.fccType)), 557 HIBYTE(HIWORD(infoPtr->ash.fccType))); 558 TRACE("ash.fccHandler='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccHandler)), 559 HIBYTE(LOWORD(infoPtr->ash.fccHandler)), 560 LOBYTE(HIWORD(infoPtr->ash.fccHandler)), 561 HIBYTE(HIWORD(infoPtr->ash.fccHandler))); 562 TRACE("ash.dwFlags=%ld\n", infoPtr->ash.dwFlags); 563 TRACE("ash.wPriority=%d\n", infoPtr->ash.wPriority); 564 TRACE("ash.wLanguage=%d\n", infoPtr->ash.wLanguage); 565 TRACE("ash.dwInitialFrames=%ld\n", infoPtr->ash.dwInitialFrames); 566 TRACE("ash.dwScale=%ld\n", infoPtr->ash.dwScale); 567 TRACE("ash.dwRate=%ld\n", infoPtr->ash.dwRate); 568 TRACE("ash.dwStart=%ld\n", infoPtr->ash.dwStart); 569 TRACE("ash.dwLength=%ld\n", infoPtr->ash.dwLength); 570 TRACE("ash.dwSuggestedBufferSize=%ld\n", infoPtr->ash.dwSuggestedBufferSize); 571 TRACE("ash.dwQuality=%ld\n", infoPtr->ash.dwQuality); 572 TRACE("ash.dwSampleSize=%ld\n", infoPtr->ash.dwSampleSize); 573 TRACE("ash.rcFrame=(%d,%d,%d,%d)\n", infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left, 574 infoPtr->ash.rcFrame.bottom, infoPtr->ash.rcFrame.right); 575 infoPtr->fnmmioAscend(infoPtr->hMMio, &mmckInfo, 0); 513 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { 514 WARN("Can't find 'strh' chunk\n"); 515 return FALSE; 516 } 517 518 mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->ash, sizeof(infoPtr->ash)); 519 520 TRACE("ash.fccType='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccType)), 521 HIBYTE(LOWORD(infoPtr->ash.fccType)), 522 LOBYTE(HIWORD(infoPtr->ash.fccType)), 523 HIBYTE(HIWORD(infoPtr->ash.fccType))); 524 TRACE("ash.fccHandler='%c%c%c%c'\n", LOBYTE(LOWORD(infoPtr->ash.fccHandler)), 525 HIBYTE(LOWORD(infoPtr->ash.fccHandler)), 526 LOBYTE(HIWORD(infoPtr->ash.fccHandler)), 527 HIBYTE(HIWORD(infoPtr->ash.fccHandler))); 528 TRACE("ash.dwFlags=%ld\n", infoPtr->ash.dwFlags); 529 TRACE("ash.wPriority=%d\n", infoPtr->ash.wPriority); 530 TRACE("ash.wLanguage=%d\n", infoPtr->ash.wLanguage); 531 TRACE("ash.dwInitialFrames=%ld\n", infoPtr->ash.dwInitialFrames); 532 TRACE("ash.dwScale=%ld\n", infoPtr->ash.dwScale); 533 TRACE("ash.dwRate=%ld\n", infoPtr->ash.dwRate); 534 TRACE("ash.dwStart=%ld\n", infoPtr->ash.dwStart); 535 TRACE("ash.dwLength=%ld\n", infoPtr->ash.dwLength); 536 TRACE("ash.dwSuggestedBufferSize=%ld\n", infoPtr->ash.dwSuggestedBufferSize); 537 TRACE("ash.dwQuality=%ld\n", infoPtr->ash.dwQuality); 538 TRACE("ash.dwSampleSize=%ld\n", infoPtr->ash.dwSampleSize); 539 TRACE("ash.rcFrame=(%d,%d,%d,%d)\n", infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left, 540 infoPtr->ash.rcFrame.bottom, infoPtr->ash.rcFrame.right); 541 542 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); 576 543 577 544 mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'f'); 578 if ( infoPtr->fnmmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) {579 580 545 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { 546 WARN("Can't find 'strh' chunk\n"); 547 return FALSE; 581 548 } 582 549 583 550 infoPtr->inbih = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); 584 551 if (!infoPtr->inbih) { 585 WARN("Can't alloc input BIH\n"); 586 return FALSE; 587 } 588 589 infoPtr->fnmmioRead(infoPtr->hMMio, (LPSTR)infoPtr->inbih, mmckInfo.cksize); 590 TRACE("bih.biSize=%ld\n", infoPtr->inbih->biSize); 591 TRACE("bih.biWidth=%ld\n", infoPtr->inbih->biWidth); 592 TRACE("bih.biHeight=%ld\n", infoPtr->inbih->biHeight); 593 TRACE("bih.biPlanes=%d\n", infoPtr->inbih->biPlanes); 594 TRACE("bih.biBitCount=%d\n", infoPtr->inbih->biBitCount); 595 TRACE("bih.biCompression=%ld\n", infoPtr->inbih->biCompression); 596 TRACE("bih.biSizeImage=%ld\n", infoPtr->inbih->biSizeImage); 597 TRACE("bih.biXPelsPerMeter=%ld\n", infoPtr->inbih->biXPelsPerMeter); 598 TRACE("bih.biYPelsPerMeter=%ld\n", infoPtr->inbih->biYPelsPerMeter); 599 TRACE("bih.biClrUsed=%ld\n", infoPtr->inbih->biClrUsed); 600 TRACE("bih.biClrImportant=%ld\n", infoPtr->inbih->biClrImportant); 601 infoPtr->fnmmioAscend(infoPtr->hMMio, &mmckInfo, 0); 602 603 infoPtr->fnmmioAscend(infoPtr->hMMio, &mmckList, 0); 604 552 WARN("Can't alloc input BIH\n"); 553 return FALSE; 554 } 555 556 mmioRead(infoPtr->hMMio, (LPSTR)infoPtr->inbih, mmckInfo.cksize); 557 558 TRACE("bih.biSize=%ld\n", infoPtr->inbih->biSize); 559 TRACE("bih.biWidth=%ld\n", infoPtr->inbih->biWidth); 560 TRACE("bih.biHeight=%ld\n", infoPtr->inbih->biHeight); 561 TRACE("bih.biPlanes=%d\n", infoPtr->inbih->biPlanes); 562 TRACE("bih.biBitCount=%d\n", infoPtr->inbih->biBitCount); 563 TRACE("bih.biCompression=%ld\n", infoPtr->inbih->biCompression); 564 TRACE("bih.biSizeImage=%ld\n", infoPtr->inbih->biSizeImage); 565 TRACE("bih.biXPelsPerMeter=%ld\n", infoPtr->inbih->biXPelsPerMeter); 566 TRACE("bih.biYPelsPerMeter=%ld\n", infoPtr->inbih->biYPelsPerMeter); 567 TRACE("bih.biClrUsed=%ld\n", infoPtr->inbih->biClrUsed); 568 TRACE("bih.biClrImportant=%ld\n", infoPtr->inbih->biClrImportant); 569 570 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); 571 572 mmioAscend(infoPtr->hMMio, &mmckList, 0); 573 605 574 #if 0 606 575 /* an AVI has 0 or 1 video stream, and to be animated should not contain 607 * an audio stream, so only one strl is allowed 576 * an audio stream, so only one strl is allowed 608 577 */ 609 578 mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l'); 610 if ( infoPtr->fnmmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) == 0) {611 612 613 } 614 #endif 615 616 infoPtr->fnmmioAscend(infoPtr->hMMio, &mmckHead, 0);579 if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) == 0) { 580 WARN("There should be a single 'strl' list\n"); 581 return FALSE; 582 } 583 #endif 584 585 mmioAscend(infoPtr->hMMio, &mmckHead, 0); 617 586 618 587 /* no need to read optional JUNK chunk */ 619 588 620 589 mmckList.fccType = mmioFOURCC('m', 'o', 'v', 'i'); 621 if ( infoPtr->fnmmioDescend(infoPtr->hMMio, &mmckList, &ckMainRIFF, MMIO_FINDLIST) != 0) {622 623 590 if (mmioDescend(infoPtr->hMMio, &mmckList, &ckMainRIFF, MMIO_FINDLIST) != 0) { 591 WARN("Can't find 'movi' list\n"); 592 return FALSE; 624 593 } 625 594 626 595 /* FIXME: should handle the 'rec ' LIST when present */ 627 596 628 infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 629 597 infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 598 infoPtr->mah.dwTotalFrames * sizeof(DWORD)); 630 599 if (!infoPtr->lpIndex) { 631 632 600 WARN("Can't alloc index array\n"); 601 return FALSE; 633 602 } 634 603 635 604 numFrame = insize = 0; 636 while ( infoPtr->fnmmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 &&637 638 639 640 641 642 infoPtr->fnmmioAscend(infoPtr->hMMio, &mmckInfo, 0);605 while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 && 606 numFrame < infoPtr->mah.dwTotalFrames) { 607 infoPtr->lpIndex[numFrame] = mmckInfo.dwDataOffset; 608 if (insize < mmckInfo.cksize) 609 insize = mmckInfo.cksize; 610 numFrame++; 611 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); 643 612 } 644 613 if (numFrame != infoPtr->mah.dwTotalFrames) { 645 646 614 WARN("Found %ld frames (/%ld)\n", numFrame, infoPtr->mah.dwTotalFrames); 615 return FALSE; 647 616 } 648 617 if (insize > infoPtr->ash.dwSuggestedBufferSize) { 649 650 618 WARN("insize=%ld suggestedSize=%ld\n", insize, infoPtr->ash.dwSuggestedBufferSize); 619 infoPtr->ash.dwSuggestedBufferSize = insize; 651 620 } 652 621 653 622 infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize); 654 623 if (!infoPtr->indata) { 655 656 624 WARN("Can't alloc input buffer\n"); 625 return FALSE; 657 626 } 658 627 … … 663 632 static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr) 664 633 { 665 DWORD 634 DWORD outSize; 666 635 667 636 /* check uncompressed AVI */ … … 669 638 (infoPtr->ash.fccHandler == mmioFOURCC('R', 'L', 'E', ' '))) 670 639 { 671 infoPtr->hic = 0; 672 640 infoPtr->hic = 0; 641 return TRUE; 673 642 } 674 643 675 644 /* try to get a decompressor for that type */ 676 infoPtr->hic = (infoPtr->fnICOpen)(ICTYPE_VIDEO, 677 infoPtr->ash.fccHandler, 678 ICMODE_DECOMPRESS); 645 infoPtr->hic = ICOpen(ICTYPE_VIDEO, infoPtr->ash.fccHandler, ICMODE_DECOMPRESS); 679 646 if (!infoPtr->hic) { 680 681 682 } 683 684 outSize = (infoPtr->fnICSendMessage)(infoPtr->hic,685 ICM_DECOMPRESS_GET_FORMAT, 686 (DWORD)infoPtr->inbih, 0L); 647 WARN("Can't load codec for the file\n"); 648 return FALSE; 649 } 650 651 outSize = ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 652 (DWORD)infoPtr->inbih, 0L); 653 687 654 infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize); 688 655 if (!infoPtr->outbih) { 689 WARN("Can't alloc output BIH\n"); 690 return FALSE; 691 } 692 693 if ((infoPtr->fnICSendMessage)(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 694 (DWORD)infoPtr->inbih, 695 (DWORD)infoPtr->outbih) != ICERR_OK) { 696 WARN("Can't get output BIH\n"); 697 return FALSE; 656 WARN("Can't alloc output BIH\n"); 657 return FALSE; 658 } 659 660 if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 661 (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) { 662 WARN("Can't get output BIH\n"); 663 return FALSE; 698 664 } 699 665 700 666 infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage); 701 667 if (!infoPtr->outdata) { 702 WARN("Can't alloc output buffer\n"); 703 return FALSE; 704 } 705 706 if ((infoPtr->fnICSendMessage)(infoPtr->hic, ICM_DECOMPRESS_BEGIN, 707 (DWORD)infoPtr->inbih, 708 (DWORD)infoPtr->outbih) != ICERR_OK) { 709 WARN("Can't begin decompression\n"); 710 return FALSE; 668 WARN("Can't alloc output buffer\n"); 669 return FALSE; 670 } 671 672 if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN, 673 (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) { 674 WARN("Can't begin decompression\n"); 675 return FALSE; 711 676 } 712 677 … … 726 691 727 692 if (!lParam) { 728 729 730 } 731 693 TRACE("Closing avi!\n"); 694 return TRUE; 695 } 696 732 697 if (!hInstance) 733 698 hInstance = GetWindowLongA(hWnd, GWL_HINSTANCE); … … 738 703 739 704 if (!ANIMATE_LoadRes(infoPtr, hInstance, (LPWSTR)lParam,unicode)) { 740 //TRACE("No AVI resource found!\n");705 TRACE("No AVI resource found!\n"); 741 706 if (!ANIMATE_LoadFile(infoPtr, (LPWSTR)lParam,unicode)) { 742 //WARN("No AVI file found!\n");707 WARN("No AVI file found!\n"); 743 708 return FALSE; 744 709 } … … 748 713 749 714 if (!ANIMATE_LoadRes(infoPtr,hInstance,unicode ? MAKEINTRESOURCEW((INT)lParam):(LPWSTR)MAKEINTRESOURCEA((INT)lParam),unicode)) { 750 //WARN("No AVI resource found!\n");715 WARN("No AVI resource found!\n"); 751 716 return FALSE; 752 717 } … … 773 738 } 774 739 #endif 775 776 740 if (!ANIMATE_GetAviInfo(infoPtr)) { 777 778 779 741 WARN("Can't get AVI information\n"); 742 ANIMATE_Free(infoPtr); 743 return FALSE; 780 744 } 781 745 782 746 if (!ANIMATE_GetAviCodec(infoPtr)) { 783 784 785 747 WARN("Can't get AVI Codec\n"); 748 ANIMATE_Free(infoPtr); 749 return FALSE; 786 750 } 787 751 788 752 if (!GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { 789 790 753 SetWindowPos(hWnd, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight, 754 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); 791 755 } 792 756 793 757 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_AUTOPLAY) { 794 758 return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1)); 795 759 } 796 760 … … 807 771 /* nothing opened */ 808 772 if (!infoPtr->hMMio) 809 773 return FALSE; 810 774 811 775 ANIMATE_DoStop(infoPtr); … … 816 780 static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam) 817 781 { 818 ANIMATE_INFO* infoPtr; 819 HMODULE hModule = LoadLibraryA("msvfw32.dll"); 820 821 if (!hModule) 822 return FALSE; 782 ANIMATE_INFO* infoPtr; 823 783 824 784 /* allocate memory for info structure */ … … 829 789 #endif 830 790 if (!infoPtr) { 831 ERR("could not allocate info memory!\n"); 832 return 0; 833 } 834 835 /* Temporary hack until we get dllglue up and running */ 836 infoPtr->fnICOpen = (void*)GetProcAddress(hModule, "ICOpen"); 837 infoPtr->fnICClose = (void*)GetProcAddress(hModule, "ICClose"); 838 infoPtr->fnICSendMessage = (void*)GetProcAddress(hModule, "ICSendMessage"); 839 infoPtr->fnICDecompress = (void*)GetProcAddress(hModule, "ICDecompress"); 791 ERR("could not allocate info memory!\n"); 792 return 0; 793 } 840 794 841 795 TRACE("Animate style=0x%08lx, parent=%08lx\n", GetWindowLongA(hWnd, GWL_STYLE), (DWORD)GetParent(hWnd)); … … 846 800 infoPtr->transparentColor = ANIMATE_COLOR_NONE; 847 801 infoPtr->hbmPrevFrame = 0; 848 hModWinmm = LoadLibraryA("WINMM");849 850 infoPtr->fnmmioOpenA = (void*)GetProcAddress(hModWinmm, "mmioOpenA");851 #ifdef __WIN32OS2__852 infoPtr->fnmmioOpenW = (void*)GetProcAddress(hModWinmm, "mmioOpenW");853 #endif854 infoPtr->fnmmioClose = (void*)GetProcAddress(hModWinmm, "mmioClose");855 infoPtr->fnmmioAscend = (void*)GetProcAddress(hModWinmm, "mmioAscend");856 infoPtr->fnmmioDescend = (void*)GetProcAddress(hModWinmm, "mmioDescend");857 infoPtr->fnmmioSeek = (void*)GetProcAddress(hModWinmm, "mmioSeek");858 infoPtr->fnmmioRead = (void*)GetProcAddress(hModWinmm, "mmioRead");859 802 860 803 InitializeCriticalSection(&infoPtr->cs); 861 804 862 805 return 0; 863 806 } … … 876 819 SetWindowLongA(hWnd, 0, 0); 877 820 878 FreeLibrary(hModWinmm);879 821 return 0; 880 822 } … … 884 826 { 885 827 RECT rect; 886 HBRUSH hBrush = 0; 887 888 if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 828 HBRUSH hBrush = 0; 829 830 if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 889 831 { 890 hBrush = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd); 832 hBrush = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd); 891 833 } 892 834 … … 900 842 { 901 843 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { 902 844 InvalidateRect(hWnd, NULL, TRUE); 903 845 } 904 846 return TRUE; … … 909 851 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam); 910 852 if (!ANIMATE_GetInfoPtr(hWnd) && (uMsg != WM_NCCREATE)) 911 853 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 912 854 switch (uMsg) 913 855 { 914 856 #ifdef __WIN32OS2__ 915 916 917 918 919 857 case ACM_OPENA: 858 return ANIMATE_Open(hWnd,wParam,lParam,FALSE); 859 860 case ACM_OPENW: 861 return ANIMATE_Open(hWnd,wParam,lParam,TRUE); 920 862 #else 921 863 case ACM_OPENA: 922 923 924 /*case ACM_OPEN32W: FIXME!! */925 /*return ANIMATE_Open32W(hWnd, wParam, lParam); */926 #endif 927 864 return ANIMATE_OpenA(hWnd, wParam, lParam); 865 866 /* case ACM_OPEN32W: FIXME!! */ 867 /* return ANIMATE_Open32W(hWnd, wParam, lParam); */ 868 #endif 869 928 870 case ACM_PLAY: 929 930 871 return ANIMATE_Play(hWnd, wParam, lParam); 872 931 873 case ACM_STOP: 932 933 874 return ANIMATE_Stop(hWnd, wParam, lParam); 875 934 876 case WM_NCCREATE: 935 936 937 877 ANIMATE_Create(hWnd, wParam, lParam); 878 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 879 938 880 case WM_NCHITTEST: 939 881 return HTTRANSPARENT; 940 882 941 883 case WM_DESTROY: 942 943 944 884 ANIMATE_Destroy(hWnd, wParam, lParam); 885 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 886 945 887 case WM_ERASEBKGND: 946 947 948 949 /* 888 ANIMATE_EraseBackground(hWnd, wParam, lParam); 889 break; 890 891 /* case WM_STYLECHANGED: FIXME shall we do something ?? */ 950 892 951 893 case WM_TIMER: 952 894 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 953 895 { 954 896 ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); 955 897 infoPtr->hbrushBG = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd); 956 898 } 957 958 899 return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd)); 900 959 901 case WM_CLOSE: 960 961 902 ANIMATE_Free(ANIMATE_GetInfoPtr(hWnd)); 903 return TRUE; 962 904 963 905 case WM_PAINT: 964 906 { 965 907 ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); 966 908 967 909 /* the animation isn't playing, don't paint */ 968 969 970 971 910 if(!infoPtr->uTimer && !infoPtr->hThread) 911 /* default paint handling */ 912 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 913 972 914 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 973 915 infoPtr->hbrushBG = SendMessageA(GetParent(hWnd), WM_CTLCOLORSTATIC, 974 975 916 (HDC)wParam, hWnd); 917 976 918 if (wParam) 977 919 { … … 982 924 else 983 925 { 984 985 926 PAINTSTRUCT ps; 927 HDC hDC = BeginPaint(hWnd, &ps); 986 928 987 929 EnterCriticalSection(&infoPtr->cs); 988 930 ANIMATE_PaintFrame(infoPtr, hDC); 989 931 LeaveCriticalSection(&infoPtr->cs); 990 991 EndPaint(hWnd, &ps); 932 933 EndPaint(hWnd, &ps); 934 } 992 935 } 993 } 994 break; 936 break; 995 937 996 938 case WM_SIZE: 997 998 939 ANIMATE_Size(hWnd, wParam, lParam); 940 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 999 941 1000 942 default: 1001 1002 1003 1004 #ifdef __WIN32OS2__ 1005 943 if (uMsg >= WM_USER) 944 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); 945 946 #ifdef __WIN32OS2__ 947 return defComCtl32ProcA (hWnd, uMsg, wParam, lParam); 1006 948 #else 1007 949 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 1008 950 #endif 1009 951 } … … 1024 966 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); 1025 967 wndClass.lpszClassName = ANIMATE_CLASSA; 1026 968 1027 969 RegisterClassA(&wndClass); 1028 970 }
Note:
See TracChangeset
for help on using the changeset viewer.