Windows 7 Multitouch Programming Models


Windows 7 Multitouch Programming Models

The Windows 7 multitouch platform enables you to build touch-aware applications. Keep in mind that with time, the amount and types of hardware available for supporting multitouch will increase, more computers will support multitouch, and end users will come to expect applications to respond to touch input. To provide well-rounded Windows multitouch solutions for all kinds of application, Windows 7 has various levels of touch support. There are several scenarios you can use to enhance applications using the features of the Windows multitouch platform. Before you adopt a specific approach, you should consider what you want to do with your application.

The Windows 7 multitouch platform provides several programming models that we describe collectively as the “Good, Better, and Best” model.

The Good Model: Supporting Legacy Applications

Let’s assume you have an existing (legacy) application that has a large install base, but it was not designed to support Windows 7 multitouch. We refer to these applications as legacy applications only in relation to multitouch support. You might ask yourself what the multitouch experience of my users will be when running such an application on a Windows 7 multitouch-enabled computer. You would expect your application to simply behave as it did in previous versions of the Windows operating system as far as handling keyboard and mouse input is concerned. But at the same time, you would also want your application to have some response to multitouch input to satisfy the end user, who is expecting some reaction when using its touch-sensitive capabilities, even if the response is limited to the application’s existing functionality.

The good news is that the Windows 7 multitouch platform provides free, out-of-the-box support for legacy applications that are touch unaware and were not designed to support touch or multitouch that is, out-of-the-box support for a few basic gestures. You can expect basic gestures to work and have the desired effect in your application. Basic gestures include a single-finger click on a menu item or button, single-finger or two-finger panning, twofinger zoom, and flick gestures that were introduced in the Windows Vista era.

You can find a range of existing touch-unaware applications, such as Microsoft Office Word 2007 or Adobe PDF Reader, that surprisingly behave as expected when confronted with single-finger or two-finger panning gestures as well as zoom gestures. All these applications benefit from the Windows 7 multitouch platform and enjoy this free, out-of-the-box touch support.

The Better Model: Enhancing the Touch Experience

The Better model addresses the need to make your application touch aware and provide better touch and multitouch support to your application than the default legacy support that was explained in the previous section. The Better model is focused on adding gestures support, as well as making other behavior and user interface (UI) changes so that applications are more touch friendly and go beyond simple gesture support.

The example we mentioned at the beginning of this article is the touch-optimized taskbar jump lists. In this case, the taskbar is responding to single-finger gestures (flicks) and not multiple-finger gestures (touch), but still we get a touch-optimized experience. In fact the taskbar is not using any Windows 7 multitouch APIs. To trace the origin of the input message, identify it as a touch-re

lated message, and respond accordingly, the taskbar uses the GetMessageExtraInfo function. When your application receives a mouse message (such as WM_LBUTTONDOWN), it might call the Win32 API GetMessageExtraInfo function to evaluate whether the message originated from a pen or a mouse device. The value returned from GetMessageExtraInfo needs to be mask-checked against 0xFFFFFF0 and then compared with 0xFF515700. If the comparison is true, this mouse message was generated by a touch-sensitive device.

However, the most common scenario in the Better model is gesture support. You can use gestures to enhance your application and provide better touch and multitouch support. Applications that respond to gestures directly have full control over how they behave when users are touching the touch-enabled device. For example, Windows 7 ships with a photo viewer, the Windows Photo Viewer. One of the nice things about using the gestures’ APIs, rather than relying on the legacy support that the operating system provides, is that you can get extra information about the performed gesture. In the Photo Viewer application, you can get specific information about the location where the zoom gesture occurred in the image. That is, the zoom gesture contains information about the center point specific X, Y coordinates of the zoom gesture.

Photo Viewer can therefore focus on the center of the gesture; whereas with the legacy support the center of the zoom is, by default, the center of the control. The Windows Photo Viewer application also uses panning and rotation gestures to deliver an excellent overall image-viewing experience with relatively little effort.

With gestures, you can also override the default panning behavior. For example, the default touch scrolling is designed to work in text-centric windows that scroll primarily vertically, such as with Web pages or documents, where dragging horizontally selects text rather than scrolling the page. In most applications, this works just fine. But what if your application needs to support horizontal scrolling? Also, for some applications the default scroll can appear chunky, going too fast or too slow. With gesture support, you can override the default panning behavior and optimize it for your application’s needs.

The Best Model: Experience Optimized for Multitouch

Applications or features that fall into the Best model are designed from the ground up to support multitouch and provide amazing touch experiences. These applications build on top of the Windows touch messages, which are identified as WM_TOUCH. This message type provides raw touch data to the application, and you can consume these messages and handle multiple touch points. Most of the gestures we mentioned earlier are two-finger gestures; however, with WM_TOUCH messages you can receive as many simultaneous touch points as the underlying touch-sensitive hardware supports. Developers can use this to go beyond the core system gestures and build custom gesture support for their applications.

The Windows 7 Multitouch platform also provides a manipulation and inertia processor to help you interpolate the touch messages (that correlate to touch points on the screen) of any number of touch points on an object. Think of the manipulation processor as a black box that receives as input the object that is being touched plus all the related touch messages the result is a simple two-dimensional (2D) affine transform matrix representing the transformation that happened as a result of the finger movement.

For instance, if you were writing a photo-editing application, you could grab two photos at the same time using however many fingers you wanted and rotate, resize, and translate the photos; the manipulation process would provide the changes you need to reflect on the object. Inertia provides a basic physics model for applications that continues the smooth transition of an object even after the user has picked up her fingers from the touch-sensitive device and touch points are no longer detected. This functionality creates a simple transition effect for the object rather than stopping the object on the spot.

Legal Disclaimer

Our website is not responsible for the information contained by this article. Webworldarticles.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.


This article was sent to us by: Ulmer O. at 01282010

Related Articles

1. Use the Pan Gesture to Move an Object
With the pan gesture, you can control the scrolling of content in a scrollable area. Or you can apply the pan gesture to a specific object, moving it in any direction by ...

2. Handling the WM GESTURE Message
To work with gestures, you’ll need to handle the WM_GESTURE messages that are sent to your application. If you are a Win32 programmer, you can check for WM_GESTURE ...

3. How Multitouch Works in Windows 7
New hardware and API elements in the Windows 7 operating system provide applications the ability to receive and handle touch and multitouch input. This capability enables...

4. Organize My Data Libraries in Windows 7
This article details the new functionality offered by Windows 7 Libraries. We’ll review the Windows Explorer changes that promote the new user experience that Libra...

5. Changes Made to Windows Explorer in Windows 7
Changes Made to Windows Explorer in Windows 7 In Windows 7, Libraries address the problem of users’ data being stored all over the PC by allowing users to...

6. Make Your Windows 7 Application Library Aware
Libraries under the Hood Now that we have a better understanding of what libraries represent and how users as well as developers can benefit from them, let&rsqu...

7. Working with the Shell Namespace in Windows 7
Working with the Shell Namespace Before we dive into the Shell Libraries programming model, we need to understand how the Windows Shell works. The Windows Shell...

8. How to copy files in Windows 7 and the move them
Creating Copies of Files and Folders in Windows 7 In Windows 7 when you want to share a file with a friend or if you want to create a backup of a file, the eas...