delphi小程序抓图后自动保存 ?
delphi小程序抓图后自动保存到指定的目录中 并且以时间来命名
[解决办法]
bitmap不就可以直接SaveToFile吗
[解决办法]
ABitmap.SaveToFile(SavePath + FormatDateTime('yyyymmddhhmmss', Now) + '.bmp');
SavePath是个变量,保存“指定的位置”,可以做到界面上,让用户去填,当然要程序默认一个先~
[解决办法]
抓图用拷屏BitBlt
procedure TForm1.Button3Click(Sender: TObject);
var
BMP:TBitmap;
fname:string;
ScreenDC:HDC;
begin
bmp := TBitmap.create;
bmp.Width := 1024;
bmp.Height := 768;
ScreenDC := GetDC(0);
try
BitBlt(Bmp.Canvas.Handle,0,0,bmp.Width,bmp.Height,ScreenDC,0,0,SRCCOPY);
finally
ReleaseDC(0,ScreenDC);
end;
fname := ExtractFilePath(ParamStr(0))+
FormatDateTime('yyyymmddhhmmss',now)+'.bmp';
bmp.SaveToFile(fname);
bmp.Free;
end;