# Wednesday, December 15, 2004

New in .NETCF v2.0

Jono posted a link to a new section in the online Beta documentation at MSDN which describes in some detail whats new in v2.0 of the Compact Framework. This includes new framework features and a list by namespace of the new classes introduced in v2.0.

 

#    |
# Monday, December 13, 2004

System.Net.IrDA for the desktop (Part 2)

Following my previous post, I did some further development to the code to make it fully match the .NETCF assembly (yes, in my haste I'd missed a few properties and cut a couple of corners). So now I have compiled a System.Net.IrDA.dll assembly which has exactly the same classes and methods as is available in device projects. So you can easily move device code over to Tablet and laptop PCs.

Download the DLL here (zip 7kb)

The package includes just the dll and xml documentation. The next task for the project is to build an installer for both the source and binaries...

This was a useful learning experience since I've based the Bluetooth code on the existing model of the IrDA library, so it was useful to spend some time studying this particular library and the classes it contains.

The functionality is now part of 32feet.NET a library for personal area networking for .NET. The downloads are here:-

http://inthehand.com/files/folders/releases/default.aspx

#    |
# Thursday, December 09, 2004

System.Net.IrDA for the desktop

Following on from a question which cropped up on today's MVP chat. I did some investigation into IrDA support on the desktop framework. Turns out you can't use System.Net.IrDA.dll from .NETCF on the desktop as I had read on some blog, but since the basic Socket class supports the IrDA address family, it is necessary to build a couple of helper classes for the IrDAEndPoint and IrDAClient and IrDAListener to match the .NETCF implementation. I built these rather hastily and therefore have omitted a few overrides and non critical items. I intend to flesh this out later to fully match the .NETCF class. However the code zipped up below will give you the classes necessary to migrate your .NETCF IrDA code to the desktop. It was tested using the sample code in the .NETCF Quickstart on the subject to Discover my Pocket PC and send it a file. When I get the chance I'll compile it into a System.Net.IrDA.dll, for now you'll have to make do with C# source, and I didn't really stop to write comments this evening - sorry :)

Download Source

#    |

Online Bluetooth code updated

There were some recent enquries on the OpenNETCF Forums about the current Bluetooth code. It seems I had refreshed the website with some development code which would only work if a couple of items were commented out. This is because these classes (Sdp related) are still under development and require COM interop and are currently built against InTheHand.Interop.dll which does COM interop with no native DLL required, and is used in my PocketOutlook and ADOCE products.

So I've updated the code online and attached a .zip of the project below which will build successfully against the v1.2 SDF (and the compiled dll is included in the bin folder). Documentation is in the online library at http://32feet.net/library/

I'm working on a sample application to accompany the library, but it's been tested with a Bluetooth GPS unit and a Jabra headset successfully (Before you ask it only uses the control functionality of the headset, not the audio stream). But you can programmatically make the headset ring and capture the event when the user presses the answer button. Not terribly exciting but an interesting start, I guess I need some more unusual Bluetooth devices to test against.

What isn't working in this release is the ability to host a service and allow other devices to discover it, since this requires some of the ongoing Sdp work. Once this is in place you will be able to do data transfer between devices which is when the fun will really begin!

Also bear in mind this is designed to work only with devices with the Microsoft Bluetooth stack, for example HTC Phone Edition devices and most Smartphone 2003 models.

Downloads

#    |
# Saturday, December 04, 2004

Forms Anywhere built around OpenNETCF Smart Device Framework

Via Jono's Blog:-

'Forms Anywhere is an attempt to provide a development platform for data capture using the Pocket PC. It handles all data collection tasks from creation to capture, all that is needed on the back end is the code to integrate your application.'

The code for Jim Lavin's Forms Anywhere is available in a GotDotNet workspace. The project uses OpenNETCF's Smart Device Framework for missing controls such as the DateTimePicker and the Desktop Communications library to implement desktop synchronisation. An impressive project, well worth a look.

#    |

Using OpenNETCF.Phone.Sms

Dag König has posted an example to his blog showing how to add Sms sending to your application using the OpenNETCF.Phone.Sms class and just 4 lines of code - check it out.

#    |
# Wednesday, December 01, 2004

New version of .NETCF GDI+ Library

XcrossOne Studio have just released a new v1.2 release of their incredible looking GDI+ library for .NETCF. A key change in this release is a switch to a Shared Source license, similar to what we use with our OpenNETCF projects.

This means that you are no longer restricted to releasing any works using the code in source form, this should have a dramatic effect on the number of people able to use the library. You can achieve some pretty impressive visuals, as demonstrated in the large gallery of samples on the site. This latest version adds the ability to combine raster images and anti-aliased text with the vector based drawing.

#    |
# Saturday, November 27, 2004

CLS Compliant WaitForSingleObject

Maartens recent blog post highlighted an issue with the current SDF implementation of Core.WaitForSingleObject when used from VB.NET since this method was not CLS Compliant and used unsigned integer types for both parameters and return type. Because of the values used by this function its very easy to convert it to be CLS compliant, so from the next release you'll be able to call it just as easily from both C# and VB. The method only accepts a timeout value up to 0x7fffffff which incidently is the maximum positive value for an Int32. The exception to this is a special constant passed when you want to wait indefinately on a handle - 0xffffffff which just happens to be -1 when interpreted as a signed integer. The same transformations are posible on the Wait enumeration which is the return type for the method. The amended code is already up on the online source browser. Therefore to wait with a 1s timeout on a handle in a loop you can now do this from VB:-

While WaitForSingleObject(myWin32Event, 1000) <> Wait.Object

            'do stuff here

End While

#    |
# Monday, November 22, 2004

Toggle Bluetooth on an iPaq device

We can already enable and disable Bluetooth on devices equipped with Microsoft's Bluetooth stack. In the case of iPaq devices, which use the Widcomm stack, it is possible to toggle the radio state using an API provided in HP's iPAQUtil.dll. This can be P/Invoked from a .NETCF project like so:-

[DllImport("iPAQUtil.dll", SetLastError=true)]

public static extern bool iPAQSetBlueToothRadio(ref int lpdwValue);

Which you can then call with:-

int val = 0;

iPAQSetBlueToothRadio(ref val);

Where val is either 0 to disable Bluetooth, or 1 to enable it. Tested on an iPaq 2210 but should work on any other iPaq device with Bluetooth.

Update:-

The following should also work for devices with WiFi built in:-

[DllImport("iPAQUtil.dll", SetLastError=true)]

public static extern bool iPAQSetWLANRadio(ref int lpdwValue);

But I've not been able to test this myself.
#    |
# Friday, November 19, 2004

From the Mobility Road Show

Thom Robbins posts some Powerpoint slides and code from the recent Mobility Road Shows. Check out "Mobility and Visual Studio 2005" for a good overview of NETCF 2.0 development features.

#    |
# Saturday, November 13, 2004

Hosting a Native Windows Control - The desktop approach

As a follow on to my recent article, I have compared and contrasted the System.Windows.Forms.Control classes in desktop and compact frameworks.
#    |
# Tuesday, November 09, 2004

Hosting a Native Windows Control - Live on MSDN

My latest .NETCF article is now live in the MSDN library. This is an update of the control hosting article previously published here at OpenNETCF.org. The process has been simplified so that there is now a standard base class (ControlEx) which does most of the hard work for you, the process of hosting a control is therefore much closer to the desktop experience. The article contains a sample using the WebBrowser control, which shows not only setting properties and calling methods for the control, but also reacting to notifications from the native control.

#    |
# Thursday, November 04, 2004

Virtual Bob

Virtual PC is a great tool when testing and developing as you run multiple OS versions and configurations on a single machine. However Ben Armstrong has found a more unusual use for Virtual PC - to run Microsoft Bob, the short-lived home oriented shell around windows 3.11 / 95. See the full story including nostalgic screen-shots here on Ben's blog.

#    |
# Tuesday, November 02, 2004

Open All Hours

Sometimes you want to ensure that the system will not automatically close down your application when it goes into the background. You can achieve this by handling the Closing event of your main form, the event arguments passed to your handler will allow you to Cancel the close. Therefore you can set a boolean member to ensure that the operation only succeeds once you decide it's okay to close:-

bool keepopen = true;

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)

