TGif

Source: source/classes/tgif.prg

Hierarchy: TGifTControl

TGif is a control for displaying animated GIF images within FiveWin windows and dialogs. It supports play, stop, restart operations and three sizing modes for controlling how the GIF frames fit within the control's bounding rectangle. The control can load GIFs from files or from embedded resources.

GIF Command

@ nRow, nCol GIF oGif FILE cGifFile SIZE nW, nH OF oWnd

Key DATA Members

DATATypeDefaultDescription
hGifNumericHandle to the internal GIF animation window
cFilenameCharacterPath to the GIF file (or resource name)
lAdjustLogical.F.Stretch GIF to fill the control dimensions when .T.
nSizingTypeNumericFWGIF_SIZING_FILEOne of FWGIF_SIZING_FILE, FWGIF_SIZING_CLIP, or FWGIF_SIZING_STRETCH

Sizing Modes

ConstantValueDescription
FWGIF_SIZING_FILEDefaultUse the GIF's natural dimensions. Control auto-sizes to match.
FWGIF_SIZING_CLIPClip the GIF to fit the control's bounding rectangle at its natural size.
FWGIF_SIZING_STRETCHStretch the GIF to fill the control dimensions (same as lAdjust := .T.).

Methods

MethodDescription
New( oWnd, cGifFile, nRow, nCol, nHeight, nWidth, oCursor, lAdjust, bAction )Constructor. Creates the GIF control and begins animation.
Play()Start or resume the GIF animation.
Stop()Pause the GIF animation at the current frame.
Restart()Restart the animation from the first frame.
IsRunning()Return .T. if the animation is currently playing.
SetFile( cFile )Load a new GIF file into the control.
SetSizing( nType )Change the sizing mode at runtime.
GetData()Return an array with GIF metadata (dimensions, frame count, etc.).

Example: Loading Spinner

#include "FiveWin.ch"

function Main()

   local oWnd, oGif, lPlaying := .T.

   DEFINE WINDOW oWnd TITLE "Animated GIF" ;
      SIZE 400, 350

   @ 30, 100 GIF oGif FILE "spinner.gif" ;
      SIZE 64, 64 OF oWnd

   @ 250, 80 BUTTON "&Play / Pause" SIZE 80, 25 ;
      ACTION ( If( oGif:IsRunning(), oGif:Stop(), oGif:Play() ),;
               lPlaying := !lPlaying )

   @ 250, 170 BUTTON "&Restart" SIZE 70, 25 ;
      ACTION oGif:Restart()

   @ 250, 250 BUTTON "&Close" SIZE 60, 25 ;
      ACTION oWnd:End()

   ACTIVATE WINDOW oWnd

return nil

Notes

See Also