分类: C/C++
2016-08-09 13:50:54
原文地址:Visual C++小技巧:实现透明窗体 作者:帅得不敢出门
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 ); Windows NT/2000/XP: Included in Windows 2000 and later. Windows 95/98/Me: Unsupported. Header: Declared in Winuser.h; include Windows.h. Library: Use User32.lib. |
//加入WS_EX_LAYERED扩展属性 SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE, GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000); HINSTANCE hInst = LoadLibrary("User32.DLL"); if(hInst) { typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD); MYFUNC fun = NULL; //取得SetLayeredWindowAttributes函数指针 fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes"); if(fun)fun(this->GetSafeHwnd(),0,128,2); FreeLibrary(hInst); } |