Problemas con Tprinter y Tdosprn

Problemas con Tprinter y Tdosprn

Postby Pedro » Fri Feb 10, 2012 12:13 pm

Hola a todos
Después de actualizarme a la nueva versión 12.01 para que me han llovido los problemas con las impresiones. Si antes fue el Set Default para los reportes,
ahora viene el tema , ya antiguo, de que la ventana de previsualización se esconde detrás de los diálogos en los reportes con tPrinter, ya he ido a la clase rpreview, le he quitado el mdichild, y nada en cuanto hago un printer oPrn from user preview la ventana que sale se queda detrás del diálogo.

Por otro lado tengo otro error mucho menos claro, uso la clase tdosprn junto ttxview para imprimir unos tickets de venta, pues bien, hasta la nueva versión no tenía problemas, sin embargo ahora me da un error Message not found: TDOSPRN:CNEGON, sin embargo las dos clases, TdosPrn y TTXTView, tienen esa DATA, así que no entiendo como puede dar ese error.

Alguna manita para estos problemas ?
Last edited by Pedro on Sat Feb 11, 2012 10:14 am, edited 1 time in total.
Un saludo
Pedro
gahetesoft@gmail.com
FWH12.06 BCC582, Xverce CW, Pelles C 6.00.4,PSPAD 4.54
y ahora con ADO
User avatar
Pedro
 
Posts: 464
Joined: Tue Mar 21, 2006 7:30 pm
Location: Córdoba (España)

Re: Problemas con Tprinter

Postby karinha » Fri Feb 10, 2012 1:07 pm

Holá,

Use: PREVIEW MODAL.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7313
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problemas con Tprinter

Postby Pedro » Fri Feb 10, 2012 3:15 pm

Hola Joao

pues al usar oPrn:lPrevModal := .T. y ejecutar la aplicación me da el mismo error Message not found: TPRINTER:_LPREVMODAL

la verdad que esto me está dando dolor de cabeza, no entiendo como estando las datas puede sacar el mensaje de que no existen.
Un saludo
Pedro
gahetesoft@gmail.com
FWH12.06 BCC582, Xverce CW, Pelles C 6.00.4,PSPAD 4.54
y ahora con ADO
User avatar
Pedro
 
Posts: 464
Joined: Tue Mar 21, 2006 7:30 pm
Location: Córdoba (España)

Re: Problemas con Tprinter

Postby karinha » Fri Feb 10, 2012 3:27 pm

No Pedro, no és asi:

oPrn:lPrevModal := .T.

És asi:

oPrn:lPrvModal := .T.

Salud2
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7313
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Problemas con Tprinter

Postby Antonio Linares » Fri Feb 10, 2012 3:46 pm

Pedro,

Puedes copiar aqui el contenido de las clases TdosPrn y TTXTView que usas ? gracias
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Problemas con Tprinter

Postby Pedro » Fri Feb 10, 2012 4:51 pm

Joao, llevas razón lo escribí mal, ha debido ser que ya estaba ciego con el tema.

Antonio aqui te pongo las dos clases

TDOSPRN :
Code: Select all  Expand view

#include "fivewin.ch"
#include "fileio.ch"

#translate nTrim(<n>)  => AllTrim(Str(<n>,10,0))

#define PF_BUFLEN   2048

//----------------------------------------------------------------------------//

CLASS TDosPrn

     DATA LastError
     DATA cPort, cCompress, cNormal, cFormFeed, cBuffer
     DATA cInitPrn  //RDC
     DATA cNegOn    //RDC
     DATA cNegOff   //RDC
     DATA cItaOn    //RDC
     DATA cItaOff   //RDC
     DATA cEmpOn    //RDC
     DATA cEmpOff   //RDC
     DATA c10Cpi    //RDC
     DATA c12Cpi    //RDC
     DATA cWidOn    //RDC
     DATA cWidOff   //RDC
     DATA hDC, nRow, nCol, nLeftMargin, nTopMargin          AS NUMERIC
     DATA lAnsiToOem                                        AS LOGICAL

     DATA oWnd, oPagina                                      // Ednaldo
     DATA nPage                        AS NUMERIC            // Ednaldo

     METHOD New(cPort) CONSTRUCTOR

     METHOD END()

     METHOD StartPage()        INLINE ::ShowProc()           // Ednaldo

     METHOD EndPage()

     METHOD Command(xPar1, xPar2, xPar3, xPar4, xPar5)

     METHOD SetCoors(nRow, nCol)

     METHOD NewLine()       INLINE (::cBuffer += CRLF ,;
                                    ::nRow++          ,;
                                    ::nCol    := 0     )

     METHOD Write(cText, lAToO) ;
            INLINE (IIF(lAtoO == NIL, lAtoO := .T.,),;
                    ::cBuffer += IIF(lAtoO, AnsitoOem(cText), cText) ,;
                    ::nCol    += LEN(cText)                           )

     METHOD SAY(nRow, nCol, cText, lAToO)

     METHOD SayCmp(nRow, nCol, cText)

     METHOD PrintFile(cFile)

     METHOD ShowProc()          // Ednaldo

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New(cPort) CLASS TDosPrn

     DEFAULT cPort := "LPT1"

     cPort := UPPER(cPort)

     ::cCompress   := "15"
     ::cNormal     := "18"
     ::cFormFeed   := "12"
     ::cInitPrn    := "18,27,80"
     ::cNegOn      := "27,71"
     ::cNegOff     := "27,72"
     ::c10cpi      := "27,80"
     ::c12cpi      := "27,77"
     ::cWidOn      := "27,87,1"
     ::cWidOff     := "27,87,0"
     ::cBuffer     := ""
     ::nLeftMargin := 0
     ::nTopMargin  := 0
     ::nRow        := 0
     ::nCol        := 0
     ::lAnsiToOem  := .T.
     ::cPort       := cPort+IIF(!"."$cPort,".PRN","")
     ::hDC         := FCREATE(::cPort)
     ::LastError   := 0

     IF ::hDC < 0
          ::LastError := FERROR()
     ENDIF
     MSGINFO("TDOSPRN")
     ::nPage := 1                  // Ednaldo
     ::ShowProc()                  // Ednaldo

RETURN Self

//----------------------------------------------------------------------------//

METHOD END() CLASS TDosPrn

     IF !EMPTY(::nRow+::nCol)
          ::EndPage()
     ENDIF

     ::LastError := 0

     IF !FCLOSE(::hDC)
          ::LastError := FERROR()
     ENDIF

     CursorArrow()

     IF ::oWnd != Nil                    // Ednaldo
        ::oWnd:END()                     // Ednaldo
     ENDIF                               // Ednaldo

RETURN NIL

//----------------------------------------------------------------------------//

METHOD EndPage() CLASS TDosPrn

     LOCAL nFor, nLen, nSec
     LOCAL lError

     ::Command(::cFormFeed)

     ::LastError := 0

     IF FWRITE(::hDC, ::cBuffer) < LEN(::cBuffer)
          ::LastError := FERROR()
     ENDIF

     ::cBuffer := ""
     ::nRow    := 0
     ::nCol    := 0

RETURN NIL

//----------------------------------------------------------------------------//

METHOD Command(xPar1, xPar2, xPar3, xPar4, xPar5) CLASS TDosPrn

     LOCAL cCommand, cToken, cString
     LOCAL nToken

     cString  := cValToChar(xPar1)

     IF xPar2 != NIL
          cString += ","+cValToChar(xPar2)
     ENDIF

     IF xPar3 != NIL
          cString += ","+cValToChar(xPar3)
     ENDIF

     IF xPar4 != NIL
          cString += ","+cValToChar(xPar4)
     ENDIF

     IF xPar5 != NIL
          cString += ","+cValToChar(xPar5)
     ENDIF

     cCommand := ""
     nToken   := 1

     DO WHILE !EMPTY(cToken := StrToken(cString, nToken++, ","))
          cCommand += CHR(VAL(cToken))
     ENDDO

     ::cBuffer += cCommand

RETURN NIL

//----------------------------------------------------------------------------//

METHOD SetCoors(nRow, nCol) CLASS TDosPrn

     nRow += ::nTopMargin
     nCol += ::nLeftMargin

     IF ::nRow > nRow
          ::EndPage()
          ::nPage++                          // Ednaldo
          ::StartPage()
     ENDIF

     IF nRow == ::nRow  .AND. nCol < ::nCol
          ::EndPage()
          ::nPage++                          // Ednaldo
          ::StartPage()
     ENDIF

     DO WHILE ::nRow < nRow
          ::NewLine()
     ENDDO

     IF nCol > ::nCol
          ::Write(SPACE(nCol-::nCol))
     ENDIF

RETURN NIL

//----------------------------------------------------------------------------//

METHOD SAY(nRow, nCol, cText, lAToO) CLASS TDosPrn

     DEFAULT lAToO := ::lAnsiToOem

     IF VALTYPE( cText ) = "D"
        cText := DTOC( cText )
     ENDIF

     IF VALTYPE( cText ) = "N"
        cText := STR( cText )
     ENDIF

     ::SetCoors(nRow, nCol)
     ::Write(cText, lAToO)

RETURN NIL

//----------------------------------------------------------------------------//

METHOD SayCmp(nRow, nCol, cText, lAToO) CLASS TDosPrn

     DEFAULT lAToO := ::lAnsiToOem

     ::SetCoors(nRow, nCol)
     ::Command(::cCompress)
     ::cBuffer += IIF(lAToO, AnsitoOem(cText), cText)
     ::nCol    += INT(LEN(cText)/1.7+.5)
     ::Command(::cNormal)

RETURN NIL

//----------------------------------------------------------------------------//

METHOD PrintFile(cFile) CLASS TDosPrn

     LOCAL hFile
     LOCAL nRead
     LOCAL cBuffer

     hFile := FOPEN(cFile, FO_READ)

     IF hFile < 0
          RETURN .F.
     ENDIF

     cBuffer := SPACE(PF_BUFLEN)

     DO
          nRead := FREAD(hFile, @cBuffer, PF_BUFLEN)

          IF FWRITE(::hDC, LEFT(cBuffer, nRead)) < nRead
               ::LastError := FERROR()
               FCLOSE(hFile)
               RETURN .F.
          ENDIF
     UNTIL nRead == PF_BUFLEN

     FCLOSE(hFile)

RETURN .T.

//----------------------------------------------------------------------------//
// Visualiza Processo de impressao                 // Ednaldo
//----------------------------------------------------------------------------//
METHOD ShowProc() CLASS TDosPrn

LOCAL oIcono, oBtn

     IF ::oWnd = Nil
       
     DEFINE DIALOG   ::oWnd    RESOURCE   "PREVIEW_PROC" TITLE "Generando Previsualizacion..."
   REDEFINE ICON      oIcono   ID 105      RESOURCE "XPRINT"  OF ::oWnd
   REDEFINE  SAY     ::oPagina VAR ::nPage ID 101 OF ::oWnd UPDATE
   REDEFINE BUTTONBMP oBtn     ID IDCANCEL OF ::oWnd BITMAP "ESPERA" TEXTRIGHT ACTION .t.
 
       ::oWnd:bPainted := {|| IIF(::nPage>0, ::oPagina:Refresh(), )}
     
   ACTIVATE DIALOG    ::oWnd   CENTER NOWAIT
   
        CursorWait()
        SysRefresh()

     ELSE
        ::oWnd:BeginPaint()
        ::oWnd:Paint()
        ::oWnd:EndPaint()

     ENDIF

