#include "fivewin.ch"
Static oFontText
Static oWnd
Static lPaint := .T.
Static hZebra
Static hBrush
Static nWidth := 0
Static nHeight := 0
//----------------------------------------------------------------------------//
Function Main()
DEFINE FONT oFontText NAME "Calibri" SIZE 0, -11
DEFINE WINDOW oWnd FROM 10, 10 TO 700, 700 PIXEL MENU MyMenu()
ACTIVATE WINDOW oWnd ON PAINT BarCode()
RELEASE FONT oFontText
DeleteObject( hBrush )
hb_Zebra_Destroy( hZebra )
return nil
//----------------------------------------------------------------------------//
Function MyMenu()
local oMenu
MENU oMenu
MENUITEM "Actions"
MENU
MENUITEM "Save" ACTION SaveCode()
SEPARATOR
MENUITEM "Exit" ACTION oWnd:End()
ENDMENU
ENDMENU
Return oMenu
//----------------------------------------------------------------------------//
function BarCode()
local nX := 18
local nY := 18
local hFont
local cCode := "20219719443 | 01 | F001 | 00045256 | 25/01/2018 | 18.00 | 118.00 | 6 | 10087302682 |"
if Empty( hBrush )
hBrush := CreateSolidBrush( 0 )
hZebra := hb_Zebra_Create_Qrcode( cCode, NIL )
hb_zebra_draw( hZebra, { | x, y, w, h | nWidth := x + w, nHeight := y + h, ;
FillRect( oWnd:hDC, { y, x, y + h, x + w }, hBrush ) }, nX, nY, 11, 11 )
oFontText:Activate( oWnd:hDC )
DrawText( oWnd:hDC, cCode, { nHeight + 10 , nX - 4, nHeight + 24, nWidth + 4 }, 0 )
oFontText:DeActivate( oWnd:hDC )
endif
return nil
//----------------------------------------------------------------------------//
Function SaveCode()
local oBmp
local hGraf
local hBmp
local hBrush1 := GdiPlusNewSolidBrush( 255, 255, 255, 255 )
local hBrush2 := GdiPlusNewSolidBrush( 255, 0, 0, 0 )
oBmp := GdiBmp():New()
hBmp := GdiPlusBmpFromBrush( nWidth + 18, nHeight + 18, hBrush1 )
hGraf := GdiPlusHGraFFromHBmp( hBmp )
hb_zebra_draw( hZebra, { | x, y, w, h | GdiPlusDrawRect( hGraf, , hBrush2, x, y, w, h ) }, 18, 18, 11, 11 )
oBmp:hBmp := hBmp
GdiPlusDeleteGraphics( hGraf )
GdiPlusDeleteBrush( hBrush2 )
GdiPlusDeleteBrush( hBrush1 )
oBmp:Save( "Code1.png" )
oBmp:End()
Return nil
//----------------------------------------------------------------------------//