Archive for September, 2007

Creating a Tab Control for the Smartphone

Saturday, September 29th, 2007

Screenshot of sample application demonstrating the tab control I developed for Windows Mobile Smartphone devicesThe .NET Compact Framework does not support a Tab Control when targeting a Windows Mobile Smartphone device. Today I present a sample custom control designed to provide a suitable replacement for System.Windows.Forms.TabControl when you are building a Smartphone application.

I am not sure using such a control is good from a usability perspective, but it has been asked for enough times within the developer community, that this time I decided to provide a working solution. This was especially true once I determined the custom tab control would also provide some benefits for Pocket PC developers.

My development background was originally in the native world writing applications in C and C++. As such I know the raw Win32 APIs provided by the Windows Mobile operating system pretty well. The smartphone OS actually provides the standard Commctrl.h Tab Control, however the .NET Compact Framework has decided not to expose this functionality. So this custom control simply uses quite a lot of Platform Invoke calls to wrap up the native tab control provided by the operating system in a .NET Compact Framework friendly manor.

Benefits of this control

  • Works on both Smartphone and Pocket PC devices.
  • Allows tabs to have an optional bitmap displayed beside the text.
  • Exposes a SelectedIndexChanging event which allows the programmer to cancel a tab change if the application logic desires.

Sample Application

A sample application which runs on both Pocket PC and Smartphone devices is available for download. This download also contains the file SmartphoneTabControl.cs which contains the source code for the custom control itself.

[Download 48KB]

The sample application has three tabs and demonstrates how you can navigate the tabs via the left and right arrow keys. Once you have selected the third tab, you can use the up and down arrow keys to select the various textbox controls, and return to the tab control to select another tab.

Another neat feature demonstrated in the sample application is a way to have an animated icon displayed on a tab. This may be useful for a tabbed interface where a tab is displaying the results of an asynchronous or lengthy operation (such as a file download). The tab’s icon could be animated while the operation is still in progress, allowing the user to determine the state of the operation with a quick glance.

How to use the control

  1. Add SmartphoneTabControl.cs to your solution.
  2. Compile your project (needed to get the control into your toolbox).
  3. Drag a SmartphoneTabControl from your toolbox onto your form.
  4. Dock the tab control to the bottom and make it 26 pixels high.
  5. Add one or more Panel controls to your form (one for each tab page) and set the DockStyle property of each one to ‘Fill’.
  6. Populate the panels with the controls you want visible on each tab.
  7. Within your form’s constructor call the SmartphoneTabControl’s AddTab() method to create each tab, passing in the name of the tab, an optional image, and the panel which contains it’s controls.

There are a couple of outstanding bugs/missing features with this control. The biggest being the lack of design time support and device resolution independance. This control was quickly put together to demonstrate what could be possible with a little bit of work. If anyone is interested in collaborating to improve this control, I would be keen to hear from them.

Free games for your Windows Mobile PDA or Smartphone

Wednesday, September 26th, 2007

It has been a long time since my last blog posting. I am trying to get back into the habit of regular posting, so I thought I would start off again with a beta release of a project that I have been working upon recently.


As I mentioned previously Simon Tatham’s Portable Puzzle Collection is a high addictive collection of 27 logic puzzles that can be used on Windows, Mac OS , Unix and PalmOS powered devices. I have picked up the existing Windows Mobile PDA support found within the SVN repository and improved the port, making it more functional and compatible with a wider range of Windows Mobile devices.

I am at the stage where I am getting ready to make an initial release. As such I have decided to make a beta release, in the hope that it generates some feedback which will allow me to further improve device compatibility and iron out any kinks.

Installation Process

[Download - 741KB]

Download the attached ZIP file and extract the CAB file called Puzzles.ARMV4.CAB located within it. Once you transfer this CAB file to your device, you can install the games as you would with any other CAB file.

Once installed, you should see a Puzzles folder underneath the Games section of your device’s Start Menu which contains 27 new games to occupy your time with.

The single CAB file should be usable on any Windows Mobile 2003 or above device – Smartphone or Pocket PC, QVGA or VGA, Landscape, Portrait or Square screen. It would probably even work on the OFone if one actually existed! The user interface dynamically adapts at run time to its current situation. For instance it uses a slightly different menu layout on Pocket PC 2003 devices, and hides a toolbar if it finds itself running on a smartphone with a numeric keypad.

On the device compatibility front, if anyone has a Windows Mobile Standard (smartphone) device with a QWERTY keyboard such as a Moto Q or Samsung BlackJack which I could borrow for a short time, I would love to hear from them… especially something running WM6.

Further details

From anyone who downloads this beta release I would be interested in hearing feedback on:

  1. Any bugs and/or device compatibility issues
  2. If there is interest in a localised version (i.e. having the UI in French, German or Japanese etc)?
  3. If there is interest in support for “raw” Windows CE based devices?

As with all beta releases there are a couple of known issues which you will need to be aware of. Many will hopefully be resolved before I make a final release. These issues include:

  1. The lack of proper start menu icons.
  2. Usability issues with many of the games on non touch-screen enabled devices.
  3. Some Cosmetic issues within the custom game configuration dialog.
  4. The game “filling” has some corrupt pixels on the edges of the game board.
  5. The game “inertia” is currently unplayable via keyboard, due to not being able to move on diagonals.

My next steps

Within the next day or so I will clean up my patch to Simon Tatham’s original source code and post it to this blog along with compilation instructions (for Visual Studio 2005) etc. Then I will start producing a plan for the additional work required to make a proper v1.0 release.

In developing this port I have also came up with some ideas for future blog topics. These blog topics will be of interest to native (C and C++) developers, instead of Compact Framework developers, and will focus on topics such as SIP handling, Smartphone and Pocket PC UI differences, and cross platform development tips.

I also have a couple of blog postings about popup notification balloons to follow on from my previous entry on the subject. So hopefully I’ll get back into the swing of things over the next few days.