Category Archives: Pocket PC Development



“In more bad news for Windows Mobile, Apple shipped more iPhones in the quarter than the total of all handsets based on the Microsoft system, even though their numbers actually increased by 42%.” (See article Apple and RIM tussle for Q4 prizes as smartphones boom)

I’m really sorry, but I don’t think Windows Mobile 6.5 or 7 is going to make any difference, it seems that Microsoft is not going to be able to produce anything compelling enough, soon enough.   I don’t think there’s going to be a “comeback”.

In case you think that the iPhone is all hype and marketing, I have a question for you.  Have you ever tried using one?  I have yet to meet anyone who has had less than a “revelatory” experience using an iPhone. 

I’ve had a great experience developing for the platform (I think the Compact Framework is excellent).

I believe the future of mobile computing is and is going to be huge, but I’m afraid Windows Mobile isn’t going to play a significant role anymore. 

Future handset operating systems will be various, including of course the iPhone and Android.

Other mobile devices such as tablet computers and netbooks will probably continue to run Windows, so I think Microsoft should concentrate their efforts on continuing to ensure relevance on this form factor.

For developers I think the news is all good.  There are great opportunities out their in mobility, if we are willing to “move on” in our choice of development technologies. 



Permanent Link to IE6 for Windows Mobile – Better, but not brilliant

The Mobile Spoon: What happens when a Windows Mobile Addict breaks his vow and buys an iPhone?

Apple and RIM tussle for Q4 prizes as smartphones boom


Share this post :


Estranged Siblings – Silverlight Mobile and the Compact Framework CLR


An illustration that contemplates the cojoined nature of Silverlight and the Compact Framework


At PDC 2008 in the session Microsoft Silverlight 2 for Mobile- Developing for Mobile Devices, Amit Chopra revealed some interesting details about Silverlight Mobile that I haven’t seen written elsewhere.

The presentation mainly consists of “here’s Silverlight running on Windows Mobile”.   The interesting bits are at the end.  I dear reader, present these to you here.


Compact Framework, small but mighty

The compact framework, is small yet mighty.  (Some may say mighty default)

The Compact Framework provides a great deal of rich device integration and sheer programmability. It is a pleasure to create software for.  I even think that Compact Framework based applications have been a reason for customers, particularly in the Mobile Fieldworker areas to adopt Windows Mobile devices.

If you’re a Compact Framework developer like me, you may have been frustrated by the default “yesterday” appearance of the System.Windows.Forms forms engine.  It takes a great deal of work to make forms look good. 

Silverlight, a Framework Apart?

Two frameworks, Silverlight and Compact Framework, so alike, yet so different.

I for one was very excited last year at the thought of a Silverlight (ie WPF) graphics engine being available for Mobile Device development.  I was then saddened to learn that the Silverlight runtime would not be extending the Compact Framework, but would exist in addition to Compact Framework.

This is disappointing news. (I am now showing my disappointed face….beware!) It appears that Microsoft (at the moment) seem determined to give Silverlight minimal access to the device.  This is aligned with the idea that Silverlight is only a competitor to traditional Flash app that runs from a Web page. 

Although this may be acceptable for certain kinds of desktop oriented Silverlight applications, I doubt this is a believable use case for mobile developers.  The power of mobility is not only the ability to access data anywhere, but the ability to talk to the features of the device.

In the presentation mentioned at the outset, there was declaration of the intention to support Webcams, accelerometer and other device features in the future, depending on the support for this on other platforms (eg Windows and Mac). 

So, we are restricted to the lowest common denominator.  You may believe this is for technical reasons.  It isn’t. Because….

Silverlight Uses the Compact Framework!

Diagram of Silverlight Architecture on Windows Mobile

Amit said that the Silverlight runtime for Windows Mobile may be smaller because it may omit certain codecs and it also shares the Compact Framework Clr.    He went on to say that the Compact Framework would be a prerequisite to installing the Silverlight runtime.

A new and nobler purpose for Silverlight Mobile

I give you....Silver-Knight

It’s Microsoft’s belief that targeting Windows Mobile 6.? (Sorry about that WM2003 and 5) and Nokia phones will mean Web users will eschew DHTML and Flash websites for Silverlight ones.  

With the proliferation of device operating systems (particularly that pesky iPhone) I don’t think this is a likely scenario.  Do you?  Well do you?

I’ve I got an idea!  As it’s unlikely Microsoft will backtrack on their “one platform everywhere” philosophy for Silverlight, why not, in addition enable Silverlight as a cutdown WPF for the Compact Framework on Windows Mobile? Microsoft, I know you can!  Doing this would earn the gratitude of all Compact Developers and provide a side benefit to their current Silverlight efforts on Mobile.

