TSayBarCode
Fonte: 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
| DATA | Type | Description |
|---|---|---|
cText | Character | Text string to encode in the barcode |
bGet | Code block | Code block returning the barcode text value |
BarCodeType | Numeric | Barcode symbology type (default 128 for Code 128) |
lVertical | Logical | Render the barcode vertically |
nPinSize | Numeric | Width of the narrowest bar element in pixels |
nFlags | Numeric | Additional rendering flags for the barcode engine |
Methods
| Method | Description |
|---|---|
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
- The
BarCodeTypedefaults to 128 (Code 128). Other supported types include 39 (Code 39), EAN-13, EAN-8, UPC-A, and Interleaved 2 of 5. - Set
lVerticalto.T.for applications where vertical space is more abundant than horizontal space. - The
nPinSizeproperty controls the width of the narrowest bar. Increase for larger barcodes suitable for long scanning distances. - Use a code block
bGet(or theVARclause) to bind the barcode to a variable that updates automatically. - Call
Refresh()after changing any rendering property to update the display.