Display: C++Builder Version

The C++Builder 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 C++Builder Object Inspector, then setting its WindowState property to wsMaximized in the OnCreate handler after switching to the 800x600 display resolution.

/****************************************************************************\
*                                                                            *
*  Display.cpp                                                               *
*  DisplayU.cpp                                                              *
*                                                                            *
*  This program resizes the desktop to 800x600 using the fg_modeset()        *
*  function.                                                                 *
*                                                                            *
\****************************************************************************/
#include 
#pragma hdrstop
#include "DisplayU.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)
{
   Visible = True;
   if (fg_modetest(vbWidth,vbHeight,fg_colors()) != 0)
   {
      MessageDlg("Cannot set 800x600 desktop",mtError,TMsgDlgButtons()<Terminate();
      return;
   }
   fg_modeset(vbWidth,vbHeight,fg_colors(),1);
   WindowState = wsMaximized;
   hDC = GetDC(Form1->Handle);
   fg_setdc(hDC);
   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 = OnActivate;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{
   if (Key == VK_ESCAPE || Key == VK_F12) Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
{
   fg_vbpaste(0,vbWidth-1,0,vbHeight-1,0,vbHeight-1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
   fg_vbclose();
   fg_vbfree(hVB);
   fg_vbfin();
   fg_modeset(0,0,0,0);
   DeleteObject(hPal);
   ReleaseDC(Form1->Handle,hDC);
   Application->Minimize();
}

Note the call to Application->Minimize() in the FormDestroy handler. This is recommended for full screen C++Builder 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.