Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to let a CFrameWnd based SDI application start in full screen?

207 views
Skip to first unread message

Leo

unread,
Jun 10, 2010, 2:53:19 PM6/10/10
to
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

Seetharam

unread,
Jun 10, 2010, 5:51:09 PM6/10/10
to
You don't have to set the WS_MAXIMIZE style bit. A full-screen mode is
not a maximized window. For full-screen you simply resize your app
window to the desktop window size...maybe even remove the
WS_THICKFRAME style.

Also take a look at
http://support.microsoft.com/kb/164162

-Seetharam

Paul S. Ganney

unread,
Jun 11, 2010, 4:55:33 AM6/11/10
to
This works for me:

in CMyApp::InitInstance()

// The one and only window has been initialized, so show and update
it.
m_pMainWnd->ShowWindow(SW_MAXIMIZE); // start maximised
m_pMainWnd->UpdateWindow();

Paul

Seetharam

unread,
Jun 11, 2010, 10:00:02 AM6/11/10
to
Good that it works for you.. but I hope you are aware that a maximized
window doesn't overlap the taskbar area.
If you try the "full-screen" mode in say MS Visual Studio IDE, you'll
see that there is no WS_MAXIMIZED style bit ( using spy ).
A "full-screen" app is different than a maximized window.

-Seetharam

Martin Richter [MVP]

unread,
Jun 12, 2010, 3:14:36 AM6/12/10
to
Hallo Leo!

> I have a CFrameWnd based SDI application. I want it to start in full
> screen.

Simply set CWinApp::m_nCmdShow to SW_MAXIMIZED!

--
Martin Richter [MVP] WWJD http://blog.m-ri.de
"A well-written program is its own heaven; a poorly written
program is its own hell!" The Tao of Programming
FAQ: http://www.mpdvc.de Samples: http://www.codeproject.com

0 new messages