1

Originally my MFC program had one .rc file that includes resources for two languages. But, now I have two .rc files in two separate resource-only dll projects(in the same solution), and use LoadLibrary() and AfxSetResourceHandle() to select language dynamically(I referenced this article).

It seems working well, but one problem is that I cannot use dialog editor properly for dialogs in resource-only dll projects. It shows dialogs normally but I cannot add event handler by double-clicking a control or by using property menu. Is there any way to connect code and resource files which are in separate projects in the same solution?

EDIT:

I changed the approach slightly. Instead of creating new RC files in separate resource projects, I created them in the main project and excluded them from the build. And I made them to be referenced by separate resource projects.

One important point was that I added #include "resource.h" into Read-only symbol directives of each RC file(You can do this by right-clicking the RC file in Resource View and choosing Resource Includes item). "resource.h" here is the one that is related to the main project's original RC file which has resources for multiple languages. I don't know why I should add it, but it seems necessary for satellite dll to be working well.

One problem remaining is how to maintain that multiple RC files. For adding resources, if I should maintain original RC file and its resource.h file, I might have to add resources first into the original RC file and then copy them into every language specific RC file. Is this right method, or can I go on without the original RC file?

David Johns
  • 1,201
  • 5
  • 15
  • 34

1 Answers1

1

Include the RC file for this resource only DLL into the project too. But exclude it from the build.

If you have two resource files. Use resource file in a different way:

  1. Create a stand alone program with a normal MFC resource file...
  2. Use language tags for all dialog resources internally
  3. Than use this resource in a second project to build the satellite DLL
  4. Set the resource compiler defines so that the resources tagged with the specfic language are not included.
xMRi
  • 14,982
  • 3
  • 26
  • 59
  • If I include the RC file into the project that includes source code, then how can I exclude the RC file from the build? – David Johns May 07 '14 at 12:44
  • Right-click .rc file in solution explorer, under 'general' set 'excluded from build' to 'yes'. – Roel May 07 '14 at 15:33
  • I included the RC file from resource dll project into the project that has source code(maybe just reference not copied) but still I can't add event handler using dialog editor. – David Johns May 08 '14 at 00:08
  • Do you have more than one resource file? Changed my answer. – xMRi May 08 '14 at 05:52