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 :


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

Sleep(1)                             !Wait for Form objects to complete loading

frmHGForm.Visible=True               !Make the form visible
sImageDir=GetDir(aGetDirCurrent)     !Get the current directory location
sImageName=sImageDir+"\\Logo.jpg"    !Logo file name. Put the Logo on the top of the form
imgLogo.LoadFromFile(sImageName)     !Load the logo
imgLogo.Visible=True                 !Make it visible

!Set the ALog Window to HTML mode to display the animated image file
!Remove the Scroll bar
logHGWid.Document.body.setAttribute("scroll", "no")
!Position the image in the Top-Left corner of the ALog control
!Clear the ALog window
!Get the dimensions of the ALog control for the image height and width settings

!HTML Image string
sImageName="<IMG SRC=\"File:"+sImageDir+"\\Hourglass_icon.gif"+"\""+" width=\""+Str(fWidth)+"\" height=\""+Str(fHeight)+"\">"
!Place the image in the ALog window

An ATEasy application that demonstrates how to load an animated GIF file into a form can be downloaded by clicking on this link Q200225 Example. 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/26/2023
Keywords gif, animatation, ATEasy, form, ALog

Login to rate article

Read Prior Article Read Next Article