Colors: C++Builder Version

/****************************************************************************\
*                                                                            *
*  Colors.cpp                                                                *
*  ColorsU.cpp                                                               *
*                                                                            *
*  This program illustrates how to establish the current color for 256-color *
*  and direct color virtual buffers. It obtains the display driver's color   *
*  depth, creates a 640x480 virtual buffer with the same color depth, and    *
*  fills it with blue pixels.                                                *
*                                                                            *
\****************************************************************************/
#include 
#pragma hdrstop
#include "ColorsU.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)
{
   int bpp;
   hDC = GetDC(Form1->Handle);
   fg_setdc(hDC);
   hPal = fg_defpal();
   fg_realize(hPal);
   fg_vbinit();
   bpp = fg_colors();
   fg_vbdepth(bpp);
   hVB = fg_vballoc(640,480);
   fg_vbopen(hVB);
   fg_vbcolors();
   if (bpp > 8)
      fg_setcolorrgb(85,85,255);
   else
      fg_setcolor(19);
   fg_fillpage();
   Application->OnActivate = OnActivate;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormPaint(TObject *Sender)
{
   fg_vbscale(0,fg_getmaxx(),0,fg_getmaxy(),0,cxClient-1,0,cyClient-1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormResize(TObject *Sender)
{
   cxClient = ClientWidth;
   cyClient = ClientHeight;
   Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
   fg_vbclose();
   fg_vbfree(hVB);
   fg_vbfin();
   DeleteObject(hPal);
   ReleaseDC(Form1->Handle,hDC);
}

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.