现在的位置: 首页 > 综合 > 正文

设置窗体透明 隐藏任务栏 与全屏显示 .

2014年01月15日 ⁄ 综合 ⁄ 共 2299字 ⁄ 字号 评论关闭

 

因为一种特别的需要 做了一个小程序主要三个功能

 

设置窗体透明

 

  1. void CSetDlg::SetTransparent()  
  2. {  
  3.     ::SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);//TopMost
      
  4.       
  5.     SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);  
  6.       
  7.     HINSTANCE hModule=LoadLibrary("User32.DLL");   
  8.     if(hModule==NULL)   
  9.     {  
  10.         return;  
  11.     }  
  12.       
  13.     typedef BOOL (WINAPI *FN_SetColor)(HWND,COLORREF,BYTE,DWORD);  
  14.       
  15.     FN_SetColor SetColor = NULL;  
  16.       
  17.     SetColor=(FN_SetColor)GetProcAddress(hModule,"SetLayeredWindowAttributes");  
  18.       
  19.     if (SetColor==NULL)  
  20.     {  
  21.         return;  
  22.         FreeLibrary(hModule);   
  23.     }  
  24.       
  25.     SetColor(this->GetSafeHwnd(),0,50,2);  
  26.       
  27.     FreeLibrary(hModule);   
  28. }  

 

全屏幕显示窗体

 

 

  1. void CSetDlg::SetFullScreen()  
  2. {  
  3.     LONG style = ::GetWindowLong(this->m_hWnd,GWL_STYLE);  
  4.     style &= ~(WS_DLGFRAME | WS_THICKFRAME);  
  5.     SetWindowLong(this->m_hWnd,GWL_STYLE, style);  
  6.     this->ShowWindow(SW_SHOWMAXIMIZED);  
  7.     CRect rect;  
  8.     this->GetWindowRect(&rect);  
  9.     ::SetWindowPos(this->m_hWnd,HWND_NOTOPMOST,rect.left-1, rect.top-1, rect.right-rect.left + 3, rect.bottom-rect.top + 3, SWP_FRAMECHANGED);  
  10. }  

 

 

隐藏任务栏

 

  1. void CSetDlg::SetTaskBarHide()  
  2. {  
  3.     ::SetWindowLong(GetSafeHwnd(),GWL_EXSTYLE, WS_EX_TOOLWINDOW);    
  4. }  

抱歉!评论已关闭.