Delphi 截屏函数(包含截取鼠标形状)


本文整理自网络,侵删。

 
//--------------------------------------------------------------------------------------------
 function getDateFilename():string;
  var
    s:string;
  begin
    DateTimeToString(s,'yyyymmddhhnnsss',now());
    result:=s;
  end;
//截屏
function captureScreen(x1:integer;y1:integer;x2:integer;y2:integer):tbitmap;
var
  dc:HDC;
  bmp:tbitmap;
  fullCanvas:TCanvas;
begin
  dc:=GetDC(0);
  fullCanvas:=TCanvas.Create;
  fullCanvas.Handle:=dc;
  bmp:=TBitmap.Create;
  try
    bmp.Width:=abs(x2-x1);
    bmp.Height:=abs(y2-y1);
    bmp.Canvas.CopyRect(Rect(0,0,bmp.Width,bmp.Height),fullCanvas,Rect(x1,y1,x2,y2));
    //bmp.SaveToFile('c:\tmp\1.bmp');
  finally
  end;
  result:=bmp;
end;
 
 
//*************** Draw Cursor on the bitmap ******************
Function DrawCursor(Bit : TBitmap) : TBitmap;
Var
Cur : TCursorInfo;
Icn : TIcon;
IcnInfo : TIconInfo;
Rec : TRect;
begin
Icn := TIcon.Create;
Rec := Bit.Canvas.ClipRect;
try
Cur.cbSize := SizeOf(Cur);
if GetCursorInfo(Cur) then
if Cur.flags = CURSOR_SHOWING then
begin
Icn.Handle := CopyIcon(Cur.hCursor);
if GetIconInfo(Icn.Handle, IcnInfo) then
Bit.Canvas.Draw(Cur.ptScreenPos.X - Integer(IcnInfo.XHotSpot) - Rec.Left,
Cur.ptScreenPos.Y - Integer(IcnInfo.YHotSpot) - Rec.Top,
Icn);
end;
finally
Icn.Free;
end;
Result := Bit;
end;
//************ End of cursor drawing *************************

相关阅读 >>

Delphi 关于 class helper for ... 语法

Delphi xe berlin readprocessmemory writeprocessmemory

Delphi android使用idhttp.get抓取https(ssl)文件

Delphi 无类型文件读写

Delphi资源文件的详细使用方法

Delphi indy 组件包里的 idhttp 组件使用 get 方法下载文件限速的方法

Delphi 调用打印软件代码

Delphi 取目录下指定文件到列表

Delphi 编写ie代理服务器

Delphi windows 编程[21] - wm_menuselect 消息与 getmenustring 函数

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...