功能:在当前视中有一个按钮,点击它,此视隐藏
说明:单文档双视图,视图均基于CFormView CMainFrame* pMf=(CMainFrame*)AfxGetMainWnd();
CView* sdi=(CSDIView*)(pMf->m_wndSplitter.GetPane(0,1)); this->ShowWindow(SW_HIDE);
sdi->ShowWindow(SW_SHOW);
GetDocument()->RemoveView(this);
pMf->SetActiveView(sdi);
pMf->RecalcLayout();结果:
当前视没有隐藏(分割条仍存在),单不可用,拖动分割条,显视不正常,有谁能帮帮我吗
说明:单文档双视图,视图均基于CFormView CMainFrame* pMf=(CMainFrame*)AfxGetMainWnd();
CView* sdi=(CSDIView*)(pMf->m_wndSplitter.GetPane(0,1)); this->ShowWindow(SW_HIDE);
sdi->ShowWindow(SW_SHOW);
GetDocument()->RemoveView(this);
pMf->SetActiveView(sdi);
pMf->RecalcLayout();结果:
当前视没有隐藏(分割条仍存在),单不可用,拖动分割条,显视不正常,有谁能帮帮我吗
{
CCreateContext ctx;
ctx.m_pNewViewClass = RUNTIME_CLASS(CMyView);
// GetActiveDocument() call before you destroy m_splitter.
ctx.m_pCurrentDoc = GetActiveDocument();
ASSERT(ctx.m_pCurrentDoc!=NULL);
// m_pSplitter !=NULL when there is a visible splitter.
if (m_pSplitter)
{
// Destroy splitter window.
delete m_pSplitter;
m_pSplitter = NULL;
// Create and initialize CMyView.
SetActiveView((CView*)CreateView(&ctx));
GetActiveView()->OnInitialUpdate();
}
else
{
// Destroy CMyView.
GetActiveView()->DestroyWindow();
// Create new splitter window.
m_pSplitter = new CSplitterWnd;
if (!m_pSplitter->CreateStatic(this, 1, 2))
{
TRACE0("Can't create splitter window.\n");
return;
}
else
{
if ((!m_pSplitter->CreateView(0, 0,
RUNTIME_CLASS(CPane1View),
CSize(350, 0), &ctx))
||(!m_pSplitter->CreateView(0, 1,
RUNTIME_CLASS(CPane2View),
CSize(0, 0), &ctx)))
{
TRACE0("Can't create one of the splitter panes.\n");
return;
}
// Initialize the two panes (each containing a view
// associated with the current document).
((CView*)m_pSplitter->GetPane(0, 0))->OnInitialUpdate();
((CView*)m_pSplitter->GetPane(0, 1))->OnInitialUpdate();
SetActiveView((CView*)m_pSplitter->GetPane(0, 0));
}
}
// Redisplay frame.
RecalcLayout();
}
百度就能搜到。
virtual void DeleteView( int row, int col );
照 他改就可以了。
文档构造函数:m_bAutoDelete =FALSE;
主框架关闭时:
void CMainFrame::OnClose()
{
GetActiveDocument()->m_bAutoDelete = TRUE;
CFrameWnd::OnClose();
} 这种替换实际上是已经删除原来的视图了,还有一种重载CSplitterWnd的方法
http://www.codeproject.com/splitter/st_splitterwnd.asp
你要重新切分才行啊,切分方式不变,你隐藏也无效当前视没有隐藏(分割条仍存在),单不可用,拖动分割条,显视不正常,有谁能帮帮我吗
分割条仍存在,它是由切分方式决定出来的。
CSplitterWnd m_wndSplitter;
如此定义分割条,可以正常显示,也可以隐藏,但复原时出错
CSplitterWnd* m_wndSplitter;
定义为指针时,调试到下面的****语句时产生异常,运行时提示"该内存不能为读",不知何故,
郁闷!!!
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
m_wndSplitter->CreateStatic(this,1,2); //****
m_wndSplitter->CreateView(0,0,RUNTIME_CLASS(CMyView),CSize(300,0),pContext);
m_wndSplitter->CreateView(0,1,RUNTIME_CLASS(CSDI1View),CSize(0,0),pContext);
return TRUE;
//return CFrameWnd::OnCreateClient(lpcs, pContext);
}
还望各位献言献策
CSplitterWnd* m_wndSplitter;你有没有给它new一下?