首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

关于切分View的有关问题

2012-02-02 
关于切分View的问题!我建立一个SDI的MFC工程,里面的view从CEditView派生,我想把这个界面切分为两部分。工程

关于切分View的问题!
我建立一个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);
但是就是出不了想要的界面啊?
希望做过类似程序的高手,讲解下切分视图的一般步骤。尽量详细点哦,现在正急着做课程设计啊。

[解决办法]

我建立一个SDI的MFC工程,里面的view从CEditView派生,我想把这个界面切分为两部分。
工程建立好后,我添加了两个类分别为CInputView一个为CTextView分别从CFromView和CView派生

你既然想要用那两个类,那你开始的View就不要指定CEditView.直接设成其中的一个。如CInputView.
然后,再分割,给另一个FRAME配上CTextView.
[解决办法]
return CFrameWnd::OnCreateClient(lpcs, pContext);
最后这一句注释掉,直接用return TRUE;就可以了
[解决办法]
1. 这里有个例子:
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);
}

热点排行