TGif
Source: source/classes/tgif.prg
Hierarchy: TGif → TControl
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
| DATA | Type | Default | Description |
|---|---|---|---|
hGif | Numeric | Handle to the internal GIF animation window | |
cFilename | Character | Path to the GIF file (or resource name) | |
lAdjust | Logical | .F. | Stretch GIF to fill the control dimensions when .T. |
nSizingType | Numeric | FWGIF_SIZING_FILE | One of FWGIF_SIZING_FILE, FWGIF_SIZING_CLIP, or FWGIF_SIZING_STRETCH |
Sizing Modes
| Constant | Value | Description |
|---|---|---|
FWGIF_SIZING_FILE | Default | Use the GIF's natural dimensions. Control auto-sizes to match. |
FWGIF_SIZING_CLIP | Clip the GIF to fit the control's bounding rectangle at its natural size. | |
FWGIF_SIZING_STRETCH | Stretch the GIF to fill the control dimensions (same as lAdjust := .T.). |
Methods
| Method | Description |
|---|---|
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
- GIF files can be loaded from disk or from embedded resources (resource type 10 /
RT_RCDATA). When a resource name is passed, the control extracts it to a temporary file for display. - When no explicit width/height is given, the control auto-sizes to the GIF's natural dimensions.
- The
lAdjustflag is a convenience property that internally sets the sizing mode toFWGIF_SIZING_STRETCH. - Multiple TGif controls can coexist in the same window; each manages its own animation independently.
- The control requires the FWH internal GIF engine (linked from
source/function/).