{"id":39,"date":"2006-10-28T22:52:51","date_gmt":"2006-10-28T21:52:51","guid":{"rendered":"http:\/\/dalelane.co.uk\/blog\/?p=39"},"modified":"2006-10-30T12:22:27","modified_gmt":"2006-10-30T11:22:27","slug":"hello-windows-mobile-world","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=39","title":{"rendered":"Hello (Windows Mobile) World!"},"content":{"rendered":"<p>Finally &#8211; a chance to play with my new <a href=\"http:\/\/dalelane.co.uk\/blog\/?p=35\">Windows Mobile developer kit<\/a>. I had my first go with it tonight, and so far, I&#8217;m pretty impressed.<\/p>\n<p>The Windows Mobile 5 API exposes a lot of nice stuff to the developer &#8211; just looking through the <a title=\"MSDN: What's new for developers on Windows Mobile 5\" target=\"_blank\" href=\"http:\/\/msdn.microsoft.com\/windowsmobile\/learning\/whatsnew\/default.aspx?pull=\/library\/en-us\/dnppcgen\/html\/whatsnew_wm5.asp\">overview page on MSDN.com<\/a> showed me lots of stuff I want to have a go with. Like interacting with the phone, incoming calls, SMS messages &#8211; sent or received, using the phone&#8217;s internal camera, getting all sorts of system info like battery data, and loads more. So much to play with! The <a title=\"MSDN: What's new for developers on Windows Mobile 5\" target=\"_blank\" href=\"http:\/\/msdn.microsoft.com\/windowsmobile\/learning\/whatsnew\/default.aspx?pull=\/library\/en-us\/dnppcgen\/html\/whatsnew_wm5.asp\">overview page<\/a> also shows how easy it is to access the Pocket Outlook database, so I thought that this would be a good place to start. <\/p>\n<p><!--more-->For my first app, as a <a href=\"http:\/\/www.davidco.com\/what_is_gtd.php\" title=\"Getting Things Done - a productivity model by David Allen\" target=\"_blank\">GTD<\/a> fanatic, I thought I&#8217;d write something to play with my task list (<a href=\"http:\/\/dalelane.co.uk\/blog\/?p=28\">again!<\/a> :-)) <\/p>\n<p>Starting from the desktop (&#8216;Today screen&#8217;) on a Windows Mobile device, to create a new todo list item, I need to:<\/p>\n<ul>\n<li>Click on &#8216;Start&#8217;<\/li>\n<li>Click on &#8216;Tasks&#8217; to launch the Todo list application&#8230; and wait!<\/li>\n<li>Click on the &#8216;New&#8217; softkey<\/li>\n<li>Fill in the form<\/li>\n<li>Click &#8216;OK&#8217;<\/li>\n<\/ul>\n<p>Doesn&#8217;t sound like much, but it feels a little long-winded. The delay in launching &#8216;Tasks&#8217; is a couple of seconds to load all of the existing tasks &#8211; which is annoying when I don&#8217;t need to see the existing tasks, just add a new one. <\/p>\n<p>As a result, there are quite a few tasks which come up quite often that I don&#8217;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 <a href=\"http:\/\/www.lovefilm.com\/\" title=\"lovefilm.com - DVD rental by post\" target=\"_blank\">DVD rented from lovefilm<\/a> or write up a report after meeting with my mentee.<\/p>\n<p>So, I thought a one-click way to add these common tasks would be useful.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/dalelane.co.uk\/blog\/post-images\/061028-editlist.gif\" alt=\"my GUI to edit the common tasks list\" hspace=\"5\" align=\"left\"\/> I used the Visual Studio IDE to generate a GUI that can edit a stored list of &#8216;common-tasks&#8217; 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 &#8211; 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. <img decoding=\"async\" src=\"http:\/\/dalelane.co.uk\/blog\/post-images\/061028-addtask.gif\" alt=\"GUI to add a new task\" hspace=\"5\" align=\"right\"\/> The problem with this approach, though, is it still involves launching an app &#8211; which is what I want to get away from. So, my next attempt was to try adding it to the &#8216;Today screen&#8217; &#8211; making it present on the desktop all the time. <\/p>\n<p>There are <a href=\"http:\/\/msdn.microsoft.com\/windowsmobile\/learning\/default.aspx#WMApps\" title=\"MSDN article: How do I develop applications for Windows Mobile powered devices?\" target=\"_blank\">two main approaches to writing apps for Windows Mobile<\/a> &#8211; managed code, like the .NET Compact Framework apps I&#8217;d knocked up so far, or native code in C++ using the native APIs, as well as the Win32, ATL, and MFC frameworks. <\/p>\n<p>Managed code is much easier and quicker to develop &#8211; but the performance isn&#8217;t as good as you can get writing the native code yourself. And as anything running on the &#8216;Today&#8217; screen is running <em>all the time<\/em>, 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. <\/p>\n<p>So, I decided to write a Today screen app using native code. (Actually, for an app this simple, I&#8217;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!)<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/dalelane.co.uk\/blog\/post-images\/061028-today.jpg\" alt=\"today screen\" align=\"left\" hspace=\"5\"\/>This was more tricky. In fact, it was a massive pain. GUI-builders like Visual Studio have made me lazy! I&#8217;d forgotten what a hassle it was to write GUI code yourself&#8230; the code was so much longer than it needed to be for such a simple tool &#8211; and the trial-and-error approach to getting it look (nearly!) right, meant I spent much longer on it than I wanted. <\/p>\n<p>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!<br \/>\n<br clear=\"all\"\/><br \/>\nJust creating the drop down list needed:<\/p>\n<pre><code>g_hTaskDropDownList = CreateWindow(TEXT(\"COMBOBOX\"), \r\n   NULL,\r\n   CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP,\r\n   CW_USEDEFAULT,CW_USEDEFAULT,\r\n   CW_USEDEFAULT,CW_USEDEFAULT,\r\n   g_hWnd,\r\n   NULL,\r\n   g_hInst,\r\n   NULL);<\/code><\/pre>\n<p> Then having to use <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/wceui40\/html\/cerefSendMessage.asp\" title=\"MSDN documentation\" target=\"_blank\">SendMessage<\/a> to do anything with it&#8230; like adding entries to it. <\/p>\n<p>On the plus side, I found a nice <a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa458855.aspx\" title=\"MSDN - writing a custom Today screen item\" target=\"_blank\">article on MSDN<\/a> which helped me make sure that I exported the right functions in my DLL, to let the &#8216;Today&#8217; screen display the tool and update it correctly. <\/p>\n<p>Despite cursing C++ tonight, I&#8217;m still liking this Windows Mobile stuff, and enjoying starting to customize my phone to suit my needs&#8230; will have to try something else tomorrow!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Finally &#8211; a chance to play with my new Windows Mobile developer kit. I had my first go with it tonight, and so far, I&#8217;m pretty impressed. The Windows Mobile 5 API exposes a lot of nice stuff to the developer &#8211; just looking through the overview page on MSDN.com showed me lots of stuff [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","hentry","category-code"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=39"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}