Hi there,

I have a VC application that I want to implement a switch for which will
change the name of the application, as well as several other resource items.

I implemented a pre-compile check within the .rc file for the version
information, but VC removes my check and replaces it for the section that
evaluated to true, for example...

#define APP2

#ifdef APP2
//version info block here for app 2
//the entire block gets replaced by the code within this section.
#else
//version info block here for app 1
#endif

So my question is, how do I specify to use a different set of resources
for a specific compile switch?

Many thanks in advance.

Nick.

Re: Build Switching by NickP

NickP
Thu May 24 05:05:35 CDT 2007

HI again,

I am attempting to achieve this by including multiple resources in my
application, so far I have...

mainresource.rc
resourceset1.rc
resourceset2.rc

both resource sets are included in mainresource.rc. mainresource.rc does
not include any resources itself.

resourceset1.rc uses resource.h, and resourceset2.rc uses resource1.h. So
they both have their own resource header.

My current problem is that mainresource.rc includes resource.h at the very
top, regardless of the precompile switch, also both rc files are included as
text includes below.

Any ideas on where I go from here?

Nick.

"NickP" <a@a.com> wrote in message
news:u$0Qo3dnHHA.668@TK2MSFTNGP05.phx.gbl...
> Hi there,
>
> I have a VC application that I want to implement a switch for which
> will change the name of the application, as well as several other resource
> items.
>
> I implemented a pre-compile check within the .rc file for the version
> information, but VC removes my check and replaces it for the section that
> evaluated to true, for example...
>
> #define APP2
>
> #ifdef APP2
> //version info block here for app 2
> //the entire block gets replaced by the code within this section.
> #else
> //version info block here for app 1
> #endif
>
> So my question is, how do I specify to use a different set of resources
> for a specific compile switch?
>
> Many thanks in advance.
>
> Nick.
>



Re: Build Switching by David

David
Thu May 24 07:24:04 CDT 2007

NickP wrote:
> Hi there,
>
> I have a VC application that I want to implement a switch for which will
> change the name of the application, as well as several other resource items.
>
> I implemented a pre-compile check within the .rc file for the version
> information, but VC removes my check and replaces it for the section that
> evaluated to true, for example...
>
> #define APP2
>
> #ifdef APP2
> //version info block here for app 2
> //the entire block gets replaced by the code within this section.
> #else
> //version info block here for app 1
> #endif
>
> So my question is, how do I specify to use a different set of resources
> for a specific compile switch?

Nick:

Put conditional items in the .rc2 file.

--
David Wilkinson
Visual C++ MVP

Re: Build Switching by NickP

NickP
Thu May 24 06:23:31 CDT 2007

I have extended my header files so I now have 3

resource.h decides which resource header to use by checking the precompile
constant.

This seems to work fine, but my issue remaining seems to be in my
mainresource.rc, it includes both resources as TEXTINCLUDE blocks, so I am
getting a CVT1100 duplicate resource error.

Confusing to say the least.

Nick.

"NickP" <a@a.com> wrote in message
news:OiveUsenHHA.668@TK2MSFTNGP05.phx.gbl...
> HI again,
>
> I am attempting to achieve this by including multiple resources in my
> application, so far I have...
>
> mainresource.rc
> resourceset1.rc
> resourceset2.rc
>
> both resource sets are included in mainresource.rc. mainresource.rc does
> not include any resources itself.
>
> resourceset1.rc uses resource.h, and resourceset2.rc uses resource1.h. So
> they both have their own resource header.
>
> My current problem is that mainresource.rc includes resource.h at the very
> top, regardless of the precompile switch, also both rc files are included
> as text includes below.
>
> Any ideas on where I go from here?
>
> Nick.
>
> "NickP" <a@a.com> wrote in message
> news:u$0Qo3dnHHA.668@TK2MSFTNGP05.phx.gbl...
>> Hi there,
>>
>> I have a VC application that I want to implement a switch for which
>> will change the name of the application, as well as several other
>> resource items.
>>
>> I implemented a pre-compile check within the .rc file for the version
>> information, but VC removes my check and replaces it for the section that
>> evaluated to true, for example...
>>
>> #define APP2
>>
>> #ifdef APP2
>> //version info block here for app 2
>> //the entire block gets replaced by the code within this section.
>> #else
>> //version info block here for app 1
>> #endif
>>
>> So my question is, how do I specify to use a different set of
>> resources for a specific compile switch?
>>
>> Many thanks in advance.
>>
>> Nick.
>>
>
>



Re: Build Switching by NickP

NickP
Thu May 24 07:22:18 CDT 2007

Hi David,

> Put conditional items in the .rc2 file.

Sorry, I am not quite sure what you mean?

I want to use exactly the same resource ID's just some of them will have
different values for each build.

I don't seem to be able to put any precompile checks that actually get
noticed in the rc file so far, or am I doing something wrong?

Nick.



Re: Build Switching by NickP

NickP
Thu May 24 09:39:01 CDT 2007

Hurrah! After some confusion I now have it working!

So I have decided to have 1 resource.h file and 3 rc files.

In the resource.h file I have the following defined

#define BUILD2

I copied the main resource file to 2 resource files, exactly the same
contents, build1.rc and build2.rc. My main rc file contains no resources,
the following TEXTINCLUDE block,

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""atlres.h\0"
END

3 TEXTINCLUDE
BEGIN
"#include ""build1.rc""\0"
"#include ""build2.rc""\r\n"
END

and a small block at the bottom...

#ifndef APSTUDIO_INVOKED

#ifdef BUILD2
#include "build2.rc"
#else
#include "build1.rc"
#endif

#endif

If I defined BUILD2 within the project properties dialog it was not
detected.

Anyway this works great and I can now specify different resources for each
build using the same ID's. Which is great stuff!

Nick.

"NickP" <a@a.com> wrote in message
news:u$0Qo3dnHHA.668@TK2MSFTNGP05.phx.gbl...
> Hi there,
>
> I have a VC application that I want to implement a switch for which
> will change the name of the application, as well as several other resource
> items.
>
> I implemented a pre-compile check within the .rc file for the version
> information, but VC removes my check and replaces it for the section that
> evaluated to true, for example...
>
> #define APP2
>
> #ifdef APP2
> //version info block here for app 2
> //the entire block gets replaced by the code within this section.
> #else
> //version info block here for app 1
> #endif
>
> So my question is, how do I specify to use a different set of resources
> for a specific compile switch?
>
> Many thanks in advance.
>
> Nick.
>



Re: Build Switching by David

David
Thu May 24 09:51:33 CDT 2007

"NickP" <a@a.com> wrote in news:u$0Qo3dnHHA.668@TK2MSFTNGP05.phx.gbl:

> Hi there,
>
> I have a VC application that I want to implement a switch for
> which will
> change the name of the application, as well as several other resource
> items.
>
> I implemented a pre-compile check within the .rc file for the
> version
> information, but VC removes my check and replaces it for the section
> that evaluated to true, for example...
>
> #define APP2
>
> #ifdef APP2
> //version info block here for app 2
> //the entire block gets replaced by the code within this section.
> #else
> //version info block here for app 1
> #endif
>
> So my question is, how do I specify to use a different set of
> resources
> for a specific compile switch?
>
> Many thanks in advance.
>
> Nick.
>
>

In the resource view, r-click on the resource and select 'Insert Copy'.
Part of that dialog has a section for entering a conditional - that's
where you put the 'APP2'. On quick inspection, it appears you can do this
on all resources except the stringtable.

Now, you have only one RC, and you can easily use VS to edit all the
resources. (If you conditionally include RC files as you were thinking,
you will have a problem trying to edit the contained resources)

Dave Connet