Click here to Skip to main content
15,867,453 members
Articles / Desktop Programming / MFC
Article

Animated Buttons

Rate me:
Please Sign up or sign in to vote.
4.11/5 (5 votes)
8 Feb 2000CPOL 132.9K   2.2K   56   5
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionunknown identifier Pin
Vladimir199031-Mar-11 0:15
Vladimir199031-Mar-11 0:15 
GeneralA quick solution.. Pin
Sicks15-Sep-05 2:44
Sicks15-Sep-05 2:44 
GeneralProblem with Close() Pin
Sicks14-Sep-05 2:14
Sicks14-Sep-05 2:14 
GeneralHELP !!!!!!!!!!! Pin
10-Feb-02 1:49
suss10-Feb-02 1:49 
GeneralRe: HELP !!!!!!!!!!! Pin
Praveen Kumar G8-Mar-03 19:36
Praveen Kumar G8-Mar-03 19:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.