(1)目前情况是:在主框架窗口实现分割视左边为CTreeView,右边为CListView
(已经实现)。
(2)我想实现得是:双击左边视图得节点,促发主框架中自定义函数OnSplitterStaff
删除右边视图(CListView),显示另外一个视图(CDaoRecordView),也就是在主
框架窗口中重新分割视图。
(A)我在CTreeView双击事件中得程序如下:
void CLTreeView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
{
CMainFrame* pWnd=(CMainFrame*)AfxGetApp()->GetMainWnd();
pWnd->OnSplitterStaff();
*pResult = 0;
}
(B)主框架窗口中自定义函数如下:
void CMainFrame::OnSplitterStaff()
{
CRect rc;
GetClientRect(&rc);
CSize paneSizeStaff(7*rc.Width()/10,rc.Height());
CCreateContext Context;
Context.m_pNewViewClass=RUNTIME_CLASS(CEmployeeView);
Context.m_pCurrentDoc=((CRLApp*)AfxGetApp())->m_pDoc;
Context.m_pCurrentFrame=this;
Context.m_pNewDocTemplate=Context.m_pCurrentDoc->GetDocTemplate();
//运行到这出错
Context.m_pLastView=(CLTreeView*)m_wndSplitter.GetPane(0,0);
m_wndSplitter.DeleteView(0,1);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS (CEmployeeView),paneSizeStaff,&Context);
CEmployeeView* eView=(CEmployeeView*)m_wndSplitter.GetPane(0,1);
eView->GetParentFrame()->RecalcLayout();
m_wndSplitter.RecalcLayout();
eView->OnInitialUpdate();
m_wndSplitter.SetActivePane(0,1); }
(3)编译后没有错误,可是运行却出错,设置断点发现是在Context.m_pNewDocTemplate=Context.m_pCurrentDoc->GetDocTemplate();出错。
请问如何解决这个问题。
谢谢!
(已经实现)。
(2)我想实现得是:双击左边视图得节点,促发主框架中自定义函数OnSplitterStaff
删除右边视图(CListView),显示另外一个视图(CDaoRecordView),也就是在主
框架窗口中重新分割视图。
(A)我在CTreeView双击事件中得程序如下:
void CLTreeView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
{
CMainFrame* pWnd=(CMainFrame*)AfxGetApp()->GetMainWnd();
pWnd->OnSplitterStaff();
*pResult = 0;
}
(B)主框架窗口中自定义函数如下:
void CMainFrame::OnSplitterStaff()
{
CRect rc;
GetClientRect(&rc);
CSize paneSizeStaff(7*rc.Width()/10,rc.Height());
CCreateContext Context;
Context.m_pNewViewClass=RUNTIME_CLASS(CEmployeeView);
Context.m_pCurrentDoc=((CRLApp*)AfxGetApp())->m_pDoc;
Context.m_pCurrentFrame=this;
Context.m_pNewDocTemplate=Context.m_pCurrentDoc->GetDocTemplate();
//运行到这出错
Context.m_pLastView=(CLTreeView*)m_wndSplitter.GetPane(0,0);
m_wndSplitter.DeleteView(0,1);
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS (CEmployeeView),paneSizeStaff,&Context);
CEmployeeView* eView=(CEmployeeView*)m_wndSplitter.GetPane(0,1);
eView->GetParentFrame()->RecalcLayout();
m_wndSplitter.RecalcLayout();
eView->OnInitialUpdate();
m_wndSplitter.SetActivePane(0,1); }
(3)编译后没有错误,可是运行却出错,设置断点发现是在Context.m_pNewDocTemplate=Context.m_pCurrentDoc->GetDocTemplate();出错。
请问如何解决这个问题。
谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货