AutoAnimate Example for Delphi
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.
var
RasterIO: LEADRasterIO ;
rcClient: TRect;
// Declare variables for positioning the control.
DisplayWidth, DisplayHeight, DisplayLeft, DisplayTop: Integer;
begin
RasterIO:= CoLEADRasterIO.Create ();
// Force continued looping after the file loads.
LEADRasterView1.AutoAnimationLoop:= AUTOANIMATIONLOOP_INFINITE;
// Get information about the file we will load.
RasterIO.GetFileInfo (LEADRasterView1.Raster, 'E:\lead14\dist\images\eye.gif', 0, 0);
// Exit if this is not an animated file.
if (RasterIO.InfoAnimation = false) then
ShowMessage ('Not an animated file')
else
begin
// Calculate information for centering the LEAD control.
Windows.GetClientRect (Handle, rcClient);
DisplayWidth:= Trunc (RasterIO.InfoAnimationWidth);
DisplayHeight:= Trunc (RasterIO.InfoAnimationHeight);
DisplayLeft:= Trunc((rcClient.right - DisplayWidth) / 2);
DisplayTop:= Trunc((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.
RasterIO.Load (LEADRasterView1.Raster, 'E:\lead14\dist\images\eye.gif', 0, 0, -1);
end;
end;