Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Multiple icons in a single resource file

Posted on 2011-03-14
7
626 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

840 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