Recently I need to add full screen mode for one of my MFC projects. Like what we did usually, my first impression is to hide the tool bar of main frame and expand the size of view. Thus, I need to calculate the system screen size (GetSystemMetrics() API), to calculate the current size of windows frame (GetWindowRect() API), and to reset the location/coordinator of main frame( SetWindowPos() API).
It is not hard, but it really took me much time on implementating it. Then, I tested it and found the full screen mode can be displayed. However, when I tried to go back to normal size, my Ribbonbar dissappeared! Thus, I realized that I need to do more work about Ribbon bar. When I read the documentation on MSDN, fortunately I found a very interesting class "CFullScreenImpl" class in MFC. http://msdn.microsoft.com/en-us/library/cc308980.aspx
Thus, I tried it in my Visual Studio 2010. Easy!!! You only need to do three things:
int
{
............
EnableFullScreenMode (ID_VIEW_FULLSCREEN); // the ID of your control you created in step 1
EnableFullScreenMainMenu(FALSE);
}
3. In MainFrm.cpp, add an event handler function for your control in step (1), and add ShowFullScreeen().
void
ShowFullScreen();
That is it! Very simple! I hope more and more people can enjoy it!