Mobile/PocketPC Development Jump Start, Page 3
Adding a PocketPC Menu to Your Application
Before concluding this lab, you will do one more thing. You will add a PocketPC menu to your application. Go back to the IDE and make sure the Design tab for your form is displayed. As was shown in Figure 3, there is a mainMenu1 item included with your application by default.
When you right-click on the mainMenu1 item, you will see that your form changes in the design area. You now have an area with Type Here text. You can enter your menu item by clicking on the text and typing. When you click to enter the text, you will see that additional menu options are displayed beside and above the one you are entering. Enter "Do It" into the main box. In Figure 8, you can see this text added.
To add code to the Do It menu item, double-click on it. This will bring up your code window with the menuItem1_Click method. For this example, you should add the following line of code to this method:
This will call the same code used by your Do It button on the form.
You can now recompile and run your application. You should see the same application you saw before with the addition of a Do It menu in the bar at the bottom, as shown in Figure 9. When you click Do It in the menu, you will see that it works just like clicking the button—which is exactly what you coded!
If you get a deployment error, you should check to see that you are not currently running the previous version of the application in the emulator. This can happen if you saved the emulator state instead of closing it. Simply close the running application in the emulator by clicking the Close button (the X in the top right). You then can restart your new application.
Figure 9: The running application with a menu item
As you can see, developing a PocketPC or Windows CE application is very much the same as building other applications. You do have restrictions based on the device, such as a smaller screen and some controls and functions that simply don't make sense on the smaller device, but otherwise, if you've been developing in Visual Studio .NET, you already have all the knowledge you need. This article was not comprehensive; however, you'll find that as you expand on what you did in this article, most things work just as they do for standard (non-mobile) applications.
In Visual Studio 2005, Microsoft has made additional enhancements to mobile development. Instead of seeing the plain box you see in the development environment (as shown in Figure 3), you actually see something that looks more like the emulator. This makes it easier to see how your application works in the context of the device. In fact, different devices will have different 'skins' shown in Visual Studio.
# # #