{

   if(keepopen)

   {

      e.Cancel = true;

   }

}

 

Then based on some pre-determined action in your program you can set keepopen to false and the form will close down.

#    |

The Naked Emulator

If you want to display the standard Pocket PC emulator without the regular skin, so just the screen itself is shown you can modify a couple of the settings files and skin bitmaps. For the default Pocket PC 2002 emulator you'll find the files here by default:-

C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\ConnectionManager\Bin\Images\PocketPC\2002\1033

Make a backup before you alter anything!

Then replace the ppc2002.xml file with this one. Finally add this image to the folder which is the null skin, necessary in order that the emulator window is sized correctly. The finished result should look like this:-

 

Naked Emulator
#    |
# Friday, October 29, 2004

Great Installation advice on the Smartphone Developer newsgroup

Lars Peter recently posted this excellent post on the microsoft.public.smartphone.developer newsgroup.

In the post Lars describes using Nullsoft Installer (NSIS) to build a desktop installation package to include multiple cab file installations. This is ideal for those scenarios when you want to deploy more than just one application cab file, for example OpenNETCF's Smart Device Framework, Sql Ce or the .NETCF runtimes themselves.

Lars' post includes a sample install script, which you can pass a number of cab files for installation. You can also download the sample script from Lars' server.

Nice one Lars!

