Mi aplicaciones usa 4 impresoras siempre hay alguna por defecto, cambie la version al compilador 16.02 y la clase printer aunque direccione las impresoras correctamente, siempre imprime en la impresora por defecto. Tomando el printer.prg de la version 10.08 funciona correctamente.
Saludos
Andres.
Impresora por defecto
Re: Impresora por defecto
No dimos cuenta que el problema se genera cuando se usa el PRINTBEGIN.
Saludos
Saludos
Re: Impresora por defecto
Mira se es esto:
Cambia PRINTER.PRG
Cambia PRINTER.PRG
Code: Select all
METHOD New( cDocument, lUser, lPreview, cModel, lModal, lSelection, cFile ) CLASS TPrinter
local aOffset
local cPrinter
DEFAULT cDocument := "FiveWin Report" ,;
lUser := .f., lPreview := .f., lModal := .f., lSelection := .f.
lPreview := .t.
if lUser
::hDC := GetPrintDC( GetActiveWindow(), lSelection, PrnGetPagNums() )
if ::hDC != 0
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
endif
elseif cModel == nil // Modified: 16/01/2014
::hDC := GetPrintDefault( GetActiveWindow() )
//cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
// MUDEI EM: 08/03/2016 - Joao
if ::hDC != 0
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
endif
SetPrintDefault( cModel ) // NEW !!! // 16/01/2014 Joao
else
cPrinter := GetProfString( "windows", "device" , "" )
WriteProfString( "windows", "device", cModel )
SysRefresh()
PrinterInit()
::hDC := GetPrintDefault( GetActiveWindow() )
SysRefresh()
WriteProfString( "windows", "device", cPrinter )
SetPrintDefault( cPrinter ) // NEW !!! Antonio Linares
endif
if ::hDC != 0
aOffset = PrnOffset( ::hDC )
::nXOffset = aOffset[ 1 ]
::nYOffset = aOffset[ 2 ]
::nOrient = ::GetOrientation()
elseif ComDlgXErr() != 0
MsgStop( "There are no printers installed!" + CRLF + ;
"Please exit this application and install a printer." )
::nXOffset = 0
::nYOffset = 0
else
::nXOffset = 0
::nYOffset = 0
::nOrient = DMORIENT_PORTRAIT
endif
::cDocument = cDocument
::cModel = cModel
::nPage = 0
::nPad = 0
::lMeta = .f.
::lPreview = lPreview
::lStarted = .F.
::lModified = .F.
::lPrvModal = lModal
if ! Empty( cFile ) .and. Lower( Right( cFile, 3 ) ) == "pdf"
::cFile = cFile
::lMeta = .t.
elseif ::lPreview
::lMeta = .t.
endif
if ! ::lMeta
::hDcOut = ::hDC
else
::aMeta = {}
::cDir = GetEnv( "TEMP" )
if Empty( ::cDir )
::cDir = GetEnv( "TMP" )
endif
if Right( ::cDir, 1 ) == "\"
::cDir = SubStr( ::cDir, 1, Len( ::cDir ) - 1 )
endif
if ! Empty( ::cDir )
if ! lIsDir( ::cDir )
::cDir = GetWinDir()
endif
else
::cDir := GetWinDir()
endif
endif
return Self
João Santos - São Paulo - Brasil
Re: Impresora por defecto
Gracias lo voy a probar.
Saludos
Andres
Saludos
Andres
Re: Impresora por defecto
Gracias Karinha, haciendo las modificaciones en las lineas 10, 31 y 49 anduvo todo bien. La linea 10 por cuestiones obvias, la 31 provocaba el cambio no deseado de la impresora por default de windows y la 49 por la misma razon. Vevificada la 49 en el fuente de printer.prg del mes 8 del 2010 y del mes 8 de 2013.
Muchas gracias.
Andres
Muchas gracias.
Andres
Code: Select all
METHOD New( cDocument, lUser, lPreview, cModel, lModal, lSelection, cFile ) CLASS TPrinter
local aOffset
local cPrinter
DEFAULT cDocument := "FiveWin Report" ,;
lUser := .f., lPreview := .f., lModal := .f., lSelection := .f.
// lPreview := .t. Modificado 29/01/2016
if lUser
::hDC := GetPrintDC( GetActiveWindow(), lSelection, PrnGetPagNums() )
if ::hDC != 0
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
endif
elseif cModel == nil // Modified: 16/01/2014
::hDC := GetPrintDefault( GetActiveWindow() )
//cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
// MUDEI EM: 08/03/2016 - Joao
if ::hDC != 0
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
endif
// SetPrintDefault( cModel ) // NEW !!! // 16/01/2014 Joao Modificado 29/01/2016 Para no modificar la impresora por default
else
cPrinter := GetProfString( "windows", "device" , "" )
WriteProfString( "windows", "device", cModel )
SysRefresh()
PrinterInit()
::hDC := GetPrintDefault( GetActiveWindow() )
SysRefresh()
WriteProfString( "windows", "device", cPrinter )
// SetPrintDefault( cPrinter ) // NEW !!! Antonio Linares Modificado 29/01/2016 Para no modificar la impresora por default
endif
if ::hDC != 0
aOffset = PrnOffset( ::hDC )
::nXOffset = aOffset[ 1 ]
::nYOffset = aOffset[ 2 ]
::nOrient = ::GetOrientation()
elseif ComDlgXErr() != 0
MsgStop( "There are no printers installed!" + CRLF + ;
"Please exit this application and install a printer." )
::nXOffset = 0
::nYOffset = 0
else
::nXOffset = 0
::nYOffset = 0
::nOrient = DMORIENT_PORTRAIT
endif
::cDocument = cDocument
::cModel = cModel
::nPage = 0
::nPad = 0
::lMeta = .f.
::lPreview = lPreview
::lStarted = .F.
::lModified = .F.
::lPrvModal = lModal
if ! Empty( cFile ) .and. Lower( Right( cFile, 3 ) ) == "pdf"
::cFile = cFile
::lMeta = .t.
elseif ::lPreview
::lMeta = .t.
endif
if ! ::lMeta
::hDcOut = ::hDC
else
::aMeta = {}
::cDir = GetEnv( "TEMP" )
if Empty( ::cDir )
::cDir = GetEnv( "TMP" )
endif
if Right( ::cDir, 1 ) == "\"
::cDir = SubStr( ::cDir, 1, Len( ::cDir ) - 1 )
endif
if ! Empty( ::cDir )
if ! lIsDir( ::cDir )
::cDir = GetWinDir()
endif
else
::cDir := GetWinDir()
endif
endif
return Self