VC++ 实现全屏

实现全屏的函数如下,作为主框架窗口的成员函数,调用即可。

void CMainFrame::FullScan()
{
static bool isfull=true;
static CRect m_OldWndRect;
static CMenu m_OrgMenu;
if(isfull==true)
{
GetWindowRect(&m_OldWndRect);//得到原窗口位置
//隐藏工具栏和状态栏
if(m_wndToolBar.IsWindowVisible())
{
m_wndToolBar.ShowWindow(SW_HIDE);
}
if(m_wndStatusBar.IsWindowVisible())
{
m_wndStatusBar.ShowWindow(SW_HIDE);
}
//隐藏菜单栏
CMenu* pOldMenu=GetMenu();
m_OrgMenu.Attach(pOldMenu->Detach());
SetMenu((CMenu*)NULL);
//隐藏标题栏
LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
style&=~WS_CAPTION;
::SetWindowLong(m_hWnd,GWL_STYLE,style);
//窗体最前
::SetWindowPos(AfxGetMainWnd()->m_hWnd,HWND_TOPMOST,-1,-1,-1,-1,SWP_NOMOVE|SWP_NOSIZE);
//全屏
ShowWindow(SW_SHOWMAXIMIZED);
RecalcLayout();//重绘框架
isfull=false;
}
else
{
//显示工具栏和状态栏
m_wndToolBar.ShowWindow(SW_SHOW);
m_wndStatusBar.ShowWindow(SW_SHOW);
//显示菜单栏
SetMenu(&m_OrgMenu);
m_OrgMenu.Detach();
//显示标题栏
LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
style|=WS_CAPTION;
::SetWindowLong(m_hWnd,GWL_STYLE,style);
//取消窗体最前
::SetWindowPos(AfxGetMainWnd()->m_hWnd,HWND_NOTOPMOST,m_OldWndRect.left,m_OldWndRect.top,m_OldWndRect.right-m_OldWndRect.left,m_OldWndRect.bottom-m_OldWndRect.top,SWP_SHOWWINDOW);
//恢复
ShowWindow(SW_SHOWNOACTIVATE);
MoveWindow(m_OldWndRect);
RecalcLayout();//重绘框架
isfull=true;
}
return;
}

你可能感兴趣的:(vc++)