메인 프레임 헤더...
BOOL m_IsFullScreen; WINDOWPLACEMENT m_wpPrev; void SetFullScreen();
메인 프레임 소스...
void CMainFrame::SetFullScreen() { WINDOWPLACEMENT wpNew; CRect rectDesktop;
if (!m_IsFullScreen) { // 툴바와 상태바를 감춘다. m_wndStatusBar.ShowWindow(SW_HIDE); m_wndToolBar.ShowWindow(SW_HIDE);
// 현재 윈도우의 위치를 얻어온다. GetWindowPlacement (&m_wpPrev); m_wpPrev.length = sizeof m_wpPrev;
::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop ); ::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE, GetExStyle());
wpNew = m_wpPrev; wpNew.showCmd = SW_SHOWNORMAL; wpNew.rcNormalPosition = rectDesktop; m_IsFullScreen=TRUE; } else { m_IsFullScreen=FALSE; // 툴바와 상태바를 보여준다. m_wndStatusBar.ShowWindow(SW_SHOWNORMAL); m_wndToolBar.ShowWindow(SW_SHOWNORMAL); wpNew = m_wpPrev; }
SetWindowPlacement ( &wpNew ); }
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { CRect rectDesktop; ::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop ); ::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE, GetExStyle()); // 윈도우의 최대 사이즈를 얻어온다. if (m_IsFullScreen) { lpMMI->ptMaxSize.y = rectDesktop.Height(); lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y; lpMMI->ptMaxSize.x = rectDesktop.Width(); lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x; } CFrameWnd::OnGetMinMaxInfo(lpMMI); }
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { //ALT + Enter를 누르면 풀 스크린이당 ^^ if(pMsg->message == WM_SYSKEYDOWN && pMsg->lParam == 0x201C0001) SetFullScreen(); return CFrameWnd::PreTranslateMessage(pMsg); }
MDI 일경우는... 차일드 프레임 소스... void CChildFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); if(pFrame) { CRect rectDesktop; ::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop ); ::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE, GetExStyle()); // 윈도우의 최대 사이즈를 얻어온다. if (pFrame->m_IsFullScreen) { lpMMI->ptMaxSize.y = rectDesktop.Height(); lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y; lpMMI->ptMaxSize.x = rectDesktop.Width(); lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x; } }
CMDIChildWnd::OnGetMinMaxInfo(lpMMI); } |