Wednesday, January 30, 2008

Checking out Windows Live Writer

I've been using the Blogger editor for the past couple of years (except for a while when I used Qumana) and while it's improved a lot from when I started using it, I thought I'd check out Windows Live Writer after Rick Strahl mentioned he likes it.

I like the preview features, both Web Layout, which shows just the article you're entering in the theme of your blog and is fully editable, and Web Preview, which shows what the post will look like in your blog but isn't editable.

Live Writer has lots of cool features. For example, it's really easy to insert a map or aerial view. Here's the world-wide HQ of Stonefield Software (the building is somewhat shaded by the tall apartment building just to the south):

Map image

You can also easily insert pictures, links, tags, tables, and videos. Plug-ins make it even easier to use; available at http://wlwplugins.com/ are plug-ins such as SnagIt Screen Capture Plugin for Windows Live Writer and WebSnapr URL Preview Image.

It has the usual formatting capabilities, spell checking, and lots of other features. So far, so good.

Some Interesting Posts

Here are some blog entries I've found particularly useful or interesting of late:

Reinventing the Clipboard: discusses why the Windows clipboard needs to be rethought and even better, links to a cool tool (Clipx) that provides a multi-entry clipboard.

TIP: Compressing Virtual PC images: Craig's tips are always great and this one saves lots of disk space.

Why Your Business Must Be on the First Page of Google: yes, it's marketing, but since we're all involved in marketing one way or another, you might as well figure out how to do it better. Mike's blog has lots of useful tips and I found this article really interesting.

Evolve Your User Interface To Educate Your Users: the Smashing Magazine blog is mostly web-oriented but is almost always interesting. However, the ideas in this post are also applicable to making desktop apps easier to use.

Friday, January 11, 2008

Don't Save if Minimized

We've had a few people report an unusual problem: when they launch Stonefield Query, rather than displaying a login dialog, it looks like it's hung, but pressing Esc makes it close. It turns out that under some circumstances, the login dialog appears behind the application but has focus. As a result, it waits for the user to login and since it's a modal dialog, it looks like the application has hung. Pressing Esc cancels the dialog and closes the app. If you type the user name and password (blindly, of course, since you can't see the dialog) and press Enter, it succeeds.

We couldn't reproduce this ourselves and setting the login form's AlwaysOnTop to .T. didn't help for those people who did encounter it.

Then someone today reported the following situation: they minimize Stonefield Query then log off from Windows. (Minimizing, right-clicking on its Task Bar item, and choosing Close also caused the problem.) The next time they launch Stonefield Query, it starts minimized. They restore it and boom, the application is "hung" but pressing Esc closes it. Bingo -- we have a reproducible scenario.

In digging into this, I found the following code executes when the application shuts down:
with This.oRegistry
.SetKey(lcKey, 'WindowState', _screen.WindowState)
.SetKey(lcKey, 'Height', _screen.Height)
.SetKey(lcKey, 'Left', _screen.Left)
.SetKey(lcKey, 'Top', _screen.Top)
.SetKey(lcKey, 'Width', _screen.Width)
endwith
This code stores the current size, position, and window state of _SCREEN so the next time they launch Stonefield Query, it can restore those settings. And that's the start of the problem: when the application is minimized, _SCREEN.Top and Left are set to -32000. The login dialog then opens and since it has Desktop set to .T. so it looks nice in Windows Vista, it doesn't live inside _SCREEN but centers itself inside the current location of _SCREEN. That makes it really far offscreen. Then the user restores the application, which puts _SCREEN back where it was, but since the login dialog doesn't live in _SCREEN, it doesn't move. So, while it has focus and the user can type in it, they can't see the dialog.

The solution was easy: don't call the above code if _SCREEN.WindowState is 1-Minimized. That way, _SCREEN will be restored to the size and position it was the last time it was closed while actually visible.

Wednesday, January 02, 2008

Here's an Obscure One

I spent a couple of hours this afternoon tracking down and resolving a very obscure bug. See anything wrong with the following SQL statement?
select ;
CONTACT1.COMPANY, ;
CONTACT1.KEY4, ;
CONTACT2.UJRCONSULT ;
from CONTACT2 ;
right outer join CONTACT1 ;
on CONTACT2.ACCOUNTNO=CONTACT1.ACCOUNTNO ;
where CONTACT1.KEY4 like '%JDM%' or ;
CONTACT2.UJRCONSULT like '%JDM%'
Neither did I, yet this gives a "Function argument value, type, or count is invalid" error. Long story short, it turns out this is the set of conditions that make this fail:
  • An OUTER JOIN
  • A filter condition on the "other" table (e.g. the left table for a RIGHT OUTER JOIN); in this case, it's the second condition that causes the error
  • The field in the filter is a Varchar
  • One or more records have a null value in that field
  • The filter uses the LIKE operator

Changing any one of these makes the error go away. In my case, I changed the filter condition to:

nvl(CONTACT2.UJRCONSULT, '') like '%JDM%'
and that fixed the problem.