如何获取整个桌面的位图

ysddmy 2014-02-23 01:20:11
RT
用CCllientDC 类可以办到吗
...全文
454 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2014-02-23
  • 打赏
  • 举报
回复

HBITMAP CopyScreenToBitmap(CRect &Rect,HWND hwnd) 
{  
HDC      hScrDC, hMemDC;      
HBITMAP  hOldBitmap,hBitmap;  
int      xScrn, yScrn;        
// to screen coordinates. 
	MapWindowPoints(hwnd,NULL,(POINT *)&Rect,2);
	hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL); 
	hMemDC = CreateCompatibleDC(hScrDC); 
//
	xScrn = GetDeviceCaps(hScrDC, HORZRES); 
	yScrn = GetDeviceCaps(hScrDC, VERTRES); 
//
	if (Rect.left < 0)  Rect.left = 0; 
	if (Rect.top < 0)   Rect.top  = 0; 
	if (Rect.right  > xScrn)  Rect.right = xScrn; 
	if (Rect.bottom > yScrn) Rect.bottom = yScrn; 
//
	hBitmap = CreateCompatibleBitmap(hScrDC, Rect.Width(),Rect.Height()); 
	hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap); 
	BitBlt(hMemDC,0,0,Rect.Width(),Rect.Height(),hScrDC,Rect.left,Rect.top,SRCCOPY); 
	hBitmap =(HBITMAP)SelectObject(hMemDC,hOldBitmap); 
//
	DeleteDC(hScrDC); 
	DeleteDC(hMemDC); 
//
	return hBitmap; 
}      
副组长 2014-02-23
  • 打赏
  • 举报
回复
不可以。 你可以直接用裁剪板。

2,586

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