Showing tag results for Code

Jun 22, 2006
Post comments count0
Post likes count0

An auto-reset event is just a stupid semaphore

Raymond Chen

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 event;...

Code
Jun 21, 2006
Post comments count0
Post likes count0

Psychic debugging: Understanding DDE initiation

Raymond Chen

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 if w...

Code
Jun 15, 2006
Post comments count0
Post likes count0

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

Raymond Chen

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

Code
Jun 14, 2006
Post comments count0
Post likes count0

Pitfalls of transparent rendering of anti-aliased fonts

Raymond Chen

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

Code
Jun 12, 2006
Post comments count0
Post likes count0

Remember what happens when you broadcast a message

Raymond Chen

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

Code
Jun 8, 2006
Post comments count0
Post likes count0

The forgotten common controls: The MenuHelp function

Raymond Chen

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 a men...

Code
Jun 7, 2006
Post comments count0
Post likes count0

If you're going to try to simulate user actions, make sure the user can do them

Raymond Chen

Many people like to simulate user actions programmatically. I'm not going to comment here on whether that's a good idea to begin with; what I want to point out is that if you're going to do it, you have to make sure you're simulating things the user can actually do. For example, if you want to act as if the user clicked the "close" button in the ...

Code
Jun 5, 2006
Post comments count0
Post likes count0

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

Raymond Chen

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

Code
Jun 2, 2006
Post comments count0
Post likes count0

What does the CS_CLASSDC class style do?

Raymond Chen

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

CodeHistory
Jun 1, 2006
Post comments count0
Post likes count2

What does the CS_OWNDC class style do?

Raymond Chen

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 it to...

CodeHistory