RETURN NIL

//----------------------------------------------------------------------------//

FUNCTION WorkSheet(cPort)

     LOCAL oPrn
     LOCAL cLine
     LOCAL nFor

     cLine := ""

     FOR nFor := 0 TO 7
          cLine += STR(nFor,1)+REPLICATE(".",9)
     NEXT

     cLine := SUBSTR(cLine,3)

     oPrn := TDosPrn():New(cPort)

     oPrn:StartPage()

     FOR nFor := 0 TO 65
          oPrn:SAY(nFor,0,STRZERO(nFor,2)+cLine)
     NEXT

     oPrn:EndPage()

     oPrn:END()

RETURN NIL
 


CLASE TTXTVIEW
Code: Select all  Expand view

*---------------------------------------------------------------------------
* TxtPreview - Ednaldo Rolim (edrol@uol.com.br)
* Modificado por Ralph del Castillo para la clase tRichEdit
* MODICACIONES EXTRAS POR: Víctor Daniel Cuatecatl León
* ==========================================================================
* Utiliza: Richedit -
*          TdosPrn - Ignacio Ortiz
* Baseado em MPreview.prg - Jos‚ Lal¡n
*---------------------------------------------------------------------------

// Desligue a proxima linha se voce nao usa PREVIEW.DLL
// Comment the next line if you don't use any PREVIEW.DLL

#define _PREV_DLL

// Para Fivewin versao 2.0 ou abaixo, habilite a linha seguinte
// #define __CLIPPER__

#include "FiveWin.ch"

#ifndef COLOR_BTNFACE
#include "WColors.ch"
#endif

#include "RichEdit.ch"

#ifdef __XPP__
   #define New   _New
#endif

#define TXT_FIRST     LoadString( GetResources(), 07 )
#define TXT_PREVIOUS  LoadString( GetResources(), 08 )
#define TXT_NEXT      LoadString( GetResources(), 09 )
#define TXT_LAST      LoadString( GetResources(), 10 )
#define TXT_ZOOM      LoadString( GetResources(), 11 )
#define TXT_UNZOOM    LoadString( GetResources(), 12 )
#define TXT_TWOPAGES  LoadString( GetResources(), 13 )
#define TXT_ONEPAGE   LoadString( GetResources(), 14 )
#define TXT_PRINT     LoadString( GetResources(), 15 )
#define TXT_EXIT      LoadString( GetResources(), 16 )
#define TXT_FILE      LoadString( GetResources(), 17 )
#define TXT_PAGE      LoadString( GetResources(), 18 )
#define TXT_PREVIEW   LoadString( GetResources(), 03 )
#define TXT_PAGENUM   LoadString( GetResources(), 19 )

#define TXT_A_WINDOW_PREVIEW_IS_ALLREADY_RUNNING ;
        LoadString( GetResources(), 20 )
#define TXT_GOTO_FIRST_PAGE ;
        LoadString( GetResources(), 21 )
#define TXT_GOTO_PREVIOUS_PAGE ;
        LoadString( GetResources(), 22 )
#define TXT_GOTO_NEXT_PAGE ;
        LoadString( GetResources(), 23 )
#define TXT_GOTO_LAST_PAGE ;
        LoadString( GetResources(), 24 )
#define TXT_ZOOM_THE_PREVIEW ;
        LoadString( GetResources(), 25 )
#define TXT_UNZOOM_THE_PREVIEW ;
        LoadString( GetResources(), 26 )
#define TXT_PREVIEW_ON_TWO_PAGES ;
        LoadString( GetResources(), 27 )
#define TXT_PREVIEW_ON_ONE_PAGE ;
        LoadString( GetResources(), 28 )
#define TXT_PRINT_CURRENT_PAGE ;
        LoadString( GetResources(), 29 )
#define TXT_EXIT_PREVIEW ;
        LoadString( GetResources(), 30 )

#define TXT_ZOOM_FACTOR        ;
        "Fijar el factor de Zoom"
#define TXT_ERROR_FWERROR      ;
        "Error de Impresion"
#define TXT_ERROR_NOTFOUND     ;
        "No encontrado. Imposible continuar."
#define TXT_ERROR_TOOMANY_WINDOWS  ;
        "No se pueden abrir mas ventanas de previsualizacion."

STATIC oMdiTmp, nOldArea, oIcon, oUnZoom

STATIC snCurPrev    := 0
STATIC saMPrevOpts  := { .t., 10, 1, .f., .f. }

#xtranslate slMdiPrev   => saMPrevOpts\[1\]
#xtranslate snMaxPrev   => saMPrevOpts\[2\]
#xtranslate snZFactor   => saMPrevOpts\[3\]
#xtranslate slWantMenu  => saMPrevOpts\[4\]
#xtranslate slSpool     => saMPrevOpts\[5\]


//----------------------------------------------------------------------------//
FUNCTION SetMTxtPreview( lOnOff, nMaxWnd, nNewZFactor, lMenu, lSpool )

  LOCAL aOld := saMPrevOpts

  DEFAULT nMaxWnd     := 0, ;
          nNewZFactor := 0, ;
          lSpool      := ( "\\" $ PrnGetPort() )

  IF lOnOff != nil
     slMdiPrev := lOnOff
  ENDIF

  IF nMaxWnd > 0
     snMaxPrev := nMaxWnd
  ENDIF

  IF nNewZFactor > 0
     snZFactor := nNewZFactor
  ENDIF

  IF lMenu != nil
     slWantMenu  := lMenu
  ENDIF

  slSpool:= lSpool

RETURN aOld

//----------------------------------------------------------------------------//
FUNCTION TxtPreview( cFileTxt, cTitle, lPrvModal, lSpool, cPort, oPrn, oDlg, lKill, lGPrint, cImpre  )  // cImpre: Agregado por VDCL

  LOCAL oPrev
  LOCAL hOldRes := GetResources()
  LOCAL hDLL := LoadLibrary( "Riched20.dll" )

  IF WndMain() = NIL
     lPrvModal := .t.

     oDlg:Hide()

     DEFINE ICON     oIcon   RESOURCE "REPORTE"
     DEFINE WINDOW   oMdiTmp FROM 0, 0 TO 20, 79 MDI TITLE "TxtPreview"
     SET MESSAGE OF  oMdiTmp TO "Preview" CENTERED  NOINSET
     oMdiTmp:SetIcon(oIcon)
     ACTIVATE WINDOW oMdiTmp ICONIZED ON INIT TxtPrevDlg( cFileTxt, cTitle, lPrvModal, lSpool, cPort, oPrn, lKill, lGPrint, cImpre )  //RDC   cImpre: Agregado por VDCL

     oDlg:Show()
     oDlg:SetFocus()

  ELSE
     oPrev := TTxtPreview():New( cFileTxt,, lPrvModal, cTitle, lSpool, cPort, oPrn, lKill, lGPrint, cImpre )  //RDC  cImpre: Agregado por VDCL
     oPrev:Activate()
  ENDIF

  FreeLibrary( hDLL )

  SetResources( hOldRes )

 
RETURN nil

//----------------------------------------------------------------------------//
STATIC FUNCTION TxtPrevDlg( cFileTxt, cTitle, lPrvModal, lSpool, cPort, oPrn, lKill, lGPrint, cImpre )  // cImpre: Agregado por VDCL

  LOCAL oPrev
  oPrev := TTxtPreview():New( cFileTxt, oMdiTmp , lPrvModal, cTitle, lSpool, cPort, oPrn, lKill, lGPrint, cImpre )  // cImpre: Agregado por VDCL
  oPrev:Activate()

RETURN nil

//----------------------------------------------------------------------------//
CLASS TTxtPreview

  DATA oWndMain
  DATA oDevice
  DATA oDbf

  DATA oMenu
  DATA oPage, oZoom, oMenuZoom, oSize
  DATA oMenuUnZoom, oMenuOnePage, cResFile

  DATA lExit

  DATA lPrintDlg      AS LOGICAL INIT .t.


  DATA lKillFile      AS LOGICAL INIT .t.     //RDC
  DATA lModoGraf      AS LOGICAL INIT .f.     //RDC

  DATA oFont

  DATA nPage AS NUMERIC INIT 1
  DATA lZoom

  DATA hOldRes
  DATA oBar
  DATA oWnd
  DATA oFGet

  DATA lPrvModal
  DATA cTitle, cDir, cTxtFile, cDbfTmp, cMemTmp, cTextFmt

  DATA lSpool
  DATA cPort, cCompress, cNormal, cFormFeed, cImpre         // cImpre: Agregado por VDCL
  DATA cNegOn, cNegOff, cItaOn, cItaOff, cEmpOn, cEmpOff
  DATA c10Cpi, c12Cpi, cWidOn, cWidOff

  METHOD New( cFileTxt, oWndMain, lModal, cTitle, lSpool, cPort, oPrn, lKill, lGPrint, cImpre ) CONSTRUCTOR  // RDC    cImpre: Agregado por VDCL
  METHOD Activate()
  METHOD END() INLINE IF( ::oWnd != nil, ::oWnd:END(), )

  METHOD Command( xPar1, xPar2, xPar3, xPar4, xPar5 )
  METHOD Destroy()

  METHOD BuildBtnBar( l97Look )
  METHOD BuildFGet()
  METHOD BuildMenu()

  METHOD NextPage()
  METHOD PrevPage()
  METHOD TopPage()
  METHOD BottomPage()

  METHOD Zoom()
  METHOD Zoom_in()    // RDC
  METHOD Zoom_out()   // RDC
  METHOD KeyDown( nKey, nFlags )
  METHOD KeyChar( nKey, nFlags )

  METHOD PRINT()
  METHOD PrintPrv( oDlg, nOption, nPageIni, nPageEnd, cRange, nCopies )
  METHOD PrintPage( oPrn, cTxt )

  METHOD GPrint()       // RDC
  METHOD Text2Lines()   // RDC

  METHOD AjustFget()
  METHOD BuildDbfTmp()
  METHOD TxtToRTF( cText )

  METHOD MenuFGet( nRow, nCol )

ENDCLASS

