ID2D1HwndRenderTarget always having black background instead of transparent

老子叫甜甜 提交于 2019-12-01 17:27:25

I don't think it's possible with directX. However GDI does work.

Take a look at the source here to see how it's done: http://pastebin.com/NJf8wi2V

In the source you can see that there is an option to attempt to use directx/opengl. However as you can see from running they do not work.

Oleh Nechytailo

Here how it's achievable using DirectComposition API

Russian: http://www.oszone.net/25395/

English: https://msdn.microsoft.com/magazine/dn745861.aspx

Basically what author does is

  1. Sets WS_EX_NOREDIRECTIONBITMAP extended style to remove redirection bitmap of DWM. Content of window is now empty.

  2. Creates DirectComposition device

  3. Creates Composition SwapChain (and not hwnd swapchain)

  4. Places one visual with SwapChain as content as root visual.

  5. Renders into SwapChain using Direct2D API.

It also works well with WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_TOPMOST for creating event-transparent overlays.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!