开发者

Why could DwmRegisterThumbnail fail?

开发者 https://www.devze.com 2022-12-18 11:22 出处:网络
I am trying to capture screen of a child window and render it on parent surface in Windows 7. HTHUMBNAIL thumbnail = NULL;

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_USEDEF开发者_如何学运维AULT, 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);


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消