SDI切分窗口

1.1VC6.0classview里面使用appwizard添加新类CMyTreeView,继承自CTreeView

 

 

1 void CMyTreeView1::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
2 {
3 CTreeCtrl& m_tree = GetTreeCtrl();//设置树的样式
4 m_tree.ModifyStyle(0,TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES);
5 m_tree.InsertItem(_T("中国"), 0, 1, TVI_ROOT, TVI_LAST);
6 }

以此类推,添加listview formview editview

Maiframe中进行切分,

 1 BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext *pContext)
 2 {
 3 CRect rect;
 4 GetClientRect(&rect);
 5 //切分
 6 if (!m_wndSplitFirst.CreateStatic(this, 1, 2))//静态切分, 一行2列
 7     return FALSE;
 8 //切分1后的第一个视图    if (!m_wndSplitFirst.CreateView(0, 0, RUNTIME_CLASS(CMyTreeView1), CSize(rect.Width()/5, rect.Height()), pContext) )
 9 {
10     m_wndSplitFirst.DestroyWindow();
11     return FALSE;
12 }
13 //第二次切分
14 if(!m_wndSplitSecon.CreateStatic(&m_wndSplitFirst,2,1,WS_CHILD|WS_VISIBLE, _wndSplitFirst.IdFromRowCol(0, 1)))
15 {
16     return FALSE;
17 }
18 if (!m_wndSplitSecon.CreateView(1, 0, RUNTIME_CLASS(CMyListView), CSize(rect.Width()/5*4, rect.Height()/2), pContext) )
19 {
20 m_wndSplitSecon.DestroyWindow();
21 return FALSE;
22 }
23 
  m_wndSplitSecon.SetRowInfo(0, rect.Height()/2, 0);
24 //第三次切分 25 if(!m_wndSplitThird.CreateStatic(&m_wndSplitSecon, 1, 2, WS_CHILD|WS_VISIBLE, m_wndSplitSecon.IdFromRowCol(0, 0))) 26 { 27 return FALSE; 28 } 29 if (!m_wndSplitThird.CreateView(0, 0, RUNTIME_CLASS(CMyFormView), CSize(rect.Width()/5*2, rect.Height()/2), pContext) ) 30 { 31 m_wndSplitSecon.DestroyWindow(); 32 return FALSE; 33 } 34 if (!m_wndSplitThird.CreateView(0, 1, RUNTIME_CLASS(CMyEditView), CSize(rect.Width()/5*2, rect.Height()/2), pContext) ) 35 { 36 m_wndSplitSecon.DestroyWindow(); 37 return FALSE; 38 } 39 40 return TRUE; 41 }

 

posted @ 2013-03-04 10:17  陈朋  阅读(367)  评论(0编辑  收藏  举报