tree view control

how i can use tree view control in my application???
how to populate this tree with actual data of my computer
vishal
[125 byte] By [VishalNikiSharma] at [2007-11-18 10:00:14]
# 1 Re: tree view control
If you are using MFC (which I think it's your case, since you posted to this forum), follow this link:
Using MFC CTreeCtrl class (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Using_CTreeCtrl.asp)

If you use plain Win32 API:
Win32 API for tree view controls (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/notifications/tvn_selchanging.asp):)
puzzolino at 2007-11-11 2:36:30 >
# 2 Re: tree view control
i like to populate my treeview control same as the explorer...
ie to see the structure as the explorer what i should do.......
vishal
VishalNikiSharma at 2007-11-11 2:37:24 >
# 3 Re: tree view control
There are already out-of-the-box controls available...take a look at the treeview ( http://www.dev-archive.com/treeview/index.shtml) section here at dev-archive ( http://www.dev-archive.com).
Andreas Masur at 2007-11-11 2:38:34 >
# 4 Re: tree view control
thanks but still i am not able to acheive what i want......
suggest me some good tutorial or code which can help me......
vishal
VishalNikiSharma at 2007-11-11 2:39:26 >
# 5 Re: tree view control
Originally posted by VishalNikiSharma
i like to populate my treeview control same as the explorer...
ie to see the structure as the explorer what i should do.......
vishal

From the Treeview section on this site:
http://www.dev-archive.com/treeview/DirTreeCtrl.htm
http://www.dev-archive.com/treeview/DynmDirTree.shtml
puzzolino at 2007-11-11 2:40:36 >
# 6 Re: tree view control
thanks puzzolino
the link which u provided were really great
i am able to solve my problem......
vishal
VishalNikiSharma at 2007-11-11 2:41:34 >
# 7 Re: tree view control
the code which u provide me is not working correctly........
it is not showing all files
i have download the code from here
http://www.dev-archive.com/treeview/DirTreeCtrl.htm
VishalNikiSharma at 2007-11-11 2:42:38 >
# 8 Re: tree view control
Originally posted by VishalNikiSharma
the code which u provide me is not working correctly........
it is not showing all files
i have download the code from here
http://www.dev-archive.com/treeview/DirTreeCtrl.htm
What files are missing? System files? Hidden files? Randomly?
Andreas Masur at 2007-11-11 2:43:39 >
# 9 Re: tree view control
it shows only folder and exe
it shows hidden exe also
VishalNikiSharma at 2007-11-11 2:44:36 >
# 10 Re: tree view control
Originally posted by VishalNikiSharma
it shows only folder and exe
it shows hidden exe also
Did you read the article?

The right way to use this class is to call the method Initialize( ) into OnCreate( ) method of parent window.

Into MatchExtension there will be the code that allows to select what files to show with directories. Here there are some example of MatchExtension method:

To show only directories this is the right MatchExtension method:

bool CMyDirTreeCtrl::MatchExtension(CString file){
return false;
}

instead if you want show only .exe and .gif files...

bool CMyDirTreeCtrl::MatchExtension(CString file){
if (file.Right(4)==CString(".exe")) return true;
if (file.Right(4)==CString(".gif")) return true;
return false;
}

in this last example it shows all files:

bool CMyDirTreeCtrl::MatchExtension(CString file)
{
return true;
}
Andreas Masur at 2007-11-11 2:45:38 >
# 11 Re: tree view control
thanks
VishalNikiSharma at 2007-11-11 2:46:39 >
# 12 Re: tree view control
i am using the code given in the below link
http://www.dev-archive.com/treeview/DirTreeCtrl.htm
i want to know this code populate the tree with all the directories/files in my computer.......
if i want to use this code only to populate with the specific directory,how can i do it........
let say i have to populate only with files in "C:\\VishalNikiSharma\"
then how to do it......
vishal
VishalNikiSharma at 2007-11-11 2:47:42 >
# 13 Re: tree view control
Go to ClassWizard . Select CDirTreeCtrl class .Add handler for TVN_ITEMEXPANDED
Edit function :

void CDirTreeCtrl::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
CString fullpath;
fullpath=GetPathFromHere(fullpath, pNMTreeView ->itemNew.hItem);
//DO something with path , check extension etc
*pResult = 0;
}
theInstaller at 2007-11-11 2:48:41 >
# 14 Re: tree view control
Originally posted by VishalNikiSharma
if i want to use this code only to populate with the specific directory,how can i do it........
let say i have to populate only with files in "C:\\VishalNikiSharma\"
then how to do it......
vishal
I am not sure but...

DirTreeCtrl Exposes also 2 additional methods: SetPath( ) that allows to set the browser to a defined directory and GetPath( ) that return the (full) path of selected item.
Andreas Masur at 2007-11-11 2:49:41 >
# 15 Re: tree view control
thanks to all
particularly masur for the help
vishal
VishalNikiSharma at 2007-11-11 2:50:42 >
# 16 Re: tree view control
NOTE: ALL IN pure WIN32API non mfc
I want to reach such result as http://www.dev-archive.com/treeview/DirTreeCtrl.htm or
www.toya.net.pl/~grupaie2/a.JPG
my job with the msdn help is at www.toya.net.pl/~grupaie2/Tree.rar
I CAN'T FINISH IT MYSELF, only one missing fuction.
Functions as in http://www.dev-archive.com/treeview/DirTreeCtrl.htm
by clicking button smoe text field must be set as the chosen path.
Only catalogues r interestiong me, no files- in chosen path furhter i 'll search some files, but it's now important at this time. Such icons would be great. BUT ALL IN PURE WIN32API HELP
THANKS IN ADVANCE
jacksson at 2007-11-11 2:51:46 >