Call to Action

If you agree, please add a comment or bookmark this article using the links below, blog about this yourself or email the people at Microsoft.   Amit said they wanted feedback, lets give it!

(BTW Any physical resemblance between Amit and myself is entirely coincidental, so don’t say it)



Microsoft Silverlight 2 for Mobile- Developing for Mobile Devices

Amit Chopra’s Blog (Email) – WIndows Mobile Program Mananger

Giorgio Sardo’s Blog (Email: gisardo @ microsoft  com) – Evangelist for Windows Mobile


Share this post :

Twittering using the Compact Framework



My twitter updates are done using a variety of code.  At the moment I use the Curl command line  in conjunction with SlickRun.  In the past I did this with Outlook (see the article Twittering from Outlook Using VBA).  In the past I’ve found this pretty easy to do using the Twitter Api.


I also like to do updates from my Pocket PC, but am not keen on SMS charges.  The solution of course is to create my own client, which I’ll be posting about shortly.

For my client program I intend to use TwitterLib library.  Sadly this does not work for the compact framework unaltered.  I am currently working on porting it to the compact framework.


In the interim I want to share with you a simple code sample for submitting tweets to Twitter. 

The example is simple enough to be used by people who want to do HTTP posts to similar services.


    Dim lsParams As String = "status=" & Uri.EscapeDataString(tweetText)

    Dim loRequest As HttpWebRequest = CType(HttpWebRequest.Create(""), HttpWebRequest)
           With loRequest
               .Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy()

               .Timeout = 10000
               .AllowAutoRedirect = True
               .AllowWriteStreamBuffering = True

               .Method = "POST"

               .ContentType = "application/x-www-form-urlencoded"
               .ContentLength = Len(lsParams)

               Dim loCred As New System.Net.NetworkCredential("someusername", "somepassword")
               .Credentials = loCred

               ' Write the request paramater
               Dim stOut As New StreamWriter(.GetRequestStream(), System.Text.Encoding.ASCII)

               Dim loResp = .GetResponse
               With loResp

               End With

           End With


The most important difference with the full .net framework is the “GetEmptyWebProxy” and “AllowWriteStreamBuffering” lines.  It won’t work without it.

Share this post :

PPCFinder released


Isn't the PPCFinder dog just the cutest?


About a year ago we released the freeware Pocket PC search program PPCFinder.  This program has had literally thousands of downloads subsequently with only a single release.

I’m proud to announce the first public update of the program since it’s original release.  The maintenance release

The “backstory” of PPCFinder is a plane flight home from Sydney to Brisbane.  In the past I found the inbuilt Windows Mobile search completely inadequate.  The available freeware alternatives seemed unpleasant to use and the commercial ones seemed to be as an ajunct to filemanager functionality.    It was time to write my own….In only a few days, PPCFinder was born. 

PPCFinder is a simple program that still addresses an important need on the Windows Mobile Platform.  That is the need to find files, particularly large ones (the definition of “large” has changed since the default search application in Windows Mobile was created), in order to get extra memory.

PPCFinder gives you all the “advanced” search options available to the original Windows XP search, including the cute doggy mascot that I’m sure you find excellent.

If you need all this, give PPCFinder a go.

The full release notes for the new version are available at the forum.

If you are a fan, please leave a comment and let everyone know about it.

Share this post :

Getting a Screenshot with VB.NET on the Compact Framework 2.0




I believe that “thumbnail” images of data in applications is a powerful way of giving an overview to a user.

One sort of application that uses this technique is the “Flip 3D” functionality of Vista.

The code sample below provides a routine that “grabs” a rectangle of the currently displayed screen.  Just like it’s desktop equivalent, it can only take screenshots of the visible screen, not graphics that are off-screen. (Anyone know how to do that? Please let me know!)

Here’s the code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    picScreenshot.Image = GetControlBitmap(Me.CreateGraphics, Me.SomeControl.Bounds)
End Sub
Const SRCCOPY As Integer = &HCC0020
Public Declare Function BitBlt Lib "coredll.dll" (ByVal hdc As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As Integer) As Boolean

Private Function GetControlBitmap(ByVal gx As Graphics, ByVal rect As Rectangle) As Bitmap

    ' Create the bitmap to output
    Dim loBitmap As Bitmap = New Bitmap(rect.Width, rect.Height)

    ' Create compatible graphics
    Dim loCompGraphics As Graphics = Graphics.FromImage(loBitmap)

    ' Blit the image data
    BitBlt(loCompGraphics.GetHdc(), 0, 0, rect.Width, rect.Height, gx.GetHdc(), rect.Left, rect.Top, SRCCOPY)

    ' Cleanup
    Return loBitmap
