关于一个拆分窗口后动态加载视图的问题

lpscjn 2006-06-30 11:34:57
如题
谁能给个思路??我先说下我做的,
CCreateContext contextT;
CView* pOldView = (CView*)m_swSplitterWnd.GetActivePane();
contextT.m_pLastView = pOldView;
contextT.m_pCurrentDoc = pOldView->GetDocument();
contextT.m_pNewDocTemplate =contextT.m_pCurrentDoc->GetDocTemplate();

m_swSplitterWnd.DeleteView(0,1);
m_swSplitterWnd.CreateView(0,1,RUNTIME_CLASS(CExamTreeView),CSize(150,200),&contextT);
但是这样以后就不知道怎么弄了,哪位大侠帮帮忙啊?

...全文
191 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
gdsdyl 2006-06-30
  • 打赏
  • 举报
回复
下面贴上我自己程序中的代码,供参考
void CMainFrame::PaneSwitchToForm(int nForm)
{
CRect rect ;

CView* pOldActiveView ;
CView* pNewActiveView ;

pOldActiveView = (CView*)m_Splitter.GetPane(0,0);

switch (nForm)
{
case IDW_VIEW1 :
if ( pOldActiveView->IsKindOf(RUNTIME_CLASS(CView1)))
return; // already active
else
break ;

case IDW_VIEW2 :
if ( pOldActiveView->IsKindOf(RUNTIME_CLASS(CView2)))
return; // already active
else
break ;
}

pOldActiveView->GetWindowRect(&rect) ;
pNewActiveView = (CView*)(m_Splitter.GetDlgItem(nForm)) ;

if (pNewActiveView == NULL)
{
if (nForm == IDW_VIEW1)
pNewActiveView = (CView*)new CView1;
else if (nForm == IDW_VIEW2)
pNewActiveView = (CView*)new CView2;

if ( !pNewActiveView )
return ;

CCreateContext context ;
context.m_pCurrentDoc = pOldActiveView->GetDocument() ;
pNewActiveView->Create(NULL, NULL, 0L, rect,&m_Splitter, nForm, &context) ;

RecalcLayout();

pNewActiveView->OnInitialUpdate() ;
}

SetActiveView(pNewActiveView);

CRuntimeClass* pRC ;
pRC = pOldActiveView->GetRuntimeClass() ;

if ( pRC == RUNTIME_CLASS(CView1) )
pOldActiveView->SetDlgCtrlID(IDW_VIEW1) ;
else if ( pRC == RUNTIME_CLASS(CView2) )
pOldActiveView->SetDlgCtrlID(IDW_VIEW2) ;

pNewActiveView->SetDlgCtrlID(m_Splitter.IdFromRowCol(0, 0));

pNewActiveView->ShowWindow(SW_SHOW);
pNewActiveView->UpdateWindow();
pOldActiveView->ShowWindow(SW_HIDE);

m_Splitter.RecalcLayout();
}
lpscjn 2006-06-30
  • 打赏
  • 举报
回复
嘿嘿,我搞定了,只要在我的代码后边加上RecalcLayout()的调用就可以了:)
CCreateContext contextT;
CView* pOldView = (CView*)m_swSplitterWnd.GetActivePane();
contextT.m_pLastView = pOldView;
contextT.m_pCurrentDoc = pOldView->GetDocument();
contextT.m_pNewDocTemplate =contextT.m_pCurrentDoc->GetDocTemplate();

m_swSplitterWnd.DeleteView(0,1);
m_swSplitterWnd.CreateView(0,1,RUNTIME_CLASS(CExamTreeView),CSize(150,200),&contextT);
m_swSplitterWnd.RecalcLayout();
lpscjn 2006-06-30
  • 打赏
  • 举报
回复
谢了,可是你的VIEW的ID是在哪里设定的啊??

15,976

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