//----------------------------------------------------------------------------------//
METHOD New( cFileTxt, oWndMain, lModal, cTitle, lSpool, cPort, oPrn, lKill, lGPrint, cImpre ) CLASS TTxtPreview  
 // cImpre: Agregado por VDCL

  LOCAL nFor
  LOCAL oIcon
  LOCAL oBrush
  LOCAL l97Look
  LOCAL nTmp, lIsLaser, cImpr, cFont

  DEFAULT oWndMain := WndMain(),;
          lModal:= !slMdiPrev,;
          cTitle:= "Previsualizacion",;
          lSpool:= slSpool,;
          lKill := .t.,;
          lGPrint := .f.


  ::oWndMain  := oWndMain
  ::lExit     := .F.
  ::cTxtFile  := cFileTxt
  ::cTitle    := cTitle
  ::lPrvModal := lModal
  ::lZoom     := ( snZFactor = 1 )
  ::nPage     := 1
  ::lModoGraf := lGPrint
  ::lSpool    := lSpool
  ::lKillFile := lKill      //RDC
  ::cPort     := cPort
  ::cImpre    := cImpre     // cImpre: Agregado por VDCL

  IF oPrn = Nil
     cImpr := PrnGetName()
     lIsLaser := ( AT('JET',UPPER(cImpr)) > 0 .OR. AT('LASER',UPPER(cImpr)) > 0 )
     IF lIsLaser
        ::cNormal     := ::Command("27,40,115,49,50,72")
        ::cCompress   := ::Command("27,40,115,49,56,72")
     ELSE
        ::cCompress   := ::Command("15")
        ::cNormal     := ::Command("18")
     ENDIF
     ::cFormFeed   := ::Command( "12" )
     ::cNegOn      := ::Command("27,71")
     ::cNegOff     := ::Command("27,72")
     ::c10cpi      := ::Command("27,80")
     ::c12cpi      := ::Command("27,77")
     ::cWidOn      := ::Command("27,87,1")
     ::cWidOff     := ::Command("27,87,0")
  ELSE
     ::cCompress   := ::Command( oPrn:cCompress )
     ::cNormal     := ::Command( oPrn:cNormal )
     ::cFormFeed   := ::Command( oPrn:cFormFeed )
     ::cNegOn      := ::Command( oPrn:cNegOn )
     ::cNegOff     := ::Command( oPrn:cNegOff )
     ::c10cpi      := ::Command( oPrn:c10cpi )
     ::c12cpi      := ::Command( oPrn:c12cpi )
     ::cWidOn      := ::Command( oPrn:cWidOn )
     ::cWidOff     := ::Command( oPrn:cWidOff )
  ENDIF

  ::cDir := GETENV("TEMP")

  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

  nOldArea  := SELECT()   //RDC

  IF RIGHT( ::cDir, 1 ) != "
\"
     ::cDir += "
\"
  ENDIF

  l97Look:= .t.

  #ifdef _PREV_DLL

    ::hOldRes := GetResources()

    #ifdef __CLIPPER__
      ::cResFile := "
Preview.dll"
    #else
      ::cResFile := "
