A Simple Pocket PC Application using Visual Studio 2005

by Jayaram Krishnaswamy | November 2008 | .NET Microsoft

This article by Dr. Jayaram Krishnaswamy teaches how you may create a .NET Compact Framework (CF) 2.0 forms application. This can be used with Pocket PC 2003, or later devices. In the absence of a device being available for testing, the emulator is the next best thing. The application will be tested on one of the many emulators available in Visual Studio 2005. You may try other devices as well just by choosing the item in the Device Emulation Manager described in the article.

Creating a Device Application

File | New | Project will open the New Project window as shown. Expand the Visual Basic node and follow it up by expanding the Smart Device node as shown. There are three kinds of Smart Devices listed; Pocket PC 2003, Smartphone 2003 and Windows CE 5.0. For this article the Pocket PC 2003 is chosen.

When you select Pocket PC 2003 in the left pane, the right hand pane shows many templates available for Pocket PC 2003. You will be able to create the application for CF 1.0 as well as CF 2.0. In this interface you may choose to create the following types of applications:

  • Device Application: CF2.0 Forms APP for Pocket PC 2003 or later
  • Device Application(1.0: CF1.0 Forms APP for Pocket PC 2003 or later
  • Console Application: CF 2.0 non-graphic application
  • Console Application(1.0: CF 1.0 non-graphic application
  • Control Library : CF 2.0 controls for Pocket PC

Class library can be used for creating dll's.

A Simple Pocket PC Application using Visual Studio 2005

Change the name of the default project name to something different. Here it is changed to Pocket2. When you click OK after changing the name of the project, the program creates a MyProject folder and a Form1.vb file which you see under Solution Explorer. You may rename the file.

The interface functions very much like, as if you are creating a Windows Application. The difference is you will be displaying a small foot print device as shown in the next figure. Form1 is displayed in the design mode and a mainMenu1 item is added to the Control Tray.

A Simple Pocket PC Application using Visual Studio 2005

When you click on the mainMenu1 in the tray you get a visible cue as to what you should do next as shown. The mainMenu1 shows up with Smart Tasks as shown.

A Simple Pocket PC Application using Visual Studio 2005

Now click on the Edit Menu and this opens up the Type Here area where you can enter some text. Here "Test" has been entered. This will create a single menu item "Test".

A Simple Pocket PC Application using Visual Studio 2005

This is a nice interface where you can build up menu items very easily as shown in the next figure. All you need to do is just type in the area indicated by "Type Here". In addition to this you may also use other common controls from the toolbox.

A Simple Pocket PC Application using Visual Studio 2005

Placing Other Controls on the Form

Because of the compact nature of the device with a reduced foot print, the controls available are a subset of the controls that you find normally in a desktop application. Where as controls in desktop can take a variety of arguments, the compact controls work with limited set of arguments. The next figure shows the device related controls that are available.

A Simple Pocket PC Application using Visual Studio 2005

Let us go ahead and drag and drop (or double click in the Toolbox), a DateTime Picker control and a textbox as shown in the next figure. Rearranging objects is a snap because Visual Studio 2005 has an excellent support for sizing and aligning objects. The grid lines automatically snap in place (notice the thin blue line tying the alignment of Textbox1 with the DataTimePicker control. The Form1 text was changed using the Form's property window to read "Testing a simple device".

A Simple Pocket PC Application using Visual Studio 2005

Attaching an Event to Test the Controls

Let us make use of the click event of the TestTime sub menu item to read from the DataTimePicker control and display it in the Textbox. To begin with, let us make the Textbox's text to be empty. Using the code shown the next paragraph we can show the date we pick from the DataTimePicker to display in the textbox. You can get to the code page by clicking on the TestTime sub menu [MenuItem3] item in the design window.

Note Form1.vb is renamed as MyFirstMobile.vb

A Simple Pocket PC Application using Visual Studio 2005


Books from Packt

Software Testing with Visual Studio Team System 2008
Software Testing with Visual Studio Team System 2008

Entity Framework Tutorial
Entity Framework Tutorial

Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained
Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained

ASP.NET Data Presentation Controls Essentials
ASP.NET Data Presentation Controls Essentials

Programming Windows Workflow Foundation: Practical WF Techniques and Examples using XAML and C#
Programming Windows Workflow Foundation: Practical WF Techniques and Examples using XAML and C#

Visual SourceSafe 2005 Software Configuration Management in Practice
Visual SourceSafe 2005 Software Configuration Management in Practice

LINQ Quickly
LINQ Quickly

BlackBerry Enterprise Server for Microsoft® Exchange
BlackBerry Enterprise Server for Microsoft® Exchange

 


Testing the Device

Click on the Build menu item to display the drop-down menu and choose to build the project.

A Simple Pocket PC Application using Visual Studio 2005

After the Build succeeds (you should see a build succeeded message at the bottom of the screen) click on Start Debugging (green arrow) by the side of the Debug menu item. This displays the Deploy Pocket2 window as shown. There are a number of Pocket PC devices shown with the highlighted as the default.

A Simple Pocket PC Application using Visual Studio 2005

Accept the default emulator and click on the Deploy button. When the deployment succeeds you should see a message to that effect in the Output window (you may access this from the View menu item). You will also see the emulator skin as shown in the next figure.

A Simple Pocket PC Application using Visual Studio 2005

Which changes into the following when the program gets loaded.

A Simple Pocket PC Application using Visual Studio 2005

Now click on the DateTimePicker control, pick a date as shown in the next figure.

A Simple Pocket PC Application using Visual Studio 2005

After picking the date click on the sub menu item of Test which is TestTime. This transfers the date information from the DateTimePicker and places it in the textbox after adding some text as shown. You may pick another date and test it again.

A Simple Pocket PC Application using Visual Studio 2005

When you try to close the device by hitting the close button at the top of the window the following window gets displayed.

A Simple Pocket PC Application using Visual Studio 2005

If you choose Yes, the device state gets saved and the next message gets displayed.

A Simple Pocket PC Application using Visual Studio 2005

Although a Pocket PC emulator was chosen you could get all the accessible devices using the Device Emulator sub menu item from the Tools menu as shown.

A Simple Pocket PC Application using Visual Studio 2005

When you click on the Device Emulation Manager... you will see all the available devices as shown.

A Simple Pocket PC Application using Visual Studio 2005

Get acquainted with the Object Browser

The Object Browser is one place where you may find clues as to what is happening in your program, whether you are using the correct syntax, etc. Refer to this important resource as you develop your programs.

A Simple Pocket PC Application using Visual Studio 2005

Summary

This article described a simple introductory application for mobile devices. The application deployment to a Pocket PC emulator was also described.


About the Author :


Jayaram Krishnaswamy

Jayaram Krishnaswamy studied at the Indian Institute of Science in Bangalore India and Madras University in India and taught at the Indian Institute of Technology in Madras. He went to Japan on a Japanese Ministry of Education Research scholarship to complete his PhD in Electrical Engineering from Nagoya University. He was a Post-Doctoral Fellow at Sydney University in Australia; a Government of India Senior Scientific Officer at the Indian Institute of Science in Bangalore and Indian Institute of Technology at Kanpur; a Visiting Scientist at the Eindhoven Institute of Technology in the Netherlands; a visiting Professor of Physics at the Federal University in Brazil; an Associate Research Scientist at a government laboratory in São Jose dos Campos in São Paulo, Brazil; a visiting scientist at the National Research Council in Ottawa, Canada before coming to USA in 1985. He has also taught and worked at the Colorado State University in Fort Collins and North Carolina State University in Raleigh, North Carolina. He worked with Northrop Grumman Corporation on a number of projects related to high energy electron accelerators and Free Electron Lasers. These projects were undertaken at the Brookhaven National Laboratory in Long Island and in the Physics Department at Princeton University. He has over 80 publications in refereed and non-refereed publications and 8 issued patents. He is fluent in Japanese and Portuguese and lives in Honolulu, Hawaii, USA.

He has been working in IT-related fields since 1997. He was once a Microsoft Certified Trainer in Networking and a Siebel Certified developer. He has worked with several IT related companies, such as the Butler International in their Siebel practice, with several IBM sub-contractors and smaller companies. Presently he is active in writing technical articles in the IT field to many online sites such as http://CodeProject.com, http://APSFree.com, http://DevShed.com, http://DevArticles.com, http://OfficeUsers.org, http://ASPAlliance.com, Egghead Café, http://SSWUG.org, Packt Article Network, http://databasedev.co.uk, http://cimaware.com, and many others. Between 2006 and 2010 he wrote more than 400 articles mostly related to database and web related technologies covering Microsoft, Oracle, Sybase, ColdFusion, Sun, and other vendor products.

He has written four books all published by Packt related to Microsoft Database and Application Development: SQL Server Integration Services Using Visual Studio 2005, Learning SQL Server Reporting Services 2008, Microsoft SQL Azure; Enterprise Application Development, and Microsoft Visual Studio Lightswitch Business Application Development. He regularly writes for his four blogs on Blogger; http://Hodentek.blogspot.com, http://HodentekHelp.blogspot.com, http://HodentekMobile.blogspot.com, and http://HodentekMSSS.blogspot.com. He received the 2011 Microsoft Community Contributor award.

Contact Jayaram Krishnaswamy

Books From Packt

Beginners Guide to SQL Server Integration Services Using Visual Studio 2005
Beginners Guide to SQL Server Integration Services Using Visual Studio 2005

ODP.NET Developer’s Guide: Oracle Database 10g Development with Visual Studio 2005 and the Oracle Data Provider for .NET
ODP.NET Developer’s Guide: Oracle Database 10g Development with Visual Studio 2005 and the Oracle Data Provider for .NET

Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained
Microsoft AJAX Library Essentials: Client-side ASP.NET AJAX 1.0 Explained

ASP.NET Data Presentation Controls Essentials
ASP.NET Data Presentation Controls Essentials

Programming Windows Workflow Foundation: Practical WF Techniques and Examples using XAML and C#
Programming Windows Workflow Foundation: Practical WF Techniques and Examples using XAML and C#

Visual SourceSafe 2005 Software Configuration Management in Practice
Visual SourceSafe 2005 Software Configuration Management in Practice

LINQ Quickly
LINQ Quickly

BlackBerry Enterprise Server for Microsoft® Exchange
BlackBerry Enterprise Server for Microsoft® Exchange

 


Your rating: None Average: 5 (2 votes)
performance counter by
hallow, i had try that and i want to ask about performanceCounter in device application, because i want to make a application for remoting a server. replace with what the performanceCounter??? help me please???
This is great by
I very much appreciate Dr. Jayaram Krishnaswamy for this wonderful and very helpful article. Thank you so much this will help many beginners like me. Jerry Maiapu

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
C
j
E
W
6
p
Enter the code without spaces and pay attention to upper/lower case.
Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software