Replacing views in MDI.
Svetlana Guljajeva -- svetlana@assert.ee Friday, November 08, 1996 Environment: VC++ 4.2-flat, Win 95 Hello! I have an MDI application,and in every child frame I want to change views(replace). I got an assertion fault in CDataExcange::PrepareCtrl function: HWND hWndCtrl; m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl); if (hWndCtrl == NULL) { TRACE1(...); ASSERT(FALSE); AfxThrowNotSupportedException(); } m_hWndLastControl = hWndCtrl; This was called from DoDataExchange()<--UpdateData(0)<--OnInitialUpdate() After GetDlgItem my hWndCtrl is NULL.Actually all the member valiables' hWndCtrl are NULL.My question is : why?? here is a function where I change views: BOOL CChildFrame::ReplaceView(CRuntimeClass * pViewClass) { CCreateContext context; CView * pCurrentView; if((pCurrentView = GetActiveView()) == NULL) return FALSE; CDocument * pDoc = pCurrentView->GetDocument(); BOOL bAutoDelete = pDoc->m_bAutoDelete; pDoc->m_bAutoDelete = FALSE; pCurrentView->DestroyWindow(); pDoc->m_bAutoDelete = bAutoDelete; context.m_pNewViewClass = pViewClass; context.m_pCurrentDoc = pDoc; context.m_pNewDocTemplate = NULL; context.m_pLastView = NULL; context.m_pCurrentFrame = this; CView * pNewView = (CView *) pViewClass->CreateObject(); if(pNewView == NULL) { TRACE1("Warning:Dynamic create of view type %Fs failed \n", pViewClass->m_lpszClassName); return FALSE; } if(!pNewView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW,CRect(0,0,0,0),this,AFX_ IDW_PANE_FIRST,&context)) { TRACE0("Warning:failed to create view for frame\n"); return FALSE; } pNewView->SendMessage(WM_INITIALUPDATE,0,0); RecalcLayout(); pNewView->UpdateWindow(); SetActiveView(pNewView); return TRUE; } What else should I call to tie my member variables correctly with their actual controls?? Thanks in advance, Svetlana ----------------------------------------- **svetlana@assert.ee** //**Assert Ltd.**\\ //****Tallinn****\\ //****Estonia****\\
Jim Lawson Williams -- jimlw@mail.ccur.com.au Sunday, November 10, 1996 G'day! At 11:22 AM 08-11-96 +0200, you wrote: >Environment: VC++ 4.2-flat, Win 95 >>BOOL CChildFrame::ReplaceView(CRuntimeClass * pViewClass) >{ > context.m_pNewDocTemplate = NULL; ^^^^ I don't know the answer, but this looks suspicious.... Regards, Jim LW
| Вернуться в корень Архива |