AutoAnimate Example for C++ 5.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.

ILEADRasterIO *pRasterIO=NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL,
                 IID_ILEADRasterIO, (void**)&pRasterIO);
// Declare variables for positioning the control.
int DisplayWidth, DisplayHeight, DisplayLeft, DisplayTop;
// Force continued looping after the file loads.
m_LEADRasterView1.SetAutoAnimationLoop(AUTOANIMATIONLOOP_INFINITE);
// Get information about the file we will load.
pRasterIO->GetFileInfo(m_LEADRasterView1.GetRaster(),
                       "d:\\lead14\\dist\\images\\eye.gif", 0, 0 );
// Exit if this is not an animated file.
if(pRasterIO->GetInfoAnimation() == FALSE)
{
   MessageBox(TEXT("Not an animated file"), TEXT("Error"));
   return;
}
// Calculate information for centering the LEAD control.
CRect rcClient;
GetClientRect(rcClient);
DisplayWidth = (int) pRasterIO->GetInfoAnimationWidth();
DisplayHeight = (int) pRasterIO->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_LEADRasterView1.MoveWindow(rcWindow);
// Set properties for playing the animation as is loads.
m_LEADRasterView1.SetAutoAnimate(TRUE);
m_LEADRasterView1.SetAutoRepaint(TRUE);
// Load the animated file.
pRasterIO->Load(m_LEADRasterView1.GetRaster(),
                "d:\\lead14\\dist\\images\\eye.gif", 0, 0, -1);
pRasterIO->Release();