In a Win32 App, can I make a hardware accelerated transparent child window?

Russell McClellan 0 Reputation points
2023-03-27T17:11:16.51+00:00

I have a Win32 app where I have a child window that needs a transparent background, such that it draws over the content of the parent window. If I use WS_EX_LAYERED, I can achieve the effect I need. Is there a way to accomplish the same thing, but with hardware accelerated drawing? Ideally I'm looking for an OpenGL solution but a Direct3D solution would also be acceptable. I've tried following some examples online that use DwmExtendFrameIntoClientArea, but these seem to only work for top-level windows, not child windows. Thanks

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
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 81,721 Reputation points
    2023-03-27T19:56:53.82+00:00

    You can draw with Direct2D as explained at How to render by using a Direct2D device context

    with CreateSwapChainForHwnd and the layered child window handle (I generally do this with WinUI 3 in C# because of a resizing bug in SwapChainPanel control...)