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

📄 mdocdemoview.cpp

📁 VC++6开发指南的源代码第7章-第11章
💻 CPP
字号:
// MDocDemoView.cpp : implementation of the CMDocDemoView class
//

#include "stdafx.h"
#include "MDocDemo.h"

#include "MDocDemoDoc.h"
#include "MDocDemoView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMDocDemoView

IMPLEMENT_DYNCREATE(CMDocDemoView, CView)

BEGIN_MESSAGE_MAP(CMDocDemoView, CView)
	//{{AFX_MSG_MAP(CMDocDemoView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMDocDemoView construction/destruction

CMDocDemoView::CMDocDemoView()
{
	// TODO: add construction code here

}

CMDocDemoView::~CMDocDemoView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMDocDemoView drawing

void CMDocDemoView::OnDraw(CDC* pDC)
{
	CMDocDemoDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CString str=pDoc->m_str;//获取输出文本
	LOGFONT lf=pDoc->m_lf;//获取字体结构
	CFont *pFont=new CFont;
	pFont->CreateFontIndirect(&lf);//创建字体
	CFont *poldFont=pDC->SelectObject(pFont);//载入DC
	pDC->TextOut(40,40,str);//输出文本
	pDC->SelectObject(poldFont);//恢复字体
}

/////////////////////////////////////////////////////////////////////////////
// CMDocDemoView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMDocDemoView diagnostics

#ifdef _DEBUG
void CMDocDemoView::AssertValid() const
{
	CView::AssertValid();
}

void CMDocDemoView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CMDocDemoView message handlers

⌨️ 快捷键说明

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