Click to See Complete Forum and Search --> : Help! CTreeCtrl Assert


Mike Stenzler
October 11th, 1999, 02:32 PM
I have a CTreeView with it's associated CTreeCtrl embedded in a CSplitterWnd. The tree works fine until I select an item and then switch to the CFormView on the right side of the splitter that corresponds to the item I selected. Then when I return to the tree ctrl to delete all items, I get an Assert at the item after the one I selected. When I track down the Assert I can track it thru ::IsWindow(m_hWnd) and ultimately into AFXWIN2.inl - CDocument::GetDocTemplate() returns NULL.

Anyone guess why this is happening?


void T3TraderTV::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{

NM_TREEVIEW* pnmtv = (NM_TREEVIEW*)pNMHDR;
HTREEITEM hItem = pnmtv->itemNew.hItem;

// what type am I?
int nodetype = GetNodeType(hItem);

// do I have any children?
BOOL withchild = GetTreeCtrl().ItemHasChildren(hItem);
if(!withchild)
{
AddChildren(hItem, nodetype);
}

// display the appropriate formview on the right
CMainFrame *pmf = (CMainFrame *)theApp.GetMainWnd();
switch(nodetype)
{
case CLIENT_NODE:
{
pmf->ShowFormView(CLIENT_NODE);
CString id = GetTreeCtrl().GetItemText(hItem);
((clform *)pmf->m_wndSplitter.GetPane(0,1))->OnInitialUpdate(id, this);
pmf->SetActiveView((CView*)pmf->m_wndSplitter.GetPane(0,1));
pmf->ShowControlBar(&(pmf->m_tbar), TRUE, TRUE);
CString wtext(STD_FRAME_TEXT);
wtext += " Client Maintenance";
pmf->SetWindowText(wtext);
break;
}
}
}

void CMainFrame::ShowFormView(int vtype)
{


CRuntimeClass* newclass;
switch(vtype)
{
case CLIENT_NODE:
{
newclass = RUNTIME_CLASS(clform);
break;
}
default:
ASSERT(0);
return;
}

((CWnd *)m_wndSplitter.GetPane(0,1))->DestroyWindow();
CCreateContext context;
context.m_pNewViewClass = newclass;
context.m_pCurrentDoc = GetActiveDocument();
context.m_pCurrentFrame = this;
context.m_pNewDocTemplate = context.m_pCurrentDoc->GetDocTemplate();
context.m_pLastView = (CView*)m_wndSplitter.GetPane(0,0);
if(!m_wndSplitter.CreateView(0, 1, newclass, CSize(0, 0), &context))
{
TRACE0("Failed to create pane 2\n");
return;
}

m_wndSplitter.RecalcLayout();
((CView*)m_wndSplitter.GetPane(0,1))->OnInitialUpdate();
SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
m_wndSplitter.GetPane(0,1)->ShowWindow(SW_SHOW);
m_wndSplitter.SetActivePane(0,1,NULL);


}






TIA,

Mike

Mike Stenzler
Vice President/CIO
RXR Capital Management Inc.