Developer Enhancements to
Windows Touch and Tablet PC
October 12, 2010
Abstract
This paper provides guidelines for developers to understand the new Windows®
Touch and Tablet PC developer enhancements to the Windows family of operating
systems.
This information applies for the following operating systems:
Windows 7
Windows Server® 2008 R2
References and resources discussed here are listed at the end of this paper.
For the latest information, see:
http://www.microsoft.com/whdc/device/input/touch_tab_enhance.mspx
Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including
URL and other Internet Web site references, may change without notice. You bear the risk of using it.
This document does not provide you with any legal rights to any intellectual property in any Microsoft
product. You may copy and use this document for your internal, reference purposes. You may modify this
document for your internal, reference purposes.
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 2
Document History
Date
October 12, 2010
December 18, 2008
November 5, 2008
Change
Added reference links for math input control.
Originally titled “Developer Enhancements to Windows for Touch and
Tablet.”
Clarified that the Math Input Control does not ship in Windows
Server 2008 R2.
First publication
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 3
Contents
Introduction ................................................................................................................... 4
The Math Input Control.................................................................................................. 4
Creating the Math Input Control ............................................................................... 5
Include Headers and Libraries for the Math Input Control ................................... 5
Declare and Initialize the Control Pointer ............................................................. 6
Show the Control ................................................................................................... 6
Customizing the Math Input Control ......................................................................... 7
Changing the Displayed Buttons ........................................................................... 7
Changing the Control Caption ............................................................................... 8
Changing the Control's Preview-Area Size ............................................................ 8
Multitouch for Windows 7 ............................................................................................. 9
Creating Custom Dictionaries for Handwriting Recognition ........................................ 10
Compiling a Word List .............................................................................................. 10
Explanation of Options ........................................................................................ 10
Defaults................................................................................................................ 11
Examples .............................................................................................................. 12
Installing a Compiled Custom Dictionary ................................................................. 12
Running HwrReg.exe in Check/Install Mode ....................................................... 12
Running HwrReg.exe in List/Remove Mode ........................................................ 13
General Notes on Custom Dictionaries.................................................................... 14
Server-Side Recognition ............................................................................................... 14
Resources ..................................................................................................................... 15
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 4
Introduction
The Windows® 7 operating system operating system introduces additional language
support, the math input control, custom dictionaries, and multitouch support to
Windows operating systems. Windows Server® 2008 R2 introduces support for
additional languages, custom dictionaries, and server-side recognition. These features
enhance Tablet PC functionality and let developers deliver new applications that
support practical scenarios for end users:

The math input control allows input of math formulas and functions from
handwritten text in Windows 7.

To improve text recognition, Windows 7 and Windows Server 2008 R2 support
custom dictionaries, so that administrators can directly enable support for word
lists.

