How does one compile the resources used by an MFC exe or MFC DLL so that they are in a DLL? Then how do you load those resources into the exe or DLL?
Thanks
Jim Bassett
Printable View
How does one compile the resources used by an MFC exe or MFC DLL so that they are in a DLL? Then how do you load those resources into the exe or DLL?
Thanks
Jim Bassett
The online MSDN help contains an article called "Create a Resource-Only DLL".
Just add the resources to the project which is the DLL and then compile the DLL as normal.
Every time you want to load a resource, do the following:
// save current resource handle
HINSTANCE hInstance = AfxGetResourceHandle();
// set resource handle to ourselves (the DLL)
AfxSetResourceHandle(theApp.m_hInstance);
// then display a dialog or...
int rv = dlg->DoModal();
// ...load an image list, or whatever
CImageList ilMyImageList.Create(IDB_IMAGE_LIST_ID, 16, 0, RGB(192, 192, 192));
// finally, reset resource handle to what it was before
AfxSetResourceHandle(hInstance);
theApp is defined by the Wizard for you and looks something like below:
/////////////////////////////////////////////////////////////////////////////
// The one and only CDLLApp object
CDLLApp theApp;