Taking a screen shot of a window using Delphi code is rather easy.
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
and fast!
Delphi and ImageEn
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*)
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.的更多相关文章
- Capture a Screen Shot
using System; using System.Runtime.InteropServices; using System.Drawing; using System.Drawing.Imagi ...
- Delphi Screen.DataModuleCount 总是返回 0!Delphi 的 Bug? DataModuleCount = 0
今天遇到一个很隐蔽的 Delphi 问题,不知做了什么,有一个功能总是不能使用,后来跟踪以下发现是因为 Screen.DataModuleCount 总是返回 0,而程序中一个函数正好要用到 ...
- [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 ...
- [GE]手动截取当前活动窗口,并且按规则命名(1/2)
Function Take-ScreenShot { <# .SYNOPSIS Used to take a screenshot of the desktop or the active wi ...
- [APAC]手动截取当前活动窗口,并且按规则命名(1/2)
Function Take-ScreenShot { <# .SYNOPSIS Used to take a screenshot of the desktop or the active wi ...
- 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 ...
- Oracle Form's Trigger Tutorial With Sample FMB
Created an Oracle Form to handle specific events / triggers like When-New-Form-Instance, Pre-Insert, ...
- JS BOM基础 全局对象 window location history screen navigator
全局变量声明的两种方式:1,window.变量名=值;2,var 变量名=值; 全局函数声明的两种方式:1,window.函数名=function(){}2,function 函数名=function ...
- 屏幕的遮挡层,js得到屏幕宽高、页面宽高 (window.screen.availHeight)等--
window.screen.availWidth 返回当前屏幕宽度(空白空间) ------当手机有输入法的时候,要注意................window.screen.availHeigh ...
随机推荐
- SQL Server DTS向导,字段转换出现202和200错误
当使用SQL Server 2012的DTS向导(Import and Export Data/导入导出数据)时,会出现如下问题: 当来源数据直接使用表的时候,没有任何问题 但如果来源数据是查询时,就 ...
- vim中ctags应用
ctags(Generate tag files for source code)是vim下方便代码阅读的工具.尽管ctags也可以支持其它编辑器,但是它正式支持的只有VIM.并且VIM中已经默认安装 ...
- httpClient使用中报错org.apache.commons.httpclient.HttpMethodBase - Going to buffer response body of large or unknown size.
在使用HttpClient发送请求,使用httpMethod.getResponseBodyAsString();时当返回值过大时会报错: org.apache.commons.httpclient. ...
- hdu3613 Best Reward 扩展kmp or O(n)求最大回文子串
/** 题目:hdu3613 Best Reward 链接:http://acm.hdu.edu.cn/showproblem.php?pid=3613 题意:有一个字符串,把他切成两部分. 如果这部 ...
- 常见sql 写法总结
关于如何获取1对多数据中最大条数据的写法 例子: LEFT JOIN ( SELECT * FROM table AS n1 WHERE n1.ID IN ( SELECT MAX(id) FROM ...
- Openstack(Kilo)安装系列之Keystone(三)
安装配置 Before you configure the OpenStack Identity service, you must create a database and an administ ...
- mysql DBA 指南
Mysql目录 数据库介绍.常见分类 Mysql入门 Mysql安装配置 Mysql多实例安装配置 Mysql常用基本命令 Mysql权限体系 Mysql数据库备份和恢复 Mysql日志 Mysql逻 ...
- js Date操作
new Date(new Date().getTime() - 24 * 24 * 60 * 60 * 1000)类似C#中的AddDays,返回一个月前的时间 //时间格式化方法 v ...
- git & github 菜鸟笔记
1.概念: 最先进的分布式版本控制系统 文件修改该提交的内容:---版本 文件名 用户 说明 日期 GitHub网站上线了,它为开源项目免费提供Git存储 --CVS及SVN都是集中式的版本控制系统, ...
- BZOJ 3362 Navigation Nightmare 带权并查集
题目大意:给定一些点之间的位置关系,求两个点之间的曼哈顿距离 此题土豪题.只是POJ也有一道相同的题,能够刷一下 别被题目坑到了,这题不强制在线.把询问离线处理就可以 然后就是带权并查集的问题了.. ...