03 Set 2008 10:12
function Txt2rtf( cArquivo, nColunas )
local cArqRtf, arq, arq_txt, cHandle
local cCaractere := space( 01 )
local cLinha := space( 01 )
local lf := chr( 13 ) + chr( 10 )
// fs define o tamanho da fonte, para o Courier New é a metade
// fs14 - fonte 7,0 - 136 colunas
// fs23 - fonte 11,5 - 80 colunas
// margl - margem esquerda
// margr - margem direita
// margt - margem superior
// margb - margem inferior
// criar um arquivo rtf com o mesmo nome
cArqRtf := lower( left( cArquivo, len( cArquivo ) - 4 ) + ".rtf" )
cArqRtf := substr(time(),1,2)+substr(time(),4,2)+substr(time(),7,2)+".rtf"
// End
// acrescentar antes do texto os parâmetros rtf
arq := fcreate( cArqRtf, 1 )
cHandle := "{\rtf1\ansi\ansicpg1252\deff0\deflang1046{\fonttbl{\f0\fmodern\fprq1\fcharset0 Courier New;}{\f1\fswiss\fcharset0 Arial;}}" + lf
cHandle += "\margl284\margr505\margt505\margb505" + lf
if nColunas == 136
cHandle += "{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs14 "
else
cHandle += "{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs23 "
endif
// End
fwrite( arq, cHandle )
// Pega Linha por Linha do TXT e Transforma para RTF
arq_txt := fopen( cArquivo, 0 )
while .t.
cCaractere := space( 01 )
if fread( arq_txt, @cCaractere, 1 ) <> 1
exit
endif
if ( cCaractere ) = chr( 13 )
cLinha += "\par" + lf
fwrite( arq, cLinha )
cLinha := space( 01 )
fseek( arq_txt, 1, 1 )
loop
endif
if cLinha = space( 01 )
cLinha := cCaractere
else
cLinha += cCaractere
endif
enddo
// End
cHandle := "}"
fwrite( arq, cHandle )
fclose( arq )
fclose( arq_txt )
return( .T. )
03 Set 2008 22:29
05 Set 2008 11:21
29 Set 2008 15:35
14 Out 2008 15:18
#include "richedit.ch"
function rtfWPrint( cFile, lPrint, lVisible )
LOCAL oRWnd, oRich, hRichDLL := LoadLibrary( "riched20.dll" ), cVar := ""
LOCAL ScreenWidth := GetSysMetrics(0), ScreenHeight := GetSysMetrics(1), ScreenMargim := 25
if lVisible
DEFINE DIALOG oRWnd FROM 0, 0 TO ScreenHeight,ScreenWidth PIXEL STYLE WS_POPUP COLOR nRGB(0,0,0),nRGB(0,0,0) //NOSYSMENU NOICONIZE
@ 5,5 SAY "Imprimindo "+cFile+" em "+PRNGETNAME()+"..." COLOR nRGB(255,255,255),nRGB(0,0,0) OF oRWnd PIXEL
@ ScreenMargim,(ScreenWidth-310)/8 RICHEDIT oRich VAR cVar SIZE 310,350 PIXEL OF oRWnd
oRich:LoadFromRTFFile( cFile )
if lPrint
oRich:Print( cFile )
endif
ACTIVATE DIALOG oRWnd
else
DEFINE WINDOW oRWnd FROM 0,0 TO 1,1 TITLE "Imprimindo "+cFile+"..."
oRich := TRichEdit():New(0,0,,oRWnd,,,,.T.,, .f. )
oRich:LoadFromRTFFile( cFile )
if lPrint
oRich:Print( cFile )
endif
//oRWnd:setControl(oRich)
ACTIVATE WINDOW oRWnd
SysWait(5)
oRWnd:End()
endif
FreeLibrary( hRichDLL )
return nil
05 Nov 2008 16:53
06 Nov 2008 09:50
06 Nov 2008 15:30
****************************************************************************************
function main()
clear
use ..\arquivos\temp_imp new shared
@ 00 , 00 say 'Aguardando Arquivos para Impressao'
@ 02 , 00 say 'Pressione ESC para finalizar'
sele temp_imp
go top
do while lastkey() # 27
do while !eof() .and. lastkey()#27
if temp_imp -> situ # "OK"
xArq := alltrim(temp_imp -> arquivo)
xPorta := upper(alltrim(temp_imp -> Porta))
if left(xPorta,3)=´LPT´
copy file &xArq to &xPorta
else
! wordpad /p &xArq (((((( aki posso usar o prnrich ))))))))
*
* como vc pode ver imprimo apenas na impressora padrao, como o relatorio eh pequeno 1 pagina e sempre é impresso
* na mesma impressora, gostaria de seguir a ideia acima, apenas enviando para outra impressora, mas se tiver que
* fazer uma rotina para isso......maos a obra...
*
* ops... lembrando que o unico sistema que compilei no xharbour foi este...rs..
* no fivewin .....nada....rs
*
endif
sele temp_imp
do while !lock()
enddo
repl situ with "OK"
unlock
endif
skip
enddo
Inkey(1)
go top
enddo
close all
**********************************************************************
14 Dez 2008 09:28
15 Dez 2008 10:41
15 Dez 2008 12:13
16 Dez 2008 08:03
16 Dez 2008 11:32
17 Dez 2008 10:14
17 Dez 2008 10:34