19,468
社区成员
发帖
与我相关
我的任务
分享
HWND hSource = ::GetDesktopWindow();
if (!hSource)
{
cout<<"没有找到窗口"<<endl;
return 0;
}
RECT SourceRect;
GetWindowRect(hSource,&SourceRect);
HDC hdcSource = ::GetDC(hSource);
HDC hdcMem = CreateCompatibleDC(hdcSource);
HBITMAP hSourceMap = ::CreateCompatibleBitmap(hdcMem,SourceRect.right- SourceRect.left,
SourceRect.bottom - SourceRect.top);
HBITMAP hOldBM = (HBITMAP)SelectObject(hdcMem,hSourceMap);
::BitBlt(hdcMem,0,0,SourceRect.right - SourceRect.left,SourceRect.bottom -SourceRect.top,
hdcSource,0,0,SRCCOPY);
hSourceMap = (HBITMAP)SelectObject(hdcMem,hOldBM);