#define WS_EX_LAYERED 0x00080000
#define LWA_COLORKEY 0x00000001
#define LWA_ALPHA 0x00000002
typedef BOOL (*_SetLayeredWindowAttributes)(HWND,COLORREF,BYTE,Dword);
_SetLayeredWindowAttributes SetLayeredWindowAttributes;
void SetLayered(HWND hWnd,int Pos)
{
SetLayeredWindowAttributes = (_SetLayeredWindowAttributes)GetProcAddress(GetModuleHandle("user32.dll"),"SetLayeredWindowAttributes");
if ( SetLayeredWindowAttributes == NULL )
return ;
else{
__try{
SetWindowLong(hWnd,GWL_EXSTYLE,GetWindowLong(hWnd,GWL_EXSTYLE)|WS_EX_LAYERED);
SetLayeredWindowAttributes(hWnd,RGB(0,0,0),Pos,LWA_ALPHA);
}
__except(EXCEPTION_EXECUTE_HANDLER){
AfxMessageBox("SYSTEM FALSE");
}
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-988135/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10752043/viewspace-988135/
本文介绍了一种使用 SetLayeredWindowAttributes 函数实现窗口透明的方法。通过设置窗口样式和透明度属性,可以使得应用程序窗口呈现出半透明的效果。这种方法适用于 Windows 平台上的应用程序开发。
1044

被折叠的 条评论
为什么被折叠?



