About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).

Tuesday, December 01, 2009

Creating an Psion Tecklogix Scan Gun App

In 4 simple and easy to follow steps:

Step 1: Getting Psion Resources

You will have to register to get access to the page.
(https://teknet.psionteklogix.com/ptxCMS/Teknet.aspx?s=us&p=DevKits)

Download and install their "Mobile Devices SDK"


Step 2: Create Project

If you go to the "Smart Device" section, you will notices a "Psion Teklogix Device Project". This add the Psion TeklogixNet reference and also the PtxSdkCommon.dll in the root directory, which is a dependency when running your app on device.
















Step 3: Add Items to the Toolbar, if needed

Right-click on the Toolbar, and select Choose Items.
Browse to C:\Program Files\Psion Teklogix\Mobile Devices SDK V3.1\DotNet2 and select the PsionTeklogixNet.dll

This should add:




If not already done so, drag each of those items onto the form.

















The default app gives a good example, it uses the ScanCompleteEvent; which send in a string value representation of the barcode and places it text into a textbox for the user to see.








Step 4: Deploying
Code Snippet
  1. /* $Revision 1.1.1.1 */
  2. /* Copyright Psion Teklogix Inc. 2007 */
  3. /*
  4. * File: Form1.cs
  5. *
  6. * Description:
  7. * Implementation file for Form1 class in PtxApp1
  8. *
  9. */
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Data;
  15. using System.Drawing;
  16. using System.Runtime.InteropServices;
  17. using System.Text;
  18. using System.Windows.Forms;
  19. using PsionTeklogix.Barcode;
  20. using PsionTeklogix.Barcode.ScannerServices;
  21.  
  22. /*! <summary>
  23. Contains the class and functions related to PtxApp1 scanner application
  24. </summary>
  25. */
  26. namespace PtxApp1
  27. {
  28.     /*
  29.     * Form1
  30.     *
  31.     */
  32.     /// <summary>
  33.     /// The Form1 class generates the Graphical User Interface for PtxApp1.
  34.     /// </summary>
  35.     public partial class Form1 : Form
  36.     {
  37.         /*
  38.         * InitializeScanner
  39.         *
  40.         */
  41.         /// <summary>
  42.         /// Initialize components for PtxApp1.
  43.         /// </summary>
  44.         private void InitializeScanner()
  45.         {
  46.             scanner.Driver = scannerServicesDriver;
  47.             scanner.ScanCompleteEvent += new ScanCompleteEventHandler(scanner_ScanCompleteEvent);
  48.         }
  49.  
  50.         /*
  51.         * Form1
  52.         *
  53.         */
  54.         /// <summary>
  55.         /// Required for Windows Form designer support.
  56.         /// </summary>
  57.         public Form1()
  58.         {
  59.             try
  60.             {
  61.                 InitializeComponent();
  62.                 InitializeScanner();
  63.             }
  64.             catch (Exception ex)
  65.             {
  66.                 MessageBox.Show("Failed to initialize component: " + ex.ToString());
  67.                 this.Close();
  68.             }
  69.         }
  70.  
  71.         /*
  72.         * Button1_Click
  73.         *
  74.         */
  75.         /// <summary>
  76.         /// This method is called when the scan button is clicked and will scan the
  77.         /// barcode.
  78.         /// </summary>b
  79.         /// <param name="sender">
  80.         /// The calling object that represents the user that sent the message.
  81.         /// </param>
  82.         /// <param name="e">
  83.         /// Contains event data of the Scan Button control
  84.         /// </param>
  85.         private void button1_Click(object sender, EventArgs e)
  86.         {
  87.             try
  88.             {
  89.                 scanner.Scan();
  90.             }
  91.             catch (Exception ex)
  92.             {
  93.                 MessageBox.Show("Scan error: " + ex.ToString());
  94.                 this.Close();
  95.             }
  96.         }
  97.        
  98.         /*
  99.         * Scanner1_ScanCompleteEvent
  100.         *
  101.         */
  102.         /// <summary>
  103.         /// This method is called when the scan complete event occurs. The method is
  104.         /// called by its respective handler and then displays a text representation
  105.         /// of the barcode on the display.
  106.         /// </summary>
  107.         /// <param name="sender">
  108.         /// The calling object that represents the user that sent the message.
  109.         /// </param>
  110.         /// <param name="e">
  111.         /// Contains event data once the scan is complete
  112.         /// </param>
  113.         delegate void scanner_ScanCompleteDelegate(object sender, ScanCompleteEventArgs e);
  114.  
  115.         private void scanner_ScanCompleteEvent(object sender, ScanCompleteEventArgs e)
  116.         {
  117.             if (!InvokeRequired)
  118.             {
  119.                 textBox1.Text = e.Text;
  120.             }
  121.             else
  122.             {
  123.                 Invoke(new scanner_ScanCompleteDelegate(scanner_ScanCompleteEvent),
  124.                 new object[] { sender, e });
  125.             }
  126.         }
  127.     }
  128. }
When deploying, remember to set the device to PtxPxa27c: ARMV4I_Release


P.S.
The size of the form shouldn't be bigger than 245 x 300

5 comments:

Anonymous said...

dear Andrus nice to see your blog on a topic which is not frequently touched upon. I am developing a barcode scanner app on Psion Teklogix device running windows mobile 2003. Currently Im having problem adding the Ptxsdkcommon.dll to my C# project and gives me error unable to add reference probably because it is built in c++. I have tried different versions of the above mentioned dll with the same result everytime, can you please send me a link to the SDK version mentioned in your blog. I can not find it on the psion official site. My target framework is 2.0 - 3.5. You can email me at razi_19@hotmail.com. Any help will be greatly appreciated

Unknown said...

Your post is great of many details.
Now I'm trying to integrate barcode reader with windows forms. I love your article which help me a lot. Thanks.

Jim Green said...

HOW TO scan a barcode with Android smartphone camera from a web page?you can try this barcode scan SDK for ASP.Net.

James said...
This comment has been removed by the author.
James said...

13 years later...just dropping in to say this saved my life after a lot of heartache with a PTX7535.