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.
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.
- The Legacy Support for Panning with Scroll Bars section explains how to ensure that your application behaves as users expect in Windows 7.
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.
- The Improving the Single Finger Panning Experience section explains how to customize the panning experience by handling the WM_GESTURE message.
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.
- The Windows Touch Input section explains how you can interpret the WM_TOUCH message.
- The Detecting and Tracking Multiple Touch Points section demonstrates how to create a simple application that interprets multiple inputs.
- The Manipulations and Inertia section explains how to enable the most flexible approach to Windows Touch.
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.