Return to homepage
   
 
Jump to Article
   
 

Responding to all the device buttons in VB.NET

Introduction

One of the most important things to bear in mind when developing applications for our end users is to ensure they have access to all the functionality they need in the easiest way possible. You’ll notice on your Pocket PC device that there are many different buttons that have a function which in most cases, the end user won’t really miss. A user running a mobile application to record stock won’t really need a dedicated button to bring up their personal calendar or record a voice message.

So why not remap these buttons to a useful function of the application the user is “supposed” to be using. Well, Sapphire Solutions (http://www.sapphire-solutions.co.uk) have created a utility that does just this. This can monitor whether a user has pressed one of the buttons on the device and your eVB or VB.NET/C# application can do whatever is required after. That may be displaying a certain screen to the user.

Utility overview

The Sapphire Buttons Utility is a small DLL that can be called from eVB or VB.NET/C#. It will return the current status of what buttons are currently being pressed by the user and you can even get the actual name of the button should you desire to do so.

Feature list

The features of the Sapphire Buttons Utility are as follows:

  • Check what button is pressed
  • Retrieve the button name

Running the demo project

Sapphire have also provided an extensive demo project in both eMbedded Visual Basic and VB.NET that show how to use all the functions of the DLL. You get all the eVB and VB.NET source code which is not only great for experienced programmers to implement the utility, but also great for new programmers to see how the application has been approached.

The latest version of the Sapphire Buttons Utility can be downloaded from their web site here:
http://www.sapphire-solutions.co.uk/product.asp?product=BUTTONS

Once you have downloaded the demo project and unzip it, you will have two versions of the demo project, one for eVB and the other for VB.NET. You will also have a folder containing the different DLLs compiled for the different devices.

Simply select the DLL that matches the device. If you are developing in eVB, then you will need to copy the DLL to the \Windows\ path. Alternatively, if you are developing in VB.NET or C#, you need to copy the DLL to the application path. Check the project settings to see where the demo project will deploy itself to.

Now you are ready to run the demo. Please note the following screenshots have been taken from the VB.NET demo project.

Buttons Demo

Buttons Demo

Sample code

Private Sub tmrButtons_Tick(ByVal sender As System.Object, _
                            ByVal
e As System.EventArgs) Handles tmrButtons.Tick

  Dim lButton As Integer

  Dim lKey1 As Integer

  Dim lKey2 As Integer

 

  lButton = sButtons(1234567890, lKey1, lKey2)

 

  If lButton = 0 Then

    lblButton.Text = ""

  Else

    If lKey2 = 0 Then

      lblButton.Text = ButtonName(lKey1)

    Else

      lblButton.Text = ButtonName(lKey1) & " (" & ButtonName(lKey2) & ")"

    End If

  End If

End Sub

Manual documentation

Sapphire Solutions also provide a comprehensive manual for all their utilities. It includes a definition of the DLL function calls, some sample code and FAQs to help with any troubleshooting.

Their manual documentation can be viewed online, downloaded as a HTML document for offline use and even a downloadable Windows help file. These can all be found on their web site at http://www.sapphire-solutions.co.uk/manual.

Licence of use

Sapphire Solutions provide an unlimited use demo version of the Sapphire Buttons Utility. While the product will function as normal, the user will receive a popup message stating that it is a demo version. It is great for trying out the utility, checking device compatibility, building it into your application and selling the idea to your customer. Students can use it as well for their college or university projects without having to purchase it either.

Of course though, for commercial applications being developed you will need to get a licence for the utility to make it run without any pop-ups. The good thing about Sapphire’s pricing policy is that it is a one off fee and you or your company can use it as many times as you like for your projects royalty free. There are no royalties required for rolling out your application to your client.

With that you will also get 12 months support via email to their experienced technical team. They also provide upgrades for the latest versions at discounted prices which also extend the 12 months support by a further 12 months