Stepping Up Windows Mobile Development with Visual Studio 2005
Published: July 19, 2005
By David Goon
David is an Application Development Consultant providing information and best-practice to partners and customers targeting the Windows Mobile platform. Starting his years in Microsoft as a technical troubleshooter, David has traded his assembler debugging skills in the last 5 years for the shinier world of mobile gadgets. Prior to joining Microsoft, David was a software developer with Intel.
On This Page
Introduction
With each new release of the Windows Mobile operating system for Pocket PC and Smartphone devices, users benefit from ever-richer feature sets, improved usability and increased overall power.
As a result, application developers now have a fantastic opportunity to create innovative solutions for both the consumer and the enterprise user. To help do this efficiently, Visual Studio 2005 incorporates many features that make developing for Windows Mobile a breeze. Together with the Windows Mobile 5.0 Software Development Kits, it provides access to the latest, most flexible mobile platforms available today.
This article will attempt to highlight a few of the many great features that make this development suite the tool of choice when targeting Windows Mobile. It will take a look at Visual Studio 2005 features in the following major areas:
1. User Interface Design
2. Application Development and Testing
3. Solution Deployment
By the end of this article, you will have become familiar with the significant new enhancements that Visual Studio 2005 brings to Windows Mobile developers.
Visual Studio 2005 is available today in its Beta 2 form. It is important to note that the information presented in this article is subject to change as the product has not yet been officially released.
User Interface Design
Form Designers
Visual Studio 2005 boasts a What-You-See-Is-What-You-Get designer for both Pocket PC and Smartphone form factors when developing for the .NET Compact Framework. These designers allow the developer to visualize how their screen layouts would look on the device without having to deploy the application to an emulator or a physical device. Better yet, the form designer now allows rotation of the form so that layouts can be tested at various orientations and resolutions within the designer itself!
 Figure 1. Landscape screen on the Forms designer
Porting Forms between Pocket PC and Smartphone
With an application that has been designed for the Pocket PC user interface Visual Studio 2005 radically simplifies the process of adding a Smartphone user interface. Visual Studio 2005 allows both form designers to be viewed side-by-side so that it becomes easier to envision how the user interface would look on each device. To enable this feature, simply right-click on the designer tab and select "New Vertical Group" from the context menu that appears.
 Figure 2. Side-by-side designers
This feature really comes into its own because it allows a developer to easily copy Pocket PC form controls to the Smartphone designer. This is a simple Copy (CTRL+C) and Paste (CTRL+V) operation. Visual Studio 2005 will maintain all the internal properties of the controls that have been copied so populated fields such as list collections will be persisted.
However, not all controls can be supported on both device platforms. For example, button controls typically do not make sense on a Smartphone due to the lack of a touch-screen. Visual Studio 2005 is aware of this and displays a warning symbol and a small button on the offending control. Selecting the button enables the developer to quickly convert such controls to the most sensible equivalents.
In the example screenshot below, Visual Studio 2005 is recommending buttons be changed to menu items that can be accessed via the Smartphone device's soft keys.
 Figure 3. Converting controls to match the target platform
New Controls
Visual Studio 2005 incorporates version 2.0 of the .NET Compact Framework. This updated release of the .NET Framework for devices includes many enhancements. For the developer, a slew of new supported controls have been added to the designer's Toolbox. The following represents a sample few.
DateTimePicker. A control much missed in the original release, the DateTimePicker control, or alternatively the MonthCalendar control, is now part of the palette of controls available for use.
Notification. This Pocket PC-only control provides an easy way to display alert or informational messages to the user. The body of a notification can contain HTML tags which allow a message to be comprised of hyperlinks, graphics and other controls.
WebBrowser. Use this control to enable display and navigation of web pages from within the application. You can also leverage this control to host other web-based controls.
 Figure 4. DateTimePicker and MonthCalendar controls; and the Notification control (Examples running under Windows Mobile 2003)
Application Development and Testing
Integrated native development support
Visual Studio 2005 aims to be the single toolset that a mobile developer needs for Windows Mobile devices. Indeed, it is the single toolset for desktop, server and device programming!
To this end, and for the first time, Visual Studio 2005 includes Visual C++ as a supported language to develop smart device applications. That's right - developers no longer need a separate installation of eMbedded Visual C++ in order to target devices with native code!
Out of the box, Visual Studio 2005 supports development for Windows Mobile 2003 and Windows Mobile 2003 Second Edition Pocket PC and Smartphone devices. With the addition of the Windows Mobile 5.0 SDKs, developers can also target the very latest Windows Mobile release from Microsoft.
Best of all, all projects can live together in the same solution. Consider a development project that has an ASP.NET web service providing the data that is consumed by a desktop Windows Forms client, a .NET Compact Framework-based Smartphone application and a native Windows Mobile Pocket PC executable within a single solution file. This makes managing diverse projects easier since only one tool is needed to work with all of them.
 Figure 5. Solution Explorer with a ASP.NET Web Service, a C++ Pocket PC application, a .NET Compact Framework Smartphone project and a Windows Forms client
Industrial-strength Integrated Development Environment
Visual Studio 2005 comes with all the features expected from a top-of-the-line development environment. The MSDN documentation that comes as part of the Visual Studio 2005 installation features Internet links that will always display the most updated information that is available on MSDN Online. The library can be filtered to only show entries that are relevant to Smart Device programming so that a developer doesn't need to sift through desktop equivalents to find the information needed.
 Figure 6. Filtered documentation
