位置:用考培訓(xùn)網(wǎng) > 計(jì)算機(jī)類>計(jì)算機(jī)等級(jí)> 全國計(jì)算機(jī)二級(jí)C++知識(shí)點(diǎn):MFC實(shí)現(xiàn)全屏功能的代碼
2018-10-31 11:21:13
MFC實(shí)現(xiàn)全屏功能的代碼
很多的播放器都有快捷鍵控制窗口以全屏幕的方式顯示。給應(yīng)用程序加上全屏幕的功能,并不需要很多的代碼,比如給一個(gè)基于對(duì)話框的應(yīng)用程序加上全屏功能只需要以下少量代碼就可以工作了。
void CFullScreenDlg::FullScreenView(void)
{
RECT rectDesktop;
WINDOWPLACEMENT wpNew;
if (!IsFullScreen())
{
// We'll need these to restore the original state.
GetWindowPlacement (&m_wpPrev);
//Adjust RECT to new size of window
::GetWindowRect ( ::GetDesktopWindow(), &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
{
// 退出全屏幕時(shí)恢復(fù)到原來的窗口狀態(tài)
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)
{
// 記錄窗口當(dāng)前是否處于全屏狀態(tài)
return m_bFullScreen;
}
以上就是小編為您整理全國計(jì)算機(jī)二級(jí)C++知識(shí)點(diǎn):MFC實(shí)現(xiàn)全屏功能的代碼的全部?jī)?nèi)容,更多精彩請(qǐng)進(jìn)入計(jì)算機(jī)等級(jí)欄目查看
只要一個(gè)電話
我們免費(fèi)為您回電