From: https://www.gamedev.net/forums/topic/22 ... tx-window/
Code: Select all
Allright, i got it to work finally (working with GDI functions btw):
otherwindow = myClass.Getotherwindowhwnd();
myDC = GetDC (otherwindow);
memDC = CreateCompatibleDC (myDC);
myBitmap = CreateCompatibleBitmap (myDC, 800, 600);
SelectObject (memDC, myBitmap);
rc = BitBlt (memDC, 0, 0, 800, 600, myDC, 0, 0, SRCCOPY);
b = (char*) malloc (800*600*4);
for (int i=0;i < 256; i++) b = i;
BITMAPINFO* myInfo;
myInfo = (BITMAPINFO*) malloc (sizeof (BITMAPINFO) + sizeof(RGBQUAD)*800+600);
myInfo->bmiHeader.biBitCount = 32;
myInfo->bmiHeader.biClrImportant = 0;
myInfo->bmiHeader.biClrUsed = 0;
myInfo->bmiHeader.biCompression = BI_RGB;
myInfo->bmiHeader.biHeight = 600;
myInfo->bmiHeader.biPlanes = 1;
myInfo->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
myInfo->bmiHeader.biSizeImage = 800*600*4;
myInfo->bmiHeader.biWidth = 800;
myInfo->bmiHeader.biXPelsPerMeter = 1;
myInfo->bmiHeader.biYPelsPerMeter = 1;
GetDIBits (memDC, myBitmap, 0, 600, b, myInfo, DIB_RGB_COLORS);
free (myInfo);
//free (b);
Now i have the screen shot in b[..] and can save it to disk. Thx for all replies anyway!!