# The Old New Thing

## Answers to exercise from Scrollbars Part 11

Exercise: Why do we use the formula instead of the simpler ? Answer: To avoid integer overflow in the computation of . Here, and are window coordinates, and the window can be anywhere. If the window were placed at extreme coordinates like (MAXLONG,MAXLONG), then the ...

## Scrollbars part 12: Applying WM_NCCALCSIZE to our scrollbar sample

Now that we have learned about the intricacies of the message, we can use it to get rid of the flicker in our resizing code. We just take the trick we used above and apply it to the scroll program. First, we need to get rid of the bad flickery resize, so return the OnWindowPosChanging function...

## Scrollbars part 11: Towards an even deeper understanding of the WM_NCCALCSIZE message

The other form of the message is the complicated one, when the is . In this case, the is a pointer to a structure. When Windows sends the message, the structure is filled out like this: Notice that the client rectangle is given in ...

## Eric's complete guide to BSTR semantics

Eric Lippert has posted Eric's Complete Guide to BSTR Semantics. This is a document that is widely valued within Microsoft, since BSTR semantics are rather tricky, and I'm glad he's willing to share it with the world. In particular, Eric spends quite a bit of time discussion the very ...

## Answers to exercises from Scrollbars Part 10

Answers to exercises from Scrollbars Part 10.

## Scrollbars part 10 – Towards a deeper understanding of the WM_NCCALCSIZE message

When your window is resized, Windows uses the message to determine where your window's client area lives inside your window rectangle. There are two forms of the message. The simple form merely takes a window rectangle and returns a client rectangle. This is useful for resizing a window...

## Scrollbars part 9 – Maintaining the metaphor

When a document is displayed with scrollbars, the metaphor is that the window is a viewport onto the entire document, only a portion of which is visible at the moment. The default behavior of a resize, however, is to maintain the origin at the upper left corner of the client area, which breaks the metaphor...

## Where is my program running from?

Another common question: "How do I find out where my program is? I want to be able to access support files in that same directory." Answer: GetModuleFileName(NULL...

## Case mapping on Unicode is hard

Occasionally, I'm asked, "I have to identify strings that are identical, case-insensitively.  How do I do it?" The answer is, "Well, it depends. Whose case-mapping rules do you want to use?" Sometimes the reply is, "I want this to be language-independent." Now ...

## How to recognize different types of timestamps from quite a long way away

The great thing about timestamps is that there are so many to choose from.