Visual C++ and MFC Fundamentals Chapter 15: Fundamental Controls
BOOL Open(LPCTSTR lpszFileName);
BOOL Open(UINT nID);
The first version expects the path of the video file. Alternatively, you can first add the file
as a resource to your project and use its identifier as argument to the second version. Here
is an example:
BOOL CControlsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RECT Recto = { 5, 5, 360, 360 };
Player->Create(WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT,
Recto, this, 0x1884);
Player->Open("res\\clock.AVI");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
As mentioned already, an animation is made of various pictures. Each picture is called a
frame. The number of frames that make up an animation can influence its length. A video
to play as animation is a file that puts these pictures together. Once you have the video,
you can play it in an animation. If you want the animation to start playing as soon as its
parent window comes up, you can create it with the ACS_AUTOPLAY style. Otherwise,
to play the animation, you can call the CAnimateCtrl::Play() method. Its syntax is:
BOOL Play(UINT nFrom, UINT nTo, UINT nRep);
?? The nFrom argument specifies the index number of the first frame to play. The
frames are stored as a zero-based array. The first frame is 0, the second is 1, etc
?? The nTo argument is the last frame to play from the list of frames. If you want to
play the video to the end, pass this argument with a value of - 1
?? The nRep is the number of times the video should be played before stopping. If
you want the video to play until you explicitly decide to stop it, pass this
argument as - 1
Suppose you have a long video or one made of various special pictures, if you want to
display just one particular frame of the video, you can call the CAnimateCtrl::Seek()
method whose syntax is:
BOOL Seek(UINT nTo);
This method allows the animation to just straight to the nTo frame number.
At any time, you can stop the video playing by calling the CAnimateCtrl::Stop()
method. Its syntax is:
BOOL Stop();
This member function simply stops the animation.
If you had added your Animator control at design time to the dialog box or form or other
parent window, when the parent goes out of scope, it takes the Animator control with it.