|
|
@ -347,19 +347,22 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) { |
|
|
|
int width = GetDeviceCaps(hdcScreen, HORZRES); |
|
|
|
int height = GetDeviceCaps(hdcScreen, VERTRES); |
|
|
|
|
|
|
|
HBITMAP hBmp = CreateCompatibleBitmap(hdcScreen, width, height); |
|
|
|
|
|
|
|
// Select the compatible bitmap into the compatible memory DC.
|
|
|
|
SelectObject(hdcMemDC,hbmScreen); |
|
|
|
SelectObject(hdcMemDC,hBmp); |
|
|
|
|
|
|
|
// Bit block transfer into our compatible memory DC.
|
|
|
|
if(!BitBlt(hdcMemDC, |
|
|
|
0,0, |
|
|
|
rcClient.right-rcClient.left, rcClient.bottom-rcClient.top, |
|
|
|
hdcWindow, |
|
|
|
width, height, |
|
|
|
hdcScreen, |
|
|
|
0,0, |
|
|
|
SRCCOPY)) |
|
|
|
{ |
|
|
|
MessageBox(hWnd, L"BitBlt has failed", L"Failed", MB_OK); |
|
|
|
DeleteObject(hbmScreen); |
|
|
|
DeleteObject(hBmp); |
|
|
|
DeleteObject(hdcMemDC); |
|
|
|
ReleaseDC(NULL,hdcScreen); |
|
|
|
ReleaseDC(hWnd,hdcWindow); |
|
|
@ -367,7 +370,7 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) { |
|
|
|
} |
|
|
|
|
|
|
|
// Get the BITMAP from the HBITMAP
|
|
|
|
GetObject(hbmScreen,sizeof(BITMAP),&bmpScreen); |
|
|
|
GetObject(hBmp,sizeof(BITMAP),&bmpScreen); |
|
|
|
|
|
|
|
BITMAPFILEHEADER bmfHeader; |
|
|
|
BITMAPINFOHEADER bi; |
|
|
@ -394,7 +397,7 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) { |
|
|
|
|
|
|
|
// Gets the "bits" from the bitmap and copies them into a buffer
|
|
|
|
// which is pointed to by lpbitmap.
|
|
|
|
GetDIBits(hdcWindow, hbmScreen, 0, |
|
|
|
GetDIBits(hdcScreen, hBmp, 0, |
|
|
|
(UINT)bmpScreen.bmHeight, |
|
|
|
lpbitmap, |
|
|
|
(BITMAPINFO *)&bi, DIB_RGB_COLORS); |
|
|
@ -433,6 +436,7 @@ int CaptureImage(HWND hWnd, const wchar_t* filename) { |
|
|
|
|
|
|
|
// clean up
|
|
|
|
DeleteObject(hbmScreen); |
|
|
|
DeleteObject(hBmp); |
|
|
|
DeleteObject(hdcMemDC); |
|
|
|
ReleaseDC(NULL,hdcScreen); |
|
|
|
ReleaseDC(hWnd,hdcWindow); |
|
|
|