Showing tag results for Code

Feb 8, 2007
Post comments count0
Post likes count1

Why does my property sheet blink and the immediately disappear?

Raymond Chen

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, an a...

Code
Feb 7, 2007
Post comments count0
Post likes count1

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

Raymond Chen

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

Code
Feb 6, 2007
Post comments count0
Post likes count1

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

Raymond Chen

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

Code
Jan 29, 2007
Post comments count0
Post likes count1

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

Raymond Chen

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

Code
Jan 23, 2007
Post comments count0
Post likes count1

Non-psychic debugging: If you can't find something, make sure you're looking in the right place

Raymond Chen

This isn't psychic debugging, but it's the sort of dumb mistake everybody makes and which you can't see when re-reading your code because your brain shows you what you want to see, not what's really there. I'm trying to respond to the notification, but it's not working. What am I doing wrong? You can stare at this code for ages and completel...

Code
Jan 22, 2007
Post comments count0
Post likes count1

The cost of continuously-visible affordances with dynamic states

Raymond Chen

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

Code
Jan 16, 2007
Post comments count0
Post likes count1

EnumChildWindows already enumerates recursively

Raymond Chen

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

Code
Jan 12, 2007
Post comments count0
Post likes count1

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

Raymond Chen

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

Code
Jan 11, 2007
Post comments count0
Post likes count1

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

Raymond Chen

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

Code