From: Leo on
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
From: Seetharam on
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
From: Joseph M. Newcomer on
See below...
On Thu, 10 Jun 2010 11:53:19 -0700 (PDT), Leo <jchliustuff(a)gmail.com> wrote:

>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;
>}
****
I have never considered doing anything like this If I want a window maximized, I will
just call ShowWindow(SW_MAXIMIZE);

Are you sure that you have all the styles correct? For example, is the line that sets
everything but WS_MAXIMIZE completely redundant with what is already there? Why not

cs.style |= WS_MAXIMIZE

Or did you plan on clearing out all the other style bits? This sort of silliness
typically means you think you understand EXACTLY what is coming in, and I see no evidence
here that you have determined that you want to do anything more than set the WS_MAXIMIZE
bit.

I have no idea why you are clearing the WS_EX_CLIENTEDGE. Did you really mean to do this?

Why do you register your own window class?
****
>
>This will start full screen on my development machine. But after
>deploying it, it doesn't start in full screen on other machines.
****
It shouldn't start in "full screen" mode; it should start in "maximized" mode which is
what you asked for.
****
>
>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);
****
Why not something as simple as ShowWindow(SW_MAXIMIZE)?

Note that the above code is only going to do something if you set the focus. If the focus
is never set, this code will never be invoked. Therefore, this is not the proper
solution.

Also, you must NEVER use SM_CXSCREEN or SM_CYSCREEN as if they have meaning; they do not.
They apply ONLY to the primary display, and therefore are completely useless on a
multimonitor display. Look into the multimonitor support to get this right. But
generally, you should NEVER believe that these values are useful for any real situation.
****
> }
>}
>
>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.
****
There are a lot of documented techniques for doing "full-screen" presentation; why aren't
you using one of the documented methods? Do a google search for "full screen MFC"! This
is not exactly Rocket Science; you really should understand that search engines exist and
are useful tools.
joe
****
>
>Leo
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Paul S. Ganney on
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
From: Seetharam on
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