Multitouch supports input from multiple touch sources through new window
messages, plus a gesture-recognition API that supports panning, zooming, and
rotating.
Windows Server 2008 R2 supports server-side recognition of form input, and custom
dictionaries for server-side recognition. With the addition of these features,
developers and administrators can create and customize powerful applications that
support handwriting recognition from the server side.
The Math Input Control
The Windows 7 operating system supports math input from the math input panel
(MIP), the new math-specific equivalent of the text input panel. Note that Windows
Server 2008 R2 does not include support for the math input panel or math input
control. Many applications—even legacy applications—can take advantage of the MIP
without modification, because users can directly trigger this input application from
Windows 7. The following image illustrates one scenario of usage for the math input
control, in which a user takes notes, inks them into a pen-enabled document, and
then copies them into another application as symbolic input.
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 5
The math input control lets developers integrate the functionality of the MIP much
more directly within their applications. Compared to data input with traditional
methods—such as browsing through symbol menus or memorizing keyboard
shortcuts—entering data by using the math input control is much more intuitive and
natural. Because the math input control is well integrated into applications, users
should notice the improved experience.
Developing applications that take advantage of the math input control is very easy in
Windows 7. This section gives a few examples of typical tasks that Windows 7
developers may want to perform when they integrate the math input control into
their applications.
For more information about the math input control, see the Resources section at the
end of this paper.
Creating the Math Input Control
In this section, you will learn how to create the math input control from application
code. This creation procedure is typically performed when the programmer expects a
user to enter formulaic data.
To create the math input control
1. Include the headers and libraries for the math input control.
2. Declare and initialize the control pointer.
3. Show the control.
Include Headers and Libraries for the Math Input Control
Place the following at the top of code that uses the math input control:
// includes for implementation
#include "micaut.h"
#include "micaut_i.c"
This code adds support for the math input control to your application.
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 6
Declare and Initialize the Control Pointer
After you have included the headers for your control, you can declare the control
pointer and initialize it with a call to the CoInitialize function. This call creates a
handle to the math input control interface. The following code can be placed in a
class or as a global variable in your application's implementation:
CComPtr<IMathInputControl> g_spMIC; // Math Input Control
The following code shows how to call CoInitialize on the control pointer:
HRESULT hr = CoInitialize(NULL);
hr = g_spMIC.CoCreateInstance(CLSID_MathInputControl);
After calling CoInitialize on the control pointer, you have a reference to the control
and can access the control's methods. For example, you could enable the extended
set of controls as shown in the following code:
hr = g_spMIC->EnableExtendedButtons(VARIANT_TRUE);
Show the Control
The control does not automatically appear after you create it. To show the control,
call the Show method on the control reference that you created in the previous step.
The following code demonstrates how the Show method can be called:
hr = g_spMIC->Show();
After the control shows, it looks something like the following image.
Note that the extended set of buttons is enabled, so that Redo and Undo are
available. They appear dimmed in this image because the user has not yet done
anything to undo or redo.
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 7
Customizing the Math Input Control
This section explains three ways of customizing the math input control's appearance
to better suit your application:

Changing the displayed buttons.

Changing the control caption.

Changing the control's preview-area size.
Changing the Displayed Buttons
You can change the buttons that are displayed on the math input control so that the
control has extended functionality or appears smaller on the screen. Enabling the
extended button set shows the Redo and Undo buttons. The following code shows
how to enable the extended button set:
void CMath_Input_Control_testDlg::OnBnClickedToggleBtns()
{
static bool enabled = true;
HRESULT hr = S_OK;
hr = g_spMIC->Hide();
if(!enabled){
if (SUCCEEDED(hr)){
hr = g_spMIC->EnableExtendedButtons(VARIANT_TRUE);
enabled = true;
}
}else{
if (SUCCEEDED(hr)){
hr = g_spMIC->EnableExtendedButtons(VARIANT_FALSE);
enabled = false;
}
}
if (SUCCEEDED(hr)){
hr = g_spMIC->Show();
}
}
The following images show the control with the extended set of buttons (on the left)
and without the extended set of buttons (on the right). (The different color schemes
occur because the screen shots are from two different computers.)
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Changing the Control Caption
You can change the control caption for the math input control, to set the caption on
the math input control's window. The following code shows how to set the caption:
void CMath_Input_Control_testDlg::OnBnClickedSetCaption()
{
g_spMIC->Hide();
CComBSTR cap1(L"Some Caption Text");
g_spMIC->SetCaptionText((BSTR)cap1);
g_spMIC->Show();
}
The following image shows the control after the caption has been set.
Changing the Control's Preview-Area Size
You can customize the math input control so that the control explicitly sets its
preview-area size. This creates a larger area in which the math formulas appear. The
following code shows how to set the preview-area size:
void CMath_Input_Control_testDlg::OnBnClickedSetPreviewAreaSize()
{
LONG height = 200;
HRESULT hr = S_OK;
hr = g_spMIC->SetPreviewHeight(height);
}
Developer Enhancements to Windows Touch and Tablet PC - 9
The following images show a control with differently sized preview areas.
Multitouch for Windows 7
New hardware and API elements in the Windows 7 operating system allow
applications to receive multitouch input. This ability lets an application detect and
respond to multiple simultaneous touch points on the application’s visible surface.
Functionality for this feature in Windows 7 is provided by a new set of dedicated
window messages that report touch-down, touch-up, and touch-move actions. The
new messages report the action and position of touch points, with unique
identification of simultaneous touch points.
The messages are generated by pen or touch raw-input processing, which is currently
performed by the Tablet platform's Windows Ink Service Platform Tablet Input
Subsystem (WISPTIS) process and which is delivered to a target application.
In addition to the new input messages, multitouch gesture messages are added to the
existing list of window messages. Messaging support for multitouch and multitouch
gestures functions through new window messages. Those messages are sent or
posted by the Tablet WISPTIS process to appropriate application windows when user
input is recognized as a gesture. Dedicated API functions encapsulate the details for
creation and consumption of these messages. This is done so that the information
that is associated with the message can change in the future without requiring
developers to update applications that already consume this message.
By applying the new multitouch functionality available in Windows 7, developers can
create applications that we see falling into three tiers of specialization:

Applications in the first tier have no optimized support for multitouch. These
applications use generic handlers for gesture input and translate those messages
into window automation.

Applications in the second tier have some optimization for specific messages. For
example, these applications use the center point of a pinch or zoom gesture,
rather than zoom directly to the center of a picture.
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 10

Applications in the third tier are full multitouch applications. These applications
are designed specifically for use only on multitouch hardware; for example, a
multitouch game where multitouch gestures and multiple input points are used
to manipulate objects on screen.
The Windows 7 Software Development Kit (SDK) includes documentation with more
information about this new functionality.
Creating Custom Dictionaries for Handwriting Recognition
In the Windows 7 and Windows Server® 2008 R2 operating systems, the accuracy of
handwriting recognition can be significantly improved through the use of custom
dictionaries. These dictionaries supplement or replace system dictionaries that are
used for handwriting.
Note that custom dictionaries can be installed for a language only if the handwriting
recognizer for that language is installed.
There are two basic steps to setting up a custom dictionary for handwriting:

Compile a word list. The compilation creates a compiled custom-dictionary
(.hwrdict) file.

Install the compiled custom dictionary.
Compiling a Word List
The word list to be compiled must be in plain-text format and should be saved by
using a Unicode encoding. Other encodings do not work. Each line of the text file is
considered a single entry in the dictionary. Multiword units—entries that contain one
or more spaces—are allowed. Spaces at the beginning or end of a line are ignored.
A custom dictionary is compiled from a command line. To compile a dictionary, open
a command window, navigate to the folder that contains the word list, and then run
HwrComp.exe with the desired command-line options.
The following shows the usage syntax for the command-line options:
Usage: hwrcomp
[-lang <localename>] [-type <type>]
[-comment <comment>]
[-o <dictfile.hwrdict>]
<inputfile>
Explanation of Options
-lang <localename>
The specified locale name is assigned to the compiled custom-dictionary file. The
argument <localename> has the form language-REGION. An example of this is
en-US, which signifies the English language in the United States region. You can
find examples of this form in “Locale Identifier Constants and Strings” on the
MSDN Web site.
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 11
-type <type>
The option argument <type> is a single-string concatenation of the resource's
use—as either the main word list (PRIMARY) or as a supplement to the main
word list (SECONDARY)—followed by the actual word-list name to which the
resource is applied (such as DICTIONARY or SURNAME).
The following are possible type values:



















PRIMARY-CITYNAME-LIST
PRIMARY-COUNTRYNAME-LIST
PRIMARY-COUNTRYSHORTNAME-LIST
PRIMARY-DICTIONARY
PRIMARY-GIVENNAME-LIST
PRIMARY-STATEORPROVINCE-LIST
PRIMARY-STREETNAME-LIST
PRIMARY-SURNAME-LIST
SECONDARY-CITYNAME-LIST
SECONDARY-COUNTRYNAME-LIST
SECONDARY-COUNTRYSHORTNAME-LIST
SECONDARY-DICTIONARY
SECONDARY-EMAILSMTP-LIST
SECONDARY-EMAILUSERNAME-LIST
SECONDARY-GIVENNAME-LIST
SECONDARY-STATEORPROVINCE-LIST
SECONDARY-STREETNAME-LIST
SECONDARY-SURNAME-LIST
SECONDARY-URL-LIST
If a type value starts with the prefix PRIMARY, the compiled dictionary, once
installed, replaces the system dictionary. The value PRIMARY-DICTIONARY
represents the main system dictionary for the given language. Note that replacing
a system dictionary does nothing to the original system-dictionary content,
because the replacement is in effect only until the custom dictionary has been
removed.
If a type value starts with the prefix SECONDARY, the compiled dictionary
supplements the system dictionary without replacing it.
-comment
<comment>
The specified comment is compiled into the dictionary file. The comment must be
a single string and no longer than 64 characters.
-o <dictfile.hwrdict>
Output is written to the file name that is specified by <dictfile.hwrdict>.
If this option is missing, the output file name is derived from the original input file
name, with the input-file extension replaced by .hwrdict.
Defaults
If no parameters are specified, the following are the default option values:
-lang <current input language> -type SECONDARY-DICTIONARY
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 12
Examples
The following compiles the input file Mylist1.txt, applies the default option values,
and creates the output file Mylist1.hwrdict:
hwrcomp mylist1.txt
In contrast, the following compiles Mylist1.txt into Myrsrc1.hwrdict, but assigns
“English (US)” (en-US) as the language and SECONDARY-DICTIONARY as the type:
hwrcomp –lang en-US –type SECONDARY-DICTIONARY –o myrsrc1 mylist1.txt
Installing a Compiled Custom Dictionary
HwrComp.exe creates an .hwrdict file, which is in a binary format that is usable by a
handwriting recognizer. This file can be installed on any computer that is running
Windows 7 or Windows Server 2008 R2 and supports handwriting recognition. A
dictionary is installed either for just the current user or for all users on a machine.
A compiled custom-dictionary file can be installed from the command line by using
the HwrReg.exe tool. This tool is useful if you want to override configuration values
that either are compiled into the file or are the default values. There are two ways to
run HwrReg.exe: in check/install mode and in list/remove mode.
Running HwrReg.exe in Check/Install Mode
This mode is for custom dictionary files that have not yet been installed. The
following shows the usage syntax for the command-line options:
Usage: hwrreg
[-check]
[-lang <localename>]
[-scope {all|me}]
[-noprompt]
<dictfile.hwrdict>
Explanation of Options
-check
The dictionary file is verified without being installed. The –check option displays
the file’s comment, plus the registration information that is used to install the
file. This option is useful for verifying registration information before the
installation is performed.
If this option is missing, HwrReg.exe installs the custom dictionary.
-lang <localename>
The specified locale name is applied to the custom dictionary. This effectively
ignores the locale name specified during compilation with HwrComp.exe. The
argument <localename> has the form language-REGION. You can find examples
of this form in “Locale Identifier Constants and Strings” on the MSDN Web site.
If this option is missing, the language that is specified during compilation is used.
-scope {all|me}
The custom dictionary is installed either for all users (–scope all) or for just the
current user (-scope me). Installing with –scope all requires the command to be
run in an elevated command prompt; otherwise, an error code is returned.
If this option is missing, the installation is scoped to just the current user.
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 13
-noprompt
HwrReg.exe does not prompt for confirmation. This can be useful when running
hwrReg.exe from a script.
Example
The following example installs the custom dictionary Myrsrc1.hwrdict for language
“Danish (Denmark)” (da-DK), with the default scope of just the current user:
hwrreg –lang da-DK myrsrc1.hwrdict
Running HwrReg.exe in List/Remove Mode
This mode either lists or removes installed custom dictionaries. The following code
shows the usage syntax for the command-line options:
Usage: hwrreg
[-lang <localename>]
[-scope {all|me}]
[-type <type>]
-list | -remove
Explanation of Options
-lang <localename>
The dictionaries that are registered for only this locale name are listed or
removed. The argument <localename> has the form language-REGION. You can
find examples of this form, in “Locale Identifier Constants and Strings” on the
MSDN Web site.
If this option is missing, dictionaries for all languages are listed or removed.
-scope {all|me}
Dictionaries are listed or removed either for all users (-scope all) or for just the
current user (-scope me). Running with –scope all requires the command to be
run in an elevated command prompt; otherwise, an error code is returned.
If this option is missing, the listing or removal is scoped to just the current user.
-type <type>
This option lists or removes only dictionaries that are registered with the
specified type.
If this option is missing, all dictionaries type are listed or removed.
-list
This option lists all installed dictionaries that match the other options.
If this option is missing, the option –remove must be specified.
-remove
This option prompts for removal of any dictionary that matches the other
options.
If this option is missing, the option –list must be specified.
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 14
Examples
The following code lists dictionaries that have language ”English (US)” (en-US) and
type PRIMARY-DICTIONARY and that are installed for just the current user:
hwrreg –list –lang en-US –type PRIMARY-DICTIONARY
Similarly, the following code removes dictionaries that match the same criteria:
hwrreg –remove –lang en-US –type PRIMARY-DICTIONARY
General Notes on Custom Dictionaries

If you install two custom dictionaries that have the same type, language, and
scope, the second installation overwrites the first.

If you install two custom dictionaries that have the same type and language, but
with different scopes—one for all users, and one for the current user—the
dictionary installed for the current user take precedence and the dictionary
installed for all users is ignored.

The only way to specify a non-default type is at compilation time by using the
HwrComp.exe program.

Only files that are compiled by using HwrComp.exe should be registered. Forcing
registration of any other file may disable or otherwise disrupt handwriting
recognition.

The type that corresponds to the main system dictionary (PRIMARYDICTIONARY) comprises several other types. Installing a custom dictionary of
another type (such as PRIMARY-COUNTRYNAME-LIST) affects handwriting
recognition in all contexts.

Custom dictionaries in Windows 7 and Windows Server 2008 R2 are incompatible
with the approach to customization that is outlined in “Creating Portable
Encoded Custom Dictionaries That Improve Handwriting Recognition Results” on
the MSDN Web site. If you have used that approach, we strongly encourage you
to reinstall your word list as a custom dictionary for Windows 7 or Windows
Server 2008 R2.

Custom dictionaries in Windows Server 2008 R2 can be installed only for all
machine (-scope all).
Server-Side Recognition
The Windows Server 2008 R2 operating system supports server-side recognition.
Server-side recognition lets a server recognize content that is typed into a Microsoft®
Silverlight™ form. This is particularly useful when users on a network specify terms
that are interpreted by using a custom dictionary. For example, if you had a medical
application that queried a server database for patient names, those names could be
added to another database that would be cross-referenced when you perform
searches from a handwritten Silverlight form.
Windows Server 2008 R2 includes an example application, SilverLiveSearch, to
demonstrate server-side recognition.
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.
Developer Enhancements to Windows Touch and Tablet PC - 15
Resources
MSDN Web site
Locale Identifier Constants and Strings
http://go.microsoft.com/fwlink/?LinkId=129137
Creating Portable Encoded Custom Dictionaries That Improve Handwriting
Recognition Results
http://go.microsoft.com/fwlink/?LinkId=129140
Programming the Math Input Control
http://msdn.microsoft.com/en-us/library/dd317324(VS.85).aspx
Math Input Control Reference Documentation
http://msdn.microsoft.com/en-us/library/dd317311(VS.85).aspx
October 12, 2010
© 2010 Microsoft Corporation. All rights reserved.