20%透明效果如下圖:
href="http://www.j2megame.org/wupei/plugins/plogeshi/styles/plogeshi.css" type="text/css" rel="stylesheet" />
具體代碼實現:
-
//參數說明:透明度(範圍是0-255)
-
void CSizeDlg::SetWindowAttributes(int Attributes)
-
{
-
//////////////////////////////////////////////////////////////////////////
-
//透明實現
-
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,Attributes,2);
-
FreeLibrary(hInst);
-
}
-
//////////////////////////////////////////////////////////////////////////
-
}
這個函數在Vista下,使用也可實現透明效果