# Friday, July 06, 2007

.NET Micro Framework Book on special offer

Rob Miles has just blogged that his book "Embedded Programming with the Microsoft .NET Micro Framework" is currently on special offer at Computer Manuals through the MSDN Flash email newsletter. So if you have a wobbly table, or a door you want to prop open now is the time to buy (just kidding) :-)

For exactly the same reasons you might want to grab the Mobile Development Handbook at 32% off. Alternatively if you just want some fun browsing the site then why not enter "Windows CE" into the quick search box. The only result is "The Johns Hopkins Manual of Gynecology and Obstetrics" an ideal addition to any mobile developers toolbox!

Finally on a related note I spotted that Doug Boling is working on an update of his Windows CE book due out in October - "Programming Windows® Embedded CE 6.0 Developer Reference". Definitely worth adding to your wish list, even if you are primarily a managed code developer as it is important to know your way around the underlying OS.

#    |
# Monday, June 25, 2007

Guid.NewGuid Performance

João Paulo was investigating Guid performance when used as identifiers in a SQL Compact database and discovered that the performance of Guid.NewGuid() left a lot to be desired. The reason for this is that the function uses lowest-common-denominator support, using a random number generator and setting a couple of specific bits to conform to guid standards. Another method I've been recommending for some time is to use the native CoCreateGuid() function - see http://www.peterfoot.net/NeedAGUIDInAHurry.aspx. This method is supported in all devices running Windows Mobile 2003 and above, and in Windows CE 4.x. I've been using it in the InTheHand.Guid2 class in Mobile In The Hand (Will be renamed to GuidHelper in the next version). I did some tests creating 100,000 guids in a row with both methods. Guid.NewGuid() took 139 seconds, and GuidHelper.NewGuid() took a mere 9 seconds. As you can see that is quite a significant difference.

#    |
# Tuesday, June 19, 2007

Motorola Game Developer Challenge

Fancy yourself as a mobile game developer and want to win loads of Motorola kit? If so the Motorola Developer Network (MOTODEV) have a game development contest for you! There are categories for both Java and Windows Mobile games, for Windows Mobile you could choose to write in native or managed code. It would be cool for the winning game to be written with the Compact Framework of course. The deadline is the 10th of August, full details are available here:-

http://developer.motorola.com/eventstraining/gamechallenge/

#    |
# Wednesday, June 13, 2007

Microsoft Mobile Development Handbook at DevDays 2007

Rob Miles, a fellow MVP who wrote one of the chapters for our book has grabbed a copy at DevDays in Amsterdam, you can see a picture of him proudly clutching the book in his latest blog post. In case you need any further encouragement to purchase the book beyond the 600+ pages of technical stuff, you'll notice from Rob's picture that carrying the book is also great for attracting a posse of female admirers :-)

I travelled home yesterday to pick up my first copy of the book, it's such a great feeling seeing the finished book after all this time. This was actually the first opportunity I got to read Rob's chapter properly. As a guru of graphics and games development it's no surprise that Rob does a great job of explaining Direct 3D Mobile.

#    |
# Monday, June 04, 2007

Windows Mobile Standard Landscape Shortcut Keys

On a traditional Standard (nee Smartphone) device the start-menu items are arranged into a 3x3 grid, you can navigate these quickly using the numeric keypad. On a landscape device the items are arranged in a 4x2 grid so this is impractical. Instead the QWERTY keys are used, or to be exact:-

Q W E R
A S D F

Another helpful feature which was introduced in one of the AKU updates to Windows Mobile 5.0 was a scrollbar so that scrolling off of the current page of menu items would advance to the next or previous screen of items (Equivalent to pressing soft-key "More" or Back button). The scrollbar give you a visual indication of where you are within the menu items which typically span 5 screens in landscape orientation.

One part of the shell which has not received the same attention is the Settings screens. Unlike the Start Menu there is no scrollbar, you must advance to the next screen using the last list item (this is not offered as a soft-key item). This means that in landscape orientation only 6 settings items fit on a page. A few changes here would allow more items per screen and consistency with the start menu behaviour. On devices with a built in scroller such as the HTC S620, T-Mobile Dash etc you could quickly scroll through all the configuration items.

Another place where this behaviour is not followed is the Pictures & Video application. Here the items are again arranged in a 4x2 grid on a landscape device however the key assignments are really wacky:-

1 2 3  
4 5 6  

You can see that the application is hard-coded to use the numerical keys and so there isn't a shortcut to select the righthand column.

These help to illustrate another area where developing for multiple screen sizes and layouts can introduce complications. You should try to follow best practices to offer appropriate shortcut keys in your application, just be aware that even Microsoft have missed some of these issues in the platform itself.

#    |
# Monday, May 28, 2007

Practical .NET 2.0 Networking Projects

Fellow MVP Wei-Meng Lee has finished a book on building applications with a range of networking technologies using .NET, both on the desktop and on devices. This covers the fundamentals of Sockets and Serial programming and contains a number of interesting projects incorporating webcams, fingerprint readers, RFID and GPS receivers.

The section on Infrared programming shows how to use the System.Net.Irda assembly in the Compact Framework and goes on to show how you can use exactly the same techniques on the desktop using the 32feet.NET library.

So far it's been a fun read and I'm looking forward to trying out some of the projects just as soon as I find my fingerprint reader!

#    |
# Monday, May 14, 2007

Waiting for a Process

