CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 1999
    Posts
    7

    DLL classes and AFX_MANAGE_STATE( AfxGetStaticModuleState( ))

    Do I need to use the macro "AFX_MANAGE_STATE( AfxGetStaticModuleState( ))" in every member of an exported class?


  2. #2
    Join Date
    May 1999
    Location
    Mass, USA.
    Posts
    103

    Re: DLL classes and AFX_MANAGE_STATE( AfxGetStaticModuleState( ))

    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



  3. #3
    Join Date
    Apr 1999
    Posts
    25

    Re: DLL classes and AFX_MANAGE_STATE( AfxGetStaticModuleState( ))

    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.


  4. #4
    Join Date
    Jun 1999
    Posts
    7

    Re: DLL classes and AFX_MANAGE_STATE( AfxGetStaticModuleState( ))

    __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



  5. #5
    Join Date
    May 1999
    Location
    Mass, USA.
    Posts
    103

    Re: DLL classes and AFX_MANAGE_STATE( AfxGetStaticModuleState( ))

    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured