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
Re: How to let a CFrameWnd based SDI application start in full screen?
In the application's app class InitInstance function, change this line
m_pMainWnd->ShowWindow(SW_SHOW);
to
m_pMainWnd->ShowWindow(SW_MAXIMIZED);
Re: How to let a CFrameWnd based SDI application start in full screen?
Quote:
Originally Posted by
jchliu
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
Replace NULL with &CWnd::wndTopMost. This will knock the taskbar out of the way.
Re: How to let a CFrameWnd based SDI application start in full screen?
Thanks very much for help. I tried to all your suggestion. I did the following:
SetWindowPos(&CWnd::wndTopMost, -cxFrame, -(cyFrame + cyCaption), cxScreen + 2 * cxFrame, cyScreen + 2 * cyFrame + cyCaption, 0);
This will put the applicaiton topmost. However I can still see the taskbar although all places except Start are not clickable now. Is there someway completely cover / hide the taskbar? I really want the application to occupy the full screen like full screen mode of movies. Thanks...
Re: How to let a CFrameWnd based SDI application start in full screen?
Well, get rid of that other stuff you put in there, and only use this rect:
Code:
fullscreenrect = CRect( 0,0, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN) );
Re: How to let a CFrameWnd based SDI application start in full screen?
It works great: now the application occupies the full screen now. However is that possible to only show the client area (exclude the blue top frame of the application)? Right now the only style I have is WS_MAXIMIZE...
Re: How to let a CFrameWnd based SDI application start in full screen?
Modified style to be WS_POPUP | WS_MAXIMIZE which solved the problem. Thanks very much for your help!