Carlos,
Gracias por tu contribución. Copiemos aqui los ficheros pues mediafire se cancela despues de un tiempo,
BARCODEW.CH
Code: Select all
#ifndef _BARCODE_
#define _BARCODE_
#translate @ <nRow>, <nCol> CODE128W <cCode> ;
[ MODE <cMode>] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, <cMode>, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"CODE128", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_CODE128W <cCode> ;
[ MODE <cMode>] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, <cMode>, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"CODE128", <.design.>, .F. )
#translate @ <nRow>, <nCol> CODE3_9W <cCode> ;
[ <lCheck:CHECK> ] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"CODE3_9", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_CODE3_9W <cCode> ;
[ <lCheck:CHECK> ] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"CODE3_9", <.design.>, .F. )
#translate @ <nRow>, <nCol> EAN13W <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
"EAN13", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_EAN13W <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
"EAN13", <.design.>, .F. )
#translate @ <nRow>, <nCol> UPCAW <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
"UPCA", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_UPCAW <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
"UPCA", <.design.>, .F. )
#translate @ <nRow>, <nCol> EAN8W <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
"EAN8", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_EAN8W <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
"EAN8", <.design.>, .F. )
#translate @ <nRow>, <nCol> SUP5W <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
"SUP5", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_SUP5W <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
"SUP5", <.design.>, .F. )
#translate @ <nRow>, <nCol> CODABARW <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"CODABAR", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_CODABARW <cCode> ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
Nil, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"CODABAR", <.design.>, .F. )
#translate @ <nRow>, <nCol> INT25W <cCode> ;
[ <lCheck:CHECK> ] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"INT25", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_INT25W <cCode> ;
[ <lCheck:CHECK> ] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"INT25", <.design.>, .F. )
#translate @ <nRow>, <nCol> IND25W <cCode> ;
[ <lCheck:CHECK> ] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"IND25", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_IND25W <cCode> ;
[ <lCheck:CHECK> ] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"IND25", <.design.>, .F. )
#translate @ <nRow>, <nCol> MAT25W <cCode> ;
[ <lCheck:CHECK> ] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"MAT25", <.design.>, .T. )
#translate @ <nRow>, <nCol> CM_MAT25W <cCode> ;
[ <lCheck:CHECK> ] ;
[ <lVert:VERTICAL> ];
[ COLOR <nColor> ] ;
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ OF <oWnd>] ;
[ <design:DESIGN>] ;
=> ;
TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, Nil, <nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, Nil, Nil, ;
"MAT25", <.design.>, .F. )
#ENDIF
/* ***************************************************************************************** */
#translate @ <nRow>, <nCol> BARCODEW [ <oBarCodeW> PROMPT ] <cCode> ;
[ <predef: CODE128, CODE3_9, EAN13, UPCA, EAN8, SUP5, ;
CODABAR, INT25, IND25, MAT25> ] ;
[ OF <oWnd>] ;
[ <lCheck:CHECK> ] ;
[ MODE <cMode>] ;
[ COLOR <nColor> ] ;
[ <lVert:VERTICAL> ];
[ WIDTH <nWidth> ] ;
[ SIZE <nSize> ] ;
[ <lBanner:BANNER> ] ;
[ FONT <cFont> ] ;
[ <design: DESIGN > ] ;
[ <lPixel: PIXEL, PIXELS > ] ;
=> ;
<oBarCodeW> := TBarCodeW():New( <nRow>, <nCol>, <cCode>, <oWnd>, ;
<.lCheck.>, <cMode>,<nColor>, .not. <.lVert.>, ;
<nWidth>, <nSize>, <.lBanner.>, <cFont>, ;
Upper(<(predef)>), <.design.>, <.lPixel.> )
BANNERW.PRG
Code: Select all
// labels on barcodes
#include "fivewin.ch"
FUNCTION barlen13W( cCode, oWnd, nRow, nCol, Color, lHorz, nWidth, nLen, cFont)
Local oFont, nLenChar, l , Control, k, n, nWidthChar
Local WndhDC := 0
default lHorz := .t.
default nWidth := 0.025 // 1/3 M/mm
default nLen := 1.5 // Cmm.
default cFont := 'arial'
default Color := CLR_BLACK
WndhDC := oWnd:GetDC()
k:=left(alltrim(cCode)+'000000000000',12) // padding with '0'
// calculo del digito de control
k := k + EAN13_CHECK( k ) // Chaeck Digit en EAN13
If !lHorz
//nWidth := round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
nWidth := ROUND( nCm2Pixels( WndhDC, nWidth, .T. ), 0 )
else
//nWidth := round ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
nWidth := ROUND( nCm2Pixels( WndhDC, nWidth, .F. ), 0 )
EndIf
// Len of bar
If lHorz
//nLen := round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
nLen := ROUND( nCm2Pixels( WndhDC, nLen, .T. ), 0 )
Else
//nLen := round ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
nLen := ROUND( nCm2Pixels( WndhDC, nLen, .F. ), 0 )
EndIf
/*
nLenChar := nWidth*10
nWidthChar:= nLen*0.3
while .t.
define font oFont name cFont of oPrInt size nLenChar , nLenChar/2 ;
nescapement if(lHorz,0,13500)
if oPrint:GetTextWidth( '888888', oFont )<=42*nWidth
// alert(if(lHorz,'H:','V:')+str(nWidth*7)+str(nLenChar/(nWidth*7)))
while .t.
define font oFont name cFont of oPrInt size nLenChar , nWidthChar ;
nescapement if(lHorz,0,13500)
if oPrint:GetTextHeigth( '8', oFont )<=0.2*nLen
alert(if(lHorz,'H:','V:')+str(nLen*0.2)+str(nWidthChar/(nLen*0.2)))
exit
else
nWidthChar-=0.2
end
oFont:end()
enddo
exit
else
nLenChar-=1
end
oFont:end()
end
* nWidt -> 0.8
*/
//DEFINE FONT oFont NAME cFont OF oPrInt SIZE nWidth * 5.6, nLen * 0.04 ;
// NESCAPEMENT If( lHorz, 0, 13500)
DEFINE FONT oFont NAME cFont SIZE nWidth * 5.6, nLen * 0.24 ;
NESCAPEMENT If( lHorz, 0, 13500)
If lHorz
//oPrint:say( nRow + nLen * 0.9, nCol - nWidth * 8, Left(k, 1), oFont, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol - nWidth * 8, Left(k, 1), Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nLen * 0.9, nCol + nWidth * 3, Substr(k, 2, 6), oFont, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol + nWidth * 3, SubStr(k, 2, 6), Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nLen * 0.9, nCol + nWidth * 50, Substr(k, 8, 6), oFont, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol + nWidth * 50, SubStr(k, 8, 6), Color, Nil, oFont, .T., Nil, Nil )
Else
//oPrint:say( nRow - nWidth * 8, nCol + nLen * 0.1, Left(k, 1), oFont, , Color)
oWnd:Say( nRow - nWidth * 8, nCol + nLen * 0.1, Left(k, 1), Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nWidth * 3, nCol + nLen * 0.1, substr(k, 2, 6), oFont, , Color)
oWnd:Say( nRow + nWidth * 3, nCol + nLen * 0.1, SubStr(k, 2, 6), Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nWidth * 50, nCol + nLen * 0.1, Substr(k, 8, 6), oFont, , Color)
oWnd:Say( nRow + nWidth * 50, nCol + nLen * 0.1, SubStr(k, 8, 6), Color, Nil, oFont, .T., Nil, Nil )
EndIf
RELEASE oFont
oWnd:ReleaseDC()
RETURN Nil
FUNCTION barlenW( cCode, nDigs, oWnd, nRow, nCol, Color, lHorz, nWidth, nLen, cFont)
Local oFont, nLenChar, l ,Control,k,s1,s2,n, Izda, dCha
Local WndhDC := 0
DEFAULT lHorz := .t.
DEFAULT nWidth := 0.025 // 1/3 M/mm
DEFAULT nLen := 1.5 // Cmm.
DEFAULT cFont := 'arial'
DEFAULT Color := CLR_BLACK
DEFAULT nDigs := 11
WndhDC := oWnd:GetDC()
// calculo del digito de control
k := Left(Alltrim(cCode) + '000000000000', nDigs) // padding with '0'
// calculo del digito de control
k = k + Upc_CHECK(cCode, nDigs) // cCode,nLen
nDigs++
dcha := Right(K, nDigs / 2)
izda := Left(k, nDigs / 2)
If !lHorz
//nWidth :=round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
nWidth := ROUND( nCm2Pixels( WndhDC, nWidth, .T. ), 0 )
Else
//nWidth :=round ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
nWidth := ROUND( nCm2Pixels( WndhDC, nWidth, .F. ), 0 )
EndIf
// Len of bar
If lHorz
//nLen :=round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
nLen := ROUND( nCm2Pixels( WndhDC, nLen, .T. ), 0 )
Else
//nLen :=round ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
nLen := ROUND( nCm2Pixels( WndhDC, nLen, .F. ), 0 )
EndIf
//define font oFont name cFont of oPrInt size nWidth*5.6 , nLen*0.04 ;
// nescapement if(lHorz,0,13500)
DEFINE FONT oFont NAME cFont SIZE nWidth * 5.6 , nLen * 0.24 ;
NESCAPEMENT If(lHorz, 0, 13500)
// fisrt letter
If lHorz
//oPrint:say( nRow + nLen * 0.9, nCol + nWidth * 3, Izda, oFont, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol + nWidth * 3, Izda, Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nLen * 0.9, nCol + nWidth * ( int(nDigs) / 2 * 7 + 8), dcha, oFont, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol + nWidth * ( int(nDigs) / 2 * 7 + 8), dcha, Color, Nil, oFont, .T., Nil, Nil )
Else
//oPrint:say( nRow + nWidth * 3, nCol + nLen * 0.1, izda, oFont, , Color)
oWnd:Say( nRow + nWidth * 3, nCol + nLen * 0.1, izda, Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nWidth * (nDigs / 2 + 8), nCol + nLen * 0.1, dcha, oFont, , Color )
oWnd:Say( nRow + nWidth * (nDigs / 2 + 8), nCol + nLen * 0.1, dcha, Color, Nil, oFont, .T., Nil, Nil )
EndIf
RELEASE oFont
oWnd:ReleaseDC()
return nil
FUNCTION ban5W( cCode, oWnd, nRow, nCol, Color, lHorz, nWidth, nLen, cFont)
Local oFont, nLenChar, k,n, oPen
Local WndhDC := 0
DEFAULT lHorz := .t.
DEFAULT nWidth := 0.025 // 1/3 M/mm
DEFAULT nLen := 1.5 // Cmm.
DEFAULT cFont := 'arial'
DEFAULT Color := CLR_BLACK
WndhDC := oWnd:GetDC()
ccode := Left(Alltrim(cCode) + '000000000000', 5) // padding with '0'
If !lHorz
//nWidth := round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
nWidth := ROUND( nCm2Pixels( WndhDC, nWidth, .T. ), 0 )
Else
//nWidth := round ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
nWidth := ROUND( nCm2Pixels( WndhDC, nWidth, .F. ), 0 )
EndIf
// Len of bar
If lHorz
//nLen :=round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
nLen := ROUND( nCm2Pixels( WndhDC, nLen, .T. ), 0 )
Else
//nLen :=round ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
nLen := ROUND( nCm2Pixels( WndhDC, nLen, .F. ), 0 )
EndIf
//define font oFont name cFont of oPrInt size nWidth*5.6 , nLen*0.04 ;
// nescapement if(lHorz,0,13500)
DEFINE FONT oFont NAME cFont SIZE nWidth * 5.6 , nLen * 0.24 ;
NESCAPEMENT If( lHorz, 0, 13500)
//define pen oPen color CLR_WHITE of oPrint
DEFINE PEN oPen COLOR CLR_WHITE
k := ''
FOR n := 1 to 4
k += substr( cCode, n, 1) + ' '
ENDFOR
cCode := k + right( cCOde, 1)
//Box( nTop, nLeft, nBottom, nRight )
If lHorz
//oPrint:box(nrow,ncol,nrow+nLen*.3,nCol+48*nWidth,oPen)
Rectangle( WndhDC, nrow, ncol, nrow + nLen * .3, nCol + 48 * nWidth, oPen:hPen )
Else
//oPrint:box(nrow,ncol,nrow+41*nWidth,nCol+nLen*.3+48*nWidth,oPen)
Rectangle( WndhDC, nrow, ncol, nrow + 41 * nWidth, nCol + nLen * .3 + 48 * nWidth, oPen:hPen )
EndIf
//oPrint:say(nRow,nCol,cCode,oFont,,Color)
oWnd:Say( nRow, nCol, cCode, Color, Nil, oFont, .T., Nil, Nil )
RELEASE oFont
RELEASE oPen
oWnd:ReleaseDC()
RETURN Nil
FUNCTION UPCA_barlenW( cCode, oWnd, nRow, nCol, Color, lHorz, nWidth, nLen, cFont)
Local oFont, nLenChar, l ,Control,k,n, Izda, dCha, nDigs:=11,oFont2
Local WndhDC := 0
DEFAULT lHorz := .t.
DEFAULT nWidth := 0.025 // 1/3 M/mm
DEFAULT nLen := 1.5 // Cmm.
DEFAULT cFont := 'arial'
DEFAULT Color := CLR_BLACK
WndhDC := oWnd:GetDC()
// calculo del digito de control
k := Left(Alltrim(cCode) + '000000000000', nDigs) // padding with '0'
// calculo del digito de control
k = k + Upc_CHECK( cCode, nDigs) // cCode,nLen
nDigs++
dcha := Right(K, nDigs / 2)
izda := Left(k, nDigs / 2)
If !lHorz
//nWidth :=round ( nWidth * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
nWidth := ROUND( nCm2Pixels( WndhDC, nWidth, .T. ), 0 )
Else
//nWidth :=round ( nWidth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
nWidth := ROUND( nCm2Pixels( WndhDC, nWidth, .F. ), 0 )
EndIf
// Len of bar
IF lHorz
//nLen :=round ( nLen * 10 * oPrint:nVertRes() / oPrint:nVertSize() ,0 )
nLen := ROUND( nCm2Pixels( WndhDC, nLen, .T. ), 0 )
Else
//nLen :=round ( nLen * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 )
nLen := ROUND( nCm2Pixels( WndhDC, nLen, .F. ), 0 )
EndIf
//define font oFont name cFont of oPrInt size nWidth*5.6 , nLen*0.04 ;
// nescapement if(lHorz,0,13500)
//define font oFont2 name cFont of oPrInt size nWidth*5.6 , nLen*0.025 ;
// nescapement if(lHorz,0,13500)
DEFINE FONT oFont NAME cFont SIZE nWidth * 5.6 , nLen * 0.24 ;
NESCAPEMENT If(lHorz, 0, 13500)
DEFINE FONT oFont2 NAME cFont SIZE nWidth * 5.6 , nLen * 0.15 ;
NESCAPEMENT If(lHorz, 0, 13500)
// fisrt letter
If lHorz
//oPrint:say( nRow + nLen * 0.9, nCol - nWidth * 8, left(k, 1), oFont2, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol - nWidth * 8, Left(k, 1), Color, Nil, oFont2, .T., Nil, Nil )
//oPrint:say( nRow + nLen * 0.9, nCol + nWidth * 10, right(Izda, 5), oFont, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol + nWidth * 10, Right(Izda, 5), Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nLen * 0.9, nCol + nWidth * 50, left( dcha, 5), oFont, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol + nWidth * 50, Left( Dcha, 5), Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nLen * 0.9, nCol + nWidth * 95, right( k, 1), oFont2, , Color)
oWnd:Say( nRow + nLen * 0.9, nCol + nWidth * 95, Right( k, 1), Color, Nil, oFont2, .T., Nil, Nil )
Else
//oPrint:say( nRow - nWidth * 8, nCol + nLen * 0.1, left(k, 1),oFont2,,Color)
oWnd:Say( nRow - nWidth * 8, nCol + nLen * 0.1, Left(k, 1), Color, Nil, oFont2, .T., Nil, Nil )
//oPrint:say( nRow + nWidth * 10, nCol + nLen * 0.1, right( izda, 5), oFont, , Color)
oWnd:Say( nRow + nWidth * 10, nCol + nLen * 0.1, Right( Izda, 5), Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nWidth * 50, nCol + nLen * 0.1, left( dcha, 5), oFont, , Color)
oWnd:Say( nRow + nWidth * 50, nCol + nLen * 0.1, Left( Dcha, 5), Color, Nil, oFont, .T., Nil, Nil )
//oPrint:say( nRow + nWidth * 95, nCol + nLen * 0.1, right( k, 1), oFont2, , Color)
oWnd:Say( nRow + nWidth * 95, nCol + nLen * 0.1, Right( k, 1), Color, Nil, oFont2, .T., Nil, Nil )
EndIf
RELEASE oFont
RELEASE oFont2
oWnd:ReleaseDC()
RETURN Nil
//
BARLIBW.PRG
Code: Select all
/* Para visualizar los códigos de barra por pantalla.
Basado en el desarrollo de Cayetano (Barlib).
C.Gelabert 28/4/09
============================================== */
// funciones de llamadas de barlib
// chequean las posibles concordancias de datos
// y dan los errores
#include 'fivewin.ch'
// CODE 128
/*
Code 128:
Admite los 128 caracteres 0 - 127
si s¢lo son n£meros se usa un modelo comprimido, llamado
modo C
Si hay caracteres < 32 se usa el m¢do A
Si hay caracteres en minusculas se usa el modo B ( modo por defecto)
Los modos se mezclan
Sintaxis :
code128W(nRow,nCol,cCode,oWnd,[cMode],[Color],
[lOrientacion],[nAncho],[nAlto])
nRow, nCol en Pixels
nAncho,nAlto en Cm
*/
Function Code128W( nRow, nCol, cCode, oWnd, cMode, Color, lHorz, nWidth, nHeigth )
// test de parametros
// por implementar
go_codeW( _code128(cCode,cMode), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
return nil
Function c_Code128W( nRow, nCol, cCode, oWnd, cMode, Color, lHorz, nWidth, nHeigth )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return Code128W( nRow, nCol, cCode, oWnd, cMode, Color, lHorz, nWidth, nHeigth )
Function Code3_9W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
// test de parametros
// por implementar
go_codeW( _code3_9(cCode,lCheck), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
return nil
Function c_Code3_9W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth)
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return Code3_9W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
Function ean13W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth, lBanner, cFont )
local nLen
// test de parametros
// por implementar
default nHeigth := 1.5
default lBanner:=.f.
// desplazamiento...
if lHorz
go_codeW( _ean13(cCode), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth * 0.90 )
else
//nLen :=round ( nHeigth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 ) * 0.1
nLen := round ( nCm2Pixels( oWnd:GetDC(), nLen, .F. ), 0 ) * 0.1
oWnd:ReleaseDC()
// 10% espacios
go_codeW( _ean13(cCode), nRow, nCol + nLen, oWnd, lHorz, Color, nWidth, nHeigth * 0.90 )
end
go_codeW( _ean13Bl(), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
if lBanner
barlen13W( cCode, oWnd, nRow, nCol, Color, lHorz, nWidth, nHeigth, cFont )
end
return nil
Function c_ean13W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return ean13W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
Function UPCAW( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth, lBanner, cFont )
local nLen
// test de parametros
// por implementar
default nHeigth := 1.5
default lBanner:=.f.
if lHorz
go_codeW( _UPC(cCode), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth * 0.90 )
else
//nLen := round ( nHeigth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 ) * 0.1
nLen := ROUND( nCm2Pixels( oWnd:GetDC(), nLen, .F. ), 0 ) * 0.1
oWnd:ReleaseDC()
// 10% espacios
go_codeW( _UPC(cCode), nRow, nCol + nLen, oWnd, lHorz, Color, nWidth, nHeigth * 0.90 )
end
go_codeW( _UPCABl(cCode), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
if lBanner
UPCA_barlenW( cCode, oWnd, nRow, nCol, Color, lHorz, nWidth, nHeigth, cFont )
end
return nil
Function c_UPCAW( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return UPCAW( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
Function ean8W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth, lBanner, cFont )
local nLen
// test de parametros
// por implementar
default nHeigth := 1.5
default lBanner:=.f.
if lHorz
go_codeW( _UPC(cCode,7), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth * 0.90 )
else
//nLen :=round ( nHeigth * 10 * oPrint:nHorzRes() / oPrint:nHorzSize(), 0 ) * 0.1
nLen := ROUND( nCm2Pixels( oWnd:GetDC(), nLen, .F. ), 0 ) * 0.1
oWnd:ReleaseDC()
// 10% espacios
go_codeW( _UPC(cCode,7), nRow, nCol + nLen, oWnd, lHorz, Color, nWidth, nHeigth * 0.90 )
end
go_codeW( _ean13Bl(8), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
if lBanner
barlenW( cCode, 7, oWnd, nRow, nCol, Color, lHorz, nWidth, nHeigth, cFont )
end
return nil
Function c_ean8W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return ean8W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
Function sup5W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth, lBanner, cFont )
// test de parametros
// por implementar
go_codeW( _sup5(cCode), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
if lBANNER
ban5W( cCode, oWnd, nRow, nCol, Color, lHorz, nWidth, nhEIGTH, cFont )
end
return nil
Function c_Sup5W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth, lBanner, cFont )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return sup5W( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth, lBanner, cFont )
Function CodabarW( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
// test de parametros
// por implementar
go_codeW( _Codabar(cCode), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
return nil
Function c_CodabarW( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return CodabarW( nRow, nCol, cCode, oWnd, Color, lHorz, nWidth, nHeigth )
Function int25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
// test de parametros
// por implementar
go_codeW( _int25(cCode,lCheck), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
return nil
Function c_int25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return int25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
Function ind25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
// test de parametros
// por implementar
go_codeW( _ind25(cCode,lCheck), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
return nil
Function c_ind25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return ind25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
Function mat25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
// test de parametros
// por implementar
go_codeW( _mat25(cCode,lCheck), nRow, nCol, oWnd, lHorz, Color, nWidth, nHeigth )
return nil
Function c_mat25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )
uCm2Pixels( oWnd:GetDC(), @nRow, @nCol )
oWnd:ReleaseDC()
return mat25W( nRow, nCol, cCode, oWnd, lCheck, Color, lHorz, nWidth, nHeigth )