procedure TForm1.Button1Click(Sender: TObject);var cvs: TCanvas;begin {PaintBox1 就像窗体一样, 也有 Canvas 属性} PaintBox1.Canvas.Brush.Color := clRed; PaintBox1.Canvas.FillRect(PaintBox1.ClientRect); {像 Panel1 这样没有 Canvas 属性的控件, 也可以绕道获取} cvs := TCanvas.Create; cvs.Handle := GetDC(Panel1.Handle); cvs.Brush.Color := clBlue; cvs.FillRect(Panel1.ClientRect); cvs.Free;end; //执行前后对比图: