The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

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, ...

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

Fortune cookie fortunes are getting less and less interesting all the time

Raymond Chen

I remember reading a story about the history of fortune cookie fortunes, and how the pool of fortunes has been getting smaller because people keep complaining about them. In the article, they gave as an example that the fortune "You will meet a stranger" was removed from the fortune library because somebody complained that it was too scary. The effects of this trend toward meaningless fortunes continue to be felt. A few years ago, I opened a fortune cookie and looked at the slip of paper inside. It read simply Someone will give you something.

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

A concrete illustration of practical running time vs big-O notation

Raymond Chen

Memory access time changes the math.

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

Spam trackback attack week 2 statistics

Raymond Chen

The trackback spam attack is well into its second week now. The people who run blogs.msdn.com blocked all access from the IP address block, which not only blocks trackbacks but also prevents them from reading the content (and therefore prevents them from scraping). Undaunted, the sites just moved to a new IP address.