Showing results for Code - The Old New Thing

Aug 1, 2006
Post comments count0
Post likes count0

C# nested classes are like C++ nested classes, not Java inner classes

Raymond Chen
Raymond Chen

When you declare a class inside another class, the inner class still acts like a regular class. The nesting controls access and visibility, but not behavior. In other words, all the rules you learned about regular classes also apply to nested classes. The keyword in an instance methods of a class (nested or not) can be used to access members of...

Code
Jul 10, 2006
Post comments count0
Post likes count0

Before you can learn to recognize what's wrong, you must learn to recognize what's right

Raymond Chen
Raymond Chen

Sometimes, when I'm debugging a problem, I'll ignore a particular thread and somebody will ask, "What is that thread doing, and how did you know to ignore it?" My reply: "I have no idea what it's doing, but whatever it's doing, it's normal." Tess has been running an excellent series of posts on debugging the CLR, but one of the most important le...

Code
Jul 6, 2006
Post comments count0
Post likes count0

Is the maximum size of the environment 32K or 64K?

Raymond Chen
Raymond Chen

There appears to be some confusion over whether the maximum size of the environment is 32K or 64K. Which is it? Both. The limit is 32,767 Unicode characters, which equals 65,534 bytes. Call it 32K or 64K as you wish, but make sure you include the units in your statement if it isn't clear from context.

Code
Jul 3, 2006
Post comments count0
Post likes count0

Security: Don't forget to initialize the stuff you don't care about

Raymond Chen
Raymond Chen

Lost in excitement of privilege escalation vulnerabilities is the simple information disclosure through missing garbage initialization. Everybody should by now be familiar with the use of the function to ensure that buffers that used to contain sensitive information are erased, but you also have to zero out buffers before you write their contents...

Code
Jun 29, 2006
Post comments count0
Post likes count0

Generating tooltip text dynamically

Raymond Chen
Raymond Chen

Our multiplexed tooltip right now is displaying the same string for all items. Let's make it display something a bit more interesting so it's more obvious that what we're doing is actually working. Instead of providing fixed tooltip text, we generate it on the fly by setting the text to and producing the text in response to the notification. ...

Code
Jun 28, 2006
Post comments count0
Post likes count0

Multiplexing multiple tools into one in a tooltip

Raymond Chen
Raymond Chen

The tooltip control lets you set multiple "tools" (regions of the owner window) for it to monitor. This is very convenient when the number of tools is manageably small and they don't move around much. For example, the toolbar control creates a tool for each button. But if you have hundreds or thousands of screen elements with tooltips, creating a ...

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