In order to create new instances of animation objects of type CAnim in the DLL, you need to implement the CAnimDll::CreateInstanceL() pure virtual factory function in the derived class.
Declare your CAnimDll derived class in a header file as follows:
class CExampleAnimDll : public CAnimDll { public: virtual CAnim* CreateInstanceL(TInt aType); };
A convenient way to implement CreateInstanceL() is to switch on the TInt aType argument, with each switch constructing a different CAnim derived animation class identified by an aType enum. For example. if CShapesAnims is one of those classes:
switch(aType) { // cases case EShapesAnims: return new(ELeave) CShapesAnims; ... default: iFunctions -> Panic(); return NULL; // dummy return to prevent compiler error }
It is up to the implementer to decide whether receiving a bad parameter should cause a panic, as here, or a leave. The approach shown is recommended.
The Panic() function is an MAnimGeneralFunctions helper function, to which CAnim provides the iFunctions pointer. These functions are implemented by the Window Server and are available to any CAnim derived class.
The animation class's ConstructL() function is called after CreateInstanceL().