VBdemo: Delphi Version


{*****************************************************************************
*                                                                            *
*  VBdemo.dpr                                                                *
*  VBdemoU.pas                                                               *
*                                                                            *
*  This program demonstrates how to copy the contents of one virtual buffer  *
*  to another, with and without transparent colors.                          *
*                                                                            *
*****************************************************************************}
unit VBdemoU;
interface
uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, Menus, FGWin;
type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Cut: TMenuItem;
    Paste: TMenuItem;
    Exit1: TMenuItem;
    procedure AppOnActivate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure CutClick(Sender: TObject);
    procedure PasteClick(Sender: TObject);
    procedure ExitClick(Sender: TObject);
  end;
var
  Form1: TForm1;
implementation
{$R *.DFM}
const
  vbWidth  = 640;
  vbHeight = 480;
var
  dc   : hDC;
  hPal : hPalette;
  hVB1, hVB2 : integer;
  cxClient, cyClient : 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;
  hVB2 := fg_vballoc(vbWidth,vbHeight);
  fg_vbopen(hVB2);
  fg_vbcolors;
  hVB1 := fg_vballoc(vbWidth,vbHeight);
  fg_vbopen(hVB1);
  fg_vbcolors;
  fg_setcolor(25);
  fg_fillpage;
  fg_setcolor(20);
  fg_rect(vbWidth div 4,vbWidth*3 div 4,vbHeight div 4,vbHeight*3 div 4);
  Application.OnActivate := AppOnActivate;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
  fg_vbscale(0,vbWidth-1,0,vbHeight-1,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
  fg_vbclose;
  fg_vbfree(hVB1);
  fg_vbfree(hVB2);
  fg_vbfin;
  DeleteObject(hPal);
  ReleaseDC(Form1.Handle,dc);
end;
procedure TForm1.CutClick(Sender: TObject);
begin
  fg_vbcopy(0,vbWidth-1,0,vbHeight-1,0,vbHeight-1,hVB1,hVB2);
  fg_erase;
  fg_vbscale(0,vbWidth-1,0,vbHeight-1,0,cxClient-1,0,cyClient-1);
  Paste.Enabled := True;
end;
procedure TForm1.PasteClick(Sender: TObject);
begin
  fg_tcdefine(25,1);
  fg_vbtccopy(0,vbWidth-1,0,vbHeight-1,0,vbHeight-1,hVB2,hVB1);
  fg_vbscale(0,vbWidth-1,0,vbHeight-1,0,cxClient-1,0,cyClient-1);
end;
procedure TForm1.ExitClick(Sender: TObject);
begin
  Close;
end;
end.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.