//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; int keyy; bool isZero = false; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void drawZeroOrX(int x, int y) { if(isZero) { Form1->Canvas->Ellipse( x*(Form1->ClientWidth/3), y*(Form1->ClientHeight/3), x*(Form1->ClientWidth/3)+(Form1->ClientWidth/3), y*(Form1->ClientHeight/3)+(Form1->ClientHeight/3) ); }else{ Form1->Canvas->MoveTo(x*(Form1->ClientWidth/3), y*(Form1->ClientHeight/3)); Form1->Canvas->LineTo(x*(Form1->ClientWidth/3)+(Form1->ClientWidth/3), y*(Form1->ClientHeight/3)+(Form1->ClientHeight/3)); Form1->Canvas->MoveTo(x*(Form1->ClientWidth/3)+(Form1->ClientWidth/3), y*(Form1->ClientHeight/3)); Form1->Canvas->LineTo(x*(Form1->ClientWidth/3), y*(Form1->ClientHeight/3)+(Form1->ClientHeight/3)); } isZero=!isZero; } void __fastcall TForm1::FormPaint(TObject *Sender) { TRect aRect = Rect(0,0,ClientWidth,ClientHeight); Canvas->Brush->Color=(TColor)0xffffff; Canvas->FillRect(aRect); for(int i=1; i<3; i++) { Canvas->MoveTo(i*ClientWidth/3,0); Canvas->LineTo(i*ClientWidth/3,ClientHeight); } for(int i=1; i<3; i++) { Canvas->MoveTo(0, i*ClientHeight/3); Canvas->LineTo(ClientWidth,i*ClientHeight/3); } } //--------------------------------------------------------------------------- void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { //UL if((XClientWidth/3) && (X<2*ClientWidth/3) && (Y2*ClientWidth/3) && (YClientHeight/3) && (Y<2*ClientHeight/3)) { drawZeroOrX(0,1); } //SS else if((X>ClientWidth/3) && (X<2*ClientWidth/3) && (Y>ClientHeight/3) && (Y<2*ClientHeight/3)) { drawZeroOrX(1,1); } //SR else if((X>2*ClientWidth/3) && (Y>ClientHeight/3) && (Y<2*ClientHeight/3)) { drawZeroOrX(2,1); } //DL if((X2*ClientHeight/3)) { drawZeroOrX(0,2); } //DS else if((X>ClientWidth/3) && (X<2*ClientWidth/3) && (Y>2*ClientHeight/3)) { drawZeroOrX(1,2); } //DR else if((X>2*ClientWidth/3) && (Y>2*ClientHeight/3)) { drawZeroOrX(2,2); } Canvas->TextOutA(2,3,IntToStr(keyy)); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { keyy = (int) Key; //if(((int)Key)==VK_LEFT) drawZeroOrX(0,0); } //---------------------------------------------------------------------------