【发布时间】:2015-01-02 11:53:44
【问题描述】:
我正在使用下面的代码来捕获使用 bltblt 的窗口的屏幕截图。然而,标题栏在捕获的屏幕截图中显示为完全黑色。我在 Windows 8.1 上运行代码。有没有办法可以正确捕获标题栏。
// Retrieve the handle to a display device context for the sourceWindow
hdcScreen = GetDC(ss);
// Retrieve the handle to a display device context for the dest window
hdcWindow = GetDC(hWnd);
//Get the client area for size calculation
RECT rcClient;
GetWindowRect(ss, &rcClient);
if (!BitBlt(hdcWindow,
0, 0,
rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
hdcScreen,
0, 0,
SRCCOPY|CAPTUREBLT))
{
MessageBox(hWnd, L"BitBlt has failed", L"Failed", MB_OK);
goto done;
}
编辑: 我在其中显示屏幕截图的窗口将覆盖整个桌面,并将不断更新其后面窗口的屏幕截图。此外,显示屏幕截图的窗口将始终是最顶部的窗口。
【问题讨论】:
-
我检查了它..不幸的是,这对我不起作用,因为我显示屏幕截图的窗口会覆盖整个屏幕,所以我无法捕获整个桌面并将其裁剪以包含我的窗口想要在我的截图中。
-
也许可以看看DWM thumbnails。
-
我还需要像素数据。
DWMthumbnail 无法做到这一点。 -
为什么不直接捕获客户区,并将其放入您自己的标准最大化窗口中,并使用相同的标题栏文本?您需要额外的工作来处理最小化等问题,但效果(可能)是相同的。
标签: winapi visual-c++ gdi+ gdi