Delphi 10.3. I want to detect the entering of a bar code scanning into a editbox (TEdit or TcxEdit). I think of the onChange or onEditValueChange, so need to make the editbox readonly. I don't want to fire this event everytime I type in the digit (the barcode has 20 digits). The barcode scanner will be plug into the USB port, my question is if the editbox is readonly, when the cursor within the editbox can the barcode fill in the editbox when I scan the barcode?
Asked
Active
Viewed 551 times
0
-
If the Edit box is read-only, the scanner won't be able to "type" into it, no. You should try to find out if your scanner supports an API where you can directly get the barcode, or at least receive events from the scanner itself, rather than "typing" into an Edit box at all – Remy Lebeau Sep 30 '21 at 00:58
-
1As I understand, you use a barcode scanner that connect as a keyboard. Using that, you can't do what you want. Replace (or configure) the barcode scanner by a model which read input not as a keyboard. For example an RS232 interfaced barcode. You'll be able to handle the barcode data independently of the keyboard: The barcode reader doesn't "type" in the editbox, you explicitly read the data using a RS232 component and you can write to the editbox if that is what you need. – fpiette Sep 30 '21 at 05:56
-
2Most barcode scanners (that I know of) that hooks into the keyboard chain can be set up to send a "prefix" character before the actual digits. So in your KeyDown/KeyUp event you can check for this value, set a flag, and then on each subsequent KeyDown/KeyUp event you can collect the digits until the termination character (often CR) is received. – HeartWare Sep 30 '21 at 06:46
-
Hi, we find out the barcode scanner will be used is a bluetooth type...so it will be a sort of USB then, right? Because they need to plug in the dongle in USB port in PC. – Ricky Nelson Sep 30 '21 at 06:47
-
In use a Disabled Edit Box and add the characters to it from the Form Keypress event. This way you can capture the Barcode but the Edit Box is not editable directly. – NeoPOS Sep 30 '21 at 06:58
-
Bluetooth is not important, what matters is it doing keyboard emulation or RS232! – Delphi Coder Sep 30 '21 at 10:05
-
Some newer BarCode scanners also support pasting the scanned value instead of simulating individual key presses for each character in the scanned string. This is becoming especially popular in newer BarCode scanners that also support scanning of QR codes as they can contain quite long strings. Imagine simulating Keyboard events for a scanned QR cod that contains about 100 characters long string. So I recommend reading the BarCode scanner documentation first to see which modes are supported before you start designing your application. It can save you a bunch of time. – SilverWarior Sep 30 '21 at 17:30