Hi, I was previously using a CSplitterWnd
in a MFC application, using it's CreateView
function. Everything was working fine but now I would like to pass a parameter to the constructor of my views, so I cannot use MFC dynamic object creation (DECLARE_DYNCREATE
and IMPLEMENT_DYNCREATE
) because they require an empty constructor.
After searching a little on the internet I found an exemple that looks like this:
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CMyView), CSize(0,0), pContext);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CMyView), CSize(0,0), pContext);
m_pView0=(CMyView *)m_wndSplitter.GetPane(0,0);
m_pView1=(CMyView *)m_wndSplitter.GetPane(0,1);
This could be a workaround (i.e.: create a new function in CMyView
letting me specify what I want) but this would be ugly and error prone. Anyone know if there is another way I could do this?
Edit: Adding more details after ee's answer:
Your right that the initialize method would work but this force me to remember to call that initialize method, but like you pointed out I will probably not create these views many times so that should be ok. Another thing I would maybe like is to manage the lifetime of the view myself so again this is not possible using CreateView.
Thanks