Code: Select all
#include "Fivewin.ch"
#xtranslate NTRIM( < n > ) = > ( LTrim( Str( < n > ) ) )
#xtranslate MM2PxHor( < nMM >, < oPrn > ) = > < nMM > / 25.4 * < oPrn > :nLogPixelX()
#xtranslate MM2PxVer( < nMM >, < oPrn > ) = > < nMM > / 25.4 * < oPrn > :nLogPixelY()
#xtranslate Px2MMVer( < nPx >, < oPrn > ) = > < nPx > * 25.4 / < oPrn > :nLogPixelY()
FUNCTION Main()
Stampa( 0, "Prova Verticale" )
Stampa( 1, "Prova Orizzontale" )
RETURN Nil
FUNCTION Stampa( nOriente, cTitolo )
LOCAL nZ, aTabul
LOCAL oFont, Font, nTmp, cTxt
LOCAL oPen, oPen1, oPen2, nPag, aParam := { }, aCorpo
LOCAL oPrinter, nPosRow, nPosCol, nMax, nCol
DEFAULT cTitolo := "Prova Orizzontale", nOriente := 1
nPag := 0
aTabul := { { "Colonna 1", 0, 8, 53, 1 }, ;
{ "Colonna 2", 0, 63, 60, 3 }, ;
{ "Colonna 3", 0, 125, 65, 5 } }
// Qui imposto la stampa da fivewin
PRINT oPrinter PREVIEW // NAME cTxt MODAL // TO cPrinter
IF oPrinter:hDC != 0
oFont := { }
DEFINE Font Font NAME "Arial" SIZE 0, - 20 BOLD OF oPrinter
AAdd( oFont, Font )
DEFINE Font Font NAME "Arial" SIZE 0, - 9 BOLD OF oPrinter
AAdd( oFont, Font )
DEFINE Font Font NAME "Arial" SIZE 0, - 9 OF oPrinter
AAdd( oFont, Font )
SysRefresh()
PAGE
IF nOriente > 0
oPrinter:SetLandscape()
ELSE
oPrinter:SetPortrait()
ENDIF
SysRefresh()
aParam := oPrinter:GetPhySize()
AAdd( aParam, 15 )
AAdd( aParam, 10 )
AAdd( aParam, 25 )
AAdd( aParam, 5 )
DEFINE PEN oPen WIDTH 1 OF oPrinter
DEFINE PEN oPen1 WIDTH 10 OF oPrinter
DEFINE PEN oPen2 WIDTH 15 OF oPrinter
aCorpo := Array( 2 )
nCol := Len( aTabul )
nMax := 0
nTmp := 0
nPosRow := 15
nPosCol := 10
oPrinter:Say( MM2PxVer( nPosRow, oPrinter ), ;
MM2PxHor( nPosCol, oPrinter ), ;
cTitolo, oFont[ 1 ] )
nPosRow += Px2MMVer( oFont[ 1 ]:nHeight, oPrinter ) + aParam[ 6 ]
nMax := 0
FOR nZ := 1 TO nCol
nTmp := MM2PxVer( nPosRow, oPrinter ) + aTabul[ nZ, 2 ] * oFont[ 2 ]:nHeight * 1.2
IF nMax < nTmp
nMax := nTmp
ENDIF
oPrinter:Say( nTmp, ;
MM2PxHor( ( nPosCol + aTabul[ nZ, 3 ] ), oPrinter ), ;
aTabul[ nZ, 1 ], oFont[ 2 ] )
NEXT
aCorpo[ 1 ] := nMax + oFont[ 2 ]:nHeight * 1.2
oPrinter:Line( aCorpo[ 1 ], ;
MM2PxHor( ( aParam[ 4 ] ), oPrinter ), ;
aCorpo[ 1 ], ;
MM2PxHor( ( aParam[ 1 ] - aParam[ 4 ] ), oPrinter ), ;
oPen1 )
aCorpo[ 1 ] += oFont[ 2 ]:nHeight * 0.2
aCorpo[ 2 ] := MM2PxVer( ( aParam[ 2 ] - aParam[ 5 ] ), oPrinter )
oPrinter:Line( aCorpo[ 2 ], ;
MM2PxHor( ( aParam[ 4 ] ), oPrinter ), ;
aCorpo[ 2 ], ;
MM2PxHor( ( aParam[ 1 ] - aParam[ 4 ] ), oPrinter ), ;
oPen2 )
aCorpo[ 2 ] -= oFont[ 2 ]:nHeight * 1.2
cTxt := "Pagina " + NTrim( nPag )
oPrinter:Say( aCorpo[ 2 ] + oFont[ 3 ]:nHeight * 1.5, ;
MM2PxHor( ( aParam[ 1 ] - aParam[ 4 ] ), oPrinter ) - oPrinter:GetTextWidth( cTxt, oFont[ 3 ] ), ;
cTxt, oFont[ 3 ] )
cTxt := "Torino, " + " " + DToC( Date() )
oPrinter:Say( aCorpo[ 2 ] + oFont[ 3 ]:nHeight * 1.5, ;
MM2PxHor( nPosCol, oPrinter ), ;
cTxt, oFont[ 3 ] )
EndPage
ENDPRINT
oPen:END()
oPen1:END()
oPen2:END()
oFont[ 1 ]:END()
oFont[ 2 ]:END()
oFont[ 3 ]:END()
ENDIF
RETURN .t.[\code]