Hi again, ...
as promised, here is the
Link to my little ezPrint-Library (in an imho "unreleasable", but nevertheless "working" state).
Attached please find a little Demo-Code to see what's possible so far:
Code: Select all
EnableExplicit
#ezPrint_IncludeDebugHandling = #True ; see "Lib_ezPrint.pbi" at Line 12 for more information on that constant
XIncludeFile "..\Includes\Lib_ezPrint.pbi" ; File available at: http://www.bmi-online.de/public/PB-Sources/Includes/Lib_ezPrint.pbi
; With the global variable "ezPrint_DebugInfoLevel", you can set the level of debuginfo the ezPrint-Functions will post into the debug-channel
; ezPrint_DebugInfoLevel = #ezPrint_Debug_SimpleInfo
; ezPrint_DebugInfoLevel = #ezPrint_Debug_DetailedInfo
ezPrint_DebugInfoLevel = #ezPrint_Debug_NoDebugInfo
; First, you "could" call "ezPrint_Initialize()", to initialize the ezPrint-Functions
; This is not really necessary, because ezPrint_Initialize() will be called from within the ezPrint-Functions if necessary.
ezPrint_Initialize()
; After calling ezPrint_Initialize(), there are 2 internal LinkedList ("ezPrintInt_PrinterList()" and "ezPrintInt_DetailedPrinterList()") with a List of all installed Printerdevices.
; See Debug-output for more information.
; Because this list is used internally, be carefull if you use it as well.
; If you want to get these informations in an own list you could do it by using the functions "ezPrint_GetPrinterList()" and "ezPrint_GetDetailedPrinterList()":
; (see Debug-Output and the structures "ezPrintStruc_PrinterSimpleInfo" and "ezPrintStruc_PrinterDetailedInfo" for more Informations on the received Info.)
Define NumberOfAvailablePrinters.l
NewList AvailablePrinters.ezPrintStruc_PrinterSimpleInfo()
NewList PrinterDetails.ezPrintStruc_PrinterDetailedInfo()
ezPrint_DebugInfoLevel = #ezPrint_Debug_DetailedInfo ; Turn Debug-Output on, to see which informations will be received by "ezPrint_GetPrinterList()" and "ezPrint_GetDetailedPrinterList()"
NumberOfAvailablePrinters = ezPrint_GetPrinterList(AvailablePrinters())
NumberOfAvailablePrinters = ezPrint_GetDetailedPrinterList(PrinterDetails())
ezPrint_DebugInfoLevel = #ezPrint_Debug_NoDebugInfo ; Turn Debug-Output off, because we don't want to get more debug-infos for now
; You can get the Name of the Default-Printer
Debug "" : Debug "----- Result of: ezPrint_GetDefaultPrinter()"
Debug ezPrint_GetDefaultPrinter()
; And you can SELECT a Printer outof the created internal List:
; The "Selected" Printer will be used from most ezPrint-Functions as default, if you do not specify a printer by calling these ezPrint-Functions
Debug "" : Debug "----- Result of: ezPrint_SelectPrinterByName()"
Debug ezPrint_SelectPrinterByName("zebra") ; <========= replace "zebra" with the name (or part of the name) of one of your printers
; ezPrint_SelectPrinterByName() will return "#ezPrint_Error", if it cannot find a Printer in the List with the given Name
; "1", if it has found a Printer with the exact given Name
; "2", if it hase found a Printer, where the given Name is a part of the printers name
; to get the actual selected Printer, you can use: ezPrint_GetSelectedPrinterName()
Debug "" : Debug "----- Result of: ezPrint_GetSelectedPrinterName()"
Debug ezPrint_GetSelectedPrinterName()
; You can "OPEN" a printer by using "ezPrint_OpenPrinter()", and GET information for a single Printer by using "ezPrint_GetPrinterDetails()".
; (SETTING values to a Printer is not supported so far.
; So, opening a printer just to get Details for the Printer is not realy necessary, if you have used "ezPrint_GetDetailedPrinterList()" already,
; because you will have the same information for ALL printers already in a LinkedList given to ezPrint_GetDetailedPrinterList())
; See Debug-Output and the structure "ezPrintStruc_PrinterDetailedInfo" for more information on the received Details
Define PrinterHandle.i
Define PrinterInfo.ezPrintStruc_PrinterDetailedInfo
PrinterHandle = ezPrint_OpenPrinter(0,"Kyocera") ; <========= replace "Kyocera" with the name (or part of the name) of one of your printers
; ezPrint_OpenPrinter() returns "#ezPrint_Error", if it cannot find a Printer with the given Name
; the handle to the Printer, if you've specified the Printer-ID ("0" in the example above)
; a PB-like ID, if you passed #PB_Any as the Printer-ID
; If you open a Printer, if will be added to the internal "Opened Printer List": ezPrintInt_OpenedPrinters()
; the stored Details are among other things:
; (see structure "ezPrintStruc_PrinterDetailedInfo" for more Details)
If PrinterHandle
Debug "" : Debug "----- Opened Printer '" + ezPrintInt_OpenedPrinters()\Info\Name + "' by 'ezPrint_OpenPrinter()'"
Debug "Assigned 'PB-like' Printer-ID: "+Str(ezPrintInt_OpenedPrinters()\PrinterID)
Debug "API-Handle to this Printer: "+Str(ezPrintInt_OpenedPrinters()\hPrinter)
; You can get the Status of an opened Printer by using "ezPrint_GetPrinterStatus()"
; See "http://msdn.microsoft.com/en-us/library/dd162845(VS.85).aspx" or the #Printer_Status_xxx Constants for more Information on the possible Printer states
Debug "Printer status: "+Str(ezPrint_GetPrinterStatus()) : Debug ""
; You can get/refresh the details of an opened Printer by using "ezPrint_GetPrinterDetails(@PrinterInfo)"
; See Debug-Output and structure "ezPrintStruc_PrinterDetailedInfo" for more information on the received informations
ezPrint_DebugInfoLevel = #ezPrint_Debug_DetailedInfo ; Turn Debug-Output on, to see which informations will be received by "ezPrint_GetPrinterDetails()"
ezPrint_GetPrinterDetails(@PrinterInfo)
Debug "" : Debug "Printerdetails of '" + PrinterInfo\PrinterName + "' -> PaperWidth: " + StrF(PrinterInfo\dmPaperWidth / 100,2) + "mm, PaperLength: " + StrF(PrinterInfo\dmPaperLength / 100,2) + "mm" : Debug ""
ezPrint_DebugInfoLevel = #ezPrint_Debug_NoDebugInfo ; Turn Debug-Output off, because we don't want to get more debug-infos for now
; Use "ezPrint_ClosePrinter()" to close an previously opened printer
ezPrint_ClosePrinter()
EndIf
; Further you can get a List of all bins, supported by a specific printer:
ezPrint_DebugInfoLevel = #ezPrint_Debug_DetailedInfo ; Turn Debug-Output on, to see the List of Bins received by "ezPrint_GetBinList()"
NewList BinList.ezPrintStruc_BinInfo()
ezPrint_GetBinList(BinList(), #ezPrint_SystemDefaultPrinter) ; Get the Bin-List of the System-Default-Printer
ezPrint_DebugInfoLevel = #ezPrint_Debug_NoDebugInfo ; Turn Debug-Output off, because we don't want to get more debug-infos for now
;=======================================================================================================
; Finally we start printing, by using "ezPrint_StartPrintJob()" to create a Printjob
; ezPrint_StartPrintJob() will give back a PB-like ID.
; Because you can initialize more than one PrintJobs at a time with ezPrint, you can use this ID to get the related DC by using "ezPrint_GetPrintJobOutputDC(PrintJobID)".
; ===== Note =====
; If you do not need all the informations you could get trough the ezPrint-Functions introduced above,"ezPrint_StartPrintJob()" is the only ezPrint-Function you need
; to start a printout. Further you may need "ezPrint_GetPrintJobOutputDC()" to get the Output-DC and "ezPrint_StopPrintJob()" to close the PrintJob and start printing.
Define PrintJobID.l
Define PrintJobDC.i
PrintJobID = ezPrint_StartPrintJob() ; Without a specified PrintJob- and Printername, ezPrint_StartPrintJob() uses the default PrintJob-Name and the last selected printer.
If PrintJobID <> #ezPrint_Error
PrintJobDC = ezPrint_GetPrintJobOutputDC(PrintJobID) ; Without a specified PrintJobID, ezPrint_GetPrintJobOutputDC() will return the DC of the last selected/initialized PrintJob.
Debug "" : Debug "----- PrintJob started For Printer: " + ezPrintInt_StartedPrintJobs()\PrinterName
Debug "ID of the PrintJob: "+Str(PrintJobID)
Debug "DC of the PrintJob: "+Str(PrintJobDC)
Debug "Name of the initialized PrintJob: " + ezPrintInt_StartedPrintJobs()\PrintJobName
Debug "Driver used for this PrintJob: " + ezPrintInt_StartedPrintJobs()\PrinterDriver
Define Text.s = "This is a Test-Printout, using the ezPrint_()-Library"
TextOut_(ezPrint_GetPrintJobOutputDC(), 300, 100, Text, Len(Text))
ezPrint_StopPrintJob()
Debug "" : Debug "PrintJob closed by 'ezPrint_StopPrintJob()'"
Debug "Printing will start immediately."
EndIf
Most of the Lib will be rewritten (to get things cleaned up) and some Functions has to be added to be able to "SET" some Printer-Settings.
Nevertheless I hope that it will be useful to you (or someone else) in some kind - even though it's not cleaned up an finished yet.
Greetz from Germany,
PL.
PS: The ezPrint-Lib will XInclude the file: "Proc_GetLastErrorInfo.pbi"
You will find the Download-Link to that right behind the XInclude-Command within the ezPrint-Source at line 25.