The Old New Thing

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

How do I print the contents of a rich text control?

For some reason, people are really puzzled by rich edit printing. I'm no expert on printing, but even I was able to figure it out. The kernel is the message. Each time you call it, a little bit more of the rich text control is printed, and the message returns the index of the first unprinted character, which you can pass back in to print the...

How do I put more than 32,000 characters into a rich text control?

Last time we looked at loading an entire file into a rich text control. The code runs great, until you try to use it to display a license agreement provided by your legal department, and then some paranoid user reports that they can't read past page seven. (What, somebody reads those things?) What's going on? If you don't specify otherwise...

How do I load an entire file into a rich text control?

To load an entire file into a rich text control, you can use the message, which accepts an of data all at once. Once you find the message, it's pretty straightforward how to use it, but I'll write out the code anyway; You pretty much follow your nose. The message wants you to tell it the format of the stream () and provide a pointer to ...