Add full screen display for MFC applications

xiaoxiao2021-03-06  104

Add the following member variables and member functions (using classwizard) in the CMAINFRAME class. The following is the functional description of these variables and functions:

Member variables:

BOOL M_BFULLSCREEN; / / full screen display flag

CRECT M_FULLSCREENWINDOWRECT; / / full screen display window Rect

WindowPlaceMent M_Wpprev; // The window location information for saving normal views

CToolbar * m_wndfullscreenbar; // Floating toolbar when displaying

Member function:

Void onmenufullscreen (); // Full screen display processing function

void onlineMAXINFO (); // Capture WM_GETMINMAXINFO message to allow you to add window size

Void onupdateViewFullscreen (); // Update the status of the "Full Screen Display" menu

Source

Void CMAINFRAME :: onmenufullscreen ()

{// full-screen display processing function

RECT RectDesktop;

WindowPlacement WpNew;

IF (m_bfullscreen)

{// full screen display mode

// Hide toolbar and status bar

M_WndStatusBar.showWindow (sw_hide);

m_wndtool bar.showwindow (sw_hide);

/ / Save the window location information when normal views to restore the original state

GetWindowPlacement; & M_WppRev

M_WppRev.Length = SizeOf M_Wpprev;

// Adjust the RECT for the new window size

:: getWindowRect (:: getDesktopwindow (), & reviewsktop;

:: AdjustWindowRectex (& RectDesktop, getStyle (), true, getExStyle ());

/ / Save the Rect to use ONGETMINMAXINFO ()

m_fullscreenwindowRect = RectDesktop;

WPNEW = m_wpprev;

Wpnew.showcmd = sw_shownormal;

Wpnew.rcnorMalposition = RectDesktop;

/ / Generate a new toolbar

m_wndfullscreenbar = new ctoolbar;

IF (! m_wndfullscreenbar-> Create (this, cbrs_size_dynamic | cbrs_floating)

||! M_wndfullscreenbar-> loadingtoolbar (idR_fullscreen))

{

Trace0 ("Failed to Create Toolbar / N);

Return; // Fail to Create

}

// Do not allow the toolbar to moister

M_WndFullscreenbar-> enabledocking (false);

m_wndfullscreenbar-> setwindowpos (0,100,100,0,0,0, swp_nosize

| SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWINDOW);

M_wndfullscreenbar-> setWindowText (_t ("full screen display"));

FloatControlbar (M_Wndfullscreenbar, CPOINT (100, 100));

m_bfullscreen = true;

}

Else

{/ / Normal display mode

/ / Delete full screen toolbar

m_wndfullscreenbar-> destroyWindow ();

Delete m_wndfullscreenbar;

m_bfullscreen = false; // Restore Toolbar and Status Bar

M_WndstatusBar.showWindow (sw_shownormal);

m_wndtoolbar.showwindow (sw_shownormal);

WPNEW = m_wpprev;

}

// Set the window display status

Setwindowplacement (& WPNEW);

}

Void CMAINFRAME :: ONGETMINMAXINFO (MinMaxInfo Far * LPMMI)

{

IF (m_bfullscreen)

{

LPMMI-> PTMAXSIZE.Y = m_fullscreenwindowRect.Height ();

LPMMI-> PTMaxTracksize.y = lpmmi-> ptmaxsize.y;

LPMMI-> PTMAXSIZE.X = m_fullscreenwindowRect.width ();

LPMMI-> PTMaxTracksize.x = lpmmi-> ptmaxsize.x;

}

}

Void CMAINFRAME :: OnUpdateMenufullscreen (ccmdui * pcmdui)

{// update the state of the menu

PCMDUI-> enable ();

PCMDUI-> SetCheck (m_bfullscreen);

}

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

New Post(0)