1、创建SDI程序TestViewSplitter
2、添加CLeftView、CRightView两个CView视图
3、打开CTestViewSplitterView头文件,添加定义
CSplitterWnd m_wndSplitter;
4、添加CTestViewSplitterView的WM_CREATE消息函数,添加如下代码:
if(!m_wndSplitter.CreateStatic(this,1,2))
{
return FALSE;
}
BOOL bRet = m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftView), CSize(200,100), NULL);
if(!bRet)
{
TRACE0("Failed to create left user pan!");
return FALSE;
}
bRet = m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightView), CSize(100, 100), NULL);
if(!bRet)
{
TRACE0("Failed to create right user pan!");
return FALSE;
}
m_wndSplitter.RecalcLayout();
5、添加CTestViewSplitterView的WM_SIZE消息函数,添加如下代码:
CRect rect;
GetClientRect(&rect);
if(m_wndSplitter.GetSafeHwnd() != NULL)
{
m_wndSplitter.MoveWindow(&rect);
}
6、重新编译,执行程序!
本文详细介绍了如何创建SDI程序并整合两个视图CLeftView和CRightView,通过添加视图和消息处理函数实现了左右视图的显示与布局调整。
629

被折叠的 条评论
为什么被折叠?



