devxlogo

Cruising the Interstate with Windows Mobile 6 Development

Cruising the Interstate with Windows Mobile 6 Development

n recent years, the mobile application platform has gained a lot of interest among enterprise developers. With so many mobile platforms available, customers aren’t lacking choices. However, at the forefront of a developer’s mind are the various criteria that must be evaluated before deciding which platform to support. These factors are:

  1. Size of device installed base
  2. Ease of development and support for widely known/used programming languages
  3. Ability to run one version of an application on a large number of devices

One of your mobile platform choices is the Microsoft Windows Mobile platform, now in its sixth generation. Today, the Windows Mobile platform is one of the most successful mobile device platforms in the market, with support from many different handset manufacturers (such as HP, Asus, HTC, and even Sony Ericsson and Palm).

This article will walk you through the basics of Windows Mobile, help you write your first application and demonstrate how to test and deploy that application to a real device. If you’ve always wondered how to get started in Windows Mobile development, this article is your highway to advanced Windows Mobile development!

Introduction to Windows Mobile Standard, Classic, and Professional
The Windows Mobile platform defines a device running the Windows CE operating system customized with a standard set of Microsoft-designed user interface shells and applications. Devices that use the Windows Mobile platform include:

  • Pocket PCs
  • Smartphones
  • Portable Media Centers
  • Automobile computing devices

In this article, discussion will be restricted to the first two categories of devices?Pocket PCs and Smartphones.

The latest version of the Windows Mobile platform is Windows Mobile 6. With this new release, there are some new naming conventions. Table 1 shows the list of names used by Microsoft over the years.

Table 1. Names for the various Windows Mobile platforms.

Pocket PCs

Smartphones

Pocket PC 2000/ Pocket PC 2000 Phone Edition

 

Pocket PC 2002/ Pocket PC 2002 Phone Edition

Smartphone 2002

Windows Mobile 2003 for Pocket PC/

Windows Mobile 2003 for Pocket PC Phone Edition

Windows Mobile 2003 for Smartphone

Windows Mobile 2003 SE (Second Edition) for Pocket PC/

Windows Mobile 2003 SE (Second Edition) for Pocket PC Phone Edition

Windows Mobile 2003 SE for Smartphone

Windows Mobile 5.0 for Pocket PC/

Windows Mobile 5.0 for Pocket PC Phone Edition

Windows Mobile 5.0 for Smartphone

Windows Mobile 6 Classic/

Windows Mobile 6 Professional

Windows Mobile 6 Standard

Starting with Windows Mobile 6, Microsoft defines a device with a touch screen but without phone capability as a Windows Mobile 6 Classic device (previously known as Pocket PC or Windows Mobile). Figure 1 shows a Windows Mobile 6 Classic device (the iPaq 211).


Figure 1. Classic: The image shows the iPaq 211.
 
Figure 2. Professional: The image shows the HTC Touch Cruise.
 
Figure 3. Standard: The image shows the Moto Q9h.

Touch-screen devices with phone functionality are now known as Windows Mobile 6 Professional (previously known as Windows Mobile Phone Edition). Figure 2 shows a Windows Mobile 6 Professional device (the HTC Touch Cruise).

Devices that do not support touch-screens are now known as Windows Mobile 6 Standard (previously known as Smartphones). Figure 3 shows a Windows Mobile 6 Standard device (the Moto Q9h).

Developing Your Application
The easiest way to start developing for the Windows Mobile platform is to use Microsoft .NET Compact Framework (henceforth referred to as the .NET CF). .NET CF is a scaled-down version of the .NET Framework and is designed to work on Windows CE-based devices (in turn, Windows CE is a scaled-down version of the Windows OS, supporting a subset of the Win32 APIs). .NET CF contains a subset of the class libraries available on the desktop version of .NET Framework and includes a few new libraries designed specifically to work on mobile devices.

At the time of writing, the latest version of .NET CF is version 3.5. Table 2 shows the various version names of .NET CF and their corresponding version numbers.

Table 2. Versions of .NET CF (table adapted from Wikipedia)

Version Name

Version Number

1.0 RTM

1.0.2268.0

1.0 SP1

1.0.3111.0

1.0 SP2

1.0.3316.0

1.0 SP3

1.0.4292.0

2.0 RTM

2.0.5238.0

2.0 SP1

2.0.6129.0

2.0 SP2

2.0.7045.0

3.5 Beta 1

3.5.7066.0

3.5 Beta 2

3.5.7121.0

3.5 RTM

3.5.7283.0

As a developer, you can use either the C# or VB.NET language to write applications for the Windows Mobile platform. All the functionalities required by your applications can be satisfied by:

Figure 4. .NET CF Versions: The versions of the .NET CF installed on an device/emulator.
  • The class libraries in .NET CF, and/or
  • APIs at the OS level via Platform Invoke (P/Invoke), and/or
  • Alternative third-party class libraries, such as the OpenNetCF’s Smart Device Extension (SDE).

You can determine the versions of .NET Compact Framework currently installed on your Windows Mobile device by going to Start?>File Explorer and launching the cgacutil.exe utility located in Windows.

Figure 4 shows the version of .NET CF installed on a Windows Mobile emulator (more on this later).

Windows Mobile 5.0 devices come with .NET CF 1.0 preinstalled in ROM, while the newer Windows Mobile 6 devices come with .NET CF 2.0 preinstalled in ROM. If your application uses the newer .NET CF v3.5, you’ll need to install it on the device before the application can execute.

Obtaining the Different SDKs and Tools
To develop Windows Mobile applications using .NET CF, you need to download the SDK for each platform. Here are some of the SDKs you’ll need:

