I'd like to create a Direct2D application that has a transparent background on which a few opaque complex controls are placed. The problem can be broken into several sub-problems:
Architecture: Should the controls be implemented as child windows? I think that this is the correct approach, rather that creating Direct2D polygons that implement a child-window functionality.
I tried to implement this by initializing the parent window:
SetWindowLong(m_hwnd, GWL_EXSTYLE, GetWindowLong(m_hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(m_hwnd, 0, (255 * 50) / 100, LWA_ALPHA);
And create the child window as WS_CHILD. This resulted in a child on which all D2D drowings including background are transparent. I could not find a way to make the child opaque. When I create the child window as WS_POPUP or WS_OVERLAPPED the opacity problem is solved but the child window is located on the desktop unrelated to the parent.
Layered Window? I chose to work with Layered Windows but since I target at VistaSP2 and higher there might be better solutions. I tried the solution offered here but I too failed to implement it.