The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts

Don't forget to pass the current directory along with the command line to your single-instance program

If you make a single-instance program, and somebody runs a second copy of the program and passes a command line, the most common way of handling this is to hand the command line to the first copy of the program and let the first copy deal with it. When you do this, don't forget about the current directory. If somebody passes a relative path to the second copy of the program, that relative path needs to be resolved against the current directory of the second program. I've seen programs that fail to take this into account. Instead, they pass the command line to the first copy of the program, and the first copy r...

2007 mid-year link clearance

Random stuff.

If it's optional, then don't make it mandatory

I was filling out an online form, and it gave me the option of providing feedback on the service I had received. The button was marked "optional", but I clicked it anyway because there were one or two things I thought were worthy of mentioning, suggestions on how they could improve the user's experience with the Web site, that sort of thing. What came next was not something I was expecting. I was faced with a 43-question survey asking me to rank my level of satisfaction on scale of 1 to 5 on each of those 43 different axes. I skipped all of those questions since they aren't why I chose to give them feedback. At...

Overheard conversation in the cockpit that you might not want to have heard

A few weeks ago, I got a piece of email from a friend. Maintenance crew in cockpit. They just told the pilot that the airplane "double faulted."

Those who do not understand the dialog manager are doomed to reimplement it, badly

A customer wanted to alter the behavior of a multi-line edit control so that it did not treat a press of the Tab key as a request to insert a tab character but rather treated it as a normal dialog navigation key. The approach the customer took was to subclass the edit control and intercept the Tab key: There are many things wrong with this approach. You can spend quite a lot of time nitpicking the little details, how this code fails to set focus in a dialog box properly, how it fails to take nested dialogs into account, how it fails to handle the Shift+Tab navigation key, how it blatantly assumes that the co...

What's all this stuff hanging from that utility pole?

Brain Hayes, author of Infrastructure: A Field Guide to the Industrial Landscape (another example of the "short: long" book title fad), talks us through all of the wires hanging from what we commonly call a "telephone pole".

Why do DLGC_WANTALLKEYS and DLGC_WANTMESSAGE have the same value?

From a purely theoretical point of view, there is only one "want" code you really need: . All the others are just conveniences. For example, returning means "I want this message if it is an arrow key; otherwise, I don't care." It lets you write instead of the more cumbersome (but equivalent) Similarly, is equivalent to returning if the message is a press of the tab key, and is equivalent to returning if the message is . And that leaves , which is just another name for : They mean the same thing but look at the situation through different perspectives. The value is more readable if you return it ...

Why the Fantastic 4 Human Torch ATV is the Worst Movie Tie-In Toy Ever

Columnist Wm. Steven Humphrey expounds on Why the Fantastic 4 Human Torch ATV (with Light-Up Headlights!) is the Worst Movie Tie-In Toy Ever. (Readers cautioned for strong language, but it's funny because it's true.)

There's no point improving the implementation of a bad idea

is a bad idea and you shouldn't call it. In the comments, many people proposed changes to the function to improve the implementation. But what's the point? is just a bad idea. There's no point improving the implementation of a bad idea. On the other hand, some people suggested making it clear that is a bad idea by making it worse. While this is tempting in a "I'm forcing you to do the right thing" sense, it carries with it serious compatibility problems. There's a lot of code that uses even though it's a bad idea, and making worse would risk breaking those programs that managed to get away with it up u...