The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Mar 31, 2009
Post comments count 0
Post likes count 1

Freudian typo? The spinlock

Raymond Chen

I was typing up a document and somehow accidentally misspelled spinlock as sinlock. I was tempted to leave it.

Mar 30, 2009
Post comments count 0
Post likes count 1

What is the implementation of WM_PRINTCLIENT?

Raymond Chen

Via the suggestion box, Martin Filteau asks Could you explain the implementation of WM_PRINTCLIENT? It seems that even MS got it wrong in the LISTBOX control. Try to AnimateWindow a window that as a LISTBOX control as a child. The LISTBOX displays correctly if it is NOT empty. However, if it is empty... nothing is drawn. I got a similar problem when embedding an Internet Explorer control. Thanks. -mf As I noted back in 2003, the implementation of WM_PRINTCLIENT is the same as that of WM_PAINT. In particular, the implementation of WM_PRINTCLIENT for an empty window is... to paint nothing. That's...

Mar 27, 2009
Post comments count 0
Post likes count 0

I drive a car the way most people use a computer

Raymond Chen

It was interesting to me reading the reactions to my adventures driving a manual transmission. People seemed to be spending a lot of time trying to convince me that if only I were to expend a bit more effort in learning the finer points of driving a manual transmission and log enough time behind the wheel, then the activity will become less taxing on my mental brainpower. But why should I care? To me, driving is not an end in itself. It is just a tool for solving the problem of getting from point A to point B. The less I have to learn about how to accomplish this task the better. My goal is not...

Mar 26, 2009
Post comments count 0
Post likes count 1

The inability to lock someone out of the registry is a feature, not a bug

Raymond Chen

There is no way to lock the registry. Whereas you can open a file with a deny all sharing mode to prevent anyone else from opening the file, the registry has no such provision. You can't lock a registry key and prevent others from reading from or writing to it. There is an internal lock on the registry, but that's just to ensure that registry operations are atomic; that is, that if one thread writes a value to the registry and another thread reads that same value from the registry, then the value that comes back is either the value before the write took place or the value after the write took place, but not some ...

Mar 25, 2009
Post comments count 0
Post likes count 0

Caption contest: The pinball machine

Raymond Chen

I may regret this, but here's something new: A caption contest. One of my colleagues saw this picture on a company's Web site. The original caption for this picture was something like Join our affiliate program or Score big with our affiliate program. Your mission is to come up with something funnier. Here are some ideas to get you started: Do you have balls of steel? Maybe you can become an affiliate. We love to flip off our affiliates. When you become an affiliate, you're going to get whacked around a lot. Sooner or later you'll end up in the hole. We like to play games with you. Become an affiliate today...

Mar 24, 2009
Post comments count 0
Post likes count 1

Double secret auto-arrange probation

Raymond Chen

When you view a folder for the first time, Explorer arranges the items in a nice default pattern. And when items are added to the folder, they get added to the end. And when you delete an item from the folder... the other items auto-arrange to close the gap? But wait, if you look at the View options, the Auto-Arrange option is not set. So are we auto-arranging or not auto-arranging? Well, yes, but only until you touch it. As long as you express no interest in the placement of icons in a folder (and the desktop counts as a folder), then Explorer will auto-arrange them. But once you move an icon around, Exp...

Mar 23, 2009
Post comments count 0
Post likes count 1

What’s the point of the MoveWindow function when we already have SetWindowPos?

Raymond Chen

Commenter Phil Quirk notes via the suggestion box, " is just a weird function. I guess it's easier to call than , but that's the only thing it seems to have going for it." Yup, that's about right. The function doesn't really do anything you couldn't already do yourself with . It's just a convenience function. And it you look at it pretty closely, it's really not that big of a convenience either, saving you one parameter () and replacing the flag with a boolean parameter. Whoop-dee-doo. It shouldn't take too much imagination to figure out how this situation came about. It's the same reason why you hav...

Mar 20, 2009
Post comments count 0
Post likes count 2

How to write like Raymond: Intentional typographical errors

Raymond Chen

I'm a pretty good speller. If I want to show impatience, I will type very fast and make no attempt to fix the typographical errors. Here's an example: Somebody asked me what the correct name is for a particular user interface element. i don't nkow. call up the online hep and see what the ycall it. It may surprise you to know that I am not part of the committee that decides on the names for all user interface elements. If you want to know the correct name for a user interface element (for example, the Start menu), you don't need to ask me. You can look it up yourself: It's in the help. The list of agreed-...

Mar 19, 2009
Post comments count 0
Post likes count 1

Defense in depth means that you protect against exploits that don’t exist yet

Raymond Chen

Defense in depth is about protecting against threats that are already being protected against, just in case the existing protection fails. This is why there is not merely a lock on your safety deposit box, but also a lock on the door to the safety deposit box room, and then a lock on the doors of the bank itself. This is why you wear your seat belt even though the car is equipped with air bags. This is why factories have multiple safety systems. It's why, when you put away a gun, you set the safety and remove the ammunition and lock the gun case. An insistent anonymous commenter refused to believe in this pri...