Recent

Author Topic: Scanner & Tedit  (Read 643 times)

Petrus Vorster

  • Full Member
  • ***
  • Posts: 171
Scanner & Tedit
« on: September 02, 2024, 11:30:43 am »
Hi All

Please help me think.
This has to be something simple I am overlooking.

I have a Tedit into which i scan barcodes.
They are ALWAYS 13 characters.

I added a Keyup event to check when it reached that 13th character then it calls a procedure that validates the barcode, add to a datarecord and then clear the Tedit for the next barcode.

The Tedit1.setfocus is messing around since the scanners always returns a TAB afterwards.
(Re-calibrating them will not be allowed.)

I made a workaround by setting the focus to another control just before it, and that works, but it doesnt seem the ideal means.

Any suggestions?

Regards,

Peter

rvk

  • Hero Member
  • *****
  • Posts: 6886
Re: Scanner & Tedit
« Reply #1 on: September 02, 2024, 11:36:52 am »
Create a FormKeyDown, set the KeyPreview of the form to true and in the OnFormKeyDown eat the VK_TAB key when your focus is on the TEdit.

Manually tabbing though the TEdit isn't possible then too.

Another option would be to do your checks in the OnExit and not in the OnChange of the TEdit.

Zvoni

  • Hero Member
  • *****
  • Posts: 3135
Re: Scanner & Tedit
« Reply #2 on: September 02, 2024, 11:38:08 am »
You mean to say, that your Scanner is configured with a TAB as a suffix?????
Bloody hell, whoever had that idea?!?!??!
The "standard" is usually a Cr(LF)

Next: When you scan a Barcode, you get all 13 Characters in one go (like a Copy/Paste), so i'm not sure if KeyUp is the correct event.
My first try would be OnChange.
Though you have to do Sanity-Checking within (Is Length=13 etc.) in case of manual entry
Don't forget "Trim"-ing within (it would also eliminate any trailing TAB's coming from the scanner)
« Last Edit: September 02, 2024, 11:40:06 am by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Petrus Vorster

  • Full Member
  • ***
  • Posts: 171
Re: Scanner & Tedit
« Reply #3 on: September 02, 2024, 11:47:12 am »
Thanks. I got it working.
The EXIT on the tedit works.

Depends on the applications used. Many scanners are configured to a TAB, sometimes to a LF (ENTER) depending on the needs.
I just have to go with the flow.

-Regards,

Peter


 

TinyPortal © 2005-2018