How to Display an Animated GIF File in an ATEasy Form

Knowledge Base Article # Q200225

Read Prior Article Read Next Article
Summary How to display an animated GIF file on a form
  
Login to rate article
In ATEasy form's, animated GIF files are supported by the ALog control. To display an animated GIF in a log control, set the control to HTML mode (PlainText property set to False), and then append an image tag with the GIF file.
The image file is defined using the HTML IMG tag and can then be inserted into the ALog control using the Append method.

The height and width of the image can be specified using the height and width attributes.
For example, the following line links the image to the "C:\geotest.gif" file and sets the image height and width to 42.

  <img src="c:\\geotest.gif" height="42" width="42" />


The image is then appended to the ALog control using the Append control as follows:

  log1.Append("<img src=\"c:\\geotest.gif\" height=\"42\" width=\"42\" />")


To hide the ALog's scrollbar, which is displayed by default, insert the following into ALog's OnLoad event:

  log1.Document.body.setAttribute("scroll", "no")


The image can be positioned in the ALog control by setting the ALog control margins. For example, inserting the following settings into AForm's OnLoad event will align the image in the Top-Left corner of ALog control :

  log1.Document.Body.LeftMargin=0
  log1.Document.Body.TopMargin=0


Here is the complete code for displaying the animated GIF in a log control:

  ! set the ALog Window to HTML mode to display the animated image file
  logAnimated.PlainText=False
  ! remove the Scroll bar
  logAnimated.Document.body.setAttribute("scroll", "no")
  ! position the image in the Top-Left corner of the ALog control
  logAnimated.Document.Body.LeftMargin=0                
  logAnimated.Document.Body.TopMargin=0                
  ! get the dimensions of the ALog control for the image height and width settings
  fHeight=logAnimated.Height-4
  fWidth=logAnimated.Width-4
  ! place the image in the ALog window
  sText="<IMG SRC=\"File:"+GetDir(aGetDirAppExe)+"\\Hourglass_icon.gif"+        " \"width=\""+str(fWidth)+" \"height=\""+str(fHeight)+"\">"
  logAnimated.Append(sText)


An ATEasy application that demonstrates how to load an animated GIF file into a form can be downloaded by clicking on this link DownloadQ200225.zip. The application opens a window that displays a spinning hourglass. The main section of code can be found in the OnLoad event for the program form.
Article Date 2/27/2012 , 4/16/2014
Keywords gif, animatation, ATEasy, form, ALog


Login to rate article

Read Prior Article Read Next Article
>