by rterraz » Mon Mar 15, 2021 12:02 pm
Hola Enrico
aca te paso un sample de lo que estoy haciendo aver si a vos te funciona !
asi llamo a la funcion del codigo QR desde la rutina de impresion
nRow+=nRowStep
oPrn:say(nRow,nMargen, replicate('-',45),oFont1)
nRow+=nRowStep
//..Genera QR llamando a TcodeBars )
BuildQR(oPrn, nRow,nMargen ,cCodBar ) // cCodbar trae la data a incluir en el QR
ENDPAGE
ENDPRINT
//............................................
FUNCTION BuildQR( oPrn ,nRow,nCol,cCode )
local nFlags := 0
local nCode := 14 // codigo para el CODEBARQR
oCode := TCodeBars():New(600,600,10,10,nCode,cCode,0)
oCode:Reset()
oCode:Build()
Drawbitmap( oPrn:hDCOut, oCode:hCodeBar, nRow,nCol) // aca deberia dibujar el QR hace unos dias lo hacia pero ahora no
RETU oCode
esta es la clase TCodeBars de Garcia GIl que estoy usando hace mucho sin problemas hasta ahora
/////// CLASS TCODEBARS //////////////////////
CLASS TCodeBars
DATA aTypes HIDDEN
DATA cCode
DATA nFlags
DATA hCodeBar
DATA hData
DATA nType, nWidth, nHeight, nWidthCode, nHeightCode
METHOD New()
METHOD End() INLINE DeleteObject( ::hCodeBar ), If( ::hData != NIL, hb_zebra_destroy( ::hData ), )
METHOD DefError( nError )
METHOD SetCode( cCode )
METHOD SetFlags( nFlags )
METHOD SetType( cnType )
METHOD Reset() INLINE ::End()
METHOD Build()
METHOD Rebuild() INLINE ::Reset(), ::Build()
ENDCLASS
//--------------------------------------------------------------------------------------------//
METHOD New( nWidth, nHeight, nWidthCode, nHeightCode, cnType, cCode, nFlags ) CLASS TCodeBars
DEFAULT nWidth := 200,;
nHeight := 100,;
nWidthCode := 1,;
nHeightCode := 3
nFlags := 0
::aTypes = { { "EAN13" , {| | hb_zebra_create_ean13( ::cCode, ::nFlags ) } },;
{ "EAN8" , {| | hb_zebra_create_ean8( ::cCode, ::nFlags ) } },;
{ "UPCA" , {| | hb_zebra_create_upca( ::cCode, ::nFlags ) } },;
{ "UPCE" , {| | hb_zebra_create_upce( ::cCode, ::nFlags ) } },;
{ "ITF" , {| | hb_zebra_create_itf( ::cCode, ::nFlags ) } },;
{ "MSI" , {| | hb_zebra_create_msi( ::cCode, ::nFlags ) } },;
{ "CODABAR" , {| | hb_zebra_create_codabar( ::cCode, ::nFlags ) } },;
{ "CODE11" , {| | hb_zebra_create_code11( ::cCode, ::nFlags ) } },;
{ "CODE39" , {| | hb_zebra_create_code39( ::cCode, ::nFlags ) } },;
{ "CODE93" , {| | hb_zebra_create_code93( ::cCode, ::nFlags ) } },;
{ "CODE128" , {| | hb_zebra_create_code128( ::cCode, ::nFlags ) } },;
{ "PDF417" , {| | hb_zebra_create_pdf417( ::cCode, ::nFlags ) } },;
{ "DATAMATRIX" , {| | hb_zebra_create_datamatrix( ::cCode, ::nFlags ) } },;
{ "QRCODE" , {| | hb_zebra_create_qrcode( ::cCode, ::nFlags ) } } }
::nWidth = nWidth
::nHeight = nHeight
::nWidthCode = nWidthCode
::nHeightCode = nHeightCode
::SetType( cnType )
::SetCode( cCode )
::SetFlags( nFlags )
return Self
//--------------------------------------//
METHOD Build() CLASS TCodeBars
local hBmpOld
local hDCDesk := GetDC( GetDesktopWindow() )
local hDCMem := CreateCompatibleDC( hDCDesk )
local hBrush := CreateSolidBrush( 0 )
local hBack := CreateSolidBrush( CLR_WHITE )
::hCodeBar = CreateCompatibleBitMap( hDCDesk, ::nWidth, ::nHeight )
hBmpOld = SelectObject( hDCMem, ::hCodeBar )
::hData := Eval( ::aTypes[ ::nType ][ CODEBAR_BLOCK ] )
::DefError()
FillRect( hDCMem, { 0, 0, ::nHeight, ::nWidth }, hBack )
hb_zebra_draw( ::hData, {| x, y, w, h | FillRect( hDCMem, { y, x, y + h, x + w }, hBrush ) }, 0, 0, ::nWidthCode, ::nHeightCode )
//DrawText( hDCMem, ::cCode, { ::nHeight - 15, 0, ::nHeight, ::nWidth }, 1 )
SelectObject( hDCMem, hBmpOld )
ReleaseDC( GetDesktopWindow(), hDCDesk )
DeleteDC( hDCMem )
DeleteObject( hBrush )
DeleteObject( hBack )
return NIL
//--------------------------------------//
METHOD SetCode( cCode ) CLASS TCodeBars
if ! Empty( cCode )
if ValType( cCode ) != "C"
cCode = cValToChar( cCode )
endif
::cCode = cCode
endif
return NIL
//--------------------------------------//
METHOD SetFlags( nFlags ) CLASS TCodeBars
::nFlags = nFlags
return NIL
//--------------------------------------//
METHOD SetType( cnType ) class TCodeBars
local cType
if ( ( cType := ValType( cnType ) )$"CN" )
if cType == "N"
if cnType > 0 .and. cnType < 15
::nType = cnType
endif
else
::nType = AScan( ::aTypes, {| a | a[ CODEBAR_TYPE ] == Upper( cnType ) } )
endif
else
::nType = DEFAULT_CODEBAR
endif
return NIL
//--------------------------------------//
METHOD DefError( ) CLASS TCodeBars
local oError
local nError := 0
if ::hData != NIL
nError = hb_zebra_geterror( ::hData )
endif
if nError != 0
hb_zebra_destroy( ::hData )
oError := ErrorNew()
oError:SubSystem = "TCODEBARS"
oError:SubCode = nError
oError:Severity = 2
Eval( ErrorBlock(), oError )
endif
RETURN nil
#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
HB_FUNC( CREATECOMPATIBLEBITMAP ) // hDC, nWidth, nHeight
{
hb_retnl( ( LONG ) CreateCompatibleBitmap( ( HDC ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ) ) );
}
#pragma ENDDUMP