您的位置:首页 > 其它

CView中创建CSplitterWnd

2014-11-19 14:13 417 查看
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、重新编译,执行程序!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