Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 15: Fundamental Controls


Practical Learning: Introducing Animations



  1. Create a New Dialog-based Project called Video1

  2. Delete the TODO line and the OK button

  3. Change the caption of the Cancel button to &Close


15.2.2..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
rectangular shape. 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 style. In this case, the center of
the video would 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

Practical Learning: Animating a Video



  1. From the Controls toolbox, click the Animation button and draw a rectangle
    from the upper left section of the dialog box to the right-middle

  2. Using the Properties window, set the Border value to False or uncheck it

  3. Set the Auto Play, the Center, and the Transparent values to True or check them

Free download pdf