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

📄 samplereportview.cpp

📁 这是一个不用任何控件的的纯VC报表源码。而且写得相当好!
💻 CPP
字号:
// SampleReportView.cpp : implementation of the CSampleReportView class
//

#include "stdafx.h"
#include "SampleReport.h"

#include "SampleReportDoc.h"
#include "SampleReportView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSampleReportView

IMPLEMENT_DYNCREATE(CSampleReportView, CScrollView)

BEGIN_MESSAGE_MAP(CSampleReportView, CScrollView)
	//{{AFX_MSG_MAP(CSampleReportView)
		// 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()

/////////////////////////////////////////////////////////////////////////////
// CSampleReportView construction/destruction

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

}

CSampleReportView::~CSampleReportView()
{
}

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

	return CScrollView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CSampleReportView drawing

void CSampleReportView::OnDraw(CDC* pDC)
{
	CSampleReportDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	pDoc->Draw(pDC);
}

void CSampleReportView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	// For this sample app, the page defaults to 8.5 x 11 inches.
	// Also, remember to set the mode to LO_METRIC, which is used
	// by the report. However, this view is not WISWIG in that the 
	// printer resolution is different from the screen resolution. 
	// However, if you print-preview the report, you will see the 
	// report in all it's glory !
	sizeTotal.cx = (int)(8.5*254);
	sizeTotal.cy = (int)(11*245);
	SetScrollSizes(MM_LOMETRIC, sizeTotal);
}

/////////////////////////////////////////////////////////////////////////////
// CSampleReportView printing

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

void CSampleReportView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* pInfo)
{
	pInfo->SetMaxPage( GetDocument()->GetPageCount());
}

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

/////////////////////////////////////////////////////////////////////////////
// CSampleReportView diagnostics

#ifdef _DEBUG
void CSampleReportView::AssertValid() const
{
	CScrollView::AssertValid();
}

void CSampleReportView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CSampleReportView message handlers

void CSampleReportView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
	GetDocument()->GotoPage( pInfo->m_nCurPage - 1);	// we use 0-based indexing, hence the -1	
	CScrollView::OnPrint(pDC, pInfo);
}

⌨️ 快捷键说明

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