Choosing the Right Approach to Windows Touch

This section explains the different approaches to Windows Touch that you can use.

You can enhance applications using Windows Touch features in many ways. Before you adopt a method, you should consider what you want to do with your application. The following scenarios are typical for Windows Touch:

  • You want your application to behave the same as in legacy versions of Windows but want Windows Touch messages to behave consistently.
  • You want custom object rotation, translation, panning, or zoom support in your application.
  • You want your application to have fine-grained interpretation of Windows Touch gestures or to interpret multiple touches on an application that is specifically optimized for Windows Touch input.
  • You have an application that uses the RealTimeStylus object and want to enhance it with Windows Touch capabilities.

You want your application to behave as it did in legacy versions of Windows

In Windows 7, applications by default generate messages that enable Windows Touch functionality. For example, pan gestures trigger WM_*SCROLL messages. In addition to pan support, the default WM_GESTURE handler in Windows 7 supports boundary feedback, zoom, and press and tap. Boundary feedback is enabled through legacy support as well. See the Windows Touch Gestures Overview for more information on how gestures map to messages. Developers who want only this basic functionality do not need to directly work with the Windows Touch API.

Note

Custom scroll bar handlers must support the SM_THUMBPOSITION request for WM_VSCROLL messages and must support the SB_LINELEFT request and SB_LINERIGHT request for WM_HSCROLL messages.

You want custom object rotation, translation, panning, or zoom support

If you want limited support for touch but the default behavior that Windows 7 offers is not adequate for your application, you can use gestures to enhance your application. By using gestures, you can interpret the gesture commands by handling the WM_GESTURE message. More information on gestures can be found in the section Windows Touch Gestures. If your application needs support only for high-granularity rotations, improved zooming support, or single-finger panning, gestures is the best approach to take for Windows Touch development. In addition to interpreting the gesture message, you can opt to have support for boundary feedback. For more information on boundary feedback, see the Boundary Feedback section of the Windows Touch Programming Reference. In Windows 7, the command prompt and Internet Explorer take advantage of boundary feedback and gestures.

You want fine-grained gesture interpretation or custom handling of multiple touch points

If you want to have even more specific control of gestures than is offered by the WM_GESTURE message, or you want to interpret multiple gestures on multiple objects, you should use the manipulation processor. The manipulation processor essentially is a superset of gestures. Using the manipulation processor requires that you implement an event sink for manipulations that you feed raw touch data to.

If you want simple object physics in addition to interpreting the gestures, you should use an inertia processor in conjunction with the manipulation processor. The inertia processor works with the manipulation processor by taking velocity values from the manipulation processor upon manipulation completion.

If you want to interpret multiple touch points in your application, you should create a message handler for the WM_TOUCH message.

Important

Windows 11 and newer

Some three- and four-finger touch interactions will no longer work in Windows apps by default.

By default, three- and four-finger touch interactions are now consumed by the system for operations such as switching or minimizing windows and changing virtual desktops. As these interactions are now handled at the system level, your app's functionality could be affected by this change.

To support three- or four-finger interactions within an application, a new user setting has been introduced that specifies whether or not the system handles these interactions:

Bluetooth & devices > Touch > "Three- and four-finger touch gestures"

When set to "On" (default), the system will handle all three- and four-finger interactions (apps will not be able to support them).

When set to "Off", three- and four-finger interactions can be supported by apps (they will not be handled by the system).

If your application must support these interactions, we recommend that you inform users of this setting and provide a link that launches the Settings app to the relevant page (ms-settings:devices-touch). For more details, see Launcher.LaunchUriAsync Method.

You want to enable Windows Touch input to an application that uses the RealTimeStylus

If you want to enable input for multiple contacts on the Tablet PC platform, you must implement a custom RealTimeStylus plug-in that interprets the Windows Touch data. Microsoft introduced the ITablet3 and IRealTimeStylus3 interfaces to enable input from multiple contacts in the RealTimeStylus plug-in. These interfaces simplify extending RealTimeStylus plug-ins to support multiple contact points.

To check whether support for multiple contacts is enabled, call IsMultiTouch. To check the number of supported contacts, call GetMaximumCursors. To enable or disable multiple contact support, call MultiTouchEnabled.

Note

If you don't enable multiple contact points in the RealTimeStylus, you will receive gesture messages such as pan and zoom.

Programming Guide