Delphi 对非活动窗口进行屏幕截图


本文整理自网络,侵删。

 
function WindowSnap(windowHandle: HWND; bmp: TBitmap): boolean;
var
  r: TRect;
  user32DLLHandle: THandle;
  printWindowAPI: function(sourceHandle: HWND; destinationHandle: HDC;
    nFlags: UINT): BOOL; stdcall;
begin
  result := False;
  user32DLLHandle := GetModuleHandle(user32) ;
  if user32DLLHandle <> 0 then
  begin
    @printWindowAPI := GetProcAddress(user32DLLHandle, 'PrintWindow');
    if @printWindowAPI <> nil then
    begin
      GetWindowRect(windowHandle, r) ;
      bmp.Width := r.Right - r.Left;//www.delphitop.com
      bmp.Height := r.Bottom - r.Top;
      bmp.Canvas.Lock;
      try
        result := printWindowAPI(windowHandle, bmp.Canvas.Handle, 0) ;
      finally
        bmp.Canvas.Unlock;
      end;
    end;
  end;
end; (*WindowSnap*)



procedure TForm2.Button1Click(Sender: TObject);

begin
Image1.Picture:=nil;
WindowSnap(Self.Handle, Image1.Picture.Bitmap) ;
Image1.Refresh;

end;

相关阅读 >>

Delphi根据进程名强制关闭进程

Delphi 2009 之 tcategorypanelgroup[5]: headerstyle

Delphi旋转位图

Delphi getdrivetypea() 查看驱动器类型

Delphi 错误no ftp list parsers have been registered

Delphi xe 如何实现("再按一次退出") 然后退出程序

Delphi 取当前目录下所有文件夹名和文件名

sendmessage在结束进程上的使用

Delphi写一个简单的多线程的程序

Delphi 提取html网页源文件纯文本函数可做采集

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



打赏

取消

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

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

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

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

评论

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