Page 1 of 1
Impresora por defecto
Posted: Mon Mar 28, 2016 2:32 pm
by acartucho
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.
Re: Impresora por defecto
Posted: Mon Mar 28, 2016 3:36 pm
by acartucho
No dimos cuenta que el problema se genera cuando se usa el PRINTBEGIN.
Saludos
Re: Impresora por defecto
Posted: Mon Mar 28, 2016 7:21 pm
by karinha
Mira se es esto:
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
Re: Impresora por defecto
Posted: Tue Mar 29, 2016 11:06 am
by acartucho
Gracias lo voy a probar.
Saludos
Andres
Re: Impresora por defecto
Posted: Tue Mar 29, 2016 12:18 pm
by acartucho
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
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