Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Disable keyboard input in Barcode textbox
Message
From
02/05/2019 12:22:30
 
 
To
02/05/2019 08:32:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01668357
Message ID:
01668366
Views:
45
>Dear Experts
>
>I have a textbox1 which gets input from Barcode scanner.
>I want this textbox not to accept input from keyboard.
>
>Background:
>
>I scan barcodes of new products and save in database.
>Some times user enters some wrong data into this textbox and save it in db.
>I want to block user to input any data in said textbox to ensure correct data is being entered.
>
>While googling I found this link similar to my problem
>https://stackoverflow.com/questions/50464858/allow-only-barcode-scanner-and-eliminate-keyboard-input?noredirect=1&lq=1
>
>But do no know how to make procedures workable in VFP.
>
>Please help

If I had this requirement, I would create a DLL and subclass the thisForm.HWND to intercept all of the WM_KEYDOWN and WM_KEYUP messages, and perform a timing analysis on them when the user is on a field that has input that should only come from a remote device like a barcode scanner.

If the keys are not received in immediate succession (within a few milliseconds), then ignore them on that field.

If you would like this solution I can write it for you. I would create the API interface:
DECLARE INTEGER keyboard_intercept IN kbd.dll INTEGER nHwnd
DECLARE INTEGER keyboard_deintercept IN kbd.dll INTEGER nHwnd
DECLARE keyboard_only_barcode_scanner IN kbd.dll
DECLARE keyboard_allow_all_keys IN kbd.dll
Those three functions should do it for you. On the form's Init() event you would call keyboard_intercept(thisForm.HWnd). On the GotFocus() event, call keyboard_only_barcode_scanner(), and on LostFocus() call keyboard_allow_all_keys(). And on the Unload() or Destroy() event, call keyboard_deintercept(thisForm.HWnd).

Let me know.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform