Barcode Scanning on Unitech Windows Mobile/PocketPC Scanners
Previous Topic  

QuickStart Guide to: Barcode Scanning on Unitech Windows Mobile/PocketPC Scanners


Unitech manufactures several models of Windows Mobile/PocketPC rugged handhelds with integrated barcode scanning capability.  This QuickStart Guide shows you how to add Unitech Windows Mobile/PocketPC barcode scanning support to your Satellite Forms application, quickly and easily.


This QuickStart Guide contains plenty of screenshots to guide you through the process step by step, but don't let the length of this article scare you: the entire process of building the barcode scanning test application for the Unitech PocketPC scanners should only take about 15 minutes.


In order to control the Unitech barcode scanner, we'll utilize the UnitechScan plugin extension that is included with Satellite Forms.  This extension is written to work with the Unitech scanner library that is preinstalled on most Unitech Windows Mobile/PocketPC scanners.


Okay, let's build an Unitech Scan Test sample application step by step:


Step 1. Start a new project in Satellite Forms MobileApp designer, and select the PocketPC platform target.  A default form named Form 1 will be created, ready for you to add controls to.  Click in the middle of the form, so that the Control Palette Toolbar becomes active.  Let's add a form Title control, with the title text set to Unitech Scan Test.  Next add a text control with the label Barcode: and below that add an edit control named edBarcode that stretches across the width of the form.  Your form should look like this:



Step 2. The next step is to add the UnitechScan control extension to our project.  Click on the Manage Extensions toolbar icon which looks like this:   A list of available extensions is displayed.  Do not select the one at the top named Bar Code Reader.  Scroll down to the bottom of the list, and select the UnitechScan extension, then click OK:




Step 3. Step 3. The UnitechScan extension is a custom SFX control, and not just a plugin script extension.  Although it is a custom control, the control is not actually visible to the end user: it is only visible in form design view of MobileApp Designer.  Because it is a custom control, an icon is added to the Control Palette toolbar so that you can click on the icon to add the control to your forms.  The SFX icon looks like this and is added to the right end of the Control Palette toolbar.  If you do not see it, there's a good chance that part of the Control Palette toolbar is simply being cut off because the MobileApp Designer window is not wide enough.  That's easy to solve, we'll just grab the Control palette toolbar "handle" and drag it down to the next line in the MobileApp Designer desktop.  Now we can see all the Control palette toolbar icons, like this:




Okay good, we can see all the toolbar icons now.


So, click on the SFX custom control toolbar icon so that we can add it to our form.  It's possible you might have more than one custom control on a form and they all share the same toolbar icon, so a selection box appears to let you choose the custom control you want, like this:



Click OK to select it, and the control then appears on our form as a little barcode symbol.  Remember, this custom control is not visible to the end user.  Let's move it out of the way so it does not overlap other controls, so your form should now look like this:



The default name that appears for the scanner control is UnitechScan1, and we'll leave it at that default.  With the scanner control selected, click the Edit Action button in the control properties, and select Run Script from the Action Type droplist.  This is the OnClick script for the scanner control, and this event will be fired when a barcode is scanned.



Step 4. Alright, now we're getting into the thick of things: here is where we decide what to do when a barcode is scanned.  Click on Edit Script and the blank script editor window will open up.  In this script, we are going to use a script method of the scanner control to obtain the barcode data that was scanned and place it into the edBarcode edit control on the form.  Here's the script code to type in (feel free to copy & paste right from this QuickStart Guide article):


'this OnClick event is fired when a barcode is scanned

edBarcode = UnitechScan1.GetScanData


Step 5. Okay, we need to do a couple more things to make barcode scanning work.  What we need to do is to make sure the device we're running on is really an Unitech barcode scanner, and if so, make sure the scanner is enabled.  We also need to disable the scanner when we leave the form.  So, in the form AfterOpen event script that gets fired when the form is opened, confirm the scanner is enabled like this:


'if device is Unitech barcode scanner then

'enable scanner in AfterOpen event and

'disable in BeforeClose event


if UnitechScan1.IsUnitechScanner = True then

       'enable scanning

       UnitechScan1.ScannerEnable

else

       'warn user about no scanner

       edBarcode = "Not Unitech scanner"

endif


And in the form BeforeClose event, disable the barcode scanner like this:


'if device is Unitech barcode scanner then

'disable in BeforeClose event


if UnitechScan1.IsUnitechScanner = True then

       'disable scanning

       UnitechScan1.ScannerDisable

endif


That's about it for the barcode scanning stuff.  Let's give the application a name, compile it, and test it out on the handheld.


Step 6. Click on the Edit > Project Properties menu, and give our application the name Unitech Scan Test, like this:



Click OK, and then save your project.  Name it Unitech Scan Test.sfa.


Now, compile the application by pressing the F7 hotkey (Rebuild All).  If the compiler finds any typos, fix them, and then Rebuild All again.  Next, connect the Unitech scanner to the cradle or sync cable, and use the Handheld > Download App & Tables menu option (or press the F5 hotkey) to download the application to your Unitech Windows Mobile/PocketPC scanner device.  Launch the SatForms SDK app on the handheld, select Unitech Scan Test from the list, and you are ready to scan.


Point the scanner at a nearby barcode, press one of the scan buttons on the Unitech unit, and you the scanner should read the barcode and play a confirmation beep.  Here's a sample screenshot from a Unitech PA950 screen:



Congratulations!  You've just learned how to scan barcodes on Unitech Windows Mobile/PocketPC scanners with Satellite Forms!


There are plenty of additional functions in the scanner control to give you even more detailed control over the scanning process, but you've got the basic scanning function covered just by applying what you learned in the QuickStart Guide above.


Additional Sample Projects:        

       \Satellite Forms 7\Samples\Projects\Unitech Scan\UnitechScan.sfa


Keywords:      Unitech, barcode, scanner, quickstart, PocketPC, Windows Mobile, PA950, PA500, PA600


KB ID: 10082 

Updated: 2007-12-03


Satellite Forms KnowledgeBase Online

Satellite Forms Website Home