I am taking screenshots of IE using PrintWindow. The problem is that several times I get images with black areas. It can be whole html content that is black, sometimes only some areas are black.
IE content does not change between shots.
What is strange is that on some computers I get a lot of black images, on some I never get them.
I tested Fx and had the same black images.
HBITMAP ShootWindow(HWND hWnd) { RECT rect = {0}; GetWindowRect(hWnd, & rect); HDC hDC = GetDC(hWnd); if(hDC == NULL) throw "GetDC failed."; HDC hTargetDC = CreateCompatibleDC(hDC); if(hTargetDC == NULL) throw "CreateCompatibleDC failed."; HBITMAP hBitmap = CreateCompatibleBitmap(hDC, rect.right - rect.left, rect.bottom - rect.top); if(hBitmap == NULL) throw "CreateCompatibleBitmap failed."; if(!SelectObject(hTargetDC, hBitmap)) throw "SelectObject failed."; if(!PrintWindow(hWnd, hTargetDC, 0)) throw "PrintWindow failed."; ReleaseDC(hWnd, hDC); ReleaseDC(hWnd, hTargetDC); return hBitmap; }
I found some links, but they do not give an answer:
http://www.vbforums.com/showthread.php?t=555250 http://www.codeguru.com/forum/archive/index.php/t-357211.html http://social.msdn.microsoft. com / forums / en-US / winforms / thread / 3e3decd8-ced1-4f17-a745-466e5aa91391 /
, . BitBlt , PrintWindow.
WINDOWINFO wi; GetWindowInfo(hWnd, &wi); BitBlt(hdc, 0, 0, rect.right - rect.left, rect.bottom - rect.top, hDC, wi.rcClient.left, wi.rcClient.top, SRCCOPY);
, PrintWindow WM_PRINT.