使用CSplitterWnd分割Frame和View

这里讲的是静态分割

1、分割Frame,通过重载 BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 函数实现。

2、分割View,通过在View类的OnCreat()函数中实现

3、通过CFormView生成的View与对话框连接后需要将对话框的Style改成Child

4、分割Frame的时候,需要将原来SDI文档自动生成的View类删除,或者隐藏,否则会看不到分割的视图。如果删除,将App类中pDocTemplate的第四个参数改成NULL。

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
	// TODO: 在此添加专用代码和/或调用基类
	if(!m_wndSplitWnd.CreateStatic(this,1,3))
	{
		MessageBox(L"分割失败");
		return FALSE;
	}
	CRect rc;
	GetClientRect(&rc);
	if(!m_wndSplitWnd.CreateView(0,0,RUNTIME_CLASS(CLeftStatusView),CSize(300,rc.Height()),pContext) ||
		!m_wndSplitWnd.CreateView(0,1,RUNTIME_CLASS(CMiddleLoopArg),CSize(300,rc.Height()),pContext) ||
		!m_wndSplitWnd.CreateView(0,2,RUNTIME_CLASS(CRightDataView),CSize(300,rc.Height()),pContext) )
	{
		this->MessageBox(L"生成分割窗口失败!");
		m_wndSplitWnd.DestroyWindow();
		return FALSE;
	}
//	m_wndSplitWnd.SetColumnInfo(0,200,300);
//	m_wndSplitWnd.SetColumnInfo(1,200,300);
//	m_wndSplitWnd.SetColumnInfo(2,200,300);
//	m_wndSplitWnd.RecalcLayout();
	return CFrameWnd::OnCreateClient(lpcs, pContext);
	//return TRUE;
}


猜你喜欢

转载自blog.csdn.net/jiangzihao2011/article/details/39527591
今日推荐