Showing tag results for Code

Jan 23, 2007
Post comments count0
Post likes count0

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

Raymond Chen
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 count0

The cost of continuously-visible affordances with dynamic states

Raymond Chen
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 count0

EnumChildWindows already enumerates recursively

Raymond Chen
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 count0

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

Raymond Chen
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 count0

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

Raymond Chen
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
Jan 10, 2007
Post comments count0
Post likes count0

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

Raymond Chen
Raymond Chen

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

Code
Jan 9, 2007
Post comments count0
Post likes count0

What triggers the recall of an offline file?

Raymond Chen
Raymond Chen

Hierarchical storage management is one of the taxes software developers have to pay. What can you safely do to an offline file? What will trigger its recall? (First, a note on terminology: Recalling a file means to restore it from remote storage to local storage. A file that has been recalled is online; a file that has been placed on remote stora...

Code
Jan 5, 2007
Post comments count0
Post likes count0

What('s) a character!

Raymond Chen
Raymond Chen

Norman Diamond seems to have made a side career of harping on this topic on a fairly regular basis, although he never comes out and says that this is what he's complaining about. He just assumes everybody knows. (This usually leads to confusion, as you can see from the follow-ups.) Back in the ANSI days, terminology was simpler. Windows opera...

Code
Jan 2, 2007
Post comments count0
Post likes count0

Why can't I GetProcAddress for CreateWindow?

Raymond Chen
Raymond Chen

Occasionally, I'll see people having trouble trying to for functions like or . Usually, it's coming from people who are trying to write p/invoke signatures, for p/invoke does a under the covers. Why can't you for these functions? Because they're not really functions. They're function-like macros: In fact, as you can see above is doubly a...

Code