End Function

The function “GetControlBitmap” will get a bitmap of a control or any rectangle passed into it.


Share this post :

Disabling the context menu in the .Net CF WebBrowser Control



Although initially impressive, the WebBrowser control in the .NET Compact Framework 2.0 lacks the ability to be customised in a few important areas. An obvious one that people are asking about seems to be the ability to remove the default context menu.

None of the obvious solutions , such as setting the ContextMenu property to null seem to work.

The Problem
The internal PIE control that the WebBrowser control wraps has a COM property to disable it, but this is not exposed.

So how can we set the property?

The .NET CF 2.0 provides the answer. It introduced some new features that allows straight forward interaction with COM objects and controls.

Doing this with the WebBrowser control involves sending a special windows message (DTM_BROWSERDISPATCH) to the windows handle of the control to retrieve a pointer to the IDispatch interface, converted into an object (using the GetObjectForIUnknown call) , which is then cast to a marked up interface with the appropriate identifiers. These are found webvw.h which is part of the Compact Framework SDK.

This technique will only work for Windows Mobile (not Smartphone) based devices. For my own projects I use a compiler directive to screen avoid the COM calls on the Smartphone platform.

The Solution

I have cut down the solution to it’s bare essentials and encapsulated it in the class WebBrowserContactMenu. You should be able to reuse this class, unaltered in your own project.

Warning: Currently this solution WILL ONLY WORK FOR Windows Mobile 2003!   It is supposed to work for WM5 and above also (it all seems correct) but for some reason the SendMessage to DTM_BROWSERDISPATCH is not working at all.   I have researched the problem but as yet cannot find a workaround.  I will update this article if I do.  Any suggestions are welcome.

Imports System.Runtime.InteropServices
Imports System.Runtime.CompilerServices
Public Class WebBrowserContextMenu
Private moWebBrowser As WebBrowser
Public Sub New(ByVal control As WebBrowser)
moWebBrowser = control
End Sub
Const WM_USER As Integer = &H400
Const DTM_BROWSERDISPATCH As Integer = (WM_USER + 124)
Declare Function SendMessageLongRef Lib “Coredll” Alias “SendMessageW” (ByVal HWND As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer
Public Property Enabled() As Boolean
Return mGetBrowserInterface.ContextMenuEnabled
End Get
Set(ByVal value As Boolean)
mGetBrowserInterface.ContextMenuEnabled = value
End Set
End Property

Private Function mGetBrowserInterface() As IBrowserBareEssentials

Dim liPtr As Integer = 0
SendMessageLongRef(moWebBrowser.Handle.ToInt32, DTM_BROWSERDISPATCH, 0, liPtr)

Return CType(System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(CType(liPtr, IntPtr)), IBrowserBareEssentials)

End Function

<ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIDispatch), Guid(“698E3FC9-70C3-11D0-81E8-00A0C90AD20A”)> _
Public Interface IBrowserBareEssentials

<DispId(185)> Property ContextMenuEnabled() As Boolean
End Interface
End Class

In the example project, a simple WebBrowser application hosts this class, instantiating it and using radio buttons to toggle the button. Here’s what the form code looks like:

Public Class Form1
Private moContextMenu As WebBrowserContextMenu
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate(New Uri(txtUrl.Text))
moContextMenu = New WebBrowserContextMenu(WebBrowser1)
End Sub
Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
WebBrowser1.Navigate(New Uri(txtUrl.Text))
End Sub
Private Sub optEnabled_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles optEnabled.Click
moContextMenu.Enabled = optEnabled.Checked
End Sub
Private Sub optDisabled_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles optDisabled.Click
moContextMenu.Enabled = optEnabled.Checked
End Sub

End Class

Download the sample project. (14K)


The purpose of this article was to provide a direct solution to the context menu problem. I have by no means an exhaustive description of using COM with WebBrowser, but this may help as an introduction. At a future date I will share other uses for this technique.

Share this post :

kick it on

Write Code Once For Both Mobile And Desktop Apps



In a previous article I wrote about the technique used by Mobile Client Software Factory to do Microsoft Test automated testing in device projects.

MSDN magazine have now published a magazine article that explores the technique for developing other kinds of assemblies.  They also make the point that Compact Framework assemblies are “retargetable” (able to run on either platform ) whereas full framework assemblies are not.

This is not always ideal, as sometimes you may want to take advantage of desktop platform features.

The recommended technique involves sharing source, yet having two project files, targeting each different platform in the same project directory. 


 Share Code: Write Code Once For Both Mobile And Desktop Apps — MSDN Magazine, July 2007

Unit Testing Smart Device Projects

A reference "to that project" could not be added


