VC下實現窗體透明效果(clarity for CDialog)

VC下實現窗體透明效果,我只測試了CStatic是不可以實現這個效果的,應該是隻有CWnd子類纔可以實現這個效果,如果想使用空間透明化,只能把他放窗體上了....
20%透明效果如下圖:
20%透明窗體演示
href="http://www.j2megame.org/wupei/plugins/plogeshi/styles/plogeshi.css" type="text/css" rel="stylesheet" />
具體代碼實現:
  1. //參數說明:透明度(範圍是0-255)
  2. void CSizeDlg::SetWindowAttributes(int Attributes)
  3. {
  4.         //////////////////////////////////////////////////////////////////////////
  5.         //透明實現
  6.         SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,
  7.                 GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);
  8.         HINSTANCE hInst = LoadLibrary("User32.DLL");
  9.         if(hInst)
  10.         {
  11.                 typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD);
  12.                 MYFUNC fun = NULL;
  13.  
  14.                 //取得SetLayeredWindowAttributes函數指針    
  15.                 fun=(MYFUNC)GetProcAddress(hInst,"SetLayeredWindowAttributes");  
  16.                 if(fun)fun(this->GetSafeHwnd(),0,Attributes,2);
  17.                 FreeLibrary(hInst);
  18.         }
  19.         //////////////////////////////////////////////////////////////////////////
  20. }

這個函數在Vista下,使用也可實現透明效果

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章