Prev32.dll"
    #endif

    IF SetResources( ::cResFile ) < 32
       MsgStop( ::cResFile + "
" + TXT_ERROR_NOTFOUND, TXT_ERROR_FWERROR )
       SetResources(::hOldRes)
       RETURN Self
    ENDIF

  #endif

  /* [jlalin] */

  IF snCurPrev == snMaxPrev
    MsgStop( TXT_ERROR_TOOMANY_WINDOWS )
    #ifdef _PREV_DLL
       SetResources( ::hOldRes )
    #endif
    RETURN Self
  ENDIF

  IF oWndMain != nil
    oIcon := oWndMain:oIcon
  ENDIF

  IF ::lPrvModal = Nil
     SetMTxtPreview()
     ::lPrvModal := slMdiPrev
  ENDIF

  ::BuildDbfTmp()

  IF ::lPrvModal .and. oWndMain != nil
     oWndMain:Hide()
  ELSE
     ::lExit := .T.
  ENDIF

  IF oWndMain != nil .and. oWndMain:oFont != nil
    ::oFont := oWndMain:oFont
  ELSE
    DEFINE FONT ::oFont NAME "
Ms Sans Serif" SIZE 0,-12
  ENDIF

  DEFINE ICON     oIcon   RESOURCE "
REPORTE"
  msginfo("
llegamos aqui")

  IF !::lPrvModal
    DEFINE WINDOW ::oWnd FROM 0, 0 ;
      TO oWndMain:nBottom - 100, oWndMain:nRight - 10 - IF( oWndMain:oLeft != nil, oWndMain:oLeft:nWidth(), 0 ) ;
      TITLE ::cTitle ;
      COLOR CLR_BLACK, GetSysColor( COLOR_BTNFACE ) ;
      OF oWndMain ;
      PIXEL
*      MDICHILD OF oWndMain ;
  ELSE

    nTmp:= WndHeight(FindWindow( 'Shell_TrayWnd',nil))

    DEFINE WINDOW ::oWnd FROM 0, 0 ;
      TO WndHeight(GetDesktopwindow())-nTmp, WndWidth(GetDesktopwindow()) ;
      PIXEL ;
      TITLE ::cTitle ;
      COLOR CLR_BLACK, GetSysColor( COLOR_BTNFACE ) ;
      MENU ::BuildMenu()

  ENDIF


  ::oWnd:SetIcon(oIcon)
  ::BuildBtnBar( l97Look )
  ::cTextFmt:= ::TxtToRTF( ::oDbf:TEXT )

  IF slWantMenu
    ::BuildMenu()
  ENDIF

  ::BuildFGet()

  ::nPage     := 1
  SysRefresh()

  #ifdef _PREV_DLL
     SetResources( ::hOldRes )
  #endif

RETURN Self

//----------------------------------------------------------------------------//
METHOD BuildBtnBar( l97Look ) CLASS TTxtPreview

LOCAL ASIZE := {"
100%","120%","140%","160%","180%","200%","300%" }
LOCAL cSize := ASIZE[1], oObj := self

  DEFINE BUTTONBAR ::oBar _3D SIZE 25,25 OF ::oWnd
  ::oBar:bLClicked := {|| NIL }
  ::oBar:bRClicked := {|| NIL }

  IF l97Look
    DEFINE BUTTON RESOURCE "
Top" OF ::oBar ;
        MESSAGE TXT_GOTO_FIRST_PAGE        ;
        ACTION ::TopPage()                 ;
        TOOLTIP STRTRAN( TXT_FIRST, "
&", "" ) NOBORDER ;
        WHEN ::oDbf:RECCOUNT() > 1 .and. ::nPage > 1

    DEFINE BUTTON RESOURCE "
Prev" OF ::oBar ;
        MESSAGE TXT_GOTO_PREVIOUS_PAGE          ;
        ACTION ::PrevPage()                     ;
        TOOLTIP STRTRAN( TXT_PREVIOUS, "
&", "" ) NOBORDER ;
        WHEN ::oDbf:RECCOUNT() > 1 .and. ::nPage > 1

    DEFINE BUTTON RESOURCE "
Next" OF ::oBar           ;
        MESSAGE TXT_GOTO_NEXT_PAGE                    ;
        ACTION ::NextPage()                           ;
        TOOLTIP STRTRAN( TXT_NEXT, "
&", "" ) NOBORDER ;
        WHEN ::oDbf:RECCOUNT() > 1 .and. ::nPage < ::oDbf:RECCOUNT()

    DEFINE BUTTON RESOURCE "
Bottom" OF ::oBar         ;
        MESSAGE TXT_GOTO_LAST_PAGE                    ;
        ACTION ::BottomPage()                         ;
        TOOLTIP STRTRAN( TXT_LAST, "
&", "" ) NOBORDER ;
        WHEN ::oDbf:RECCOUNT() > 1 .and. ::nPage < ::oDbf:RECCOUNT()

    DEFINE BUTTON ::oZoom RESOURCE "
Zoom" OF ::oBar GROUP ;
        MESSAGE TXT_ZOOM_THE_PREVIEW                      ;
        ACTION ::Zoom_in()                                   ;
        TOOLTIP STRTRAN( TXT_ZOOM, "
&", "" ) NOBORDER
   
    DEFINE BUTTON oUnZoom RESOURCE "
UnZoom" OF ::oBar GROUP ;
        MESSAGE "
Deshacer Zoom de la página"                      ;
        ACTION ::Zoom_Out()                                   ;
        TOOLTIP "
Alejar"
       
   /* DEFINE BUTTON RESOURCE "
Config" OF ::oBar GROUP ;
        MESSAGE "
Seleccionar impresora"             ;
        PROMPT "
Configurar"                         ;
        ACTION PrinterSetup() NOBORDER TOOLTIP "
Selección de Impresora"*/


    DEFINE BUTTON RESOURCE "
Printer" OF ::oBar GROUP ;
        MESSAGE TXT_PRINT_CURRENT_PAGE             ;
        ACTION ::PRINT()                           ;
        TOOLTIP STRTRAN( TXT_PRINT, "
&", "" ) NOBORDER

    DEFINE BUTTON RESOURCE "
Exit" OF ::oBar GROUP  ;
        MESSAGE TXT_EXIT_PREVIEW                   ;
        ACTION ::oWnd:END()                        ;
        TOOLTIP STRTRAN( TXT_EXIT, "
&", "" ) NOBORDER
   
  /* @ ::oBar:nTop + 5, ::oBar:GetBtnLeft()+2 COMBOBOX ::oSize ;
                VAR cSize ITEMS ASIZE OF ::oBar ;
                SIZE 60,300 FONT ::oFont ;
                ON CHANGE oObj:Zoom() PIXEL

    ::oSize:cToolTip := "
Factor de Zoom"*/
   
  ELSE
    DEFINE BUTTON RESOURCE "
Top" OF ::oBar    ;
        MESSAGE TXT_GOTO_FIRST_PAGE           ;
        ACTION ::TopPage()                    ;
        TOOLTIP STRTRAN( TXT_FIRST, "
&", "" ) ;
        WHEN ::oDbf:RECCOUNT() > 1 .and. ::nPage > 1

    DEFINE BUTTON RESOURCE "
Prev" OF ::oBar  ;
        MESSAGE TXT_GOTO_PREVIOUS_PAGE       ;
        ACTION ::PrevPage()                  ;
        TOOLTIP STRTRAN( TXT_PREVIOUS, "
&", "" ) ;
        WHEN ::oDbf:RECCOUNT() > 1 .and. ::nPage > 1

    DEFINE BUTTON RESOURCE "
Next" OF ::oBar  ;
        MESSAGE TXT_GOTO_NEXT_PAGE           ;
        ACTION ::NextPage()                  ;
        TOOLTIP STRTRAN( TXT_NEXT, "
&", "" ) ;
        WHEN ::oDbf:RECCOUNT() > 1 .and. ::nPage < ::oDbf:RECCOUNT()

    DEFINE BUTTON RESOURCE "
Bottom" OF ::oBar ;
        MESSAGE TXT_GOTO_LAST_PAGE            ;        
        ACTION ::BottomPage()                 ;
        TOOLTIP STRTRAN( TXT_LAST, "
&", "" )  ;
        WHEN ::oDbf:RECCOUNT() > 1 .and. ::nPage < ::oDbf:RECCOUNT()

    DEFINE BUTTON ::oZoom RESOURCE "
Zoom" OF ::oBar GROUP ;
        MESSAGE TXT_ZOOM_THE_PREVIEW                      ;
        ACTION ::Zoom_in()                                   ;
        TOOLTIP STRTRAN( TXT_ZOOM, "
&", "" )
     
    DEFINE BUTTON oUnZoom RESOURCE "
UnZoom" OF ::oBar GROUP ;
        MESSAGE "
Deshacer Zoom de la página"                      ;
        ACTION ::Zoom_Out()                                   ;
        TOOLTIP "
Alejar"  

    /*DEFINE BUTTON RESOURCE "
Config" OF ::oBar GROUP ;
        MESSAGE "
Seleccionar impresora"             ;
        PROMPT "
Configurar"                         ;
        ACTION PrinterSetup() NOBORDER TOOLTIP "
Seleccionar Impresora"*/

    DEFINE BUTTON RESOURCE "
Print" OF ::oBar GROUP ;
        MESSAGE TXT_PRINT_CURRENT_PAGE             ;
        ACTION ::PRINT()                           ;
        TOOLTIP STRTRAN( TXT_PRINT, "
&", "" )

    DEFINE BUTTON RESOURCE "
Exit" OF ::oBar GROUP ;
        MESSAGE TXT_EXIT_PREVIEW               ;
        ACTION ::oWnd:END()                    ;
        TOOLTIP STRTRAN( TXT_EXIT, "
&", "" )
  ENDIF

 @ ::oBar:nTop + 4, ::oBar:GetBtnLeft()+600 COMBOBOX ::oSize ;
                VAR cSize ITEMS ASIZE OF ::oBar ;
                SIZE 60,300 FONT ::oFont ;
                ON CHANGE oObj:Zoom() PIXEL
   
   
  @ ::oBar:nTop + 6, ::oBar:nLeft + 700 SAY ::oPage    ;
    PROMPT TXT_PAGENUM + LTRIM( STR( ::nPage, 3 ) )  + ;
      "
/ " + LTRIM( STR( ::oDbf:RECCOUNT() ) )        ;
    SIZE 100, 15 PIXEL OF ::oBar FONT ::oFont

RETURN nil

//----------------------------------------------------------------------------//
METHOD BuildFGet() CLASS TTxtPreview
LOCAL oObj := self


   @ ::oBar:nHeight, 0 RICHEDIT ::oFGet VAR ::cTextFmt OF ::oWnd ;
     SIZE ::oWnd:nRight-::oWnd:nLeft-13,(::oWnd:nBottom-::oWnd:nTop)-::oBar:nHeight ;
     PIXEL HSCROLL READONLY

   ::oFGet:Hide()
   ::oFGet:bRClicked  := {| nRow, nCol | Self:MenuFGet( nRow, nCol ) }
   ::oFGet:bKeyDown   := {| nKey, nFlags | oObj:KeyDown( nKey, nFlags ) }
   ::oFGet:bKeyChar   := {| nKey, nFlags | oObj:KeyChar( nKey, nFlags ) }

RETURN nil

//----------------------------------------------------------------------------//
METHOD Activate() CLASS TTxtPreview

     
  IF ::oWnd != nil

    ++snCurPrev

    ACTIVATE WINDOW ::oWnd                      ;
      ON RESIZE     ::AjustFGet()               ;
      VALID         ::Destroy()

    ::zoom(100)
    ::zoom_in()  // se ve mejor asi
    ::oFGet:Show()

    WHILE !::lExit
       SysWait( .1 )
    ENDDO

    IF ::lPrvModal .and. ::oWndMain != nil
       ::oWndMain:Show()
    ENDIF

  ENDIF

RETURN nil

//----------------------------------------------------------------------------//
METHOD AjustFget() CLASS TTxtPreview

   LOCAL oRect := ::oWnd:GetCliRect()
   ::oFGet:SetSize( oRect:nWidth-1, oRect:nHeight-( ::oBar:nHeight ) )

RETURN Nil

//----------------------------------------------------------------------------//
METHOD MenuFGet( nRow, nCol ) CLASS TTxtPreview

   LOCAL oMenu, lEnd:= .f., i

   #ifdef _PREV_DLL
      SET RESOURCES TO ::cResFile
   #endif

   MENU oMenu POPUP

        IF ::oDbf:RECCOUNT() > 1 .and. ::nPage > 1
           MENUITEM TXT_FIRST    RESOURCE "
Top"      ACTION ::TopPage()
           MENUITEM TXT_PREVIOUS RESOURCE "
Prev"     ACTION ::PrevPage()
        ELSE
           MENUITEM TXT_FIRST    RESOURCE "
Top"      ACTION ::TopPage()  DISABLED
           MENUITEM TXT_PREVIOUS RESOURCE "
Prev"     ACTION ::PrevPage() DISABLED
        ENDIF

        IF ::oDbf:RECCOUNT() > 1 .and. ::nPage < ::oDbf:RECCOUNT()
           MENUITEM TXT_NEXT     RESOURCE "
Next"     ACTION ::NextPage()
           MENUITEM TXT_LAST     RESOURCE "
Bottom"   ACTION ::BottomPage()
        ELSE
           MENUITEM TXT_NEXT     RESOURCE "
Next"     ACTION ::NextPage()   DISABLED
           MENUITEM TXT_LAST     RESOURCE "
Bottom"   ACTION ::BottomPage() DISABLED
        ENDIF

        SEPARATOR

        MENUITEM "
Acercar"       RESOURCE "Zoom"     ACTION ::Zoom_in()
        MENUITEM "
Alejar"        RESOURCE "UnZoom"   ACTION ::Zoom_Out()
         SEPARATOR

        MENUITEM TXT_EXIT        RESOURCE "
Exit"     ACTION ::oWnd:END()

   ENDMENU

   ACTIVATE POPUP oMenu AT nRow - 60, nCol OF ::oFGet:oWnd

   IF ::oBar != Nil
      FOR i=1 TO 4
          ::oBar:aControls[i]:ForWhen()
          ::oBar:aControls[i]:Refresh()
      NEXT i
   ENDIF

   #ifdef _PREV_DLL
      SetResources( ::hOldRes )
   #endif

RETURN Nil

//----------------------------------------------------------------------------//
METHOD NextPage() CLASS TTxtPreview

  IF ::nPage == ::oDbf:RECCOUNT()
    MessageBeep()
    RETURN nil
  ENDIF

  ::nPage++

  #ifdef _PREV_DLL
     SET RESOURCES TO ::cResFile
  #endif

  ::oDbf:SKIP(1)
  ::oFGet:Settext(::TxtToRTF( ::oDbf:TEXT ))

  ::oPage:SetText( TXT_PAGENUM + LTRIM( STR( ::nPage, 4, 0 ) ) + ;
                   "
/ " + LTRIM( STR( ::oDbf:RECCOUNT() ) ) )

  ::oFGet:Refresh()
  ::oFGet:SetFocus()

  #ifdef _PREV_DLL
     SetResources( ::hOldRes )
  #endif

RETURN nil

//----------------------------------------------------------------------------//
METHOD PrevPage() CLASS TTxtPreview

  IF ::nPage == 1
    MessageBeep()
    RETURN nil
  ENDIF

  ::nPage--

  #ifdef _PREV_DLL
     SET RESOURCES TO ::cResFile
  #endif

  ::oDbf:SKIP(-1)
  ::oFGet:Settext(::TxtToRTF( ::oDbf:TEXT ))

  ::oPage:SetText( TXT_PAGENUM + LTRIM( STR( ::nPage, 4, 0 ) ) + ;
                   "
/ " + LTRIM( STR( ::oDbf:RECCOUNT() ) ) )
  ::oFGet:Refresh()

  ::oFGet:SetFocus()

  #ifdef _PREV_DLL
     SetResources( ::hOldRes )
  #endif

RETURN nil

//----------------------------------------------------------------------------//
METHOD TopPage() CLASS TTxtPreview

  IF ::nPage == 1
    MessageBeep()
    RETURN nil
  ENDIF

  ::nPage:= 1

  #ifdef _PREV_DLL
     SET RESOURCES TO ::cResFile
  #endif

  ::oDbf:GoTop()
  ::oFGet:Settext(::TxtToRTF( ::oDbf:TEXT ))

  ::oPage:SetText( TXT_PAGENUM + LTRIM( STR( ::nPage, 4, 0 ) ) + ;
                   "
/ " + LTRIM( STR( ::oDbf:RECCOUNT() ) ) )
  ::oFGet:Refresh()

  ::oFGet:SetFocus()

  #ifdef _PREV_DLL
     SetResources( ::hOldRes )
  #endif

RETURN nil

//----------------------------------------------------------------------------//
METHOD BottomPage() CLASS TTxtPreview

  IF ::nPage == ::oDbf:RECCOUNT()
    MessageBeep()
    RETURN nil
  ENDIF

  ::nPage   := ::oDbf:RECCOUNT()

  #ifdef _PREV_DLL
     SET RESOURCES TO ::cResFile
  #endif

  ::oDbf:GoBottom()
  ::oFGet:Settext(::TxtToRTF( ::oDbf:TEXT ))

  ::oPage:SetText( TXT_PAGENUM + LTRIM( STR( ::nPage, 4, 0 ) ) + ;
                   "
/ " + LTRIM( STR( ::oDbf:RECCOUNT() ) ) )
  ::oFGet:Refresh()
  ::oFGet:SetFocus()

  #ifdef _PREV_DLL
     SetResources( ::hOldRes )
  #endif

RETURN nil

//----------------------------------------------------------------------------//
METHOD Zoom(xFactor) CLASS TTxtPreview

LOCAL afonts := {"
",""}
LOCAL nFactor, nw


  IF !EMPTY(xFactor)
    nfactor:= xFactor / 100
  ELSE
    nfactor:= VAL(STRTRAN(::oSize:Varget(),"
%","")) / 100
  ENDIF
  IF ::lModoGraf
     // font modo grafico
     aFonts[ 1 ] := TFont():New( "
Lucida console", 0, -9*nfactor, ,;
                              , , , , , , , , , , ,  )
     ::oFGet:SetFont(aFonts[ 1 ])
  ELSE
     // font modo texto
     nW := ROUND(4.4 * nFactor,2)
     aFonts[ 2 ] := TFont():New( "
Courier New", 0, -10*nFactor, ,;
                              , , , , , , , , , , ,  )
     ::oFGet:SetFont(aFonts[ 2 ])
  ENDIF

  ::oFGet:Refresh()
  ::oFGet:SetFocus()

RETURN nil

//----------------------------------------------------------------------------//
METHOD Zoom_in() CLASS TTxtPreview

LOCAL oCur1, oCur2

DEFINE CURSOR oCur1 RESOURCE "
LUPA1"
DEFINE CURSOR oCur2 RESOURCE "
LUPA2"

  #ifdef _PREV_DLL
     SET RESOURCES TO ::cResFile
  #endif

  IF ::oSize:nAt < LEN(::oSize:aItems )
     ::oSize:SELECT(::oSize:nAt+1)
     ::oSize:change()
     ::zoom()
     ::oZoom:Enable()
     ::oZoom:Refresh()
     oUnZoom:Enable()
     oUnZoom:Refresh()
  ELSE
     ::oZoom:Disable()
     ::oZoom:Refresh()
     RETURN nil
  ENDIF

  #ifdef _PREV_DLL
     SetResources( ::hOldRes )
  #endif


RETURN nil

//----------------------------------------------------------------------------//
METHOD Zoom_out() CLASS TTxtPreview

LOCAL oCur1, oCur2

DEFINE CURSOR oCur1 RESOURCE "
LUPA1"
DEFINE CURSOR oCur2 RESOURCE "
LUPA2"

  #ifdef _PREV_DLL
     SET RESOURCES TO ::cResFile
  #endif

  IF ::oSize:nAt > 1
     ::oSize:SELECT(::oSize:nAt-1)
     ::oSize:change()
     ::zoom()
     oUnZoom:Enable()
     oUnZoom:Refresh()
     ::oZoom:Enable()
     ::oZoom:Refresh()
  ELSE
     oUnZoom:Disable()
     oUnZoom:Refresh()
     RETURN nil
  ENDIF

  #ifdef _PREV_DLL
     SetResources( ::hOldRes )
  #endif

RETURN nil

//----------------------------------------------------------------------------//
/* Version original de Joerg K. */
METHOD KeyDown( nKey, nFlags ) CLASS TTxtPreview

  IF nKey == 27     // VK_ESCAPE
     ::oWnd:END()
  ENDIF

  DO CASE
    CASE ( nKey == ASC( "
I" ) .OR. nKey == ASC( "i" ) ) .and. GetKeyState( VK_CONTROL )
      ::PRINT()
    CASE ( nKey == ASC( "
P" ) .OR. nKey == ASC( "p" ) ) .and. GetKeyState( VK_CONTROL )
      ::PRINT()
    CASE ( nKey == ASC( "
Z" ) .OR. nKey == ASC( "z" ) ) .and. GetKeyState( VK_CONTROL )
      ::Zoom_in()
    CASE  nKey == ASC( "
-" )  .and. GetKeyState( VK_CONTROL )
      ::Zoom_out()
    CASE  nKey == ASC( "
+" )  .and. GetKeyState( VK_CONTROL )
      ::Zoom_in()
  ENDCASE

  IF !::lZoom
    DO CASE
      CASE nKey == VK_HOME
        ::TopPage()
      CASE nKey == VK_END
        ::BottomPage()
      CASE nKey == VK_PRIOR
        ::PrevPage()
      CASE nKey == VK_NEXT
        ::NextPage()
    ENDCASE

  ELSE

  ENDIF

RETURN nil

METHOD KeyChar( nKey, nFlags ) CLASS TTxtPreview

  DO CASE
    CASE nKey == ASC( "
+" ) //.and. GetKeyState( VK_CONTROL )
      ::Zoom_in()
    CASE nKey == ASC( "
-" ) //.and. GetKeyState( VK_CONTROL )
      ::Zoom_out()
  ENDCASE

RETURN nil

//----------------------------------------------------------------------------//
METHOD PRINT() CLASS TTxtPreview

  LOCAL oDlg, oRad, oPageIni, oPageFin, oRange, oBtn, oSay, oGet
  LOCAL cPrinter:= ::cImpre    // cImpre: Agregado   por VDCL
  LOCAL  cDriver:= PrnGetDrive()
  LOCAL  cPuerto:= ::cPort     // cImpre: Modificado por VDCL

  LOCAL nOption := 1, ;
        nFirst  := 1, ;
        nLast   := ::oDbf:RECCOUNT() , ;
        nCopies := 1, ;
        nOldCop := nCopies, ;
        cRange  := SPACE( 30 )

  IF nLast == 1 .and. !::lPrintDlg

     ::PrintPrv( nil, nOption, nFirst, nLast )
     RETURN nil

  ELSE

        DEFINE DIALOG oDlg Resource "
IMPRIME" TITLE "Impresion de Documentos"
      REDEFINE SAY    oSay                   ID 100 OF oDlg
      REDEFINE GET    oGet VAR cPrinter      ID 101 OF oDlg READONLY COLOR Rgb(000,000,000), Rgb(255,255,206)
      REDEFINE SAY    oSay                   ID 102 OF oDlg
      REDEFINE GET    oGet VAR cDriver       ID 103 OF oDlg READONLY COLOR Rgb(000,000,000), Rgb(238,255,228)
      REDEFINE SAY    oSay                   ID 104 OF oDlg
      REDEFINE GET    oGet VAR cPuerto       ID 105 OF oDlg READONLY COLOR Rgb(000,000,000), Rgb(255,255,206)
      REDEFINE RADIO  oRad     VAR nOption   ID 106,107,108,109,110,111 OF oDlg ON CHANGE ( IF( nOption == 5, ;
                                                                                        ( oPageIni:Enable(), oPageFin:Enable() ), ;
                                                                                        ( oPageIni:Disable(), oPageFin:Disable() ) ), ;
                                                                                      IF( nOption == 6, oRange:Enable(), oRange:Disable() ) ) ;
                                                                                      WHEN ::oDbf:RECCOUNT() > 1
     REDEFINE SAY    oSay                    ID 112 OF oDlg
     REDEFINE GET    oGet      VAR nCopies   ID 113 OF oDlg UPDATE SPINNER MIN 1 MAX 999 VALID nCopies > 0 .and. nCopies <= 999 PICTURE "
999"
     REDEFINE GET    oPageIni  VAR nFirst    ID 114 OF oDlg PICTURE "
@K 99999" VALID IF( nFirst < 1 .OR. nFirst > nLast, ( MessageBeep() , .F. ), .T. )
     REDEFINE SAY    oSay                    ID 115 OF oDlg
     REDEFINE GET    oPageFin  VAR nLast     ID 116 OF oDlg PICTURE "
@K 99999" VALID IF( nLast < nFirst .OR. nLast > ::oDbf:RECCOUNT(), ( MessageBeep(), .F. ), .T. )
     REDEFINE GET    oRANGE    VAR cRange    ID 117 OF oDlg PICTURE "
@S!"
        oPageIni:Disable()
        oPageFin:Disable()
        oRange:Disable()

    REDEFINE BUTTONBMP oBtn ID 118 OF oDlg BITMAP "
ACEPTAR"  TEXTRIGHT ACTION ::PrintPrv( oDlg, nOption, nFirst, nLast, cRange, nCopies )
    REDEFINE BUTTONBMP oBtn ID 119 OF oDlg BITMAP "
CANCELAR" TEXTRIGHT ACTION oDlg:END()


     ACTIVATE DIALOG oDlg CENTERED ON INIT (oDlg:SetIcon(oIcon))

  ENDIF

RETURN nil

//----------------------------------------------------------------------------//  RDC
METHOD PrintPrv( oDlg, nOption, nPageIni, nPageEnd, cRange, nCopies ) CLASS TTxtPreview

  LOCAL nFor, nCopy, oPrn
  LOCAL nPages  := ::oDbf:RECCOUNT()
  LOCAL aPages, aRange, i, nCPage := ::oDbf:RECNO()

  DEFAULT nCopies:= 1

  CursorWait()

  IF ! ::lModoGraf

     oPrn:= TDosPrn():New()
     oPrn:cPort  := PrnGetPort()

     FOR nCopy = 1 TO nCopies

         DO CASE

            //--- Todas
            CASE nOption == 1
                 ::oDbf:GoTop()
                 DO WHILE !( ::oDbf:EOF() )
                    ::PrintPage( oPrn, ::oDbf:TEXT )
                    ::oDbf:SKIP(1)
                 ENDDO

            //--- Atual
            CASE nOption == 2
                 ::PrintPage( oPrn, ::oDbf:TEXT )

            //--- Pares
            CASE nOption == 3
                 ::oDbf:GOTO(2)                 // Vaí para a pag 2 (reg 2)
                 DO WHILE !( ::oDbf:EOF() )
                    ::PrintPage( oPrn, ::oDbf:TEXT )
                    ::oDbf:SKIP(2)              // Pula 2 registros
                 ENDDO

            //--- Impares
            CASE nOption == 4
                 ::oDbf:GoTop()                 // Vaí para a pag 1 (reg 1)
                 DO WHILE !( ::oDbf:EOF() )
                    ::PrintPage( oPrn, ::oDbf:TEXT )
                    ::oDbf:SKIP(2)              // Pula 2 registros
                 ENDDO

            //--- Seleccion
            CASE nOption == 5
                 ::oDbf:GoTop()
                 ::oDbf:GOTO( nPageIni )
                 DO WHILE !( ::oDbf:EOF() )
                    IF ::oDbf:Pagina >= nPageIni .and. ::oDbf:Pagina <= nPageEnd
                       ::PrintPage( oPrn, ::oDbf:TEXT )
                    ENDIF
                    IF ::oDbf:Pagina > nPageEnd
                       EXIT
                    ENDIF
                    ::oDbf:SKIP(1)
                 ENDDO

            //--- Range
            CASE nOption == 6
                 aPages := Str2Arr2( cRange, "
,", "-" )
                 FOR nFor := 1 TO LEN( aPages )
                     IF VALTYPE( aPages[ nFor ] ) == "
A"
                        aRange := { VAL( aPages[ nFor ][1] ), VAL( aPages[ nFor ][2] ) }
                        IF aRange[ 1 ] > 0 .and. aRange[ 2 ] > 0 .and. aRange[ 2 ] >= aRange[ 1 ]
                           FOR i := aRange[ 1 ] TO aRange[ 2 ]
                               ::oDbf:GOTO( i )
                               ::PrintPage( oPrn, ::oDbf:TEXT )
                           NEXT
                        ENDIF
                     ELSE
                        ::oDbf:GOTO( VAL( aPages[ nFor ] ) )
                        ::PrintPage( oPrn, ::oDbf:TEXT )
                     ENDIF
                 NEXT

         ENDCASE

     NEXT nCopy


     oPrn:END(,.f.)

     CursorArrow()

     IF oDlg != nil
        oDlg:END()
     ENDIF

  ELSE

     PRINT oPrn NAME "
Test"

     FOR nCopy = 1 TO nCopies

         DO CASE

            //--- Todas
            CASE nOption == 1
                 ::oDbf:GoTop()
                 DO WHILE !( ::oDbf:EOF() )
                    ::GPrint(oPrn,::oDbf:TEXT)
                    ::oDbf:SKIP(1)
                 ENDDO

            //--- Actual
            CASE nOption == 2
                ::GPrint(oPrn,::oDbf:TEXT)

            //--- Pares
            CASE nOption == 3
                 ::oDbf:GOTO(2)                 // Vaí para a pag 2 (reg 2)
                 DO WHILE !( ::oDbf:EOF() )
                    ::GPrint(oPrn,::oDbf:TEXT)
                    ::oDbf:SKIP(2)              // Pula 2 registros
                 ENDDO

            //--- Impares
            CASE nOption == 4
                 ::oDbf:GoTop()                 // Vaí para a pag 1 (reg 1)
                 DO WHILE !( ::oDbf:EOF() )
                    ::GPrint(oPrn,::oDbf:TEXT)
                    ::oDbf:SKIP(2)              // Pula 2 registros
                 ENDDO

            //--- Seleccion
            CASE nOption == 5
                 ::oDbf:GoTop()
                 ::oDbf:GOTO( nPageIni )
                 DO WHILE !( ::oDbf:EOF() )
                    IF ::oDbf:Pagina >= nPageIni .and. ::oDbf:Pagina <= nPageEnd
                       ::GPrint(oPrn,::oDbf:TEXT)
                    ENDIF
                    IF ::oDbf:Pagina > nPageEnd
                       EXIT
                    ENDIF
                    ::oDbf:SKIP(1)
                 ENDDO

            //--- Range
            CASE nOption == 6
                 aPages := Str2Arr2( cRange, "
,", "-" )
                 FOR nFor := 1 TO LEN( aPages )
                     IF VALTYPE( aPages[ nFor ] ) == "
A"
                        aRange := { VAL( aPages[ nFor ][1] ), VAL( aPages[ nFor ][2] ) }
                        IF aRange[ 1 ] > 0 .and. aRange[ 2 ] > 0 .and. aRange[ 2 ] >= aRange[ 1 ]
                           FOR i := aRange[ 1 ] TO aRange[ 2 ]
                               ::oDbf:GOTO( i )
                               ::GPrint(oPrn,::oDbf:TEXT)
                           NEXT
                        ENDIF
                     ELSE
                        ::oDbf:GOTO( VAL( aPages[ nFor ] ) )
                        ::GPrint(oPrn,::oDbf:TEXT)
                     ENDIF
                 NEXT

         ENDCASE

     NEXT nCopy

     ::oDbf:GOTO(nCPage)  //RDC
     ::nPage := ::oDbf:RECNO()
     ::cTextFmt:= ::TxtToRTF( ::oDbf:TEXT )
     ::oPage:SetText( TXT_PAGENUM + LTRIM( STR( ::nPage, 4, 0 ) ) + ;
                      "
/ " + LTRIM( STR( ::oDbf:RECCOUNT() ) ) )
     ::oFGet:Refresh()

     CursorArrow()

     oPrn:END()

     IF oDlg != nil
        oDlg:END()
     ENDIF

  ENDIF

RETURN nil

//----------------------------------------------------------------------------//
METHOD PrintPage( oPrn, cTxt ) CLASS TTxtPreview

   LOCAL nLines, nLin, cLine, cTmp, cTxt2, cTxtTmp, cPorta

   cPorta:= ::cPort

   IF Empt( cPorta )
      cPorta:= ALLTRIM( PrnGetPort() )
   ELSE
      cPorta:= ALLTRIM( cPorta )
   ENDIF
   /*
   if ! ( left(upper(cPorta),3) = 'LPT' )
      // desactivamos el spool si no son puertos directos
      // porque no funciona en XP - Win 200x
      ::lSpool := .f.
   else
      ::lSpool := .t.
   endif
   */
   IF ::lSpool

      cTxtTmp := UPPER( cTmpName( ::cDir ) )
      cTxtTmp := STRTRAN( cTxtTmp, "
.DBF", ".TXT" )

      nLines:= MLCOUNT( cTxt, 240 )
      cTxt2:= "
"
      FOR nLin= 1 TO nLines
          cTxt2 += RTRIM( MEMOLINE( cTxt, 240, nLin ) ) + CRLF
      NEXT nLin
      cTxt := ALLTRIM( cTxt2 )

      MEMOWRIT( cTxtTmp, STRTRAN( cTxt, ::cFormFeed, "
" ) + ::cFormFeed )

      IF FILE('dosprint.bat')
         WAITRUN("
DOSPRINT.BAT " + cTxtTmp + " " + cPorta, 0 )
      ELSE
         cPorta:= "
PRN"
         winexec( "
start c:\command.com /c copy /b "+ cTxtTmp + " " + cPorta)
      ENDIF

      IF FILE( cTxtTmp )
      *  FERASE( cTxtTmp )
      ENDIF

   ELSE
      oPrn:Startpage()

      nLines:= MLCOUNT( cTxt, 240 )
      FOR nLin= 1 TO nLines
          cLine := RTRIM( MEMOLINE( cTxt, 240, nLin ) )
          oPrn:SAY( nLin, 00, STRTRAN( cLine, ::cFormFeed, "
" ) )
      NEXT nLin

      oPrn:EndPage()

   ENDIF

RETURN Nil

//----------------------------------------------------------------------------//
METHOD BuildMenu() CLASS TTxtPreview

  LOCAL nFor

  MENU ::oMenu

    MENUITEM TXT_FILE
    MENU
      MENUITEM TXT_PRINT ACTION ::PRINT() ;
        MESSAGE TXT_PRINT_CURRENT_PAGE RESOURCE "
Printer"

      SEPARATOR

      MENUITEM TXT_EXIT ACTION ::oWnd:END() ;
        MESSAGE TXT_EXIT_PREVIEW RESOURCE "
Exit"

    ENDMENU

    MENUITEM TXT_PAGE
    MENU
      MENUITEM TXT_FIRST ACTION ::TopPage() ;
        MESSAGE TXT_GOTO_FIRST_PAGE RESOURCE "
Top"

      MENUITEM TXT_PREVIOUS ACTION ::PrevPage() ;
        MESSAGE TXT_GOTO_PREVIOUS_PAGE RESOURCE "
Previous"

      MENUITEM TXT_NEXT ACTION ::NextPage() ;
        MESSAGE TXT_GOTO_NEXT_PAGE RESOURCE "
Next"

      MENUITEM TXT_LAST ACTION ::BottomPage() ;
        MESSAGE TXT_GOTO_LAST_PAGE RESOURCE "
Bottom"

      SEPARATOR

      MENUITEM ::oMenuZoom PROMPT TXT_ZOOM ACTION ::Zoom_in() ENABLED ;
        MESSAGE TXT_ZOOM_THE_PREVIEW RESOURCE "
Zoom +"

      MENUITEM ::oMenuUnZoom PROMPT TXT_UNZOOM ACTION ::Zoom_out() ENABLED ;
        MESSAGE "
Deshacer Zoom de la página" RESOURCE "Zoom -"

    ENDMENU

  ENDMENU

RETURN nil

//----------------------------------------------------------------------------//
METHOD BuildDbfTmp() CLASS TTxtPreview

   LOCAL oFile, nPag, cTxt, lFim, oDlg, oBtn
   LOCAL cLine, nStart, nEnd, cAlias, oIcono

   SysRefresh()
   
   cAlias  := cGetNewAlias( "
TXTP" )

   ::cDbfTmp := UPPER( cTmpName( ::cDir ) )
   ::cMemTmp := STRTRAN( ::cDbfTmp, "
.DBF", cMemoExt() )

   IF FILE( ::cDbfTmp )
      FERASE( ::cDbfTmp )
   ENDIF

   DBCREATE( ::cDbfTmp, { { "
PAGINA", "N",  5, 00 },;
                          { "
TEXT",   "M", 10, 00 } } )

   USE ( ::cDbfTmp ) EXCLUSIVE ALIAS &( cAlias ) NEW

   oFile = TTxtFile():New( ::cTxtFile )
   IF ! oFile:Open( 0 )
      MsgInfo( "
El Archivo " + ::cTxtFile + ", no puede ser abierto." )
      RETURN nil
   ENDIF

   DEFINE   DIALOG    oDlg   Resource    "
PREVIEW_PROC" TITLE "Generando Previsualizacion..."
   REDEFINE ICON      oIcono ID 105      RESOURCE "
XPRINT"  OF oDlg
   REDEFINE BUTTONBMP oBtn   ID IDCANCEL BITMAP   "
ESPERA" TEXTRIGHT OF oDlg  ACTION .t.
   ACTIVATE DIALOG    oDlg   CENTER      ON INIT (oDlg:SetIcon(oIcon))

   CursorWait()
   SysRefresh()

   nPag= 0
   cTxt= "
"
   lFim= .F.

   DO WHILE .T.

      cLine = oFile:cLine
      IF ::lModoGraf
         // eliminamos algunos caracteres de control de la impresora
         cLine = STRTRAN(cLine, ::cNegOn , "
")
         cLine = STRTRAN(cLine, ::cNegOff, "
")
         cLine = STRTRAN(cLine, ::c10cpi , "
")
         cLine = STRTRAN(cLine, ::c12cpi , "
")
         cLine = STRTRAN(cLine, ::cWidOn , "
")
         cLine = STRTRAN(cLine, ::cWidOff, "
")
      ENDIF
      cTxt += cLine + SPACE(1) + CRLF

      oFile:SKIP(1)

      //--- si encuentra salto de pagina
      IF ::cFormFeed $ cLine .OR. oFile:lEof()

         nPag ++                          // incrementa Pagina

         append blank                     // adiciona reg
         REPLACE PAGINA WITH nPag         // grava os dados
         REPLACE TEXT   WITH cTxt

         cTxt = "
"

      ENDIF

      IF oFile:lEof
         lFim = .t.
         EXIT
      ENDIF

   ENDDO

   oFile:CLOSE()

   SELECT ( cAlias )
   DATABASE ::oDbf
   ::oDbf:bEoF = nil
   ::oDbf:bBoF = nil
   ::oDbf:GoTop()

   CursorArrow()
   oDlg:END()

RETURN Nil

//----------------------------------------------------------------------------//
METHOD TxtToRTF( cTxt ) CLASS TTxtPreview

// Esta rutina falta mejorar para convertir los tipos de letras
// en formato RTF

   LOCAL cType, cTextFormat, nColor
   LOCAL lFlagComp

   cTextFormat := "
"

   cTxt = STRTRAN(cTxt, ::cNegOn , "
")
   cTxt = STRTRAN(cTxt, ::cNegOff, "
")
   cTxt = STRTRAN(cTxt, ::c10cpi , "
")
   cTxt = STRTRAN(cTxt, ::c12cpi , "
")
   cTxt = STRTRAN(cTxt, ::cWidOn , "
")
   cTxt = STRTRAN(cTxt, ::cWidOff, "
")
   cTxt = STRTRAN(cTxt, ::cCompress, "
")
   cTxt = STRTRAN(cTxt, ::cNormal, "
")

   IF IsOEM(cTxt)
      cTxt := OemToAnsi(cTxt)
   ENDIF
   IF ( lFlagComp:= ( AT( ::cCompress, cTxt ) > 0 ) )
      //define font
      ::lZoom:= .t.

   ELSE

      ::lZoom:= .f.

   ENDIF

   cTxt:= STRTRAN( cTxt, ::cFormFeed, "
" )
   cTextFormat += cTxt

RETURN cTextFormat

//----------------------------------------------------------------------------//
METHOD Command( cStr1, cStr2, cStr3, cStr4, cStr5 ) CLASS TTxtPreview

 LOCAL cCommand, cToken, cString
 LOCAL nToken

 cString := cStr1

 IF cStr2 != nil
    cString += "
," + cStr2
 ENDIF

 IF cStr3 != nil
    cString += "
," + cStr3
 ENDIF

 IF cStr4 != nil
    cString += "
," + cStr4
 ENDIF

 IF cStr5 != nil
    cString += "
," + cStr5
 ENDIF

 cCommand := "
"
 nToken   := 1

 DO WHILE ! EMPTY( cToken := StrToken( cString, nToken++, "
," ) )
    cCommand += CHR(VAL(cToken))
 ENDDO

RETURN cCommand

//----------------------------------------------------------------------------//
METHOD Destroy() CLASS TTxtPreview

   ::oWnd:oIcon := nil
   ::oFGet:END()
   ::oDbf:CLOSE()
   FERASE( ::cDbfTmp )
   FERASE( ::cMemTmp )
   IF ::lKillFile      // RDC
      FERASE( ::cTxtFile )
   ENDIF

   SELECT(nOldArea)   //RDC

   ::lExit := .T.
   --snCurPrev

   IF oMdiTmp != Nil
      oMdiTmp:END()
      oMdiTmp:= Nil
   ENDIF

   IF UPPER( ::oWnd:ClassName() ) == "
TMDICHILD"
      ::oWnd:oWndClient:ChildClose( ::oWnd )
   ENDIF

   ::oWndMain:Setfocus()

   Self:= Nil

RETURN .t.

//----------------------------------------------------------------------------//
// Static functions
//----------------------------------------------------------------------------//
STATIC FUNCTION cTmpName( cDir )      // Toninho@fwi.com.br

   LOCAL cFile:= cDir + STRTRAN( LTRIM( STR( SECONDS() ) ), "
.", "" ) + ".dbf"

   WHILE FILE( cFile )
      cFile = cDir + STRTRAN( LTRIM( STR( SECONDS() ) ), "
.", "" ) + ".dbf"
   ENDDO

RETURN cFile

//----------------------------------------------------------------------------//
STATIC FUNCTION cMemoExt()

   LOCAL cRet, cRddName

   cRddName := RDDSETDEFAULT()

   #ifdef __HARBOUR__
      cRddName := IF( cRddName == "
DBF", "DBFNTX", cRddName )
   #endif

   IF "
DBFCDX" $ cRddName .OR. "SIXCDX" $ cRddName
      cRet:= "
.FPT"

   ELSEIF cRddName = "
ADS"
      cRet:= "
.DBT"

   ELSE
      cRet:= "
.DBT"

   ENDIF

RETURN cRet

//----------------------------------------------------------------------------//
STATIC FUNCTION Str2Arr2( cStr, cDelim, cSubDelim )

  LOCAL aArray  := {}
  LOCAL nPos    := 0
  LOCAL cTmp

  DEFAULT cDelim := "
,"

  WHILE ( nPos := AT( cDelim, cStr ) ) != 0
    cTmp := SUBSTR( cStr, 1, nPos - 1 )
    IF cSubDelim != nil
      IF AT( cSubDelim, cTmp ) > 0
        cTmp  := Str2Arr2( cTmp, cSubDelim )
      ENDIF
    ENDIF
    AADD( aArray, cTmp )
    nPos += LEN( cDelim )
    cStr := SUBSTR( cStr, nPos )
  ENDDO
  AADD( aArray, cStr )

RETURN aArray

//----------------------------------------------------------------------------//
#define TA_BASELINE            24

METHOD GPrint(oPrint, cTexto) CLASS TTxtPreview

   LOCAL n
   LOCAL oPrn
   LOCAL nRow := 0
   LOCAL nCol := 0
   LOCAL nMarg := 100
   LOCAL nRowStep
   LOCAL cText
   LOCAL oFont, nFont
   // creamos un array para guardar fonts apropiados para impresora laser
   LOCAL aFonts := ARRAY( 4 ), lIsPrt

   IF EMPTY(oPrint)
      PRINT oPrn NAME "
Notes"
      lIsPrt := .t.
   ELSE
      oPrn := oPrint
      lIsPrt := .f.
   ENDIF

   IF EMPTY( oPrn:hDC )
      MsgStop( "
Printer not ready!" )
      RETURN self
   ENDIF

   oPrn:Setpage(9)   // A4
   cFaceName := "
Lucida console"  // este es un font escalable

   nWidth  := 0
   nHeight := -11.9
   // definimos escalas equivalentes a los fonts tradicionales modo DOS
   //         normal, elite, comprimida, elite comprimida
   aSizes := {1, 80/96, 10/17, 10/20 }
   // Definimos los fonts a usar
   aFonts[ 1 ] := TFont():New( cFaceName, nWidth, nHeight, ,;
                               , , , , , , , , , , , oPrn )
   aFonts[ 2 ] := TFont():New( cFaceName, nWidth*aSizes[2], nHeight*aSizes[2], ,;
                               , , , , , , , , , , , oPrn )
   aFonts[ 3 ] := TFont():New( cFaceName, nWidth*aSizes[3], nHeight*aSizes[3], ,;
                               , , , , , , , , , , , oPrn )
   aFonts[ 4 ] := TFont():New( cFaceName, nWidth*aSizes[4], nHeight*aSizes[4], ,;
                               , , , , , , , , , , , oPrn )
   CursorWait()

   aText := ::Text2Lines(cTexto)

   PAGE

      nRowStep := 0
      oFont := aFonts[ 1 ]
      nMaxlen := 0

      FOR n := 1 TO LEN( aText )
          cText := aText[ n ]
          nMaxlen := MAX( nMaxlen, LEN(cText) )
      NEXT
      // escojemos el font adecuado para la longitud del texto
      // el tamaño maximo de todas las lineas determina el font a usar
      // y ese font se usa para calcular el avance de linea
      DO CASE
      CASE nMaxlen<= 80
           nFont := 2   // el font1 es muy grande para imprimir
      CASE nMaxlen<= 96
           nFont := 2
      CASE nMaxlen<= 132
           nFont := 3
      CASE nMaxlen<= 160
           nFont := 4
      OTHERWISE
           nFont := 4
      ENDCASE
      nFont := MAX( 1, nFont )
      oFont := aFonts[ nFont ]
      // vemos si es necesario ajustar el tamaño de fuente por un factor para
      // que el texto entre en la hoja horizontalmente
      cText := ATAIL(aText)
      nWidthLine := ( oPrn:GetTextWidth( RIGHT(ALLTRIM(cText),1), oFont ) * nMaxlen ) + nMarg + 80
      IF nWidthLine > oPrn:nHorzRes()
         factor := ROUND(oPrn:nHorzRes() / (nWidthLine),4)
         msgwait("
ajustando texto al ancho de la hoja "+TRANSFORM(factor*100,"999")+"%",,1)
         oFont := TFont():New( cFaceName, nWidth*aSizes[nFont]*factor, nHeight*aSizes[nFont]*factor, ,;
                                  , , , , , , , , , , , oPrn )
      ENDIF
      nRowStep := ABS( oFont:nHeight )*1.15 // aumentamos un 15% para mejor legibilidad
      //--------------
      nCol := 0

      FOR n := 1 TO LEN( aText )
          cText := aText[ n ]
          oPrn:SAY( nRow, nMarg+nCol, cText, oFont )
          nRow += nRowStep
          IF nRow > oPrn:nVertRes()
             nRow := nRowStep
             ENDPAGE
             PAGE
          ENDIF
      NEXT

   ENDPAGE

   IF lIsPrt
     ENDPRINT
   ENDIF

   AEVAL( aFonts, { |oFont| oFont:END() } )

   CursorArrow()

RETURN nil


//----------------------------------------------------------------------------//

METHOD Text2Lines( cTxt ) CLASS TTxtPreview
LOCAL cLine, aLines := {}, nLin
// eliminamos algunos caracteres de control de la impresora
// porque vamos a imprimir en formato plano
// asumimos que no hay cambio de font en una misma linea
cTxt = STRTRAN(cTxt, ::cNegOn , "
")
cTxt = STRTRAN(cTxt, ::cNegOff, "
")
cTxt = STRTRAN(cTxt, ::c10cpi , "
")
cTxt = STRTRAN(cTxt, ::c12cpi , "
")
cTxt = STRTRAN(cTxt, ::cWidOn , "
")
cTxt = STRTRAN(cTxt, ::cWidOff, "
")
cTxt = STRTRAN(cTxt, ::cCompress, "
")
cTxt = STRTRAN(cTxt, ::cNormal, "
")
IF IsOEM(cTxt)
   cTxt := OemToAnsi(cTxt)
ENDIF

nCrLF := AT( CRLF, cTxt )
DO WHILE nCrLF > 0
   cLine := SUBSTR( cTxt, 1, nCrLF - 1 )
   cLine := STRTRAN( cLine, ::cFormFeed, "
" )
   AADD(aLines, TRIM(cLine))
   cTxt := SUBSTR( cTxt, nCrLF+2 )
   nCrLF := AT( CRLF, cTxt )
ENDDO

RETURN aLines
Un saludo
Pedro
gahetesoft@gmail.com
FWH12.06 BCC582, Xverce CW, Pelles C 6.00.4,PSPAD 4.54
y ahora con ADO
User avatar
Pedro
 
Posts: 464
Joined: Tue Mar 21, 2006 7:30 pm
Location: Córdoba (España)

Re: Problemas con Tprinter y Tdosprn

Postby Pedro » Sat Feb 11, 2012 10:18 am

Hola a todos

Antonio, después de haber echo unas cuantas pruebas, resulta que no pasa por la clase tdosprn que yo incluyo en la aplicación, ya que el msginfo("tdosprn") que tengo puesto en el método NEW, no salta, por lo que intuyo que no toma esta clase.
No obstante, oPrn si que va a la clase TTxtView como un objeto
Un saludo
Pedro
gahetesoft@gmail.com
FWH12.06 BCC582, Xverce CW, Pelles C 6.00.4,PSPAD 4.54
y ahora con ADO
User avatar
Pedro
 
Posts: 464
Joined: Tue Mar 21, 2006 7:30 pm
Location: Córdoba (España)

Re: Problemas con Tprinter y Tdosprn

Postby Antonio Linares » Sat Feb 11, 2012 11:00 am

Pedro,

me da un error Message not found: TDOSPRN:CNEGON


Puedes copiar aqui el contenido del fichero error.log que se genera ? gracias
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Problemas con Tprinter y Tdosprn

Postby Pedro » Sat Feb 11, 2012 11:52 am

Antonio, aquí te pongo el error.log.
Tan sólo decirte que cambiando el nombre a la clase TdosPrn, por TdosPrnEx se soluciona el problema, ahora si que toma esta nueva clase. Esto debe ser alguna incompatibilidad del prg con la lib.

ERROR.LOG

Error description: Warning BASE/1004 Message not found: TDOSPRN:CNEGON

Stack Calls
===========
Called from: source\rtl\tobject.prg => TDOSPRN:ERROR( 0 )
Called from: source\rtl\tobject.prg => TDOSPRN:MSGNOTFOUND( 0 )
Called from: source\rtl\tobject.prg => TDOSPRN:CNEGON( 0 )
Called from: C:\PROYEC~1\PIZARRO\SOURCE\txtview.prg => TTXTPREVIEW:NEW( 289 )
Called from: C:\PROYEC~1\PIZARRO\SOURCE\txtview.prg => TXTPREVIEW( 142 )
Called from: C:\PROYEC~1\PIZARRO\SOURCE\imptickets.prg => IMPRIMETICKET( 153 )
Called from: C:\PROYEC~1\PIZARRO\SOURCE\gesh0200.prg => IMPRIMEVENTA( 302 )
Called from: C:\PROYEC~1\PIZARRO\SOURCE\gesh0200.prg => (b)VENTAS( 70 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 465 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 656 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1690 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 1407 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3159 )
Called from: => WINRUN( 0 )
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 980 )
Called from: C:\PROYEC~1\PIZARRO\SOURCE\geshinic.prg => MAIN( 159 )

System
======
CPU type: Pentium(R) Dual-Core CPU E5700 @ 3.00GHz 3000 Mhz
Hardware memory: 2145 megs

Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %

Windows total applications running: 12
1 , C:\Program Files\Google\Chrome\Application\chrome.exe
2 , C:\Program Files\PSPad editor\PSPad.exe
3 , C:\Windows\Explorer.EXE
4 , C:\Windows\System32\hkcmd.exe
5 , C:\XVERCE\xverce.Exe
6 CiceroUIWndFrame, C:\Windows\system32\taskhost.exe
7 DWM Notification Window, C:\Windows\system32\Dwm.exe
8 Gestión Comercial [ 012011 FERRETERIA MARI CARMEN PIZARRO ] - [Fichero de Ventas], C:\Proyectos\PIZARRO\GFACTU.Exe
9 MCI command handling window, C:\Program Files\AVAST Software\Avast\AvastUI.exe
10 PersistWndName, C:\Windows\System32\igfxpers.exe
11 advertencia, C:\Program Files\VIA\VIAudioi\VDeck\VDeck.exe
12 igfxtrayWindow, C:\Windows\System32\igfxtray.exe

Variables in use
================
Procedure Type Value
==========================
TDOSPRN:ERROR
Param 1: C "Message not found"
Param 2: C "TDOSPRN"
Param 3: C "CNEGON"
Param 4: N 1004
Local 1: U
Local 2: O Class: TDOSPRN
Local 3: N 13
TDOSPRN:MSGNOTFOUND
Param 1: C "CNEGON"
Local 1: O Class: TDOSPRN
TDOSPRN:CNEGON
TTXTPREVIEW:NEW
Param 1: C "\PROYECTOS\PIZARRO\Programacion\TICKET.PRN"
Param 2: O Class: TMDIFRAME
Param 3: L .T.
Param 4: C "Impresion de Pruebas"
Param 5: L .F.
Param 6: C "CPW2:"
Param 7: O Class: TDOSPRN
Param 8: L .T.
Param 9: L .F.
Param 10: C "CUTEPDF WRITER"
Local 1: O Class: TTXTPREVIEW
Local 2: U
Local 3: U
Local 4: U
Local 5: U
Local 6: U
Local 7: U
Local 8: U
Local 9: U
Local 10: U
Local 11: O Class: TTXTPREVIEW
Local 12: U
Local 13: O Class: TTXTPREVIEW
TXTPREVIEW
Param 1: C "\PROYECTOS\PIZARRO\Programacion\TICKET.PRN"
Param 2: C "Impresion de Pruebas"
Param 3: L .T.
Param 4: U
Param 5: C "CPW2:"
Param 6: O Class: TDOSPRN
Param 7: U
Param 8: U
Param 9: L .F.
Param 10: C "CUTEPDF WRITER"
Local 1: U
Local 2: N 4194304
Local 3: N 1782448128
IMPRIMETICKET
Param 1: N 14
Local 1: O Class: TDOSPRN
Local 2: N 0
Local 3: N 17
Local 4: N 40
Local 5: U
Local 6: C "\PROYECTOS\PIZARRO\Programacion\TICKET.PRN"
Local 7: L .F.
Local 8: A Len: 3
Local 9: C "CUTEPDF WRITER"
Local 10: C "CPW2:"
Local 11: L .T.
Local 12: C "@COPY /B %1 %2 >Nul
@exit"
Local 13: C "\PROYECTOS\PIZARRO\Programacion\DOSPRINT.BAT"
Local 14: C "Programacion"
Local 15: C "\PROYECTOS\PIZARRO\Programacion"
Local 16: C "\PROYECTOS\PIZARRO"
IMPRIMEVENTA
(b)VENTAS
Param 1: O Class: TBTNBMP
TBTNBMP:CLICK
Local 1: O Class: TBTNBMP
TBTNBMP:LBUTTONUP
Param 1: N 38
Param 2: N 39
Param 3: O Class: TBTNBMP
Local 1: U
Local 2: L .T.
TCONTROL:HANDLEEVENT
Param 1: N 514
Param 2: N 0
Param 3: N 2490407
Local 1: O Class: TBTNBMP
Local 2: U
TBTNBMP:HANDLEEVENT
Param 1: N 514
Param 2: N 0
Param 3: N 2490407
Local 1: O Class: TBTNBMP
_FWH
Param 1: N 2490407
Param 2: N 514
Param 3: N 0
Param 4: N 2490407
Param 5: N 24
Local 1: O Class: TBTNBMP
WINRUN
Param 1: N 853208
TMDIFRAME:ACTIVATE
Param 1: C "MAXIMIZED"
Param 2: U
Param 3: U
Param 4: U
Param 5: U
Param 6: B {|| ... }
Param 7: U
Param 8: B {|| ... }
Param 9: U
Param 10: U
Param 11: U
Param 12: U
Param 13: U
Param 14: U
Param 15: U
Param 16: U
Param 17: B {|| ... }
Param 18: U
Param 19: U
Local 1: O Class: TMDIFRAME
Local 2: U
Local 3: U
MAIN
Local 1: A Len: 2
Local 2: N 22740992
Local 3: O Class: TBTNBMP
Local 4: O Class: TBTNBMP
Local 5: O Class: TBTNBMP
Local 6: O Class: TBTNBMP
Local 7: O Class: TBTNBMP
Local 8: O Class: TMENU
Local 9: O Class: TMENU
Local 10: O Class: TMENU
Local 11: O Class: TMENU
Local 12: O Class: TMENU

Linked RDDs
===========
DBF
DBFFPT
DBFBLOB
DBFCDX
DBFNTX

DataBases in use
================

1: => CMOS RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
14 14 .F. .F.

Indexes in use TagName
=> NUMERO NUMERO
CLIENTE CLIENTE
DTOS(FECHA) FECHA

Relations in use

2: LMOS RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
27 26 .F. .T.

Indexes in use TagName
=> NUMERO NUMERO

Relations in use

3: CLIE RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
37 37 .F. .F.

Indexes in use TagName
=> CODIGO CODIGO
NOMBRE NOMBRE

Relations in use

4: ARTI RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
4550 7391 .F. .F.

Indexes in use TagName
=> CODIGO CODIGO
DESCRIPCIO NOMBRE
FAMILIA FAMILIA
PROVEEDOR PROVEEDOR

Relations in use

5: CCTE RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
1 3 .F. .F.

Indexes in use TagName
=> NUMERO NUMERO
CLIENTE CLIENTE

Relations in use

6: LCTE RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
1 4 .F. .F.

Indexes in use TagName
=> NUMERO NUMERO

Relations in use

Classes in use:
===============
1 ERROR
2 HASHENTRY
3 HBCLASS
4 HBOBJECT
5 TFONT
6 TWINDOW
7 TCONTROL
8 TICON
9 TBRUSH
10 TBITMAP
11 TMDIFRAME
12 TMENU
13 TMDICLIENT
14 TMSGBAR
15 TRECT
16 TMSGITEM
17 TTIMER
18 TBAR
19 TBTNBMP
20 TMENUITEM
21 TDATABASE
22 TDIALOG
23 TBUTTON
24 TBUTTONBMP
25 TXBROWSE
26 TXBRWCOLUMN
27 TSCROLLBAR
28 TMDICHILD
29 TDOSPRN
30 TTXTPREVIEW
31 TREG32

Memory Analysis
===============
282 Static variables

Dynamic memory consume:
Actual Value: 0 bytes
Highest Value: 0 bytes
Un saludo
Pedro
gahetesoft@gmail.com
FWH12.06 BCC582, Xverce CW, Pelles C 6.00.4,PSPAD 4.54
y ahora con ADO
User avatar
Pedro
 
Posts: 464
Joined: Tue Mar 21, 2006 7:30 pm
Location: Córdoba (España)

Re: Problemas con Tprinter y Tdosprn

Postby Antonio Linares » Sat Feb 11, 2012 1:55 pm

Pedro,

Efectivamente, se debía estar enlazando la de FWH en vez de la tuya

Me alegro de que esté solucionado

Queda algo más ? (de momento) :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Problemas con Tprinter y Tdosprn

Postby Pedro » Sat Feb 11, 2012 5:00 pm

Pues aún me queda una cosa, Antonio.

Me queda el por qué ahora hay que poner en el FONT de la clase tPrinter un Size tan alto .
Me explico, antes poníamos DEFINE FONT oFont NAME "ARIAL" SIZE 0,-10 ó -12, etc, pero ahora he tenido que modificarlo y poner -50 para tenerlo igual que antes era -10
de lo contrario las letras en el listado salen como nanoletras :shock:
Lo curioso es que solo se da en la clase Tprinter, en TReport los valores son los mismos que antes.
Un saludo
Pedro
gahetesoft@gmail.com
FWH12.06 BCC582, Xverce CW, Pelles C 6.00.4,PSPAD 4.54
y ahora con ADO
User avatar
Pedro
 
Posts: 464
Joined: Tue Mar 21, 2006 7:30 pm
Location: Córdoba (España)

Re: Problemas con Tprinter y Tdosprn

Postby Antonio Linares » Sun Feb 12, 2012 10:16 am

Pedro,

Cuando defines un Font especificas su impresora previamente creada ?

DEFINE FONT oFont NAME ... SIZE ... OF oPrinter
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Problemas con Tprinter y Tdosprn (solucionado)

Postby Pedro » Mon Feb 13, 2012 8:57 am

Hola Antonio

Pues pedirte disculpas, ya que llevas razón, olvidé o borré poner el OF oPrn, después de tantos días intentando averiguar el motivo por el que después de actualizar los listados con TDosPrn no salían. Me inclino por que borré sin darme cuenta el OF oPrn, ya que antes estaba funcionando. Lo curioso es que funcione el font sin asignarlo.
En fin que de momento todo solucionado.
Muchas gracias
Un saludo
Pedro
gahetesoft@gmail.com
FWH12.06 BCC582, Xverce CW, Pelles C 6.00.4,PSPAD 4.54
y ahora con ADO
User avatar
Pedro
 
Posts: 464
Joined: Tue Mar 21, 2006 7:30 pm
Location: Córdoba (España)


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 47 guests