current view doesn't receive msg
Hi,
I wrote a SDI application where I switch bewteen views.
The problem is now it seems I don't receive windows message after having
switched from mainview to another view.For instance I cannot enter text
in edit box.
Here is the code used to switch :
LRESULT CMainFrame::OnSwitchView( WPARAM wParam, LPARAM lParam )
{
CViewMgr* pViewMgr = CViewMgr::GetInstance();
CViewMgr::ViewInfo viewInfo = pViewMgr->GetViewInfo( (CViewMgr::ViewID)
wParam );
CRuntimeClass* pNewViewClass = viewInfo.pViewClassName;
CView* pOldActiveView = STATIC_DOWNCAST( CView, GetActiveView() );
// If we're already displaying this kind of view, no need to go further.
if ( pOldActiveView->IsKindOf(pNewViewClass) ) {
return 0L;
}
// Set the child window ID of the active view to AFX_IDW_PANE_FIRST.
// This is necessary so that CFrameWnd::RecalcLayout will allocate
// this "first pane" to that portion of the frame window's client
// area not allocated to control bars. Set the child ID of
// the previously active view to some other ID.
::SetWindowLong( pOldActiveView->m_hWnd, GWL_ID, 0 );
// create the new view
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = GetActiveDocument();
//pCurrentDoc->m_bAutoDelete = FALSE;
CView* pNewView = STATIC_DOWNCAST(CView, CreateView( &context ));
if ( pNewView != NULL ) {
// set the commandBar
CreateCommandBar( viewInfo.nCmdBarId );
// the new view is there, but invisible and not active...
pNewView->ShowWindow( SW_SHOW );
pNewView->OnInitialUpdate();
// redim
SetActiveView( pNewView );
RecalcLayout();
pOldActiveView->DestroyWindow();
}
#ifdef _DEBUG
else {
ASSERT(FALSE); // big problem !!!!
}
#endif
return 0L;
}
Any idea ?