I have a main window with children. I need to take screenshots programmatically to crop and draw them back on my main window. The way I do this is:
HDC hDC = GetWindowDC(hWnd);
HDC memDC = CreateCompatibleDC(hDC);
HBITMAP memBM = CreateCompatibleBitmap(hDC, Width, Height);
HBITMAP OldBM = (HBITMAP)::SelectObject(memDC, memBM );
BitBlt(memDC, 0, 0, Width, Height , hDC, BEGINX, BEGINY, SRCCOPY);
int Bpp = GetDeviceCaps(hDC,BITSPIXEL);
int size = Bpp/8 * ( Width * Height );
BYTE *lpBits = new BYTE[size];
GetBitmapBits(memBM, size, lpBits);
But this doesn't capture the OpenGL section of the child windows, instead it just draws blank white in the area where OGL render is supposed to be.
Any ideas are appreciated.