Discussion:
How to ensure the resource ids are unique?
(too old to reply)
Tony Thomas
2004-09-03 08:21:07 UTC
Permalink
Hi friends,

In my MFC project I have imported resources from another appliction,but some
of the ids of the newly added resources confilicts with the existing ids, is
there any way to make unique ids for all resources in the resource.h
file?.should i edit the file manually?
Expecting the answer form the experts programmes of this
form

Tony
Scott McPhillips [MVP]
2004-09-03 12:19:51 UTC
Permalink
Post by Tony Thomas
Hi friends,
In my MFC project I have imported resources from another appliction,but some
of the ids of the newly added resources confilicts with the existing ids, is
there any way to make unique ids for all resources in the resource.h
file?.should i edit the file manually?
Expecting the answer form the experts programmes of this
form
Tony
Yes, you can edit resource.h manually. When you finish renumbering also
edit the "next number to use" items at the bottom of the file. Then do
a "Build All" instead of the usual "Build."
--
Scott McPhillips [VC++ MVP]
Joseph M. Newcomer
2004-09-03 16:01:59 UTC
Permalink
Not easily. This is one of the real defects in how Visual Studio works: it is hard to
import resources.

Now, there is no problem if you have a control 123 in ten different dialogs. Since the
control ID is interpreted relative to its own dialog, it is common to have many instances
of control 123. The control ID does not need to be globally unique.

This fails, however, if you had imported a dialog with radio buttons, and the name of one
of the radio buttons was already defined. The consequence is an out-of-sequence radio
button, and chaos rapidly follows. There can be similar problems any time the sequence
numbers matter, such as arrays of controls.

You always have the option of hand-editing resource.h. I know it is an ugly solution, but
it does work. You will then be prompted to re-load the resources if they were already
loaded, and it is VERY IMPORTANT to do a "Rebuild All" after any hand-edit of resource.h,
because it is not considered in the rebuild dependency analysis.
joe
Post by Tony Thomas
Hi friends,
In my MFC project I have imported resources from another appliction,but some
of the ids of the newly added resources confilicts with the existing ids, is
there any way to make unique ids for all resources in the resource.h
file?.should i edit the file manually?
Expecting the answer form the experts programmes of this
form
Tony
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Tony Thomas
2004-09-04 05:27:54 UTC
Permalink
Thank you for ur valuable advices...
Tony
Post by Joseph M. Newcomer
Not easily. This is one of the real defects in how Visual Studio works: it is hard to
import resources.
Now, there is no problem if you have a control 123 in ten different dialogs. Since the
control ID is interpreted relative to its own dialog, it is common to have many instances
of control 123. The control ID does not need to be globally unique.
This fails, however, if you had imported a dialog with radio buttons, and the name of one
of the radio buttons was already defined. The consequence is an out-of-sequence radio
button, and chaos rapidly follows. There can be similar problems any time the sequence
numbers matter, such as arrays of controls.
You always have the option of hand-editing resource.h. I know it is an ugly solution, but
it does work. You will then be prompted to re-load the resources if they were already
loaded, and it is VERY IMPORTANT to do a "Rebuild All" after any hand-edit of resource.h,
because it is not considered in the rebuild dependency analysis.
joe
On Fri, 3 Sep 2004 13:51:07 +0530, "Tony Thomas"
Post by Tony Thomas
Hi friends,
In my MFC project I have imported resources from another appliction,but some
of the ids of the newly added resources confilicts with the existing ids, is
there any way to make unique ids for all resources in the resource.h
file?.should i edit the file manually?
Expecting the answer form the experts programmes of this
form
Tony
Joseph M. Newcomer [MVP]
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
ckorda
2016-10-23 16:36:10 UTC
Permalink
Free & open-source resource renumbering tool for Visual Studio:
https://sourceforge.net/projects/resrenum/

from the help file:
"ResRenum renumbers resource IDs in Visual Studio C++ projects. It's a console app, and it's intended to be integrated into the IDE as an external tool. It's compatible with any version of Visual Studio from MFC 6.0 onwards. It's been tested in 6.0, VS2008, VS2010, and VS2012.

The resources are sorted in alphabetical order within each resource type. The resource types are sorted in compliance with Windows rules. Unicode is fully supported: the app automatically detects if either input file contains Unicode text and does the right thing."
Loading...