M
my.c
Unregistered / Unconfirmed
GUEST, unregistred user!
我想当鼠标在窗体上左击时,在窗体上画图。代码段如下:
void TForm1:rawChessmanX(int x,int y)
{
Canvas->Pen->Width=2;
Canvas->Pen->Style=psSolid;
Canvas->Pen->Color=clBlack;
Canvas->MoveTo(x,y);
Canvas->LineTo(x+30,y+30);
Canvas->MoveTo(x+30,y);
Canvas->LineTo(x,y+30);
}
void TForm1:rawChessmanO(int x, int y)
{
Canvas->Pen->Width=2;
Canvas->Pen->Style=psSolid;
Canvas->Pen->Color=clBlue;
Canvas->Brush->Color=Form1->Color;
Canvas->Ellipse(x,y,x+30,y+30);
}
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{int x,y;
if(Button==mbLeft)
for(x=20;x<=20+30*18;x=x+30)
{if(X>x&&X<x+30)
for(y=20;y<=20+30*18;y=y+30)
{if(Y>y&&Y<y+30)
{if(steps%2==1)
DrawChessmanX(x,y);
if(steps%2==0)
DrawChessmanO(x,y);}}
}
steps=steps+1;
}
鼠标左击时,图是画出来了,可当窗体刷新时,图就没了。怎样才能使窗体刷新后图保持原样?
还有,这是我第一次用bcb,c语言也是正在学习中,代码写得很烂,麻烦大家批评指正。不胜感激!!!
void TForm1:rawChessmanX(int x,int y)
{
Canvas->Pen->Width=2;
Canvas->Pen->Style=psSolid;
Canvas->Pen->Color=clBlack;
Canvas->MoveTo(x,y);
Canvas->LineTo(x+30,y+30);
Canvas->MoveTo(x+30,y);
Canvas->LineTo(x,y+30);
}
void TForm1:rawChessmanO(int x, int y)
{
Canvas->Pen->Width=2;
Canvas->Pen->Style=psSolid;
Canvas->Pen->Color=clBlue;
Canvas->Brush->Color=Form1->Color;
Canvas->Ellipse(x,y,x+30,y+30);
}
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{int x,y;
if(Button==mbLeft)
for(x=20;x<=20+30*18;x=x+30)
{if(X>x&&X<x+30)
for(y=20;y<=20+30*18;y=y+30)
{if(Y>y&&Y<y+30)
{if(steps%2==1)
DrawChessmanX(x,y);
if(steps%2==0)
DrawChessmanO(x,y);}}
}
steps=steps+1;
}
鼠标左击时,图是画出来了,可当窗体刷新时,图就没了。怎样才能使窗体刷新后图保持原样?
还有,这是我第一次用bcb,c语言也是正在学习中,代码写得很烂,麻烦大家批评指正。不胜感激!!!