Question

I ported a win32 control using QWinHost, and put it on a layered (semi-transparent) widget. When I set WS_EX_LAYERED flag, then paint not occurred for win32 ported control.

SetWindowLong(winId(),
           GWL_EXSTYLE,
           GetWindowLong(winId(), GWL_EXSTYLE) | *WS_EX_LAYERED*);
Was it helpful?

Solution

You need to tell Windows how to paint the layered window. MSDN says that there are two ways; you almost certainly want SetLayeredWindowAttributes since you don't want to alter the control's painting code.

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 must be a top-level window on Windows 7 below; only Windows 8 and above support layered child windows.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top