Click here to Skip to main content
15,895,799 members
Articles / Programming Languages / C++

Print Previewing without the Document/View Framework

Rate me:
Please Sign up or sign in to vote.
4.90/5 (25 votes)
26 Nov 1999CPOL4 min read 332.8K   12.3K   111  
Want to preview your printing without relying on the doc/view framework?
#if !defined(AFX_LISTPRINTSETUP_H__E1B3DDE5_9D53_11D1_8BAC_0000B43382FE__INCLUDED_)
#define AFX_LISTPRINTSETUP_H__E1B3DDE5_9D53_11D1_8BAC_0000B43382FE__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// ListPrintSetup.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CListPrintSetup dialog
#include "CoolButton.h"
#include "ListPrintPage1.h"
#include "ListPrintPage2.h"

// This are some small helper macros to manage CDialogs as tab pages

// put this in the header file with numDialog = number of cdialogs pages
#define GfxTabSupport(numDialog)	CDialog * __gfxTabDialog[numDialog];

// used to set up the array of CDialog * with the pages pointer; see OnInitDialog for sample
#define GfxSetTabDialog(numDialog, pDialog)	__gfxTabDialog[numDialog] = (CDialog *) pDialog;

// used to insert tabs in the control; m_ctlTab is the tab control, nId the index of page
// and pText the label of the page; see OnInitDialog for sample
#define GfxAddTabItem(m_ctlTab, nId, pText)\
{\
	TC_ITEM TabCtrlItem;\
	TabCtrlItem.mask = TCIF_TEXT;\
	TabCtrlItem.pszText = pText;\
	m_ctlTab.InsertItem( nId, &TabCtrlItem );\
}

// called in the CTabCtrl OnSelChange to switch between pages
#define GfxSwitchTabDialog(numDialog, maxDialog)\
{\
	for (int __gfxT = 0; __gfxT < maxDialog; __gfxT++)\
	{\
		if (__gfxT == numDialog) \
			__gfxTabDialog[__gfxT]->ShowWindow(SW_SHOW); \
		else \
			__gfxTabDialog[__gfxT]->ShowWindow(SW_HIDE); \
	}\
}

class CListPrintSetup : public CDialog
{
// Construction
public:
	CListPrintSetup(CWnd* pParent = NULL);   // standard constructor
	CListPrintPage1	dlgSheet1;
	CListPrintPage2 dlgSheet2;

	enum { iNumDialog = 2};
	GfxTabSupport(iNumDialog);

	BOOL m_bPrintPreview; // Kah Hoe added

	void OnUpdateDialog();

// Dialog Data
	//{{AFX_DATA(CListPrintSetup)
	enum { IDD = IDD_LISTSETUP };
	CCoolButton	wndPreview;
	CCoolButton	wndOk;
	CCoolButton	wndCancel;
	CTabCtrl	wndTab;
	CCoolButton	wndPrintOpt;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CListPrintSetup)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CListPrintSetup)
	virtual BOOL OnInitDialog();
	afx_msg void OnBtPrintopt();
	afx_msg void OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult);
	virtual void OnOK();
	afx_msg void OnPreview();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_LISTPRINTSETUP_H__E1B3DDE5_9D53_11D1_8BAC_0000B43382FE__INCLUDED_)

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
Malaysia Malaysia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions