MFC完成全屏功效代碼實例。本站提示廣大學習愛好者:(MFC完成全屏功效代碼實例)文章只能為提供參考,不一定能成為您想要的結果。以下是MFC完成全屏功效代碼實例正文
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 default if (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; }