FieldSoftware
Home

PrinterCE SDK
   General Info
   Download
   Purchase & Pricing

Developer Info
   eVC MFC
   eVC C/C++
   eVB

Special Features
   AsciiCE
   PrintDC
   BarcodeCE

Documentation
   PrinterCE SDK
   AsciiCE
   PrintDC
   BarcodeCE

Special Topics
  Supported Printers
  Bluetooth Printing
  Network Printing

.Net CF C# or VB.Net:
  PrinterCE.NetCF SDK

-----------------------------

Software Developers
  PrinterCE SDK
 
PrinterCE.NetCF SDK
  PocketHTMLprint SDK

Printing Utilities
  PrintPocketCE
  PIEprint
  PocketPixPrint
  PocketShot
 
PocketClipPrint

 Arcade Games
  SockOut
  MazeCraze

Contact Info

PrintDC Developer's Guide
Library Name : PrintDC.dll
DLL Name : PrEngineCE.dll

PrintDC is a set of printing-related functions exported by the PrinterCE DLL (named PrEngineCE.dll) that closely emulate the standard Windows printing process. PrintDC assists Windows CE C/C++/MFC developers in porting applications from Windows as well as developers who are familiar with the standard Windows printing process. While the PrinterCE control offers many benefits for most Windows CE apps that need printing, PrintDC can speed the task of porting printer functionality from an existing Windows app.

In order to emulate the standard Windows printing process as closely as possible, it was necessary to design PrintDC for use as a set of standard DLL-exported functions rather than as an ActiveX control like PrinterCE. This prevents use of PrintDC by eVB, but provides easy use by eVC/VCCE in C/C++/MFC apps. Note that PrintDC's functions closely emulate the Windows CE HPC and HPC/Pro printing functions. PrintDC is a part of PrinterCE SDK and works on Pocket PC, HPC/Pro and HPC 2000 devices.

Quick Overview of Printing Process Using PrintDC:

Below is an outline of the typical steps involved with using PrintDC to print on Windows CE devices. Notice that all PrintDC functions begin with the PDC_ prefix, but anyone familiar with standard Windows printing will easily recognize these steps:

bullet

PDC_PrintDlg() - Puts up "Select Printer" dialog box, returns printer DC (device context) and other printer info.

bullet

PDC_SetAbortProc() - Establish abort query handler which main app is responsible for.

bullet

PDC_StartDoc() - Start printing document

bullet

PDC_StartPage() - Start next page

bullet

PDC GDI calls to draw printing data to printer device context (see functions below)

bullet

PDC_EndPage() - print out this page... if more pages to print, loop back to PDC_StartPage()

bullet

PDC_EndDoc() - done with the document - close printer connection

bullet

PDC_DeleteDC() - delete Printer DC.

Notes:

bullet

Fonts, pens, and brushes can be created using all standard functions (such as CreateFontIndirect(), etc).. See limitations under PDC_SelectObject() below.

bulletBitmaps and DIBSections can be created in any desired way. PDC_CreateCompatibleDC() is then used to create a memDC, the image is selected into the printer DC via PDC_SelectObject() and “printed” via PDC_BitBlt() or PDC_StretchBlt(). 
bullet See example code here for code to load BMP file into a DibSection and print it - look for definition and usage of CELoadDIBSectionFromBMPFile())
bulletNote: Line drawing is done via PDC_Polyline().  

 

PrintDC Special Functions:
The main set of PrintDC functions are equivalent to the standard set of Windows printing-related functions (see below). The "Special Functions" here are setup, cleanup and status checking functions for PrintDC.

int PDC_Init(LPTSTR szInitString) 
Handles all startup and initialization processes for PrintDC and PrinterCE controls. szInitString is the License Key to “unlock” PrintDC (works as PrinterCE License Key also). Returns FALSE (0) if successful. This MUST be the first PrintDC function called.

int PDC_UnInit()
Shuts down PrintDC and frees up resources used. Returns FALSE if no error.

