//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
DrawingBoard = new Graphics::TBitmap;
DrawingBoard->Width = this->PaintBox1->Width;
DrawingBoard->Height = this->PaintBox1->Height;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
IsDrawing = True;
StartX = X;
StartY = Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1MouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if( IsDrawing )
{
DrawingBoard->Canvas->Rectangle(StartX, StartY, X, Y);
PaintBox1->Canvas->Draw(0, 0, DrawingBoard);
IsDrawing = False;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
PaintBox1->Canvas->Draw(0, 0, DrawingBoard);
}
//---------------------------------------------------------------------------
|