Available in the LEADTOOLS Imaging toolkit. |
AutoAnimate Example for C++ 4.0 and later
This example gets information about an animated file, uses the information to position the LEAD control, and plays the animation as it loads the file.
// Declare variables for positioning the control.
int DisplayWidth, DisplayHeight, DisplayLeft, DisplayTop;
// Force continued looping after the file loads.
m_Lead1.SetAutoAnimationLoop(AUTOANIMATIONLOOP_INFINITE);
// Get information about the file we will load.
m_Lead1.GetFileInfo("c:\\windows\\system\\wndsurf1.avi", 0, 0 );
// Exit if this is not an animated file.
if (m_Lead1.GetInfoAnimation() == FALSE)
{
MessageBox("Not an animated file", "Error");
return;
}
// Calculate information for centering the LEAD control.
CRect rcClient;
GetClientRect(rcClient);
DisplayWidth = (int) m_Lead1.GetInfoAnimationWidth();
DisplayHeight = (int) m_Lead1.GetInfoAnimationHeight();
DisplayLeft = (rcClient.right - DisplayWidth) / 2;
DisplayTop= (rcClient.bottom - DisplayHeight) / 2;
// Center the LEAD control.
CRect rcWindow;
rcWindow.SetRect(DisplayLeft, DisplayTop,
DisplayLeft + DisplayWidth,
DisplayTop + DisplayHeight);
m_Lead1.MoveWindow(rcWindow);
// Set properties for playing the animation as is loads.
m_Lead1.SetAutoAnimate(TRUE);
m_Lead1.SetAutoRepaint(TRUE);
// Load the animated file.
m_Lead1.Load("c:\\windows\\system\\wndsurf1.avi", 0, 0, -1);