我正在使用PrintWindow做IE的截图。问题是有时候我得到黑色区域的图像。它可能是一个完整的html内容,有时只有某些区域是黑色的。使用PrintWindow制作截图时的黑色图片
IE拍摄的内容不会改变。
奇怪的是,在某些电脑上,我得到了非常后台的黑色图像,有些我从来没有得到它们。
我用Fx测试过,并且有相同的黑色图像。
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;
}
我已经发现了一些联系,但他们没有给出答案:
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/
页面上的黑色区域与SWF/Flash之间是否存在关联? – Mark 2009-08-14 20:03:20
不,我用简单的www.google.com获得了黑洞。 – alex2k8 2009-08-14 21:38:33
我在Windows 2008上看到了这个问题。虽然XP,Vista和Windows 7似乎没有问题。 – alex2k8 2009-08-15 09:06:34