The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

May 12, 2014
Post comments count 0
Post likes count 1

Enumerating bit sequences with isolated zero-bits via the Fibonacci recurrence

Raymond Chen

Today's Little Program enumerates bit sequences of a particular length subject to the constraint that you cannot have consecutive 0-bits. This may sound kind of arbitrary, but it is important in magnetic media storage, because you cannot go too long without a flux reversal (traditionally represented by a 1); otherwise, the read head's clock starts to drift and gets out of sync with the data. (The read head uses flux reversals both for signaling and for clock synchronization.) Let's say that an allowable bit sequence is one that contains no consecutive 0-bits. The recurrence for enumerating these types of co...

May 9, 2014
Post comments count 0
Post likes count 1

Even if you're the President, your mother still has the power to embarrass you

Raymond Chen

Last year, in honor of Mother's Day (the United States version), the John F. Kennedy Library shared a letter sent by President Kennedy to his mother. Mrs. Kennedy had contacted Premier Khrushchev asking for an autographed photo, copies of which were subsequently forwarded to the White House so that the President could sign them as well. President Kennedy tries to express in the politest language he can muster that the mother of a sitting president directly contacting a foreign dignitary is "subject to interpretations", and that in the future, it would be greatly appreciated if she would let the White House clea...

May 9, 2014
Post comments count 0
Post likes count 1

When was the WM_COPYDATA message introduced, and was it ported downlevel?

Raymond Chen

Gabe wondered when the message was introduced. The message was introduced by Win32. It did not exist in 16-bit Windows. But it was there all along. The The message was carefully designed so that it worked in 16-bit Windows automatically. In other words, you retained your source code compatibility between 16-bit and 32-bit Windows without having to do a single thing. Phew, one fewer breaking change between 16-bit and 32-bit Windows. As Neil noted, there's nothing stopping you from sending message in 16-bit Windows with a window handle in the and a pointer to a in the . Since all 16-bit applications ra...

May 8, 2014
Post comments count 0
Post likes count 1

How can you use both versions 5 and 6 of the common controls within the same module?

Raymond Chen

Commenter Medinoc was baffled by the statement that the decision to use the visual-styles-enabled version of the common controls library is done on a window-by-window basis. " Isn't it rather on a per-module basis, depending on each module's manifest? If it is indeed on a per-window basis, how does one choose?" Whether a particular call to (or one of its moral equivalents) gets the classic version of the control or the visual-styles-enabled version of the control depends on which activation context is active at the point of the call. If an activation context with version 6 of the common controls is active, th...

May 7, 2014
Post comments count 0
Post likes count 1

Why does saving a file in Notepad fire multiple FindFirstChangeNotification events?

Raymond Chen

Many people have noticed that the and functions (and therefore their BCL equivalent and WinRT equivalent ) fire multiple events when you save a file in Notepad. Why is that? Because multiple things were modified. Notepad opens the file for writing, writes the new data, calls to truncate any excess data (in case the new file is shorter than the old file), then closes the handle. Two things definitely changed, and a third thing might have changed. It's therefore not surprising that you got two events, possibly three. Remember the original design goals of the function: It's for letting an application ca...

May 6, 2014
Post comments count 0
Post likes count 1

Letting the boss think your project is classier than it really is

Raymond Chen

Once upon a time, there was a team developing two versions of a product, the first a short-term project to ship soon, and the other a more ambitious project to ship later. (Sound familiar?) They chose to assign the projects code names Ren and Stimpy, in honor of the lead characters from the eponymous cartoon series. Over time, the two projects merged, and the code name that stuck was Ren. When the project came up in a meeting with Bill Gates, it was mentioned verbally but never spelled out, and since Bill wasn't closely tuned into popular culture, he mapped the sound /rɛn/ not to the hairless Mexican dog...

May 5, 2014
Post comments count 0
Post likes count 0

Warehouse holding 1000 cans of surströmming burns to the ground, insert punch line here

Raymond Chen

A warehouse in Sweden holding 1000 cans of surströmming burned to the ground last week. No people were injured. The cans of surströmming, already prone to violent decompression under normal conditions, exploded over a period of six hours. Some of them turned into projectiles and shot through the air. No information on what effect this will have on the supply of surströmming ice cream. I knew you were wondering.

May 5, 2014
Post comments count 0
Post likes count 1

Getting the location of the Close button in the title bar

Raymond Chen

Today's Little Program locates the × button in the corner of the window and, just to show that it found it, displays a balloon tip pointing at it. Let's start with the program from last week, the one that displays a balloon tip, then make these changes: Instead of positioning the balloon at the cursor position, we put it at the center of the Close button. We use the message to obtain information about the window title bar, specifically checking information about the Close button. After verifying that it is visible and on-screen and enabled, we calculate its center point and return success. The me...

May 2, 2014
Post comments count 0
Post likes count 1

If a lot of settings are ignored when set in a DLL, why bother even letting you set them on a DLL?

Raymond Chen

There are many settings that are ignored when set in a DLL. . and . There are plenty of others. Commenter 640k asks why these settings even exist for DLLs if they has no effect. Because they are settings for PE modules in general. If there were separate file formats for EXEs and DLLs, then there would have to be two different module loaders, one for EXEs and one for DLLs. This creates extra work for no particular benefit aside from satisfying some anal-retentive compulsion that nothing be wasted. As far as I can tell, all operating systems use a common file format for both executables and libraries. If it...