Rapid Application Development for Windows Mobile 5

Any update to the operating system used by Pocket PCs and Smartphone is big news, but the latest version—Microsoft Windows Mobile 5.0—comes with a twist: a complete overhaul of the development tools. As hinted at by its support for building applications using the .NET Compact Framework in Visual Studio 2003 .NET, the main development tool for all Windows Mobile-based development is now Visual Studio 2005. Although currently at Beta 2 release, it's still possible to use this powerful IDE to build applications using the Smartphone and Pocket PC SDKs. These tools allow you to develop applications today for the next generation of handheld devices that will be soon hitting the market.

So what's new? As you might expect, there are a large number of new APIs for mobile-device specific features. What you might not have expected are the brand new device emulators included as part of the SDK. These "hardware simulators" emulate the ARM CPU used in Pocket PCs and Smartphones, so it's possible to use the very same binary files on both the emulators and the physical devices. Support for ActiveSync and debugging have also been improved: you can virtually cradle your emulated device to ActiveSync, making debugging many times faster than before.

Even though no hardware based on Windows Mobile 5.0 is on sale at the time of writing, you can be sure it is coming soon. And in the meantime, you can get a very good idea as to how your application will behave on real hardware.

Visual Studio 2005 itself is a huge step up from embedded Visual C++ and embedded Visual Basic. There are many new enhancements to the IDE, such as new data and user interface designers, a faster debugger with new features, a new emulator, refactoring (intelligent source code manipulation tools), and Snippets (plug-in sections of frequently used code) to really speed up development times. And of course, you now have the choice of three development languages: C++, C# and Visual Basic, and a bunch of new libraries (for example, Direct3D, DirectDraw, and MFC 8) and new controls to play with.

But enough of looking at the specs on paper—you'll get a better idea of the improvements by actually building an application. For the rest of this article, I'm going to go step-by-step through an application that fulfills many different Enterprise needs. The application is going to make it easy for the user in the field to take a picture with the built-in camera, and then e-mail that picture to a contact from the address book.

Doing this using C++ with previous generation devices would have been a lengthy process; by contrast this application contains less than 100 lines of C# code. This version is for the Pocket PC, but a version for the Smartphone would use almost all the same source code with only a few tweaks to the user interface.

Visual Studio created the skeleton for the program with its New Project wizards, and after that there are only five steps to the complete application.

Once you have the new project created, you're ready to go.

Step 1. Design the User Interface

One area where Visual Studio 2005 really shines is user interface design. After dragging three buttons and two picturebox controls to the main Windows form, it's all done. To aid with alignment, controls now snap to automatically-appearing guidelines. Controls can also dock and anchor themselves to specific edges of the display, which means if your device is switched from landscape to portrait mode, the controls will automatically re-position and size themselves appropriately.

Creating controls has never been simpler in mobile development: simply drag them onto the form. Visual Studio even helps you line them up.

Step 2. Taking a Photograph