seleccionar impresoras

Post Reply
chocochester
Posts: 14
Joined: Mon Oct 24, 2005 3:24 pm

seleccionar impresoras

Post by chocochester »

Hola. He probado miles de cosas de www.fivewin.info y he leido aki en el foro pero no consigo solucionar esto. Tengo un programa de gestion y kiero imprimir tickets por el lpt1 (epson tmu220) y albaranes por el usb (oki 5400). Si pongo:
cPrinter:="OKI C5400n(PCL)"
PRINT OPRN NAME "PRESUPUESTO " TO alltrim(cPrinter)
me sale para seleccionar la impresora, no me imprime directamente a esa impresora. si pongo:
from user , entonces me imprime en la que seleccione pero con los tamaños de papel de la otra, ufff, no se que hacer. Como dirijo una impresión a la impresora que quiera en cada momento?

FW2.4, clipper 5.2, blinker 6.0, windows xp sp2

Gracias.
User avatar
Willi Quintana
Posts: 859
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú
Contact:

Post by Willi Quintana »

Hola,,,
Para imprimir en una TMU, debes usar la clase TDOSPrint, alli direccionas en que puerto esta conectada,, (LPT1, LPT2, LPT3) y listo,,,, para la impresora USB, usas la report u otra que trabaje en la impresora por defecto,,,

Salu2
Willi
chocochester
Posts: 14
Joined: Mon Oct 24, 2005 3:24 pm

Post by chocochester »

hola willi. Nunca he usado esta clase. La he bajao de la web www.fivewin.info, la incluyo en mi compilación y me da fallos. Por ejemplo me dice que este exe tiene mas de 254 segmentos. Luego hay un include de "dr.ch". No se, estoy atascado. Puedes indicarme como usar esta clase ? Gracias.
User avatar
dbSoft
Posts: 16
Joined: Thu Oct 13, 2005 8:31 pm
Location: Greece
Contact:

Post by dbSoft »

Code: Select all

//---------------------------
Function AGetPrinters()
//---------------------------
Local aPrinters, cText, cToken := Chr(15)

// Passing no second param or passing ZERO to GetProfStr()
// grabs entire section in .ini file.  Each printer is separated by a
// null char (Chr(0)) and a CRLF.  We just strip them out
    cText := StrTran( StrTran( StrTran( ;
    GetProfStr( "Devices", 0 ), Chr(0), cToken ), Chr(13) ), Chr(10) )
    aPrinters := Array( Len( cText ) - Len( StrTran( cText, cToken ) ) )
    AEval( aPrinters, {|cPrn,nEle| ;
    aPrinters[nEle] := StrToken( cText, nEle, cToken ) } )

Return aPrinters

/*
  1 Open tdosprn.prg and change the way ::cPort is assigned in method ::New()
  from
    ::cPort       := cPort+iif(!"."$cPort,".PRN","")
  to
    ::cPort        := cPort + If( ! "." $ cPort .and. ! "\\" $ cPort, ".PRN", "" )  // considers the port can be a network route
(\\computername\sharename)

2 use this function to get the path to the network printer.  IE you'll
say wfPrnShName( "PRINTER1" ) and it will return \\computername\sharename.

Note:  make sure you use Patrick Mast's
TReg32 mods if you're not using FW 2.3:
*/

///#include "FiveWin.ch"

//#define  HKEY_LOCAL_MACHINE      2147483650

//---------------------
function mainPrn( cLPT  )
//---------------------
#define  HKEY_LOCAL_MACHINE      2147483650
//// msginfo( wfPrnShName("Epson FX-80+") )
//
return wfPrnShName( cLPT )

//--------------------------------
Function wfPrnShName( cModel )
//--------------------------------
Local oReg, nPos, cComputer, cPrinter, cShare := "", cKeyName

Default cModel := StrToken( GetProfStr( "Windows", "Device", "" ), 1, "," ) // get default printer if not provided

If IsWinNT()   // for W2K,NT4,XP


   IF cNET    //  PARAMETRE FOR Network printer       
    cKeyName := "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\LanMan Print Services\Servers\"
    If Left( cModel, 2 ) == "\\"
       nPos := RAt( "\", cModel )
       cComputer := SubStr( cModel, 3, nPos - 3 )
       cPrinter  := SubStr( cModel, nPos + 1 )

       oReg := TReg32():New( HKEY_LOCAL_MACHINE, ;
          cKeyName + cComputer + "\Printers\" + cPrinter )
       If oReg:nError == 0                        // in case the printer name doesn't exist
          cShare := "\\" + cComputer + "\" + ;    // create in the form of "\\computername\sharename"
                    StrTran( oReg:Get( "Share Name", "" ), Chr(0) )
       Endif
       oReg:close()

    Endif

   ELSE

    cKeyName := "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\"
     oReg := TReg32():New( HKEY_LOCAL_MACHINE, cKeyName + cModel )
    If oReg:nError == 0                           // in case the printer name doesn't exist
       cPrinter := StrTran( oReg:Get( "Port", "" ), Chr(0) )
      /// If Left( cPrinter, 2 ) == "\\"             // if it's not a network printer it returns "LPT1:" or "LPT2:" or whatever applies
          cShare := cPrinter                      // this one is already in the form "\\computername\sharename"
      /// Endif
    Endif
    oReg:close()
   ENDIF



Else           // for Win9x
    cKeyName := "System\CurrentControlSet\Control\Print\Printers\"

    oReg := TReg32():New( HKEY_LOCAL_MACHINE, cKeyName + cModel )
    If oReg:nError == 0                           // in case the printer name doesn't exist
       cPrinter := StrTran( oReg:Get( "Port", "" ), Chr(0) )
      /// If Left( cPrinter, 2 ) == "\\"             // if it's not a network printer it returns "LPT1:" or "LPT2:" or whatever applies
          cShare := cPrinter                      // this one is already in the form "\\computername\sharename"
      /// Endif
    Endif
    oReg:close()

Endif

Return cShare
[/quote]
Post Reply