|Date:||February 8, 2007 / year-entry #46|
|Summary:||Occasionally, a customer will ask, "I'm trying to display a property sheet, but when I call the PropertySheet 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 PROPSHEETHEADER structure, which in turn contains a pointer to either an array...|
Occasionally, a customer will ask, "I'm trying to display a property sheet, but when I call the
Recall that displaying a property sheet entails filling out a
When you ask for a property sheet to be displayed, the property sheet manager looks up each of the pages you specified in order to get its title, and then it starts off by displaying the page you specified in the
Of course, in order to display the page to the user, the property sheet manager needs to create the dialog whose template you specified. And that's where the property sheet can blink out of existence: If the property sheet manager tries to create the dialog corresponding to a property sheet page, but the call to
If you make a rookie mistake and either specify the wrong dialog template or fail to register all the classes that your dialog template requires, then the property sheet manager will try to create your first property sheet page and fail. "Fine, let's try the second one, then." And that fails. "How about the third one?" And that fails. Finally, the property sheet manager has tried every single page and none of them could be created. That's when it gives up and tears down the property sheet.
This also explains why you might see a property sheet page that disappears once you click on its tab. The same thing happened: The property sheet manager tried to create the dialog, but the
This is what often gets mistaken for psychic debugging. You just explore the space logically, consider at each step what could go wrong, and from that list of possible mistakes, choose the one that sounds the most likely. If you just jump directly to your conclusion, people will think you're psychic.
"My psychic powers tell me that you forgot to call
"Wow, that's amazing! How did you know that?"
Sherlock Holmes used the same technique to draw startling conclusions in many of Arthur Conan Doyle's stories. Each step in the chain of reasoning was relatively simple and straightforward, but by chaining them together and announcing the conclusion directly, people will think you're psychic.
*You can override the title by setting the
‡Nitpicking a nitpick, if you use
<-- Back to Old New Thing Archive Index