AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
Hi I have a dll with exported functions, which I protect with
AFX_MANAGE_STATE(AfxGetStaticModuleState())
. Fine. Now, to those functions I send a callback function as a param. This callback function is in the exe. Is there a corresponding way to restore the module state when I get back into the exe, or do I need to roll up my sleves for this one? It's a requirement that the writer of the dll shouldn't be bothered with restoring the state before calling the callbacks, but just setting his own state correctly using theAFX_MANAGE_STATE
macro. tia Niklas -
Hi I have a dll with exported functions, which I protect with
AFX_MANAGE_STATE(AfxGetStaticModuleState())
. Fine. Now, to those functions I send a callback function as a param. This callback function is in the exe. Is there a corresponding way to restore the module state when I get back into the exe, or do I need to roll up my sleves for this one? It's a requirement that the writer of the dll shouldn't be bothered with restoring the state before calling the callbacks, but just setting his own state correctly using theAFX_MANAGE_STATE
macro. tia NiklasDo you really need to do this? Are you accessing resources in the dll and the callback? Mark
-
Do you really need to do this? Are you accessing resources in the dll and the callback? Mark
-
Yes. :( The dlls may supply dialogs, as well as calling one of the callbacks to invoke the exes dialogs (along with other things)
I would think you'd just need AFX_MANAGE_STATE(AfxGetStaticModuleState()) at the top of the callback function. As long as the module handle is set properly so MFC can find and load resources when it needs to. This can also be overriden by loading the resources yourself if you need to. Mark
-
I would think you'd just need AFX_MANAGE_STATE(AfxGetStaticModuleState()) at the top of the callback function. As long as the module handle is set properly so MFC can find and load resources when it needs to. This can also be overriden by loading the resources yourself if you need to. Mark
-
I would think you'd just need AFX_MANAGE_STATE(AfxGetStaticModuleState()) at the top of the callback function. As long as the module handle is set properly so MFC can find and load resources when it needs to. This can also be overriden by loading the resources yourself if you need to. Mark
After some investigation I found that
AFX_MODULE_STATE* pPrevModuleState = AfxSetModuleState(NULL);
on entry, andAfxSetModuleState(pPrevModuleState);
on exit seems to work. This will allow me to load the correct resources and also use AfxGetApp() and its compadres. (though I'm not entirely convinced yet) thanks for your time. Niklas -
After some investigation I found that
AFX_MODULE_STATE* pPrevModuleState = AfxSetModuleState(NULL);
on entry, andAfxSetModuleState(pPrevModuleState);
on exit seems to work. This will allow me to load the correct resources and also use AfxGetApp() and its compadres. (though I'm not entirely convinced yet) thanks for your time. NiklasThat sounds good :) Just in case you haven't seen this: How to properly export functions by using the MFC Shared Library[^] Outlines the few things that can fail if it's not right. Mark