The Old New Thing

Controlling resource consumption by meting out work items

At the PDC, one person came to talk to me for advice on a resource management problem they were having. To simplify, their system generated dozens of work items, each of which required significant resource consumption. For the sake of illustration, let's say that each of the work items was a single-threaded computationally-intensive operation ...

A thread waiting on a synchronization object could be caught napping

If you have a synchronization object, say a semaphore, and two threads waiting on the semaphore, and you then release two semaphore tokens with a single call to , you would expect that each of the waiting threads would be woken, each obtaining one token. And in fact, that's what happens—most of the time. Recall in our discussion of why...

If you ask for a window caption, you also get a border

Some people may have noticed that the is defined as the combination of and : Since includes , it is impossible to get a caption without a border. Sometimes people don't quite get this and keep asking the question over and over again, and I have to keep trying to explain the laws of logic in different ways until one of them finally ...

Why is there no message for disabling the Cancel button on a wizard?

Some people have noticed that there is no message that lets you disable the Cancel button on a wizard. This is on purpose. Usability studies reveal that users find it extremely frustrating when they get partway through a wizard and then decide they don't want to perform the operation after all, but find that the wizard doesn't give them a way ...

The consequences of invalidating the null window

On occasion, you might notice that every window on the desktop flickers and repaints itself. One of the causes for this is a simple null handle bug. The function is one you're probably well-familiar with. It is used to indicate to the window manager that the pixels of a particular window are no longer current and should be repainted. (You ...

Very late remarks on the original Chinese dictionary series

I have not forgotten about the Chinese/English dictionary series, but I simply haven't had the motivation to sit down and write up descriptions and discussion for the code that I wrote along the way, so instead of adding to the program, I'm going to answer some questions that were asked back when I started the series but which I didn't respond...

Restating the obvious about the WM_COMMAND message

I'm satisfied with the MSDN documentation for the message, but for the sake of mind-numbing completeness, I'm going to state the obvious in the hope that you, dear readers, can use this technique to fill in the obvious in other parts of MSDN. The one-line summary of the message says, "The WM_COMMAND message is sent when the user selects ...

Keep your eye on the code page, practical exam

The instructions that came with my new monitor are printed in several languages. One of those languages is Polish, or at least it would be Polish if... well, you'll see. UWAGA: Szczegó³owe informacje dla u¿ytkownika znajduj¹ siê na do³¹czonej p³ycie CD. This is garbage. What they meant to write was...

Changing a window class affects all windows which belong to that class

Sometimes you need to state the obvious, and that's fine. You can learn a lot from the obvious. For example, the first topic in my PDC talk consisted of simply stating the obvious. Occasionally, when you state the obvious, you have to follow up by stating the obvious. When I pointed out that the effect of lasts only until the next , one ...

Enumerating threads in a process

The tool helper library is sort of the black sheep of Win32. It grew out of the 16-bit TOOLHELP library, which provided services for system debugging tools to do things like take stack traces and enumerate all the memory in the system. The original incarnation of Win32 didn't incorporate it; it wasn't until Windows 95 that a 32-bit ...