Showing tag results for Code

Jun 27, 2006
Post comments count0
Post likes count0

Using custom-draw in tooltips to adjust the font

Raymond Chen
Raymond Chen

Last time, we looked at in-place tooltips. In that example, we finessed the font problem by simply setting the destination font into the tooltip control. We got away with that since we had only one tool. But if you have multiple tools with different fonts, then you can't set a font into the tooltip control and expect it to work for every tool. Th...

Code
Jun 26, 2006
Post comments count0
Post likes count0

Coding in-place tooltips

Raymond Chen
Raymond Chen

Today we'll look at how to implement in-place tooltips. These are tooltips that appear when the user hovers the mouse over a string that cannot be displayed in its entirety. The tooltip overlays the partially-displayed text and provides the remainder of the text that had been truncated. The keys to this technique are the notification (which lets ...

Code
Jun 22, 2006
Post comments count0
Post likes count0

An auto-reset event is just a stupid semaphore

Raymond Chen
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
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
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
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
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
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
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
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