⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 screenview.cpp

📁 1.在MFC框架下实现全屏 2.同时能够从全屏中恢复成普通屏
💻 CPP
字号:
// screenView.cpp : implementation of the CScreenView class
//

#include "stdafx.h"
#include "screen.h"
#include "MainFrm.h"
#include "screenDoc.h"
#include "screenView.h"

#include "FullScreenHandler.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CScreenView

IMPLEMENT_DYNCREATE(CScreenView, CFormView)

BEGIN_MESSAGE_MAP(CScreenView, CFormView)
	//{{AFX_MSG_MAP(CScreenView)
	ON_WM_KEYDOWN()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CScreenView construction/destruction

CScreenView::CScreenView()
	: CFormView(CScreenView::IDD)
{
	//{{AFX_DATA_INIT(CScreenView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CScreenView::~CScreenView()
{
}

void CScreenView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CScreenView)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BOOL CScreenView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CScreenView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CScreenView printing

BOOL CScreenView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CScreenView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CScreenView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CScreenView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CScreenView diagnostics

#ifdef _DEBUG
void CScreenView::AssertValid() const
{
	CFormView::AssertValid();
}

void CScreenView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CScreenDoc* CScreenView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CScreenDoc)));
	return (CScreenDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CScreenView message handlers


void CScreenView::OnDraw(CDC* pDC) 
{
	// TODO: Add your specialized code here and/or call the base class
	CRect rc;
	GetClientRect(&rc);
	pDC->DrawText(FullScreenHandler.InFullScreenMode() ?
		_T("恢复窗口按ESC") : _T(""), &rc, 0);
	
	
}

void CScreenView::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;
	 //调用主窗口类的自定义函数 EndFullScreen ,便可退出全屏显示状态
		pFrame->Recover();
	}
	CFormView::OnKeyDown(nChar, nRepCnt, nFlags);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -