//ModifyStyleEx(0, WS_EX_LAYERED|WS_EX_TRANSPARENT); //窗口透明并且不接受鼠标消息
ModifyStyleEx(0, WS_EX_LAYERED); //窗口透明但接受鼠标消息
SetLayeredWindowAttributes(0, 128, 2); //第二个参数表示透明度
//SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
以下信息来自MSDN
CWnd::SetLayeredWindowAttributes | ![]() |
Sets the opacity and transparency color key of a layered window.
BOOL SetLayeredWindowAttributes( COLORREF crKey, BYTE bAlpha, DWORD dwFlags );
BOOL SetLayeredWindowAttributes( COLORREF crKey, BYTE bAlpha, DWORD dwFlags );
Parameters
Return Value
Nonzero if the function succeeds; otherwise 0.
Remarks
This member function emulates the functionality of the function SetLayeredWindowAttributes, as described in the Windows SDK.