Click here to Skip to main content
Click here to Skip to main content
Go to top

Animated Buttons

, 8 Feb 2000
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

Raghav Gupta

United States United States
No Biography provided

Comments and Discussions

 
Questionunknown identifier PinmemberVladimir199031-Mar-11 0:15 
Hi, I'm fresh in Visual C++ programming, and I need to implement your code for this animated button in my project. But I can't seem to understand what this "IDC_ANIMATE1" is (because the Visual Studio 2010 says it's an unknown identifier) Smile | :)

I hope I'll get an answer, and I'm pretty sure that it's something very obvious - but I'm a newbie (:
 
Thank you
GeneralA quick solution.. PinsussSicks15-Sep-05 2:44 
GeneralProblem with Close() PinsussSicks14-Sep-05 2:14 
GeneralHELP !!!!!!!!!!! PinmemberAnonymousCPopUpDlg dlg;10-Feb-02 1:49 
GeneralRe: HELP !!!!!!!!!!! PinmemberPiku8-Mar-03 19:36 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 8 Feb 2000
Article Copyright 2000 by Raghav Gupta
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid