Jump to content
Fivewin Brasil

TDOSPRN


Alain da Silva

Recommended Posts

boa tarde, eu utilizo a tdosprn para a impressão em uma epson lx 300 na porta LTP1. porém agora com a troca do equipamento o computador não possui mais porta lpt1 e tive que colocar um adaptador de USB. Agora não funciona mais. Qual  solução para isto? outro programa ou tem solução com a tdosprn? lembrando que é para imprimir cheques

agradeço a ajuda

Link to comment
Share on other sites


USB com TDOSPRN.PRG

Enla cabecera de mi rutina de impresión hice esto:
	cPorta := PrnGetPort()
cPrinter := PrinterPortToName( cPorta )
if empty(cPrinter)
   cPrinter := PrinterPortToName( "USB002" )
   if empty(cPrinter)
      cPrinter := PrinterPortToName( "USB001" )
   endif
endif
 
	Despues empiezo la impresión, preo creando un archivo:
	
oPrin := TDosPrn():New("minuta.txt")
oPrin:StartPage()
...
...
 
	Y en el fin de la rutina hago esto:
	
...
...
oPrin:EndPage()
oPrin:End()
	
PrintFileRaw( cPrinter, TrueName("MINUTA.TXT"), "Impressão de Vendas" )
	

Sds

Link to comment
Share on other sites

23 horas atrás, Eroni disse:

Boa tarde, eu adaptei para usar a tdosprn com visualização pelo tTxtPrev e funciona certinho, inclusive mantenho as duas opções de impressão.

A título de curiosidade, não conheço ttxtprev, poderia disponibilizar informações sobre. Como help, onde baixar ou até mesmo um exemplo se possível. Se É free ?

Link to comment
Share on other sites

Não tenho a tTxtPrev, mas tenho esta rotina que está sendo útil no momento.

FUNCTION MsgPrevew(cSpoolFile, nSkip)
   LOCAL lOk, aText, cText, nMaior, o_Txt, lExit := .F.
   PUBLIC nFont := 3, o_Fnt[9]
   DEFAULT nSkip := 6
   lOk := .f.
   aText := {}
   cText := ""
   nMaior:=0

   o_Txt := MEMOREAD( cSpoolFile )
   nLinh := MLCOUNT(o_Txt)
   for n := 3 TO nLinh
      cLinh := SUBSTR(STRTRAN(MEMOLINE(o_Txt,254,n),"",""), nSkip, 254)
      cText += cLinh + CRLF
      nMaior := IIF(LEN(ALLTRIM(cLinh)) > nMaior, LEN(ALLTRIM(cLinh)), nMaior)
      IF n >= 350
         cText += "--------------------" + CRLF
         cText += "Continua..." + CRLF
         EXIT
      ENDIF
   next

   DEFINE FONT o_Fnt[1] NAME "Courier New" SIZE 0, -09
   DEFINE FONT o_Fnt[2] NAME "Courier New" SIZE 0, -10
   DEFINE FONT o_Fnt[3] NAME "Courier New" SIZE 0, -11
   DEFINE FONT o_Fnt[4] NAME "Courier New" SIZE 0, -12
   DEFINE FONT o_Fnt[5] NAME "Courier New" SIZE 0, -13
   DEFINE FONT o_Fnt[6] NAME "Courier New" SIZE 0, -14
   DEFINE FONT o_Fnt[7] NAME "Courier New" SIZE 0, -15
   DEFINE FONT o_Fnt[8] NAME "Courier New" SIZE 0, -16
   DEFINE FONT o_Fnt[9] NAME "Courier New" SIZE 0, -17
   DEFINE CURSOR oHand HAND

   SysRefresh()
   DEFINE WINDOW oVisu FROM 0,0 TO 35, 100 TITLE "Previsualização" ;
          STYLE nOr( WS_POPUP, WS_CAPTION, WS_BORDER, WS_SYSMENU, DS_SYSMODAL)

   DEFINE SBUTTONBAR oViBar SIZE 44, 33 OF oVisu 3DLOOK COLORS CLR_GRAY, nBtClr OFFICE
   oViBar:bRClicked := { |nRow, nCol| ( NIL ) } // Mouse direito
   oViBar:bLClicked := { |nRow, nCol| ( NIL ) } // Mouse Esquerdo

   DEFINE SBUTTON oSb1 OF oViBar FILE ".\bitmaps\printer.bmp" OFFICE ;
          MESSAGE "Imprimir" ;
          COLOR CLR_GRAY,{CLR_HGRAY,CLR_WHITE,3} ;
          MENU ACTION ImpSplMenu(oSb1, cSpoolFile)
   DEFINE SBUTTON oSb2 OF oViBar FILE ".\bitmaps\procbtn2.bmp" OFFICE ;
          MESSAGE "Aumentar tamanho da fonte" ;
          COLOR CLR_GRAY,{CLR_HGRAY,CLR_WHITE,3} ;
          ACTION MudaFonte(oGet1, "+") GROUP
   DEFINE SBUTTON oSb3 OF oViBar FILE ".\bitmaps\procbtn1.bmp" OFFICE ;
          MESSAGE "Diminuir tamanho da fonte" ;
          COLOR CLR_GRAY,{CLR_HGRAY,CLR_WHITE,3} ;
          ACTION MudaFonte(oGet1, "-")
   DEFINE SBUTTON oSb4 OF oViBar FILE ".\bitmaps\sair1.bmp" OFFICE ;
          MESSAGE "Sair da previsualização" ;
          COLOR CLR_GRAY,{CLR_HGRAY,CLR_WHITE,3} ;
          ACTION oVisu:End() GROUP
   AEval( oViBar:aControls, { | o | o:oCursor := oHand } )

   DEFINE STATUSBAR OF oVisu PROMPT "Previsualização" CENTERED

   @25, 05 GET oGet1 VAR cText OF oVisu SIZE 35, 100 PIXEL MEMO FONT o_Fnt[nFont] HSCROLL READONLY

   WndCenter(oVisu:hWnd)

   ACTIVATE WINDOW oVisu ;
            ON INIT (oGet1:Move(35, 4, oVisu:GetCliRect():nRight - oVisu:GetCliRect():nLeft - 8, oVisu:GetCliRect():nBottom - oVisu:GetCliRect():nTop -70, .t.)) ;
            VALID (AEVAL(o_Fnt, {|o|o:End()}) ,;
                         oHand:End()          ,;
                         oVisu := nil         ,;
                         lExit := .T.         ,;
                         .T.)
   StopUntil( {|| lExit} )
   RELEASE nFont
RETURN lOk

STATIC FUNCTION MudaFonte(oGet1, cOp)
   *----------------------( Função MudaFonte de MsgPreview )---------------------*
   IF cOp = "+"
      nFont ++
      IF nFont > 9 ; nFont := 9  ; MsgBeep(); ENDIF
   ELSEIF cOp = "-"
      nFont --
      IF nFont < 1 ; nFont := 1 ; MsgBeep(); ENDIF
   ENDIF
   oGet1:SetFont(o_Fnt[nFont])
   oGet1:Refresh()
RETURN NIL

STATIC FUNCTION ImpSplMenu(oBtn, cSpoolFile)
   LOCAL oMenu, aRect
   aRect := GetClientRect( oBtn:hWnd )
   MENU oMenu POPUP 2007
      MENUITEM "Papel Carta" ACTION ImpSpool(cSpoolFile, cDraftp)
      MENUITEM "Imp Térmica" ACTION ImpSpool(cSpoolFile, cICupom)
   ENDMENU
   ACTIVATE POPUP oMenu AT aRect[ 3 ] + 1, aRect[ 2 ] OF oBtn
RETURN NIL

 

Link to comment
Share on other sites

Achei uma TXTPREV.PRG velha pra KCTE, quando você não está com sorte, até o URUBU de baixo kga no de cima(kkkk), além de perder meu 4shared, o HD de BACKUP desmunhecou(bixou) igual o FDP que me denunciou no 4shared. kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

 

https://mega.nz/file/QNtnnCyZ#AmUp3mLacqOlT9C9JlGJcl9yO_QhWnZzgxeFIxqSuo0

 

Abs

Link to comment
Share on other sites

Ariston, compile, e veja se eu entendi sua lógica, se faltar alguma coisa no IMPSPOOL(), por favor complete, pois estou sem impressora matricial no momento para testar. Many thanks. Não fique zangando, fiz como eu "enxerguei" a sua lógica e fiz como eu gosto de ver um programa em FiveWin, tá? kkkkkkkkkk


// \SAMPLES\MSGPREV.PRG By Ariston - 13/01/2022 - Modificado por: Joao Santos
	#Include "FiveWin.ch"
	#Define aPubGrad        {| lInvert | If( lInvert, ;
                        { { 1 / 3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
                        { 2 / 3, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) }  ;
                        }, ;
                        { { 1 / 2, nRGB( 219, 230, 244 ), nRGB( 207 - 50, 221 - 25, 255 ) }, ;
                        { 1 / 2, nRGB( 201 - 50, 217 - 25, 255 ), nRGB( 231, 242, 255 ) }  ;
                        } ) }
	STATIC oWnd
	MEMVAR nFont, o_Fnt
	FUNCTION Main()
	   LOCAL nSkip      := 3
   LOCAL cSpoolFile := "TEST.TXT"
   LOCAL cImpTxt
	   cImpTxt := MsgPrevew( cSpoolFile, nSkip )
	RETURN NIL
	FUNCTION MsgPrevew( cSpoolFile, nSkip )
	   LOCAL lOk, aText, cText, nMaior, o_Txt, lExit := .F., n, cLinha, nLinha
   LOCAL oBtn1 AS OBJECT
   LOCAL oBtn2 AS OBJECT
   LOCAL oBtn3 AS OBJECT
   LOCAL oBtn4 AS OBJECT
   LOCAL oGet1 AS OBJECT
   LOCAL oBar  AS OBJECT
   LOCAL oIco  AS OBJECT
   LOCAL oHand AS OBJECT
	   DEFAULT nSkip := 6
	   HB_GCALL( .F. )
	   nFont  := 3
   o_Fnt  := ARRAY(10)
   lOk    := .F.
   aText  := {}
   cText  := ""
   nMaior := 0
	   o_Txt  := MEMOREAD( cSpoolFile )
   nLinha := MLCOUNT(o_Txt)
	   FOR n := 3 TO nLinha
	      SysRefresh()
	      cLinha := SUBSTR(STRTRAN(MEMOLINE(o_Txt,254,n),"",""), nSkip, 254)
	      cText += cLinha + CRLF
	      nMaior := IIF(LEN(ALLTRIM(cLinha)) > nMaior, LEN(ALLTRIM(cLinha)), nMaior)
	      IF n >= 350
	         cText += "--------------------" + CRLF
	         cText += "Continua..." + CRLF
	         EXIT
	      ENDIF
	   NEXT
	   SetBalloon( .T. ) // Balloon shape required for tooltips
	   SkinButtons()
	   DEFINE CURSOR oHand HAND
   DEFINE ICON oIco FILE "..\icons\fax.ico"
	   DEFINE FONT o_Fnt[1] NAME "Courier New" SIZE 0, -09
   DEFINE FONT o_Fnt[2] NAME "Courier New" SIZE 0, -10
   DEFINE FONT o_Fnt[3] NAME "Courier New" SIZE 0, -11
   DEFINE FONT o_Fnt[4] NAME "Courier New" SIZE 0, -12
   DEFINE FONT o_Fnt[5] NAME "Courier New" SIZE 0, -13
   DEFINE FONT o_Fnt[6] NAME "Courier New" SIZE 0, -14
   DEFINE FONT o_Fnt[7] NAME "Courier New" SIZE 0, -15
   DEFINE FONT o_Fnt[8] NAME "Courier New" SIZE 0, -16
   DEFINE FONT o_Fnt[9] NAME "Courier New" SIZE 0, -17
	   DEFINE WINDOW oWnd FROM 0,0 TO 35, 100 TITLE "Previsualização"           ;
      STYLE nOr( WS_POPUP, WS_CAPTION, WS_BORDER, WS_SYSMENU, DS_SYSMODAL)
	   DEFINE BUTTONBAR oBar _3D SIZE 44, 33 OF oWnd 2007
	   WITH OBJECT oBar
	      oBar:bClrGrad := aPubGrad
	      oBar:bRClicked := { || NIL } // Botao direito  do Mouse desligado.
      oBar:bLClicked := { || NIL } // Botao Esquerdo do Mouse desligado.
	      oBar:Adjust()
	   END
	   DEFINE BUTTON oBtn1 OF oBar FILENAME "..\bitmaps\16x16\printer.bmp" FLAT ;
      ACTION( ImpSplMenu( oBtn1, cSpoolFile ) )                             ;
      TOOLTIP "Imprimir um documento" GROUP
	   DEFINE BUTTON oBtn2 OF oBar FILENAME "..\bitmaps\16x16\plus.bmp" FLAT    ;
      ACTION( MudaFonte( oGet1, "+" ) )                                     ;
      TOOLTIP "Aumentar tamanho da fonte" GROUP
	   DEFINE BUTTON oBtn3 OF oBar FILENAME "..\bitmaps\16x16\minus.bmp" FLAT   ;
      ACTION( MudaFonte( oGet1, "-" ) )                                     ;
      TOOLTIP "Diminuir tamanho da fonte" GROUP
	   DEFINE BUTTON oBtn4 OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT    ;
      ACTION( oWnd:End() ) TOOLTIP "Sair da previsualização" GROUP
	   AEval( oBar:aControls, { | o | o:oCursor := oHand } )
	   SET MESSAGE OF oWnd TO "© João Santos: (11) 9.5150-7341 - Skype: joao@pleno.com.br" ;
       + "." FONT o_Fnt[3] NOINSET CLOCK DATE KEYBOARD COLOR CLR_HBLUE, CLR_WHITE 2007
	   @25, 05 GET oGet1 VAR cText OF oWnd SIZE 35, 100 PIXEL MEMO              ;
      FONT o_Fnt[nFont] HSCROLL READONLY
	   WndCenter( oWnd:hWnd )  // CENTRALIZA A WINDOW
	   ACTIVATE WINDOW oWnd ;
      ON INIT(oGet1:Move(35, 4, oWnd:GetCliRect():nRight - oWnd:GetCliRect():nLeft - 8, oWnd:GetCliRect():nBottom - oWnd:GetCliRect():nTop -70, .t.))
	   RELEASE o_Fnt
   RELEASE nFont
	   SysRefresh()
	   HB_GCALL( .T. )
	   CLEAR MEMORY
	   PostQuitMessage( 0 )
	   QUIT
	RETURN lOk
	STATIC FUNCTION MudaFonte(oGet1, cOp)
	   *----------------------( Função MudaFonte de MsgPreview )---------------------*
   IF cOp = "+"
	      nFont ++
	      IF nFont > 9 ; nFont := 9  ; MsgBeep(); ENDIF
	   ELSEIF cOp = "-"
	      nFont --
	      IF nFont < 1 ; nFont := 1 ; MsgBeep(); ENDIF
	   ENDIF
	   oGet1:SetFont(o_Fnt[nFont])
   oGet1:Refresh()
	RETURN NIL
	STATIC FUNCTION ImpSplMenu( oBtn, cSpoolFile )
	   LOCAL oMenu, aRect, cDraftp, cICupom
	   aRect := GetClientRect( oBtn:hWnd )
	   MENU oMenu POPUP 2007
	      MENUITEM "Papel Carta" ACTION ImpSpool( cSpoolFile, cDraftp ) //??
	      MENUITEM "Imp Térmica" ACTION ImpSpool( cSpoolFile, cICupom ) //??
	   ENDMENU
	   ACTIVATE POPUP oMenu AT aRect[ 3 ] + 1, aRect[ 2 ] OF oBtn
	RETURN NIL
