扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:电子科技集团公司第二十二研究所 来源:天极网 2007年10月19日
关键字:
BOOL SetLayeredWindowAttributes( HWND hwnd, // handle to the layered window COLORREF crKey, // specifies the color key BYTE bAlpha, // value for the blend function DWORD dwFlags // action ); |
#define WS_EX_LAYERED 0x00080000 |
// 全局变量 typedef BOOL (WINAPI *lpfn) (HWND hWnd, COLORREF cr, BYTE bAlpha, DWORD dwFlags); lpfn g_pSetLayeredWindowAttributes; …… // 获取函数 SetLayeredWindowAttributes 在User32.dll中的指针 HMODULE hUser32 = GetModuleHandle(_T("USER32.DLL")); g_pSetLayeredWindowAttributes = (lpfn)GetProcAddress(hUser32, "SetLayeredWindowAttributes"); if (g_pSetLayeredWindowAttributes == NULL) ::PostQuitMessage(0); …… // 半透明 HWND hWnd = GetSafeHwnd(); LONG lWindowLong = GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED; ::SetWindowLong(hWnd, GWL_EXSTYLE, lWindowLong); g_pSetLayeredWindowAttributes(hWnd, 0, (BYTE)m_sldAlpha.GetPos(), 2); ::RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。