vc mfc实现dialog半透明置顶效果
通过修改GWL_EXSTYLE和GWL_STYLE实现半透明
通过修改GWL_EXSTYLE和GWL_STYLE实现半透明
SetWindowPos设置对话框置顶
LONG i1 = ::GetWindowLong(this->m_hWnd, GWL_EXSTYLE);
LONG i2 = ::GetWindowLong(this->m_hWnd, GWL_STYLE);
i1 |= WS_EX_LAYERED;
i1 |= WS_EX_TOPMOST;
SetWindowLong(this->m_hWnd, GWL_EXSTYLE, i1);
SetWindowLong(this->m_hWnd, GWL_STYLE, i2);
::SetWindowPos(this->m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
::SetLayeredWindowAttributes(this->m_hWnd, 0, 200, LWA_ALPHA);
示例代码下载