Developers: It?s a Context Menu, not a Right-Click Menu

July 14th, 2008 by admin

Well-behaved GUI software should make all functionality easily accessible from the keyboard. For Windows, most of this is covered by the Windows User Experience Guidelines.

But there a some subtleties not covered there which many developers get wrong. And one that I see quite often is the improper display of context menus. Many people refer to these as right-click menus, but they can also be initiated from the keyboard, either by pressing the menu key (usually to the right of the space bar) or Shift+F10.

The first problem is that some applications ignore the user and don’t display the menu at all when initiated via the keyboard. The second issue, and probably the most common, is displaying the context menu at the mouse pointer location instead of near the keyboard focus/selection. For keyboard users, it is not uncommon for the mouse pointer to be far away from the current selection (even on a different monitor), making for a very unpleasant, inefficient user experience.

Handling display of the context menu properly is very simple. Do not use the WM_RBUTTONUP message to display a context menu. Instead, process the WM_CONTEXTMENU notification in each control that displays a context menu. This notification provides the mouse position (if initiated via the mouse) or a position of -1, -1 if initiated via the keyboard.

If initiated via the keyboard, determine the position of the caret or first focused/selected item in the control and use that position to display the context menu. For tree and list controls, see how Windows Explorer handles this, and for edit controls, see WordPad. For all you developers who are doing this wrong, please fix it now. Thanks!

Posted in Power tools | No Comments »

Windows XP Forever

July 7th, 2008 by admin

Windows XP is a great operating system, possibly the best desktop OS ever. It looks great, is very stable, performs well, and rarely requires rebooting. And unlike earlier versions of Windows, it hardly ever needs to be repaved (format + reinstall). I’ve been running Windows XP SP2 as installed with my PC for over 3 years.

But like everything in the universe, entropy is always increasing, so it can’t last forever. Well, a few weeks ago, Windows XP stopped recognizing my DVD drive, probably after uninstalling some software. I don’t use it much, but I knew that I would eventually need to, and my online searches for a fix came up empty. I briefly considered just switching to Vista (which I have installed on another partition but use only for testing), but I have not been impressed with it.

I even toyed with switching to Mac or Linux. I have an old Mac Mini and also experimented with Ubuntu in a virtual machine, and while both have come a long way in the last few years, I didn’t find either more compelling than XP. Plus, there will always be a few Windows applications that I need. My experience with running the Windows apps that I use under Wine has been dismal, and running them in a Windows virtual machine under Mac or Linux is not nearly as useable as running natively (and I would still need to have Windows installed there anyway).

I tried searching one more time on the DVD drive issue, and lo and behold, I found the very simple solution of cleaning up a few registry keys.

I also had some trouble installing Windows XP SP3, but quickly found a fix for that too. And installing SP3 resolved the other annoyance that had cropped up — all open applications encountering an Application Error on Windows shutdown (which I had been working around by using CloseAll).

So XP is now running like new again and I expect it will for many years to come. I’m not sure how Microsoft will handle activation of Windows XP when support ends, in case I ever do need to reinstall Windows, but it is possible to transfer activation.

And I’m not really worried about Microsoft no longer updating XP. I’ve never encountered a security related problem with it (even running as administrator and without anti-virus or anti-spyware), and there’s not much chance that a new security flaw will ruin that record.

And there’s always Windows 2000, or maybe Linux 2014.

Posted in Power tools | No Comments »