您的位置:首页 > 其它

mfc 单文档分拆窗口

2013-05-29 20:14 232 查看
在CMainFrame中定义CSplitterWnd类型的成员变量:

class CMainFrame : public CFrameWnd

{    

protected: // 仅从序列化创建

    CMainFrame();

    DECLARE_DYNCREATE(CMainFrame)

// 属性

public:

    CSplitterWnd m_wndSplitter;

    ……

}

       2 .  重载CMainFrame的OnCreateClient函数:

             BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)

             {

                // TODO: 在此添加专用代码和/或调用基类

                CRect rect;

                GetClientRect(&rect);

                m_wndSplitter.CreateStatic(this, 1, 2);

                m_wndSplitter.CreateView(0, 0, pContext->m_pNewViewClass, CSize(1000, 0), pContext);

                m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CNewView), CSize(0, 0), pContext);

                m_wndSplitter.SetActivePane(0, 0);

                return TRUE;

             }

             CNewView是拆分出来的新窗口中的视图类。


MFC单文档 窗口分割(二次分割)  

2009-05-19 09:52:47|  分类: vc开发资料整理|字号 订阅

文件1   

class CMainFrame : public CFrameWnd 添加如下代码

public:

CSplitterWnd m_splMainCols;

CSplitterWnd m_splRightRows;

BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);

cpp文件添加函数

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)

{

if(!m_splMainCols.CreateStatic(this, 1, 3))

{

   return FALSE;

}

if(!m_splMainCols.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 0), pContext))

{

   return FALSE;

}

/*

if(!m_splMainCols.CreateView(0, 1, RUNTIME_CLASS(CLeftView), CSize(500, 0),pContext))

{

   return FALSE;

}

*/

if(!m_splMainCols.CreateView(0, 2, RUNTIME_CLASS(CLeftView), CSize(0, 0),pContext))

{

   return FALSE;

}

if(!m_splRightRows.CreateStatic(&m_splMainCols, 2, 1, WS_CHILD|WS_VISIBLE, m_splMainCols.IdFromRowCol(0,1) ))

{

   return FALSE;

}

if(!m_splRightRows.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(0, 300), pContext))

{

   return FALSE;

}

if(!m_splRightRows.CreateView(1, 0, RUNTIME_CLASS(CLeftView), CSize(0, 0), pContext))

{

   return FALSE;

}

//m_splMainCols.SetRowInfo(0, 350, 0); //重新设置行宽

    //m_splMainCols.RecalcLayout();

//m_splMainCols.SetColumnInfo(2,100,50);

return TRUE;

}

界面预览:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MFC 文档 窗口分割