CView中创建CSplitterWnd

来源:互联网 发布:java 编译流程 编辑:程序博客网 时间:2024/06/03 16:18

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、重新编译,执行程序!


0 0
原创粉丝点击