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

A Copy Utility using TWAIN

Rate me:
Please Sign up or sign in to vote.
4.54/5 (10 votes)
14 Jul 20042 min read 100.1K   6.8K   47  
Example for a simple encapsulation of the TWAIN interface
#ifndef __PRINTINGINFO_H_
#define __PRINTINGINFO_H_





class CPrintingInfo : public CObject
{
public:
	// ------------------
	// founding operators
	// ------------------

	CPrintingInfo();
	CPrintingInfo(const CPrintingInfo& PrintInfo);
	virtual ~CPrintingInfo();

    void Serialize( CArchive& archive );    
	void Reset();

	// -----
	// types
	// -----

	enum EPrinterStatus {PR_NOTANY, PR_OK, PR_STD};

	// -------
	// methods
	// -------

	void GetData(const PRINTDLG& PrnDlg);
	bool SetData(PRINTDLG& PrnDlg) const;

	HDC GetPrinterDC(CPrintDialog& PrintDlg) const;
	HDC CreateStandardDC(CPrintDialog& PrintDlg) const;
	
	LPCTSTR GetPrinterName() const;
	bool IsValidDevInfo() const;

	HGLOBAL GetDevInfo() const;
	bool GetPrinterDesc(CString& sPrinter, CString& sDriver, CString& sPort) const;

	EPrinterStatus TestPrintInfo() const;

	// ---------
	// operators
	// ---------

	const CPrintingInfo& operator=(const CPrintingInfo& PrintInfo); 

	// -------
	// mfc
	// -------

	DECLARE_SERIAL(CPrintingInfo) 

private:
	// -------
	// methods
	// -------
	
	HGLOBAL SetDevNames(LPCTSTR pDeviceName) const;
	bool InterpretPrinterInfo2(LPCTSTR pDeviceName, CString& sPrinter, CString& sDriver, CString& sPort) const;

	void SetDevModeInfo(LPCVOID pData = NULL);

	// -------
	// members
	// -------

	UINT	  m_DevModeSize;		
	DEVMODE*  m_pDevMode;
};

#endif // !defined(AFX_PRINTINFO_H__611183D5_42A4_11D4_A011_00D0B729A594__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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


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

Comments and Discussions