SetLayeredWindowAttributes未定义的解决方案
1 对于未定义的风格进行自定义
#define WS_EX_LAYERED 0x00080000
#define LWA_COLORKEY 0x00000001
2 动态链接函数
typedef
BOOL
(WINAPI *PFN_SETLAYEREDWINDOWATTRIBUTES)(
HWND hwnd,
COLORREF crKey,
BYTE bAlpha,
DWORD dwFlags);
PFN_SETLAYEREDWINDOWATTRIBUTES SetLayeredWindowAttributes = NULL;
HMODULE m_hUser32 = LoadLibrary(_T("User32.dll"));
SetLayeredWindowAttributes = (PFN_SETLAYEREDWINDOWATTRIBUTES)GetProcAddress(m_hUser32, "SetLayeredWindowAttributes");
如果想通过SetLayeredWindowAttributes函数来设置窗口的透明度,那么还要求窗口具有WS_EX_LAYERED的属性
// 设置分层扩展标记
#define WS_EX_LAYERED 0x00080000
SetWindowLong( m_hWnd, GWL_EXSTYLE, GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE) | WS_EX_LAYERED);
然后就可以设置窗口的透明度了!