The Old New Thing

An auto-reset event is just a stupid semaphore

When you create an event with the function, you get to specify whether you want an auto-reset event or a manual-reset event. Manual-reset events are easy to understand: If the event is clear, then a wait on the event is not satisfied. If the event is set, then a wait on the event succeeds. Doesn't matter how many people are waiting for the ...

Psychic debugging: Understanding DDE initiation

You too can use your psychic powers to debug the following problem: We have a problem with opening documents with our application by double-clicking them in Explorer. What's really strange is that if we connect a debugger to Explorer and set a breakpoint on , then wait a moment after returns, then hit '', then the document opens fine. But...

Window class properties apply to all windows that belong to the class

Window class properties apply to all windows that belong to the class. That's why they're called class properties. This seems like an obvious thing to say when put in so many words, but I see many "solutions" that lose sight of this simple fact. All the properties that you set in the (or ) are window class properties, as are the properties...

Pitfalls of transparent rendering of anti-aliased fonts

Windows provides a variety of technologies for rendering monochrome text on color displays, taking advantage of display characteristics to provide smoother results. These include grayscale anti-aliasing as well as the more advanced ClearType technique. Both of these methods read from the background pixels to decide what pixels to draw in the...

Remember what happens when you broadcast a message

Occasionally I catch people doing things like broadcasting a message to all top-level windows. This is one of those things that is so obviously wrong I don't see how people even thought to try it in the first place. Suppose you broadcast the message What happens? Every top-level window receives the message with the same parameters, ...

The forgotten common controls: The MenuHelp function

The function is one of the more confusing ones in the common controls library. Fortunately, you will almost certainly never had need to use it, and once you learn the history of the function, you won't want to use it anyway. Our story begins with 16-bit Windows. The message is sent to notify a window of changes in the selection state of ...

Why can't you say </script> in a script block?

Because it ends the script block, of course. Duh, what's so hard about that? Because if you have script that generates script, you'll find yourself caught out if you're not careful. For example, you can't say in a script block because the HTML parser will see the and conclude that your script block is over. In other words, the script ...

What does the CS_CLASSDC class style do?

Last time, I talked about the historical background for the class style and why it starts out sounding like a good idea but when you think about it some more turns out to be an awful idea. The class style is the same thing, but worse, for it takes all the problems of and magnifies them. Recall that the class style instructs the window ...

What does the CS_OWNDC class style do?

Recall that window DCs are most commonly used only temporarily. If you need to draw into a window, you call or, if outside of a paint cycle, , although painting outside of a paint cycle is generally to be avoided. The window manager produces a DC for the window and returns it. You use the DC, then restore it to its original state and return ...