Answer to previous exercise about m_fRecursing

Answer to previous exercise: The m_fRecursing flag does not need to be per-instance. It only needs to be valid long enough that the recursive call that comes immediately afterwards can be detected. However, a global variable would not work because two threads might be inside the recursive DefDlgProc call simultaneously. But a thread-local variable would…


A different type of dialog procedure

In the discussion following my entry about dialog procedure return values, somebody suggested an alternate dialog design where you just call DefDlgProc to do default actions (the same way you write window procedures and DefWindowProc) rather than returning TRUE/FALSE. So let’s do that. In fact, we’re going to do it twice. I’ll cover one method…

2

Welcome Martyn Lovell

Martyn Lovell from the VC++ team has joined the world of blogging. Martyn is a smart guy, even though he does spell some words funny.


Safer subclassing

Answer to yesterday’s homework assignment, with discussion.

5

Homework assignment about window subclassing

Window subclassing is trickier than you think. Consider this code sketch: // Subclass the window for a little while WNDPROC OldWndProc = SubclassWindow(hwnd, NewWndProc); … do stuff … // Okay all done, remove our subclass by // restoring the previous window procedure SubclassWindow(hwnd, OldWndProc); What could go wrong? We’ll discuss it tomorrow.

6

A warning to people averse to code

This is going to be a code-heavy week. People who are averse to code may want to just lie low until next week. I’ll try to make it up by having next week be more storytelling-focused.


How much do you expect from a framework layer?

If a framework exposes functionality provided by a lower layer, how hard should the framework try to insulate you from all the quirks and limitations of the lower layer? Instinctively, of course, you would say, “The framework should insulate me completely.” But be careful what you ask for. If a framework insulated you completely, then…

10

Returning values from a dialog procedure

For some reason, the way values are returned from a dialog procedure confuses people, so I’m going to try to explain it a different way. The trick with dialog box procedures is realizing that they actually need to return two pieces of information: Was the message handled? If so, what should the return value be?…

15

Why are companies so worried about retraining costs?

Remember, most people do not view the computer as a world to be explored. It is merely a means to an end. So they learn the five steps they need to follow, and if they can’t do them, they get stuck. “I hit Alt+Tab like I always do, to switch to another program, but instead…

27