Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Multiple icons in a single resource file

Posted on 2011-03-14
7
Medium Priority
?
632 Views
Last Modified: 2012-05-11
Hi,

I have a Visual Studio 2008 solution that has multiple projects (a few executables and a lib).
I'm bundling all the resources that are used in any of the projects in a single Resource.rc (and a single resource.h) file. I tried to seperate the resources per project but that is a hassle, especially due to the "automatic" numbering of the resources which gives conflicts between the projects.

It all works fine but now i would like to have different icons for the different executables (the program icon that shows on the desktop or in the start menu). Do i still have to make a Resource.rc file per-project just for this icon? Or is there another way?

Kind Regards,
Daniel Dekkers
0
Comment
Question by:DoZo1971
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1000 total points
ID: 35131144
>>Do i still have to make a Resource.rc file per-project just for this icon?

Unfortunately, yes. The default icon for an executable is always the one with the lowest resource ID.
0
 
LVL 7

Assisted Solution

by:JimBeveridge
JimBeveridge earned 1000 total points
ID: 35144174
I have the same problem as you. Our project uses one "Core" rc file that is included by all other resource files, but this arrangement is something of a headache to maintain because I always have to consider the scope of any resource I create.

However, there is another way to do it. If each of your applications is built separately, but they all use a common rc file, then you can use the "Condition" in the resource compiler to determine which icon is included for a particular build. The condition is based on definitions from the command line that are set in Project Properties / Resources / General / Preprocessor defintions. For example, one of our apps includes the Preprocessor definition SERVER. In the resource file, the condition for one of the dialogs is set to SERVER to include that dialog for that app.

This works for all types of resources. To see the Condition field, select any resource and look at the Properties window for that resource.

0
 

Author Comment

by:DoZo1971
ID: 35149214
Hi Jim,

This "condition" method sounds smart. So if i understand correctly i would have to add all the icons for all possible projects with low resource ids (lower than the other (non icon) resources). Say 10, 11, 12, 13, 14,.. and then include/exclude icons (depending on build) so that the right one still has the lowest id and will take the role of program icon. What is the exact syntax of the condition (in the resource) to include or exclude a particular resource?

Kind Regards,
Daniel Dekkers
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Expert Comment

by:JimBeveridge
ID: 35149258
When using Conditions, all of the icons can have the same resource ID, as long as only one of them appears in any given exe or dll.

The Condition is just a preprocessor definition name. In my example, the condition was just SERVER.
0
 

Author Comment

by:DoZo1971
ID: 35149417
Ok ,thanks i'll try it out. First i have to create the core Resource.rc again, i've split it up due to the icon problem, plus, the last time i actually made the core Resoure.rc all dialogs got crippled. So i think i'll do it in steps now, first making exact copies of Resource.rc for the different projects, see if anything goes wrong, before collapsing it to a single core.

By the way... "ResOrg" is a big help to renumber the symbols and identify problems in resource.h files.
http://www.riverblade.co.uk/products/resorg/index.html
0
 
LVL 40

Expert Comment

by:evilrix
ID: 36518478
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question