The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Apr 22, 2009
Post comments count 0
Post likes count 1

What structure packing do the Windows SDK header files expect?

Raymond Chen

/Zp8 In words, integral types and pointers up to eight bytes in size are stored at their natural alignment. Larger types are stored at eight-byte alignment. In other words (saying it a third time), let be an integral or pointer type. If ≤ 8, then is aligned at a -byte boundary. If ≥ 8, then is aligned at an 8-byte boundary.

Apr 21, 2009
Post comments count 0
Post likes count 0

How to answer the telephone, according to the manual

Raymond Chen

I have a fancy new office telephone with a bajillion features (most of which I will never even find, much less use). The telephone comes with a helpful manual, explaining how to carry out various tasks. For example: Answering a Call Using the Handset: Pick up the handset. Cool, I was wondering about that.

Apr 20, 2009
Post comments count 0
Post likes count 0

Principles of economics, translated

Raymond Chen

Yoram Bauman, the stand-up economist translates Mankiw's ten principles of economics into English. The proof presented in the footnote to principle 5, as well as an extended version of the translation, can be found in the Annals of Improbable Research.

Apr 20, 2009
Post comments count 0
Post likes count 1

The dangers of destroying a window while it is processing a sent message

Raymond Chen

Commenter BryanK wonders why weird things happen if you destroy a window while it is processing the message. He suspects that it's similar to the problems you encounter when you destroy a window in response to the message. Although I haven't studied the situation, I wouldn't be surprised if the problem is indeed entirely analogous. It just follows from general programming principles: After all, you are destroying the active window. The message is sent as part of the activation change, and the documentation says that the message is sent "when a window belonging to a different application than the active wi...

Apr 17, 2009
Post comments count 0
Post likes count 1

Why is the animation common control limited to RLE8-compressed animations?

Raymond Chen

The animation common control is very limited in the type of animations it can play. The animation must be in AVI format, it cannot have any sound, and it must be either uncompressed or use RLE8 compression. Why so many restrictions? Because if it could handle other file formats, play sound, and support arbitrary codecs, it would just be a reimplementation of the multimedia animation control. (We saw this principle earlier when discussing why you can't do everything with registry values that you can do with registry keys.) The point of the animation common control is to play very simple animations without th...

Apr 16, 2009
Post comments count 0
Post likes count 1

The frustration of people who are not interested in why something works but only interested in the magic phrase they need to type

Raymond Chen

It's frustrating when people who are presumably smart (or who are at least pretending to be) have a problem and are satisfied to receive the magic phrase they need to type with no interest at all in understanding why the magic phrase works. For example, here's a question sent to an internal mailing list for users of something I'll call Program Q. From: X Why is it that after I use program Q to create a table, nothing else works? Here's a batch file I've written: q create table newtable pause q create table newtable2 The pause command never executes; in fact, nothing in the batch file executes after t...

Apr 15, 2009
Post comments count 0
Post likes count 1

Taxes redux: You can’t open the file until the user tells you to open it

Raymond Chen

One of the so-called taxes of software development on Windows is being respectful of Hierarchical Storage Management. You can't open a file until the user tells you to open it. This rule has consequences for how Explorer extracts information about a file, because what you definitely don't want is for opening a folder full of archived files in Explorer to result in all the files being recalled from tape. (Actually, file recall is just an extreme case of the cost of opening the file. You run into a similar problem if the file is on a slow medium or over a slow network connection. But just to motivate the discussio...

Apr 14, 2009
Post comments count 0
Post likes count 1

Microspeak: The plate

Raymond Chen

To have a lot on one's plate means to have a lot of tasks and responsibilities. We shouldn't give this task to Bob. He already has a lot on his plate. (Or: He already has a full plate.) At Microsoft, this common English language idiom is treated as a normal part of the language. The metaphorical plate has become a synonym for assigned tasks and responsibilities and can be used as a basis for new idioms. That feature moved off their plate onto ours. Feature X got postponed to the next release, so there's room on our plate for Feature Y. Update: Apparently there are some people who believe ...

Apr 13, 2009
Post comments count 0
Post likes count 1

Why is there no support in the window manager for mouse button chording?

Raymond Chen

Commenter Nekto2 asks why there is no mouse action associated with "click both buttons at the same time". The window manager doesn't fire a special event for both mouse buttons held down simultaneously like it does for double-clicks. As with higher-order clicks, mouse chording is something that you have to put together yourself from the basic mouse events that the window manager generates. Add these lines to our scratch program: void OnButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) { if ((keyFlags & (MK_LBUTTON | MK_RBUTTON)) == (MK_LBUTT...