void CMainFrame::FullScreen()
{
m_wndRibbonBar.ShowWindow(SW_HIDE);//隐藏工具栏
m_wndStatusBar.ShowWindow(SW_HIDE);//隐藏状态栏
m_menuMainWnd = GetMenu();
//隐藏菜单栏
SetMenu(NULL);
// 保存以前的位置信息
GetWindowRect(&m_FullScreenRect);
// 去除主窗口的标题
LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
style&=~WS_CAPTION;
::SetWindowLong(m_hWnd,GWL_STYLE,style);
// 使客户区无边框
ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_FRAMECHANGED);
ModifyStyleEx(WS_EX_CLIENTEDGE, NULL);
//得到当前系统的分辨率
int screenx=GetSystemMetrics(SM_CXSCREEN);
int screeny=GetSystemMetrics(SM_CYSCREEN);
// 全屏显示
SetWindowPos(NULL,0,0,screenx,screeny,SWP_NOZORDER);
style=::GetWindowLong(this->m_hWnd,GWL_STYLE);
m_bFullScreen = TRUE;
}
//退出全屏
void CMainFrame::EndFullScreen()
{
//恢复窗口标题
LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
style|=WS_CAPTION;
::SetWindowLong(m_hWnd,GWL_STYLE,style);
//如果需要,显示工具栏
m_wndRibbonBar.ShowWindow(SW_SHOW);
//如果需要,显示状态栏
m_wndStatusBar.ShowWindow(SW_SHOW);
//恢复窗口以前的大小
MoveWindow(&m_FullScreenRect);
//恢复菜单栏
this->SetMenu(m_menuMainWnd);
m_bFullScreen = FALSE;
}
最后要在C....View::PreCreateWindow()添加:cs.style &= ~WS_BORDER;
一切OK!!!