Code Snippet
1. Get screen DC
HDC hdcScreen = GetDC(NULL);
2. Get Window (being captured) bounds
RECT rcWindow;
GetWindowRect(hwnd);
3. Allocated a DC and a bitmap:
HDC hdcMem = CreateCompatibleDC(hdcScreen);
HBITMAP hbmCapture = CreateCompatibleBitmap(hdcScreen, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top);
HGDIOBJ hbm = SelectObject(hdcMem, hbmCapture);
4. Blit a block to the memory DC
BitBlt(hdcMem, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, hdcScreen, rcWindow.left, rcWindow.top, SRCCOPY);