改一句就可以:
procedure CopyForm(const AForm: TForm);
var
MyBmp: TBitmap;
R: TRect;
begin
MyBmp := TBitmap.Create;
try
R := Rect(0, 0, AForm.Width, AForm.Height) ;
MyBmp.Width := R.Right;
MyBmp.Height := R.Bottom;
AForm.PaintTo(MyBmp.Canvas, 0, 0); //加这一句
//MyBmp.Canvas.CopyRect(R, AForm.Canvas, R);
MyBmp.SaveToFile('D:/T.bmp');
finally
MyBmp.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
CopyForm(Self);
end;