The best way to develop Windows Mobile applications using .NET CF is to use the Visual Studio IDE. Use one of the following versions:

  • Visual Studio 2005 Professional or above
  • Visual Studio 2008 Professional or above

If you’re using Visual Studio 2005, you need to download the Windows Mobile 5.0 SDK for Pocket PC and Smartphone (as described above). If you’re using Visual Studio 2008, the Windows Mobile 5.0 SDKs for Pocket PC and Smartphone are already installed by default. For both versions, you’ll need to download the Windows Mobile 6 SDKs to develop applications for Windows Mobile 6 devices.

Figure 5. Design Environment: The important sections in Visual Studio 2008.

With the relevant SDKs installed, the first step is to launch Visual studio 2008 and create a new project. Select the Smart Device project type and then select the Smart Device Project template. Name the project WindowsMobileApp.

In the dialog that pops up, you will be able to select the target platform as well as the version of .NET CF you want to use. Select the Windows Mobile 6 Professional SDK and .NET Compact Framework Version 3.5 and click OK.

Figure 5 shows the various windows in Visual Studio 2008 that make up the Visual Studio 2008 development environment. The four important sections are:

  • The Toolbox, which contains all the controls available for use in your Windows Mobile applications.
  • The design window of your application. This is the place where you drag and drop controls from the Toolbox.
  • The Solution Explorer where all the files and resources of your project are organized.
  • The Properties window where you can change the properties of individual controls/Windows forms.

Drag-and-Drop: Building the User Interface
Building a Windows Mobile application’s UI is straightforward?simply drag-and-drop the controls you want from the Toolbox. Figure 6 shows three controls (Label, TextBox, and Button) dragged and dropped onto Form1‘s design view. To change the look of each control (such as change its text, size, color, etc.), select the control and change its properties in the Properties window.

Figure 6. Form1: Populating a Windows form with controls.

Coding
With the UI built, you can switch to the code-behind of Form1 and write the code to wire up all the various controls on the form. In WindowsMobileApp, double-click on the Button control to handle its Click event so that when the user clicks on the button it will display the user’s name.

Code the Click event of the Button control as shown in Listing 1.

Once the coding is done, you’re ready to test the application. To test Windows Mobile applications, you have two choices:

  • Using the emulators provided by the SDKs
  • Using a real device

Testing Using Emulators
The SDKs for the various platforms include various emulators for you to test your Windows Mobile applications without needing to use a real device. For example, if your project is targeting the Windows Mobile 6 platform, you would see a list of emulators available for your testing (see Figure 7).


Figure 7. Emulators: The list of emulators available for your testing.
 
Figure 8. Testing: You can test the application on an emulator.

Once you have selected an emulator to use, press F5 to deploy the application onto the emulator for testing (see “Figure 8).

Testing Using Real Devices
While most testing can be performed on the emulators, there are situations where you really need an actual device to fully test your application. For example, suppose your application uses infrared communication?you’ll need access to a device with that capability.

Testing your Windows Mobile application on real devices could not be easier. All you need is to:

  • Download and install ActiveSync (or Windows Mobile Device Manager for Windows Vista).
  • Connect your device to your development machine.
  • Select Windows Mobile 6 Professional Device in Visual Studio 2008.
  • Press F5 and the application will now be deployed to the device.

Deploying Your Applications
Once the debugging process is over, you need to package the application nicely so that users can install it on their devices. An easy way to package your Windows Mobile application is to create a CAB file so that you can transfer it onto the end user’s device (using emails, a web browser, a memory card, and so on).

To start, add a new project to the current solution in Visual Studio 2008 (see Figure 9).


Figure 9. Deployment: Adding a new project to the current solution.
 
Figure 10. Drag and Drop: Moving the WindowMobileApp shortcut to the Start Menu Folder.

Select the Smart Device CAB Project template.

In the File System tab, right-click on Application Folder and select Add?>Project Output.

Select the WindowsMobileApp project and click OK. Then, right-click on the output item shown on the right-side of the File System tab and create a shortcut to it. Name the shortcut WindowsMobileApp. Right-click on the File System on the Target Machine item and select Add Special Folder?>Start Menu Folder.

Drag and drop the WindowsMobileApp shortcut onto the newly added Start Menu Folder (see Figure 10).

Right-click on the SmartDeviceCab1 project name in Solution Explorer and select Properties. Change the Configuration from Debug to Release. Name the output file ReleaseWindowsMobileApp.cab.

In Visual Studio 2008, change the configuration from Debug to Release (see Figure 11).


Figure 11. Configuration: Changing the project configuration from Debug to Release.
 
Figure 12. Your Application: The CAB file containing the application.

That’s it! Right-click on the SmartDeviceCab1 project name in Solution Explorer and select Build. You will now be able to find the CAB file located in the Release folder of the SmartDeviceCab1 project (see Figure 12).

You can now distribute the CAB file to your customers using the various media, such as FTP, web hosting, email, and so on. When the end user taps on the CAB file in File Explorer (on the device), the application will ask if s/he wants to install the application onto the device or onto the storage card (see Figure 13).


Figure 13. Download: Asking for a location in which to store the application.
 
Figure 14. Start: The installed application can be found and launched from the Start menu.

A Windows Mobile Foundation
There you have the bare-bones basics of Windows Mobile development and how to use Visual Studio 2008 to create a Windows Mobile application with .NET Compact Framework. Though this article didn’t cover .NET CF’s class libraries, it does cover the steps that you need follow in order to develop an application from start till the end, right through to deployment.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist