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

📄 pagesetview.cpp

📁 VC开发技术大全
💻 CPP
字号:
// PagesetView.cpp : implementation of the CPagesetView class
//

#include "stdafx.h"
#include "Pageset.h"

#include "PagesetDoc.h"
#include "PagesetView.h"

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

extern int m_leftmargin ;

/////////////////////////////////////////////////////////////////////////////
// CPagesetView

IMPLEMENT_DYNCREATE(CPagesetView, CView)

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

/////////////////////////////////////////////////////////////////////////////
// CPagesetView construction/destruction

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

}

CPagesetView::~CPagesetView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CPagesetView drawing

void CPagesetView::OnDraw(CDC* pDC)
{
	CPagesetDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	screenx = pDC->GetDeviceCaps(LOGPIXELSX);
	screeny = pDC->GetDeviceCaps(LOGPIXELSY);
	DrawData(pDC,false);
}

/////////////////////////////////////////////////////////////////////////////
// CPagesetView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CPagesetView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CPagesetView message handlers

void CPagesetView::DrawData(CDC *pDC, BOOL isPrinted)
{
	if (! isPrinted)
	{
		pDC->TextOut(50,50,"图书销售报表");
	}
	else
	{
		double printx,printy; //打印机每英寸像素数
		printx = pDC->GetDeviceCaps(LOGPIXELSX);
		printy = pDC->GetDeviceCaps(LOGPIXELSY);

		double ratex,ratey;
		ratex = printx/screenx; //获取打印机与屏幕的像素比率
		ratey = printy/screeny;
		
		int leftmargin = int((m_leftmargin /25.4)*printx); //将毫米转换为像素

		pDC->TextOut(50*ratex+leftmargin,50*ratey,"图书销售报表");
	}
}

void CPagesetView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
	DrawData(pDC,true);
//	CView::OnPrint(pDC, pInfo);
}

⌨️ 快捷键说明

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