There have been numerous occasions where I've needed to write code to launch another process and wait for it to complete, usually taking some action based on the exit code. Therefore I've got a handy helper method to do this. It has changed a few times and is made much simpler in .NETCF v2.0 by taking advantage of the Process class. Most recently I used the code in one of the book chapters to show automatic installation of the Microsoft Message Queue (MSMQ) components onto a Windows Mobile device. The method is named ShellWait, as the name implies it launches a process and waits, the return value is the exit code from the process. If the application doesn't exist it returns -1 immediately.

[C#]

//helper function to launch a process and wait for the result code
private static int ShellWait(string app, string args)
{
   if (!File.Exists(app))
   {
      return -1;
   }


   Process p = Process.Start(app, args);
   p.WaitForExit();


   return p.ExitCode;
}

 

[VB]

Private Shared Function ShellWait(ByVal app As String, ByVal args As String) As Integer
   If Not File.Exists(app) Then
      Return -1
   End If

   Dim p As Process = Process.Start(app, args)
   p.WaitForExit()

   Return p.ExitCode
End Function

#    |
# Friday, May 04, 2007

Fabien Decret is now blogging

Fabien is a French mobile developer who regularly posts answers to the Compact Framework newsgroup. He has started blogging and already posted on a number of Windows Mobile and Visual Studio topics in both French and English. You can view Fabien's blog here:-

http://fabdecret.blogspot.com/

#    |
# Tuesday, May 01, 2007

New Sounds sample in Windows Mobile 6 SDK Refresh

The Windows Mobile 6 SDK Refresh is available today. It includes some documentation enhancements and new samples. One of these is called RingtoneManager and is a C# application which wraps all the Sound APIs for ringtone management and sound playback, the latter of which were introduced with Windows Mobile 6. This is great because it gives you all the P/Invokes etc you need to use this functionality yourself. However expect to see these Windows Mobile specific APIs in the next version of Mobile In The Hand.

#    |
# Friday, April 27, 2007

Book done, MEDC next!

We've finished all the writing for the book, and it's now winging it's way to the printers. This week I finished converting all my sample code to Visual Basic so that we'll have two versions of all the sample code in the book. I have to thank all of the people behind the book, the team at MS Press and my fellow authors for making my first writing experience such a pleasant one. I'm eagerly looking forward to seeing the finished book later in May. Just when I thought it was safe to kick back and relax I'll be off to Las Vegas for MEDC 2007 on Monday.

This years event promises to be a great one - lots of content on Visual Studio Orcas, .NETCF 3.5 and a refreshed version of the Windows Mobile 6 SDKs. I'll be taking part in one of the panel discussion session, along with my fellow authors, members of the .NET Compact Framework team and OpenNETCF. The session is on both Wednesday and Thursday so you should find one to fit your schedule.

I look forward to seeing you in Las Vegas!

#    |
# Tuesday, April 03, 2007

Deprecated APIs in Windows Mobile 6

Over on the Windows Mobile Developer Wiki is a topic listing all the APIs and technologies which are deprecated in Windows Mobile 6. This is essential reading for any Windows Mobile developer:

http://channel9.msdn.com/wiki/default.aspx/MobileDeveloper.DeprecatedFeaturesInWindowsMobile6

#    |
# Friday, March 30, 2007

Determine Version of Connected Device

When your device is synchronised with ActiveSync (or Windows Mobile Device Center in Windows Vista) a number of device properties are written to the registry. This allows you to gather information on the device during a custom installation or from a desktop application. One of these properties is the version number of the device, the exact key is:-

HKEY_CURRENT_USER\Software\Microsoft\Windows CE Services

The version is stored in a DWORD value called "DeviceVersion", its contents look like this:-

0x1560105

As raw bytes it would be {0x5, 0x1, 0x56, 0x1 }. The first byte represents the major version number, the second is the minor version and the last two bytes together are the build number e.g. 0x156 = 342. Putting that all together shows that my connected device is returning version:

5.1.342

Which is exactly what I can see on the Settings > System > About screen for the device (which is a Pocket PC running Windows Mobile 5.0 AKU 3.0).

#    |
# Monday, March 26, 2007

TomTom In The Hand 6.1

I've been a bit quiet over the past few weeks, on vacation and at the Microsoft MVP Summit. I've also been working on the TomTom In The Hand library and today have released a new version.

It turns out that TomTom SDK 6 shipped with a known bug that prevents you from passing negative co-ordinates into any of the methods (returned values were okay). At the moment I believe that our library is the only one which has a fix for this bug which was a major headache for developers. You can now use TomTom through this library wherever you reside in the world (assuming you have map coverage of course) without making any changes to your existing code.

This release also adds some new functionality - The RawGpsReceived event on the Navigator object allows you to receive NMEA data from TomTom which allows you to share this data if you are not already using a multiplexer such as the Windows Mobile 5.0 GPS service or Franson GPS Gate or similar.

#    |
# Friday, March 09, 2007

Personal Area Networking in the Delphi Magazine

John Penman has written an article in the March edition of Delphi Magazine entitled "Simple Wireless Networking with Delphi for .NET" which describes using the 32feet.NET library from Delphi code. It walks the user through each of the areas of functionality in the library: IrDA, Bluetooth and Object Exchange. Its written for the v1.6 version, but the object model in the latest v2.1 version is a superset so the code will work with the latest version.

#    |