Showing results for Code - The Old New Thing

Oct 13, 2003
Post comments count0
Post likes count0

Why is there no WM_MOUSEENTER message?

Raymond Chen
Raymond Chen

There is a message. Why isn't there a message? Because you can easily figure that out for yourself. When you receive a message, set a flag that says, "The mouse is outside the window." When you receive a message and the flag is set, then the mouse has entered the window. (And cle...

Code
Oct 9, 2003
Post comments count0
Post likes count0

Other uses for bitmap brushes

Raymond Chen
Raymond Chen

Bitmap brushes used to be these little 8x8 monochrome patterns that you could use for hatching and maybe little houndstooth patterns if you were really crazy. But you can do better. CreatePatternBrush lets you pass in any old bitmap - even a huge one, and it will create a brush from it. The bi...

Code
Oct 7, 2003
Post comments count0
Post likes count1

Stupid memory-mapping tricks

Raymond Chen
Raymond Chen

Shared memory is not just for sharing memory with other processes. It also lets you share memory with yourself in sneaky ways. For example, this sample program (all error checking and cleanup deleted for expository purposes) shows how you can map the same shared memory into two locations simultaneousl...

Code
Oct 1, 2003
Post comments count0
Post likes count0

Why do I get spurious WM_MOUSEMOVE messages?

Raymond Chen
Raymond Chen

In order to understand this properly, it helps to know where messages come from. When the hardware mouse reports an interrupt, indicating that the physical mouse has moved, Windows determines which thread should receive the mouse move message and sets a flag on that thread's input queue that...

Code
Sep 17, 2003
Post comments count0
Post likes count0

The end of the scrollbar series

Raymond Chen
Raymond Chen

Okay, that's basically the end of the scrollbar series. Do people actually like the idea of a coding series? It gets very few comments, and it's a lot of work to write, so if nobody actually cares I can just write about quick little things and not try to be coherent from day to day. I guess that's what most blogs are like anyway. If you like th...

Code
Sep 17, 2003
Post comments count0
Post likes count0

Answers to exercise from Scrollbars Part 11

Raymond Chen
Raymond Chen

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

Code
Sep 17, 2003
Post comments count0
Post likes count0

Scrollbars part 12: Applying WM_NCCALCSIZE to our scrollbar sample

Raymond Chen
Raymond Chen

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

Code
Sep 15, 2003
Post comments count0
Post likes count0

Eric's complete guide to BSTR semantics

Raymond Chen
Raymond Chen

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

Code