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

📄 myprin~2.cpp

📁 visual c++ 时尚编程百例 全部源代码
💻 CPP
字号:
// MyPrintView.cpp : implementation of the CMyPrintView class
//

#include "stdafx.h"
#include "MyPrint.h"

#include "MyPrintDoc.h"
#include "MyPrintView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyPrintView

IMPLEMENT_DYNCREATE(CMyPrintView, CView)

BEGIN_MESSAGE_MAP(CMyPrintView, CView)
	//{{AFX_MSG_MAP(CMyPrintView)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CMyPrintView construction/destruction

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

}

CMyPrintView::~CMyPrintView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMyPrintView drawing

void CMyPrintView::OnDraw(CDC* pDC)
{
	int i,j,Height;
	CString str;
	CFont font;
	TEXTMETRIC tm;
	CMyPrintDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	pDC->SetMapMode(MM_TWIPS);
	pDC->Rectangle(m_rectPrint+CRect(0,0,-20,20));
	font.CreateFont(-200,0,0,0,400,false,false,0,ANSI_CHARSET,
		OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_ROMAN,"Times New Roman");
	CFont*pOldFont=(CFont*)pDC->SelectObject(&font);
	pDC->GetTextMetrics(&tm);
	Height=tm.tmHeight+tm.tmExternalLeading;
	j=pDoc->m_stringArray.GetSize();
	for(i=0;i<j;i++)
	{
		pDC->TextOut(720,-i*Height-720,pDoc->m_stringArray[i]);
	}
	pDC->SelectObject(pOldFont);
	
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMyPrintView printing

BOOL CMyPrintView::OnPreparePrinting(CPrintInfo* pInfo)
{
	pInfo->SetMaxPage(1);
	// default preparation
	return DoPreparePrinting(pInfo);
}

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

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

/////////////////////////////////////////////////////////////////////////////
// CMyPrintView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMyPrintView message handlers

void CMyPrintView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CView::OnPrepareDC(pDC, pInfo);
	pDC->SetMapMode(MM_ANISOTROPIC);
	CSize size=CSize(800,600);
	pDC->SetWindowExt(size);
	int xLogPixPerInch=pDC->GetDeviceCaps(LOGPIXELSX);
	int yLogPixPerInch=pDC->GetDeviceCaps(LOGPIXELSY);
	long xExt=(long)size.cx*xLogPixPerInch/96;
	long yExt=(long)size.cy*yLogPixPerInch/96;
	pDC->SetViewportExt((int)xExt,(int)yExt);
}

⌨️ 快捷键说明

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