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

Microspeak: Walls and ladders

Reader laonianren wanted to know more about this game Walls and Ladders. "Walls and Ladders" is not a game. It's just a metaphor for a conflict in which one side wants to perform some action and the other side wants to prevent it. The defending side builds a wall, and the attacking side builds a taller ladder. In response, the defending side builds a taller wall, and the attacking side builds an even taller ladder. The result of this conflict is that the defending side constructs an ever-more-elaborate wall and the attacking side constructs a more-and-more complex ladder [link possible NSFW], both sides expen...

Cultural arbitrage: The food-related sucker bet

While I was at a group dinner at a Chinese restaurant, a whole fish was brought to our table. One of the other people at the table told a story of another time a whole fish was brought to the table. He attended the wedding rehearsal dinner of a family member. The bride is Chinese, but the groom is not. (Or maybe it was the other way around. Doesn't matter to the story.) The dinner was banquet-style at a Chinese restaurant, and one of the many courses was a whole fish. Two of the non-Chinese attendees marveled at the presence of an entire fish right there in front of them, head, tail, fins, and all. I guess they...

Why was there a font just for drawing symbols on buttons?

Henke37 wonders why the Marlett font was introduced. Why use a font for drawing symbols on window buttons? Using a font was a convenient way to have scalable graphics. It's not like Windows could've used VML or SVG since they hadn't been invented yet. EMFs would have been overkill as well. Fonts were very convenient because the technology to render scalable fonts already existed and was well-established. It's always good to build on something that has been proven, and TrueType scalable font technology proved itself very nicely in Windows 3.1. TrueType has the added benefit of supporting hinting, allowing...

Keys duplicated from photo: Delayed reaction

There was a report some time ago that researchers have developed a way to duplicate keys given only a photograph. When I read this story, I was reminded of an incident that occurred to a colleague of mine. He accidentally locked his keys in his car and called a locksmith. Frustratingly, the keys were sitting right there on the driver's seat. The locksmith arrived and assessed the situation. "Well, since you already paid for me to come all the way out here, how would you like a spare key?" "Huh? What do you mean?" The locksmith looked at the key on the driver's seat, studied it intently for a few seconds, then...

How do I print non-error messages during compilation?

Commenter Worf remarked, "My one wish is that would be supported." I always find it interesting when people say "I wish that Microsoft would stop following standards," since the directive is nonstandard. The Microsoft C/C++ compiler implements the feature in a method compatible with the standard, namely via a directive. If you want to warn people away from deprecated functionality, you can use the directive or the even more convenient (but more standards-troublesome) declaration specifier. The declaration specifier is much more convenient than the preprocessor directive because you can...

Puzzling out the upsell-o-meter

As I noted before, many grocery stores in the United States have a printer next to the cash register which prints out coupons customized to your purchases. Here's a purchase and the accompanying coupon. What is the story behind this pairing? Purchased: Diapers for newborn baby. Coupon: Save 75 cents on ice cream. Bonus chatter: While waiting in line, I read the warning label on the diapers. It went on for quite a bit, but one part triggered my "I wonder what lawsuit led to this warning" sensor: "Like most articles of clothing, XYZ brand diapers will burn if exposed to flame." Did somebody say, "Oh no, there's ...

Why does CreateEvent fail with ERROR_PATH_NOT_FOUND if I give it a name with a backslash?

A customer reported that the function was failing with the unusual error code : The customer continued, "The documentation for says that the parameter must not contain the backslash character. Clearly we are in error for having passed an illegal character, but why are we getting the strange error code? There is no file path involved. Right now, we've added to our list of possible error codes, but we'd like an explanation of what the error means." Okay, first of all, building a table of all known error codes is another compatibility problem waiting to happen. Suppose in the next version of Windows, a new...

What a steal: A house for only ten dollars!

When I was signing the papers for a house purchase many years ago, I noticed that the deed papers read The Grantor «names of people selling the house» for and in consideration of TEN DOLLARS AND OTHER GOOD AND VALUABLE CONSIDERATION in hand paid, conveys and warrants to «me» the following described real estate... I noticed that I technically was buying the house for ten dollars. The closing agent explained, "Well, ten dollars and other consideration. This is just a convention, so that the actual amount paid for the house doesn't go into the record." It also saves them from havin...

How can I detect the language a run of text is written in?

A customer asked, "I have a Unicode string. I want to know what language that string is in. Is there a function that can give me this information? I am most interested in knowing whether it is written in an East Asian language." The problem of determining the language in which a run of text is written is rather difficult. Many languages share the same script, or at least very similar scripts, so you can't just go based on which Unicode code point ranges appear in the string of text. (And what if the text contains words from multiple languages?) With heuristics and statistical analysis and a large enough sample, ...