FGIW2: C++Builder Version


/****************************************************************************\
*                                                                            *
*  FGIW2.cpp                                                                 *
*  FGIW2U.cpp                                                                *
*                                                                            *
*  This example shows how to play a flic file from an FGI library, using     *
*  either fgi_showflic() or the low-level fgi_flicxxx() routines.            *
*                                                                            *
\****************************************************************************/
#include 
#pragma hdrstop
#include "FGIW2U.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
   : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
   fg_realize(hPal);
   Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
   hDC = GetDC(Form1->Handle);
   fg_setdc(hDC);
   hPal = fg_defpal();
   fg_realize(hPal);
   fg_vbinit();
   hVB = fg_vballoc(320,200);
   fg_vbopen(hVB);
   fg_vbcolors();
   hFGI = fgi_open("EXAMPLE.FGI");
   if (hFGI == 0)
   {
      MessageDlg("Unable to open FGI file.",mtError,TMsgDlgButtons()<OnActivate = OnActivate;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
   TShiftState Shift)
{
   switch (Key)
   {
      case VK_F1:
         Cursor = crHourGlass;
         fgi_showflic("GLASS.FLI",2,0,hFGI);
         Cursor = crDefault;
         break;
      case VK_F2:
         Cursor = crHourGlass;
         fgi_flicskip(Context,-1);
         while (fg_flicplay(Context,1,0) > 0)
            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)
            fg_vbscale(0,fg_getmaxx(),0,fg_getmaxy(),0,cxClient-1,0,cyClient-1);
         Cursor = crDefault;
         break;
   }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
{
   fg_vbscale(0,fg_getmaxx(),0,fg_getmaxy(),0,cxClient-1,0,cyClient-1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
{
   cxClient = ClientWidth;
   cyClient = ClientHeight;
   Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
   fgi_close(hFGI);
   fg_vbclose();
   fg_vbfree(hVB);
   fg_vbfin();
   DeleteObject(hPal);
   ReleaseDC(Form1->Handle,hDC);
}

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.