[英]i have a win32 windows application and want to capture full screen and remove the border of window displayed?
[英]How to exclude certain window from screen capture in Win32 API?
我想捕獲桌面並排除我的應用程序被捕獲的窗口。
我的窗口正在創建如下:
m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_LAYERED,
g_lpszClassName, NULL, WS_THICKFRAME,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL,
_WPModule.GetHInstance(), NULL);
我捕獲屏幕如下:
HWND hWndCapture = ::GetDesktopWindow();
HDC hdcScreen = ::GetDC(hWndCapture);
HDC hdcMem = ::CreateCompatibleDC(hdcScreen);
::BitBlt(
hdcMem,
0,
0,
Width, //width of region of interest
Height, //height of region of interest
hdcScreen,
X, //left staring point for capture
Y, //top staring point for capture
SRCCOPY);
我找到了以下鏈接Excluded certain windows from screen capture但它沒有為 IE 8 及更高版本提供解決方案。 我沒有找到針對此問題發布的任何其他解決方案。
我知道這個問題已經很老了,但是我遇到了同樣的問題,而且很難找到任何關於這個的信息。
自Windows 10 版本 2004 (內部版本 10.0.19041)起, SetWindowDisplayAffinity
API已擴展為包含一個名為WDA_EXCLUDEFROMCAPTURE
(0x00000011) 的標志。 這將從使用BitBlt
捕獲的圖像中刪除窗口
該窗口僅顯示在監視器上。 在其他任何地方,窗口根本不會出現。 這種親和性的一種用途是用於顯示視頻錄制控件的窗口,以便控件不包含在捕獲中。
在 Windows 10 版本 2004 中引入。請參閱有關早期版本 Windows 兼容性的備注。
對於 2004 之前的版本,它將使用現有的WDA_MONITOR
標志。
我已經通過桌面的屏幕截圖對此進行了測試,但我不確定如果您使用 Windows DC 會發生什么。
所以我想一個可能的解決方案是:
// get window handle
m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_LAYERED,
g_lpszClassName, NULL, WS_THICKFRAME,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL,
_WPModule.GetHInstance(), NULL);
BOOL result = SetWindowDisplayAffinity(m_hWnd, WDA_EXCLUDEFROMCAPTURE);
// do bitblt stuff
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.