30 Days of .NET (Windows Mobile) Revisited
02 June 08 01:33 PM | BrainThump | with no comments

After talking with Chris (Craft) about his project for the next 30 days, I asked if he would mind whether or not I took his C# code and converted it to VB.NET to post here and he liked the idea. With that said look forward to having some updated code samples here as quickly as I can convert them. See Chris' blog for the latest installments he's released.

30 Days of .NET (Windows Mobile Applications)
02 June 08 10:39 AM | BrainThump | with no comments

Fellow Mobility Geek and friend Chris Craft has started a series on his blog which aims to showcase 30 Windows Mobile Applications in the next 30 days. Simple examples to get anyone started on the path towards Windows Mobile Development...now why didn't I think of that? :)

Anyways, to tune in to what Chris is bringing you, head over to his blog and check it out!

Windows Mobile slide deck and demo code posted
22 April 08 09:57 AM | BrainThump | with no comments

I've posted the slide deck and demo code from my user group presentation the other night. You can download it here: http://ilovevb.net/Web/files/folders/vbmobile/entry132.aspx

The demo code shows basic SMS Messaging, State & Notifications Broker, Call Blocking (using the State and Notifications Broker) and using System Settings - all in VB.NET.

Enjoy!

Getting started with the .NET Compact Framework
08 April 08 06:50 AM | BrainThump | 3 comment(s)

This article explains the basics of building a simple but useful application using the .NET Compact Framework where we’ll go beyond “Hello World” but not so far that you’ll get lost in the process. We accomplish this by focusing on building our application while starting to realize some of the limitations and workarounds Compact Framework developers face.

By the end of the article you’ll have a clear understanding of just how easy it can be to get started developing your own Compact Framework applications. If you’ve been coding along with the article, you’ll also have built a template for future development projects.

Part 1 – Background Info

Section 1 – A Short Time Ago at a Code Camp Near You…

The Theo And Lou Show

In September 2006 Theo Moore and I co-presented a fun Code Camp session on .NET Compact Framework Game Development. We had quite a few people show up across the entire 3+ hour session (with breaks of course!) and the interaction with the developers who were there was great.

One of the things that I think surprised me the most was that there seemed to be an overwhelming notion (among those viewing our session) that .NET Compact Framework was going to be waaaaay different than programming the “full” .NET Framework. I even had guys come up to me afterwards and mention that one thing that had kept them from exploring the Compact Framework was they thought they might have to re-learn a bunch of stuff. Now, without getting into lengthy discussions about specifics, for a good number of basic apps, the code can remain the same although your interface design will need some changes to accommodate smaller screens, etc.

7000 downloads and counting!

To illustrate this point I often use my wildly popular Tip Calculator/Bill Splitter which uses the same code base in the full .NET Framework and the .NET Compact Framework. In fact, I developed it first in the full framework and then copied/pasted it into my CF project when I was ready. I did all this because I wanted to get started developing CF applications but wanted something a little more robust than “Hello World!”

Here’s a shot of what the finished program looks like on PocketGear.com:

clip_image002

If you’re interested in downloading the program for yourself, you can do so free of charge at PocketGear.com with the following link: http://classic.pocketgear.com/software_detail.asp?id=17954

I had no idea when I released this little application that it would become so widely used.

