Share via


Getting Started with Smart Device Extensions

Larry Roof
Tonked.com

April 30, 2002

It's here. After months of rumors (most of which I'm responsible for) and waiting, (well, since I was the one to give you the first peek back last October I'll take the blame for that too) the Smart Device Extensions (SDE) Beta is available. Doesn't that just make you want to do a happy dance, kiss your significant other, take the dog for a walk and thrust your arms into the air as if you just won an Olympic gold medal, or at least found a close parking spot at the mall?

I'll start with the answer to the question on all of your minds. "Where do I get it?" I know, you're thinking, "Is Larry psychic? How did he know what I was thinking? Does he have some type of super-human power that enables him to read my mind through a Web page? If he does, can he tell what I'm thinking when I'm surfing adult-oriented sites?" All I can say to that is, in short, yes.

But, I digress. As John pointed out in his article (yes, he beat me to the punch and he'll pay for it), the SDE Beta is available at https://msdn.microsoft.com/vstudio/device/sdebeta.asp. Let me warn you though, the download is huge. I'm talking biblical proportions, weighing in at 94.71 megabytes (MB). At that size it will take about 8 minutes to download if you have a T1 connection running into your kitchen, and some way-hard insane amount of time on a 300-baud acoustic coupler. Everyone else will probably fall somewhere in-between.

Now, I fully expect most of you are going to leave this article now and go off to download SDE. That's okay, I don't mind. Years of therapy have taught me to cope with just about everything, including blatant disregard for my feelings. So you just go ahead and download your software.

Working with SDE

Unlike eMbedded Visual Basic®, which is stand-alone, SDE requires that you already have either Visual Studio® .NET or Visual Basic .NET. For those of you who haven't delved into the Visual Studio .NET world yet, I will give you four pieces of advice.

  1. You might want to consider buying that new computer you've been holding off on. Visual Studio .NET likes all of the resources it can get. The more computer you have, the better Visual Studio .NET runs and the happier you will be.
  2. Read the getting started documents that come with the SDE Beta distribution. You know those irritating little files that you normally just blow away—read them. They will make your life much easier.
  3. Get a good Visual Basic .NET book and read it. The difference between eMbedded Visual Basic and Visual Basic .NET is mind-boggling. Don't make the normal developer assumption that it will just come to you if you stare at your screen long enough.
  4. As John pointed out in his article, there are language specific versions of Visual Studio .NET available for something of a bargain price. There are three language releases available: C++, C#, and Visual Basic. The C++ version doesn't support SDE at this time (sorry John!), so you can go with Visual Basic and stop reading John's columns altogether.

Your First SDE Application

Last fall I gave you a sneak peak at SDE in my article First Look at Smart Device Extensions. Some things have changed since then, such as the addition of a form designer and the fact that you can now get an application to build, so I figured it would be a good to start to walk you through the process of building a simple SDE application.

Starting a New Project

The first sign you will see of SDE is when you go to create a new project within Visual Studio .NET. The New Project dialog, shown in Figure 1, will have an additional template under the Visual Basic Projects folder titled Smart Device Application. Select this template and enter the name of Hello World to get started.

Figure 1. The New Project Dialog

Clicking the OK button on the New Project dialog causes the Smart Device Application Wizard to be displayed as shown in Figure 2. From this wizard you can select two items: the target for your project and the type of project you want to create. For this example, I am going to target the Pocket PC and create a Windows Application project.

Figure 2. The Smart Device Application Wizard

When you click the OK button on the Smart Device Application Wizard, Visual Studio .NET creates and configures a new project as specified. That project is then loaded into the Visual Studio .NET development environment as shown in Figure 3.

Figure 3. An SDE project within the Visual Studio .NET IDE

Setting Project Properties

SDE offers several ways to configure project properties. First, you can use the Properties window as shown in Figure 4.

Figure 4. The Properties Window

Second, there is a Deployment Device combo box nestled into the IDE toolbar as shown in Figure 5. This allows you to easily switch between the emulator and a device when testing your applications.

Figure 5. Selecting the deployment device from the IDE toolbar

Finally, by right-clicking on your project in the Solution Explorer, and then selecting Properties from the bottom of the pop-up menu, you can access the Property dialog as shown in Figure 6. This method provides an easy to use interface to all of your project configurations.

Figure 6. The project properties dialog

For the purpose of this demonstration, I'm going to change the Output File Folder setting to \Windows\Start Menu, forcing my application to be added to the Start menu.

Building an Interface

When I first wrote about SDE back in October, the Form Designer had not been completed. Those who struggled to work with the early release version of SDE will be happy to know that a fairly complete Form Designer is included with the beta. This designer works similarly to the eMbedded Visual Basic IDE and should be somewhat familiar for most of you.

Figure 7. The Form Designer

At the bottom of Figure 7, you see that the hooks for a menu have already been added to the form. And get this, SDE has a menu designer. Makes you want to stand up and yell, "Commmmeeeneehaaahhhhhh!" doesn't it? That's right, no more longhand coding your menu structures like you have to do with eMbedded Visual Basic.

This feature is so cool that I'm going to add a menu to my Hello World application. What purpose will the menu serve? None, but it is cool. To add a menu, I first click on the MainMenu1 graphic located below my form. A dark gray box will be added near the top of my form. This is the start of my menu. By clicking on the dark gray box, I can graphically configure menus along with their items. A completed version of my menu is shown in Figure 8.

Figure 8. The Menu Designer

Next, I want to construct a simple interface. Figure 9 shows the Visual Studio .NET toolbox with a Device Controls section added by SDE. I use this toolbox to select interface components, just as I would in eMbedded Visual Basic .

Figure 9. The Toolbox

From the toolbox, I'm going to select a single button to add to my application. I've changed the Text property of the button to Click Me, giving it that Alice in Wonderland type of feel. For simplicity's sake, that's all I'm going to do with the interface.

Writing Some Code

Now I'm ready to write some code. The only code I'm going to add is a single line that displays the message "Hello World!" when the user taps the button.

I can access the click event of the button by simply double-clicking on the button in the Form Designer, same as I would with eMbedded Visual Basic. The code window will be displayed as shown in Figure 10. As you can see, I'm using MsgBox to display my simple message.

Figure 10. The Code Window

Testing in the Emulator

I'm now ready to test my Hello World application. Like previous versions of Microsoft Visual Basic-based mobile development tools, SDE supports testing in both an emulator and on a device. Unlike previous versions, the SDE emulator is a true binary image of the target device. What this means is that you can expect the emulator to offer a far more robust, functional, and realistic test environment.

This emulator is seriously cool. It can be customized to fit your needs. You can specify the amount of memory it has to work with, the size of the screen, the depth of color it uses, what hardware ports it supports, and whether it has Ethernet functionality.

Note The emulator used with eMbedded Visual Basic "existed" on your system as a sub-folder nestled under C:\Windows CE Tools. This configuration allowed you to simply copy files to and from the emulator using File Explorer. In contrast to this, the SDE emulator acts like an actual device. As such, you work with the SDE emulator, copying files to and from it, just as you would a device.

To test on the emulator, I first select Pocket PC Emulator from the Deployment Device combo box on the Visual Studio .NET toolbar, and then click the Start button. After a brief pause, the emulator is launched. My application is then loaded and runs as shown in Figure 11.

Figure 11. My application running in the emulator

Testing on the Device

To switch to testing on a device, I simply need to select Pocket PC Device from the Deployment Device combo box and click the Start button. As was with the emulator, my application is copied to my Pocket PC and then runs.

Converting Existing eMbedded Visual Basic Applications

I figure at about this point, existing eMbedded Visual Basic developers have got to be wondering how to convert an eMbedded Visual Basic application to SDE. The harsh truth is simply to start over. While I do know of a 57-step process that leverages eMbedded Visual Basic, Visual Basic, Visual Studio .NET, and SDE to convert an eMbedded Visual Basic application to SDE, the resulting application often looks like it was part of a bad transporter mishap on Star Trek.

Summarizing the SDE Beta

So there you have it, a brief overview of how to build an application with the SDE. Granted, this article is just a fly-by of SDE and doesn't begin to show the depth and breath of the functionality that SDE provides mobile developers. SDE offers developers a tool that is well suited for creating the next generation of mobile solutions. It has power, flexibility, and features that you could not even dream about with eMbedded Visual Basic.

Don't be mistaken though, the transition from eMbedded Visual Basic to SDE isn't going to be easy. In fact, it has all the possibilities of being downright scary. Visual Basic .NET is a whole new beast, being far more powerful and far more difficult to master. During the coming months, though, I will try to smooth the ride by presenting a series of articles on the common building blocks of SDE.

If you haven't already done so, I would strongly recommend that you read John's article Some Very Smart Software. Yes, I know he is the C++/C# guy. The fact is that with Smart Device Extensions there is a tremendous carryover of concepts and techniques between the languages. With what John provided in his article and what I covered here, you should be able to construct your own Visual Basic-based Web service.

Back on the Road

That's it for this month. I'm heading off for a much-needed surfing adventure. I'll be back in a month with a tan and a new SDE application. I would suggest that you run to your favorite bookstore and pick up a book or two on Visual Basic. NET. That should help take off some of the rough edges on getting started with SDE. Until next month, I'm back on the road.

John Kennedy is a Technical Writer/Programmer in the Visual C++ group by day and leads a secret life as a Pocket PC developer by night.

Larry Roof is a partner at tonked, a firm that specializes in the development of mobile solutions and training. He's the author of Professional Visual Basic Windows CE, available from Wrox Press.