Realize full screen display in VC 6.0 development
Realize full screen display in VC 6.0 development
Full-screen display is an essential function of some application software programs. For example, when using resources such as VC editing engineering or editing dialog, select menu "View / Full Screen", you can enter full screen display status, press "ESC" button to exit 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 "View / Full Screen" to implement full screen display, and how to exit 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: // I have added three member variables
WindowPlaceMent M_OldWndplacement; // Used to save the original window location
BOOL M_BFULLSCREEN; / / full screen display logo
CRECT M_FULLSCREENRECT; / / indicates the window position when the full screen is displayed
protected: 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. The response function is as follows:
Void CMAINFRAME :: onfullscreen ()
{GetWindowplacement (& m_oldwndplacement);
CRECT WINDOWRECT;
GetWindowRect (& WindowRect);
CRECT ClientRect;
Repositionbars (0, 0xfff, AFX_IDW_PANE_FIRST, ReposQuery, & ClientRect);
ClientToscreen (& ClientRect);
/ / Get the resolution of the screen
INT nfulwidth = getSystemMetrics (SM_CXSCREEN);
Int nfullheight = getSystemMetrics (SM_CYSCREEN);
// The full screen of the customer area except the control bar is displayed to the NFullWidth, NfullHeight area, extends the original window and the resolution strip in two points (NFULLWIDTH, NFULLHEIGHT). The difference between the client area location is the window location displayed by the full screen.
M_FullscreenRect.Left = WindowRect.Left-ClientRect.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; // Setting full screen display flag True
// Enter the full screen display status
WINDOWPLACEMENT WNDPL;
Wndpl.length = sizeof (Windowplacement);
Wndpl.flags = 0;
Wndpl.showcmd = sw_shownormal;
Wndpl.rcnorMalposition = m_fullscreenRect;
SetWindowPlacement;}
4) The ONGETMAXINFO function of the CMAINFRAME class is overloaded, and the full screen display is provided when the full screen is displayed.
Void CMAINFRAME :: ONGETMINMAXINFO (MinMaxInfo Far * LPMMI)
{IF (m_bfullscreen)
{lpmmi-> ptmaxsize.x = m_fullscreenRect.width ();
LPMMI-> PTMAXSIZE.Y = M_FullscreenRect.Height ();
LPMMI-> ptmaxposition.x = m_fullscreenRect.width ();
LPMMI-> PTMaxPosition.y = m_fullscreenRect.Height ();
// The largest TRACK size must also change
LPMMI-> PTMaxTracksize.x = m_fullscreenRect.width ();
LPMMI-> PTMaxTracksize.y = m_fullscreenrect.Height ();
} CframeWnd :: ONGETMINMAXINFO (LPMMI)
} After completing the above programming, you can connect FullScreen.exe, select the menu "View / Full Screen" or click the toolbar button associated with it to enter the full screen display status. But now you need to increase the user's operating interface that exits the full-screen display status. Here, how to program how to implement the "ESC" button to exit full screen display status.
1) Select CMAINFRAME in ClassView and click the right mouse button, select "Add Member Function ...", add the member function of the public type EndFullScreen, which will complete the operation of exiting the full screen display.
Void CMAINFRAME :: endfullscreen ()
{IF (m_bfullscreen)
{// Exit full screen display, restore the original window display
ShowWindow (SW_HIDE);
SetWindowPlacement (& M_OldWndPlace
Ment);}}
2) The function endfullscreen can exit full-screen display status, and how is the "ESC" button is called to execute this function. Since the view class can handle the relevant messages entered by the keyboard (such as WM_KEYDOWN means that the user presses a key), we will add the Processing button message WM_KEYDOWN in the view class CFullScreenViewNKeyDown. To determine if the button is pressed for the "ESC" button, the function endfulscreen of the CMAINFRAME class can be quit the full screen display status.
Void cfullscreenview :: onkeydown (uint nchar, uint nrepcnt, uint nflags) {if (nchar == vk_escape) // If the button is pressed for the ESC button
{// Get the pointer to the main frame window
CMAINFRAME * PFRAME = (CMAINFRAME *) AFXGetApp () -> m_pmainwnd;
// Call the custom function endfullscreen of the main window class, you can exit full screen display status
Pframe-> endfullscreen ();
CView :: onkeydown (nchar, nrepcnt, nflags);}
In this way, we have achieved a comparison of professional full-screen features, and believe that the software program that will definitely makes a lot of software programs.