Stay healthy: Drink Guinness

Flavenoids in Guinness combat fatty deposits in arteries. Note, however that the beer was consumed by being “fed … via tubes directly into their stomachs.” On the other hand, a friend of mine points out, “I thought a tube leading directly to the stomach was also called the esophagus. That’s my Guinness delivery system.”


Preventing edit control text from being autoselected in a dialog box

By default, when the user TABs to an edit control in a dialog box, the entire contents of the edit control are autoselected. This occurs because the edit control responds with the DLGC_HASSETSEL flag in response to the WM_GETDLGCODE message. To prevent it from happening, remove that flag. LRESULT CALLBACK RemoveHasSetSelSubclassProc (HWND hwnd, UINT uiMsg,…


British newspapers are much more fun to read

You can always count on The Register for a snarky take on the day’s technology news. Today’s favorite is this “review” of the nTAG, which ends with Well, we think that any sane person would have to held at gunpoint to induce them to carry an electronic device which, besides containing personal or other information…


Another different type of dialog procedure

The other method of using a window-procedure-like dialog box is to change the rules of the game. Normally, the window procedure for a dialog box is the DefDlgProc function, which calls the dialog procedure and then takes action if the dialog procedure indicated that it desired the default action to take place. The dialog procedure…


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…


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.


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.


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.