分类: C/C++
2008-08-07 17:35:05
主要代码举例:
void CMainFrame::OnViewFullScreen() { RECT rectDesktop; WINDOWPLACEMENT wpNew; if (!IsFullScreen()) { // 需要所有状态栏 m_wndStatusBar.ShowWindow(SW_HIDE); m_wndToolBar.ShowWindow(SW_HIDE); // 还需要恢复原状 GetWindowPlacement (&m_wpPrev); m_wpPrev.length = sizeof m_wpPrev; //通过调节RECT 来确定新窗口的大小 ::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop ); ::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE, GetExStyle()); // 把参数用于 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; //创建失败 } //不允许工具栏停靠 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_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); }(全文完) 下载本文示例代码