One Community, One World
Beginning Developing Smart Device Applications with dot NET Compact Framework Part 1
by Ahmed Waly  on Sep 4 2006 12:00AM
  PageViews 9444   |    Add to Fav   |     Send to Friend   |    Download Code

Learn how to develop a smart device application targeting Windows mobile using .NET compact framework 1.0.

Smart device application development doesn't differ so much from normal windows application, except in the design strategies and some concepts and basics.

So if you are already a .NET developer, then you will not face any problems switching to .NET smart device development.

Here in this article, I'll separate it to several articles; each will explain how to target a certain platform.

We will start with the development of device applications to target Windows Mobile 2003 and .NET compact framework v1.0. 

But before we start, there are some points you need to know about why we are using .NET compact framework 1.0; 

.NET compact framework 1.0 applications can be used in PocketPC and Smartphones with Windows Mobile 2002 and later tell the latest Windows Mobile 05, while .NET compact framework v2.0 applications can only be used with devices running Windows Mobile 2003 SE and later, so you will need to decide which version to use according to your targeted devices. 

Resources Used:
Microsoft Visual Studio 2003 or 2005
.NET Compact Framework v1.0
Microsoft Pocket PC 2003 SDK
Microsoft ActiveSync 3.8 or later(optional)

PPC Important Concepts:
You need to know these concepts before starting developing PPC application.

  • Most PPC screen resolution is 240*320 pixels, and when using the on screen keyboard, its size become 240*240, so when using controls like textbox or like that, you must consider placing them in a place where they are not hidden behind the KB.
  • Windows Mobile allows only one instance of the same application to run in the memory, so you can't run multiple instances of the same application in the same time.
  • In case of multiple forms application, when opening the new form, you must hide the previous form or it will be still opened in the memory till you Exit the application, in this case, you will consume a large amount of memory.
  • The deployment of applications to the devices are of two ways, either by generating a cab file and copying it to the device and running it from there, or by generating a Setup project and run it from the desktop to install the application through ActiveSync.

Let's Start...
First, we start visual studio and choose new project, from the list, select Smart device node, then PocketPC 2003 Device Application (1.0), and if you are using VS 2003 just select smart device application and when a new window appears, select PPC and press OK.

Next, the IDE will generate the initial design code behind and shows the designer screen.

You can show or hide the PPC Skin by right click on the form and select "Show/Hide Skin".

As you can see, I'm using here VS 2005, so if you are using VS 2003 you will notice some changes, but they don't differ so much, although I liked the VS 2003 more then VS 2005 in the smart device development specially in compact framework 1.0, it is faster and more stable than VS 2005, but after all it is my point of view.

Back to the article, now after creating the application, we will make a sample on how to implement and use the On-Screen Keyboard (input Panel or SIP).

Add a new textbox control to the form, and inputPanel control too.

In the textbox events, double click on the "TextChanged”, "GotFocus”, "LostFocus” events, and the "Click” event of the form to generate its code.

And type the following in the events code:
private void textBox1_TextChanged(object sender, EventArgs e)        
        //Showing the inputPanel             
        inputPanel1.Enabled = true;         

private void textBox1_GotFocus(object sender, EventArgs e)   
        //Showing the inputPanel             
        inputPanel1.Enabled = true;   

private void textBox1_LostFocus(object sender, EventArgs e)         
        //Hiding the inputPanel             
        inputPanel1.Enabled = false;         

private void Form1_Click(object sender, EventArgs e)         
        //Hiding the inputPanel             
        inputPanel1.Enabled = false;         

This sample code will show the inputPanel when the textbox control got focused when typing on it, and hides the inputPanel control when the textbox loses the focus.

Now from the toolbar, select "Debug” and then "Start debugging”, it will show a window asking you to select where to deploy your application, choose the emulator you want, or choose PocketPC 2003 Device if you want to deploy to your Device (it must be connected to the PC and ActiveSync).

When the application runs, select the textbox and you will see the SIP (inputPanel) shows up, now click on an empty place and you will se the SIP hide.

In Part 2, I will talk about targeting smart device applications using .NET compact framework 2.0 and difference between 1.0 and 2.0.

With the release of Visual studio 2003 and .NET compact framework 1.0, developers were able to develop smart device applications in a faster and easier way, as if they are developing a Windows application for their PC, thanks for Microsoft .NET CF Team.