我正在尝试获取不可见的窗口的缩略图。
这是我到目前为止的代码
BOOL CALLBACK WindowProc(HWND hWnd, LPARAM lParam)
{
RECT WindRect;
GetWindowRect(hWnd, &WindRect)
CurrentScreenShot->Next = new ScreenShotList();
CurrentScreenShot = CurrentScreenShot->Next;
HDC SourceDC = GetDC(hWnd);
HDC TargetDC = CreateCompatibleDC(SourceDC);
CurrentScreenShot->ScreenShot = CreateCompatibleBitmap(SourceDC, WindRect.right - WindRect.left, WindRect.bottom - WindRect.top);
BitBlt(TargetDC, 0, 0, WindRect.right - WindRect.left, WindRect.bottom - WindRect.top, SourceDC, 0, 0, SRCCOPY);
ReleaseDC(hWnd, SourceDC);
g_iWindows++;
return TRUE;
}
目前,WindowProc
直接调用FindWindow
用于获取句柄,但我最终想使用EnumWindows
循环所有窗口以获取它们的缩略图并将它们存储在链接列表中。
WindowProc(FindWindow(NULL, L"File Explorer"), 0);
此代码位于从 C# Forms 应用程序调用的 DLL 中。目前,C# 应用程序只需获取位图并将其保存到文件中。
问题是,除非我FindWindow
用来获取可见窗口(也恰好是 C# 应用程序),否则图片最终会变成一个黑盒子。
是否可以获取背景窗口的图片?
编辑:这是一个 Windows Mobile 应用程序