Implementation of full-screen MFC single-document (SDI) Program

Source: Internet
Author: User

MFCSingle Document (SDI) full screen Program Implementation Method for your reference:

MFC single document (SDI)Full Screen ProgramImplementation ideas:

  1. Convert full screen display mode when F11 is pressed
  2. Record the current position of the window when the screen is full.
  3. Record the Display Properties of the toolbar and status bar
  4. Hide/show menu bar
  5. Hide/show title bar
  6. Maximize/minimize windows

 

Single-document (SDI) full-screen MFC Program ImplementationTechnical points:

  1. Add a keydown event for the view. When nchar = 122, add the processing code.
  2. Obtain the mainframe pointer in the View: cmainframe * pmain = (cmainframe *) afxgetapp ()-> m_pmainwnd;
  3. Add status and other variables to mainframe:

    Public:

    Bool m_bfullscreenmode;

    Cmenu m_menumainwnd;

    PRIVATE:

    Bool m_bstatusbarwasvisible, m_btoolbarwasvisible;

    Crect m_mainrect;

  4. Initialize the variable value in the oncreate event of mainframe: This-> m_menumainwnd.loadmenu (idr_mainframe );

    This-> setmenu (& m_menumainwnd );
  5. The status of full screen initialization in the mainframe constructor is false: This-> m_bfullscreenmode = false;
  6. Add the function fullscreenmodeswitch to mainframe.
  7. 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 ();}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.