Download Source Code

CWinPrint Class Reference

Thin wrapper around the Windows Printing API. More...

#include <WinPrint.h>

List of all members.

Public Member Functions

LPRECT GetDeviceSize ()
 Calculates the device image size in pixels.
BOOL EndPage ()
 Ends printing for current page.
BOOL StartPage ()
 Starts printing on a particular page.
BOOL EndDoc ()
 Ends printing for the current document.
BOOL StartDoc (LPCTSTR pName)
 Starts print job.
void Destroy ()
 Ends printing and resets print device information.
BOOL PageSetup (HWND hOwner)
 Displays the page setup dialog box to the user.
BOOL PrintDlg (HWND hOwner, LONG lCopies=1, LONG lFrom=1, LONG lTo=1, LONG lMin=0, LONG lMax=1)
 Displays the print dialog box to the user.
 CWinPrint ()
 Default constructor.
virtual ~CWinPrint ()
 Destructor.
HDC GetPrintHdc ()
 Returns the print HDC. Must call PrintDlg() before using.
LPRECT GetPrintRect ()
 Returns the size of the print device context.
BOOL SupportsBitBlt ()
 Returns non-zero if the printer supports BitBlt().
PRINTDLG & GetPrintDlgInfo ()
 Returns reference to PRINTDLG structure.
PAGESETUPDLG & GetPageSetupInfo ()
 Returns reference to PAGESETUPDLG structure.
BOOL IsDocumentPrinting ()
 Returns non-zero if a document is being printed.
BOOL IsPagePrinting ()
 Returns non-zero if a page is being printed.

Static Public Member Functions

static BOOL CALLBACK AbortProc (HDC hPrintDC, int nCode)
 Called by Windows when a print job is to be cancelled.
static void CancelPrinting ()
 Cancels any current print job.


Detailed Description

Thin wrapper around the Windows Printing API.

Example:

    CWinPrint wp;
    if ( wp.PrintDlg( hWnd ) )
    {
        // Start print document
        wp.StartDoc( "My Picture" );

        // First page
        wp.StartPage();

        // Draw page
        DrawMyImage( wp.GetPrintHdc(), wp.GetPrintRect() );

        // End first page
        wp.EndPage();

        // End document
        wp.EndDoc();

    } // end if


Member Function Documentation

BOOL CALLBACK CWinPrint::AbortProc HDC  hPrintDC,
int  nCode
[static]
 

Called by Windows when a print job is to be cancelled.

Parameters:
[in] hPrintDC - Print DC
[in] nCode - Error code
Returns:
See also:

BOOL CWinPrint::EndDoc  ) 
 

Ends printing for the current document.

Returns:
Non-zero if success

BOOL CWinPrint::EndPage  ) 
 

Ends printing for current page.

Returns:
Non-zero if success

LPRECT CWinPrint::GetDeviceSize  ) 
 

Calculates the device image size in pixels.

Returns:
Pointer to RECT containing image size

HDC CWinPrint::GetPrintHdc  )  [inline]
 

Returns the print HDC. Must call PrintDlg() before using.

Returns:
HANDLE to a printer DC
See also:

LPRECT CWinPrint::GetPrintRect  )  [inline]
 

Returns the size of the print device context.

Must call PrintDlg or PrintDlgEx before using this function.

Returns:
RECT structure containing size of the printer device image.
See also:

BOOL CWinPrint::PageSetup HWND  hOwner  ) 
 

Displays the page setup dialog box to the user.

Parameters:
[in] hOwner - Handle to parent window.
Results are stored in m_pd.

Returns:
Non-zero if user clicks 'Ok'.
See also:

BOOL CWinPrint::PrintDlg HWND  hOwner,
LONG  lCopies = 1,
LONG  lFrom = 1,
LONG  lTo = 1,
LONG  lMin = 0,
LONG  lMax = 1
 

Displays the print dialog box to the user.

Parameters:
[in] hOwner - Handle to parent window.
[in] lCopies - Default number of copies
[in] lFrom - Default start page
[in] lTo - Default end page
[in] lMin - First page
[in] lMax - Last page
Returns:
Non-zero if the user clicks 'Print'.
See also:

BOOL CWinPrint::StartDoc LPCTSTR  pName  ) 
 

Starts print job.

Parameters:
[in] pName - Print job name.
Returns:
Non-zero if success
See also:

BOOL CWinPrint::StartPage  ) 
 

Starts printing on a particular page.

Returns:
Non-zero if success


The documentation for this class was generated from the following files:
  • inc/WinPrint.h
  • WinPrint.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL