Jump to content
Fivewin Brasil

usando serviços Gerador de codigo QR


kapiaba

Recommended Posts




// Our first DialogBox sample - Somente funciona nas novas versoes.

#include "FiveWin.ch"
#include "ttitle.ch"

# define HTTPREQUEST_PROXYSETTING_PROXY 2

function Main()



local obmp ,cBmp
local oDlg, oIco
local ofont
local cCode:= space(180)

DEFINE Font ofont NAME "Verdana" SIZE 0,14

DEFINE ICON oIco FILE "..\icons\fivewin.ico"

DEFINE DIALOG oDlg TITLE "Qrcode Generator" ;
ICON oIco SIZE 350, 440

@ 30,24 IMAGE oBmp FILE cBmp OF oDlg size 128,128 pixel NOBORDER

oBmp:lTransparent := .t.

// cargaBmp( "hola",oBmp )


@ 160, 10 SAY "Introduce el codigo a generar :" size 100, 12 ;
FONT oFont pixel OF oDlg

@ 170, 10 GET cCode size 120, 12 FONT oFont pixel OF oDlg

@ 205, 85 BUTTON "&Buscar" SIZE 40, 12 OF oDlg pixel ;
FONT oFont ;
ACTION cargaBmp( alltrim( cCode) ,oBmp )

@ 205,130 BUTTON "&Salir" SIZE 40, 12 pixel OF oDlg;
FONT oFont ;
ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT DlgBarTitle( oDlg, " Generador de Qrcode","" ,44 ) ;
ON PAINT DlgStatusBar(oDlg, 68,, .t. )

return nil

//------------------------------------------------------------------------------

Function cargaBmp( cCode, oImage )

local cResp
local nZeroZeroClr
local ogbmp := GdiBmp():new()
local nHeight := 248
local nWidth := 248
local cUrl := "http://api.qrserver.com/v1/create-qr-code/?data="

cUrl += GetSafeURL(hb_strtoutf8( cCode ) )
cUrl += "&size=" + alltrim( str( nWidth ) ) + "x" + alltrim( str( nHeight ) )

cResp := loadBmp(cUrl)

if !Empty( cResp )

oGbmp:hbmp := GDIPLUSIMAGELOADPNGFROMSTR( cResp,len(cResp) )

oImage:hBitmap := oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oImage:Refresh()
if msgYesNo( " ¨ quiere grabar el codigo QR a Disco ?")
oGBmp:save(".\qrcode.png" )
endif
oGbmp:End()
endif

Return nil

Static Function GetSafeURL( cUrl )
local cAsc
local nChr
local sHex
local i
local cGetSafeURL := ""

For i = 1 To Len( cUrl )
cASC := substr( cUrl, i, 1)
nChr := Asc( cASC )

If ( nChr > 47 .and. nChr < 58 ) .Or. ( nChr > 64 .And. nChr < 91 ) .Or. ( nChr > 96 .And. nChr < 123 )
cGetSafeURL += cASC
Else
sHex := hb_NumtoHex( nChr )
If Len( sHex ) = 1
cGetSafeURL += "%0" + sHex
Else
cGetSafeURL += "%" + sHex
End If
End If
Next

Return cGetSafeURL

//------------------------------------------------------------------------------

Function loadBmp(cUrl)
local oHttp
local cResp := nil

Try
oHttp := CreateObject( "winhttp.winhttprequest.5.1" )

oHttp:Open("GET", cUrl, .f. )
oHttp:Send()
cResp := oHttp:ResponseBody()

Catch
MsgStop( "Error" )
Return cResp
End Try

Return cResp

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

Function DlgStatusBar(oDlg, nHeight, nCorrec , lColor )
Local nDlgHeight := oDlg:nHeight
Local aColor := { { 0.40, nRGB( 200, 200, 200 ), nRGB( 184, 184, 184 ) },;
{ 0.60, nRGB( 184, 184, 184 ), nRGB( 150, 150, 150 ) } }

DEFAULT nHeight := 72
DEFAULT nCorrec := 0
DEFAULT lColor := .F.

nDlgHeight:= nDlgHeight+ncorrec
IF lColor
GradienTfill(oDlg:hDC,nDlgHeight-( nHeight-2 ),0,nDlgHeight-20,oDlg:nWidth, aColor ,.t.)
WndBoxIn( oDlg:hDc,nDlgHeight-( nHeight-1 ),0,nDlgHeight-( nHeight ),oDlg:nWidth )
ELSE
WndBoxIn( oDlg:hDc,nDlgHeight -( nHeight-1 ),4,nDlgHeight-( nHeight ),oDlg:nWidth - 10 )
endif

Return Nil

//------------------------------------------------------------------------------

FUNCTION DlgBarTitle( oWnd, cTitle, cBmp ,nHeight )
LOCAL oFont
LOCAL oTitle
LOCAL nColText := 180
LOCAL nRowImg := 0


DEFAULT cTitle := ""
DEFAULT nHeight := 48

IF nHeight < 48
nColText := 60
nRowImg := 12
DEFINE FONT oFont NAME "Arial" size 10, 30
ELSE
DEFINE FONT oFont NAME "Arial" size 12, 30
endif

@ -1, -1 TITLE oTitle size oWnd:nWidth+1, nHeight+1 of oWnd SHADOWSIZE 0

@ nRowImg, 10 TITLEIMG OF oTitle BITMAP cBmp SIZE 48, 48 REFLEX ;
TRANSPARENT

@ nRowImg-2 , nColText TITLETEXT OF oTitle TEXT cTitle COLOR CLR_BLACK FONT oFont

oTitle:aGrdBack := { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 ) } }
oTitle:nShadowIntensity = 0
oTitle:nShadow = 0
oTitle:nClrLine1 := nrgb(0,0,0)
oTitle:nClrLine2 := RGB( 229, 233, 238 )
oWnd:oTop:= oTitle



RETURN oTitle


Quem tem versao deste ano, pode testar? Thanks.


Link to comment
Share on other sites

qual versao mais nova?

1502 nao vai

┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for xHarbour 15.02 - Feb. 2015 xHarbour development power │▄
│ © FiveTech, 1993-2015 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8 │█
└────────────────────────────────────────────────────────────────────────────┘█
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
xHarbour 1.2.3 Intl. (SimpLex) (Build 20141106)
Compiling 'qrcode.prg' and generating preprocessed output to 'qrcode.ppo'...
Generating C source output to 'qrcode.c'...
Done.
Lines 186, Functions/Procedures 6, pCodes 827
Borland C++ 5.82 for Win32 Copyright © 1993, 2005 Borland
qrcode.c:
Turbo Incremental Link 5.69 Copyright © 1997-2005 Borland
Error: Unresolved external '_HB_FUN_HB_NUMTOHEX' referenced from E:\FWH1502\MULT
ISQL\QRCODE.OBJ
* Linking errors *
E:\FWH1502\multisql>
Link to comment
Share on other sites

Tente:



#IFDEF __XHARBOUR__
#xtranslate hb_DateTime([<x,...>]) => DateTime(<x>)
#xtranslate hb_tstostr([<x>]) => TToS(<x>)
#xtranslate hb_stot([<x>]) => SToT(<x>)
#xtranslate hb_ttod([<x>]) => TToD(<x>)
#xtranslate hb_hour([<x>]) => Hour(<x>)
#xtranslate hb_minute([<x>]) => Minute(<x>)
#xtranslate hb_sec([<x>]) => Secs(<x>)
#xtranslate hb_NumToHex([<x>]) => NumToHex(<x>)
#xtranslate hb_StrFormat([<x,...>]) => StrFormat(<x>)
#xtranslate <x>:__EnumIndex => hb_EnumIndex
#ENDIF


Link to comment
Share on other sites

  • 1 month later...

oi kapíaba.

EU QUANDO COMPILO DA ESTE ERRO,

Compiling...

Borland C++ 5.5 for Win32 Copyright © 1993, 2000 Borland

qrcode.c:

ttitle.c:

Turbo Incremental Link 5.00 Copyright © 1997, 2000 Borland

Fatal: Too many DEF file names: d:\fwh1407\lib\Fivehx.lib

* There are errors

VOCE TEM IDEIA DO QUE POSSA SER?

Link to comment
Share on other sites

oi kapíaba. EU QUANDO COMPILO DA ESTE ERRO, Compiling... Borland C++ 5.5 for Win32 Copyright © 1993, 2000 Borland qrcode.c: ttitle.c: Turbo Incremental Link 5.00 Copyright © 1997, 2000 Borland Fatal: Too many DEF file names: d:\fwh1407\lib\Fivehx.lib * There are errors VOCE TEM IDEIA DO QUE POSSA SER?

Na sua versão, não funcionará, na versão FWH15.05 funcionará perfeita, pois a GDIPLUS estará completa. abs.

Link to comment
Share on other sites

Dá pra usar API do Google também

Basta passar: https://chart.googleapis.com/chart?chs=255x255&cht=qr&chl=<data>&choe=<output_encoding>&chld=<error_correction_level>|<margin>

onde:

chs= tamanho

chl= texto para codificação

choe= encoder( UTF-8,Shift_JIS ou ISO-8859-1 )

chld= nível de correção de erros

margin= Tamanho da borda branca ao redor do QRCode gerado

------------------------------------------------------------------------------------------------------------

Fonte: https://google-developers.appspot.com/chart/infographics/docs/qr_codes

Link to comment
Share on other sites

eu tenho a 14.07(que atualizei ano passado), nesta funciona ou tenho que atualizar pra 15.05?

Não funcionará. E eu garanto, que a versão FWH15.05 está maravilhosa. Estou dando aulas em casa para um clippeiro, e pedi que ele comprasse com o Gilmer, a versão FWH15.05. Mano, está tudodebom.com. E vc. pode fazer em duas vezes no cartão, ou no boleto. Fale com o Gilmer, negocie, xore, expernei... kkkkkkkkkkkk, mas compre. Eu recomendo. abs.

Link to comment
Share on other sites

Kapi,

Quanto é o jabá que tu tá recebendo pra fazer propaganda para o Gilmer? kkkkkkkkkkkkkkkkkkkkk

Fala friend! Em brejas, é lógico!!! kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

Kleyber, eu acho que para você, porque é você, ele fará em 3 vezes no cartão; Poddyyyyyy??? kkkkk

abs.

Link to comment
Share on other sites

Melhorando...



// Our first DialogBox sample
// Testado com FWHX15.05 Show de bola.

#include "FiveWin.ch"
#include "ttitle.ch"

# define HTTPREQUEST_PROXYSETTING_PROXY 2

#IFDEF __XHARBOUR__
#xtranslate hb_DateTime([<x,...>]) => DateTime(<x>)
#xtranslate hb_tstostr([<x>]) => TToS(<x>)
#xtranslate hb_stot([<x>]) => SToT(<x>)
#xtranslate hb_ttod([<x>]) => TToD(<x>)
#xtranslate hb_hour([<x>]) => Hour(<x>)
#xtranslate hb_minute([<x>]) => Minute(<x>)
#xtranslate hb_sec([<x>]) => Secs(<x>)
#xtranslate hb_NumToHex([<x>]) => NumToHex(<x>)
#xtranslate hb_StrFormat([<x,...>]) => StrFormat(<x>)
#xtranslate <x>:__EnumIndex => hb_EnumIndex
#ENDIF

function Main()

local obmp ,cBmp
local oDlg, oIco
local ofont
local cCode:= space(180)
local oGerar, oSaida

DEFINE Font ofont NAME "Verdana" SIZE 0,14

DEFINE ICON oIco FILE "fivewin.ico"

DEFINE DIALOG oDlg TITLE "Gerador de Qrcode - FWHX15.05" ;
ICON oIco SIZE 350, 440

oDlg:lHelpIcon := .F.

@ 30,24 IMAGE oBmp FILE cBmp OF oDlg size 128,128 pixel NOBORDER

oBmp:lTransparent := .t.

// cargaBmp( "hola",oBmp )

@ 160, 10 SAY OemToAnsi( "Digite o C¢digo Para Gerar: " ) ;
size 100, 12 FONT oFont pixel OF oDlg

@ 170, 10 GET cCode size 120, 12 FONT oFont pixel OF oDlg

@ 205, 85 BUTTON oGerar PROMPT "&Gerar" SIZE 40, 12 OF oDlg pixel ;
WHEN( .NOT. EMPTY( cCode ) ) FONT oFont ;
ACTION cargaBmp( alltrim( cCode) ,oBmp )

oGerar:cToolTip := "Busca e Gera o Qrcode"

@ 205,130 BUTTON oSaida PROMPT "&Saida" SIZE 40, 12 pixel OF oDlg ;
FONT oFont ;
ACTION oDlg:End()

oSaida:cTooltip := "Saida - Exit - Cancelar"

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT DlgBarTitle( oDlg, " Gerador de Qrcode","" ,44 ) ;
ON PAINT DlgStatusBar(oDlg, 68,, .t. )

oFont:End()

return nil

//------------------------------------------------------------------------------

Function cargaBmp( cCode, oImage )

local cResp
local nZeroZeroClr
local ogbmp := GdiBmp():new()
local nHeight := 248
local nWidth := 248
local cUrl := "http://api.qrserver.com/v1/create-qr-code/?data="

cUrl += GetSafeURL(hb_strtoutf8( cCode ) )
cUrl += "&size=" + alltrim( str( nWidth ) ) + "x" + alltrim( str( nHeight ) )

cResp := loadBmp(cUrl)

if !Empty( cResp )

oGbmp:hbmp := GDIPLUSIMAGELOADPNGFROMSTR( cResp,len(cResp) )

oImage:hBitmap := oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oImage:Refresh()

if msgYesNo( "Deseja Gravar QRCODE.PNG no Disco?")

oGBmp:save(".\qrcode.png" )

endif

oGbmp:End()

endif

Return nil

Static Function GetSafeURL( cUrl )

local cAsc
local nChr
local sHex
local i
local cGetSafeURL := ""

For i = 1 To Len( cUrl )

cASC := substr( cUrl, i, 1)
nChr := Asc( cASC )

If ( nChr > 47 .and. nChr < 58 ) .Or. ;
( nChr > 64 .And. nChr < 91 ) .Or. ;
( nChr > 96 .And. nChr < 123 )

cGetSafeURL += cASC

Else

sHex := hb_NumtoHex( nChr )

If Len( sHex ) = 1
cGetSafeURL += "%0" + sHex
Else
cGetSafeURL += "%" + sHex
End If

End If

Next

Return cGetSafeURL

//------------------------------------------------------------------------------

Function loadBmp(cUrl)

local oHttp
local cResp := nil

Try
oHttp := CreateObject( "winhttp.winhttprequest.5.1" )

oHttp:Open("GET", cUrl, .f. )
oHttp:Send()

cResp := oHttp:ResponseBody()

Catch

MsgStop( "Error" )

Return cResp

End Try

Return cResp

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

Function DlgStatusBar(oDlg, nHeight, nCorrec , lColor )

Local nDlgHeight := oDlg:nHeight
Local aColor := { { 0.40, nRGB( 200, 200, 200 ), nRGB( 184, 184, 184 ) },;
{ 0.60, nRGB( 184, 184, 184 ), nRGB( 150, 150, 150 ) } }

DEFAULT nHeight := 72
DEFAULT nCorrec := 0
DEFAULT lColor := .F.

nDlgHeight:= nDlgHeight+ncorrec

