|
An animation is a series of pictures put together to produce a video clip. It can be used to
display the evolution of an ongoing task to the user. This makes such tasks less boring. For
example, making a copy of a CD is usually a long process that can take minutes. To let the
user know when such a task is being performed, you can display an animation.
Microsoft Windows provides a few small animations you can use for your
applications. These animations, just like many other resources of Visual Studio or Visual C++,
are not installed by default. During setup, you can install them if necessary. If you forgot
to install them and you need them, run Setup again and select the Add/Remove button. Then
click the check box of the Options checked list
box. If you want only the videos or some resources, click the Graphics items and click the
Change Options, and select the items you
want. You can then click Continue to install the videos.
If you need an animation other than those supplied, you may have to
create it. Visual C++ is not the place to create an animation. You may need a graphics
software to do this.
To use a regular animation, the video must be a standard Microsoft
Windows audio/video format: Audio Video Interleaved or AVI. Therefore, it must be a file
with the avi extension. If the file has both audio and video, only the video part would be
considered. |
|
Animation Control and Properties |
|
|
An animation first originates from an avi file created by an external
application. Therefore, you must already have the video you want to play in your application.
To provide an animation for your application, at design time, from the Controls toolbox,
click the Animate button
and click the desired
area on the host.
To represent the frame of animation on the dialog box or form, the control draws a
rectangle. Normally, the animation would be played inside of the area. The person who
created the animation likely did not use the same rectangular dimensions
when creating the video. Consequently, when it is asked to play, the animation’s upper-left
corner would be set to correspond to your rectangle’s upper-left corner. If you want the
animation to be centered in your assigned rectangle, set the control’s
Center property to True. This is equivalent to adding the ACS_CENTER. In
this case, the center of the video woud match the center of your rectangle, even though
the animation may still not exactly match the dimensions of your rectangle.
When playing the video, you have the option of displaying the original background color
of the video or
seeing through. When creating a video, its author can do it with transparency to allow
seeing the color of the host. In this case, to display the color of the host while the
video is playing, set the
Transparent property to True. If you are creating the control programmatically,
add the
ACS_TRANSPARENT style.
If you want the video to start displaying immediately once its host
(the dialog box or form) comes up, set its
Auto Play property to True. If you are dynamically creating the control and you
want its video to play as soon as its parent comes up, add the
ACS_AUTOPLAY style. |
|
The Animator control is based on the CAnimatorCtrl class.
Therefore, if you want to programmatically create an animation, you must first declare
a variable of type, or a pointer to,
CAnimationCtrl. You can do this in the view or the dialog class. After
declaring the variable or pointer, to initialize the object, call its
Create() method. Here is an example:
|
|
|