The win32 controls (QWinHost) are not colored in a layered (i.e. translucent) widget (WS_EX_LAYERED)

I ported the win32 control using QWinHost and placed it in a layered (translucent) widget. When I set the WS_EX_LAYERED flag, then drawing does not occur to control porting over win32.

SetWindowLong(winId(), GWL_EXSTYLE, GetWindowLong(winId(), GWL_EXSTYLE) | *WS_EX_LAYERED*); 
+4
source share
1 answer

You need to tell Windows how to draw a layered window. MSDN says there are two ways; you almost certainly want SetLayeredWindowAttributes , since you do not want to change the code for the control painting.

So after

 SetWindowLong(winId(), GWL_EXSTYLE, GetWindowLong(winId(), GWL_EXSTYLE) | WS_EX_LAYERED); 

add

 SetLayeredWindowAttributes(winId(), RGB(0,0,0), bAlpha, LWA_ALPHA); 

(Adjusted, of course, for your needs).

Note that the layered window should be the top window in Windows 7 below; only Windows 8 and above support multi-level child windows.

+2
source

All Articles