我正在使用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