Implementing Full-Screen Mode

Full Screen mode is widely used in programs such as Word, VisualC, Corel Draw etc. If you take a closer look on the these implementations you will notice that they solve this problem differently.

Below you will find an example for this problem. I have used it in my editor program ( MyLight ) for a long time. This application has been tested under Windows 9x and Windows NT.

So use it if you like. The only thing I recommend is that name me in your product.

Downloads

Download demo project - 22 Kb

History



Comments

  • Complete Full Screen

    Posted by Legacy on 10/10/2003 12:00am

    Originally posted by: Tim Millar

    The borders that appear when making a full-screen MFC
    
    application are also set by the view currently inside
    the frame window.

    To make them disappear, override the PreCreateWindow
    method in the view class and add the following line
    of code before exiting the method:

    cs.dwExStyle &= ~WS_EX_CLIENTEDGE;

    (Why doesn't Microsoft document these things?)

    Reply
  • small bug

    Posted by Legacy on 06/11/2001 12:00am

    Originally posted by: Jeff

    m_pFullScreenBar->DestroyWindow();
    
    delete m_pFullScreenBar;
    m_pFullScreenBar=NULL; // I think this is important

    Reply
  • Neat Solution!!

    Posted by Legacy on 04/16/2001 12:00am

    Originally posted by: kajal

    Thankyou. It was of help. With the Hiding of Menu, it was just what I was looking for.

    Reply
  • How to hide the menu in full screen mode ?

    Posted by Legacy on 10/17/2000 12:00am

    Originally posted by: wdf2

    How to hide the menu in full screen mode ? Not destroy it,
    just hide it in it's original position,and if you press
    "ALT+F" ,then the "File" Menu appears,just like the VC platform do.

    Reply
  • Border Still shows

    Posted by Legacy on 02/12/2000 12:00am

    Originally posted by: Michael Malinak

    When in "Full-Screen" mode there is still a white border along the bottom and right hand side of the screen. For true full-screen this should be removed also. I have been trying unsuccessfully to remove it though.
    Any Hints?

    Reply
  • FullScreen for 1 SDI view

    Posted by Legacy on 10/07/1999 12:00am

    Originally posted by: Marcel

    I want full screen for only one view of multiple-view splitter based SDI app. Anyone out there done that?

    Please show me.

    Reply
  • How about hiding the scrool bar in Full Screen mode?

    Posted by Legacy on 09/09/1999 12:00am

    Originally posted by: curious

    How about hiding the scrool bar in Full Screen mode?

    Reply
  • Small bug on multimon system

    Posted by Legacy on 08/16/1999 12:00am

    Originally posted by: Paul Bludov

    SetWindowPos(NULL, -4, -4, screenX+4, screenY+4) will show border on all other monitors. It sounds like you should maximize mainframe window. When a window maximized, it has no border.
    

    Reply
  • Switch from Full Screen to Normal on ESC key

    Posted by Legacy on 07/28/1999 12:00am

    Originally posted by: skywalker

    In Full screen mode if you want to handle ESC key to switch to Normal mode add follwing code to you CMainFrame.
    
    

    Override PreTranslateMessage. You could do this using Class Wizard.

    Add Following code to PreTranslateMessage function

    BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
    {
    if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE
    && m_bFullScreenMode)
    {
    FullScreenModeOff();
    }
    return CMDIFrameWnd::PreTranslateMessage(pMsg);
    }

    Reply
  • Small changes to handle floating toolbars

    Posted by Legacy on 07/21/1999 12:00am

    Originally posted by: P�l K. T�nder

    The suggested code does not handle floating toolbars well, and also there is some flickering connected with the dynamically created toolbar. Here are the methods FullScreenModeOn and FullScreenModeOff with the suggested
    
    changes. My additions are commented starting with PKT.

    void CMainFrame::FullScreenModeOn()
    {
    // available only if there is an active doc
    CMDIChildWnd* pChild=MDIGetActive();
    if(!pChild) return;
    m_bToolBarWasVisible=(m_wndToolBar.IsWindowVisible()!=0);
    // PKT: ShowControlBar used instead of ShowWindow
    // because this also handles floating toolbars
    ShowControlBar(&m_wndToolBar, FALSE, FALSE );
    m_bStatusBarWasVisible=(m_wndStatusBar.IsWindowVisible()!=0);
    // PKT: ShowControlBar used instead of ShowWindow
    // because this also handles floating toolbars
    ShowControlBar(&m_wndStatusBar, FALSE, FALSE );
    // now save the old positions of the main and child windows
    GetWindowRect(&m_mainRect);
    // remove the caption of the mainWnd:
    LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
    style&=~WS_CAPTION;
    ::SetWindowLong(m_hWnd,GWL_STYLE,style);
    int screenx=GetSystemMetrics(SM_CXSCREEN);
    int screeny=GetSystemMetrics(SM_CYSCREEN);
    // resize:
    SetWindowPos(NULL,-4,-4,screenx+8,screeny+8,SWP_NOZORDER);
    style=::GetWindowLong(pChild->m_hWnd,GWL_STYLE);
    m_bChildMax=(style & WS_MAXIMIZE)?true:false;
    // note here: m_bMainMax is not needed since m_hWnd only
    // changed its caption...

    // and maximize the child window
    // it will remove its caption, too.
    pChild->ShowWindow(SW_SHOWMAXIMIZED);
    RecalcLayout();
    // PKT: Moved it down to avoid some flickering

    // Create the new toolbar
    // this will contain the full-screen off button
    m_pwndFullScreenBar=new CToolBar;
    m_pwndFullScreenBar->Create(this);
    m_pwndFullScreenBar->LoadToolBar(IDR_FULLSCREEN);
    m_pwndFullScreenBar->SetBarStyle(m_pwndFullScreenBar->GetBarStyle() |
    CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
    // to look better:
    m_pwndFullScreenBar->ModifyStyle(0, TBSTYLE_FLAT);
    m_pwndFullScreenBar->EnableDocking(0);
    // place the full-screen off button somewhere:
    CPoint pt(screenx-100,50);
    FloatControlBar(m_pwndFullScreenBar,pt);

    m_bFullScreenMode=true;

    }

    void CMainFrame::FullScreenModeOff()
    {
    // You can use SaveBarState() in OnClose(),
    // so remove the newly added toolbar entirely
    // in order SaveBarState() not
    // to save its state. That is why I used dynamic
    // allocation
    delete m_pwndFullScreenBar;
    LONG style=::GetWindowLong(m_hWnd,GWL_STYLE);
    style|=WS_CAPTION;
    ::SetWindowLong(m_hWnd,GWL_STYLE,style);
    if(m_bToolBarWasVisible)
    // PKT: ShowControlBar used instead of ShowWindow
    // because this also handles floating toolbars
    ShowControlBar(&m_wndToolBar, TRUE, FALSE );
    if(m_bStatusBarWasVisible)
    // PKT: ShowControlBar used instead of ShowWindow
    // because this also handles floating toolbars
    ShowControlBar(&m_wndStatusBar, TRUE, FALSE );
    MoveWindow(&m_mainRect);
    RecalcLayout();
    CMDIChildWnd* pChild=MDIGetActive();
    // pchild can be NULL if the USER closed all the
    // childs during Full Screen Mode:
    if(pChild){
    if(m_bChildMax)
    MDIMaximize(pChild);
    else MDIRestore(pChild);
    }
    m_bFullScreenMode=false;
    }

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

  • Best-in-Class organizations execute on a strategy that supports the multi-channel nature of customer requests. These leading organizations do not just open up their service infrastructures to accommodate new channels, but also empower their teams to deliver an effective and consistent experience regardless of the channel selected by the customer. This document will highlight the key business capabilities that support a Best-in-Class customer engagement strategy.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds