TSayBarCode

Source: source/classes/tsaybcod.prg

Inherits from: TControl

TSayBarCode renders barcodes as a visual control on windows and dialogs. It supports multiple barcode symbologies (Code 128, Code 39, EAN, etc.) with configurable orientation, pin size, and display flags. The control can be bound to a data variable for automatic refresh.

Key DATA Members

DATATypeDescription
cTextCharacterText string to encode in the barcode
bGetCode blockCode block returning the barcode text value
BarCodeTypeNumericBarcode symbology type (default 128 for Code 128)
lVerticalLogicalRender the barcode vertically
nPinSizeNumericWidth of the narrowest bar element in pixels
nFlagsNumericAdditional rendering flags for the barcode engine

Methods

MethodDescription
New( nRow, nCol, bText, cType, oWnd, nW, nH )Create a new barcode control with text block, type, and dimensions
Redefine( nID, bText, cType, oWnd )Redefine from a dialog resource by control ID
Paint()Draw the barcode graphic in the control area
Refresh()Re-render the barcode after changing properties
SetText( c )Update the barcode text and refresh the display

Commands

@ nRow, nCol SAYBARCODE oBar VAR bBlock TYPE cType SIZE nW, nH OF oDlg

Example: Code128 Barcode

#include "FiveWin.ch"

function Main()

   local oWnd, oBar
   local cCode := "ABC-12345"

   DEFINE WINDOW oWnd TITLE "Barcode Demo" SIZE 400, 200

   @ 20, 20 SAYBARCODE oBar VAR { || cCode } ;
      TYPE "CODE128" SIZE 360, 80 OF oWnd

   oBar:nPinSize := 2
   oBar:lVertical := .F.

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also