Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Disable keyboard input in Barcode textbox
Message
From
05/05/2019 07:34:56
 
 
To
05/05/2019 02:48:02
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01668357
Message ID:
01668401
Views:
52
>>>>>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.
>>>
>>>
>>>Thanks sir for helping,
>>>Naomi Nosonovsky's solution NODEFAULT on keypress event does not work. Textbox does not accept values from keyboard or barcode scanner.
>>>
>>>I think your codes will work fine to accept values only coming from external device.
>>>
>>>Please help
>>
>>I'll try to work on it tomorrow or Monday.
>
>Thanks in advance.
>
>I have just found a vfp codes based solution and want to share.
>
>I wrote these lines under timer
>
>
>if len(alltrim(thisform.text1.value))<5
>	thisform.text1.value=""
>endif
>
>
>Now text1 does not accept any value coming from keyboard.
>
>May be your solution will be different.

If it works, use it. Sounds good.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform