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
# 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):)
# 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
# 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).
# 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
# 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
# 6 Re: tree view control
thanks puzzolino
the link which u provided were really great
i am able to solve my problem......
vishal
# 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
# 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?
# 9 Re: tree view control
it shows only folder and exe
it shows hidden exe also
# 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;
}
# 11 Re: tree view control
thanks
# 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
# 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;
}
# 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.
# 15 Re: tree view control
thanks to all
particularly masur for the help
vishal
# 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