A day of upgrades

I followed Neil and Alex‘s lead and upgraded my blog to dasBlog too. Luckily because dasBlog is an evolution of BlogX the migration was pretty smooth. I may well tweak the theme slightly yet though because I miss my roadsign 🙂


I’ve also flashed my iPaq 2210 with the latest 1.10 ROM (Thanks to Ed at Pocket PC Thoughts for the heads up). This includes a number of previous patches, sadly it has .NETCF SP1, not SP2 so that will still require a RAM install. However doing a ROM flash is always a good time to clean out the crud so my iPaq is nice and tidy (for the moment at least)

New Controls article posted

I’ve posted a new
article
to OpenNETCF.org about hosting Native windows controls from within the
.NET Compact Framework. The approach used allows you to host the control within a
Control object and receive notification back from the control thus supporting Events.
The first control to use this technique was the HTMLViewer in the Smart Device Framework
v1.0, but this has already been supplemented with InkX and MonthCalendar controls
in our latest source code. The
bulk of the work required is encapsulated in the ControlMessageWindow so it is a fairly
quick process to implement new controls in this way.

I sincerely hope that we get some extra power in the .NET Compact Framework v2.0 such
as the ability to override the WndProc of the control itself, and built in support
for the Handle property. Of course it is only a week until the Mobility
Developer Conference
when more should become clear… I can’t wait!

A consistent way to get native window handles (HWND)

In the full desktop framework all Controls and Forms expose the Handle property which
represents the native window handle of the control – this can be passed to API functions.
In the Compact Framework this property is not implemented. In the Smart
Device Framework
 we have created the OpenNETCF.Windows.Forms.IWin32Window interface
which matches the equivalent interface on the full framework. You can implement this
interface in your custom controls and forms to provide a standard way of exposing
the window handle.

Getting the handle to any control requires just one P/Invoked API function – GetCapture
which returns the window handle of the control with capture (able to receive mouse/stylus
input). First Capture is set on the control, then this API call will return the HWND
of the control, finally capture is optionally release from the control. The GetCapture
function is implemented in the OpenNETCF.Win32.Win32Window class,
or you can P/Invoke it directly. The following code illustrates adding IWin32Window
support to your control:-

[VB]

Imports OpenNETCF.Windows.Forms
Imports OpenNETCF.Win32

Public Class MyControl
    Inherits System.Windows.Forms.Control
    Implements IWin32Window
    

    Overridable ReadOnly Property Handle() As System.IntPtr
        Get
            Me.Capture = True

            Dim thishandle As IntPtr
            thishandle = Win32Window.GetCapture()
            Me.Capture = False
            Handle = thishandle
        End Get
    End Property
End Class


[C#]

using OpenNETCF.Windows.Forms;
using OpenNETCF.Win32;

public class MyControl : Control, IWin32Window
{
   public IntPtr Handle
   {
       get
       {
           this.Capture = true;
           IntPtr thishandle = Win32Window.GetCapture();
           this.Capture = false;
           return thishandle;
       }
   }
}

By using the Interface approach rather than adding in support for handles on an ad-hoc
basis you have a garunteed signature for your handle implementation. Therefore
if you have a method which requires a native window handle you can accept an IWin32Window
as an argument. We will be ensuring that all our OpenNETCF controls in the future
implement this interface so you can rely on the Handle property to get the native
window handle.

Browse and search Source Code

To co-incide with our latest source-code release of the Smart
Device Framework
, we’ve implemented an online
source browser
which you can use to view our complete portfolio of code.

One of the features of this is the ability to search for keywords in the code. A good
example of why you might want to do this is when looking for a specific P/Invoke definition,
for example CreateProcess. Doing a search on “CreateProcess” results in a reference
in OpenNETCF.Diagnostics.Process
and we can see that on line 402 and 403 the function is declared.

Smart Device Framework poster

To give an overview of the various namespaces, classes, structures and interfaces
which make up the OpenNETCF Smart Device Framework, I have created a poster – which
you can now download in PDF format and print out as big as you want from the
link below:-

OpenNETCF Posters

I’ll also be uploading shortly a further refresh to the online
documentation
. This will hopefully fill in a few of the gaps in the documentation,
and also add details of some of the new functionality which is currently being added
to the source. Chris recently posted
the latest
source packages
which include his cool
new instrumentation controls
.

So what do you think of OpenNETCF?

The OpenNETCF Survey

As we are approaching our first anniversary (and so is the .NET Compact Framework
itself which was officially announced last March) we are interested to understand
what you think of the code, articles etc we have created so far and what you would
like to see from us in the future. We would really appreciate it if you could spare
a few minutes to fill in our short survey,
you can fill it anonymously if you like or if you provide details you’ll be entered
into a draw for some secret OpenNETCF goodies – we’ll announce the winner during the
upcoming MDC 2004 week.

 

Microsoft Mobile Dev Con just over a month away

Kevin Lisota has just posted about his excitement for the upcoming MDC in San Francisco. It’s shaping up to be a really interesting event and of course OpenNETCF will be providing an exciting session:-







“CLI345 – Developing Real-world Smart Device Applications with Visual Studio .NET 2003, .NET Compact Framework and OpenNETCF SmartDevice Framework

The .NET Compact Framework is a powerful tool for a mobile developer. To fully utilize its potential in a real-world application, a developer needs access to the native API and intrinsic Windows CE controls. OpenNETCF SmartDevice framework is designed to address these needs.”


There will also be a number of worldwide events to follow offering MDC content nearer to you.


Find your way around the API maze

This Win32
to .NET mapping article
on MSDN caught my eye recently. It’s aim is to show the
mapping between Win32 API functions and their managed equivalent. This is for the
full desktop framework, would you be interested in a Compact Framework equivalent?

Since Compact Framework development generally requires a fair bit of P/Invoke its
useful to know which functions are already available in managed form (its very easy
to start P/Invoking functions to find an equivalent is already available in the Compact
Framework or an OpenNETCF library). It would also be useful to show which functions
can and cannot be P/Invoked directly…