Solved

Multiple icons in a single resource file

Posted on 2011-03-14
7
622 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
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…

772 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