July 29 2010




 
Search Blog Entries:



What is this?

Article Details
 
DVDsMobile - A Windows Mobile Application developed from scratch

Introduction

Developing applications for Windows Mobile Devices seems very easy at a first glance. Your first ‘Hello, World’ application will probably take less than five minutes to create, deploy and run on a Windows Mobile Device. However, developing a real world application that can target many different devices, is secure, runs fast and is battery friendly is something else. Even though Windows Mobile Devices are small devices with limited resources, especially compared to modern desktop computers, they are still extremely powerful. To create real powerful applications for these types of devices is probably harder then developing desktop applications. You must learn how to deal with device limitations, User Interface restrictions, battery powered operation, occasional connectivity and many, many more things. This article explains in detail how to develop a Windows Mobile Device Application in Managed Code from scratch. Throughout the article, a complete application is developed and the underlying technology is explained in detail through a number of downloadable videos..

Development Tools

To develop applications for Windows Mobile Devices you can either use Microsoft Visual Studio 2005 or Microsoft Visual Studio 2008. Unfortunately you cannot use the Express SKU’s of these Integrated Development Environments; you need the Professional Edition or better. This article describes how to develop an application that targets both Windows Mobile 6 Standard and Windows Mobile 6 Professional Devices. In order to target these devices you need to download and install the Windows Mobile 6 Software Development Kits (SDK). There are separate downloads for the Windows Mobile 6 Standard SDK and the Windows Mobile 6 Professional SDK. In the accompanying videos to create a complete Windows Mobile Device, the development machine runs Windows Vista Business with SP1, Visual Studio 2008 with SP1 and the Windows Mobile Device Center 6.1. Also, the Windows Mobile 6 Refresh SDK’s are installed as well as Emulator Images for Windows Mobile 6.1 and Localized Emulator Images for Windows Mobile 6.

If you have installed all development tools, you are ready to create your first Windows Mobile 6 application. After installing the Windows Mobile 6 SDKs you can build applications and solutions for a large number of Windows Mobile devices and for generic Windows CE devices as well. The following devices can be targeted using Visual Studio 2008:

• Pocket PC 2003
• Windows CE (non Windows Mobile Devices)
• Windows Mobile 5.0 Pocket PC
• Windows Mobile 5.0 Smartphone
• Windows Mobile 6 Professional
• Windows Mobile 6 Standard

With Visual Studio 2008 you can target two different versions of the .NET Compact Framework, version 2.0 and version 3.5. The .NET Compact Framework is a subset of the full .NET Framework that is used to write managed applications for Smart Devices. Managed applications are applications written in either C# or Visual Basic.NET. For desktop developers there is also an option to develop managed applications in Managed C++, but this is not supported for device developers. An application written in C# or Visual Basic.NET is compiled to Microsoft Intermediate Language (MSIL). The Intermediate Language is platform independent. In order to execute the application on a device, MSIL code has to be compiled into native code that can be understood by the processor on the target platform. MSIL is just-in-time compiled to native code on a per method base when the application executes on a target platform. The actual application runs in a protected environment, the Common Language Runtime. It takes care of Garbage Collection on behalf of the executing application, meaning that developers don’t really need to worry about releasing previously allocated memory when it is no longer in use by the application.

Introducing DVDsMobile

In this article you will learn how to create a complete application, targeting both Windows Mobile 6 Standard and Windows Mobile 6 Professional Devices from scratch. The application maintains a personal DVD collection. It also has functionality to store a wish list, allows easy data entry by making use of a Web Service and uses location awareness to find DVD stores that are close to the user’s current location. All source code for the application will become available for free over time. The application is written in C# and is accompanied by a large number of videos, showing you how to create the application. The videos are available for download throughout this article. Once the application is entirely finished, a downloadable electronic book will also be available, not only describing the application itself but also introducing a number of best programming practices to develop applications for Windows Mobile Devices.

DVDsMobile Video Part 1

In the first video, you will learn how to create an initial Visual Studio 2008 project and target a Windows Mobile 6 Standard Device. The application is localized, although its functionality is very limited. The application contains an empty form and one single menu entry to terminate the application. The default language used for the application is English, but a localized Dutch version is also available. The first DVDsMobile video is available for download.

