procedure TForm1.GrabControl(const aControl: TControl;
const FileName: string);
var
B: TBitmap;
srcRect,dstRect: TRect;
begin
B:=TBitmap.Create;
with dstRect do begin
Left:=0;
Top:=0;
Right:=aControl.Width+1;
Bottom:=aControl.Height+1;
end;
with srcRect do begin
Left:=aControl.Left;
Right:=aControl.Left+aControl.Width;
Top:=aControl.Top;
Bottom:=aControl.Top+aControl.Height;
end;
B.Width:=aControl.Width;
B.Height:=aControl.Height;
B.Canvas.CopyRect(dstRect,Self.Canvas,srcRect);
// сохранить с палитрой 256 цветов
B.PixelFormat:=pf8bit;
B.SaveToFile(FileName);
B.Free;
end;
...
GrabControl(Memo1,'memo_pic.bmp');
GrabControl(Edit1,'edit_pic.bmp');
|