CSplitterWnd分割Frame,左边是CTreeView,如何右边是对应选中的不同Dialog??

CSplitterWnd在OnCreateClient()函数:

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
 // TODO: Add your specialized code here and/or call the base class
 CRect frmRC;
    GetClientRect(frmRC);

 if(!m_wndSplitter.CreateStatic(this,1,2))
  return FALSE;
 if(!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftView),CSize(200,frmRC.Height()),pContext))
  return FALSE;
 if(!m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CRightView),CSize(frmRC.Width()-200,frmRC.Height()),pContext))
  return FALSE;
      return TRUE;
 
// return CFrameWnd::OnCreateClient(lpcs, pContext);
}

 

上面在Frame中实现视图分割,关键是CLeftView和CRightView。右边CRightView应该如何定义?CView、CFormView、CDialog?

 

CLeftView使用CTreeView实现:

void CLeftView::OnInitialUpdate()
{
 CTreeView::OnInitialUpdate();
 
 ::SetWindowLong(m_hWnd,GWL_STYLE,WS_VISIBLE|WS_TABSTOP
  |WS_CHILD|WS_BORDER|TVS_HASBUTTONS |TVS_LINESATROOT|TVS_HASLINES);
 
 CTreeCtrl* pCtrl = &GetTreeCtrl();
 
 TVINSERTSTRUCT tvInsert;
 tvInsert.hParent = NULL;
 tvInsert.hInsertAfter = NULL;
 tvInsert.item.mask = TVIF_TEXT;
 tvInsert.item.pszText = _T("根节点");
  
 HTREEITEM hChild1 = pCtrl->InsertItem(TVIF_TEXT,
  _T("通信控制机1"), 0, 0, 0, 0, 0, hRoot, NULL);
   
 HTREEITEM hChild2 = pCtrl->InsertItem(_T("通信控制机2"),
  0, 0, hRoot, hChild1);
 
 pCtrl->InsertItem(_T("电台1"), hChild1, TVI_SORT);
 pCtrl->InsertItem(_T("电台2"), hChild1, TVI_SORT);
 pCtrl->InsertItem(_T("电台3"), hChild1, TVI_SORT);
 
 pCtrl->InsertItem(_T("电台3"), hChild2, TVI_SORT);
 pCtrl->InsertItem(_T("电台2"), hChild2, TVI_SORT);
 pCtrl->InsertItem(_T("电台1"), hChild2, TVI_SORT);
 
 pCtrl->Expand(hRoot,TVE_EXPAND);
}

上面实现向树视图插入节点。

void CLeftView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) 函数响应当树节点选中改变时。

当OnSelchanged时,希望右边视图链接上已做好的不同的对话框以显示不同的数据控件(静态文本框、文本框、按钮等)。右边如何实现???

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值