Hey, We Are Making it Better

Brian in Opinion | 1 Comments March 17, 2004

One bad aspect of my job is that I always see the bad stuff. I’m always on the lookout for what we did wrong, what we didn’t do yet, and what we could do better. That kind of environment makes it hard to remember the good stuff we’ve already produced. Last weekend brought a smile to my face, however.

In my “off time” (whatever that is) I like to write applications for my Pocket PC. I have a little freeware app called Calendar+ that was my first pet project. While the compact framework is available for the Pocket PC, I think it is a little much for a teeny today-screen plug-in like Calendar+. So, Calendar+ is entirely C++ code written directly to the Win32 API. Very Old Skool. I find it morbidly therapeutic to write code in C++ for these small devices. Memory is a primary concern, as is efficiency. It is just a refreshing change. But man, oh man, does it remind me how wonderfully easy writing in managed code is. Take the following dialog. This very simple dialog required the following hoops:

 

· I defined individual dialog templates for each tab page.

· The resource editor fought me at every step of the way. Native resources are all about pixel independence, but dialog boxes on Pocket PCs should always fill the screen. There is a lot of guesswork and template munging needed to get it to look right.

· I subclassed each page to paint the appropriate header on top (this isn’t a standard control, but it is a standard user interface guideline for the Pocket PC).

· I had to change window styles of check boxes to make them paint like buttons

· The left and right spin buttons send the same messages when you click them as the sliders at the bottom. It took me about an hour of wading through documentation to figure out what messages (they’re not covered in the reference docs for either control), and how to interpret what the messages mean (they both use WM_HSCROLL, which is documented, but it is not documented with respect to either of these controls and they send unique codes).

 

In the end, this simple two-tab dialog box required five subclasses and three dialog procedures. And, because I have several controls that use the same window proc it required that I stash pointers sneakily inside of window handles. That’s a common procedure for Win32 programming but it gives me the willies anyway. All total, I wrote eight functions to do a simple dialog that could be done with very little code if I was using the Compact Framework.

I guess there is some good stuff in managed code…I just need the weekends to discover it.

Comments (1) -

Jonathan, Wednesday, August 3, 2005 at 9:45 AM

Just downloaded a copy of Calender+.  Very impressed with the flexibility and functionality - I can finally get my pocket PC calender to do what I want, not what MS assumes I want!
Comments are closed