The Old New Thing

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

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

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

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

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

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

Generating tooltip text dynamically

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

Multiplexing multiple tools into one in a tooltip

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

Using custom-draw in tooltips to adjust the font

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

Coding in-place tooltips

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

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