LPARA ; PrinterName LOCAL ; oPrtFunction, ; PrtHandel, ; nNumberColor, ; PrintTTFasGraphic #DEFINE NUMCOLORS 24 #DEFINE DC_TRUETYPE 15 #DEFINE DCTT_BITMAP 0x0000001 * *** PRINTER IS dot-matrix WHEN NUMBER OF maximum COLORS = 16 * *** AND WHEN PRINTER PRINTS TRUETYPE FONTS AS graphics * *** for this to work it seems that the printer (driver) has * *** to be installed on the local computer * *** which is ok, since we install the printer driver * *** on the computer with the printer_function class * *** before we would call this DECLARE INTEGER GetDeviceCaps IN gdi32.DLL ; INTEGER hdc, ; INTEGER nIndex DECLARE LONG DeviceCapabilities IN "winspool.drv" ; STRING lpDeviceName, ; STRING lpPort, ; LONG iIndex, ; STRING@ lpOutput, ; INTEGER lpDevMode * *** oPrtFunction = EVAL(THIS.oPrtFunction) PrtHandel = m.oPrtFunction.OpenPrinter(m.PrinterName) IF PrtHandel > 0 nNumberColor = GetDeviceCaps(PrtHandel, NUMCOLORS) m.oPrtFunction.ClosePrinter(PrtHandel) ELSE * *** we were unable to open the printer * *** just set the colors to any number higher then 16 * *** that way we set the printer to a non-dot-metrix nNumberColor = 256 ENDIF * *** PrintTTFAsGraphic = DeviceCapabilities(m.PrinterName, m.PrinterName, DC_TRUETYPE, "", 0) IF m.PrintTTFAsGraphic <= 0 * *** we were unable to get font info from the printer * *** just set it to anything else then 1 * *** that way we set the printer to a non-dot-metrix PrintTTFAsGraphic = 3 ENDIF IF ; m.nNumberColor <= 16 .AND. ; m.PrintTTFAsGraphic = DCTT_BITMAP * *** number of colors is smaler or equal then 16 * *** and the printer prints true type fonts as graphics * *** its a dot-metrix printer THIS.PrinterIsDotMatrix = .T. ELSE THIS.PrinterIsDotMatrix = .F. ENDIF THIS.REFRESH() procedure oPrtFunction.OpenPrinter LPARA ; PrinterPath, ; hPrinterHandle LOCAL ; ReturnString, ; ErrCode ReturnString = 0 IF PCount() = 1 hPrinterHandle = 0 ENDIF DECLARE INTEGER GetLastError IN kernel32 DECLARE INTEGER OpenPrinter IN winspool.drv; STRING pPrinterName, ; INTEGER @PrHandel, ; STRING pDefault OpenPrinter(m.PrinterPath, @hPrinterHandle, .NULL.) IF m.hPrinterHandle = 0 * *** there was an error opening the printer ErrCode = GetLastError() This.AddPrinter_ErrCode = m.ErrCode This.AddPrinter_ErrMsg = oToolBox.oGlobalStr.ApiErrorText(This.AddPrinter_ErrCode) IF VERSION(2) > 0 MESSAGEBOX(; "Unable To Open Printer" +CHR(13)+ ; "- " + m.PrinterPath +CHR(13)+CHR(13)+ ; TRANSFORM(This.AddPrinter_ErrCode) + " - " + This.AddPrinter_ErrMsg, 0, "I've got a problem") ENDIF else ReturnString = m.hPrinterHandle ENDIF RETURN(m.ReturnString) endproc procedure oPrtFunction.ClosePrinter LPARA ; PrHandel LOCAL ; ErrCode ErrCode = 0 DECLARE INTEGER GetLastError IN kernel32 DECLARE INTEGER ClosePrinter IN winspool.drv ; INTEGER PrHandel IF ClosePrinter(PrHandel) = 0 * *** we had a problem closing the printer ErrCode = GetLastError() IF VERSION(2) > 0 MESSAGEBOX(TRANSFORM(ErrCode) + " - " + oToolBox.oGlobalStr.ApiErrorText(ErrCode), 0, "I've got a problem") endif ENDIF RETURN(ErrCode) endproc