void PDC_PrDialogBox(int Operation)
Same as PrinterCE's PrDialogBox(). Pass
vbDlgBoxDisable to force PrintDC to not display the "Printing in Progress" screen during printing.

void PDC_SetReportLevel(long ReportLevel)
Same as PrinterCE's SetReportLevel(). Pass 0 (default) if PrintDC should notify users of printing errors, 1 if no PrintDC error boxes, 3 for no error dialogs and to skip Cancel Y/N dialog.

int PDC_SetScaleMode(long value)
Same as PrinterCE's ScaleMode().

int PDC_StatusCheck()
Same as PrinterCE's StatusCheck(). Returns current status of PrintDC:
bullet0 – no error
bullet1 – User cancelled print job
bullet2 – Error aborted print operation (such as image not found error) but print job is still viable).
bullet3 – Error aborted print job

int PDC_GetVersion()
Same as PrinterCE's GetVersion().Returns current version of PrintDC/PrinterCE (multiplied by 1000, so v2.0 returns as 2000)

HDC PDC_GetPrinterDC()
Returns printer DC (Device Context). NOTE: This can ONLY be used with the PDC_ functions that need a DC... this MUST NOT be used with non-PrintDC functions.

bool PDC_SetupPrinter()
bool PDC_SetupPrinterOther()
bool PDC_SetupPaper()
bool PDC_SetupNetPath()
Similar to PrinterCE's equivalent SetupPrinter(), SetupPrinterOther(), SetupPaper() and SetupNetPath() functions. Call to programmatically set printer, paper and connection settings, then call PDC_PrintDlg() with PD_RETURNDEFAULTDC bitflag to skip Select Printer dialog. These return TRUE if successful, FALSE if error is found.

PDC_SetupPrinter() has one additional parameter (OpenPort)  that is not found for SetupPrinter():

  SetupPrinter(long Printer,long Port, long Baudrate,bool OpenPort).

If OpenPort is TRUE, it causes the printer communication to be established before PDC_SetupPrinter() returns. If OpenPort is FALSE, the printer communication is not established until PDC_EndDoc or PDC_EndPage is called.

 

PrintDC's Standard Printing Functions:
Note: See eVC HPC & HPC/Pro documentation for full details of these functions.

PDC_BitBlt()
PDC_CreateCompatibleDC
()
PDC_DeleteDC
()
PDC_DrawText
()
PDC_Ellipse
()
PDC_EndDoc
()
PDC_EndPage
()
PDC_ExtTextOut
()
PDC_GetDeviceCaps
()
PDC_GetLastError
()

PDC_GetTextExtentExPoint
()

PDC_GetTextExtentPoint
()
PDC_GetTextMetrics
()
PDC_PageSetupDlg
()
PDC_Polyline
()
PDC_PrintDlg
()
PDC_Rectangle
()

PDC_RoundRect
()
PDC_SelectObject
()
PDC_SetAbortProc
()
PDC_SetBkColor
()
PDC_SetBkMode
()
PDC_SetROP2
()
PDC_StartDoc
()
PDC_StartPage
()
PDC_StretchBlt
()
PDC_SetTextColor
(
)

-------------------

BOOL PDC_BitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop)

HDC PDC_CreateCompatibleDC(HDC hdc)

BOOL PDC_DeleteDC(HDC hdc)

int PDC_DrawText(HDC hPrDC,LPTSTR lpString,int nCount,LPRECT lpRect,UINT uFormat) – NOTE: PDC_DrawText, like it's WinCE counterpart DrawText() doesn’t properly support rotated text. So be aware that any usage of DrawText will not currently work properly for Landscape printing.

BOOL PDC_Ellipse(HDC hdc,int nLeftRect, int nTopRect, int nRightRect,int nBottomRect)

int PDC_EndDoc(HDC hdc)

int PDC_EndPage(HDC hdc)

BOOL PDC_ExtTextOut(HDC hdc,int X, int Y, UINT fuOptions, const RECT *lprc, LPTSTR lpString, UINT cbCount,const int *lpDx) – Not supported options:
bulletfuOptions always 0
bulletlprc always NULL
bulletlpDx always NULL

int PDC_GetDeviceCaps(HDC hdc,int nIndex) – supported nIndex values:

bulletHORZRES
bulletVERTRES
bulletPHYSICALWIDTH
bulletPHYSICALHEIGHT
bulletPHYSICALOFFSETX
bulletPHYSICALOFFSETY
bulletLOGPIXELSX
bulletLOGPIXELSY
bulletBITSPIXEL
bulletPLANES
bulletNUMCOLORS
DWORD PDC_GetLastError()

BOOL PDC_GetTextExtentExPoint(HDC hdc,LPTSTR lpszStr, int cchString,int nMaxExtent,LPINT lpnFit, LPINT alpDx, LPSIZE lpSize)

BOOL PDC_GetTextExtentPoint(HDC hdc,LPTSTR lpszStr, int cbString,LPSIZE lpSize)

BOOL PDC_GetTextMetrics(HDC hdc,LPTEXTMETRIC lptm) – fully supported

BOOL PDC_PageSetupDlg(LPPAGESETUPDLG lppsd ) – Same as HPC/Pro PageSetupDlg. Primary difference – you do not use CreateDC() with pDriverName, pDeviceName, pPort, and lpDevMode to get printer DC – just access the global “PDC_hPrDC” value after PDC_PageSetupDlg() returns. Valid “Flags” :
bulletPSD_INTHOUSANDTHSOFINCHES
bulletPSD_INHUNDREDTHSOFMILLIMETERS
bulletPSD_MARGINS
bulletPSD_RETURNDEFAULT

BOOL PDC_Polyline(HDC hdc,const POINT * lppt, int cPoints)

void PDC_PrDialogBoxText(LPTSTR MainText, LPTSTR TitleText, LPTSTR CancelBtnText)

BOOL PDC_PrintDlg(LPPRINTDLG lppd) – Same as HPC PrintDlg() – can be used instead of PDC_PageSetupDlg().  Valid “dwFlags” :
bulletPD_SELECTDRAFTMODE
bulletPD_SELECTLETTER
bulletPD_SELECTA4
bulletPD_SELECTINFRARED
bulletPD_SELECTSERIAL
bulletPD_SELECTPORTRAIT
bulletPD_SELECTLANDSCAPE
bulletPD_INTHOUSANDTHSOFINCHES
bulletPD_INHUNDREDTHSOFMILLIMETERS
bulletPD_MARGINS
bulletPD_RETURNDEFAULTDC
BOOL PDC_Rectangle(HDC hdc,int nLeftRect, int nTopRect, int nRightRect,int nBottomRect)

BOOL PDC_RoundRect(HDC hdc,int nLeftRect, int nTopRect, int nRightRect,int nBottomRect, int nWidth, int nHeight)

HGDIOBJ PDC_SelectObject(HDC hdc,HGDIOBJ hgdiobj) – Used to select any valid HFONT, HBRUSH, HPEN, HBITMAP, or HDIBSECTION into the PrintDC DC. Note that only solid Pens and Brushes are supported.

int PDC_SetAbortProc(HDC hdc,ABORTPROC lpAbortProc)

COLORREF PDC_SetBkColor(HDC hPrDC,COLORREF crColor)

int PDC_SetBkMode(HDC hPrDC,int iBkMode)

int PDC_SetROP2(HDC hPrDC,int fnDrawMode)

int PDC_StartDoc(HDC hdc,const DOCINFO * lpdi)

int PDC_StartPage(HDC hdc)

BOOL PDC_StretchBlt(HDC hdcDest,int nXOriginDest,int nYOriginDest,int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc,int nYOriginSrc, int nWidthSrc, int nHeightSrc, DWORD dwRop)

COLORREF PDC_SetTextColor(HDC hPrDC,COLORREF crColor)