16,471
社区成员
发帖
与我相关
我的任务
分享
WINDOWPLACEMENT m_OldWndPlacement;
CRect m_FullScreenRect;
BOOL m_FullScreen;
void CMainFrame::FullScreenShow()
{
GetWindowPlacement(&m_OldWndPlacement);
CRect WindowRect;
GetWindowRect(&WindowRect);
CRect ClientRect;
RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST,reposQuery,&ClientRect);
ClientToScreen(&ClientRect);
int nFullWidth=GetSystemMetrics(SM_CXSCREEN);
int nFullHeight=GetSystemMetrics(SM_CYSCREEN);
m_FullScreenRect.left=WindowRect.left-ClientRect.left-1;
m_FullScreenRect.top=WindowRect.top-ClientRect.top-1;
m_FullScreenRect.right=WindowRect.right-ClientRect.right+nFullWidth+2;
m_FullScreenRect.bottom=WindowRect.bottom-ClientRect.bottom+nFullHeight+2;
m_FullScreen=TRUE;
WINDOWPLACEMENT wndpl;
wndpl.length=sizeof(WINDOWPLACEMENT);
wndpl.flags=0;
wndpl.showCmd=SW_SHOWNORMAL;
wndpl.rcNormalPosition=m_FullScreenRect;
ShowWindow(SW_HIDE);
SetWindowPlacement(&wndpl);
}
void CMainFrame::EndFullScreen()
{
m_FullScreen=FALSE;
ShowWindow(SW_HIDE);
SetWindowPlacement(&m_OldWndPlacement);
}
void CMainFrame::OnViewFullScreen()
{
RECT rectDesktop;
WINDOWPLACEMENT wpNew;
if (!IsFullScreen())
{
// need to hide all status bars
//m_wndStatusBar.ShowWindow(SW_HIDE);
//m_wndToolBar.ShowWindow(SW_HIDE);
if(m_wndStatusBar!=NULL) delete m_wndStatusBar;
if(m_wndToolBar!=NULL) delete m_wndToolBar;
this->UpdateWindow();
// We'll need these to restore the original state.
GetWindowPlacement (&m_wpPrev);
m_wpPrev.length = sizeof m_wpPrev;
//Adjust RECT to new size of window
::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop );
::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE, GetExStyle());
// Remember this for OnGetMinMaxInfo()
m_FullScreenWindowRect = rectDesktop;
wpNew = m_wpPrev;
wpNew.showCmd = SW_SHOWNORMAL;
wpNew.rcNormalPosition = rectDesktop;
m_pwndFullScrnBar=new CToolBar;
if (!m_pwndFullScrnBar->Create(this,CBRS_SIZE_DYNAMIC|CBRS_FLOATING) ||
!m_pwndFullScrnBar->LoadToolBar(IDR_FULLSCREEN))
{
TRACE0("Failed to create toolbar\n");
return; // fail to create
}
//don't allow the toolbar to dock
m_pwndFullScrnBar->EnableDocking(0);
m_pwndFullScrnBar->SetWindowPos(0, 100,100, 0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
m_pwndFullScrnBar->SetWindowText(_T("Full Screen"));
FloatControlBar(m_pwndFullScrnBar, CPoint(100,100));
m_bFullScreen=TRUE;
}
else
{
m_pwndFullScrnBar->DestroyWindow();
delete m_pwndFullScrnBar;
m_wndToolBar=new CToolBar;
m_wndStatusBar=new CStatusBar;
if (!m_wndToolBar->Create(this) ||
!m_wndToolBar->LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return;
}
if (!m_wndStatusBar->Create(this) ||
!m_wndStatusBar->SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return ; // fail to create
}
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar->SetBarStyle(m_wndToolBar->GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar->EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(m_wndToolBar);
m_bFullScreen=FALSE;
// m_wndStatusBar->ShowWindow(SW_SHOWNORMAL);
// m_wndToolBar->ShowWindow(SW_SHOWNORMAL);
wpNew = m_wpPrev;
}
SetWindowPlacement ( &wpNew );
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if (IsFullScreen())
{
lpMMI->ptMaxSize.y = m_FullScreenWindowRect.Height();
lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;
lpMMI->ptMaxSize.x = m_FullScreenWindowRect.Width();
lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x;
}
}
BOOL CMainFrame::IsFullScreen()
{
return m_bFullScreen;
}
void CMainFrame::OnUpdateViewFullScreen(CCmdUI* pCmdUI)
{
pCmdUI->Enable();
if (IsFullScreen())
pCmdUI->SetCheck();
else
pCmdUI->SetCheck(0);
}