VC下实现窗体透明效果,我只测试了CStatic是不可以实现这个效果的,应该是只有CWnd子类才可以实现这个效果,如果想使用空间透明化,只能把他放窗体上了....
20%透明效果如下图:
href="http://www.j2megame.org/wupei/plugins/plogeshi/styles/plogeshi.css" type="text/css" rel="stylesheet" />
具体代码实现:
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下,使用也可实现透明效果