DVDsMobile Video Part 2

In the second video, you will see how the initial project that targeted a Windows Mobile 6 Standard Device is changed into a type library. An additional project is added to the solution to allow Windows Mobile 6 Professional Devices to run the DVDsMobile application as well. Since there is only going to be one single code base to target both Windows Mobile 6 Standard and Windows Mobile 6 Professional Devices, you will learn how to make use of Form Inheritance to inherit functionality that was already available in the non-touch screen version of the application to be used in the touch screen version of the application. During runtime, the application itself determines the device on which it is running and displays the corresponding UI. The application remains localized; no additional functionality is added yet, besides support to run on a wide range of different devices.

DVDsMobile Video Part 3

In the third video you will learn how to run a Windows Mobile application on different Device Emulators, based upon different Windows Mobile SDKs by cradling them through ActiveSync (Windows XP) or the Windows Mobile Device Center (Windows Vista) using Device Emulator Manager. Cradling Device Emulators is a great way to be able to test applications on a broad range of different devices, even if the application targets different devices. Especially for managed applications, this also shows device independence of the .NET Compact Framework.

DVDsMobile Video Part 4

In video number four you will learn how to create a SQL Server 2005 Express Edition database that will store a collection of DVDs. This database will be used as the central store for DVDsMobile. Even though this video does not cover any Windows Mobile application development, we need this database in the future, because DVDsMobile will have the possibility to synchronize data between Windows Mobile devices and a back-end server.

DVDsMobile Video Part 5

In video number five you will learn how to make use of Synchronization Services for ADO.NET to synchronize data between a server and Windows Mobile clients. You will see how the database that was created in part 4 of this series will be added to the DVDsMobile solution, and that the Synchronization Services for ADO.NET take care of creating the device database. Making use of Sync Services allows you to create a multi-tier solution with great flexibility to synchronize data back and forth between Windows Mobile devices and a server. In order to reproduce the steps that are showed in this video, you need the following products on your development machine:

Of course, the name of your server will be different then the name of the server you see in the video, so in order to get Sync Services for ADO.NET working inside your own solution, you will have to provide the correct server name and optional database credentials.

DVDsMobile Video Part 6

In video number six you will learn how to synchronize data between a Windows Mobile Device and a server, making use of the Synchronization Services for ADO.NET that were introduced in the previous episode of this video series. Besides adding synchronization logic, you will also learn how to use the State & Notification Broker to determine if there is a data connection available on the device so you are able to synchronize data.

DVDsMobile Video Part 7

In video number seven you will learn how to display data that is stored in a local database on the Windows Mobile device in a DataGrid through a SqlCeResultSet. You will learn how to generate a SqlCeResultSet using Visual Studio 2008. You will also learn how to limit the number of columns that are visible through the DataGrid.

DVDsMobile Video Part 8

In video number eight you will learn how to re-synchronize an entire table of a database making use of the Synchronization Services for ADO.NET. This is necessary in those situations where the server is not able to use the synchronization history because clean-up code has been executed on the server prior to synchronize the client data with the server. On the client this will result in a TargetInvocationException which can be solved by resetting the client’s SyncAnchors.

DVDsMobile Video Part 9

In video number nine you will learn how to setup the DataGrid control making use of auto-adjusting columns. It adjusts the width of one of the columns depending on a visible vertical scroll bar and a row header. It also adjust the width of another column, depending on the text displayed in the column header. In order to achieve this, a bit of reflection is used, in combination with measuring the width of strings, accessing the DataGrid's contained scroll bars and making use of the State & Notification Broker to determine the current display orientation mode.

What's next?

In the next part of DVDsMobile you will learn how to create a User Control to easily enter UPC codes, either by touch gestures, by using the stylus or by entering the information on a keyboard. For proper touch gesture support you will also learn how to determine on which type of device the application is running.

 
Back








SpiralFX Web Development
www.spiralfx.com


Do you want to learn developing a full blown Windows Mobile Application? This article and accompanying multimedia content will help you to do so. It will be extended over the upcoming weeks / months, so check back regularly.
 
Read Full Article