Home > Software engineering >  The depth of the CTreeCtrl controls the currently selected node?
The depth of the CTreeCtrl controls the currently selected node?

Time:09-26

The depth of the CTreeCtrl controls the currently selected node?

CodePudding user response:

 
Void CLeftView: : GetTreePath (const TVITEM * ptvi, char * pbufs)
{
CTreeCtrl& LeftTree=this - & gt; GetTreeCtrl ();

HTREEITEM hParentItem.
TVITEM tvi.
Char tviname [MAX_PATH];
Char treepath [MAX_PATH];
Char drivename [MAX_PATH];
Char TMP [MAX_PATH];
//make a copy of ptvi
Memcpy (& amp; Tvi ptvi, sizeof (TVITEM));
Memset (drivename, 0, sizeof (drivename));
Memset (treepath, 0, sizeof (treepath));
HParentItem=tvi. HItem;//init
While (hParentItem)
{
Tvi. HItem=hParentItem;//initilized!
Tvi. Mask=TVIF_TEXT;
Tvi. PszText=tviname;
Tvi. CchTextMax=MAX_PATH;
Strcpy (tviname, LeftTree GetItemText (tvi. HItem));
If (strlen (treepath)) sprintf (TMP, "% s \ \ % s", tviname, treepath);
The else sprintf (TMP, "% s", tviname);
Strcpy (treepath, TMP);
//get the parent
HParentItem=LeftTree. GetParentItem (tvi. HItem);
}
//AfxMessageBox (treepath);
Strcpy (pbufs treepath);
return;
}

CodePudding user response:

@ schlafenhamster: what do you use this function? Parameter is what mean? Trouble to explain the wow, thank you

CodePudding user response:

From the root node traversal do contrast

CodePudding user response:

For example,
 
Void CLeftView: : OnSelchanged (NMHDR * pNMHDR, LRESULT * pResult)
{
PNMHDR NM_TREEVIEW * pNMTreeView=(NM_TREEVIEW *);
//TODO: Add your the control notification handler code here
CMainFrame * pMain=(CMainFrame *) AfxGetMainWnd ();
//get LeftTree
CTreeCtrl& LeftTree=this - & gt; GetTreeCtrl ();

TVITEM * pNew=NULL;
//
Char tvinamenew [MAX_PATH];
PNew=& amp; (pNMTreeView - & gt; ItemNew);
This - & gt; GetTreePath (pNew tvinamenew);

Char DirName [MAX_PATH];
Char DriveName [MAX_PATH]="";

Strcpy (DirName, tvinamenew);
//
If (stricmp (DirName, "MY COMPUTER")==0)//yes
{
PMain - & gt; ListMyComputer ();
PMain - & gt; ComboMyComputer (" My Computer ");
* pResult=0;
return;
}
If (stricmp (DirName, "Control 802 d")==0)//yes
{
PMain - & gt; List802D ();
PMain - & gt; Combo802D (" Control 802 d ");
* pResult=0;
return;
}
//not "MY COMPUTER" and "CONTROL 802 d
"BOOL MyPC;
MyPC=pMain - & gt; CutDriveName (DirName);
//
If (MyPC)
{//contain "My Computer"
PMain - & gt; ListFiles (DirName, TRUE);
PMain - & gt; ComboMyComputer (DirName);
}
The else
{//contain "Control 802 d
"PMain - & gt; List802Files (DirName, TRUE);
PMain - & gt; Combo802D (DirName);
}

* pResult=0;
}

CodePudding user response:

Has been found that as long as know the treeitem full path
This - & gt; GetTreePath (pNew tvinamenew);
  • Related