I am working on a Win CE 5 application that captures data scanned via barcode scanner. The application should support some "system-barcodes", predefinded barcodes that trigger functions of the application.
Those barcodes have to work in the whole main-frame. So I set the property "KeyPreview" of the main-frame to true and registered an KeyEventHandler on the KeyDown event of the main-frame.
My problem is, I couldn't figure out how to get the full scanned string. The string is 12 characters long and ends with a newline. Is there a possibility to get the whole string in the EventHandler?
Thank you in advance for any help.
Most, if not all, barcode scanners based on Windows CE inject the scan data as keyboard data to the device driver. The easiest way to intercept that data in your app, where you don't have to hook up handlers to every form and worry about controls getting the keys before your processing logic is to use a keyboard hook. It works just like on the desktop, so any code you find that applies to keyboard hooks on the desktop would be valid (with the exception that the DLL containing the APIs in WinCE is coredll.dll).
There is an example of keyboard hooking for Windows Mobile on CodeProject which would probably give you the bases for everything you need. From there, it's simply string parsing in the hook handler.