Resource.h File

Hi, I have a dialog based app that has a four page property sheet and a lots of controls on it. I have just copied and pasted a couple of dialog boxes from another app into my dialog based app and now it is crashing. I am fairly certain that my code is right. I did stumble across the resource.h file and I discovered that the values assigned to the resources were no longer unique and some resouces shared the same number. I have looked in MSDN for help and they talk about ranges of value that resourses are allowed to occupy but I did not fully understand what I was reading. Can anyone tell me if resource value have to be unique? If so, then how do I fix them and change them to correct values, and what values that should be? Also, can anyone tell me if the resource files is even related to the problems I am experiencing? Thanks.
rose337Asked:
Who is Participating?
 
mikeblasCommented:
I guess the rules for uniqueness can be explained with one sweeping statement:

Identifiers of any resource type must be unique throughout your resource file for all resources of that type. You can't have a string with the same ID as another string, for example. You can't have a dialog with the same ID as another dialog.

Control IDs are different than resource IDs. The IDs used for controls aren't really resource IDs. They're IDs for the child windows used once the controls are created. You can't use those values in FindResource(), for example.

As such, control IDs aren't influenced by the rule I state above. Control IDs only need to be unique within their containing dialog resource. That is, within the same dialog, no two controls can have the same IDs--even if they're different types of controls. It's perfectly OK to use the same ID for a control that appears in one dialog and for a control that appears in another dialog box.

Controls can also have a special ID of -1. That means they're static--you're not interested in giving the control a specific ID number, and the cotnrol's notifications aren't of interest to you. Very frequently, static text controls have a resource ID of -1. The VC++ resource editor shows IDC_STATIC for these guys.

I think that's a clear answer for you.

..B ekiM
0
 
OlivCommented:
resource ID don't have to be unique as long as they aren't shared :
 I mean that you can have many non unique ID but they have to be fully and
clearly defined in each context.
For example I have in my app 2 functions which automatically extract roi from an image : one with threshold, one with isovalue : don't have made different resources for my dialog boxes, keep interesting resources by a simple copy-paste...
but in your case I think property pages are shared in the property sheet and what's make the difference.

This is question of ID's type too : you can have many non unique ID as you want as they're not same type ID : resource ID, command ID, etc...

hope that helps you
Oliv'
0
 
captainkirkCommented:
Just to expand on Oliv's comments - if you have two dialog resources with the same ID, you have a problem, however, if you have one dialog resource and a string table entry, for example, with the same ID, that's not a problem. Just adjust the conflicting values in the resource.h file. If you have help ID's, you may need to get those into your resource.hm file as well.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.