Share
 
 

CAcModuleResourceOverride Class

Use an instance of this class to switch between resource providers. When the object is constructed, a new resource provider will get switched in. Upon destruction, the original resource provider will be restored. The following code provides an example:

void MyFunc ()
{
    CAcModuleResourceOverride myResources;
}

Upon entry to this function the module's resources will be selected. When the function returns, the default resources will be restored. A resource override can be selected in any of the following ways:

  • Use the default constructor (no arguments), or pass NULL (or 0) to the constructor. The DLL's resources will be selected. The default resources will be restored when the CAcModuleResourceOverride destructor is called. The DLL and default resource handles are tracked by the DLL's CAcExtensionModule.
  • Pass a non-NULL handle to the constructor. The resources of the module associated with the given handle will be selected. The default resources will be restored when the CAcModuleResourceOverride destructor is called.

Two macros—AC_DECLARE_EXTENSION_MODULE and AC_IMPLEMENT_EXTENSION_MODULE—help define and implement the classes in your application.

The following code illustrates how to make use of the CAcExtensionModule and CAcModuleResourceOverride classes in an ObjectARX application:

AC_IMPLEMENT_EXTENSION_MODULE(theArxDLL);
HINSTANCE _hdllInstance = NULL;
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);
        hdllInstance = hInstance;
    }
    else if (dwReason == DLL_PROCESS_DETACH)
    {
        theArxDLL.DetachInstance();  
    }
    return 1;   // ok
}

Was this information helpful?