|
-
July 28th, 2004, 05:24 PM
#1
Call AfxSetResourceHandle in DLL without affecting main application's resources
I have an MFC application. It loads a DLL (DLL1). DLL1 in turn loads DLL2. DLL2 is used by DLL1 for resources. The problem is when I load DLL2 in DLL1, and call AfxSetResourceHandle(), this causes the resources in the application itself to be reset aswell.
How can I load resources into a DLL without affecting the resources of the application that loaded it? Both DLLs are MFC Extention DLLs.
-
July 29th, 2004, 04:05 AM
#2
HINSTANCE hOld = AfxGetResourceHandle();
AfxSetResourceHandle(dllInstance);
// get your required resources
AfxSetResourceHandle(hOld);
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
-
July 29th, 2004, 08:46 AM
#3
question
The resource I need to load is a dialog that needs to be loaded up at the time DLL1 is initially loaded. I think what I'm trying to do is not possible; I guess there is one resource handle shared amoung a process (e.g an MFC App and a chain of DLLs all will use the same resource handle ).
If I'm wrong, please correct me.
-
July 29th, 2004, 10:04 AM
#4
A typical MFC extension DLL has this present:
Code:
static AFX_EXTENSION_MODULE MyDLL = { NULL, NULL };
// Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result.
new CDynLinkLibrary(MyDLL);
So you may be able to do it by duplicating this functionality.
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|