//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TFormOnPaint.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TFormOnPaint
// Event: Forms.TCustomForm.OnPaint

// BeginCode
/*
The following code loads a background bitmap onto the Canvas
of the main form in the OnPaint event handler.
*/

#include <memory>       //for STL auto_ptr class

Graphics::TBitmap *TheGraphic;

void __fastcall TForm1::FormPaint(TObject *Sender)// OnPaint event handler
{
  Form1->Canvas->Draw(0, 0, TheGraphic); // Draw the graphic on the Canvas
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  static std::auto_ptr<Graphics::TBitmap> _TheGraphicCleaner(TheGraphic = new Graphics::TBitmap());  // Create the bitmap object
  TheGraphic->LoadFromFile("..\\bigf.bmp"); // Load the bitmap from a file
}
// EndCode
// EndExample: TFormOnPaint
//---------------------------------------------------------------------------
