Reader Level:
ARTICLE

Developing Pocket PC Applications using .NET Framework

Posted by Shailaja Articles | Compact Framework September 02, 2003
This article presents the rudimentary knowledge that a developer requires for developing Pocket PC Applications using .Net Compact Framework.
  • 0
  • 0
  • 24629

This article presents the rudimentary knowledge that a developer requires for developing Pocket PC Applications using .Net Compact Framework.

Back Grounder:

The .NET Compact Framework brings the. NET Framework programming model to a wide range of devices, from PDA's to emerging devices, such as smart mobile phones and set-top boxes. This is targeted to run on devices with limited capabilities and which are resource constrained. The Compact Framework also leverages the MSIL concept of not targeting any specific hardware.

Below are some of the notable points which would help kick start a .NET Developer on the .NET Compact framework path:

  1. To develop for the Pocket PC/Windows CE environment, .NET provides the Compact Framework. The Compact Framework is a subset of the .NET Framework.

  2. The Compact Framework is installed by default on installing Visual Studio.NET 2003.This IDE gives you options for creating a Smart Device Project (For Pocket PC or Windows CE).This IDE also provides you an emulator.

  3. Remember the Compact Framework is a subset of the .NET Framework; this means in the desktop Framework if there are 'n' ways to perform a set of tasks ;in the Compact Framework; you would find only one way. This also means that there may not be any way at all ; )

    E.g. 1: Compact Framework does not provide support for the printing. There is no print namespace. So you have to work around to accomplish this task.

    E.g. 2: Another example is the well-known Control class: in the compact framework this class only counts 27 instead of 76 properties, 38 instead of 182 methods and 17 instead of 58 events. See Figure 1.


    Figure 1


    DevelopPocketPCAppsImg1.jpg

  4. There are also a set of namespaces which are specific to the Compact Framework environment and are not found in the Desktop environment like the System.Data.SqlServerCe.

  5. To create a Custom Control targeting the Pocket PC environment; Select New Project/Visual C#. In the next dialog box select Pocket PC and Class Library. See Figure 2,3.

  6. Remember-just by virtue of creating a class Library type of project; and making your control; your control does not get design time properties.

    DevelopPocketPCAppsImg2.jpg

    Figure 2

    DevelopPocketPCAppsImg3.jpg

    Figure 3

  7. "In order to make a custom control to appear in the toolbox of a visual designer and to be dragged and dropped on to a design surface in .NET Framework you would derive your control from System. ComponentModel. Control or System. ComponentModel. Component which implement System. ComponentModel. IComponent interface. This path will not work in .NET Compact Framework and SDE, because the System. ComponentModel. IComponent interface is missing from the Compact Framework runtime assemblies. A lot of changes have been done to reduce the size of the framework and improve its performance and execution speed. "

    Refer: http://www.intelliprog.com/articles/index.html for exhaustive information on the same.

  8. When using an image; use the fully qualified name: System. Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("TestSmartDeviceApp.images." + imageName and specify it as Embedded Resource.(Go to Properties(of the image)/Build Action-Embedded.).

  9. Whenever a control begins to paint, its background is automatically refreshed first. For example while processing OnPaint() to paint the contents of the Control, its background is painted first with the color specified from this.Backcolor. This might be undesirable in the above case where the application is owner drawing the Form; the automatic painting of the background might result in momentary flashing of the background before the application had a chance to finish painting the foreground.

  10. To prevent the above default behavior, whenever an application overrides the OnPaint() method it is highly recommended that it also overrides the OnPaintBackground() method and paints the background itself. The application can choose to handle all the painting inside of OnPaint() and leave the OnPaintBackground() empty as in the example below.

  11. On version 1.0 of the .NET Compact Framework on Pocket PC, to create a Full Screen application the WindowState property must be set inside the Form's OnLoad. Refer Figure 4 and 5:


    DevelopPocketPCAppsImg5.jpg



    Figure : 4 Default look of the screen


    DevelopPocketPCAppsImg5.jpg

    Figure: 5 Screen without the Title bar and the Task bar.

  12. Add a reference to System. Data. Common to get a reference to all Data Object Related methods (E.g.: DataAdapter does not show the 'Fill' method if reference is not provided).

  13. Remember most of the controls do not have a BackGround Image property. You might just have to create your own control to work around this. Also heed that the 'transparency' property is not provided in the Compact Framework. You could however work around this by using the SetColorKey Property in the ImageAttributes class.

  14. You cannot do an 'Application.Exit' in the PocketPC environment. When you click the X mark in the Title bar (See Figure 3); the form is only hidden.

  15. The different file system is one thing that trips up desktop developers moving over to .NET Compact Framework development for Pocket PCs. There are no drives on Windows CE-based devices. The root of the file system is '\', so typically your application will be installed to a directory like '\Program Files\MyApplication'. If your device has a storage card, then the root folder on the card is '\Storage Card'.

  16. The local SQL CE database is used for temporary storage when your users work offline. The database is treated like a data file that is created and destroyed as needed, instead of a permanent database; typically the database is dynamically created (tables and indexes) and deleted after the projects are synchronized with the master database.

Happy Coding!

COMMENT USING

Trending up