我用VC建了一个单文档工程PlaySerOle,在AppWizard的第七步选择视图基类时,我选择的是CRidhEditView,生成的视图类为
CPlaySerOleView,也就是我建立的是一个可以输入和编辑文本并可以包括嵌套OLE对象的工程。
    我想在工程中把视图拆分开,于是我派生了一个树形视图类CLeftTreeView,未添加代码:
                                                  CLeftTreeView#if !defined(AFX_LEFTTREEVIEW_H__57A2928B_28D7_4DC6_BA48_38C61A8D9123__INCLUDED_)
#define AFX_LEFTTREEVIEW_H__57A2928B_28D7_4DC6_BA48_38C61A8D9123__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// LeftTreeView.h : header file
//#include "afxcview.h"/////////////////////////////////////////////////////////////////////////////
// CLeftTreeView viewclass CLeftTreeView : public CTreeView
{
protected:
CLeftTreeView();           // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CLeftTreeView)// Attributes
public:// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLeftTreeView)
protected:
virtual void OnDraw(CDC* pDC);      // overridden to draw this view
//}}AFX_VIRTUAL// Implementation
protected:
virtual ~CLeftTreeView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif // Generated message map functions
protected:
//{{AFX_MSG(CLeftTreeView)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_LEFTTREEVIEW_H__57A2928B_28D7_4DC6_BA48_38C61A8D9123__INCLUDED_)         接着我在类CMainFrame添加了一个用于拆分窗口的保护成员:
               CSplitterWnd m_wndSplitter1;
        然后我重载了函数BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext),用于拆分窗口,代码如下 :BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if(!m_wndSplitter1.CreateStatic(this,1,2,WS_CHILD | WS_VISIBLE ))
        return false; if(!m_wndSplitter1.CreateView(0, 0, RUNTIME_CLASS(CLeftTreeView),CSize(160, 100), pContext))
        {
        m_wndSplitter1.DestroyWindow();
return false;
}        if(!m_wndSplitter1.CreateView(0, 1,RUNTIME_CLASS(CPlaySerOleView),CSize(100, 100), pContext))
{
        m_wndSplitter1.DestroyWindow();
return false;
}
    CRect r;
GetClientRect(&r);
        m_wndSplitter1.SetColumnInfo(0,r.Width()/4,0);
m_wndSplitter1.SetColumnInfo(1,3*r.Width()/4,0);
m_wndSplitter1.RecalcLayout();        return true;
}      我编译了程序,正常,运行程序,出现窗口,客户区右边出现了CPlaySerOleView视图窗口,右边出现了CLeftTreeView视图窗口,
工具栏上的"粘贴"和"打印"按钮为灰色,当我用鼠标点击“编辑”菜单时,程序运行出现了异常,而当我再次运行程序后,我用鼠标点击
右边的CPlaySerOleView视图窗口,工具栏上的"粘贴"和"打印"按钮从灰色变成了实色,即可以使用了.当我再次用鼠标点击“编辑”菜单时,
编辑”菜单可以使用了.但我用鼠标点击左边的CLeftTreeView视图窗口时,工具栏上的"粘贴"和"打印"按钮又变成了灰色,
用鼠标点击“编辑”菜单时,程序运行又出现了异常.我想问的问题是怎样才能使"编辑"菜单在无论选择哪个视图的情况下都能使用,程序都
能正常运行.
    我还想请教的是怎样才能使拆分窗口右上角具有象关闭窗口时右上角使用的叉叉按钮,来关闭视图窗口,如上面的CLeftTreeView
视图.
    谢谢!