Click to See Complete Forum and Search --> : DLL classes and AFX_MANAGE_STATE( AfxGetStaticModuleState( ))


Jarmo
June 20th, 1999, 07:38 AM
Do I need to use the macro "AFX_MANAGE_STATE( AfxGetStaticModuleState( ))" in every member of an exported class?

Ravi Bhavnani
June 20th, 1999, 11:40 AM
No.

You should use this macro in every C-style function (if any) that your DLL exports. If you're exporting a class, you can simply prefix your class declaration with the declspec() macro - alternatively, you can prefix each public method you want to export with the declspec() macro.

/ravi

anant anavkar
June 20th, 1999, 12:50 PM
I have a DLL which has a C-style fn fnLogData (int nResourceID_OfStringToLog).

If I include the AFX_MANAGE_STATE( AfxGetStaticModuleState( )), then it is not possible to get the string resource from the calling application!

In another case, I try to create a dlg box thru a call to another C-style fn. In this case, however,
If I do NOT include the AFX_MANAGE_STATE( AfxGetStaticModuleState( )), I get an error.
I am still sorting this out.

Jarmo
June 20th, 1999, 01:59 PM
__declspec( dllimport ) and __declspec( dllexport ) are just replacements for the EXPORT/IMPORT tag in the .def file.

While AFX_MANAGE_STATE( AfxGetStaticModuleState( )) changes the INSTANCE from where windows loads all its resources.

So the question still remains unanswered....

// Jarmo

Ravi Bhavnani
June 20th, 1999, 02:33 PM
OK, let's try this again. You must (at least MS says you must) use the macro in every exported C-style function. My point is, you shouldn't use in your exported methods. Use AfxGetInstanceHandle() and AfxGet/SetResourceHandle() to enable your code to load resources from the correct source (your DLL vs. calling app).

Hope this helps.

/ravi