透明窗口

来源:互联网 发布:阿里云虚拟主机端口号 编辑:程序博客网 时间:2024/04/27 18:32
#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");
    }
}
}

原创粉丝点击