Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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();
	}
Posted
Updated 28-Aug-18 3:28am
v2
Comments
Jochen Arndt 28-Aug-18 7:04am    
What is the problem?
You have access to the right view instance via the document and can call therefore any member functions. With views you can override OnUpdate() and act according to the passed arguments (e.g. passing a pointer to the string in the pHint parameter).

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.
 
Share this answer
 
Comments
[no name] 2-Sep-18 12:41pm    
A 1 is not fair, try to give my small 5 to compensate
Richard MacCutchan 3-Sep-18 6:57am    
Thank you. But one-votes really do not hurt me.
have you a simple example how to manage selecting tree item .
 
Share this answer
 
Comments
Nelek 28-Aug-18 9:58am    
Please use the "Have a question or comment" widget if you want to speak with someone in concrete (as I am doing right now with this message to your non solution #2)

In case you want to answer a comment then use the tiny "reply" widget

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900