窗口分割

来源:互联网 发布:淘宝卖家后台操作教程 编辑:程序博客网 时间:2024/05/08 22:43

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

文件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;
}

原创粉丝点击