Finally – a chance to play with my new Windows Mobile developer kit. I had my first go with it tonight, and so far, I’m pretty impressed.
The Windows Mobile 5 API exposes a lot of nice stuff to the developer – just looking through the overview page on MSDN.com showed me lots of stuff I want to have a go with. Like interacting with the phone, incoming calls, SMS messages – sent or received, using the phone’s internal camera, getting all sorts of system info like battery data, and loads more. So much to play with! The overview page also shows how easy it is to access the Pocket Outlook database, so I thought that this would be a good place to start.
Starting from the desktop (‘Today screen’) on a Windows Mobile device, to create a new todo list item, I need to:
- Click on ‘Start’
- Click on ‘Tasks’ to launch the Todo list application… and wait!
- Click on the ‘New’ softkey
- Fill in the form
- Click ‘OK’
Doesn’t sound like much, but it feels a little long-winded. The delay in launching ‘Tasks’ is a couple of seconds to load all of the existing tasks – which is annoying when I don’t need to see the existing tasks, just add a new one.
As a result, there are quite a few tasks which come up quite often that I don’t bother to add to my task list because it is too much hassle. Some of these are common enough, like a reminder to post back a DVD rented from lovefilm or write up a report after meeting with my mentee.
So, I thought a one-click way to add these common tasks would be useful.
I used the Visual Studio IDE to generate a GUI that can edit a stored list of ‘common-tasks’ and write it to a file. I then put together another quick form which uses this file to display a drop-down list of these tasks to choose from – and on selecting something, kicking off a background thread to add it to the Pocket Outlook database. Adding new tasks to my todo list is now as simple as clicking on an entry in a list. The problem with this approach, though, is it still involves launching an app – which is what I want to get away from. So, my next attempt was to try adding it to the ‘Today screen’ – making it present on the desktop all the time.
There are two main approaches to writing apps for Windows Mobile – managed code, like the .NET Compact Framework apps I’d knocked up so far, or native code in C++ using the native APIs, as well as the Win32, ATL, and MFC frameworks.
Managed code is much easier and quicker to develop – but the performance isn’t as good as you can get writing the native code yourself. And as anything running on the ‘Today’ screen is running all the time, performance for this is more important. An inefficient app can slow down the PDA, as well as help chew up the battery all the faster.
So, I decided to write a Today screen app using native code. (Actually, for an app this simple, I’m not sure the difference would be that noticeable, but I figure this is as good an excuse as any to try writing some native code!)
This was more tricky. In fact, it was a massive pain. GUI-builders like Visual Studio have made me lazy! I’d forgotten what a hassle it was to write GUI code yourself… the code was so much longer than it needed to be for such a simple tool – and the trial-and-error approach to getting it look (nearly!) right, meant I spent much longer on it than I wanted.
Instead of a shiny drag-and-drop GUI to place my icon, button and drop-down list, I had to write chunks of code, repeatedly looking up constants in MSDN!
Just creating the drop down list needed:
g_hTaskDropDownList = CreateWindow(TEXT("COMBOBOX"), NULL, CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, g_hWnd, NULL, g_hInst, NULL);
Then having to use SendMessage to do anything with it… like adding entries to it.
On the plus side, I found a nice article on MSDN which helped me make sure that I exported the right functions in my DLL, to let the ‘Today’ screen display the tool and update it correctly.
Despite cursing C++ tonight, I’m still liking this Windows Mobile stuff, and enjoying starting to customize my phone to suit my needs… will have to try something else tomorrow!