---- On the toolbar of the application, you can place graphical buttons and some controls for quick operations,
We can also play an animation on it.To increase the program dynamics and make the user know that the program is working. This function
InYou can add CanimateCtrl, a standard control for playing an animation, to the toolbar in VC ++.
1. This program allows users to passPlay and close the animation in the "View/animation" menu.
---- Select an AVI file for the program to call before you start programming. This document uses sample. avi .,
Placed inC: emp directory.
---- AVI files can be created by yourself in some AVI editors, such as Adobe Premiere 5.1,
Corel Photo-Paint 8 and so on, you can also use existing AVI resources, when creating and selecting, the toolbar should be taken into account
Suitable for Playing videos with smaller images(The image size in the AVI file selected in this article is 27x14 pixels,
Pixel depth is 4 bits.
The procedure is as follows:
---- 1. Create a project
---- Use MFC AppWizard (exe) to create a new project "AnimateToolbar", in the MFC AppWizard-Step 1
Dialog Box selected"Single Document" option, click Finish, and then click OK in the pop-up dialog box.
Button. The project has been created.
---- 2. Create menu Resources
---- Add the "animation (A)" menu item in "View" and set its ID to ID_VIEW_ANIMATE,
Status Bar prompt (Prompt) is set to "play/Stop Animation ".
---- 3. Add the bitmap resource on the toolbar.
---- Add a new button to the bitmap resource and set the ID number to ID_ANIMATE.
---- 4. Add a CanimateCtrl control to the toolbar and play the animation.
---- (1) declare the following member variables in the CmainFrame class:
Class CMainFrame: public CFrameWnd
{
...
Public:
BOOLIsAnimationActive; // whether to play the animation identifier
CAnimateCtrlM_Animate;
...
}
---- (2) initialize the IsAnimationActive variable in the CmainFrame class constructor:
CMainFrame: CMainFrame ()
{
// TODO: add member initialization code here
IsAnimationActive = TRUE;
}
---- (3) create the CAnimateCtrl control in the CMainFrame: OnCreate Function
Int CMainFrame: OnCreate (maid)
{
...
CRect rect;