Developing Pocket PC Applications using Visual Studio.NET 2003
This article first tries to eliminate some confusion between different types of Windows Mobile devices, then explains how to develop simple Pocket PC solutions using Visual Studio.NET 2003 and Pocket PC 2003 emulators (without any physically available Pocket PC in hand).
A downloadable file for this article is available here.
What are Windows CE and Windows Mobile?
Windows CE is an operating system that has a look and feel similar to Windows 95/98. It includes scaled down versions of Excel, Word, Internet Explorer and Schedule. It also has support for Internet access, email, and so on.
Windows CE is a small embedded (can run from ROM) operating system. It supports many of the same APIs as larger versions of Windows 9x/ME/2000/XP/2003. The programs for Windows CE are completely different from DOS or Windows applications. Windows CE is also a true multitasking and multithreaded operating system.
Windows CE is a customizable, embedded operating system for a variety of small-footprint devices. OEMs can use Windows CE to design platforms and customize applications to maximize the user experience for devices such as handhelds, thin clients, logic controllers, and advanced consumer electronics.
Windows Mobile is a complete software platform built on Windows CE. Unlike Windows CE, the Windows Mobile for Smart phone or Pocket PC operating systems is specifically designed for devices that require a specialized hardware configuration. The software includes standardized interfaces and applications that ensure compatibility across hardware designs.
A Windows Mobile powered device is a handheld device powered by the Windows Mobile platform. It allows you to retrieve email, keep track of your schedule and your contacts, browse the Internet, send and receive text messages, read and compose Microsoft Word Mobile files, make Microsoft Excel Mobile charts, and view Microsoft PowerPoint presentations.
The Pocket PC runs Windows CE as its core operating system. Pocket PCs come with mobile versions of Office applications in addition to Microsoft Outlook Mobile. Though there are different Pocket PCs, many come with Wi-Fi to enable you to connect to the Internet when you are in a wireless hotspot. You can compose email messages and send them by synchronizing with your desktop computer or wirelessly when you’re in a hotspot.
Pocket PC Phone is a bit different from ordinary Pocket PC. You can do everything with a Pocket PC Phone that you can do with a Pocket PC, but with the addition of wireless access to the Internet and cellular phone capabilities. If you have a Pocket PC Phone, you can access the Internet through your wireless connection.
A smart phone has phone capabilities and comes with a smaller set of applications. Though you can add third-party software titles to your smart phone, the smaller keypad and screen are designed to give you quick one-handed access to important data. A smart phone is a good choice for business users who need to check email, keep track of their calendars, and take voice notes, but who don’t need the added functionality of Word Mobile, Excel Mobile, and PowerPoint Mobile.
The most important issue to remember before buying any Pocket PC, Pocket PC Phone or Smart Phone is to find out whether it is supported by the Windows platform or not. There exist several flavors of Smart Phones and Pocket PCs on the market. Some support the Windows platform, and some do not. To really execute and test the samples in this article in a practical environment, it is suggested that you have a “Pocket PC 2003 Second Edition powered by Windows Mobile Operating system” (but not mandatory).
Is a Pocket PC compulsory for working on and testing our Pocket PC applications?
Before explaining what we need, let us discuss what the Pocket PC really contains internally. A Pocket PC is primarily built upon Windows CE. The latest Windows CE OS already has its own version of the .NET Framework called “.NET Compact Framework.”
Any of the latest devices powered by “Windows Mobile” work with the .NET compact framework. The latest (at the time of this writing) “Pocket PC 2003 Second Edition” has its own version of the .NET Compact Framework directly installed in ROM. This gives you much less of a headache for any deployment scenarios.
Now, let us come to our concept. Do we really need to have a physical Pocket PC to execute and test our applications? No, you can still execute and test the solutions in this article without having any physical Pocket PC. This can be done using “Pocket PC emulators” installed along with your Visual Studio.NET 2003.
We have several types of emulators for developing Smart Device applications. Several of them include the emulators for Pocket PC, Smart Phone and even Windows CE. Both emulators and the .NET Compact Framework get installed automatically, if you select “Smart Device Client Extensions” during your Visual Studio.NET installation. If they are not installed, you will not be able to run execute the samples in this article.
I also suggest that you download and install Pocket PC 2003 SDK and the latest Pocket PC emulators from the Microsoft website. The download is free, and I use them in this article.
Before proceeding with the following steps, make sure that you met all the requirements discussed in the previous section.
Let us begin now:
Open Microsoft Visual Studio.NET 2003.
Go to File -> New -> Project.
Within the “New Project” Dialog, select “Visual Basic Projects” from the “Project Types” and “Smart Device Application” from the “templates” (as shown in Fig1). Currently, I left the name of the application set as “SmartDeviceApplication1.” You can change it according to your requirements.
Once you click “OK”, you will be presented with the “Smart Device Application Wizard.” Select “Pocket PC” as the platform of target and “Windows application” as “project type” (as shown in Fig2).
Click “OK” to accept your settings. You will be presented with a form (very similar to a Visual Basic 6 form), where you can design with the controls available in the toolbox.
Drag a “Button” control from your toolbox onto the form and write the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show("Hello World") End Sub
The next section helps you to execute the application we developed here.
Before proceeding with the following steps, make sure that you completed all the steps in the previous section.
Let us connect to the Pocket PC emulator first. Make sure you have the “device” toolbar visible as show in the Fig3. If it is not visible, go to View -> Toolbars and switch on the “device” toolbar. Once you have it visible, complete the following steps:
Select “Pocket PC 2003 Emulator (Default)” from the dropdown list available on the “device” toolbar. That emulator becomes visible if and only if you install an additional Pocket PC 2003 SDK and emulators. If you don’t have it, you can go for the “Pocket PC 2002” option.
Click on the “Connect to Device” icon, which exists just adjacent to the dropdown list. After a while, you should see your Pocket PC emulator (started with OS) as shown below (Fig4). It will take a bit of time to load the OS into the emulator. Once you are satisfied with the type of emulator you have selected, simply close it.
Now you execute your application by pressing F5 and you should be looking at something like the following (Fig5). You select the same emulator you selected earlier.
If necessary, you can also click the “Set As Default” button and switch off the check box to not show in the future (as shown in the above Fig5).
Finally click on “Deploy.”
After a few seconds, your Pocket PC emulator looks like the following (Fig6). You can observe that the form you designed earlier is exactly the same as on the Pocket PC emulator.
Click on “Button1” and you should see the following (Fig7).
Once you close your emulator, the control goes from run-time mode to design mode. If you face any deployment errors, just close any existing emulators and try pressing F5 again (without switching on emulators manually by yourself).
Life would not be complete without using a “datagrid” control in any .NET application. Now, let us implement a “datagrid” control even with a Pocket PC application.
Follow the steps to achieve the same:
Delete all the controls you played in the previous section (available on the form).
Add a new button (called “Fetch”) and a “datagrid” that fits the width of the form.
Open your code window and copy the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dr As DataRow Dim dt As New DataTable dt.Columns.Add("empno") dt.Columns.Add("ename") dt.Columns.Add("sal") dt.Columns.Add("deptno")
After a few seconds, once emulator is loaded, press on the “Fetch” button.
It should give you the output in the following figure (Fig8).
I developed the application using Microsoft Windows Server 2003 Standard Edition with Microsoft Visual Studio.NET 2003 Enterprise Architect and Pocket PC SDK 2003 (along with additional emulators downloaded). The entire solution for this article is freely available in the form of a downloadable zip file.
In my upcoming articles, I shall concentrate further on developing advanced Pocket PC applications. So, keep up with the website!
Any comments, suggestions, feedback, bugs, errors, enhancements are highly appreciated at jag_chat@yahoo.com