PrinterCE
SDK Special Topics
.Net CF C# or VB.Net: Printing Utilities |
Option Explicit Const vbCenter = 2 Const vbDlgBoxUp = 0 Const vbDlgBoxDown = 1 Const vbDlgBoxDisable = 2 Const vbDlgBoxStatus = 3 Const vbDlgBoxUserCancel = 4 Const vbDlgBoxAbortError = 5 Const vbErrNone = 0 Const vbErrUserCancel = 1 Const vbErrAbortOperation = 2 Const vbErrAbortPrint = 3 Const vbTwips = 1 Const vbPoints = 2 Const vbPixels = 3 Const vbInches = 5 Const vbMillimeters = 6 Const vbCentimeters = 7 '-------------------------------------- Dim PrinterCE1 Set PrinterCE1 = CreateObject("PrEngineCE.PrinterCE") Thumb ' Call our subroutine '-------------------------------------- Private Sub Thumb() AddObject "FILECTL.FileSystem","FS" 'eVB Dim FS As FILECTL.FileSystem 'eVB Set FS = CreateObject("filectl.filesystem") Dim nxtfile 'Demo changing text in dialog box... could be in any language PrinterCE1.PrDialogBoxText "Main", "Title", "Check It Out" PrinterCE1.SelectPrinter Dim rval rval = PrinterCE1.PrDialogBox(vbDlgBoxUp) Dim dirstr dirstr = "/Images/" nxtfile = FS.Dir(dirstr & "*.*") PrinterCE1.ScaleMode = vbInches 'Lets do everything in inches Dim nextx, nexty, wid, ht, deltax, deltay, txtht, loopcnt PrinterCE1.FontSize = 10 'Get text height of 10 points in inches scalemode txtht = PrinterCE1.ConvertCoord(10, vbPoints, -1) / 2 deltax = PrinterCE1.PrPgWidth / 4 deltay = PrinterCE1.PrPgHeight / 4 wid = deltax * 0.8 ht = deltay * 0.8 PrinterCE1.JustifyHoriz = vbCenter 'Center images & text PrinterCE1.JustifyVert = vbCenter nextx = deltax / 2 nexty = ht / 2 loopcnt = 0 Do While (nxtfile <> "") loopcnt = loopcnt + 1 If (loopcnt > 3) Then loopcnt = 0 PrinterCE1.DrawPicture dirstr & nxtfile, nextx, nexty, wid, ht, True If (PrinterCE1.StatusCheck > 0) Then 'if image didn't print... don't change x,y coords, just ignore If (PrinterCE1.StatusCheck <> vbErrAbortOperation) Then MsgBox "Operation cancelled or fatal error" Exit Do End If Else ' Reached here, lets print out file name PrinterCE1.DrawText nxtfile, nextx, nexty + ht / 2 + txtht nextx = nextx + deltax If (nextx > PrinterCE1.PrPgWidth) Then nextx = deltax / 2 nexty = nexty + deltay If (nexty > PrinterCE1.PrPgHeight) Then PrinterCE1.NewPage nexty = ht / 2 End If End If End If nxtfile = FS.Dir() Loop PrinterCE1.EndDoc End Sub |