RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Adding Multi-Touch to Your Windows Mobile Application's User Interface : Page 3

What if you could convert your devices to use the kind multi-touch technology you see in an iPhone? It requires modifications to the OS and an overhaul to the entire UI, but it can be done.

Second Example: A Book Selector
Instead of having users select items from a combo-box control, wouldn't it be more intuitive for them to select items visually using their fingers? This next example builds on the concepts discussed in the first. The screen displays a selection of books. To view each title, users simply touch the picture. Users can also rearrange the books by dragging them across the screen (see Figure 8).

Figure 8. The First Example: Selecting, viewing, and rearranging books.
Figure 9. Form2: Adding the two controls to Form2.

Coding the Second Example
To build the second example, add a new form to the project. Add controls to the form, as shown in as shown in Figure 9.

Add the three book cover images into the project (see Figure 10) and set their Copy to Output property as Copy. This will deploy them to the Windows Mobile device.

Figure 10. Adding Images: This will deploy the book cover images to the device.

Switch to the code-behind of Form2 and define the following constants and variables:

Public Class Form2
    '---size of picture---
    Const PIC_WIDTH As Integer = 83
    Const PIC_HEIGHT As Integer = 100

    '---spacing between the two pictures---
    Const SPACING As Integer = 5

    '---stores the path of the executable---
    Dim path As String

    '---arraylist containing all the pictures---
    Dim pictures As New ArrayList

    '---coordinates of the last point touched---
    Dim _prevX As Integer
    Dim _prevY As Integer
In the Form1_Load event handler, create new PictureBox controls to display the images and then wire up each control with the MouseMove and MouseDown event handlers Listing 2).

In this example, each PictureBox control is wired up with the PictureBox_MouseMove and PictureBox_MouseDown event handlers. These two event handlers are defined as shown in Listing 3.

Unlike in the first example, there is no need to service the startup object for the project to Form2 and press F5 to test the application. You can now rearrange the books with your finger! Download the following video how your book selector will work in real-time.

Wei-Meng Lee is a Microsoft MVP and founder of Developer Learning Solutions, a technology company specializing in hands-on training on the latest Microsoft technologies. He is an established developer and trainer specializing in .NET and wireless technologies. Wei-Meng speaks regularly at international conferences and has authored and coauthored numerous books on .NET, XML, and wireless technologies. He writes extensively on topics ranging from .NET to Mac OS X. He is also the author of the .NET Compact Framework Pocket Guide, ASP.NET 2.0: A Developer's Notebook (both from O'Reilly Media, Inc.), and Programming Sudoku (Apress). Here is Wei-Meng's blog.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date