Windows Mobile Starter Kits: the Easy Way to Start Developing

Creating a tabbed WM Web browser

If you are considering developing applications for Windows Mobile devices, I've some good news for you: we'd like to help. By "we," I mean the User Assistance team in the Mobile and Embedded Division at Microsoft; and by "help," I mean we're going to do some of the work for you. We all know that the best way to learn about a new developer tool, or to explore a new technology, is to try it out for yourself—and that's what we're trying to make as easy as possible.

Hopefully, you are aware by now that Visual Studio 2005 is the recommended development platform for the latest Windows Mobile 5.0-based devices. One particularly cool new feature that Visual Studio provides is the "Starter Kit"—a special type of Project that can quickly be downloaded and used either by itself, or as the basis for your own applications.

The Programmer/Writers at the Mobile and Embedded Division have created several of these Starter Kits and have plans for more. I'm going to take this opportunity to explain how they work, look in more detail at one in particular, and demonstrate how it can make a very useful addition to your Pocket PC programming toolkit. I hope by the time you reach the end of this article, you'll fire up your own copy of Visual Studio and download a Starter Kit to give it a try.

Writing a tabbed Web browser

Have you ever been using Internet Explore Mobile on your Pocket PC, and wished you could have several instances running at once? Perhaps you want to search for some vital fact on MSN Search, and also want to keep your favorite mobile news Web site open.

If you have tried out the latest beta release of Microsoft's Internet Explorer 7.0, or if you have used Firefox or even Safari on a Mac, you'll know that "tabs" are all the rage. Effectively, a tabbed browser keeps multiple Web pages open at once, allowing you to easily flip between them.

I love this functionality, which is why I wrote my own tabbed Web browser for the Pocket PC. I used the C# language and some pre-defined controls, which combined to greatly reduce the development time compared to using C++. I then wrote some documentation, and packaged it all up as a Starter Kit. This means it's really easy for any developer to download it, build it, and use it. Better yet, it's easy to expand with your own custom features.

As it turns out, writing a Web browser in C# is remarkably easy. There's no need to worry about HTML formatting, graphics rendering, or even HTTP protocols—all that is taken care of by using a pre-defined "control". A control is simply a programming element—such as a text box, menu or in this case a Web browser—that Visual Studio provides for you to use in your own applications. Controls are listed in the toolbox on the left of the Visual Studio design environment: all you need to do is drag them onto your application's default Windows Form.

The second way to use a control is to create it programmatically: that is, write the necessary C# code to call one of the controls into existence. The code that does all the things associated with a Web Browser has already been written and is part of the .NET Compact Framework. Think of the Compact Framework as a large library of code and controls that you can use in your own applications.

The code that creates a WebBrowser control isn't particularly complicated—in fact in C#, it looks like this:

WebBrowser myWebbrowser = new WebBrowser();

All this code does is create a new variable, of type WebBrowser that in this example we call "myWebbrowser." An instance of the WebBrowser control is then called into existence with the "new" keyword, and the myWebbrowser variable is used to keep track of it.

The new myWebbrowser variable inherits all the features of the WebBrowser control, and to access them, you simply add a period and Visual Studio will pop open a list of all the methods and properties available to you.

For example, let's say you want to make the WebBrowser control appear invisible. To do that, you would use the line of code:

 

Syndicate content
 

Flash®