The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Jun 19, 2009
Post comments count 0
Post likes count 0

The butter and the money for the butter

Raymond Chen

In a discussion a few years ago, I saw the phrase, "Now you have the butter and the money." This was new to me, and a little Web searching (guided in part by a guess at the author's nationality) revealed it to be a French proverb, the full version of which is On ne peut pas avoir le beurre et l'argent du beurre: "You can't have the butter and the money for the butter." It's a really nice phrase, and maybe someday I'll be able to use it. Bonus butter idiom: Reading the blog of a German colleague, I ran across the phrase alles wieder in Butter ("everything back in butter"), which from context appeared to mean som...

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

You can’t leave a critical section you never entered

Raymond Chen

If you call on a critical section you never entered, the behavior is undefined. Critical sections are an extremly high-traffic code path. Intense work goes into making them as fast as possible. Customers like to ask questions like "Exactly how many cycles does it take to enter a critical section? We're not going to use them if they're too slow." They don't say what they are going to do if critical sections are too slow for them, but the threat is real (even if the justification is bogus). I've seen programmers respond to code feedback of the form "You need a critical section here" with "No, I'm not going to bo...

Jun 18, 2009
Post comments count 0
Post likes count 1

Don’t you hate it when someone leaks a ref to your clothes?

Raymond Chen

The other night I had a dream in which one of my friends said, "Check out my clothes closet. This dress is hideous, but I can't get rid of it because there's still a reference to it from my blog." The dresses were labeled through .

Jun 18, 2009
Post comments count 0
Post likes count 1

The dangers of mixing synchronous and asynchronous state

Raymond Chen

The window manager distinguishes between synchronous state (the state of the world based on what messages your program has received) and asynchronous state (the actual state of the world this very instant). We saw this earlier when discussing the difference between GetKeyState and GetAsyncKeyState. Here are some other functions and their relationship to the queue state: Use synchronous state Use asynchronous state GetActiveWindow GetForegroundWindow GetMessagePos GetCursorPos GetMessageTime GetTickCount If you query the asynchronous state while processing a message, you can find yourself cau...

Jun 17, 2009
Post comments count 0
Post likes count 0

Welcome to Leavenworth, Washington’s faux-Bavarian village

Raymond Chen

The dying logging town of Leavenworth, Washington reinvented itself in the 1960's as a faux-Bavarian village. Today, over a million tourists visit annually to enjoy the scenic mountain views, soak in the fake Bavarian atmosphere, and revel in events like the Leavenworth International Accordion Celebration which starts tomorrow, or the three-weekend-long Leavenworth Oktoberfest every October. (Mind you, the Leavenworth Oktoberfest doesn't actually start until the Munich Oktoberfest is nearly over, because Oktoberfest starts in September.) I found during a brief visit to Leavenworth that the people there may d...

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

Sure, I can get spurious WM_MOUSEMOVE messages, but why do they keep streaming in?

Raymond Chen

I wrote some time ago that the window manager generates spurious messages in order to let programs know that the mouse has entered the window even if the reason was a window hierarchy reshuffle rather than a physical motion of the pointing device. But some people have noticed that that explanation fails to account for all the messages that are being delivered. In particular, the reasoning fails to explain why a stream of messages is being generated. So where is this infinite stream of messages coming from, even when the window hierarchy is stable? They're most likely coming from some third party so-called...

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

Management-speak: Upping the sats and stimulating the ecosystem

Raymond Chen

Here's another sentence that's so loaded with buzzwords and buzzphrases I'm not sure what language it's written in. I just want to have creative control over how my audience can interact with me without resorting to complex hacking in a way that is easy to explain but ups our blogging audiences sats to a new level that may also stimulate a developer ecosytem that breeds quality innovation... The ellipses are in the original, if that helps any. The scary thing is: The person who wrote this isn't even a manager.

Jun 15, 2009
Post comments count 0
Post likes count 0

Happening to be at the same post-concert restaurant as symphony performers

Raymond Chen

Getting out of the parking garage immediately after the symphony ends is usually a bit of an ordeal, so my symphony group tends to linger downtown for some coffee or dessert, allowing time for the post-symphony traffic jams to clear out. The other night, we went to the Union restaurant just a block from Benaroya Hall. (Verdict: Not a good dessert restaurant.) After we placed our orders, violinists Elisa Barston (my current "favorite symphony performer") and Mikhail Shmidt came in and were seated at the table next to us. I tried not to stare, but even though I've sat quite close to Elisa Barston before, this ti...

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

Why do some file operations take file names and others take handles?

Raymond Chen

Commenter Brian Friesen asks why some functions (like SetFileAttributes) take a file name, while others (like SetFileTime) take a handle and why we can't have two versions of every API, one for each pattern. Second question first: No need to wait for the kernel folks to write such a function; you can already do it yourself! // Following "pidgin Hungarian" naming convention, which appears // to be dominant in <winbase.h>... BOOL SetFileTimesByNameW(LPCWSTR lpFileName, CONST FILETIME *lpCreationTime, CONST FILETIME *lpLastAccessTime, ...