Solved

Multiple icons in a single resource file

Posted on 2011-03-14
7
618 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 250 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 250 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now