RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Master the Pen Using Ink Controls in Your Tablet Applications

Although you can treat Microsoft's new Tablet PC Ink Data like image data, the Ink controls and objects provide a much wider variety of options for incorporating pen input into your applications. Learn how to persist ink in many formats, depending on your needs.

he primary pointing, selecting, dragging, and input device for Tablet PCs is the pen. All Tablet PC computers have a digitizer beneath the screen that accepts pen input. Ink is a new data type designed for use on the Tablet PC that provides real-time visual feedback for pen-based input. This data type represents both pen strokes and holds metadata about the strokes. An ink-enabled application has the ability to recognize both ink and text. The Tablet PC Pen, Ink, and Reco (recognizer) APIs permit pen entry that is as responsive and natural as writing with traditional ink on paper. Because the existing architecture for Windows mouse messages does not permit this level of responsiveness in the event mechanism, pen movements and actions must be sent directly to applications in real time to create viable Tablet PC ink applications.

You can build applications for Tablet PC that support various levels of functionality for pen, ink, and ink stroke recognition, ranging from recognizing simple text input to creating and editing complex ink. Even if your application itself does not accept ink input directly, it can still receive ink input through the Microsoft Tablet PC Input Panel. See the sidebar Development Environment Required for Tablet PC Development for the hardware and software requirements you'll need.

Available Ink Controls and Objects
Microsoft provides the ink controls and programmatic objects shown in Table 1 for use in applications, documents, or Web services.

InkEdit Capture, recognize, and display ink. A visible control
InkPicture Intended for scenarios in which ink is not recognized as text. A visible control
Ink Collector Collects points from an input device and puts them into an ink object. A transparent object
InkOverlay Primary intended to display ink as ink. A transparent object.

Table 1: Ink controls and programmatic objects available for use in applications, documents, or Web services.

The Tablet PC operating system includes InkEdit, and InkPicture controls as well as the InkCollector and InkOverlay objects. If you need more complex functionality, you can create additional controls inherited from the Managed Library or from the objects in the Microsoft Tablet PC Automation Object Model.

You can quickly generate a simple pen-based user interface with the basic Tablet PC ink controls. By positioning these controls on a form you define a fixed region for pen and ink input. You can embed ink controls in a Microsoft Visual Basic form, a Web page or even a Word document. The controls have properties and methods to retrieve and manipulate the ink and its properties. You can control their appearance programatically. The controls generate events for which you can write custom handlers.

Author Note: Because the .NET versions of the InkPicture and InkEdit controls have not been marked safe for scripting, you should not use them in ASP.NET or HTML pages. If your HTML page requires an ink control, use the ActiveX version by embedding it as an <OBJECT> tag. However, you can't use the ActiveX versions in Active Server Pages. The Microsoft SDK documentation specifies the client machine must have the Tablet PC Platform runtime installed. See Table 2 for the ActiveX ClassID and ProgID values you'll need.

      id=myInkPicture1 style="WIDTH: 500px; HEIGHT: 500px" 

Automation Control ClassIDProdID
InkEdit E5CA59F5-57C4-4DD8-9BD6-1DEEEDD27AF4 InkEd.InkEdit.1
InkPicture 04A1E553-FE36-4FDE-865E-344194E69424 msinkaut.InkPicture.1

Table 2: ActiveX ClassID and ProgID values required to embed Ink controls in HTML pages.

The InkCollector and InkOverlay objects are non-visual programmatic objects designed to capture ink input from the tablet device. The InkCollector object collects input from only one specific window. InkCollectors are inherently assigned to the ink controls however, you can attach an InkCollector to any window.

Suppose you have a standard GroupBox control (System.Windows.Forms.GroupBox) located on a windows form (see Figure 1). You can attach an InkCollector to it by passing its handle to the InkCollector's New method.

   'Create the InkCollector and attach it 
   ' to the GroupBox
   myInkCollector = New InkCollector(gbInkArea.Handle)
   myInkCollector.Enabled = True

After creating, attaching, and enabling the InkCollector, you can employ any Tablet PC device (including the mouse) to lay down ink in real time on the associated window. The InkCollector stores collected ink strokes in an associated Ink object.

Figure 1: The frmInkSave form contains a GroupBox associated with an InkCollector as well as an InkEdit Control.
The InkOverlay object is a superset of the InkCollector that provides editing support. It's a COM or .NET object that displays transparently, and is useful in situations where users are concerned with the size, shape, color, and position of the ink and not with recognition of the ink. It's well suited for annotation and basic scribbling. The InkCollector stores collected data in an Ink object. Ink objects contain collections of other objects such as the Strokes collection, which in turn, contains one or more Stroke objects. A stroke is a set of data captured in a single pen-down, pen-move, and pen-up sequence. You can manipulate Stroke objects with the Ink object's methods and properties. This is useful if you want to apply drawing properties, implement measurement algorithms, selectively delete (such as undo functionality) or extract specific strokes to copy into a new Ink Object.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date