Building Hello Pocket World


Applies to:
   Microsoft Windows Powered Pocket PC 2000

So now that you have the tools, you're ready to start with the first application. Clearly the importance of this is not the code involved, but getting to know how to test and deploy applications to the Pocket PC once you've created them. Of course, there's that great moment when for the first time you see your application working on the device.

So... launch eMbedded Visual Basic 3.0, and choose Windows CE for the Pocket PC Project from the project options.

Look Before You Jump

Before you jump into adding buttons and coding, let's have a quick look around the development environment. There are a couple of important parts that are unique to Pocket PC development that are not present in standard Windows development.

Much of the Visual Basic user interface (UI) is the same or similar to standard Visual Basic, but take note of these differences:

First click on Tools and then Configure Platform Manager. This is where you can see, add, and configure the platforms available to eMbedded Visual Basic. The two devices of interest are Pocket PC (Default Device) — that's your actual Pocket PC device — and Pocket PC Emulation.

Pocket PC Emulation

This is a facility provided by the development environment that offers a Pocket PC—looking interface in a window on your PC, and allows you to test applications. This is very useful in preventing you from hanging your Pocket PC device with untested code. But be aware that not all code supported in the devices are supported in the emulator. I would suggest testing directly on the device as you gain confidence in your code.

Test Your Connections

It is worth testing the connection to your Pocket PC device in this Configure Platform Manager interface (Tools, Remote Tools, Configure Platform Manager). Click on the Plus button next to Pocket PC, then on Pocket PC (Default Device), and finally on Properties. Ensure that PPP Transport for Windows CE is selected. This appears to be important for test-running applications directly on the device. You can then test the connection.

The connection test can be made with the emulator also. Note that the only transport option here is TCP/IP.

Just Before You Start

I know you're itching to start, but just before you do right mouse click on Project, then Project1 Properties.

Click here for larger image

Figure 2: Project and Project1 Properties. Click the thumbnail for a larger image.

Here you can make the usual changes of modifying the Startup Object and changing the name of the Project. More importantly, you can set the path to the executable when it is installed on the Pocket PC and change its name. By default it will install the whole executable to the Start menu. You may wish to put the executable in a Programs folder and then put a pointer to it in the Start menu.

  • For this first application change the Project Name to Hello, and change the Remote Path to \Windows\Start Menu\Hello.vb.
  • You can also change where you will be running the code when you press the Start Debug (F5) button, either on the device or on the emulator in the Visual Basic environment. This can be changed here and on the main eMbedded Visual Basic UI. So change the Run On Target to Pocket PC Emulation.

Let's Get Started!

Okay, we're finally here.

  • Draw a button on the form.

  • Double-click on the button to go to the code window. In the Command1_Click() procedure type:

    MsgBox "Hello Pocket World"

Note that in the same window is:

Private Sub Form_OKClick()
End Sub

This is where, at the top right of a Pocket PC application, the application is closed by clicking on the OK button.

So now that you're ready to test it, you should see in the top middle of the Visual Basic UI is a drop-down list box of devices. This has the same option that you selected for the project properties, and it dictates on which device the program will run when we press the Start Debug (F5) button the Visual Basic UI.

  • Select the Emulator.
  • Press the F5 button. You will see some progress messages, and then the emulator will appear as in Figure 3. Note that this does take a few seconds.

Click here for larger image

Figure 3: The Emulator. Click the thumbnail for a larger image.

You can click on the gray Command1 button to see your application working. The OK button will close your application; the big black/gray button at the bottom will close the whole emulator (this will take a second or two).

  • Click on OK to close the application and then click on the emulator's Start menu (top left). You will be able to see your Hello project in the Start menu.

Now for the Fun - Let's Run it on the Pocket PC

  • In the Visual Basic UI change the drop-down list box at the center top so that Pocket PC (default device) is selected.
  • Press Start Debug (F5).

If you selected PPP as your transport type for the Pocket PC and if ActiveSync is running, then your application will run on the Pocket PC. As with the emulator it takes a few seconds for Visual Basic to copy over your application. Check that you have the connection and that all the right dynamic link libraries are installed on the Pocket PC. If this is so, it should run.


Creating a Setup Package

Now you have a Visual Basic project that you can run on your Pocket PC using the Start Debug button in the Visual Basic UI. Next you'll need to know how to produce a packaged product that people can install using a Setup.msi.

Click on the Project menu and then Properties. Change where on the Pocket PC the program file is going to be installed (the Remote Path). See the example in Figure 4 below.

Now save the project, click on File, Save Project as and save the .EBF (form file) and .EBP (project file). (You may want to call these files Hello.EBF and Hello.EBP.)

Click here for larger image

Figure 4: Project, Properties. Click the thumbnail for a larger image.

Compiling the Application

To compile your program, click on File, and on Make Hello.vb, and store your .vb file. You should note at this point that a Visual Basic program when compiled for use on a Pocket PC has a .VB extension, not .EXE.

Creating the Setup Package

Then click on Tools, Remote Tools, and Application Install Wizard. This wizard will need to know where your .VB program is, and where your .EBP file is — your source-code project file. It will then ask where you want the SETUP program and associated folders stored.

Selecting Processor Architecture

Not all Pocket PCs are the same inside. There are different, incompatible, processor architectures, and the Application Install Wizard will ask you which one you want to support. For the Compaq iPAQ, select the Arm 1100(4K) v3.00.

Click here for larger image

Figure 5: eMbedded Visual Basic App Install Wizard — Step 5. Click on thumbnail for a larger image.

Next it asks if you want to include any ActiveX controls, and in this case there are none to add.

In Step 8 of the wizard you are prompted for the install directory, application name, description, and company name. The install directory in this case is not on the Pocket PC, but it is asking where on your hard disk you would like to store the .cab and .ini files for this application.

All of these are required fields and, unfortunately, what you type is not recalled next time you run the wizard.

Once you have entered something for each of those fields and click Next you're ready to create the package by clicking Create Install. During the process, the wizard does shell to a DOS box momentarily.

The Setup Package is Complete

If you look in the folder you specified for the setup files you'll find a README.TXT file and a number of folders (depending on how many architectures you selected). Everything you need to run to install the application is in the CD1 folder. Run the SETUP program and watch it install. You will see that it prompts you whether you want to install the application in the default programs folder on your Pocket PC. Accept this; it means you'll see an icon for your application when you click on Start then Programs on the device.

On the Pocket PC you'll see progress messages for the files being installed, and if you have run this before it will prompt you asking if you wish to overwrite files.

Locating Your Application

If you changed the Remote Path in the project properties, as I did in this example, the application will not appear in the Start menu on the Pocket PC. But if you click on Start then Programs, you will find your application. Also, if you click on the File Explorer, then on the My Documents menu and select My Device (as seen in Figure 6 below), the Program Files folder will be exposed.

Click here for larger image

Figure 6: My Documents, My Device. Click on thumbnail for a larger image.

You'll see a program folder for your application. In Figure 7 below you can see the TestApps folder that I specified in my project properties.

Click here for larger image

Figure 7: My Documents, My Device, Program Files. Click on thumbnail for a larger image.

Removing the Application

To remove your application from the Pocket PC click on Start, then Settings, and select the System tab. There is an icon for removing applications.

Adding the Application to the Start Menu

Click on Start, then Settings, and select the Personal tab. There you can add and remove installed applications from the Start menu.