1. Krishna Mohan Gullap
  2. PowerBuilder
  3. Tuesday, 17 November 2020 19:46 PM

Hello All -

One of the requirements from my client is that he needs to restrict certain fields in a datawindow from being altered manually. He wants to have them populated using a scanner and disallow manual entry

So, I did something like this in an user-defined event mapped to pbm_dwnkey

KeyDown event (Mapped to pbm_dwnkey):

Get the old value stored in the DW column from the Primary Buffer (The changes would not take effect unless they press tab)

if user presses any key (alphabets/numerals) then

       Restore the value from the primary buffer

       Pass the control on to the next editable field

End If

As long as the user tries to edit these restricted fields using the keyboard, everything works perfectly fine. But, when the user does a scan of, say 10 characters from a barcode, the above KeyDown event gets triggered automatically 10 times (probably since it's a keyboard wedge scanner and acts pretty much like a keyboard)

Now, the challenge is that I don't have a way to distinguish if the key character to the above event came from the action where a user presses a key or from the scanner

Can you experts help in this situation? Is there another in-built pbm* datawindow event that I can make use of? Or is there an Windows API call that I can make to see if the keyboard was used to send that key? Any suggestions are greatly appreciated !!!



Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 17 November 2020 20:06 PM
  2. PowerBuilder
  3. # 1

Hi Krishna;

  I suspect that it just sends keyboard messages to the current keyboard buffer. So it might make it very hard to discern where the keyboard input actually cam from.

  I have used other types of scanners with PB Apps and they had the option to place the scanned data into the clipboard where the PB App could then use to do a proper SetItem() into the DWO's primary buffer directly. Does your scanner have that feature?

Regards ... Chris

Hey Chris -

Thanks for your response. I undetstand it is almost impossible to tell these events apart :-)

The scanner doesn't place the data onto the clipboard. I tried doing a copy from clipboard but it didn't work. It scans to all editable fields though (including an empty notepad) but a copy of the scanned text isn't there on the clipboard

The major hurdle is that I don't have access to the scanner. The client has it plugged in to his workstation and I am able to connect with him only remotely as he is in another state :-)

You were telling about this option to place the scanned data into the clipboard, is this an install time parameter? Or is it usually available in the scanner settings post installation?


  1. Krishna Mohan Gullap
  2. Wednesday, 18 November 2020 08:55 AM
FWIW: In my case, it was a scanner setting to have it use the clipboard.
  1. Chris Pollach @Appeon
  2. Wednesday, 18 November 2020 16:20 PM
Okay Chris, I can check with the client if this specific scanner allows such a change to be made
  1. Krishna Mohan Gullap
  2. Thursday, 19 November 2020 18:28 PM
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.