(cPrinter is the name of the printer to use. Selected by user via PrinterSetup() and saved to a text file.)
- Code: Select all Expand view RUN
- XPRINTER oPrn PREVIEW MODAL NAME cRptTitle to cPrinter
This code works with my old version of FWH11.08.
With FWH1912+Harbour, if I set printer to "Microsoft Print To Pdf", it will generate error because hDC is 0.
When I compare TPrinter:new() between the FWH1108 and FWH1912 versions, the difference is the usage of PrinterDcFromName() in FWH1912
- Code: Select all Expand view RUN
// FWH1912
if lUser
::hDC := GetPrintDC( GetActiveWindow(), lSelection, PrnGetPagNums() )
if ::hDC != 0
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
endif
elseif cModel == nil
::hDC := GetPrintDefault( GetActiveWindow() )
if ::hDC != 0
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
endif
else
::hDC = PrinterDcFromName( , cModel, )
endif
- Code: Select all Expand view RUN
//FWH1108
if lUser
::hDC := GetPrintDC( GetActiveWindow(), lSelection, PrnGetPagNums() )
if ::hDC != 0
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
endif
elseif cModel == nil
::hDC := GetPrintDefault( GetActiveWindow() )
if ::hDC != 0
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
endif
else
cPrinter := GetProfString( "windows", "device" , "" )
WriteProfString( "windows", "device", cModel )
SysRefresh()
PrinterInit()
::hDC := GetPrintDefault( GetActiveWindow() )
SysRefresh()
WriteProfString( "windows", "device", cPrinter )
// PrinterInit()
// DeleteDC( ::hDC )
// ::hDC = PrinterDCfromName( cModel )
endif
I tested replacing PrinterDcFromName( , cModel, ) with the old code and it works.
So what is the accurate solution? I don't want to have to manually linked-in a fixed version of TPrinter.
TIA