Share

CAcExtensionModule

Class Hierarchy

CAcExtensionModule

C++

class CAcExtensionModule;

File

AcExtensionModule.h

Description

This class serves two purposes. First, it provides a placeholder for an AFX_EXTENSION_MODULE structure (normally used to initialize or terminate an MFC extension DLL) and secondly it tracks two resource providers for the DLL. The resource providers are the module's resources (normally the DLL itself, but may be set to some other module) and the default resources (normally the host application, actually the provider currently active when AttachInstance() is called). CAcExtensionModule tracks these to simplify switching MFC's resource lookup between the default and the module's. A DLL should create exactly one instance of this class and provide the implementation for it.

Instantiate an extension module once in a single source file in your DLL project. If you want to access the extension module object from other source files in your project then use the declaration macro as well (usually in an include file). For example, an ARX application's main DLL source file might contain:

    AC_IMPLEMENT_EXTENSION_MODULE(myDLL)
    extern "C" int APIENTRY
    DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
    {
        // Remove this if you use lpReserved
        UNREFERENCED_PARAMETER(lpReserved);
        if (dwReason == DLL_PROCESS_ATTACH)
        {
            theArxDLL.AttachInstance(hInstance);
        }
        else if (dwReason == DLL_PROCESS_DETACH)
        {
            theArxDLL.DetachInstance();
        }
        return 1;// ok
    }

To publicize the extension module in this example to other source files add the following to the module's main include file:

AC_DECLARE_EXTENSION_MODULE(myDLL)

Links

CAcExtensionModule Methods

Was this information helpful?