Moderador: Moderadores
#include "WinGdi.ch"
#define RGB_BLACK RGB( 0, 0, 0 )
#define RGB_RED RGB( 255, 0, 0 )
#define RGB_GREEN RGB( 0,255, 0 )
#define RGB_BLUE RGB( 0, 0,255 )
#define RGB_CYAN RGB( 0,255,255 )
#define RGB_YELLOW RGB( 255,255, 0 )
#define RGB_MAGENTA RGB( 255, 0,255 )
#define RGB_WHITE RGB( 255,255,255 )
PROCEDURE Main
LOCAL cPrinter := "EPSON Stylus DX5000 Series"
LOCAL oPrinter
LOCAL aFonts, cFont, nFont
// Create printer object and configure print job
oPrinter := Win32Prn():new( cPrinter )
oPrinter:landscape := .F.
oPrinter:formType := DMPAPER_A4
oPrinter:copies := 1
// Create device context
IF .NOT. oPrinter:create()
Alert( "Cannot create device context" )
QUIT
ENDIF
// Create print job
IF .NOT. oPrinter:startDoc( "xHarbour test page" )
Alert( "Cannot create document" )
QUIT
ENDIF
// Text in fixed font
oPrinter:textOut( "Text in default font" )
oPrinter:bold( FW_EXTRABOLD )
oPrinter:textOut( oPrinter:fontName )
oPrinter:bold( FW_NORMAL )
oPrinter:newLine()
aFonts := oPrinter:getFonts()
nFont := AScan( aFonts, ;
{|a| "ARIAL" $ Upper(a[1]) } )
cFont := aFonts[nFont,1]
// Text in proportional font
oPrinter:setFont( cFont )
oPrinter:textOut( "Text in Arial font" )
oPrinter:bold( FW_EXTRABOLD )
oPrinter:textOut( oPrinter:fontName )
oPrinter:bold( FW_NORMAL )
oPrinter:newLine()
// Colored text
oPrinter:setColor( RGB_YELLOW, RGB_BLUE )
oPrinter:textOut( "Yellow on Blue" )
oPrinter:newLine()
// Draw colored line across page
oPrinter:setPen( PS_DASH, 5, RGB_GREEN )
oPrinter:line( oPrinter:posX, ;
oPrinter:posY, ;
oPrinter:rightMargin, ;
oPrinter:posY )
// Send output to printer
oPrinter:endDoc()
// Release GDI device context
oPrinter:destroy()
RETURN
FUNCTION RGB( nRed, nGreen, nBlue )
RETURN ( nRed + ( nGreen * 256 ) + ( nBlue * 65536 ) )
PROCEDURE Main
LOCAL cFileName, oWin32Bmp, oWin32Prn
oWin32Prn := Win32Prn():new() // default printer object
IF .NOT. oWin32Prn:create() // create device context
Alert( "Unable to create device context for printer" )
QUIT
ENDIF
cFileName := "TestImage.bmp"
oWin32Bmp := Win32Bmp():new() // load bitmap file into memory
IF .NOT. oWin32Bmp:loadFile( cFileName )
Alert( "Unable to load bitmap file: " + cFileName )
QUIT
ENDIF
// print bitmap image
oWin32Bmp:draw( oWin32Prn, { 200, 400, 2000, 1500 } )
// release GDI system resources of printer
oWin32Prn:destroy()
RETURN
Pelo exemplo do Toledo, se não existir um arquivo chamado TestImage.bmp na pasta do exemplo a mensagem que se terá na caixa do alert é: "Unable to load bitmap file: TestImage.bmp"kakamachado escreveu:Erro: Alert( "Unable to load bitmap file: " + cFileName )
cFileName := "TestImage.bmp"Penso também que facilita se você postar a função que você adequou.
*-------------------------------------------------------------------*
* SISTEMA : FPG - SISTEMA DE FOLHA DE PAGAMENTO *
* PROGRAMA : TESTE - RELATORIO DE EMPRESAS *
* FUNCAO : testar impressao de logomarca *
*-------------------------------------------------------------------*
#include "WinGdi.ch"
FUNCTION MAIN()
LOCAL cFileName, oWin32Bmp, oWin32Prn
* ENVIA CABECALHO E RECEBE PARAMETROS *
*-------------------------------------*
CLEAR
WPAGINA := 0
WW_L := 05
WNOME_REL := "RELATÓRIO DE EMPRESA(S)"
SET DEVICE TO PRINT
oWin32Prn := Win32Prn():new() // default printer object
IF .NOT. oWin32Prn:create() // create device context
Alert( "Unable to create device context for printer" )
QUIT
ENDIF
cFileName := "INSS.bmp"
oWin32Bmp := Win32Bmp():new() // load bitmap file into memory
IF .NOT. oWin32Bmp:loadFile( cFileName )
Alert( "Unable to load bitmap file: " + cFileName )
QUIT
ENDIF
// print bitmap image
oWin32Bmp:draw( oWin32Prn, { 200, 400, 2000, 1500 } )
@ WW_L+05,13 SAY "Empresa.: XPTO LTDA"
@ WW_L+07,13 SAY "CNPJ....: 99.999.999/0001-99"
@ WW_L+09,13 SAY "Situacao: INATIVA"
* FINALIZA O PROGRAMA *
*---------------------*
EJECT
// release GDI system resources of printer
oWin32Prn:destroy()
SET DEVICE TO SCREEN
RETURN
kakamachado escreveu:Suponhamos que eu tenha o comando clipper:
@ lin, col SAY EM_CGC PICT "@R XXXXXXXX/XXXX-XX"
Onde lin = 30 e col = 20, estão definidos em milÃmetros, como ficaria este comando com a oWin32Prn?
oWin32Prn:setPrc(30,20)
oWin32Prn:TextOut(Transform(EM_CGC,"@R XXXXXXXX/XXXX-XX"), .F.)
Usuários vendo este fórum: Bing [Bot], Google [Bot] e 12 visitantes