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时,希望右边视图链接上已做好的不同的对话框以显示不同的数据控件(静态文本框、文本框、按钮等)。右边如何实现???
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时,希望右边视图链接上已做好的不同的对话框以显示不同的数据控件(静态文本框、文本框、按钮等)。右边如何实现???
相关文章推荐
- 如何实现网页点击左边的导航右边显示对应的页面?
- JavaScript如何把选中d的节点添加到左边或右边
- 如何实现网页鼠标浏览左边的导航右边显示对应的页面
- 商城产品如何应对多个客户不同的需求修改并发布对应客户的文件
- HDOJ 1060 / HDOJ 1061/ HDOJ 1568 总结(如何求大数最左边最右边的数)
- MFC CSplitterWnd 静态分割窗口
- table+iframe+变量url实现左边treeview,右边根据节点选择不同加载不同页面
- table+webusercontrol实现左边treeview,右边根据节点选择不同加载不同页面
- 【问题收集·初级问题】模拟器和真机,分别如何指定数据库路径,模拟器和真机对应的沙盒有何不同…
- vs2005如何把类视图等,从右边移到左边
- Android中如何设置RadioButton在文字的右边,图标在左边
- 在jmeter中如何一套脚本可以对应不同的环境
- CSplitterWnd分割窗口的有关问题
- 如何控制checkbox的选中个数 ,name值不同,
- 杭电5288如何查找一个数字的最左边因子和最右边因子的下标,先处理100以下的数字,100以上的数字则是sqrt(n)
- 关于easyUI Dialog的创建以及Dialog如何获取选中DataGrid中的值
- 如何让精灵在不同的帧率下运动速度不变--Frame Rate Independent Movement
- c#中如何取字符串最左边和最右边的字符??
- 使用iis设置虚拟主机(如何用同一端口ip对应不同web应用)
- AlertDialog.setSingleChoiceItems 单选dialog框在阿拉伯语下图标还是在最右边如何解决