<pre name="code" class="cpp"> DWORD dwStyle = ::GetWindowLong(hWnd, GWL_EXSTYLE); //
dwStyle |= WS_EX_LAYERED;
::SetWindowLong(hWnd, GWL_EXSTYLE, dwStyle);
::SetLayeredWindowAttributes(hWnd, 0, 127, LWA_ALPHA);
可以在创建窗口的时候指定这个属性,但要用CreateWindowEx,这个函数才会接受窗口的扩展风格,而CreateWindow不会接受窗口的扩展风格,会是创建的窗口不是我们想要的。
other:
Note that once SetLayeredWindowAttributes has been called for a layered window, subsequent UpdateLayeredWindow calls will fail until the layering style bit is cleared and set again. For more information, see Layered Windows.