DirectX composition issue

Azat Tazayan 6 Reputation points
2021-03-30T12:14:12.953+00:00

I'm trying to use DirectComposition on windows for drawing some visuals over Window and have following issue. Our application is multi plugin application and some of the windows already called CreateTargetForHwnd method to work with composition and now when I try to call CreateTargetForHwnd over that windows getting DCOMPOSITION_ERROR_WINDOW_ALREADY_COMPOSED exception. Is it possible to get IDCompositionTarget pointer if it is already created? I couldn't find such API.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,526 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Strive Sun-MSFT 426 Reputation points
    2021-03-31T07:09:12.483+00:00

    Hello, @Azat Tazayan

    This is an error that has been documented.

    DCOMPOSITION_ERROR_WINDOW_ALREADY_COMPOSED : The IDCompositionDevice::CreateTargetForHwnd method was called with hwnd and topmost parameters for which a visual tree already exists.

    IDCompositionDevice::CreateTargetForHwnd method also pointed out, At most, only two composition targets can be created for each window in the system, one topmost and one not topmost. If a composition target is already bound to the specified window at the specified layer, this method fails. When a composition target object is destroyed, the layer it composed is available for use by a new composition target object.

    I noticed that you posted the same question on another forum, where someone pointed out that you might not be able to do this for code that does not belong to you.

    I agree with what he said.

    ----------

    Thank you!

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments