Impresora por defecto

Impresora por defecto

Postby acartucho » Mon Mar 28, 2016 2:32 pm

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.
acartucho
 
Posts: 58
Joined: Thu Nov 02, 2006 1:17 pm

Re: Impresora por defecto

Postby acartucho » Mon Mar 28, 2016 3:36 pm

No dimos cuenta que el problema se genera cuando se usa el PRINTBEGIN.
Saludos
acartucho
 
Posts: 58
Joined: Thu Nov 02, 2006 1:17 pm

Re: Impresora por defecto

Postby karinha » Mon Mar 28, 2016 7:21 pm

Mira se es esto:

Cambia PRINTER.PRG

Code: Select all  Expand view

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 - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Impresora por defecto

Postby acartucho » Tue Mar 29, 2016 11:06 am

Gracias lo voy a probar.

Saludos

Andres
acartucho
 
Posts: 58
Joined: Thu Nov 02, 2006 1:17 pm

Re: Impresora por defecto

Postby acartucho » Tue Mar 29, 2016 12:18 pm

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  Expand view

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

acartucho
 
Posts: 58
Joined: Thu Nov 02, 2006 1:17 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 78 guests