I am working on a MFC project with multiple GUI applications. The objective is to move all the resources from individual projects to a single resource dll.
After some change I have a single resource-only dll project and multiple GUI project. Each GUI project is using the following code to access the resource dll:
BOOL CFooApp::InitInstance()
{
HINSTANCE hRes = NULL;
hRes = LoadLibrary(_T("Resource.dll"));
if(hRes) AfxSetResourceHandle(hRes);
....
So far things work fine except there are two issues:
- The GUI exe files lose there icons in Windows explorer. Although there are some MFC boilerplate code that load the icon from IDR_MAINFRAME, that only affects the icon in the top
of the application window. - The Class Wizard won’t work anymore. For example I can no longer click on a dialog button in the resource view to add a button handler?
How to solve these issues?
Now I am using a simple method that almost solved the problem. I just add the central rc file (e.g. Resource.rc in my above example) to each GUI project. Thus: 1) The ClassWizard can be used. 2) Icon are generated for each GUI. 3) Although the GUI project is referencing to a English version rc file, the GUI exe can still load a Resource.dll in other languages. The only draw back is every GUI now has the same icon, presumably the first icon they found in the rc file.