From: WP on
Hope it's okay if I ask another question, I noticed that my dialog
lacked an IDD-enum. When you create a new dialog project, say, you get
something like the following in the public section of the dialog class
header:
enum { IDD = IDD_ASIMPLETEST_DIALOG };

I noticed I didn't have one in this old project so I added one but it
won't compile because the compiler doesn't see the identifier I'm using,
which is due to the fact that Resource.h isn't included in the dialog
class header file. But the thing is, it isn't included in my test
project either but it compiles there...both header files only got a
#pragma once. Why does it compile in the test project?

- Eric
From: Doug Harrison [MVP] on
On Thu, 05 Jun 2008 22:37:17 +0200, WP <invalid(a)invalid.invalid> wrote:

>Hope it's okay if I ask another question, I noticed that my dialog
>lacked an IDD-enum. When you create a new dialog project, say, you get
>something like the following in the public section of the dialog class
>header:
>enum { IDD = IDD_ASIMPLETEST_DIALOG };
>
>I noticed I didn't have one in this old project so I added one but it
>won't compile because the compiler doesn't see the identifier I'm using,
>which is due to the fact that Resource.h isn't included in the dialog
>class header file. But the thing is, it isn't included in my test
>project either but it compiles there...both header files only got a
>#pragma once. Why does it compile in the test project?

Because the macro has been #defined, probably because resource.h was
#included before you #included the dialog header file.

--
Doug Harrison
Visual C++ MVP
From: WP on
Doug Harrison [MVP] wrote:
> On Thu, 05 Jun 2008 22:37:17 +0200, WP <invalid(a)invalid.invalid> wrote:
>
>> Hope it's okay if I ask another question, I noticed that my dialog
>> lacked an IDD-enum. When you create a new dialog project, say, you get
>> something like the following in the public section of the dialog class
>> header:
>> enum { IDD = IDD_ASIMPLETEST_DIALOG };
>>
>> I noticed I didn't have one in this old project so I added one but it
>> won't compile because the compiler doesn't see the identifier I'm using,
>> which is due to the fact that Resource.h isn't included in the dialog
>> class header file. But the thing is, it isn't included in my test
>> project either but it compiles there...both header files only got a
>> #pragma once. Why does it compile in the test project?
>
> Because the macro has been #defined, probably because resource.h was
> #included before you #included the dialog header file.
>

Oh, yes, once defined, it's available thereafter in all files? The frame
class in the generated project includes resource.h before including the
dialog header, that's why it compiled. I was including mine after. Is
there a rule-of-thumb with regards so resource.h I've missed to follow?

Thanks again for a quick reply, as I recall from last summer, this group
is really great!

- Eric (WP)
From: AliR (VC++ MVP) on
Probably because in your other project the cpp file of the dialog includes
the header of the CWinApp derived class, which in turn includes resource.h

It won't hurt to include resource.h anywhere the compiler is complaining
about something that is defined in it.

AliR.


"WP" <invalid(a)invalid.invalid> wrote in message
news:6ar140F3931maU1(a)mid.individual.net...
> Hope it's okay if I ask another question, I noticed that my dialog lacked
> an IDD-enum. When you create a new dialog project, say, you get
> something like the following in the public section of the dialog class
> header:
> enum { IDD = IDD_ASIMPLETEST_DIALOG };
>
> I noticed I didn't have one in this old project so I added one but it
> won't compile because the compiler doesn't see the identifier I'm using,
> which is due to the fact that Resource.h isn't included in the dialog
> class header file. But the thing is, it isn't included in my test project
> either but it compiles there...both header files only got a #pragma once.
> Why does it compile in the test project?
>
> - Eric


From: Doug Harrison [MVP] on
On Thu, 05 Jun 2008 22:54:25 +0200, WP <invalid(a)invalid.invalid> wrote:

>Oh, yes, once defined, it's available thereafter in all files?

Unless someone #undefs it, yes.

>The frame
>class in the generated project includes resource.h before including the
>dialog header, that's why it compiled. I was including mine after. Is
>there a rule-of-thumb with regards so resource.h I've missed to follow?

You should #include it everywhere it's needed, including inside other
header files. This is a general rule, because header files that don't stand
on their own but require you to #include other header files first are a
pain in the neck to use.

>Thanks again for a quick reply, as I recall from last summer, this group
>is really great!

Glad to help.

--
Doug Harrison
Visual C++ MVP
 | 
Pages: 1
Prev: DoDataExchange woes
Next: MDI FormView project