SAYBARCODE algunas dudas

SAYBARCODE algunas dudas

Postby leandro » Wed Oct 30, 2019 1:36 pm

Buenas noches para todos

Dos preguntas sobre SAYBARCODE

Primera: Cuando intento compilar este código

Code: Select all  Expand view
  DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,800 PIXEL TRUEPIXEL FONT oFont ;
      TITLE "TSAYBARCODE CONTROL"

   @ 240, 40 SAY "Name    :" GET cName    SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 270, 40 SAY "City    :" GET cCity    SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 300, 40 SAY "Country :" GET cCountry SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 330, 40 SAY "Item    :" GET cItem    SIZE 200,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. ) ;
                                          PICTURE "999999999999" RIGHT
   @  230,450 SAYBARCODE oSay ;
      TEXT "Address :" + CRLF + cName - CRLF - cCity - CRLF - cCountry ;
      TYPE "QR-CODE" SIZE 100,100 PIXEL OF oDlg ;
      UPDATE

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont


Me arroja el siguiente error de sintaxis

Code: Select all  Expand view

c:\a-inv32\prg\Diwcap01.prg(2299) Error E0030  Syntax error: "syntax error at '@'"
Ya fue agregada la instrucción REQUEST FWZEBRA alinicio del prg.

Segunda pregunta:

Es posible utilizar SAYBARCODE desde recursos?

De antemano gracias
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1484
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: SAYBARCODE algunas dudas

Postby armando.lagunas » Wed Oct 30, 2019 9:11 pm

Leandro:

con una clase que encontre en el foro, genero un QR con información (que entre mas caracteres tiene es mas grande el QR), el cual lo imprimo en el preview

pero lo simpatico de esto es que genera un archivo BMP y este puede ser puesto en unrecurso "IMAGE" y te puede ayudar a lo que necesitas.

aqui la clase:

Code: Select all  Expand view


#Include "FiveWin.ch"

#define CODEBAR_EAN13          1
#define CODEBAR_EAN8           2
#define CODEBAR_UPCA           3
#define CODEBAR_UPCE           4
#define CODEBAR_ITF            5
#define CODEBAR_MSI            6
#define CODEBAR_CODABAR        7
#define CODEBAR_CODE11         8
#define CODEBAR_CODE39         9
#define CODEBAR_CODE93         10
#define CODEBAR_CODE128        11
#define CODEBAR_PDF417         12
#define CODEBAR_DATAMATRIX     13
#define CODEBAR_QRCODE         14

#define CODEBAR_TYPE           1
#define CODEBAR_BLOCK          2

#define DEFAULT_CODEBAR        CODEBAR_PDF417

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

CREATE 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

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


como lo utilizo:

Code: Select all  Expand view


           cCodeBar  := "entre mas letras o caracteres tenga es mas grande"

           oQRCode:= TCodeBars():New( 421, 421, 10, 10, CODEBAR_QRCODE, cCodeBar )
           oQRCode:Build()
           GeneraCodigo_QR( oQRCode )


PRINTER oPrn NAME "Tarja Pallet" PREVIEW  
PAGE
...
...
                       oPrn:SayImage(4800, 3500 , "..\QrCode.bmp",1200,1200 )
...
...
ENDPAGE
ENDPRINT


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

Function GeneraCodigo_QR( oCode )
   Local hDib

   If ( File( ..\QrCode.bmp" ), Ferase( ..\QrCode.bmp" ), )

   hDib := DibFromBitmap( oCode:hCodeBar )
   DibWrite( "..\QrCode.bmp", hDib )
   GloBalFree( hDib )

 Return nil

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

 



Resultado:

1. https://i.postimg.cc/MTXXYGTS/Captura3.jpg

Espero que te oriente un poco

Saludos
SkyPe: armando.lagunas@hotmail.com
Mail: armando.lagunas@gmail.com
User avatar
armando.lagunas
 
Posts: 346
Joined: Mon Oct 05, 2009 3:35 pm
Location: Curico-Chile

Re: SAYBARCODE algunas dudas

Postby cnavarro » Wed Oct 30, 2019 9:37 pm

Antes de seguir investigando, asegúrate que estés utilizando el fivewin.ch que viene con tu versión de Fivewin, si, efectivamente es el fichero .ch correcto, busca el comando y comprueba que la sintaxis que has utilizado es la que aparece en el comando del fichero .ch y en el mismo orden, que algunas veces esto produce algún quebradero de cabeza.
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6501
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: SAYBARCODE algunas dudas

Postby nageswaragunupudi » Thu Oct 31, 2019 3:03 am

Me arroja el siguiente error de sintaxis


I tried your program here with FWH1903 and I did not get any errors
This is the exact code I used and built it with buildh.bat and also buildx.bat

Code: Select all  Expand view
#include "fivewin.ch"

REQUEST FWZEBRA

function Main()

   local oDlg, oFont, oSay, cName, cCity, cCountry, cItem

   cName    := PadR( "Antonio Linares", 20 )
   cCity    := PadR( "Marbella", 20 )
   cCountry := PadR( "Spain", 20 )
   cItem    := "123456789012"

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,800 PIXEL TRUEPIXEL FONT oFont ;
      TITLE "TSAYBARCODE CONTROL"

   @ 240, 40 SAY "Name    :" GET cName    SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 270, 40 SAY "City    :" GET cCity    SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 300, 40 SAY "Country :" GET cCountry SIZE 300,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. )
   @ 330, 40 SAY "Item    :" GET cItem    SIZE 200,24 PIXEL OF oDlg VALID ( oDlg:Update(), .t. ) ;
                                          PICTURE "999999999999" RIGHT
   @  230,450 SAYBARCODE oSay ;
      TEXT "Address :" + CRLF + cName - CRLF - cCity - CRLF - cCountry ;
      TYPE "QR-CODE" SIZE 100,100 PIXEL OF oDlg ;
      UPDATE

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SAYBARCODE algunas dudas

Postby leandro » Tue Nov 12, 2019 3:44 pm

Mr Nages, Gracias por responder:

Compile el ejemplo que me envió, lo hice con la versión que estoy utilizando actualmente FWH1909, también para pruebas hice la con FWH1903 y funciona bien.

El problema ocurre al momento que integro el código (exactamente igual), a nuestra aplicación, en ese momento es cuando sale el error de sintaxis.
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1484
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: SAYBARCODE algunas dudas

Postby leandro » Tue Nov 12, 2019 3:47 pm

Armando, gracias por responder.

Efectivamente de la forma que mencionas estoy haciendo que funcione, bajando una imagen del QR al disco y luego si mostrarla por pantalla, mientras sale una versión en la que pueda dibujar el codigoQR, directamente desde recursos.
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1484
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: SAYBARCODE algunas dudas

Postby nageswaragunupudi » Tue Nov 12, 2019 4:30 pm

El problema ocurre al momento que integro el código (exactamente igual), a nuestra aplicación, en ese momento es cuando sale el error de sintaxis.

Please ensure that you are using the correct version of "fivewin.ch", without any modifications. You should not get any syntax errors.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: SAYBARCODE algunas dudas

Postby nageswaragunupudi » Tue Nov 12, 2019 4:33 pm

leandro wrote:Armando, gracias por responder.

Efectivamente de la forma que mencionas estoy haciendo que funcione, bajando una imagen del QR al disco y luego si mostrarla por pantalla, mientras sale una versión en la que pueda dibujar el codigoQR, directamente desde recursos.


Hope you know that you can easily create QR code bmp with these functions:
Code: Select all  Expand view

hBitmap := FW_BarCodeBmp( cText, "QR", nWidth, nHeight )
FW_SaveImage( hBitmap, cBmpFile )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10295
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 38 guests