|
-
November 15th, 2004, 12:01 AM
#1
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
-
November 15th, 2004, 07:56 PM
#2
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);
}
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
November 15th, 2004, 10:16 PM
#3
Re: CView : creation
Thank you very much for your reply, it is exactly what I want to know
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|