897uiaua8
897uiaua8

Reputation: 23

WS_EX_LAYERED with SetParent() doesn't show the window

I have this one problem I just can't solve. I'm trying to make a window from my application that is transparent (using flags WS_EX_TRANSPARENT | WS_EX_LAYERED) a child to another window, which is not transparent.

When I don't use the call SetParent( my_window, target_parent_window ) with my_window having the WS_EX_LAYERED flag, the new child window won't be visible.

I found out that a manifest entry could help me, since having a child window with flag WS_EX_LAYERED is supported since Windows 8. I tried it without any success.

::SetWindowLongW( process_window, GWL_STYLE, WS_CLIPSIBLINGS | WS_POPUP | WS_VISIBLE );
::SetWindowLongW( process_window, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW );

::SetWindowPos( process_window, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
::ShowWindow( process_window, SW_SHOW );

::SetParent( process_window, new_parent_window); // if i skip this call the window will render perfectly

Upvotes: 2

Views: 817

Answers (1)

Jack Longbow
Jack Longbow

Reputation: 38

https://learn.microsoft.com/en-us/windows/win32/winmsg/window-features

To create a layered window, specify the WS_EX_LAYERED extended window style when calling the CreateWindowEx function, or call the SetWindowLong function to set WS_EX_LAYERED after the window has been created. After the CreateWindowEx call, the layered window will not become visible until the SetLayeredWindowAttributes or UpdateLayeredWindow function has been called for this window.

Upvotes: 2

Related Questions