VC++ 实现整个对话框透明的效果SetLayeredWindowAttributes

来源:互联网 发布:黑龙江电视台网络直播 编辑:程序博客网 时间:2024/05/22 11:29

SetLayeredWindowAttributes函数需要WINDOWS2000以上的系统才能支持,包含在新的SDK中。

 

使用方法:在对话框的OnInitDialog()加入:

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); //128为半透明,0为完全透明
FreeLibrary(hInst); 
}

原创粉丝点击