VC单文档分割窗口1


1.用VC创建单文档工程。

2.创建类CMySplitter继承于CSplitterWnd。

3.准备类CYourView和CMyView,继承于类CView。

4.完成CMainFrame类的虚函数OnCreateClient。

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
	// TODO: 在此添加专用代码和/或调用基类
	CRect rc;
	GetWindowRect(&rc);

	if( m_wndSplitter.CreateStatic( this, 1, 2)==NULL )
		return false;
	m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CYourView),
		CSize((rc.right-rc.left)/2, (rc.bottom-rc.top)/2),pContext);
	m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CMyView),
		CSize((rc.right-rc.left)/2, (rc.bottom-rc.top)/2),pContext);
	
	//return CFrameWndEx::OnCreateClient(lpcs, pContext);
	return true;
}

5.运行即可看到效果。

你可能感兴趣的:(窗口分割)