delphi7中如何实现把程序窗体中的所有内容保存成图片。 5
1个回答
展开全部
把窗体界面保存为图片
GetControlsImage(Self).SaveToFile('D:\tools\a.bmp');
function GetControlsImage(ACtrl: TWinControl): TBitmap;
var
Ofs: Integer;
begin
Result := TBitmap.Create;
try
Result.Width := ACtrl.ClientWidth;
Result.Height := ACtrl.ClientHeight;
Result.Canvas.Brush := ACtrl.Brush;
Result.Canvas.FillRect(ACtrl.ClientRect);
Result.Canvas.Lock;
try
if GetWindowLong(ACtrl.Handle, GWL_STYLE) and WS_BORDER <> 0 then
Ofs := -1 // Don't draw form border
else
Ofs := 0; // There is no border
ACtrl.PaintTo(Result.Canvas.Handle, Ofs, Ofs);
finally
Result.Canvas.Unlock;
end;
except
Result.Free;
raise;
end;
end;
GetControlsImage(Self).SaveToFile('D:\tools\a.bmp');
function GetControlsImage(ACtrl: TWinControl): TBitmap;
var
Ofs: Integer;
begin
Result := TBitmap.Create;
try
Result.Width := ACtrl.ClientWidth;
Result.Height := ACtrl.ClientHeight;
Result.Canvas.Brush := ACtrl.Brush;
Result.Canvas.FillRect(ACtrl.ClientRect);
Result.Canvas.Lock;
try
if GetWindowLong(ACtrl.Handle, GWL_STYLE) and WS_BORDER <> 0 then
Ofs := -1 // Don't draw form border
else
Ofs := 0; // There is no border
ACtrl.PaintTo(Result.Canvas.Handle, Ofs, Ofs);
finally
Result.Canvas.Unlock;
end;
except
Result.Free;
raise;
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询