




















































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:
Class library can be used for creating dll's.
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.
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.
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".
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.
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.
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".
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
Click on the Build menu item to display the drop-down menu and choose to build the project.
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.
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.
Which changes into the following when the program gets loaded.
Now click on the DateTimePicker control, pick a date as shown in the next figure.
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.
When you try to close the device by hitting the close button at the top of the window the following window gets displayed.
If you choose Yes, the device state gets saved and the next message gets displayed.
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.
When you click on the Device Emulation Manager... you will see all the available devices as shown.
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.
This article described a simple introductory application for mobile devices. The application deployment to a Pocket PC emulator was also described.