It’s even been featured in PC Today magazine as one of their Mobile Tips in the February 2006 issue. ( http://www.pctoday.com/editorial/article.asp?article=articles%2F2006%2Ft0402%2F19t02%2F19t02.asp )

clip_image004

Part 2 – Not your average “Hello World”

Section 2 – Getting Started

Required Software

So how do we start? First things first – the Visual Basic and C# Express Editions do not support Compact Framework. If you have Visual Studio 2003, you can follow along just fine, though the screen shots will look different, none of the code (I’m pretty sure!) I’m using in this demo is .NET 2.0 specific. If you’re not fortunate enough to have Visual Studio 2005 Professional there’s hope – attending your local Microsoft Sponsored User Events like local .NET User Groups, MSDN Code Camps, etc. often result in one or more lucky persons walking away with that as a prize…in fact at the September 2006 South Carolina Code Camp, 2 people won Visual Studio 2005 Professional and we’ve given away a few copies as prizes to our Greater Charleston .NET User Group members…just one more reason to get involved in your local developer community!

Working with your project in the IDE

So that said, let’s fire up Visual Studio 2005 Professional and start a new project as shown in the screen below:

clip_image006

So here we’re creating a project that targets a Pocket PC 2003 device (only because I don’t own a Windows Mobile 5 device myself) and we’re also targeting a project for 2.0 framework. Incidentally if you want to create a 1.0 Compact Framework project in VS 2005 you still can. The project icon right underneath the one I’ve selected above is for a 1.0 project.

Once we’ve created the project we’re presented with a screenshot showing an emulator background where we can begin development of our application. See the screenshot below:

clip_image008

If you’re following along with us using Visual Studio 2003, you won’t see the emulator image in the background, but instead see a much smaller (and probably more familiar) Windows Form. I personally think the emulator image in the background is a nice touch added in VS 2005 and was pretty stoked to learn about some of the other nice things that come with that, but that’s a topic for a later lesson.

In looking at this form you can see it’s not so radically different than standard Windows forms (except for the background image of a Pocket PC). Interacting with the form, setting properties, etc. all remains the same. That said; let’s get some things set up so we can write some code!

Some helpful advice

Alright – if you look at the screenshot below you’ll notice a few things have changed. To help illustrate the changes, I’ve added color coding to bring focus to the changes I’ve made.

The first thing I want to draw your attention to is the Yellow-Bordered box both on the form itself and the Form1 Properties window. This is where I’ve set the caption for my Pocket PC application. That in and of itself isn’t too much different than what you’d do with a Windows form, but one thing to keep in mind is that there is limited real estate for your entire app, to include the form’s caption bar which is shared on the Pocket PC by notifications. You’ll see as we progress with this project that my current choice of text for the form caption is not a good idea as the “Bill Splitter” part stands to be covered up by those notifications.

clip_image010

A Mini-Rant about Smart Minimize

The next thing I’ll point out is one of my standard modifications I make to most Pocket PC applications I build. If you look at the Green-bordered box around the “OK” button in the top right corner of the Pocket PC form and the Form 1 properties window you might wonder “OK, what’s the big deal?” Microsoft has very good reasons for making the default action of a Compact Framework application to be “Smart Minimize versus closing the application outright, but my biggest gripe with it has always been the fact they use an “X” to denote “Smart Minimize” in the Compact Framework while everyone who’s used to WinForms knows that “X” is “Close”. Enough with my mini-rant, if you want to read more about “Smart Minimize versus Close” then check out the following blog entry on the Windows Mobile Team blog called “The Emperor has no Close”.

The reason I chose to override Smart Minimize and force a form closure is because the apps I’m building are mostly for entertainment purposes…not exactly something that needs to be running all the time waiting around to be disposed. That said – at least now you have a better idea of what’s going on with that and why I made the choice I did.

The Big Red Panel

Another item that stands out in the screen above is the big red rectangle at the bottom of the form. Let’s take a closer look at this in the IDE screen shot below:

clip_image012

The size is exactly 80 pixels high which also (not by accident!) happens to be the size of the SIP (Soft Input Panel) when it’s activated and visible on screen. The reason I put the “Big Red Panel” in place is to remind me of that when designing the form in the IDE so as not to place controls there which would be hidden by the SIP when active. It’s a lazy way around the problem in reality, but again for the type of application this is, it works just fine. See the screenshots below to compare having the SIP hidden and then active (also a live shot of a production app after the big red panel):

clip_image014 clip_image016 clip_image018

Of course two things are worth noting here…

1) When I’m done with development and ready to deploy the project I get rid of the “Big Red Panel” and replace it with something else, usually a banner of something else that isn’t critical to the program operation (see above).

2) This is just a simple hack, what I should be doing is to resize/and or re-position my controls as needed.

What brought about this in the first place? When I first read the Microsoft guide to getting your software “Windows Logo Certified” this was one of the requirements, that nothing could be blocked by the SIP when active. I’m a long way from being “Windows Logo Certified” but this little tidbit of info stuck with me.

Finishing the “Template”

At this point we have our basic form layout finished. We’ve chosen to override Smart-Minimize and we’ve created our “Big Red Panel” SIP placeholder. Something you might do at this point is save the project, close it all and copy the project folder to a new folder named “Pocket PC Project Template” (or something similar) and even go as far as to ZIP that new folder so that in the future it’s easy to get started with future Compact Framework project. I’ve actually saved off several such “template” folders for different development needs which I can pull out as needed. Is this a hard and fast requirement to be an effective Compact Framework developer? Nah – but it sure has helped me out since I’ve been doing it.

Section 3 – The Visual Interface

Working with limited screen real estate

We’ll finish off adding the visual elements to our form before we plug in the code. In all actuality this is the exact same as you’d do for a Windows Forms project, just find your control, drag-n-drop it on the form and then set properties on it. OK – so the purists out there are saying that I’m leaving something out…well yes. You’ll notice that because this is the Compact Framework that there are some controls missing, but for our purposes right now, we have everything we need. The screenshot below illustrates the project with the rest of the visual elements added:

clip_image020

As you can see we’ve simply added an image, a few label controls, a text box, a button and a few numeric up-downs. The reason this is worth mentioning is because after we cover this next part you can go to a Windows Forms app and add the same items with the same names and you’ll see the code work just the same!

Part 3 – Core Code

Section 4 – Just some math

Main Code Listing (in VB.NET)

Let’s get to the code! See the code screen shot below for what we’ll begin working with:

clip_image022

Alright – a few disclaimers about the code…could it be written better? Sure. I went for readability here versus elegance. So let’s focus more on function versus fashion for the time being J

Wiring the button

Once you plug that code in and call the sub from the Button_Click event you’ve got a functioning application! That wasn’t so hard was it? Of course not…and now you have a basic functioning Compact Framework application. Wasn’t that more fun than “Hello World”? I thought so too. One of the things I encourage you to do is to go ahead and test this same code in a WinForms application, after all it’s just a simple math operation after all.

The main reason I picked this application to illustrate basic development under the Compact Framework is because of what I mentioned at the start of this article. I’ve had developers come to me after I’ve given a presentation on Compact Framework to either a user group or a Code Camp audience and they’ve told me they thought developing these projects were much harder than I’ve made it out to be here. Does that mean I’m trying to say that developing real world applications for the Compact Framework will be easy? Nope. We’ve got resource constraints, chief among them processing power, network connectivity, screen real estate and user input methods to contend with if you want to develop an elegant and functional mobile application. What I hope to accomplish by providing this information is to show how easy it is to get started and also show you some of the things I’ve discovered along the way that will hopefully get you thinking about ways to tackle these problems as they relate to your development projects.

Section 5 – This program sucks, let’s improve it.

Making our program more user friendly

Let’s look next at how we can improve this project to make it a little more bearable for users other than ourselves. For example, if someone enters the numbers in the Meal Cost box using the SIP, then shouldn’t it auto-hide when they hit “Calculate”? What about going a step further and hiding the SIP if/when they hit the ENTER key on the SIP? These are perfectly valid operations and along the lines of the type of thing you might handle on a web form or Windows form so it makes sense to handle these here as well.

Additionally what happens if the user wants to figure changes in the tip by toggling up or down the Tip Percentage number? What about if the guest split option changes? For example if there are four in the party and then one person says they’ll pick up another person’s tab? Now the four becomes three. Shouldn’t our application handle these changes on-the-fly without requiring further clicks or input after toggling the up/down options? Good – I’m glad you think so because you can call it feature creep if you want, but that’s what we’re doing next!

