-
CView : creation
I use two class in a none doc\view application. The first one is derive from CMDIChildWnd and the second one is derive from CView. I Create the CMDIChildWnd this way :
HTML Code:
pFrame->CreateNewChild( RUNTIME_CLASS(WndGridChild), IDR_INTERFTYPE, m_hMDIMenu, m_hMDIAccel);
The CView derived class is create this way :
Code:
BOOL WndGridChild::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
if (m_GridView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
return CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
BOOL WndGridChild::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
pContext->m_pNewViewClass = RUNTIME_CLASS(CGridView);
m_GridView = (CGridView*)CreateView(pContext);
if(NULL == m_GridView)
{
return FALSE;
}
return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
When I create this window I don't why it call 2 times all functions for View creation ( OnInitialUpdate, PreCreateWindow, Constructor etc ).
Evedently I would like it call it one time.
Thank you
-
Re: CView : creation
This is because you create two views.
Do this:
Code:
BOOL WndGridChild::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
pContext->m_pNewViewClass = RUNTIME_CLASS(CGridView);
m_GridView = (CGridView*)CreateView(pContext); //Cretes view
if(NULL == m_GridView)
{
return FALSE;
}
return TRUE;
//return CMDIChildWnd::OnCreateClient(lpcs, pContext); //creates view
}
Or this:
Code:
BOOL WndGridChild::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
pContext->m_pNewViewClass = RUNTIME_CLASS(CGridView);
return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
-
Re: CView : creation
Thank you very much for your reply, it is exactly what I want to know