//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { b=new Graphics::TBitmap; b->LoadFromResourceID((int)HInstance, 100); ClientWidth=b->Width; ClientHeight=b->Height; for(int x = 0; x < 5; x++) for (int y = 0; y < 5; y++) o[x][y]=CreateRectRgn( x*b->Width/5, y*b->Height/5, (x+1)*b->Width/5, (y+1)*b->Height/5); p=CreateRectRgn(0,0,0,0); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormDestroy(TObject *Sender) { delete b; for(int x=0; x<5; x++) for (int y=0; y<5; y++) DeleteObject(o[x][y]); DeleteObject(p); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormPaint(TObject *Sender) { SelectClipRgn(Canvas->Handle, p); Canvas->Draw(0,0,b); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { for(int x=0; x<5; x++) for (int y=0; y<5; y++) if (PtInRegion(o[x][y],X,Y)) CombineRgn(p,p,o[x][y],RGN_OR); InvalidateRect(Handle,NULL,FALSE); } //---------------------------------------------------------------------------