Likewise, helpful IntelliSense prompts and automatic completion of program statements are filtered to only show those entries that are meaningful to the project. In native projects, this is determined by the targeted SDK, while managed applications have their help restricted to what is available within the version of the .NET Compact Framework used.
 Figure 7. Automatic completion drop-down showing only device-related entries
Visual Studio 2005 also includes a full-featured, integrated debugging experience. The debugger has all the functionality that developers expect from any professional toolset. The point to note for device developers is that the Visual Studio 2005 debugger works with devices or device emulators that are remote from the development desktop. Even though the process being debugged is on an entirely separate machine, the debugger still allows features such as source-level step-by-step execution, querying of specific variable values and setting of a variety of breakpoints that work seamlessly across development and target machines.
To boost performance even more, the emulators are now configured to use Direct Memory Access (DMA) rather than the traversing through the IP protocol stack. This removes the protocol overhead and speeds up communications. Additionally, physical devices will be able to take advantage of USB 2.0 support when this becomes available with Windows Mobile 5.0 devices.
New Emulator Technology
One of the biggest challenges in developing applications at the cutting edge is the availability of physical devices that contain the very latest software needed to test against. A developer needs to know if the architecture and design of their killer application is going to work in the real world, even before the devices themselves become available.
Visual Studio 2005 now ships with the Windows Mobile 2003 SDK which comes with an extensive suite of Pocket PC and Smartphone emulators. Additionally, it integrates with the very latest Windows Mobile 5.0 SDK emulators as well. The emulator images are provided to allow testing against different platforms and platforms with different screen configurations. For example, developers can see what their application will look like on a Pocket PC device with a square High-DPI screen!
 Figure 8. Square High-DPI Pocket PC Emulator
A significant change is that the new emulator images are now true ARM instruction set emulators. No longer are projects required to be compiled into x86 instructions for emulation, and then into ARM instructions for real devices. This eliminates any differences that may exist between these two instruction sets. The end-result is a very accurate representation of how your project is going to behave on a real device. This also extends to performance where a 1 GHz desktop CPU would translate to an approximate 200 MHz ARM CPU in the emulator.
This change brings many other benefits. For example, you can now install on the emulator any application that is available on the market if it is a required component for your application to work. A question that might arise might be: How do I get an application cabinet into the emulator so that it can be installed and used?
Using the new Device Emulator Manager emulator instanced can be 'cradled'. When this is done, ActiveSync 4.0 automatically detects the emulator and begins synchronization as if the emulator is a physical device. Beyond synchronizing with your desktop, this enables the Explore feature of ActiveSync to be used to browse and manipulate the emulator's file system and install or remove programs on the device.
 Figure 9. Desktop showing Device Emulator Manager, ActiveSync and a connected Pocket PC emulator
Another useful feature is the ability to share a folder from your development desktop that will appear on the device emulator as a Storage Card. The shared folder can then be used as a simple way of transferring data between the desktop and the device. The shared folder acts exactly like a storage card and will even emulate card insertion, kicking-off the processor-specific 'Autorun' process. This allows application installation testing without the use of a physical device.
 Figure 10. Desktop showing Emulator Properties and the Shared Folder feature, and matching file lists on both device Storage Card and the desktop file system
Remote Tools
One other feature that Visual Studio 2005 brings is a whole suite of remote tools that can be used with both physical devices and cradled emulators. As at Beta 2, some of the tools included are:
1. Remote File Viewer. Explore and transfer files to and from devices.
2. Remote Heap Walker. Investigate memory usage on a device.
3. Remote Process Viewer. List the running processes and their details.
4. Remote Registry Editor. Edit or view device-side registry settings.
Solution Deployment
Once you have completed the development of your application, there still remains the question of generating the installation script. Visual Studio 2005 now includes a separate project template, the Smart Device CAB Project.
With this project, generating an installation cabinet file for either the Pocket PC or the Smartphone is as simple as selecting the projects to include, and the type of files to include from each project. You can include resultant executable or Dynamic Link Library (DLL) files, files marked as 'Content' within a project, localized satellite assemblies, source code and XML documentation.
 Figure 11. Smart Device CAB Project
The CAB project even includes advanced features like creating a shortcut to the application's main executable. With Visual Studio 2005, this is now a matter of selecting the right menu item within the correct folder to generate the needed shortcut that will display on the device's Start Menu.
 Figure 12. Creating a new shortcut
Summary
This has been a whirlwind tour of the much expanded features of Visual Studio 2005. In each area, there are many, many more enhancements and improvements that simplify developing applications for Windows Mobile devices, provide many more powerful tools and ultimately increase developer productivity.
This article has shown some of the features of the new forms designer for devices and the expanded support for controls for both the Pocket PC and Smartphone platforms. Taken together these features allow rapid creation of compelling user interfaces.
Diving into actual code writing and debugging, we have seen that Visual Studio 2005 has become the only toolset needed to develop both native and .NET Compact Framework based solutions.
Extensive support is available to test and debug applications using the integrated source-level debugger and the high-fidelity ARM emulators. Additionally, the remote tools that ship as part of the development environment round off the arsenal of resources that can be brought to bear to create high-quality solutions.
Finally, project deployment is simplified with Visual Studio 2005's inclusion of the Smart Device CAB Project which enables trouble-free creation of cabinet installation files for Windows Mobile devices. These CAB files can then be deployed to devices on flash media, as downloads or at synchronization with a desktop.
With Visual Studio 2005, software development for mobile devices, in terms of tools support, is now a mainstream task, on par with developing desktop or server solutions.
|