Here’s the functionality we’re going to add:

  1. Auto-Hide the SIP when ENTER key on SIP is pressed
  2. Auto-Hide the SIP when “Calculate” button is pressed
  3. Auto-Convert the display of “Meal Cost”, “Tip Amount”, “Price per Guest”, and “Total Meal Cost” to currency format.
  4. Auto-Recalculate “Tip Amount”, and “Price per Guest” when the Tip Percentage number is toggled either up or down.
  5. Auto-Recalculate “Tip Amount”, and “Price per Guest” when the “# of Guests” is toggled either up or down.
Implementing the changes-Auto Hide the SIP when ENTER key is pressed

The first change we’ll tackle is Auto-Hiding the SIP when the ENTER key is pressed on the SIP. This is basically going to improve the user experience and get the SIP out of the way when we presume it’s no longer needed, (i.e., they’ve finished entering information).

Those of you who have been programming any length of time may recall capturing such events are rather easy – perhaps the thought of interacting with this SIP has you wondering if it’s more complex. The simple answer is “no”. Check it out:

 

image

First the public function to convert the key pressed into it’s ASCII number and then wire the text box key-press event to watch for the ENTER Key (ASCII 13).

Now some of you might be thinking – “Hey where’s the SIP code there?” – I confess…I got sneaky and introduced another “fix” by handling the SIP Hide as part of my TipCalc sub. If you noticed in the VB.NET code listing previously there was a Sip.Hide line of code commented out. Here’s the block of code that handles hiding the SIP:

 

image

This way of hiding the SIP is purposefully more “complex” than it needs to be because this was also part of me learning how to use PInvoke, (Platform Invoke) which is how you can call Win32 or unmanaged APIs using the .NET framework (which is of course, managed code).

A lesson I learned from a goofy mistake I made

The simpler way to handle this would have been to drop an InputPanel control on my form and handle hiding and showing it (along with resizing the form, etc.) via code that way. Way back when I was first experimenting with the Compact Framework and reading about increasing performance by limiting the number of controls you load on the form, I thought to myself “Great – I can have one less control by using PInvoke instead of dropping the InputPanel control on my form” Those of you who know better are laughing right now because you know (as I have since learned) how expensive PInvoke is! In any case this was my first introduction to PInvoke and I’ve included it ever since as a short and simple way to introduce others to it. Would you use this in a real world application? Probably not. But hopefully you’ll take away the basic concept and do some additional research on your own to determine if and when PInvoke might be a good idea for your application. Also - since you brought it up, now’s a good time to look at the PInvoke sample we’re using here.

A Gentle Introduction to PInvoke

I mentioned just a moment ago a little bit about what PInvoke is so let’s take a look at what it looks like in our code sample. Note that this is a separate class I’m using in my project. If you were going to use a lot of PInvoke code, it might make sense to build a class library of this stuff.

image

There is so much one could write about PInvoke, it could be a whole chapter or book in itself, much farther beyond the scope of this lesson. If you want to find out more you can get started by reading An Introduction to P/Invoke and Marshaling on the Microsoft .NET Compact Framework on MSDN. For some pre-written PInvoke signatures, check out the samples provided at http://www.pinvoke.net/

Implementing the changes-Auto Hide the SIP when CALCULATE button is pressed

The good news is that this change was implemented auto-magically when I decided to incorporate the SIP.HIDE functionality as part of the TipCalc subroutine. So hey – that was easy…every time the Calculate Button is pressed it’s wired up to call TipCalc() and the SIP goes away. Hurray!

Coming later – Packaging and Deploying your application…that’s all for now folks!

0wn ur phone - Taking back control of your mobile phone
15 February 08 12:43 PM | BrainThump | 2 comment(s)

It started out innocently enough – a phone call on my mobile phone while I was at work. Looking down I didn’t recognize the number…it was an 866 number. I hesitated and then answered it…ugh-how the heck is some telemarketer calling me on my mobile phone? I hung up but then later another 866 number called. I promptly hit the “ignore” soft-key and away my troubles went. Fast forward about 40 minutes and the same number calls me again. Ignore again and this time I saved it in my contacts list as “Annoying 866 caller” which had reminded me of a similar story I’ll tell you all about a woman in Ohio who kept dialing my number by mistake for months, but for now let’s get back to the problem at hand.

I started thinking about it and then it really bothered me…this is my cell phone after all so why can’t I control whether I want to be bothered by such calls? Well with Windows Mobile I can! This blog entry is going to cover the basics of call management with Windows Mobile using the State and Notifications Broker and Platform-Invoke.

Let’s lay a few ground rules first – to the best of my knowledge there does not exist a way to automatically (read that programmatically) reject an incoming call without any kind of notification to the user. I can live with that and work around that. My end goal in designing this project was to eliminate the need for me to deal with pesky toll-free numbers calling me on my cell phone…it was only after I completed this first iteration of the project that other ideas crept into my head and realized there’s a lot more that can be done to make my phone truly work for me…more on that later.

So since we can’t automatically reject the call, what’s left to do? Well looking at my normal actions I can break it down like this:

  1. Phone Rings – look at the incoming number displayed on my screen
    1. Is the number an 800 number? If so, press the “Ignore” soft-key and then acknowledge the “missed call” notification.

Since that’s a short series of manual steps, we can automate that and my life becomes easier again :)

Making friends with the State and Notifications Broker

If you’re developing software with Windows Mobile you don’t go very far before realizing you need to get acquainted with the State and Notifications Broker (SNB). The SNB gives you an incredible mechanism for storing and working with information related to state changes associated with your mobile device. I won’t re-hash what’s already been written about SNB – instead you can read about it on MSDN to get started. Here's the link: http://msdn2.microsoft.com/en-us/library/aa455748.aspx

The SNB plays a key role in our project because it is going to detect the presence of an incoming call and then retrieve the number of that incoming call. Once we have the number we’re just going to analyze it and then let it go through so I can answer it or programmatically press the “Ignore” soft-key and I won’t have to deal with it. So let’s take a look at the code we’re going to use for this.

I’ve set up a small sub called MonitorNotifications which is called when the form loads. This sub adds my phoneStatus System State Notification to an array list I’ve created (in case I later want to add more system state notifications to this project)

You’ll notice the SystemProperty I’m monitoring in this case is PhoneIncommingCall and I’ve added a handler for when that status changes.

VB Mobile - Monitor State and Notifications Broker

So what happens then in the event handler for ChangeOccured? Take a look below:

VB Mobile - State and Notifications Broker

Basically this just handles the logic for the phone call management. First we’re checking to see if I feel like ignoring all calls (via a check box on my form) and then we’re checking to see if the incoming call number is in my simple “block number” (a text box on the screen). If either of those conditions are true, then bounce the call with the BounceCall sub.

The BounceCall sub makes use of P-Invoke to programmatically press the “Ignore” soft-key that shows up on screen when an incoming call is present on your device. A full write-up on P-Invoke is beyond the scope of this article so take this as a starting point and learn from it…I’ll cover more about P-Invoke in later articles. Here’s the code we’re working with:

VB Mobile - P-Invoke to ignore calls

First we’ve defined two constants for use with our keyboard events. Then we use P-Invoke to handle the actual keyboard event. BounceCall simply does a programmatic “Key Down” and then “Key Up” on the appropriate soft-key.

Now that we’ve gone over the basics of the code involved let’s see the app in action.

VB Mobile Call Bouncer

Here we have the basic form up and running in our emulator. Notice my neat little bouncer guy – I thought it an appropriate graphic for the project!

Next fire up the Cellular Emulator tool (If you’re not sure how to configure this to work with the emulator, take a look at my previous article which details these steps) http://ilovevb.net/Web/blogs/vbmobile/archive/2008/01/07/vb-net-mobile-hello-world.aspx

Once you’ve got the Cellular Emulator running, place a call to the device emulator to see it show up on the screen as shown below.

VB Mobile Incoming Call

Notice the “Accept” and “Ignore” soft-keys present when an incoming call is in progress. Go ahead and Ignore the test call for now and then take that same number you just called with and put it in the text box on the form as shown below:

VB Mobile Ignore a Call

When you place the call this second time you may not actually notice anything in the emulator – but go ahead and click on the “Missed Call” notification icon in the top bar of your screen..you should see now two missed calls – the first one you manually did to test and the second one programmatically handled by our call bouncer as shown below:

VB Mobile Missed Calls

And the cool thing is with it working that fast in the emulator, imagine how fast it can act on your device! Unless I have my phone set to vibrate and it’s on some kind of hard surface, I don’t even realize that my call bouncer just rejected a call….it happens so quickly. What typically happens is that later in the day I notice a missed call icon and click to view it…sure enough there’s an 800 number there.

A few final notes about this project…

So what really happens when you programmatically press the ignore button on the phone? In my case, it drops the caller to voice mail – but the trick here is I purposefully do not have a voice mailbox set up on my account (I have one available, I just never set it up) so they just get a message saying that the current subscriber does not have voice mail configured – goodbye. In your case maybe you do have voice mail set up in which case you’ll likely get a voice mail notification later on.

Also – in this project I mention dropping “800” numbers which my phone does now. This example however limits it to just a single number in a text box to compare with versus using some kind of matching (hint: regular BLOCKED EXPRESSION for 800 numbers. I’m leaving that implementation up to the reader to figure out, grow and learn with based on the foundational knowledge I’ve provided here. Once you’ve hooked into the SNB and are handling a call, what you do with it is up to you.

Full source code for this example will be posted later…until then, give it a try setting this up on your own and let me know what you think about this article as well as what other future articles you’d like to see.

Oh - and about that lady from Ohio that called my phone repeatedly over the course of a few months. The first time she called I answered because I actually do have friends from Ohio who maintain their cell phone numbers there. When she asked for someone who I clearly do not know, I told her she had the wrong number and she called back a few minutes later. Same story - same wrong number. Annoyed I saved the number to my contacts list as "Ohio Wrong Number". A few days later I recognized the number calling me again and this time answered it "Ohio Telecom Wrong Number Department, How may I direct your call?" The rest of the conversation follows:

Her: "I'm trying to get in touch with Sara at (555) 555-1212 (number masked to protect the innocent)"

Me: "Sorry - you dialed (111) 111-1111 by mistake (my number masked so I don't have to add a bunch of you to my blocked call app!). To get in touch with Sara you'll need to hang up and dial (555) 555-1212

Her: "OK thanks!"

And then I wondered how long before she'd catch on to the flaw in that whole transaction. In any case - she never did catch on. Over the next few months she occasionally continued to call and I would continue to answer as the "Wrong Number Department". Occasionally I would be with friends when she would call and I'd have them answer as the "Wrong Number Department" too. Sometime late last year she finally stopped calling me. Now I just have her in my call block list for this app on my phone!

Hello World SMS Source Code posted
15 January 08 01:14 PM | BrainThump | with no comments

The source code for the Hello World SMS article I had written last week has been posted here: http://ilovevb.net/Web/files/folders/vbmobile/entry71.aspx

Enjoy!

VB.NET Mobile – Hello World!
07 January 08 09:59 AM | BrainThump | 5 comment(s)

Hello all – welcome to the first installment of my VB.NET Mobile Blog…the blog that focuses totally on what VB.NET can do on Windows Mobile Devices. Since it’s a developer blog we’ll start out with the ubiquitous “Hello World” but we’re going to do it with a Windows Mobile twist.

It would be fairly pointless for me to do a simple “Hello World” with a button click that pops up a message box or populates a text box with “Hello World” for VB.NET in Windows Mobile since the same code works in VB.NET on the full framework. So rather than do that we’re going to send ourselves an SMS Message that says “Hello World” – what more fitting way to get right into Windows Mobile specific programming than that since SMS seems to be everywhere.

Before we dive into things any further – a couple of notes about the development environment setup you’ll need…if you’re confident you’re already set up and ready to go, humor me and re-read this section anyway, ok?

First off you’re going to need either Visual Studio 2005 Professional (or higher) or Visual Studio 2008 Professional (or higher). Compact Framework isn’t supported in the Visual Studio Express versions…sorry. If you don’t happen to have either of those, or an MSDN Subscription why not check out your local user groups, and Microsoft-centric developer community to see if there are either upcoming Code Camps or User Group meetings. In events I’ve attended in the past I’ve been fortunate enough to give away Not-For-Resale editions of Visual Studio Professional as prizes at those events. You may also find a “Visual Studio Install Fest” going on in your area (or an area worth driving to) where a limited number of users can receive free NFR copies of Visual Studio just for showing up! Just another reason to get involved and stay active in your developer community!

Once you’ve installed Visual Studio (professional or higher), you’re going to need the Windows Mobile 6 SDK’s. You can download both of them using the link below:

One thing worth noting – if you happen to have Visual Studio 2005 with the Windows Mobile SDK’s installed and you later decide to install Visual Studio 2008, read my GeeksWithBlogs entry first – it may save you a bit of a headache.

For the purposes of this article – I’m using Visual Studio 2005…but it should work fine in Visual Studio 2008 as well.

Once you’ve gotten everything set up, launch Visual Studio and create a new Device Application. This will be found under Smart Device->Windows Mobile 6 Professional as shown in the screen shot below:

Starting a new device project

When you’re done with that, go ahead and make your device application form look similar to example I’ve created below (I’ll provide a download of the solution later!)

Laying out the device form

As for the code to wire-up this form, it’s very simple as you’ll see. To send an SMS Message we’ll first need to make reference to the Microsoft.WindowsMobile.PocketOutlook namespace. After that it’s as simple as creating a new instance of the SMSMessage class with an overloaded constructor passing in the Recipient phone number and Message text, then invoking the Send method…takes a look at the code below:

Imports Microsoft.WindowsMobile.PocketOutlook

Public Class Form1

    Private Sub btnSMSSend_Click_1(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnSMSSend.Click

        Dim VBMobileSMS As New SmsMessage(Me.txtSMSTo.Text, Me.txtSMSBody.Text)
        VBMobileSMS.Send()

    End Sub

End Class

In order to make use of this example we’re going to either need a Windows Mobile 6 device to deploy it to (and I realize not everyone has one yet) or we’re going to need the emulator set up with one of the tools…in either case it’s a handy thing to know how to use the tools included with the SDK so we’re going to focus on that now.

You’ll need to launch the Cellular Emulator tool which should be found under Start->Program Files->Windows Mobile 6 SDK->Tools->Cellular Emulator (if you did a standard install). Go ahead and launch that tool. It should look like this when it starts up:

Cellular Emulator Startup

In the bottom left status bar on that window you should see a COM port number – you’ll need to make note of that so you can configure the Windows Mobile device emulator to “talk” to this emulator. In this case we see COM4 is being used. Click the CONFIGURATION Tab and then click the RESET button before launching the Vis

Go launch Visual Studio and open up your project again and do a test deployment to the emulator (I’ve picked Windows Mobile Professional Emulator) and you’ll need to configure this emulator to work with the Cellular Emulator. To do this click File->Configure and on the Emulator Properties window that shows, click on the Configure tab and enter your COM port info in Serial Port 0 as shown below:

Windows Mobile Emulator Config

Once you’ve configured it all properly you should see the emulator with an “active” connection as shown below:

Windows Mobile Emulator ready for use with Cellular Emulator

If all is configured properly then let’s do a build on the project and deploy it to the emulator to test it. You should see a result like the screen below when it’s first run in the emulator:

Deploying the app

Once you click the SMS Send button you should see a screen similar to the one below indicating you’ve received a new SMS Message:

Our Hello World SMS!

If you look over to the Cellular Emulator window on the SMS Tab you should see a record of your message passing through the emulator as shown below:

Cellular Emulator view

From that window you can also type a message in the “Send to device” window and click Send to send a message straight to your Windows Mobile 6 emulator from the Cellular Emulator.

And there you have it – a not-so-typical “Hello World” in VB.NET for Windows Mobile Devices using something very specific to Windows Mobile!