FGFW3: Delphi Version


{*****************************************************************************
*                                                                            *
*  FGFW3.dpr                                                                 *
*  FGFW3U.pas                                                                *
*                                                                            *
*  Demonstrate how to display strings from two different fonts.              *
*                                                                            *
*****************************************************************************}
unit Fgfw3u;
interface
uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, FGWin, FGFWin;
type
  TForm1 = class(TForm)
    procedure AppOnActivate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    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;
  cxClient, cyClient : integer;
  hModern, hAustin : integer;
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(640,480);
  fg_vbopen(hVB);
  fg_vbcolors;
  hAustin := fgf_load('AUSTIN36.FGF'+chr(0));
  hModern := fgf_load('MODERN28.FGF'+chr(0));
  if (hAustin = 0) or (hModern = 0) then
  begin
    MessageDlg('Unable to load font file.',mtError,[mbOK],0);
    Close;
    Exit;
  end;
  fg_setcolor(255);
  fg_fillpage;
  { display characters from the Modern font in upper left corner }
  fg_setcolor(19);
  fgf_select(hModern);
  fgf_justify(-1,1);
  fgf_print('Modern 28',9);
  { display characters from the Austin font in upper right corner }
  fgf_select(hAustin);
  fgf_justify(1,1);
  fg_move(fg_getmaxx,0);
  fgf_print('Austin 36',9);
  Application.OnActivate := AppOnActivate;
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
  fgf_unload(-1);
  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.