I want to prompt the user to scan a bar code or RFID tag. That (I guess) means either MessageDlg() or a small form – I don’t care which and invite advice.
When I read a scan over serial port or HID (or timer or WM_xxxx), I want to close that prompt.
What is the simplest way to go about that? Thankls
We have this feature in our application with even 1 more integrated step to start with.
I will describe it fully, as it might be useful to you.
We have a modal dialog that allows the user to enter the Serial Id for a device by either keying it in with the keyboard or just scanning the barcode tag.
Step 1. We have a menu item with a Hot Key (Shortcut Ctrl+Alt+N for instance). We have configured the scanner so that it sends this preamble whenever it scans a barcode. (Manual equivalent of keying in the shortcut). That opens the modal dialog.
Step 2. The Focus is in a Edit box to get the Serial ID either from the user and the keyboard or from the scanner reading the barcode.
Step 3. There are an [OK] and a [Cancel] buttons. The OK button has
Default:=TrueandModalResult:=mrOK. The Cancel button hasCancel:=TrueandModalResult:=mrCancel. The scanner is set to postfix the scanned string with Enter which has the same effect as the user hitting the [Enter] key or clicking the OK button: it closes the modal dialog with mrOK in the ModalResult so we can read the Edit.text to get the SerialID.Step 3bis. The user presses [Esc] or click on Cancel or closes the dialog with the title bar close button: it closes the dialog with anything but
mrOKand we discard whatever is in the Edit…Works very well in our case with any scanner working as an HID emulation (keyboard) and where we can configure the preamble. (sending Enter at the end was by default in all the scanners we tried).