小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

vc實現(xiàn)窗口全屏的一些方法

 quasiceo 2015-12-26
2012-07-19 10:47 3448人閱讀 評論(1) 收藏 舉報
分類:

1.

void CXXXDlg::SetFullScreen()
{
	int frameWidth =  GetSystemMetrics(SM_CXFRAME);
	int frameHeight = GetSystemMetrics(SM_CYFRAME);
	int captionHeight = GetSystemMetrics(SM_CYCAPTION);
	int screenWidth = GetSystemMetrics(SM_CXSCREEN);
	int screenHeight = GetSystemMetrics(SM_CYSCREEN);
	CRect rect;
	GetClientRect(&rect);
	rect.left = rect.left - frameWidth;
	rect.top = rect.top - frameHeight - captionHeight ;
	rect.bottom = rect.top + screenHeight + 2 * frameHeight + captionHeight;
	rect.right = rect.left + screenWidth + 2 * frameWidth;
	ShowWindow(SW_HIDE);
	SetWindowPos(&wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW);
}
2.

實現(xiàn)全屏顯示:

在CMainFrame類中實現(xiàn)

private:

       BOOL                   m_bFullScreen;        // 全屏顯示標志

       WINDOWPLACEMENT m_OldWndPlacement; // 用來保存原窗口的位置

       CRect                   m_FullScreenRect;      // 表示全屏顯示時的窗口位置

初始化

CMainFrame::CMainFrame()

{

       // TODO: add member initialization code here

       m_bFullScreen = FALSE;

}

添加菜單項以及菜單效應函數(shù)

void CMainFrame::OnFullScreen()

{

       // TODO: Add your command handler code here

       GetWindowPlacement(&m_OldWndPlacement);

       CRect WindowRect;

       GetWindowRect(&WindowRect);

       CRect ClientRect;

       RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery, &ClientRect);

       ClientToScreen(&ClientRect);

      

       // 獲取屏幕的分辨率

       int nFullWidth = GetSystemMetrics(SM_CXSCREEN);

       int nFullHeight = GetSystemMetrics(SM_CYSCREEN);

       // 將出控制條外的客戶區(qū)全屏顯示到從(0,0)到(nFullWidth,nFullHeight)區(qū)域

       // 將(0,0)和(nFullWidth,nFullHeight)兩個點外擴充原窗口和控制條之外的

       // 客戶區(qū)位置間的差值,就得到全屏顯示的窗口位置

       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;       // 設置全屏顯示標志為TURE

       WINDOWPLACEMENT wndpl;

       wndpl.length = sizeof(WINDOWPLACEMENT);

       wndpl.flags = 0;

       wndpl.showCmd = SW_SHOWNORMAL;

       wndpl.rcNormalPosition = m_FullScreenRect;

       SetWindowPlacement(&wndpl);

}

void CMainFrame::OnUpdateFullScreen(CCmdUI* pCmdUI)

{

       // TODO: Add your command update UI handler code here

       if (m_bFullScreen)

       {

              pCmdUI->SetCheck(1);

       }

       else

       {

              pCmdUI->SetCheck(0);

       }

}

重載CMainFrame類的OnGetMinMaxInfo()函數(shù)

void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)

{

       // TODO: Add your message handler code here and/or call default

       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();

              //最大的Track尺寸也要改變

              lpMMI->ptMaxTrackSize.x = m_FullScreenRect.Width();

              lpMMI->ptMaxTrackSize.y = m_FullScreenRect.Height();

       }    

       CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);

}

在類CMainFrame中添加函數(shù)EndFullScreen()。

void CMainFrame::EndFullScreen()

{

       if (m_bFullScreen)

       {

              // 推出全屏顯示,恢復原始窗口顯示

              ShowWindow(SW_HIDE);

              SetWindowPlacement(&m_OldWndPlacement);

       }

}

下面實現(xiàn)在按下Esc鍵時,調用EndFullScreen()函數(shù)。也即:建立按鍵與函數(shù)之間的聯(lián)系

// 添加WM_KEYDOWN消息相應函數(shù)

void CFullScreenTestView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)

{

       // TODO: Add your message handler code here and/or call default

       if (nChar == VK_ESCAPE)   // 如果按下的是Esc鍵

       {

              // 獲取主窗口指針

              CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;

              // 調用主窗口類的自定義函數(shù)EndFullScreen(),便可以退出全屏顯示模式

              pFrame->EndFullScreen();

       }

       CView::OnKeyDown(nChar, nRepCnt, nFlags);

}

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多