IF lColor
GradienTfill(oDlg:hDC,nDlgHeight-( nHeight-2 ),0,nDlgHeight-20,oDlg:nWidth, aColor ,.t.)
WndBoxIn( oDlg:hDc,nDlgHeight-( nHeight-1 ),0,nDlgHeight-( nHeight ),oDlg:nWidth )
ELSE
WndBoxIn( oDlg:hDc,nDlgHeight -( nHeight-1 ),4,nDlgHeight-( nHeight ),oDlg:nWidth - 10 )
endif

Return Nil

//------------------------------------------------------------------------------

FUNCTION DlgBarTitle( oWnd, cTitle, cBmp ,nHeight )

LOCAL oFont
LOCAL oTitle
LOCAL nColText := 180
LOCAL nRowImg := 0


DEFAULT cTitle := ""
DEFAULT nHeight := 48

IF nHeight < 48
nColText := 60
nRowImg := 12
DEFINE FONT oFont NAME "Arial" size 10, 30
ELSE
DEFINE FONT oFont NAME "Arial" size 12, 30
endif

@ -1, -1 TITLE oTitle size oWnd:nWidth+1, nHeight+1 of oWnd SHADOWSIZE 0

@ nRowImg, 10 TITLEIMG OF oTitle BITMAP cBmp SIZE 48, 48 REFLEX ;
TRANSPARENT

@ nRowImg-2 , nColText TITLETEXT OF oTitle TEXT cTitle COLOR CLR_BLACK FONT oFont

oTitle:aGrdBack := { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 ) } }
oTitle:nShadowIntensity = 0
oTitle:nShadow = 0
oTitle:nClrLine1 := nrgb(0,0,0)
oTitle:nClrLine2 := RGB( 229, 233, 238 )
oWnd:oTop:= oTitle

RETURN oTitle

// FIM DO PROGRAMA


Link to comment
Share on other sites

  • 2 weeks later...

Usando HBZEBRA, compila com HARBOUR e xHARBOUR

#include "fivewin.ch"
#include "codebar.ch" 
 
static oCode, oWnd
 
function Main
 
   local oMenu
   
   oCode := TCodeBars():New(500,500)
   
   oMenu = BuildMenu()
   
   define window oWnd menu oMenu
   activate window oWnd 
 
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 :)") )
           menuitem "QR-CODE"    action( BuildCode( CODEBAR_QRCODE,     "http://danielgarciagil.com/") )
        endmenu
   endmenu
   
return oMenu
 
function BuildCode( nCode, cCode, nFlags )
 
   local hDC := oWnd:GetDC()
   local oPrn
 
   default nFlags := 0
   
   oCode:Reset()
   if nCode < CODEBAR_PDF417
      oCode:nHeightCode = oCode:nHeight - 50
      oCode:nWidthCode  = 1.5
   else
      if nCode == CODEBAR_QRCODE
         oCode:nHeightCode = 3
         oCode:nWidthCode  = 3
      else
         oCode:nHeightCode = 3
         oCode:nWidthCode  = 1
      endif
   endif
   oCode:SetType( nCode )
   oCode:SetCode( cCode )
   oCode:SetFlags( nFlags )
   oCode:Build()
   
   DrawBitmap( hDC, oCode:hCodeBar, 0, 0 )
 
   PRINT oPrn NAME "Qr code print" PREVIEW
      PAGE
         *Drawbitmap( oPrn, oCode:hCodeBar, 100, 100)
         *oPrn:SayImage( 100, 100, oCode:hCodeBar, 300, 300 )
         *oPrn:SayBitmap( 100, 100, oCode:hCodeBar, 300, 300 )
 
         Drawbitmap( oPrn:hDCOut, oCode:hCodeBar, 200, 400)
 
         oPrn:Say( 500, 100, "This is a test" )
      ENDPAGE
   ENDPRINT
   
   oWnd:ReleaseDC()
   
return nil   
 
// CLASSE
 
 
#include "fivewin.ch"
#include "codebar.ch"
 
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
   
 
   ::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"     , {| | NIL /*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
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...