Code for implementing the full screen function of MFC

Source: Internet
Author: User

Many players have shortcut key control windows displayed in full screen mode. Adding the full screen function to an application does not require a lot of code. For example, adding the full screen function to a dialog box-based application requires only a small amount of code to work.


Void CFullScreenDlg: FullScreenView (void)
{
RECT rectDesktop;
WINDOWPLACEMENT wpNew;
If (! IsFullScreen ())
{
// Well need these to restore the original state.
GetWindowPlacement (& m_wpPrev );
// Adjust RECT to new size of window
: GetWindowRect (: getwindowtopwindow (), rectDesktop );
: AdjustWindowRectEx (rectDesktop, GetStyle (), FALSE, GetExStyle ());
// Remember this for OnGetMinMaxInfo ()
M_rcFullScreenRect = rectDesktop;
WpNew = m_wpPrev;
WpNew. showCmd = SW_SHOWNORMAL;
WpNew. rcNormalPosition = rectDesktop;
M_bFullScreen = true;
}
Else
{
// Restore to the original window status when you exit the full screen
M_bFullScreen = false;
WpNew = m_wpPrev;
}
SetWindowPlacement (& wpNew );
}
Void CFullScreenDlg: OnGetMinMaxInfo (MINMAXINFO * lpMMI)
{
// TODO: Add your message handler code here and/or call default
If (IsFullScreen ())
{
LpMMI-> ptMaxSize. y = m_rcFullScreenRect.Height ();
LpMMI-> ptMaxTrackSize. y = lpMMI-> ptMaxSize. y;
LpMMI-> ptMaxSize. x = m_rcFullScreenRect.Width ();
LpMMI-> ptMaxTrackSize. x = lpMMI-> ptMaxSize. x;
}
CDialog: OnGetMinMaxInfo (lpMMI );
}
Bool CFullScreenDlg: IsFullScreen (void)
{
// Record whether the window is in full screen status
Return m_bFullScreen;
}

Related Article

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.