一个BCB中关于画布Canvas方面的问题
我用这个代码显示“新春快乐,万事如意”:
Canvas->Font->Size=20;
Canvas->Font->Name="隶书";
Canvas->Font->Color=clRed;
Canvas->Brush->Color=clGreen;
Canvas->TextOut(20,30,"新春快乐,万事如意");
如果让这行文字消失,代码要怎么写啊
[解决办法]
你这些代码是卸载 OnPaint 里的么
[解决办法]
你这些代码是写在 OnPaint 里的么
[解决办法]
void __fastcall TForm1::FormPaint(TObject *Sender)
{
Canvas->Font->Size=20;
Canvas->Font->Name="隶书";
Canvas->Font->Color=clRed;
Canvas->Brush->Color=clGreen;
TRect r = Rect(20,30,20+Canvas->TextWidth(txt), 30+Canvas->TextHeight(txt));
Canvas->FillRect(r);
Canvas->TextOut(r.left,r.top,txt);
}
// 显示另一句话
void __fastcall TForm1::btn1Click(TObject *Sender)
{
txt = "新春快乐,万事如意";
Repaint();
}
// 擦掉
void __fastcall TForm1::btn2Click(TObject *Sender)
{
txt = "";
Repaint();
}
// 显示另一句话
void __fastcall TForm1::btn3Click(TObject *Sender)
{
txt = "元旦快乐,万事胜意";
Repaint();
}