FGIW2: Delphi Version


{*****************************************************************************
*                                                                            *
*  FGIW2.dpr                                                                 *
*  FGIW2U.pas                                                                *
*                                                                            *
*  This example shows how to play a flic file from an FGI library, using     *
*  either fgi_showflic() or the low-level fgi_flicxxx() routines.            *
*                                                                            *
*****************************************************************************}
unit Fgiw2u;
interface
uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, FGWin, FGIWin;
type
  TForm1 = class(TForm)
    procedure AppOnActivate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormPaint(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  end;
var
  Form1: TForm1;
implementation
{$R *.DFM}
var
  dc   : hDC;
  hPal : hPalette;
  hVB  : integer;
  hFGI : integer;
  cxClient, cyClient : integer;
  Context : array [1..20] of byte;
procedure TForm1.AppOnActivate(Sender: TObject);
begin
  fg_realize(hPal);
  Invalidate;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
  fg_realize(hPal);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  dc := GetDC(Form1.Handle);
  fg_setdc(dc);
  hPal := fg_defpal;
  fg_realize(hPal);
  fg_vbinit;
  hVB := fg_vballoc(320,200);
  fg_vbopen(hVB);
  fg_vbcolors;
  hFGI := fgi_open('EXAMPLE.FGI'+chr(0));
  if hFGI = 0 then
  begin
    MessageDlg('Unable to open FGI file.',mtError,[mbOK],0);
    Close;
    Exit;
  end;
  fgi_flicopen('GLASS.FLI'+chr(0),Context,hFGI);
  fg_flicplay(Context,1,0);
  Application.OnActivate := AppOnActivate;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case Key of
  VK_F1:
    begin
      Cursor := crHourGlass;
      fgi_showflic('GLASS.FLI'+chr(0),2,0,hFGI);
      Cursor := crDefault;
    end;
  VK_F2:
    begin
      Cursor := crHourGlass;
      fgi_flicskip(Context,-1);
      while fg_flicplay(Context,1,0) > 0 do
        fg_vbscale(0,fg_getmaxx,0,fg_getmaxy,0,cxClient-1,0,cyClient-1);
      fgi_flicskip(Context,-1);
      while fg_flicplay(Context,1,0) > 0 do
        fg_vbscale(0,fg_getmaxx,0,fg_getmaxy,0,cxClient-1,0,cyClient-1);
      Cursor := crDefault;
    end;
  end;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
  fg_vbscale(0,fg_getmaxx,0,fg_getmaxy,0,cxClient-1,0,cyClient-1);
end;
procedure TForm1.FormResize(Sender: TObject);
begin
  cxClient := ClientWidth;
  cyClient := ClientHeight;
  Invalidate;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
  fgi_close(hFGI);
  fg_vbclose;
  fg_vbfree(hVB);
  fg_vbfin;
  DeleteObject(hPal);
  ReleaseDC(Form1.Handle,dc);
end;
end.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.