Conflicting Resource IDs
-
Hi, I am linking my app with a number of static libraries which contain dialog resources etc. Unfortuntately, some of the resource IDs appear to be conflicting. I could reallocate the resource IDs in the static libs to overcome this but is there a better way? Thanks Tony
-
Hi, I am linking my app with a number of static libraries which contain dialog resources etc. Unfortuntately, some of the resource IDs appear to be conflicting. I could reallocate the resource IDs in the static libs to overcome this but is there a better way? Thanks Tony
The only IDs that must be unique are dialog IDDs, string IDSs, and menu IDs. The IDCs can be reused (between dialogs) and it won't matter. To ensure that the dialog IDDs don't collide, you could switch to string resource names, instead of numeric resource IDs. To do this, simply comment out the IDD define in resource.h, and change the ctor of the dialog to use the string form. Also comment out the enum in the dialog header file. Ideally, the resource.h file should be organized by dialog, so that each IDC is unique; sometimes this can get away from you. You might want to check into the excellent Resource ID Organiser Add-In for Visual C++ 5.0/6.0/.NET[^] as a way of restoring order to resource.h.
Best wishes, Hans
-
The only IDs that must be unique are dialog IDDs, string IDSs, and menu IDs. The IDCs can be reused (between dialogs) and it won't matter. To ensure that the dialog IDDs don't collide, you could switch to string resource names, instead of numeric resource IDs. To do this, simply comment out the IDD define in resource.h, and change the ctor of the dialog to use the string form. Also comment out the enum in the dialog header file. Ideally, the resource.h file should be organized by dialog, so that each IDC is unique; sometimes this can get away from you. You might want to check into the excellent Resource ID Organiser Add-In for Visual C++ 5.0/6.0/.NET[^] as a way of restoring order to resource.h.
Best wishes, Hans
Hi Hans, Thanks for the reply - that's a great idea! Thanks again :thumbsup: :thumbsup: :-D Tony
-
The only IDs that must be unique are dialog IDDs, string IDSs, and menu IDs. The IDCs can be reused (between dialogs) and it won't matter. To ensure that the dialog IDDs don't collide, you could switch to string resource names, instead of numeric resource IDs. To do this, simply comment out the IDD define in resource.h, and change the ctor of the dialog to use the string form. Also comment out the enum in the dialog header file. Ideally, the resource.h file should be organized by dialog, so that each IDC is unique; sometimes this can get away from you. You might want to check into the excellent Resource ID Organiser Add-In for Visual C++ 5.0/6.0/.NET[^] as a way of restoring order to resource.h.
Best wishes, Hans
Hans, Sorry to trouble you again but I have changed the dialogs to use string resources and recompiled both the lib and the application which uses the lib. Everthing compiled OK but the dialog does not appear when DoModal() is called. I have trace through the MFC code for DoModal() and the call to FindResource() returns NULL, even though the resource name is correct. If I compile the library as a DLL then the dialog appears OK. I realise its hard to do things by remote control but do you have any thoughts as to what could be causing this problem, or what I could check? :confused: Thanks Tony
-
Hans, Sorry to trouble you again but I have changed the dialogs to use string resources and recompiled both the lib and the application which uses the lib. Everthing compiled OK but the dialog does not appear when DoModal() is called. I have trace through the MFC code for DoModal() and the call to FindResource() returns NULL, even though the resource name is correct. If I compile the library as a DLL then the dialog appears OK. I realise its hard to do things by remote control but do you have any thoughts as to what could be causing this problem, or what I could check? :confused: Thanks Tony
In your original message you said "I am linking my app with a number of static libraries which contain dialog resources". This is not possible. A static lib cannot have resources. A DLL (really an exe) can contain resources.
Best wishes, Hans