远程控制编程技术--屏幕抓取的实现

一、屏幕抓取的实现:
HICON CWnd::SetIcon( HICON hIcon, BOOL bBigIcon );
(Call this member function to set the handle to a specific icon, as identified by hIcon. When the window class is registered, it selects an icon.)
bBigIcon
Specifies a 32 pixel by 32 pixel icon if TRUE; specifies a 16 pixel by 16 pixel icon if FALSE.
用在对话框中可修改程序图标,其他文档不适用。

 

 

BOOL CWnd::IsIconic( ) const;
(Specifies whether CWnd is minimized (iconic). Nonzero if CWnd is minimized; otherwise 0.)

 

 

HDC CWnd::GetSafeHdc( ) const;
(Call this member function to get m_hDC, the output device context. This member function also works with null pointers. Return Value:A device context handle.)

 

 

int GetSystemMetrics(
int nIndex   // system metric or configuration setting to retrieve
);
(The GetSystemMetrics function retrieves various system metrics (widths and heights of display elements) and system configuration settings. All dimensions retrieved by GetSystemMetrics are in pixels.)

 

 

BOOL DrawIcon( int x, int y, HICON hIcon );
BOOL DrawIcon( POINT point, HICON hIcon );
在当前CDC对象的设备上绘制图标。该函数将图标左上角置于x和y 参数确定的坐标上,位置受到设备上下文的当前映射模式的影响。图标资源必须已由函数CwinApp::LoadIcon, CwinApp::LoadStandardIcon,或CwinApp::LoadOEMIcon预装,使用本函数应优先选择 MM_TEXT 映射模式。

 

 

int CDC::GetDeviceCaps( int nIndex ) const;
(Retrieves a wide range of device-specific information about the display device.)
nIndex
Specifies the type of information to return. It can be any one of the following values:
BITSPIXEL   Number of adjacent color bits for each pixel. 每一像素的颜色字节数
HORZRES   Width of the display (in pixels). 显示宽度(用像素表示)。
VERTRES   Height of the display (in raster lines). 显示高度(用光栅线表示)。
PLANES   Number of color planes. 颜色位面数。
…… ……

int GetObject(
  HGDIOBJ hgdiobj,  // handle to graphics object of interest
  int cbBuffer,     // size of buffer for object information
  LPVOID lpvObject  // pointer to buffer for object information(注意类型)
);
(The GetObject function obtains information about a specified graphics object. Depending on the graphics object, the function places a filled-in BITMAP, DIBSECTION, EXTLOGPEN, LOGBRUSH, LOGFONT, or LOGPEN structure, or a count of table entries (for a logical palette), into a specified buffer.)

 

 

int GetDIBits(
  HDC hdc,           // handle to device context
  HBITMAP hbmp,      // handle to bitmap
  UINT uStartScan,   // first scan line to set in destination bitmap
  UINT cScanLines,   // number of scan lines to copy
  LPVOID lpvBits,    // address of array for bitmap bits
  LPBITMAPINFO lpbi, // address of structure with bitmap data
  UINT uUsage        // RGB or palette index
);
(The GetDIBits function retrieves the bits of the specified bitmap and copies them into a buffer using the specified format.)

 

 

 

 

全屏抓取代码示例:
1.抓取屏幕代码示例,可放于单文档OnDraw函数内部演示:




2.第二段存储图象代码,同上面段放于单文档OnDraw函数内部演示:



3.第三段将图象复制到剪贴板代码:

 


Leave a Reply

Your email address will not be published.