You can do this with SetWindowLong
:
int initialStyle = GetWindowLong(this.Handle, -20);
SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20);
There are a few magic numbers in here:
-
-20
– GWL_EXSTYLERetrieves the extended window styles.
-
0x80000
– WS_EX_LAYEREDCreates a layered window.
-
0x20
– WS_EX_TRANSPARENTSpecifies that a window created with this style should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted.
There are numerous articles all over the web on how to do this, such as this one.