CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2009
    Posts
    12

    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

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    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);

  3. #3
    Join Date
    Nov 2001
    Posts
    251

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

    Quote Originally Posted by jchliu View Post
    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.

  4. #4
    Join Date
    Jul 2009
    Posts
    12

    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...

  5. #5
    Join Date
    Nov 2001
    Posts
    251

    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) );

  6. #6
    Join Date
    Jul 2009
    Posts
    12

    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...

  7. #7
    Join Date
    Jul 2009
    Posts
    12

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured