📄 seeprintview.cpp
字号:
// SeePrintView.cpp : implementation of the CSeePrintView class
//
#include "stdafx.h"
#include "SeePrint.h"
#include "SeePrintDoc.h"
#include "SeePrintView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSeePrintView
IMPLEMENT_DYNCREATE(CSeePrintView, CScrollView)
BEGIN_MESSAGE_MAP(CSeePrintView, CScrollView)
//{{AFX_MSG_MAP(CSeePrintView)
// 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, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSeePrintView construction/destruction
CSeePrintView::CSeePrintView()
{
// TODO: add construction code here
}
CSeePrintView::~CSeePrintView()
{
}
BOOL CSeePrintView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CSeePrintView drawing
void CSeePrintView::OnDraw(CDC* pDC)
{
//added by yhm
int i,j,Height;
CString str;
CFont font;
TEXTMETRIC tm;
//added by yhm
CSeePrintDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//added by yhm
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);
//added by yhm
// TODO: add draw code for native data here
}
void CSeePrintView::OnInitialUpdate()
{
CView::OnInitialUpdate();//added by yhm
CScrollView::OnInitialUpdate();
//added by yhm
CSize sizeTotal(m_rectPrint.Width(),-m_rectPrint.Height());
CSize sizePage(sizeTotal.cx/2,sizeTotal.cy/2);
CSize sizeLine(sizeTotal.cx/100,sizeTotal.cy/100);
SetScrollSizes(MM_TWIPS,sizeTotal,sizePage,sizeLine);
// CSize sizeTotal;
//added by yhm
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CSeePrintView printing
BOOL CSeePrintView::OnPreparePrinting(CPrintInfo* pInfo)
{
pInfo->SetMaxPage(1); //added by yhm
// default preparation
return DoPreparePrinting(pInfo);
//该函数设置打印任务中的页面的最大数目,本例中只有一页。在重载OnPreparePrinting函数调用基类DoPreparePrinting是绝对必要的。
}
// CMyPrintView message handlers added by yhm
void CSeePrintView::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 xLongPixPerInch=pDC->GetDeviceCaps(LOGPIXELSX);
int yLongPixPerInch=pDC->GetDeviceCaps(LOGPIXELSY);
long xExt=(long)size.cx*xLongPixPerInch/96;
long yExt=(long)size.cy*yLongPixPerInch/96;
pDC->SetViewportExt((int)xExt,(int)yExt);
}
void CSeePrintView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CSeePrintView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CSeePrintView diagnostics
#ifdef _DEBUG
void CSeePrintView::AssertValid() const
{
CScrollView::AssertValid();
}
void CSeePrintView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CSeePrintDoc* CSeePrintView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSeePrintDoc)));
return (CSeePrintDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSeePrintView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -