May 9th, 2007

Don't be helpless: At least look at the function you're using

Sometimes I see people ask a question and get an answer, but the answer doesn’t quite work. But instead of trying to understand the answer in order to see why it doesn’t work and develop a better solution, they just play stupid. Here’s an example. The names have been changed but the story’s the same.

How do I get a handle to a bright pink elephant? We have a dialog box that talks about elephants, and we’d like to put some information about the bright pink ones on it.

An answer came back rather quickly.

Use GetElephantHandle(EPHNT_BRIGHTPINK).

Some time later, the customer came back with a follow-up question.

I can’t get it to work. I get a compiler error:

error C2065: 'EPHNT_BRIGHTPINK' : undeclared identifier

Am I missing a header file?

(So much for people knowing what to do when they get this error message.)

Don’t be helpless. Your head isn’t just for looks. At least pretend to try to understand what you’re doing. In this case, the function is GetElephantHandle, and you’re having trouble because the EPHNT_BRIGHTPINK value we want isn’t defined. Why not check out the values that are defined?

#define EPHNT_DUMBO         0
#define EPHNT_BABAR         1
#define EPHNT_WHITE         2
#define EPHNT_BRIGHT_PINK   3

Wow, I bet the person who wrote EPHNT_BRIGHTPINK really meant EPHNT_BRIGHT_PINK.

Armed with this new skill, perhaps you can solve this person’s problem:

Somebody recommended that I add the DS_SHELLEXT style to my property sheet dialog template to fix a sizing problem, but when I try that, I get an error that tells me that DS_SHELLEXT is not defined. Is there a file I have to include?

Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.