为什么 DwmRegisterThumbnail 会失败?

发布于 2024-08-19 05:26:08 字数 822 浏览 2 评论 0原文

我试图捕获子窗口的屏幕并将其渲染在 Windows 7 的父表面上。

HTHUMBNAIL thumbnail = NULL;
HRESULT hr = S_OK;
hr = DwmRegisterThumbnail( hWnd, visualHwnd, &thumbnail );

if( SUCCEEDED( hr ) )
{
    ...
}

这总是失败。 VisualHwnd 是子窗口,hWnd 是父窗口。我也在没有父子关系的情况下尝试过,它只是没有绘制任何内容,这是预料之中的,因为 if 语句失败。

可能是什么原因?

这是我创建父级:

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

和子级的方法:

CreateProcessA( NULL, "PVFOX.exe \"view3.pv\" ", NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &piVisual);
WaitForInputIdle( piVisual.hProcess, INFINITE );
Sleep( 3000 );

EnumWindows(EnumWindowsProc, 0);
SetParent(visualHwnd, hWnd);

I am trying to capture screen of a child window and render it on parent surface in Windows 7.

HTHUMBNAIL thumbnail = NULL;
HRESULT hr = S_OK;
hr = DwmRegisterThumbnail( hWnd, visualHwnd, &thumbnail );

if( SUCCEEDED( hr ) )
{
    ...
}

This fails all the time. visualHwnd is the child window and hWnd is the parent. I also tried it without the parent-child relationship and it just doesn't draw anything, well expected because if statement fails.

What could be the reason?

Here is how I create the parent:

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

And the child:

CreateProcessA( NULL, "PVFOX.exe \"view3.pv\" ", NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &piVisual);
WaitForInputIdle( piVisual.hProcess, INFINITE );
Sleep( 3000 );

EnumWindows(EnumWindowsProc, 0);
SetParent(visualHwnd, hWnd);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

予囚 2024-08-26 05:26:08

来自 MSDN:

  • hwndDestination

    将使用 DWM 缩略图的窗口句柄。将目标窗口句柄设置为除顶级窗口类型之外的任何内容都将导致 E_INVALIDARG。

  • hwnd源

    作为缩略图源的窗口句柄。将源窗口句柄设置为除顶级窗口类型之外的任何内容都将导致 E_INVALIDARG。

如果您传递子窗口,则预计会失败。

From MSDN:

  • hwndDestination

    The handle to the window that will use the DWM thumbnail. Setting the destination window handles to anything other than a top level window type will result in an E_INVALIDARG.

  • hwndSource

    The handle to the window to as the thumbnail source. Setting the source window handles to anything other than a top level window type will result in an E_INVALIDARG.

This is expected to fail if you pass a child window.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文