#    |
# Wednesday, October 20, 2004

Orange SPV C500 ROM Update - Go get it!

Spotted over at MoDaCo, Orange have released an updated ROM which fixes the GAPI issues on the device and a few other fixes:-

  • Videos can be sent via MMS
  • Flickering issue in games has now been fixed
  • Packet video full screen mode and backlight fix
  • Improved memory management of the camera and video applications
  • Improved browsing/upload speed (changed from GPRS class 8 to class 10)

It's a 22mb download from Orange's website

#    |

Need a GUID in a hurry?

There may be times in your application you need to generate a new unique Guid. The System.Guid class in .NETCF v1.0 doesn't have the NewGuid method which is what you would normally use on the desktop. There are a couple of proposed alternatives, either generating one yourself by following the standards for Guids - using a few P/Invokes to Crypto API methods to get random numbers, using the GuidEx class which uses the same technique or indirectly using SqlCe to create a new identity value.

An easier way in many cases is to use one of the COM subsystem API methods as this involves only a single P/Invoke call. The only caveat to this is that not all CE based systems have full COM support - there are three varieties Minimal COM, Full COM and DCOM support. Minimal COM doesn't support Guid generation. However in my brief experimentation with Platform Builder it would appear that among .NETCF's prerequisites is COM support so this should in theory be supported by any CE device on which .NETCF is supported. It is certainly supported on all Windows Mobile devices:-

namespace InTheHand

{

      ///

      /// Helper class for generating a globally unique identifier (GUID).

      ///

      /// "System.Guid"/>

      public sealed class ComGuid

      {

            private ComGuid(){}

 

            ///

            /// Initializes a new instance of the "System.Guid"/> class.

            ///

            /// A new "System.Guid"/> object

            public static Guid NewGuid()

            {

                  Guid val = Guid.Empty;

 

                  int hresult = 0;

 

                  hresult = CoCreateGuid(ref val);

 

                  if(hresult != 0)

                  {

                        throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Error creating new Guid");

                  }

 

                  return val;

            }

 

            [DllImport("ole32.dll", SetLastError=true)]

            private static extern int CoCreateGuid(ref Guid pguid );

      }

}

 

#    |