Click here to Skip to main content
15,894,017 members
Articles / Desktop Programming / MFC

Print ListCtrl on multiple pages

Rate me:
Please Sign up or sign in to vote.
4.96/5 (14 votes)
26 Mar 2000CPOL 165.8K   2.7K   55  
Printing the contents of a CListCtrl or CListView with multiple pages
#ifndef __SOME_HELPER__H__
#define __SOME_HELPER__H__

#include "gfx_printjob.h"

BOOL SortListCtrl(CListCtrl *pCtrl, int nCol, BOOL bAscending, int low = 0, int high = -1);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// CListCtrlPrintJob
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CListCtrlPrintJob : public GPrintJob
{
public:
	CListCtrlPrintJob(CListCtrl *pCtrl, BOOL bPrintToDefaultPrinter);
	virtual ~CListCtrlPrintJob();
   
	CDialog		*CreatePrintDialog();
	void		OnPrint();

protected:
	CListCtrl	*m_pListCtrl;
	int			m_ColCount;
	BOOL		m_bPrintToDefault;
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// CListCtrlHeaderPage
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CListCtrlHeaderPage : public GPrintUnit
{
public:
   CListCtrlHeaderPage(GPrintJob *pJob);
   virtual ~CListCtrlHeaderPage();

   BOOL		Print();
};

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// CListCtrlDataPage
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class CListCtrlDataPage : public GPrintUnit
{
public:
	CListCtrlDataPage(GPrintJob *pJob, CListCtrl *pCtrl, int firstCol, int lastCol);
	virtual ~CListCtrlDataPage();

	BOOL		Print();
	void		StartPage();
	void		DefineColHeadings();
	void		CreatePrintFonts();
	void		InitPrintMetrics();
	void		PrintColHeadings(UINT nFormat, UINT nEffects=0);

	void		PrintHeader();
	void		PrintFooter();

protected:
	PUFONTPAIR		m_fontPairBody;
	CFont			m_fontHeading;
	CFont			m_fontHeader;
	CFont			m_fontFooter;
	int				m_firstCol,
					m_lastCol;
	CListCtrl		*m_pListCtrl;
};


#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions