FirstDD: Delphi Version
{*****************************************************************************
* *
* FirstDD.dpr *
* FirstDDU.pas *
* *
* This is a version of the first Fastgraph for Windows example program *
* modified for use as a DirectDraw windowed application. *
* *
*****************************************************************************}
unit FirstDDU;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, FGWinD;
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
{$J+}
{$R *.DFM}
var
dc : hDC;
hPal : hPalette;
hVB : 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);
var
bpp : integer;
begin
dc := GetDC(Form1.Handle);
fg_setdc(dc);
hPal := fg_defpal;
fg_realize(hPal);
Visible := True;
fg_vbinit;
bpp := fg_colors;
fg_vbdepth(bpp);
hVB := fg_vballoc(640,480);
fg_vbopen(hVB);
fg_vbcolors;
if (bpp > 8) then
fg_setcolorrgb(85,85,25)
else
fg_setcolor(19);
fg_fillpage;
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
fg_vbclose;
fg_vbfree(hVB);
fg_vbfin;
DeleteObject(hPal);
ReleaseDC(Form1.Handle,dc);
end;
end.
|