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.