4

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*);
hassan deldar
  • 293
  • 1
  • 11
  • Welcome to Stack Overflow, unfortunately your question is not a great fit for the format of the website: it doesn't tell what you have tried so far, what research you have to done, etc. You should edit your question to make it specific to a particular problem you are experiencing. – cmannett85 Aug 09 '12 at 10:27

1 Answers1

2

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.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71