Exploring Tablet PC Application Deployment
You have decided to take the plunge and create a Microsoft® Windows® XP Tablet PC Edition operating system-aware application. This decision comes with a new set of requirements when it comes to enabling Tablet PC-specific features and deployment of your application. This article will take you through the process of creating a Tablet PC-aware application and deploying it in the enterprise.
You may receive an exception if you are on a non-Tablet PC-enabled computer because there are no recognizers installed. You will need a Table PC-enabled OS to support ink recognition.
When developing Tablet PC-enabled applications you must take a number things into consideration. Do you create applications specific to just the Tablet PC platform? Do you create a single application that houses “standard” application inputs and then augments that functionality with tablet features where relevant? How do you know if you are running in a Tablet PC-enabled environment? What tools do you need to install to develop these applications? What do you need to do to deploy these applications into the enterprise? This article will address these issues.
Visual Studio 2005 developers who want to develop pen-enabled applications don’t have to do a lot more than they’d do to build any application with the .NET Framework. You can develop pen-enabled applications using the following operating systems and toolsets:
Windows Vista™ Premium Editions
Microsoft® Windows® XP Professional (SP2)
Microsoft Windows Server™ 2003
Windows XP Tablet PC Edition 2005
Microsoft Windows 2000 (SP4)
Microsoft Visual Studio® 6.0 (SP5)
Visual Studio .NET (2003 or 2005)
After installing/acquiring the proper operating systems and tools you need to download and install the Tablet PC SDK from the Microsoft Web site.
You can develop and test your applications using any of the above operating systems provided you have the proper tools installed (for a more detailed explanation of development environments for Tablet PC-enabled applications, see Eliot Graff’s article, “The Proper Developer Environments for Mobile PC, Tablet PC, and Ultra-Mobile PC Applications,” found in this issue of CoDe Focus.
The real limitations of your operating systems present themselves when it comes to deployment For instance, Windows XP Professional or Windows 2000 don’t natively support ink recognition. These operating systems can collect ink but there are no default recognizers installed to turn that ink into text. To turn ink into text you will need Windows XP Tablet PC Edition 2005, a Premium edition of Windows Vista, or a copy of Windows XP with Microsoft Windows XP Tablet PC Edition 2005 Recognizer Pack installed (see sidebar, Recognizer Pack).
After installing the Tablet PC SDK you can get to work on pen-enabling your application. This article will use Windows XP Professional and Visual Studio 2005 to create a simple Tablet PC-aware application and then deploy that application to Windows Vista Ultimate and Tablet PC Edition 2005.
Tiny Tablet Application
My small Tablet PC-enabled application has the following requirements:
Capture ink input from the end user
Determine whether the platform supports Tablet PC functionality.
Turn captured ink into text when your operating environment is capable
Determine what recognizers are available to an application
To build this application, do the following:
Create a new Windows application.
Add a reference to the Microsoft.Ink and Microsoft.Ink.Analysis assembles. You can find these assemblies in the following location: “C:\Program Files\Microsoft Tablet PC Platform SDK\Include\Microsoft.Ink.dll”
Add three buttons to your form. Name them cmdRecognize, cmdClear and cmdShowRecognizers respectively. Set the Text property of these buttons to Recognize, Clear, and Show Recognizers, respectively.
Add a Panel control to your form. Name it pnInk.
Add an imports statement referencing Microsoft.Ink assembly to your form.
Add an overlay member variable to your form.
Add the following code to the Load event of your form.MyCollector = New InkCollector(Me.pnInkHandle)
Add the following code to the Click event of the cmdRecognizeButton.Dim cString As String = _
Add the following code to the cmdClear button’s Click event.Me.MyCollector.Ink.DeleteStrokes()
Now run your application. Your Panel control should accept ink input. However, when you click the cmdRecognize button you may receive an exception if you’re not on a Tablet PC computer because there are no recognizers installed. You will need a Tablet PC-enabled OS to support ink recognition. The next section will demonstrate how to determine whether Tablet PC features are available to your applications.
The first step to building a Tablet PC-aware application is to determine whether or not you are running in a Tablet PC operating environment. You can test whether you are running in a Tablet PC-enabled environment by calling the Windows API GetSystemMetrics function with a value of 86. For example:Module WindowsAPI
Private Declare Auto Function
GetSystemMetrics Lib "user32" _
(ByVal value As Integer) As Integer
Private Const SM_TABLETPC As Integer = 86
Public Function IsTablet() As Boolean
Dim lnTestValue As Integer = _
Return lnTestValue > 0
When executed from a Tablet PC 2005 environment this function always returns true. Windows Vista Premium environments have a different set of requirements when determining Tablet PC capabilities. Windows Vista Premium editions will only return true if a number of preconditions are met:
A digitizer or pen device is installed on the machine
The version of Windows Vista must be licensed for Tablet and Touch features (i.e. a premium version of Vista)
During my development I found something strange. All of the features of my application worked on Windows Vista Ultimate even though the GetSystemMetric call I made returned false. I had forgotten to install my digitizer on my desktop machine. I decided to use this inconsistency to my advantage.
I determined that another mechanism for determining whether or not your computer has Tablet PC features installed is to see if there are any Recognizers installed. Recognizers are the APIs that Tablet PC-enabled operating systems use to turn ink into text. Tablet PC-enabled operating systems include a number of these recognizers.
On my Windows Vista machine, I knew that the Tablet PC features were installed but the GetSystemMetrics function always returned false. I used the Recognizers collection to determine whether my machine was actually tablet-aware.
In the previous section I pointed out that your application would blow up if you ran the code on a machine lacking Tablet PC features (i.e. recognizers). I changed my recognize code to look for any recognizers installed on the machine. Dim recognizers As Recognizers = New Recognizers()
If recognizers.Count > 0 Then
Dim cString As String = _
MessageBox.Show("No recognizers installed")
Note: Standard editions of Windows Vista have a single recognizer installed on them (gesture recognition) so you may want to change the count you test for to > 1.
You can now complete the final requirement of the application requirements listed earlier. The application will determine what recognizers are installed in the operating system. The following code lists the recognizers installed on your Tablet PC. Dim recognizers As Recognizers = New Recognizers()
If recognizers.Count > 0 Then
For Each oReco As Recognizer In recognizers
MessageBox.Show("No recognizers installed")
The last two examples illustrate enabling Tablet PC features even when the operating system returns a value that might not be true.
If you want to make sure that you can take advantage all Table PC features you could use a strict approach and only enable features when the IsTablet() you created earlier, returns true. Otherwise you can use a less stringent check like the one in the prior snippets.