我建立一个SDI的MFC工程,里面的view从CEditView派生,我想把这个界面切分为两部分。
工程建立好后,我添加了两个类分别为CInputView一个为CTextView分别从CFromView和CView派生,我的本意是前面一个作为输入后面一个显示。
然后我在MainFram里面添加一个virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);函数体为
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
} // add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CTextView), CSize(100, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
} // add the second splitter pane - an input view in column 1
if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CInputView), CSize(100, 50), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
} // activate the input view
SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
/******************************************************/
return CFrameWnd::OnCreateClient(lpcs, pContext);
但是就是出不了想要的界面啊?
希望做过类似程序的高手,讲解下切分视图的一般步骤。尽量详细点哦,现在正急着做课程设计啊。
工程建立好后,我添加了两个类分别为CInputView一个为CTextView分别从CFromView和CView派生,我的本意是前面一个作为输入后面一个显示。
然后我在MainFram里面添加一个virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);函数体为
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
} // add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CTextView), CSize(100, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
} // add the second splitter pane - an input view in column 1
if (!m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(CInputView), CSize(100, 50), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
} // activate the input view
SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
/******************************************************/
return CFrameWnd::OnCreateClient(lpcs, pContext);
但是就是出不了想要的界面啊?
希望做过类似程序的高手,讲解下切分视图的一般步骤。尽量详细点哦,现在正急着做课程设计啊。
我建立一个SDI的MFC工程,里面的view从CEditView派生,我想把这个界面切分为两部分。
工程建立好后,我添加了两个类分别为CInputView一个为CTextView分别从CFromView和CView派生你既然想要用那两个类,那你开始的View就不要指定CEditView.直接设成其中的一个。如CInputView.
然后,再分割,给另一个FRAME配上CTextView.
最后这一句注释掉,直接用return TRUE;就可以了
http://www.vckbase.com/document/viewdoc/?id=192 应该可以达到你的效果了!2. 最后一句话一定要注释掉:// return CFrameWnd::OnCreateClient(lpcs, pContext);// 重载基类的
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
BOOL bCreateSpltr = m_wndSplitter.CreateStatic( this, 2, 2);
// COneView and CAnotherView are user-defined views derived from CMDIView
bCreateSpltr |=m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CMyFrontView), CSize(0,0),
pContext);
bCreateSpltr |=m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CMyLeftView), CSize(0,0),
pContext);
bCreateSpltr |=m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CMyTopView), CSize(0,0),
pContext);
bCreateSpltr |=m_wndSplitter.CreateView(1,1,RUNTIME_CLASS(CMyPerSView), CSize(0,0),
pContext); m_bSplitterCreated = bCreateSpltr; if (bCreateSpltr)
// ResetSplitter();
ShwoFullView();
return bCreateSpltr;
// return CFrameWnd::OnCreateClient(lpcs, pContext);
}