The Old New Thing

Using the TAB key to navigate in non-dialogs

The IsDialogMessage function works even if you aren't a dialog. As long as your child windows have the WS_TABSTOP and/or WS_GROUP styles, they can be navigated as if they were part of a dialog box. One caveat is that IsDialogMessage will send DM_GETDEFID and DM_SETDEFID messages to your window, which are ...
Comments are closed.0 0
Code

Scrollbars redux: Part 12

Reader Jeff Miller added Word-style scroll tips to our sample scrollbar program. Here's how he did it: A tracking tooltip is used to display the scroll tip because we don't want the tooltip to do automatic positioning or automatic show/hide. When a tracking scroll occurs (...
Comments are closed.0 0
Code

Why is there no WM_MOUSEENTER message?

There is a WM_MOUSELEAVE message. Why isn't there a WM_MOUSEENTER message? Because you can easily figure that out for yourself. When you receive a WM_MOUSELEAVE message, set a flag that says, "The mouse is outside the window." When you receive a WM_MOUSEMOVE message and the flag...
Comments are closed.0 0
Code

Other uses for bitmap brushes

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. ...
Comments are closed.0 0
Code

Stupid memory-mapping tricks

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 ...
Comments are closed.0 0
Code

Why do I get spurious WM_MOUSEMOVE messages?

In order to understand this properly, it helps to know where WM_MOUSEMOVE 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...
Comments are closed.0 0
Code

The end of the scrollbar series

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 ...
Comments are closed.0 0
Code

Answers to exercise from Scrollbars Part 11

Exercise: Why do we use the formula c = a + (b-a)/2 instead of the simpler c = (a+b)/2? Answer: To avoid integer overflow in the computation of a+b. Here, a and b are window coordinates, and the window can be anywhere. If the window were placed at extreme coordinates like (...
Comments are closed.0 0
Code

Scrollbars part 12: Applying WM_NCCALCSIZE to our scrollbar sample

Now that we have learned about the intricacies of the WM_NCCALCSIZE 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 ...
Comments are closed.0 0
Code

Feedback usabilla icon