//----------------------------------------------------------------------------//
// Funcao    : ImpSpool( cFileTxt, cPorta, lErase )
// Autor     : Ednaldo Rolim (edrol@pop.com.br)
// Descricao : Envia um arquivo TXT criado pela TDosPrn para uma 
//             porta de Impressora.
//----------------------------------------------------------------------------//
Function ImpSpool( cFileTxt, cPorta, lErase )
	    //para capturar antes da impressão
    //cPorta := PrnGetPorta()
    //WinExec( cPorta )
    //depois da impressão
    //WinExex( "Net Use Lpt1: \Delete" )
    //Ficou mais facil e simples do que criar as portas na Classe TDosPrn
    //cPorta := If( cPorta == nil, Alltrim( PrnGetPort() ), cPorta ) ; lErase := If( lErase == nil, .T., lErase );
	    Default cPorta:= Alltrim( PrnGetPort() ), lErase:= .t.
    
    If !File( cFileTxt )
        return .F.
    Endif
 
    If Len( cPorta ) <= 5 .and. Left( Upper(cPorta), 4) = "LPT1"
        //--- Spool Local
        cPorta:= "PRN"
        WAITRUN("COMMAND.COM /C COPY /B " + cFileTxt + " " + cPorta, 0 )
     Else
        //--- Spool Remoto
        WAITRUN("COMMAND.COM /C COPY /B " + cFileTxt + " " + cPorta, 0 )
    Endif
	    If lErase
        // FErase( cFileTxt )  // APAGA O ARQUIVO.
    Endif
	Return .T.
// FIN / END

Regards, saludos.

Link to comment
Share on other sites

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...