Mira yo lo hago asi
#include "fivewin.ch"
#include "codebar.ch"
static oCode, oWndP
function Main()
local oMenu
oCode := TCodeBars():New()
oMenu = BuildMenu()
**
BuildCode( CODEBAR_DATAMATRIX, "DataMatrix
")
* define window oWndP menu oMenu
* activate window oWndP &&ON INIT (BuildCode( CODEBAR_DATAMATRIX, "DataMatrix
", oWndP:end() ))
return nil
function BuildMenu()
local oMenu
menu oMenu
menuitem "CodeBar"
menu
menuitem "EAN13" action( BuildCode( CODEBAR_EAN13, "477012345678" ) )
menuitem "EAN8" action( BuildCode( CODEBAR_EAN8, "1234567" ) )
menuitem "UPCA" action( BuildCode( CODEBAR_UPCA, "01234567891" ) )
menuitem "UPCE" action( BuildCode( CODEBAR_UPCE, "123456" ) )
menuitem "CODE39" action( BuildCode( CODEBAR_CODE39, "ABC123" ) )
menuitem "ITF" action( BuildCode( CODEBAR_ITF, "1234", HB_ZEBRA_FLAG_WIDE3 ) )
menuitem "MSI" action( BuildCode( CODEBAR_MSI, "1234567", HB_ZEBRA_FLAG_CHECKSUM ) )
menuitem "CODABAR" action( BuildCode( CODEBAR_CODABAR, "40156", HB_ZEBRA_FLAG_WIDE3 ) )
menuitem "CODE93" action( BuildCode( CODEBAR_CODE93, "ABC-123" ) )
menuitem "CODE11" action( BuildCode( CODEBAR_CODE11, "12", HB_ZEBRA_FLAG_WIDE3 ) )
menuitem "CODE128" action( BuildCode( CODEBAR_CODE128, "Code 128") )
menuitem "PDF417" action( BuildCode( CODEBAR_PDF417, "PDF17" ) )
menuitem "DATAMATRIX" action( BuildCode( CODEBAR_DATAMATRIX, "DataMatrix
") )
endmenu
endmenu
return oMenu
function BuildCode( nCode, cCode, nFlags )
* local hDC := oWndP:GetDC()
default nFlags := 0
oCode:Reset()
if nCode < CODEBAR_PDF417
oCode:nHeightCode = oCode:nHeight - 50
oCode:nWidthCode = 1.5
else
oCode:nHeightCode = 3
oCode:nWidthCode = 1
endif
oCode:SetType( nCode )
oCode:SetCode( cCode )
oCode:SetFlags( nFlags )
oCode:Build()
* DrawBitmap( hDC, oCode:hCodeBar, 0, 0 ) && aqui lo pinta en la pantalla
DrawBitmap( oCode:hCodeBar,10, 10 ) && aqui lo mando a un archivo file.bmp de 10x10 tam
hDib := DibFromBitmap(oCode:hCodeBar )
DibWrite( "file.bmp" , hDib )
* oWndP:ReleaseDC()
* oWndP:END()
return nil