0

When building stock Windows .rc files with Visual Studio, how do you include multiple .rc files in a project where the resource.h files associated with each .rc file may include overlapping ID definitions?

They may also include overlapping defines, for instance if someone stuck with the stock naming conventions IDC_DIALOG1 may appear in both .rc files.

Is there some standard way to deal with this problem?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
rileymat
  • 503
  • 4
  • 13
  • 3
    *resource.h* isn't (implicitly) associated with *.rc* files. That dependency is explicit. Your *.rc* scripts are free to explicitly include any number of *.h* files. – IInspectable Mar 05 '23 at 21:03
  • @IInspectable Yes, but this means renumbering and removing all overlaps anytime you add it to a new project that has not previously used it. They have this feature to use multiple .rc files, but given the global scope of the id's it seems hard to use them. I am curious if there is a standard way to deal with conflicting numbers. – rileymat Mar 05 '23 at 21:05
  • 2
    It's perfectly fine to have have duplicated ID definitions for controls between different dialogs. (i.e. `IDC_BUTTON_1` can appear in different dialogs with the same value). But you can't have redundant dialog IDs. How painful would it be to renumber your dialog ids? – selbie Mar 05 '23 at 21:08
  • That's just repeating selbie's comment: Control ID's don't need to be globally unique. They just have to be locally unique (and not even that is true). What's the specific problem you need to solve? – IInspectable Mar 05 '23 at 21:13
  • Yes, but the dialog names do, as in the example, if you are going to reference them in other code. You get `_APS_NEXT_RESOURCE_VALUE` which gets out of sync when adding a new `.rc` `.h` combo. – rileymat Mar 05 '23 at 21:54
  • Like Java Naming Conventions for packages, add a unique prefix when creating resources. – YangXiaoPo-MSFT Mar 06 '23 at 05:54
  • So this is asking about Visual Studio's resource editor then? In that case it's best to just forget that it ever existed. It hadn't been in a functional state in roughly a decade now. Not having much hope that Microsoft is ever going to change that. – IInspectable Mar 06 '23 at 13:45

0 Answers0