MS messaging is one of the most popular means of communication means in this new digital age. While SMS is best suited for asynchronous communications, it's recently being increasingly used by many as a chat tool. Rather than viewing the series of related chat messages linearly (see left of Figure 1
), using the built-in Outlook Mobile, a better way to chat is to represent them visually, complete with the photos of the recipient (if available).
|Figure 1. Linear vs. Visual: Representing SMS messages.|
This article demonstrates how to build a SMS chat application (see right of Figure 1) that allows your SMS messages to be represented visually. You will learn:
Creating the Application
- How to create a user control
- Intercept incoming SMS messages using the .NET Compact Framework
- Send SMS messages using .NET Compact Framework
- Add controls dynamically to a Panel control
- Retrieve information about users from Contacts
Using Visual Studio 2005, create a new Windows Mobile 5.0 Pocket PC application and name it as SMSChat.
In the default Form1, add the following controls (see also Figure 2):
|Figure 2. The Default Form1: Populating the form with the various controls.|
The Panel control will act as a container to display the chat messages sent by yourself and the sender.
If the sender's mobile number is:
- Already in your Contacts and has a photo attached to it, the photo of the sender will be displayed.
- Already in your Contacts but has no photo attached to it, the name of the sender will be displayed.
- Not in your Contacts, the phone number of the sender is displayed (assuming you have subscribed to the Caller ID service; check with your Telco).