As part of my research into doing test driven development on the Windows Mobile platform, I tried to create a “smart device” project level reference.

(See the post Unit Testing Smart Device Projects for more information about using Microsoft Test and unit testing on Windows Mobile)

As I haven’t found the information anywhere else, I thought I’d post my problem and the solution:

The Problem

When my test project was in Visual Basic, I got this brutal error message:

A reference to xxxxxxxxx could not be added:


A CSharp test project did manage to get to add the reference, but only after getting this message:


Does this mean I’ve finally found something CSharp can do better than VB.Net?  Surely not!

The Solution

After a great deal of messing around, I tried using the Microsoft Test Test Wizard to create the Visual Basic test project.  This worked.  The reason this worked was that it took a file reference instead.

So there’s your workaround.  Use a file reference.

Unit Testing Smart Device Projects


Screenshot of the Smart Client Software Factory's Gui Test Runner

A way of doing Test Driven Development on the Windows Mobile platform in the early days was not particularly easy.

For the development of Webby I created my own NUnit clone that worked inside the exe in debug mode.  This worked really well, but it was limited and I would have preferred something that was integrated into the IDE.

The developers of the “Mobile Client Software Factory” at Microsoft Patterns and Practices felt the need to create a unit testing environment that would enable full “test first” development.  Recently I had the need to investigate their solution, and have found very good.

The factory provides comprehensive unit tests for the application blocks that come with the factory, but more interestingly it provides a way for you to use the same testing framework.

This article below gives an outline of how tests are structured and how to do it.  

The structure of the tests

The test classes utilise the “Visual Studio Team Suite” attribute test markup ([TestClass], [TestMethod] etc).

These test classes are used by two test projects (assemblies):

  • A desktop test project for Visual Studio 2005 Team Suite
  • A mobile class library for running the unit tests on a mobile device

Both the desktop and mobile projects reside in the same project folder (with different names)

Creating the tests

The following procedures describe how you should create and run unit tests
To create and run unit tests on the desktop

  1. Create a Visual Studio 2005 Team System Edition test project that will run unit tests on the desktop.
  2. Add the <TestClass>, <TestMethod>, <TestInitialize>, and <TestCleanup> attributes described earlier to your classes to indicate which are test classes, test methods, initialization methods, and cleanup methods.  (TIP: Reference the application exe or dll as a “File Reference”)
  3. Run these unit tests using Visual Studio 2005 Team System or the TestDriven.NET test runner until all the tests pass.

Next, you can adapt these tests to run on the mobile device. The following procedure describes how you can use the GuiTestRunner utility to run your unit tests in the device emulator or on a mobile device.

To run unit tests in the emulator or on a device

  1. Add the following projects to your application project:
    • GuiTestRunner.csproj from the Tools\CFUnitTester\GuiTestRunner folder
    • TestRunner.csproj from the Tools\CFUnitTester\TestRunner folder
    • UnitTesting.csproj from the Tools\CFUnitTester\UnitTesting folder
  2. If you want to use the test utilities in your tests, also add the TestUtilities.csproj project from the Tools\TestUtilities folder. This project includes utilities to help you read application resources, access the application runtime folder, and provides stopwatches for measuring performance.
  3. Click Add on the File menu, and then click New Project. In the left-side tree view of the Add New Project dialog box, click Windows Mobile 5.0 Pocket PC. In the right-side window of this dialog box, click Class Library. Click OK to add the new project to your existing solution. Use the naming convention for test projects “[Module to be tested].Tests.CF“.
  4. Close Visual Studio and, in Windows Explorer, move your new Class Library project into same folder as desktop test project. This allows the device test project to share the same files as the desktop test project more easily.
  5. Re-open Visual Studio, and open your application solution. In Solution Explorer, right-click the References entry for your application project, and then click AddReference. On the Projects tab of the AddReference dialog box, select your test project, and click OK.
  6. With the device test project selected in Solution Explorer, click Show AllFiles on the Project menu. This reveals all files and folders in the same folder as the desktop test project.
  7. Select all the test and supporting files in Solution Explorer, right-click, and then click Include in Project.
  8. Add the compiler directive to select the appropriate test class namespace at compile time.

    #if PocketPC
     Imports Microsoft.Practices.Mobile.TestTools.UnitTesting
     Imports Microsoft.VisualStudio.TestTools.UnitTesting

  9. In Solution Explorer, right-click your test project, and then click Properties. On the Properties page, click the Devices tab. Change the value for the Output file folder in the Deployment Options section to %CSIDL_PROGRAM_FILES%\GuiTestRunner to ensure that your tests deploy to the same folder as the as the GuiTestRunner utility.
  10. Deploy and execute the GuiTestRunner utility