AutoAnimate Example for C++ Builder

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.

   LEADRasterIO * pRasterIO= NULL;
   RECT rcClient;
   // Declare variables for positioning the control.
   int DisplayWidth, DisplayHeight, DisplayLeft, DisplayTop;

   CoCreateInstance (CLSID_LEADRasterIO, NULL, CLSCTX_ALL,
                  IID_ILEADRasterIO, (void**)&pRasterIO);
   // Force continued looping after the file loads.
   LEADRasterView1->AutoAnimationLoop = AUTOANIMATIONLOOP_INFINITE;
   // Get information about the file we will load.
   pRasterIO->GetFileInfo (LEADRasterView1->Raster, AnsiToOLESTR("E:\\lead14\\dist\\images\\eye.gif"), 0, 0);
   // Exit if this is not an animated file.
   if (pRasterIO->InfoAnimation == False)
   {
      ShowMessage ("Not an animated file");
      return;
   }
   // Calculate information for centering the LEAD control.
   ::GetClientRect (Handle, &rcClient);
   DisplayWidth= (int) pRasterIO->InfoAnimationWidth;
   DisplayHeight= (int) pRasterIO->InfoAnimationHeight;
   DisplayLeft= (int)(rcClient.right - DisplayWidth / 2);
   DisplayTop= (int)(rcClient.bottom - DisplayHeight / 2);
   // Center the LEAD control.
   MoveWindow (LEADRasterView1->Handle, DisplayLeft, DisplayTop, DisplayLeft + DisplayWidth, DisplayTop + DisplayHeight, False);
   // Set properties for playing the animation as is loads.
   LEADRasterView1->AutoAnimate = True;
   LEADRasterView1->AutoRepaint = True;
   //Load the animated file.
   pRasterIO->Load (LEADRasterView1->Raster, AnsiToOLESTR ("E:\\lead14\\dist\\images\\eye.gif"), 0, 0, -1);
   pRasterIO->Release ();