如何单击一个树项并打开一个新视图 [英] How to click in one tree item and open a new view

查看:89
本文介绍了如何单击一个树项并打开一个新视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在使用SDI:我有两个分割窗口:左侧分割器用于TreeView,第二个用于显示与所选树项目相关的视图。

任何帮助如何通过点击一个选定的树状图,左侧分割器中显示一个视图。



我尝试过:



Hello , I'm working with an SDI :I have two splitter windows :the left splitter is for TreeView and the second is to show views related to selected tree item.
Any help how by clicking in one selected treeitem , a view is shown in the left splitter.

What I have tried:

void CConnecterView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	*pResult = 0;
	CIntClientDoc* pDoc = GetDocument();
	//CDocument* pDoc = GetDocument();

	// Get a reference to the tree control
	CTreeCtrl &ctlLeagues = this->GetTreeCtrl();
	// Find out what item is selected in the tree
	HTREEITEM nodSelected = ctlLeagues.GetSelectedItem();
	// Get the string of the selected node
	CString strSelected = ctlLeagues.GetItemText(nodSelected);
	// Just in case the selected node as a parent, get that parent
	HTREEITEM nodParentLeague = ctlLeagues.GetParentItem(nodSelected);
	// Find the string of the parent of the selected node, if it has a parent
	CString strParentLeague = ctlLeagues.GetItemText(nodParentLeague);
	// Now you can react depending on the selected node
	if (strSelected == "Connecter")
	{
		//pDoc->CRightView.OnEnChangeEditUserLogin();
	}

推荐答案

捕获 WM_NOTIFY 消息并检查 TVN_SELCHANGED 。通知消息将包含已选择项目的详细信息。您可以使用它将消息传递给可自行更新的视图。
Capture WM_NOTIFY messages and check for TVN_SELCHANGED. The notification message will contain the details of which item has been selected. You can use that to pass a message to the View which can update itself.


为您提供一个如何管理选择树项的简单示例。
have you a simple example how to manage selecting tree item .


这篇关于如何单击一个树项并打开一个新视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