Jump to content
Fivewin Brasil

oribeiro

Membros
  • Posts

    1,291
  • Joined

  • Last visited

  • Days Won

    35

oribeiro last won the day on February 1 2022

oribeiro had the most liked content!

1 Follower

About oribeiro

  • Birthday 02/19/1965

Contact Methods

  • Website URL
    www.oasysitu.com

Profile Information

  • Gender
    Male
  • Location
    Itu, SP

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

oribeiro's Achievements

Newbie

Newbie (1/14)

79

Reputation

Single Status Update

See all updates by oribeiro

  1. Ola Ribeiro. Vi alguns comentarios de voce la no forum, tentanto gerar um codigo QR.

    Tentei de todas as formas. Voce pode me dar alguma dica ?

    Obrigado

     

    1. oribeiro

      oribeiro

      Consegui com esse código:

      * CodeQR.prg
      * 08/03/2018
      * Programa para gerar código QR

      #include "fivewin.ch"

      /* CODEBAR.CH
      #include "hbzebra.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_TYPE           1
      #define CODEBAR_BLOCK          2
      #define CODEBAR_QRCODE         14
      #define DEFAULT_CODEBAR        CODEBAR_PDF417
      */

      Function TesteCodeQR()
         Local oCode
         Local hDC, hBmp
         Local oPrn, hDib
         oCode:=TCodeBars():New( 500, 500 )
         oCode:Reset()           // Reset
         oCode:nHeightCode = 10  // altura  -> 7.23 PAGINA CHEIA
         oCode:nWidthCode  = 10  // Largura -> 7.23 PAGINA CHEIA
         oCode:SetType( 14 )     // CODEBAR_QRCODE
         oCode:SetCode( "Oscar Batista Ribeiro Neto e Marina BATISTA Ribeiro casaram-se no dia quatorze de julho de dois mil e dezessete e viverão felizes para sempre." ) // ( "35141146377222003730599000004630001158179941|20141105134922|10.00|61694805808|m+4o8FY1lig1zcy6VU3t7INVwE6kiA/ykLXKDFZfb9gu0g4wl3Fk2HYaRhSt8G+yk9mP/R65m3R7V2IO8CxnmO1oVtlamB6UKA+UZZqDNEqtYlhQzLySNzMG0thaNMZsq5RxmQ3eQLPw8LLez3MqWvUveFXNSSq6AGEX2+KOdavteo3K2L06SQoVIjwkmcgRzqhfHP3y8t2wfr1nw/WAnaCF9ZY/K4dTykk3hsXcan/MKCTBlcSOhNgSh3sdsQHpl2w2tmbLBsYBLFkuvKlwzHarNJQ1RfRznGdojHglQH1KVtbAUXKke54pdRt3JL7nJlR+Lbmtd2tjcT2vRyTepw==" ) // Texto para gerar o QRCode
         oCode:SetFlags( 0 )     // Não sei o que é
         oCode:Build()           // Cria o código
         *
         hDib := DibFromBitmap( oCode:hCodeBar )
         DibWrite( "QRCODE.BMP" , hDib )  // Grava arquivo BMP no disco
         *
         hDC  := oWnd:GetDC()
         hBmp := ReadBitmap( 0, "QRCODE.BMP" )
         DEFINE DIALOG oDlgQR FROM 0,0 TO 20,40
         ACTIVATE DIALOG oDlgQR ON PAINT DrawBitmap( hDC, hBmp, 0, 0, 300, 300 ) CENTER
         Erase("QRCODE.BMP")
         /*
         PRINT oPrn NAME "Imprimir QrCode" PREVIEW
         PAGE
            Drawbitmap( oPrn:hDCOut, oCode:hCodeBar, 500, 500)
            *oPrn:SayImage( 100, 100, oCode:hCodeBar, 300, 300 )
            oPrn:SayBitmap( 1, 1, oCode:hCodeBar, 300, 300 )
            oPrn:SayBitmap( 1, 1, ReadBitmap(0,"QRCODE.BMP"), 300, 300 )
         ENDPAGE
         ENDPRINT
         */
         oCode:End()             // Encerra TCodeBar()
      Return nil

      //--------------------------------------//
      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"     , {| | 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 ][ 2 ] ) // [ 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[ 1 ] == Upper( cnType ) } ) // [ CODEBAR_TYPE ]
            endif
         else
            ::nType = 12 // 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

      *Eof( CodeQR.Prg )

    2. xtsystem

      xtsystem

      Obrigado amigo. Vou testar aqui. Muito brigado

    3. xtsystem

      xtsystem

      Ok Ribeiro. Funcionou, porem eu queria somente gerar o código e não o bitmap. Será que tem jeito. Muito obrigado por sua ajuda.

    4. Show next comments  3 more
×
×
  • Create New...