Realize full screen display in VC ++ 6.0 development

zhaozj2021-02-16  67

Full-screen display is an essential function of some application software programs. For example, when using resources such as VC editing a project source file or editing dialog, select the menu "ViewFull Screen", you can enter the full screen display status, and press the "ESC" button to exit the full screen display status. In VC 6.0 we use AppWizard to generate a single document interface by default. Here, you will first discuss the method of clicking on the menu item "ViewFull Screen" to implement full screen display, and how to exit the full screen display status after pressing the "ESC" button. 1) In the CMAINFRAME class, increase the following three member variables. Class CMainFrame: public CFrameWnd {private: // three member variables WINDOWPLACEMENT m_OldWndPlacement add their own; // used to store the original window location BOOL m_bFullScreen; // full screen display signs Crect m_FullScreenRect; // window position represents a protected when full screen: CMAINFRAME (); Declare_DyncReate (CMAINFRAME)} 2) Edit menu IDR_MAINFRAME in the resource editor. Add menu items "full screen" under the "View" menu bar. In its properties box, the ID is set to ID_FULL_SCREEN, and CAPTION is "full screen". You can also add a new tool icon in the toolbar, and make it associated with the menu item "full screen", which is also set to ID_FULL_SCREEN. 3) Design full screen display processing function, add the response function of the above-described menu item ID_full_screen message at the CMAINFRAME class.

Response function as follows: void CMainFrame :: OnFullScreen () {GetWindowPlacement (& m_OldWndPlacement); Crect WindowRect; GetWindowRect (& WindowRect); Crect ClientRect; RepositionBars (0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery, & ClientRect); ClientToScreen (& ClientRect); // Get the screen Resolution INT NFULLLLLLTH = GetSystemMetrics; int nfulHeight = getSystemMetrics (sm_cyscreen); // Show the client area except the control bar to the NFullWidth, NfullHeight area, will (0, 0) and (NFullWidth, NfullHeight) Two points Extended the difference between the original window and the client area outside the control bar, get the full screen displayed window position m_fullscreenrect.Left = WindowRect.LIENTRECT.LEFT; M_FULLSCREENRECT .top = WindowRect.top-ClientRect.top; m_FullScreenRect.right = WindowRect.right-ClientRect.right nFullWidth; m_FullScreenRect.bottom = WindowRect.bottom-ClientRect.bottom nFullHeight; m_bFullScreen = TRUE; // set the full-screen display flag is TRUE // enter full-screen display state WINDOWPLACEMENT wndpl; wndpl.length = sizeof (WINDOWPLACEMENT); wndpl.flags = 0; wndpl.showCmd = SW_SHOWNORMAL; wndpl.rcNormalPosition = m_FullScreenRect; SetWindowPlacement (& wndpl);} 4) The ONGETMAXINFO function of the CMAINFRAME class is overloaded, and the full screen display is provided when the full screen is displayed.

转载请注明原文地址:https://www.9cbs.com/read-21878.html

New Post(0)