1
我已經使用CPP,COM和DirectShow捕獲了總桌面。但是,我怎樣才能捕捉特定的窗口?如何捕獲特定的窗口而不是整個桌面?
我已經使用CPP,COM和DirectShow捕獲了總桌面。但是,我怎樣才能捕捉特定的窗口?如何捕獲特定的窗口而不是整個桌面?
我利用幾個助手的 - 但你需要這些應該很容易翻譯成:
// Copy the contents of the client area or the window into an HBITMAP
HBITMAP CaptureWindow(HWND hwnd, bool bIncludeFrame, const RECT * pClip)
{
// get the DC of the source
HDC hdcSource = bIncludeFrame ? ::GetWindowDC(hwnd) : ::GetDC(hwnd);
// get a memory DC
HDC hdcMemory = ::CreateCompatibleDC(hdcSource);
// get the clipping rect
RECT rcClip;
if (pClip)
rcClip = *pClip;
else if (bIncludeFrame)
::GetWindowRect(hwnd, &rcClip);
else
::GetClientRect(hwnd, &rcClip);
// determine the size of bitmap we're going to be making
SIZE sz = { rcClip.right - rcClip.left, rcClip.bottom - rcClip.top };
// create a bitmap on which to copy the image
HBITMAP hbmCapture = ::CreateCompatibleBitmap(hdcSource, sz.cx, sz.cy);
// temporarily select our bitmap into the memory DC, grab the image, then deselect it again
if (AutoSelectGDIObject & select_capture = AutoSelectGDIObject(hdcMemory, hbmCapture))
::BitBlt(hdcMemory, 0, 0, sz.cx, sz.cy, hdcSource, rcClip.left, rcClip.top, SRCCOPY);
// release our resources
::DeleteDC(hdcMemory);
::ReleaseDC(hwnd, hdcSource);
// return the captured bitmap
return hbmCapture;
}
BitBlt
只有感興趣的窗戶進入的區域的屏幕外的位圖(想捕獲完整的桌面和裁剪圖像窗口的位置)WM_PAINT
,WM_PRINTCLIENT
消息請求的窗口本身繪製到您的DC
你的意思是捕獲在屏幕截圖中? – 2010-04-16 10:28:25
不是一個屏幕截圖,但我必須捕獲一個特定的窗口,可以重新調整大小,最小化並在遠程端發佈它。當窗口最小化時,應該把什麼放在遠端? – Rupali 2010-04-16 13:20:55