相关疑难解决方法(0)

隐藏窗口的PrintWindow和BitBlt

我的程序正在截取其他应用程序窗口的屏幕截图,以自动执行其中的某些任务。这些窗口可能会隐藏在屏幕外或不时被其他窗口遮挡。

为了减少混乱,我从代码列表中删除了所有错误检查。我正在准备两种类型的屏幕截图

// Get size of the target window.
RECT clientRect;
GetClientRect(hwnd, &clientRect);
int width = clientRect.right - clientRect.left;
int height = clientRect.bottom - clientRect.top;
// Create a memory device context.
HDC windowDC = GetDC(hwnd);
HDC memoryDC = CreateCompatibleDC(windowDC);
// Create a bitmap for rendering.
BITMAPINFO bitmapInfo;
ZeroMemory(&bitmapInfo, sizeof(BITMAPINFO));
bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bitmapInfo.bmiHeader.biWidth = width;
bitmapInfo.bmiHeader.biHeight = -height;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biBitCount = 32;
bitmapInfo.bmiHeader.biCompression = BI_RGB;
bitmapInfo.bmiHeader.biSizeImage = width * height * 4;
RGBQUAD* buffer;
HBITMAP bitmap = CreateDIBSection(windowDC, …
Run Code Online (Sandbox Code Playgroud)

c++ winapi screenshot dwm bitblt

5
推荐指数
1
解决办法
3472
查看次数

标签 统计

bitblt ×1

c++ ×1

dwm ×1

screenshot ×1

winapi ×1