设置窗口透明样式

来源:互联网 发布:中国中小企业数据 编辑:程序博客网 时间:2024/06/06 11:04

typedef BOOL (FAR WINAPI *LAYERFUNC)(HWND,COLORREF,BYTE,DWORD);
BOOL SetLayeredWindowAttributes(HWND hwnd,COLORREF crKey,BYTE bAlpha,DWORD dwFlags)
{
    LAYERFUNC SetLayer;
    HMODULE hmod = LoadLibrary("user32.dll");
    SetLayer=(LAYERFUNC)GetProcAddress(hmod,"SetLayeredWindowAttributes");
    BOOL bReturn = SetLayer(hwnd,crKey,bAlpha,dwFlags);
    FreeLibrary(hmod);
    return bReturn;
}

//设置窗口透明
 int rtn = GetWindowLong(hWnd, -20);
 rtn = rtn | WS_EX_LAYERED;
 SetWindowLong(hWnd, -20, rtn);
 //SetLayeredWindowAttributes(hWnd,RGB(255,255,255),180,2);
 SetLayeredWindowAttributes(hWnd,RGB(255,255,255),0,1);
 

 

0 0
原创粉丝点击