The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

How do I suppress full window drag/resize for just one window?
Jan 29, 2010
Post comments count 0
Post likes count 0

How do I suppress full window drag/resize for just one window?

Raymond Chen
Raymond Chen

A customer asked, Is there a way to turn off Full Window Drag on a single window? I have a resizable control that I would like not update itself while resizing. It so happens that I wrote a sample program ages ago to illustrate how to do this. You can find it in the Platform SDK under . The source code is also reproduced in this Knowledge Base article. In addition to deferring painting, you may also want to defer layout if layout is expensive for your window.

Microsoft phenomenon: The annual award that winds up being awarded only once
Jan 29, 2010
Post comments count 0
Post likes count 0

Microsoft phenomenon: The annual award that winds up being awarded only once

Raymond Chen
Raymond Chen

The Grammy Awards will be handed out this upcoming weekend, an annual award that seems to have survived. A not uncommon phenomenon at Microsoft is the annual award that winds up being awarded only once. Because all the excitement is in the announcement, not in the actual award. Every year, we want to uniquely call out and recognize a set of people. I'm proud to kick off the XYZ Awards, which we will be given every year, starting this year, which recognize employees who best represent ABC and DEF. The XYZ Awards were indeed handed out that first year with great pomp and circumstance. And were never heard from...

What idiot would hard-code the path to Notepad?
Jan 28, 2010
Post comments count 0
Post likes count 0

What idiot would hard-code the path to Notepad?

Raymond Chen
Raymond Chen

There seemed to be a great deal of disbelief that anybody would hard-code the path to Notepad. Here's one example and here's another. There's a large class of problems that go like this: I'm running Program X, and when I tell it to view the error log, I get this error message: What is wrong and how do I fix it? Obviously, the file is missing. But how can that be? Well, Windows Server 2008 bit the bullet and removed one of the copies of Notepad. Once you learn this, troubleshooting the above problem becomes a simple exercise in psychic debugging. My psychic powers tell me that you're running Wi...

If you are trying to understand an error, you may want to look up the error code to see what it means instead of just shrugging
Jan 27, 2010
Post comments count 0
Post likes count 0

If you are trying to understand an error, you may want to look up the error code to see what it means instead of just shrugging

Raymond Chen
Raymond Chen

A customer had a debug trace log and needed some help interpreting it. The trace log was generated by an operating system component, but the details aren't important to the story. I've attached the log file. I think the following may be part of the problem. Any ideas? Thanks, Bob Smith Senior Test Engineer Tailspin Toys What struck me is that Bob is proud of the fact that he's a Senior Test Engineer, perhaps because it makes him think that we will take him more seriously because he has some awesome title. But apparently a Senior Test Engineer doesn't know what error 2 is. There are some error c...

Microspeak: Zap
Jan 26, 2010
Post comments count 0
Post likes count 0

Microspeak: Zap

Raymond Chen
Raymond Chen

You may hear an old-timer developer use the verb zap. That proposed fix will work. Until everybody gets the fix, they can just zap the assert. The verb to zap means to replace a breakpoint instruction with an appropriate number of NOP instructions (effectively ignoring it). The name comes from the old Windows 2.x kernel debugger. (Actually, it may be even older, but that's as far back as I was able to trace it.) The (zap) command replaces the current instruction with a NOP if it is an (the x86 single-byte breakpoint instruction), or replaced the previous instruction with NOPs if it is an (the x86 two-by...

Why doesn't the window manager have a SetClipboardDataEx helper function?
Jan 25, 2010
Post comments count 0
Post likes count 0

Why doesn't the window manager have a SetClipboardDataEx helper function?

Raymond Chen
Raymond Chen

Jonathan Wilson asks why the clipboard APIs still require GlobalAlloc and friends. Why is there not a or something that does what does but without needing to call ? Okay, here's your function: Whoop-dee-doo. Historically, Windows doesn't go out of its way to include functions like this because you can easily write them yourself, or you can at least find a framework library that did it for you. Windows focused on doing the things that only Windows could do, providing you the building blocks with which you can create your own programs. Besides, the classic clipboard is so old-school. The OLE clipboard...

During process termination, the gates are now electrified
Jan 22, 2010
Post comments count 0
Post likes count 0

During process termination, the gates are now electrified

Raymond Chen
Raymond Chen

It turns out that my quick overview of how processes exit on Windows XP was already out of date when I wrote it. Mind you, the information is still accurate for Windows XP (as far as I know), but the rules changed in Windows Vista. What about critical sections? There is no "Uh-oh" return value for critical sections; doesn't have a return value. Instead, the kernel just says "Open season on critical sections!" I get the mental image of all the gates in a parking garage just opening up and letting anybody in and out. In Windows Vista, the gates don't go up. Instead they become electrified!...

Historically, Windows didn't tend to provide functions for things you can already do yourself
Jan 21, 2010
Post comments count 0
Post likes count 0

Historically, Windows didn't tend to provide functions for things you can already do yourself

Raymond Chen
Raymond Chen

Back in the old days, programmers were assumed to be smart and hardworking. Windows didn't provide functions for things that programs could already do on their own. Windows worried about providing functionality for thing that programs couldn't do. That was the traditional separation of responsibilities in operating systems of that era. If you wanted somebody to help you with stuff you could in principle do yourself, you could use a runtime library or a programming framework. You know how to open files, read them, and write to them; therefore, you could write your own file copy function. You know how to walk a l...

The wrong way to determine the size of a buffer
Jan 20, 2010
Post comments count 0
Post likes count 0

The wrong way to determine the size of a buffer

Raymond Chen
Raymond Chen

A colleague of mine showed me some code from a back-end program on a web server. Fortunately, the company that wrote this is out of business. Or at least I hope they're out of business!