windows應用程序中有很多的播放器都有快捷鍵控制窗口以全屏幕的方式顯示。MFC實現給應用程序加上全屏幕的功能,并不需要很多的代碼,比如給一個基于對話框的應用程序加上全屏功能只需要以下少量代碼就可以實現了。
實現代碼如下所示:
void CFullScreenDlg::FullScreenView(void){RECT rectDesktop;WINDOWPLACEMENT wpNew;if (!IsFullScreen()){// We'll need these to restore the original state.GetWindowPlacement (&m_wpPrev);//Adjust RECT to new size of window::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop );::AdjustWindowRectEx(&rectDesktop, GetStyle(), FALSE, GetExStyle());// Remember this for OnGetMinMaxInfo()m_rcFullScreenRect = rectDesktop;wpNew = m_wpPrev;wpNew.showCmd = SW_SHOWNORMAL;wpNew.rcNormalPosition = rectDesktop;m_bFullScreen=true;}else{// 退出全屏幕時恢復到原來的窗口狀態m_bFullScreen=false;wpNew = m_wpPrev;}SetWindowPlacement ( &wpNew );}void CFullScreenDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI){// TODO: Add your message handler code here and/or call defaultif (IsFullScreen()){lpMMI->ptMaxSize.y = m_rcFullScreenRect.Height();lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;lpMMI->ptMaxSize.x = m_rcFullScreenRect.Width();lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x;}CDialog::OnGetMinMaxInfo(lpMMI);}bool CFullScreenDlg::IsFullScreen(void){// 記錄窗口當前是否處于全屏狀態return m_bFullScreen;}
新聞熱點
疑難解答
圖片精選