Click here to Skip to main content
13,558,069 members
Click here to Skip to main content
Add your own
alternative version


72 bookmarked
Posted 19 Feb 2005

Views in Full Screen Mode

, 19 Feb 2005
Rate this:
Please Sign up or sign in to vote.
Viewing windows in full screen mode.

Sample Image - Viewsinfullscreenmode.jpg


In many applications, occur the need of examining our view in mode, which makes full screen available. It relates especially to classes derived from CView. This project presents simple application (SDI), that uses class CScrollView showing data on the screen. Initially, view is in normal mode (placed in main frame, with toolbars, statusbar and menu). Converting our view to full mode, it's necessary to hide all other controls. Is it really necessary? It involves hiding main frame with toolbars, menu, and obliges to change code if new controls are placed. This project frees programmers from mentioned necessities and betrays a trick, that serves to preview progress run in your views.

First step

The first step is to add in CView (CSrollView,....) variables:

boolean isFull; /* in constructor of CView: isFull=false; */
CWnd *saveParent;
/* Besides other 3 var.: */
COLORREF background, text;
CMenu *ContextMenu;

Next step is to add a new button (new submenu) in Resources and attach new ID: ID_FULL_SCREEN_MODE - to enable/disable full screen mode. Associate this ID (in ClassWizard) and functions CFullScreenView::OnFullScreenMode(), CFullScreenView::OnUpdateFullScreenMode(CCmdUI* pCmdUI).

The most important lines (trick)

( Description in comments )

void CFullScreenView::OnFullScreenMode() 
    /* if normal mode - start (enable) full screen mode */

        /* Variable saveParent is used to save 
        address of parent window (address is necessary 
        in disabling this mode -to place view in former position) */

        /* this (our view) is placed on desktop window -
        CWnd::GetDesktopWindow() - Returns the Windows desktop window */

        CRect rect; /* temporary variable */

        /* Next function copies the dimensions of 
        the bounding rectangle of the desktop */

        /* view is placed on desktop */
        /* disable full screen mode */

        /* our view is placed in old window - using address saveParent 
        (pointer that has been used in former if-section) */
        this->SetParent( saveParent);

        /* pointer to the main frame and function RecalcLayout() 
        (run on behalf of CmainFrame object) 
        - that repositions all control bars 
        in the frame (#include <MainFrame.h>) */
        ((CMainFrame *)AfxGetMainWnd())->RecalcLayout();

Essentially, above-mentioned functions (its body) is way to receive our goal - after initializing variables mentioned in former chapter.

Turn off full screen mode

It's very important, to render possible disabling of full screen mode. Thus, context menu has been added (run by right mouse click). Only context menu, because of assumption to hide all controls, toolbars, menus in this mode.

How to disable full screen ? The best way is to send message ID_FULL_SCREEN_MODE. In resources, insert a new menu IDR_MENU_VIEW and in submenu define new items (first one is ID_FULL_SCREEN_MODE, the others in my project are used to start CColorDialog).


In CView::OnInitialUpdate(),

ContextMenu= new CMenu();
    AfxMessageBox("Fail to create context menu");

Context menu should appear, after clicking mouse (right button).

void CFullScreenView::OnRButtonDown(UINT nFlags, CPoint point) 
        CMenu *pSubMenu= ContextMenu->GetSubMenu(0);
            /* check menu item if full screen mode */
            pSubMenu->CheckMenuItem(ID_FULL_SCREEN_MODE,MF_CHECKED );

            /* disable next positions - to avoid 
            sending message, that start dialogs, etc. */
            /* uncheck menu item */
            pSubMenu->CheckMenuItem(ID_FULL_SCREEN_MODE,MF_UNCHECKED );
            /* enable menu item - in normal mode. */

        pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
    CScrollView::OnRButtonDown(nFlags, point);

Warning !!

It's impossible to show other windows (dialog boxes, etc.) in full screen mode. This mode serves to review content of view.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Przemyslaw Syrek
Poland Poland
I'm a student of Electrical Engineering
in Krakow (POLAND).My interest is computer
analysis in circuit theory and so far I have
been using MFC to build simple programs that
estimates solutions of circuits.
Live in Tarnow-Zdroj (of course) Smile | :)

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
xiaoyu9052517-Aug-11 16:36
memberxiaoyu9052517-Aug-11 16:36 
GeneralCFormView with Controls Pin
p2002ad28-Feb-11 17:08
memberp2002ad28-Feb-11 17:08 
GeneralIntelligent Pin
Mohammad Elsheimy5-Apr-10 9:45
memberMohammad Elsheimy5-Apr-10 9:45 
GeneralRe: Intelligent Pin
Mohammad Elsheimy5-Apr-10 9:58
memberMohammad Elsheimy5-Apr-10 9:58 
Questiondouble monitors? Pin
yulinxie27-Mar-08 17:35
memberyulinxie27-Mar-08 17:35 
AnswerRe: double monitors? Pin
yulinxie27-Mar-08 17:37
memberyulinxie27-Mar-08 17:37 
GeneralA very useful tool... Pin
Chandrasekharanp12-Feb-08 22:05
memberChandrasekharanp12-Feb-08 22:05 
GeneralSuggestion Pin
Bluezdrive28-Apr-05 21:58
memberBluezdrive28-Apr-05 21:58 
GeneralCombined Pin
Anonymous20-Feb-05 3:21
sussAnonymous20-Feb-05 3:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02-2016 | 2.8.180515.1 | Last Updated 19 Feb 2005
Article Copyright 2005 by Przemyslaw Syrek
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid