3. ADDING MULTI-TOUCH TO YOUR APPLICATION
Microsoft provides a number of interesting example
programs, all of them complicated and all of them graphics-oriented.
The examples are obviously designed to show off the capabilities of the
Multi-Touch Interface, and they do a very good job of that. However, most organizations don't really need
complex graphics applications — they need a version of Multi-Touch that
works with push buttons and the like. The Multi-Touch example is very
simple. It demonstrates how you add the Multi-Touch Interface to a
business application so that the user can interact with it using the
keyboard, mouse, or the Multi-Touch Interface as desired. The example
is purposely kept simple so that you can modify the code as needed for
your application.
3.1. Obtaining the Multi-Touch Platform Interop Library
As with most things Windows 7, Visual Studio doesn't
provide the support required to access the features. In this case, the
Code Pack won't help you either. Instead, download the Windows 7
Multitouch .NET Interop Sample Library from http://code.msdn.microsoft.com/WindowsTouch. When you open the Win7RC_MT.ZIP file to your root directory, you'll end up with a \Win7RC_MT
folder that contains the source code you need to create the
interoperability (interop) library. These steps will help you create
the interop library used for the example in this chapter.
Open the Windows7.SLN
solution using Visual Studio. Because this is an older solution, you'll
need to convert it for use with Visual Studio 2010. Simply follow the
Visual Studio Conversion Wizard prompts as usual.
Choose Build => Build Solution. The build is going to fail with five errors.
Locate the error RC1004: unexpected end of file found error for Resource.H. Double-click this entry. Visual Studio will open the Resource.H file for you.
Go to the end of the Resource.H file and press Enter to add a linefeed. Save the file and close it.
Locate the \Win7RC_MT\Demo\Multitouch\MutlitouchWPF\mtWPFInertia\Images folder on your system.
Copy
to the folder four JPG images named Pic1.JPG, Pic2.JPG, Pic3.JPG, and
Pic4.JPG. The content of the images doesn't really matter, as long as
you provide JPG files.
Choose Build => Build Solution. The build should succeed this time.
After you're able to build the library, you'll find the Windows7.Multitouch.DLL library in the \Win7RC_MT\Release
folder. This is the library you use to gain access to the Multi-Touch
Platform when working with a Windows Forms application. If you want to
create a Windows Presentation Foundation (WPF) application instead, you
need the Windows7.Multitouch.WPF.DLL library found in the \Win7RC_MT\Mutitouch\Windows7.Multitouch.WPF\bin\Release folder.
3. 2. Configuring the Application
The Multi-Touch example begins with a Windows Forms
application. The application has two push buttons, Test and Quit, that
the user will be able to interact with, using keyboard, mouse, or touch
(assuming the user's system has a touch device). You need to add the
following reference using the Browse tab of the Add Reference dialog
box. (The Multi-Touch interop library appears in the \Win7RC_MT\Release folder, as shown in Figure 1.)
Windows7.Multitouch.DLL
If you decided to create a debug version of the library, then you'll need to look in the \Win7RC_MT\Debug folder instead. You'll also need to add several using statements for this example, as follows:
using Windows7.Multitouch;
using Windows7.Multitouch.Win32Helper;