Я использую несколько помощников, но их должно быть легко перевести на то, что вам нужно:
// Copy the contents of the client area or the window into an HBITMAP
HBITMAP CaptureWindow(HWND hwnd, bool bIncludeFrame, const RECT * pClip)
{
// get the DC of the source
HDC hdcSource = bIncludeFrame ? ::GetWindowDC(hwnd) : ::GetDC(hwnd);
// get a memory DC
HDC hdcMemory = ::CreateCompatibleDC(hdcSource);
// get the clipping rect
RECT rcClip;
if (pClip)
rcClip = *pClip;
else if (bIncludeFrame)
::GetWindowRect(hwnd, &rcClip);
else
::GetClientRect(hwnd, &rcClip);
// determine the size of bitmap we're going to be making
SIZE sz = { rcClip.right - rcClip.left, rcClip.bottom - rcClip.top };
// create a bitmap on which to copy the image
HBITMAP hbmCapture = ::CreateCompatibleBitmap(hdcSource, sz.cx, sz.cy);
// temporarily select our bitmap into the memory DC, grab the image, then deselect it again
if (AutoSelectGDIObject & select_capture = AutoSelectGDIObject(hdcMemory, hbmCapture))
::BitBlt(hdcMemory, 0, 0, sz.cx, sz.cy, hdcSource, rcClip.left, rcClip.top, SRCCOPY);
// release our resources
::DeleteDC(hdcMemory);
::ReleaseDC(hwnd, hdcSource);
// return the captured bitmap
return hbmCapture;
}