Environment: VC6 SP3, NT4 SP4 German (demo application tested with Win98 German)
If you set the flag ACS_TRANSPARENT in CAnimateCtrl, the background of the animation is in no way transparent, instead it is changed to COLOR_WINDOW. Not what I expected...
Since my application has a bitmap background the standard control was useless for me, and after staring some time at the AVIView sample sources, I decided to make my own class that supports real transparency ;-)
The following list shows the public functions of my class CAVICtrl and the flags you can use when loading an animation:
HRESULT Load(UINT nIDResource, DWORD dwFlags = 0L, COLORREF clrTransparent = LTGREEN); // load from resource HRESULT Load(LPCTSTR lpszFile, DWORD dwFlags = 0L, COLORREF clrTransparent = LTGREEN); // load from file BOOL Play(BOOL bOnce = FALSE); BOOL Stop(BOOL bResetToFirst = FALSE); void Seek(UINT nTo); BOOL IsPlaying(); // call this function if the background of the parent // window changesvoid ReinitBackground(); // flags to use with Load() AVC_HALFSPEED 0x0000001 // plays video with half speed AVC_DOUBLESPEED 0x0000002 // plays video with double speed AVC_CENTERAVI 0x0000004 // centers video inside the window AVC_STRETCHAVI 0x0000008 // stretches video to fit inside of the window AVC_CENTERRECT 0x0000010 // resizes window, center point stays the same AVC_AUTOPLAY 0x0000020 // starts playing automatically after Load() // background is COLOR_WINDOW // instead of transparent (like CAnimateCtrl's // AVS_"TRANSPARENT") AVC_MAPWINDOWCOLOR 0x0000040 // ignore clrTransparent parameter and uses color of first // frame's first pixel instead (works only with 8bit images) AVC_FIRSTPIXTRANSPRNT 0x0000080If you have a dialog based application, simply add a static control to your dialog and subclass it with a CAVICtrl in OnInitDialog() before calling one of the loading functions.
I recommend downloading the demo project which demonstrates the classes usage and the working of some of the flags.
This sample program also uses Joerg Koenigs very useful CBitmapDialog class to display the background image.
One great flaw is that the animation function itself is driven by a
timer, so it stops if you click on the parent window to move or resize
I'm planning to put the animation code in a different thread for better performance and appearance, but this will be my first travel into the alien world of multithreaded programming, so please be patient ;-)
Comments, suggestions, bug reports etc. are welcome! Put them here as a comment or send them directly to me.
DownloadsDownload demo project - 140 Kb
Download source - 6 Kb