Answer to previous exercise about the mythical WM_MOUSEENTER message
If the program starts with the mouse already in the client area without moving, why do you get a beep?
If the program starts with the mouse already in the client area without moving, why do you get a beep?
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...
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...
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...
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...
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...
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...
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 ...
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 parent coo...
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...