您的位置:首页 > 其它

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

2011-10-24 14:59 483 查看
因为一种特别的需要 做了一个小程序主要三个功能



设置窗体透明



view plaincopy to clipboardprint?

void CSetDlg::SetTransparent()
{
::SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);//TopMost


SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);

HINSTANCE hModule=LoadLibrary("User32.DLL");
if(hModule==NULL)
{
return;
}

typedef BOOL (WINAPI *FN_SetColor)(HWND,COLORREF,BYTE,DWORD);

FN_SetColor SetColor = NULL;

SetColor=(FN_SetColor)GetProcAddress(hModule,"SetLayeredWindowAttributes");

if (SetColor==NULL)
{
return;
FreeLibrary(hModule);
}

SetColor(this->GetSafeHwnd(),0,50,2);

FreeLibrary(hModule);
}

view plaincopy to clipboardprint?

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

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






隐藏任务栏



view plaincopy to clipboardprint?

void CSetDlg::SetTaskBarHide()
{
::SetWindowLong(GetSafeHwnd(),GWL_EXSTYLE, WS_EX_TOOLWINDOW);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: