procedure TForm1.Button1Click(Sender: TObject);var FormImage: TBitmap; begin FormImage := GetFormImage; try Clipboard.Assign(FormImage); Image1.Picture.Assign(Clipboard); finally FormImage.Free; end; end;procedure TForm1.FormCreate(Sender: TObject);begin Shape1.Shape := stEllipse; Shape1.Brush.Color := clLime; Image1.Stretch := True; end; Image1.Picture,picture 是其它控件的属性 Tbitmap是一个位图控件 The following code draws the graphic in Picture1 in the top-left corner PaintBox1.PaintBox1.Canvas.Draw(0,0, Picture1.Graphic);
参考: var dest,source:trect; begin source;=image1.clientrect; with dest do begin left:=source.topleft.x-20; top:=source.topleft.y-20; right:=source.bottomright.X+20; bottom:=source.bottomright.Y+20; end; image1.autosize:=false; image1.width:=(dest.right-dest.left); image1.height:=(dest.botton-dest.top); image1.canvas.copyrect(dest,image1.canvas,sourec); end;
FormImage: TBitmap;
begin
FormImage := GetFormImage;
try
Clipboard.Assign(FormImage);
Image1.Picture.Assign(Clipboard);
finally
FormImage.Free;
end;
end;procedure TForm1.FormCreate(Sender: TObject);begin
Shape1.Shape := stEllipse;
Shape1.Brush.Color := clLime;
Image1.Stretch := True;
end;
Image1.Picture,picture 是其它控件的属性
Tbitmap是一个位图控件
The following code draws the graphic in Picture1 in the top-left corner PaintBox1.PaintBox1.Canvas.Draw(0,0, Picture1.Graphic);
var
dest,source:trect;
begin
source;=image1.clientrect;
with dest do
begin
left:=source.topleft.x-20;
top:=source.topleft.y-20;
right:=source.bottomright.X+20;
bottom:=source.bottomright.Y+20;
end;
image1.autosize:=false;
image1.width:=(dest.right-dest.left);
image1.height:=(dest.botton-dest.top);
image1.canvas.copyrect(dest,image1.canvas,sourec);
end;