Taking a screen shot of a window using Delphi code is rather easy.
A screen shot (screen capture) is a copy of the screen's contents that
can be saved as a graphics file or displayed in a graphics "aware" control, for
example TImage.

In most cases you will want to take a screen shot of the active window or the
Windows Desktop.

What if you need to do a screen capture of all the running applications -
most of them will be inactive and not visible to the user?

WindowSnap - Inactive Window Screen Capture

Globalize your Delphi applications easy, professionally
and fast!
Create professional multimedia and photo apps with
Delphi and ImageEn
Native VCL component for reading & writing Excel
files with Delphi/C++
 

Windows XP also introduces
the new printing API, PrintWindow. This API enables the caller to snapshot a
visual copy of a window into a device context.

Drop a TImage (named "Image1") on a form and use the following code:

                                                              

The actual WindowSnap function is defined as:

 uses Windows; //if not already used
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;       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*)
Learn C# quickly and easily. Download your Free eBook now.
Unblock any Site. Try it Risk Free. 256-Bit SSL. High Speed Guaranteed!
 

Note that the first parameter to the WindowSnap procedure is a HWND value (THandle) - the handle of the window you want to capture.

WinDowse is an extremely convenient and easy to use tool for obtaining necessary technical information about any window (handle, child windows, etc.)

Here's an idea: enumerate top-level windows (to grab their handles) and create your own task-switcher :)

Taking a screen shot of a window using Delphi code is rather easy.的更多相关文章

  1. Capture a Screen Shot

    using System; using System.Runtime.InteropServices; using System.Drawing; using System.Drawing.Imagi ...

  2. Delphi Screen.DataModuleCount 总是返回 0!Delphi 的 Bug? DataModuleCount = 0

         今天遇到一个很隐蔽的 Delphi 问题,不知做了什么,有一个功能总是不能使用,后来跟踪以下发现是因为 Screen.DataModuleCount 总是返回 0,而程序中一个函数正好要用到 ...

  3. [Windows Server]Windows Server turn off screen auto-lock to fit scheduled tasks(Error Code :0x4F7) / 关闭Windows Server的自动锁定来解决计划任务0x4F7错误

    1. 打开“运行”,输入“regedit” 并回车. 2. 找到以下注册表路径,将Attributes的值改为 2: (原为1 HKEY_LOCAL_MACHINE \SYSTEM \CurrentC ...

  4. [GE]手动截取当前活动窗口,并且按规则命名(1/2)

    Function Take-ScreenShot { <# .SYNOPSIS Used to take a screenshot of the desktop or the active wi ...

  5. [APAC]手动截取当前活动窗口,并且按规则命名(1/2)

    Function Take-ScreenShot { <# .SYNOPSIS Used to take a screenshot of the desktop or the active wi ...

  6. Run_Product Example Form - Oracle Forms 6i

    I have already posted in my previous post Running Reports Using Run_Product to run reports in Oracle ...

  7. Oracle Form's Trigger Tutorial With Sample FMB

    Created an Oracle Form to handle specific events / triggers like When-New-Form-Instance, Pre-Insert, ...

  8. JS BOM基础 全局对象 window location history screen navigator

    全局变量声明的两种方式:1,window.变量名=值;2,var 变量名=值; 全局函数声明的两种方式:1,window.函数名=function(){}2,function 函数名=function ...

  9. 屏幕的遮挡层,js得到屏幕宽高、页面宽高 (window.screen.availHeight)等--

    window.screen.availWidth 返回当前屏幕宽度(空白空间) ------当手机有输入法的时候,要注意................window.screen.availHeigh ...

随机推荐

  1. python+fastcgi+flup获取请求的数据和环境变量

    关于nginx+python+fastcgi+flup搭建fastcgi环境没问题了,可是如何处理POST/GET的请求数据呢,这个问题着实纠结了没久,通过尝试和阅读flup的源代码,终于明白了.先上 ...

  2. js删除数组中某一项,splice()

    ' ","childTagName":"高中"}, {","childTagName":"初中"}] ...

  3. 档案 & 权限管理

    1. owner, group, others root 是万能的天神 权限 连结档 owner group 容量 修改日期 档名 2. chown, chgrp, chmod chgrp –R ro ...

  4. 第一百五十八节,封装库--JavaScript,ajax说明

    封装库--JavaScript,ajax说明 封装库ajax()方法,ajax通讯方法,跨页面向动态页面发送或获取数据 /** ajax()方法,ajax通讯方法,跨页面向动态页面发送或获取数据 * ...

  5. 【BZOJ】2017: [Usaco2009 Nov]硬币游戏(dp+神题+博弈论)

    http://www.lydsy.com/JudgeOnline/problem.php?id=2017 这题太神了,我想了一个中午啊 原来是看错题一直没理解题解说的,一直以为题解是错的QAQ “开始 ...

  6. docker-py环境配置

    一.系统环境版本介绍: os-version: Linux -.el7.x86_64 python-version: Python six-version: python-six--.el7.noar ...

  7. win7系统

    网址:http://www.xitongma.com/Windows7/ 使用方法:http://www.cnblogs.com/henrychan688/p/5223935.html

  8. Linux下自动调整时间和时区与Internet时间同步

    (原文链接) 调整linux系统时间和时区与Internet时间同步一.修改时区:# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime修改为中国的 ...

  9. centos7的nfs配置

    author : headsen chen date : 2018-04-12  09:40:14  一,服务端安装和配置: 环境准备: systemctl stop firewalld system ...

  10. 【BZOJ4596】[Shoi2016]黑暗前的幻想乡 容斥+矩阵树定理

    [BZOJ4596][Shoi2016]黑暗前的幻想乡 Description 幽香上台以后,第一项措施就是要修建幻想乡的公路.幻想乡有 N 个城市,之间原来没有任何路.幽香向选民承诺要减税,所以她打 ...