Barcode Scanner Component
The Barcode Scanner component allows a Articles dialog form to automatically detect input from a USB barcode scanner. When a barcode is scanned, the OnBarcode event fires and your script can read the scanned value and populate controls on the dialog.
Adding to a Dialog Form
- Open your report in the Articles designer
- Open or create a dialog form
- Locate Barcode Scanner in the dialog component palette
- Drop it anywhere on the dialog form — it appears as a small icon and has no visible runtime presence
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| Active | Boolean | True | Enables or disables scanning. Set to False to temporarily stop the component intercepting scanner input. |
| MinLength | Integer | 3 | Minimum number of characters required before a scan is recognised as valid. Prevents single accidental keystrokes being treated as scans. |
| MaxKeyDelay | Integer | 50 | Maximum milliseconds allowed between characters from the scanner. Scanners send characters very rapidly — human typing is always slower than this threshold. |
| LastBarcode | String | The last successfully scanned barcode value. Read-only. |
Events
OnBarcode
Fires when a complete valid barcode has been scanned. A scan is considered complete when the scanner sends a carriage return (Enter) after at least MinLength characters.
PascalScript signature:
procedure BarcodeScanner1OnBarcode(Sender: TfrxComponent);
begin
// handle the scan here
end;
PascalScript Examples
Populate an edit control from a scan
procedure BarcodeScanner1OnBarcode(Sender: TfrxComponent);
begin
edtItemNo.Text := BarcodeScanner1.LastBarcode;
end;
Populate an edit control and disable further scanning
procedure BarcodeScanner1OnBarcode(Sender: TfrxComponent);
begin
edtItemNo.Text := BarcodeScanner1.LastBarcode;
BarcodeScanner1.Active := False;
end;
Scan into whichever edit control is focused
procedure BarcodeScanner1OnBarcode(Sender: TfrxComponent);
begin
if edtItemNo.Text = '' then
edtItemNo.Text := BarcodeScanner1.LastBarcode
else
edtQty.Text := BarcodeScanner1.LastBarcode;
end;
Important Notes
- The component works with USB HID barcode scanners that emulate keyboard input. It will not work with serial or Bluetooth scanners that use a different communication method.
- The scanner must be configured to send a carriage return (Enter) at the end of each scan. Most scanners do this by default.
- If MinLength is set too low, fast typists may accidentally trigger the OnBarcode event. The default of 3 is suitable for most barcodes.
- If MaxKeyDelay is set too high, normal keyboard typing may be mistaken for scanner input. The default of 50ms is suitable for most scanners. If your scanner is slow, increase this value.
- Only one Barcode Scanner component is needed per dialog form regardless of how many edit controls you have.
- The component is inactive at design time — it only starts intercepting input when the dialog is running.