Mira se ayuda:
Mira se ayuda:
// c:\fwh..\samples\SILSTAMP.PRG
#include "FiveWin.ch"
#define PAD_LEFT 0
#define PAD_RIGHT 1
#define PAD_CENTER 2
static oWnd
MEMVAR nCopias
FUNCTION Main()
nCopias := 1 // ponga en el dialogo Number of copies.
DEFINE WINDOW oWnd FROM 1, 1 TO 20, 60 TITLE "Printing a Window"
@ 3, 3 BUTTON "&Print me" OF oWnd SIZE 80, 20 ;
ACTION PrintMe_Copias() // try also with oWnd:HardCopy()
@ 5, 3 BUTTON "&End" OF oWnd SIZE 80, 20 ;
ACTION ( oWnd:End() )
ACTIVATE WINDOW oWnd CENTERED
RETURN NIL
FUNCTION PrintMe_Copias()
LOCAL nI
FOR nI := 1 TO nCopias
SYSREFRESH()
PrintMe()
NEXT
RETURN NIL
FUNCTION PrintMe()
LOCAL oPrn, oFont, oPen, aPrn, nLinha, nColuna, ResLinha, ResColuna
LOCAL cData := Date(), cText
aPrn := GetPrinters()
IF Empty( aPrn ) // Empty( oPrn:hDC )
MsgStop ("No se encontró impresora", "No se encontró impresora")
RETURN NIL
ENDIF
PRINTER oPrn PREVIEW MODAL // PARA TESTAR A IMPRESSORA ANTES DE IMPRIMIR
IF EMPTY( oPrn:hDC )
MsgInfo ("HABÍA ALGO MAL CON LA IMPRESORA", "ENCIENDA LA IMPRESORA")
oPrn:End()
RETURN( .F. )
ENDIF
oPrn:End()
cText := TimeZone( cData ) // EL TEXTO para el preview.
PRINT oPrn PREVIEW MODAL
DEFINE FONT oFont NAME "Arial" SIZE 0, -30 BOLD OF oPrn
DEFINE PEN oPen WIDTH 2 OF oPrn
oPrn:SetPage(9)
oPrn:SetPortrait()
ResLinha := oPrn:nLogPixely()/2.54
ResColuna := oPrn:nLogPixelx()/2.54
nLinha := 01
nColuna := 10
PAGE
@ 15, 01 PRINT TO oPrn TEXT cText SIZE 19,3 CM FONT oFont COLOR CLR_RED
@ 19, 05 PRINT TO oPrn TEXT cText SIZE 19,3 CM ALIGN "TL" FONT oFont COLOR CLR_BLACK
oPrn:Say( nLinha * ResLinha, 7.25 * ResColuna, ;
"TimeZone: " + TimeZone( cData ), oFont,, CLR_BLACK,, PAD_CENTER )
ENDPAGE
ENDPRINT
oFont:End()
RETURN NIL
FUNCTION TimeZone( dData )
Local cDateTimeZone,aTimeStamp,cTzd
Default dData:=Date()
aTimeStamp := hb_atokens(tip_timestamp(dData)," ")
cTzd:=aTail(aTimeStamp)
cTzd:=Left(cTzd,Len(cTzd)-2)+":"+Right(cTzd,2)
cDateTimeZone:=StrZero(Year(dData),4)+"-"+StrZero(Month(dData),2)+"-"+StrZero(Day(dData),2)+"T"+Time()+cTzd
Return( cDateTimeZone )
// fin / end
Regards, saludos.