Re: How to let a CFrameWnd based SDI application start in full
screen?
Also tried Joe's suggestion to find a solution for multimonitor case.
Generally it works great, but I have to do the following to hide the
disabled vertical scrollbar:
// Remember this for OnGetMinMaxInfo()
rectDesktop.right += ::GetSystemMetrics(SM_CXVSCROLL)
+ ::GetSystemMetrics(SM_CXFRAME);
m_FullScreenWindowRect = rectDesktop;
I guess this should be OK,right? --- I am just using the width of
VSCROLL and FRAME, not the view.
The following is what I did:
// Public method to be called from InitInstance
void CMainFrame::SetFullScreen()
{
RECT rectDesktop;
WINDOWPLACEMENT wpNew;
if (!m_bFullScreen)
{
//Adjust RECT to new size of window
::GetWindowRect(::GetDesktopWindow(), &rectDesktop);
::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE,
GetExStyle());
// Remember this for OnGetMinMaxInfo()
rectDesktop.right += ::GetSystemMetrics(SM_CXVSCROLL)
+ ::GetSystemMetrics(SM_CXFRAME);
m_FullScreenWindowRect = rectDesktop;
GetWindowPlacement(&wpNew);
wpNew.showCmd = SW_SHOWNORMAL;
wpNew.rcNormalPosition = rectDesktop;
m_bFullScreen = true;
}
SetWindowPlacement(&wpNew);
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if (m_bFullScreen)
{
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::PreCreateWindow(CREATESTRUCT& cs)
{
.... cs.style = WS_MAXIMIZE;
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}