The Old New Thing

What does LockWindowUpdate do?

Poor misunderstood . This is the first in a series on , what it does, what it's for and (perhaps most important) what it's not for. What does is pretty simple. When a window is locked, all attempt to draw into it or its children fail. Instead of drawing, the window manager remembers which parts of the window the application tried to draw...

Why don't I use any class libraries in my sample code?

As a general rule, I avoid using any class libraries in my sample code. This isn't because I'm opposed to class libraries, but rather because I don't want to narrow my audience to "people who use MFC" (to choose one popular class library). If I were to start using MFC for all of my samples, I'd probably lose all the people who don't use MFC...

Why does my property sheet blink and the immediately disappear?

Occasionally, a customer will ask, "I'm trying to display a property sheet, but when I call the function, the property sheet blinks onto the screen and then immediately disappears. What is wrong?" Recall that displaying a property sheet entails filling out a structure, which in turn contains a pointer to either an array of s, or more often...

Why can't I create my dialog box? Rookie mistake #2

Another class of rookie mistake is less obvious from looking at the code. The problem with this code is that we forgot to call to register the listview class. More generally, the problem is that one of the controls on the dialog uses a window class that was not registered. (For example, maybe there's a rich edit control on the dialog, but...

Why can't I create my dialog box? Rookie mistake #1

Each dialog box resource is specified either by an integer ordinal or by a string name. But a simple typo will turn one into the other. Do you see the two "classic rookie mistakes"? It may be easier to spot if you take the resource file and send it through the preprocessor first: The first call to passes as the resource name. But ...

If vertical strips are better, why do toolbars use horizontal strips?

If vertical strips are better, why do toolbars use horizontal strips? An early version of the toolbar control first made its appearance in Windows 3.0, and in those days, screen resolutions were low and toolbar buttons were small. Horizontal or vertical didn't really matter. Ten bitmaps, each 16 × 16, at 4-bit color, comes out to...

The cost of continuously-visible affordances with dynamic states

Serge Wautier asks, "Why are the copy/cut/paste buttons not disabled when there's nothing to copy/cut/paste?", noting that the back/forward buttons do disable themselves when navigation is not possible in that direction. To get to this question, we'll first go back in time a bit to a world without toolbars. In those early days, these dynamic ...

EnumChildWindows already enumerates recursively

I often see people write code that goes something like this: The intent here was to perform the operation on all the windows in a window tree by operating on the root, then operating on each of the children. Operating on the children is in turn performed recursively, so that we eventually see every window in the tree. Except that if you ...