MFCSingle Document (SDI) full screen Program Implementation Method for your reference:
MFC single document (SDI)Full Screen ProgramImplementation ideas:
- Convert full screen display mode when F11 is pressed
- Record the current position of the window when the screen is full.
- Record the Display Properties of the toolbar and status bar
- Hide/show menu bar
- Hide/show title bar
- Maximize/minimize windows
Single-document (SDI) full-screen MFC Program ImplementationTechnical points:
- Add a keydown event for the view. When nchar = 122, add the processing code.
- Obtain the mainframe pointer in the View: cmainframe * pmain = (cmainframe *) afxgetapp ()-> m_pmainwnd;
- Add status and other variables to mainframe:
Public:
Bool m_bfullscreenmode;
Cmenu m_menumainwnd;
PRIVATE:
Bool m_bstatusbarwasvisible, m_btoolbarwasvisible;
Crect m_mainrect;
- Initialize the variable value in the oncreate event of mainframe: This-> m_menumainwnd.loadmenu (idr_mainframe );
This-> setmenu (& m_menumainwnd );
- The status of full screen initialization in the mainframe constructor is false: This-> m_bfullscreenmode = false;
- Add the function fullscreenmodeswitch to mainframe.
- Add full-screen functions to mainframe: fullscreenmodeon and fullscreenmodeoff.
From: http://blog.csdn.net/shanzhizi
Core code:
Code highlighting produced by actipro codehighlighter (freeware) http://www.CodeHighlighter.com/--> void cmainframe: fullscreenmodeon () {m_btoolbarwasvisible = (m_wndtoolbar.iswindowvisible ()! = 0); // hide the display status of the toolbar m_wndtoolbar.showwindow (sw_hide); // hide the toolbar m_bstatusbarwasvisible = (m_wndstatusbar.iswindowvisible ()! = 0); // hide the display status of the status bar before the status bar m_wndstatusbar.showwindow (sw_hide); // hide the status bar // hide the menu bar setmenu (null ); // Save the previous location information getwindowrect (& m_mainrect); // remove the title of the Main Window long style =: getwindowlong (m_hwnd, gwl_style); Style & = ~ Ws_caption;: setwindowlong (m_hwnd, gwl_style, style); // get the current system resolution int screenx = getsystemmetrics (sm_cxscreen); int screeny = getsystemmetrics (sm_cyscreen ); // setwindowpos (null,-4,-4, screenx + 8, screeny + 8, swp_nozorder); style =: getwindowlong (this-> m_hwnd, gwl_style ); // set the full-screen display flag m_bfullscreenmode = true;} void cmainframe: fullscreenmodeoff () {// restore window title long style =: getwindowlong (m_hwnd, gwl_style ); style | = ws_caption;: setwindowlong (m_hwnd, gwl_style, style); // if necessary, display the toolbar if (m_btoolbarwasvisible) m_wndtoolbar.showwindow (sw_show); // if necessary, display status bar if (m_bstatusbarwasvisible) m_wndstatusbar.showwindow (sw_show); // restore the size of movewindow (& m_mainrect) before the window; // restore the menu bar this-> setmenu (& m_menumainwnd ); // set the full-screen display flag m_bfullscreenmode = false;} void cmainframe: fullscreenmodeswitch () {If (this-> m_bfullscreenmode) {This-> fullscreenmodeoff ();} else {This-> fullscreenmodeon ();}}