您的位置:首页 > 其它

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

2010-01-03 22:17 567 查看
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时,希望右边视图链接上已做好的不同的对话框以显示不同的数据控件(静态文本框、文本框、按钮等)。右边如何实现???
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