How to let a CFrameWnd based SDI application start in full screen?
I have a CFrameWnd based SDI application. I want it to start in full
screen. I did the following:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
...
cs.style = WS_OVERLAPPED | WS_CAPTION | WS_MAXIMIZE
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
This will start full screen on my development machine. But after
deploying it, it doesn't start in full screen on other machines.
Then I overrided the following method:
void CMainFrame::OnSetFocus(CWnd* /*pOldWnd*/)
{
// forward focus to the view window
m_wndView.SetFocus();
if (!m_bFullScreen)
{
m_bFullScreen = true;
int cyCaption = ::GetSystemMetrics(SM_CYCAPTION);
int cxFrame = ::GetSystemMetrics(SM_CXFRAME);
int cyFrame = ::GetSystemMetrics(SM_CYFRAME);
int cxScreen = ::GetSystemMetrics(SM_CXSCREEN);
int cyScreen = ::GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(NULL, -cxFrame, -(cyFrame + cyCaption), cxScreen + 2
* cxFrame, cyScreen + 2 * cyFrame + cyCaption, SWP_NOZORDER);
}
}
This will occupy most of the screen, but not the taskbar at the
bottom. How can I also let the application occupy really the full
screen (includeing the taskbar area)? Thanks.
Leo