The crucial point is that when using DECLARE_SERIAL and IMPLEMENT_SERIAL CRuntimeClass member CRuntimeClass added to your class containing the name in the m_lpszClassName field. This CRuntimeClass object CRuntimeClass also added to the list supported by the framework, which runs when classes are dynamically created. You must ensure that the CRuntimeClass object contains the old name of your class in m_lpszClassName .
You have two options:
Overriding the construction of a CRuntimeClass object
To do this, you will need to make your own versions of DECLARE_DYMAMIC , DECLARE_DYNCREATE , DECLARE_SERIAL , IMPLEMENT_DYMAMIC , IMPLEMENT_DYNCREATE and IMPLEMENT_SERIAL . You can simply copy and rename existing implementations. In your version of IMPLEMENT_DYNAMIC you need to change the code that CRuntimeClass creates CRuntimeClass that it is initialized with the old class name.
Changing the name of the class stored in the m_lpszClassName field after creating the CRuntimeClass object
Since CRuntimeClass is created by a static initializer, I donβt think you can do this from your class. I think the best place for this is in your InitInstance application. Add the static char* variable to the application class containing the old class name. Then in InitInstance set the m_lpszClassName field to your CRuntimeClass .
- The first method has the advantage of saving changes to the class on its own.
- The second makes the application aware of the class in such a way that it possibly should not be.
In any case, the first thing to do is fully familiarize yourself with how dynamic creation and serialization work.
Martin broadhurst
source share