65.9K
CodeProject 正在变化。 阅读更多。
Home

动画按钮

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.11/5 (5投票s)

2000年2月9日

CPOL
viewsIcon

134071

downloadIcon

2283

一个在按钮内显示 AVI 文件的类。

AniButton.jpg

这个类是一个简单的所有者绘制 CButton 类,它允许你在按钮内播放动画文件(AVI)。这个类可以像任何其他所有者绘制控件一样使用 - 简单地包含头文件,并将你的按钮控件声明为 CAniButton 而不是 CButton

该类具有以下方法

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

要设置按钮以播放动画,首先通过手动编辑 .rc 文件并添加以下内容将 AVI 添加到你的资源中:

IDR_AVI1  AVI     DISCARDABLE     "res\\Animation.avi"

其中 Animation.avi 是 /res 目录中的 AVI 文件(请记住在 resource.h 文件中定义 IDR_AVI1)。 然后,在创建控件之后(或在对话框的 OnInitDialog 函数中,添加以下内容:

m_Button.Open(IDR_AVI1);
m_Button.Play();
其中 m_Button 是你的动画按钮。
© . All rights reserved.