runtime class: from MFC to std C++
 
Hi,
I am trying to port an GUI application from MFC framework to WTL(Windows 
Template Library).
MFC is using dynamic polumorphism while WTL makes use of static 
polymorphism with lots of templated class.
My problem is about the view manager class.
This class is used to associate a view with an ID and to build it when 
required.
This class was mainly composed of a static struct array defined like this
ViewMgr()
ViewMgr::ViewInfo g_ViewInfo[] =
{
    { CViewMgr::MAIN_VIEW,		CViewMgr::CREATE_ONCE,		  IDR_MAINFRAME,	 
RUNTIME_CLASS(CMainView), NULL,0 },
    { CViewMgr::WELCOME_VIEW,	CViewMgr::CREATE_AND_DESTROY, 
IDR_MENU_OKCANCEL,	RUNTIME_CLASS(CWelcomeView), NULL,0 },
...}
First field is an enum to identify the class,
the second specify if the view is persistent or not when switching to 
another view,
the third is the Runtime class and this is this class that I would like 
to port in std c++.
the firth is a pointeur to the base class CView.
When doing this port from MFC there were two differences :
1) I wanted to replace the struct array by a std::map
2) Some views are loaded at runtime(DLL) so I have declared an interface 
called IDLLFormView and defined like this
struct  IDLLFormView
{
    virtual ~IDLLFormView() { }							// we intend on deriving from this,
    virtual HWND 	Initialize(HWND hParentWnd) = 0;	// Use this to 
initialize the object
    virtual void 	Destroy() = 0;						// Use this to destroy the object
    virtual TCHAR* 	Description() = 0;					// What this thing does
    virtual HICON	GetIcon(int nImageListType) = 0;
};
and views emebbded in thoses DLL exports 2 functions :
WTLDLG_API void GetPlugin( IDLLFormView** ppOutput );
WTLDLG_API LPCTSTR GetPluginName();
So now I am trying to write the new View manager and I got this
class CViewMgr : public CSingleton<CViewMgr>
{
public:
    friend class CSingleton<CViewMgr>;
    void		Init();
protected:
    map<LPCTSTR, IDLLFormView*> m_ViewMap;
private:
    // Constructor
    CViewMgr();
    CViewMgr(CViewMgr const&);
    virtual ~CViewMgr(void);
};
I have for now two classes that are inside my applications class 
CModuleSelectionView and CExplorerView
class CModuleSelectionView :public IDLLFormView, 
publicCDialogImpl<CModuleSelectionView>,public 
CWinDataExchange<CModuleSelectionView>
{
....
}
class CExplorerView:public IDLLFormView, 
publicCDialogImpl<CModuleSelectionView>,public 
CWinDataExchange<CModuleSelectionView>
{
....
}
I you are still reading and you understand a bit what I wrote(and it's 
not easy because I am not very clear), here is what I would like to know :
How could I handle views, some known at compile time and some others at 
runtime.
For instance let's take my two views inside my applications 
CExplorerView and CModuleSelectionView
in my ViewMgr init method how can I associate my views with my map ?
How can I construct them, destroy ...
void ViewMgr::Init()
{
    // Init views known at runtime
    m_ViewMap["Explorer"] = (IDLLFormView)&m_ExplorerView //???????????
}