Display: Delphi Version

The Delphi version of Display sets the form's Visible property to True in the OnCreate event handler before calling fg_modeset() or fg_modetest(). It achieves the full screen display by setting the form's BorderStyle property to bsNone through the Delphi Object Inspector, then setting its WindowState property to wsMaximized in the OnCreate handler after switching to the 800x600 display resolution.

{*****************************************************************************
*                                                                            *
*  Display.dpr                                                               *
*  DisplayU.pas                                                              *
*                                                                            *
*  This program resizes the desktop to 800x600 using the fg_modeset()        *
*  function.                                                                 *
*                                                                            *
*****************************************************************************}
unit DisplayU;
interface
uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, FGWin;
type
  TForm1 = class(TForm)
    procedure AppOnActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormPaint(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  end;
var
  Form1: TForm1;
implementation
{$R *.DFM}
const
  vbWidth = 800;
  vbHeight = 600;
var
  dc   : hDC;
  hPal : hPalette;
  hVB  : integer;
procedure TForm1.AppOnActivate(Sender: TObject);
begin
  fg_realize(hPal);
  Invalidate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Visible := True;
  if fg_modetest(vbWidth,vbHeight,fg_colors) <> 0 then
  begin
    MessageDlg('Cannot set 800x600 desktop',mtError,[mbOK],0);
    Application.Terminate;
    Exit;
  end;
  fg_modeset(vbWidth,vbHeight,fg_colors,1);
  WindowState := wsMaximized;
  dc := GetDC(Form1.Handle);
  fg_setdc(dc);
  hPal := fg_defpal;
  fg_realize(hPal);
  fg_vbinit;
  hVB := fg_vballoc(vbWidth,vbHeight);
  fg_vbopen(hVB);
  fg_vbcolors;
  fg_setcolor(19);
  fg_fillpage;
  Application.OnActivate := AppOnActivate;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if (Key = VK_Escape) or (Key = VK_F12) then Close;
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
  fg_vbpaste(0,vbWidth-1,0,vbHeight-1,0,vbHeight-1);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
  fg_vbclose;
  fg_vbfree(hVB);
  fg_vbfin;
  fg_modeset(0,0,0,0);
  DeleteObject(hPal);
  ReleaseDC(Form1.Handle,dc);
  Application.Minimize;
end;
end.

Note the call to Application.Minimize() in the FormDestroy handler. This is recommended for full screen Delphi programs to prevent a "ghost" button from remaining on the taskbar after the application exits.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.