Showing tag results for 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
Sep 11, 2003
Post comments count0
Post likes count0

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

Raymond Chen
Raymond Chen

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

Code
Sep 9, 2003
Post comments count0
Post likes count0

Scrollbars part 9 – Maintaining the metaphor

Raymond Chen
Raymond Chen

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

Code