VC 6.0下实现的 报表打印类 对数据制定打印位置 位置调整 打印预览 以及批量打印
适用于 罚单、发票等批量打印要求
以下为程序代码:
// ReportPrint.h: interface for the ReportPrint class.
//
//
#if !defined(AFX_REPORTPRINT_H__7A35BA1E_B178_4C1B_8970_5226028695DB__INCLUDED_)
#define AFX_REPORTPRINT_H__7A35BA1E_B178_4C1B_8970_5226028695DB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define POINT_COUNT 2
//打印信息结构体
typedef struct tag_PRINTINFO
{
CString text[POINT_COUNT];
}PRINTINFO;
class ReportPrint
{
public:
BOOL m_bEditMode;
void SetTextFont(char* height,char* facename);
void PrintPreview();
void Print(BOOL bDirect);
void SetPrintInfo(PRINTINFO printInfo[],int size);
void SetPaperSize(int x,int y);
void SetPaperSize(CSize paperSize);
ReportPrint();
virtual ~ReportPrint();
private:
PRINTINFO* m_pPrintInfo;
CSize m_paperSize; //打印纸张型号 默认 A4 297*210
int m_nCurPage; //当前页
int m_nMaxPage; //最大页
CString m_csHeight;
CString m_csFaceName;
CPoint m_printPoint[POINT_COUNT]; //打印坐标数组
};
#endif // !defined(AFX_REPORTPRINT_H__7A35BA1E_B178_4C1B_8970_5226028695DB__INCLUDED_)
/
// CDlgReportPrintPreview dialog
class CDlgReportPrintPreview : public CDialog
{
// Construction
public:
BOOL m_bEditMode;
CDlgReportPrintPreview(CWnd* pParent = NULL); // standard constructor
CDlgReportPrintPreview::CDlgReportPrintPreview(CString& csHeight,CString& csFaceName, CSize paperSize, PRINTINFO printInfo[], int nMaxPage, CPoint* pPrintPoint, int nPrintCount,ReportPrint* parent = NULL);
// Dialog Data
//{
{AFX_DATA(CDlgReportPrintPreview)
enum { IDD = IDD_DLG_PRINT_PREVIEW };
CComboBox m_ctrlNodes;
int m_nCurPage;
int m_nPosX;
int m_nPosY;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{
{AFX_VIRTUAL(CDlgReportPrintPreview)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{
{AFX_MSG(CDlgReportPrintPreview)
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg void OnBnPre();
afx_msg void OnBnNext();
virtual void OnOK();
afx_msg void OnBnSetPos();
afx_msg void OnSelchangeComboNode();
afx_msg void OnChangeEditY();
afx_msg void OnChangeEditX();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void DrawPrintPreview(CDC* pDC,C