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. HDU1196 Lowest Bit

    Lowest Bit Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  2. python post get请求

    安装 Requests pip install requests import requests requests.get('https://github.com/timeline.json') 使用 ...

  3. 第一百四十三节,JavaScript,利用封装库做百度分享

    JavaScript,利用封装库做百度分享 效果图 html代码 <div id="share"> <h2>分享到</h2> <ul> ...

  4. greenplum全量恢复gprecoverseg -F出现Unable to connect to database时的相关分析及解决方法

    之前有两位朋友碰到过在对greenplum的系统构架更改后,出现全量恢复gprecoverseg -F也无法正常执行的情况. 报错信息为Unable to connect to database. R ...

  5. Machine Learning Yearning - Andrew NG

    链接(1~12章): https://gallery.mailchimp.com/dc3a7ef4d750c0abfc19202a3/files/Machine_Learning_Yearning_V ...

  6. ubuntu16.04主题美化和软件推荐(转载)

    从这里转载!转载!转载! http://blog.csdn.net/terence1212/article/details/52270210

  7. 【转】Linux下mysql操作

    本文转自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/10/18/2216279.html 1.linux下启动mysql的命令:my ...

  8. UI层复习笔记

    在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是整个应用程序的一 ...

  9. CodeForces 156A Message(暴力)

    A. Message time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

  10. Create a Group Policy Central Store

    一.How to create a Group Policy Central Store You have downloaded or created your own Group Policy Ad ...