Monday, October 08, 2007

The list-based form control

Back in 2003 when the Smart Device Extensions were still in Beta and about to be renamed .NET Compact Framework, some people had to use C++ to develop database applications. I was one of these developers struggling with a crude set of tools: ADOCE for database access and the eVC3 dialog editor to design the user interfaces.

Soon we learned that ADOCE would be deprecated and so I started to look at the ATL OLE DB consumer templates. This is a great technology and I still fail to understand why it is not present on the WM5 and WM6 SDKs. In my code, I use an adapted version of the header file you get on the Pocket PC 2003 SDK but to be honest I don't like this approach (I will come back to this issue in a future post).

On the user interface side, we already had a very nice alternative to dialogs: the list-based form control used by the Pocket Outlook Contacts application. Not only this is an intuitive control for the user, it also promised to be easy for a developer to use: no designer needed to be involved, you just specified the list of items to edit and fired the object.

The big problem with this control was that there was no API for it so I had to write one. Back then I was using MFC big time due to the compiler support for it on eVC3 and eVC4. Now I am not so sure that MFC is a good option for native user interfaces and I'm leaning towards WTL. You now have great tool support in VS 2005 with the WTL Helper tool which I am using on a daily basis and with great results.

So I eventually wrote an MFC control to implement a list-based form and in the process I threw in couple of goodies such as grouping, context menus for managing the items, control notifications and a few other bells and whistles. After a recent request of fellow MVP Christian Forsberg for a similar control, I decided to go back to my 4 year old code, adapt it to VS 2005 and publish it. I had to do more work than expected because nowadays there are lots of devices that have a keyboard, display in landscape and even have VGA screens! Back then I was used to portrait QVGA screens and no keyboard, so some changes were in order.

Before I publish this code as an article, I decided to preview it here so you get a chance to look at it and let me know what you think. Download

1 comment:

Christopher Fairbairn said...


This looks to be a neat control, which is easily extensible. I took your source code and quickly compiled it for the Smartphone platform.

I noticed you mention trying to support a wide range of devices (screen resolutions etc). Have you considered also supporting the UI differences between Pocket PC and Smartphone platforms?

I think the control would be a real benifit to the smartphone platform, where UIs usually fall into the "list of controls" type of interface that your custom control handles well.

From my quick investigation it looks like little would need changing in order to support the smartphone platform within your control.

Apart from a few minor tweaks it basically works as is already. The "biggest" challenge may be working around CComboBox (on the smartphone platform you don't want a ComboBox, instead you want a 1 line high ListBox + Up/Down Auto Buddy to get the native look and feel for selectable lists).

Your control could be an ideal way to create a nice cross platform (i.e. support Pocket PC and Smartphone in a single executable) data entry application without needing to resort to lots of manual control relayout type code. A puzzle collection I am working on implements a very similiar approach to making the one UI fit across the different device types.