Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Animated Buttons

0.00/5 (No votes)
8 Feb 2000 1  
A class that show AVIs inside a button.
AniButton.jpg

This class is a simple owner-draw CButton class that allows you to play animation files (AVI's) within the button. This class can be used like any other owner drawn control - simply include the header file, and declare your button controls as CAniButton instead of CButton

The class has the following methods:

BOOL Open( LPCTSTR lpszFileName );    // Open an AVI file using its filename
BOOL Open( UINT nID );              // Open an AVI file using its resource ID
void Play();                        // Start playing the animation 
void Stop();                        // Stop the animation
void Close();                       // Close the animation and free resources

To setup the button to play an animation, first add an AVI to your resources by editing the .rc file by hand and adding the following:

IDR_AVI1  AVI     DISCARDABLE     "res\\Animation.avi"

where Animation.avi is an AVI file in your /res directory (remember to define IDR_AVI1 in your resource.h file). Then, after creating the control (or in your dialogs OnInitDialog function, add the following

m_Button.Open(IDR_AVI1);
m_Button.Play();
where m_Button is your animation button.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here