Rediger

Del via


Ink Controls

The Tablet PC platform provides two controls, InkEdit and InkPicture, which enable you to easily add ink and handwriting recognition to Tablet PC applications. The InkEdit control has managed, ActiveX , and Win32 versions, while InkPicture has only the managed InkPicture and ActiveX versions.

The key difference between the controls is in how data is saved. The InkEdit control saves ink as text by default, while InkPicture saves ink as ink.

The InkEdit control is intended for text entry through handwriting recognition. InkPicture is intended for annotation (for example, marking up a presentation slide or other picture).

In managed code, create ink controls in the same thread as the main thread for the form. If an InkEdit or InkPicture control is created in a different thread, then your application may not respond properly.

You should explicitly change the threading model to single-thread apartment (STA) before creating an ink control. This causes the control to be created on the main thread. You can use the following Managed C++ code to explicitly set the threading model.

Thread::get_CurrentThread()->set_ApartmentState(ApartmentState::STA);

You can use the following code to do the same thing in C#.

System.Threading.Thread.CurrentThread.ApartmentState = System.Threading.ApartmentState.STA;

In managed code, to avoid a memory leak you must explicitly call the Dispose method on any Tablet PC control to which an event handler has been attached before the control goes out of scope.

The following sections describe ink controls and the use of ink controls in applications: