我做了:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
DrawingBoard = new Graphics::TBitmap;
DrawingBoard->Width = this->PaintBox1->Width;
DrawingBoard->Height = this->PaintBox1->Height;
}
void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
PaintBox1->Canvas->Pen->Color = clBlack;
Canvas->MoveTo(256,216);
Canvas->LineTo(270,250);
}
void __fastcall TForm1::FormShow(TObject *Sender)
{
PaintBox1->Canvas->Draw(256, 216, DrawingBoard);
}
所以我看到了这条线,但没有在油漆盒内 - 为什么?
答案 0 :(得分:0)
,因为您使用Canvas->
代替PaintBox1->Canvas->
this->Canvas->
在你的情况下我假设你想使用位图作为后台缓冲区
Form1
而不是所有DrawingBoard->Canvas
PaintBox1->Canvas->
FormShow
代替OnPaint
... OnShow
VCL自行翻译坐标这样的事情:
PaintBox
<强> [注释] 强>