Moved WinPrinter from private.h to printdlg.cpp.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@62189 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -650,52 +650,6 @@ private:
|
|||||||
DECLARE_NO_COPY_CLASS(GlobalPtrLock)
|
DECLARE_NO_COPY_CLASS(GlobalPtrLock)
|
||||||
};
|
};
|
||||||
|
|
||||||
// smart pointer like class using OpenPrinter and ClosePrinter
|
|
||||||
class WinPrinter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// default ctor
|
|
||||||
WinPrinter()
|
|
||||||
{
|
|
||||||
m_hPrinter = (HANDLE)NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
WinPrinter( const wxString& printerName )
|
|
||||||
{
|
|
||||||
Open( printerName );
|
|
||||||
}
|
|
||||||
|
|
||||||
~WinPrinter()
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL Open( const wxString& printerName, LPPRINTER_DEFAULTS pDefault=(LPPRINTER_DEFAULTS)NULL )
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
return OpenPrinter( (LPTSTR)printerName.wx_str(), &m_hPrinter, pDefault );
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL Close()
|
|
||||||
{
|
|
||||||
BOOL result = TRUE;
|
|
||||||
if( m_hPrinter )
|
|
||||||
{
|
|
||||||
result = ClosePrinter( m_hPrinter );
|
|
||||||
m_hPrinter = (HANDLE)NULL;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
operator HANDLE() { return m_hPrinter; }
|
|
||||||
operator bool() { return m_hPrinter != (HANDLE)NULL; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
HANDLE m_hPrinter;
|
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(WinPrinter);
|
|
||||||
};
|
|
||||||
|
|
||||||
// register the class when it is first needed and unregister it in dtor
|
// register the class when it is first needed and unregister it in dtor
|
||||||
class ClassRegistrar
|
class ClassRegistrar
|
||||||
{
|
{
|
||||||
|
@@ -46,6 +46,52 @@
|
|||||||
#include <print.h>
|
#include <print.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// smart pointer like class using OpenPrinter and ClosePrinter
|
||||||
|
class WinPrinter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// default ctor
|
||||||
|
WinPrinter()
|
||||||
|
{
|
||||||
|
m_hPrinter = (HANDLE)NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WinPrinter( const wxString& printerName )
|
||||||
|
{
|
||||||
|
Open( printerName );
|
||||||
|
}
|
||||||
|
|
||||||
|
~WinPrinter()
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL Open( const wxString& printerName, LPPRINTER_DEFAULTS pDefault=(LPPRINTER_DEFAULTS)NULL )
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
return OpenPrinter( (LPTSTR)printerName.wx_str(), &m_hPrinter, pDefault );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL Close()
|
||||||
|
{
|
||||||
|
BOOL result = TRUE;
|
||||||
|
if( m_hPrinter )
|
||||||
|
{
|
||||||
|
result = ClosePrinter( m_hPrinter );
|
||||||
|
m_hPrinter = (HANDLE)NULL;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
operator HANDLE() { return m_hPrinter; }
|
||||||
|
operator bool() { return m_hPrinter != (HANDLE)NULL; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
HANDLE m_hPrinter;
|
||||||
|
|
||||||
|
DECLARE_NO_COPY_CLASS(WinPrinter);
|
||||||
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// wxWindowsPrintNativeData
|
// wxWindowsPrintNativeData
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user