void CMainFrame::FullScreenModeOn()
{
// available only if there is an active doc
CMDIChildWnd* pChild=MDIGetActive();
if(!pChild) return;
m_bToolBarWasVisible=(m_wndToolBar.IsWindowVisible()!=0);
m_wndToolBar.ShowWindow(SW_HIDE);
m_bStatusBarWasVisible=(m_wndStatusBar.IsWindowVisible()!=0);
m_wndStatusBar.ShowWindow(SW_HIDE);
// first create the new toolbar
// this will contain the full-screen off button
m_pwndFullScreenBar=new CToolBar;
m_pwndFullScreenBar->Create(this);
m_pwndFullScreenBar->LoadToolBar(IDR_FULLSCREEN);
m_pwndFullScreenBar->SetBarStyle(m_pwndFullScreenBar->GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// to look better:
m_pwndFullScreenBar->ModifyStyle(0, TBSTYLE_FLAT);
m_pwndFullScreenBar->EnableDocking(0);
// place the full-screen off button somewhere:
CPoint pt(300,200);
FloatControlBar(m_pwndFullScreenBar,pt);
// now save the old positions of the main and child windows
GetWindowRect(&m_mainRect);
// remove the caption of the mainWnd:
LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
style&=~WS_CAPTION;
::SetWindowLong(m_hWnd,GWL_STYLE,style);
int screenx=GetSystemMetrics(SM_CXSCREEN);
int screeny=GetSystemMetrics(SM_CYSCREEN);
// resize:
SetWindowPos(NULL,-4,-4,screenx+8,screeny+8,SWP_NOZORDER);
style=::GetWindowLong(pChild->m_hWnd,GWL_STYLE);
m_bChildMax=(style & WS_MAXIMIZE)?true:false;
// note here: m_bMainMax is not needed since m_hWnd only
// changed its caption...
// and maximize the child window
// it will remove its caption, too.
pChild->ShowWindow(SW_SHOWMAXIMIZED);
RecalcLayout();
m_bFullScreenMode=true;
}
void CMainFrame::FullScreenModeOff()
{
// You can use SaveBarState() in OnClose(),
// so remove the newly added toolbar entirely
// in order SaveBarState() not
// to save its state. That is why I used dynamic
// allocation
delete m_pwndFullScreenBar;
LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
style|=WS_CAPTION;
::SetWindowLong(m_hWnd,GWL_STYLE,style);
if(m_bToolBarWasVisible)
m_wndToolBar.ShowWindow(SW_SHOW);
if(m_bStatusBarWasVisible)
m_wndStatusBar.ShowWindow(SW_SHOW);
MoveWindow(&m_mainRect);
RecalcLayout();
CMDIChildWnd* pChild=MDIGetActive();
// pchild can be NULL if the USER closed all the
// childs during Full Screen Mode:
if(pChild){
if(m_bChildMax)
MDIMaximize(pChild);
else MDIRestore(pChild);
}
m_bFullScreenMode=false;
}