Smart phone is a very versatile device that runs Windows Mobile 2003, and devices running the latest version,
Windows Mobile 5.0 are expected to start appearing in July in the international market. Since both WinMobile 2003 and 5.0 run a scaled down version of Windows, they are fully capable of running the .NET framework as well. Microsoft had already planned for running .NET on devices right from the start. That's why a parallel track called the .NET Compact Framework (.NETCF) was made available for installing on devices and VS.NET has
supported developing, deploying and debugging smart phone applications. Let's take a look at what VS.NET 2005 Beta 2 supports for such applications.
To create a new Smartphone 2003 application, select File>New Project>Language>Smart Device>Smart Phone 2003>Device
Application. When the new project starts up, you will see, not the usual form designer grid, but instead an actual representation of a smart phone device on screen-along with all the soft key buttons, navigation joystick, home and end keys and the numbers keys.
|
The main screen area shows up a default Form which can be used to start creating your application. A main menu control that lets you create a soft-key menu for the cellphone. Select the menu control and start typing into the menu created in the screen area. Of course, as in
any smart phone application, you can have only two top level menu choices-one for the left and one for the right soft keys.
The toolbox in Visual Studio lets you drag and drop a number of controls onto the Form. The controls are most of the standard ones, such as textbox, combobox, checkbox, scrollbars, etc. You can drag and drop the controls into the form and double click them to
create event handlers for each of them.
|
But how do you trap a hardware event-such as a number or special button on the cellphone being pressed, or the navigation
key being used to move up, down, left, right or clicked? For this, VS.NET creates a default handler for the Form's keydown event and populates it as follows.
Private Sub Form1_KeyDown(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If (e.KeyCode = System.Windows.Forms.Keys.F1) Then
'Soft Key 1
'Not handled when menu is present.
End If
If (e.KeyCode = System.Windows.Forms.Keys.F2) Then
'Soft Key 2
'Not handled when menu is present.
End If
.
.
.
If (e.KeyCode = System.Windows.Forms.Keys.F9) Then
'#
End If
End Sub
You can now easily write code for handling the key you wish to capture. As you can see, writing code for a smart phone device is extremely simple. With Visual Studio 2005, you can also debug the application without deploying it to a real device by simply running the application and selecting the device emulator to use.
Vinod Unny, Enterprise Info Tech