CTreeCtrl and CTreeView (Windows Explorer)

I'm using VS 6.0 and MFC and working on creating a FTP client program where my main window has three splitter windows. The first one far to the left uses a TreeView structure and the next two windows over are both ListView structures.  The first splitter window (TreeView) should display only local folders on the C: drive which I have set as the default drive when the program starts up. This same window should allow users to navigate around these folders. The middle splitter window is a ListView will displays the contents (folders and files) of the selected or highlighted folder from the TreeView. The far right splitter window displays the folders and files of the remote FTP site.

My delima is two folds. First how do I implement the TreeView splitter window which allows users to navigate the folders and only folders (no files in this view) to sub folders just like Windows explorer of the C:\ drive. I am populating this TreeView window with some code but it does not work in that it does not show the folders correctly once refreshed.  I have a drop down combo box (not implemented) which allows users to change the selected drive to the other logical available drives on the system.  I have tried writing recursive code for this TreeView window since there are going to be a limited number of recursive calls but my recursive function does not work. I would be happy to paste the preliminary code if it would help. Another words I take the selected node and recurse up the ladder until I reach the top or root node. Once there my function returns and rebuilds the TreeView but only inserting child/parent nodes until we are back to the selected node then at which I want to be able to display all sibling nodes of the one which was selected.

Secondly how do I best inform/call the middle ListView structure once the user selects a folder from the TreeView window ? Can I use custom SendMessage function ? Would this be an elegant method on how to do this ? I had issues compiling when I tried declaring pointers inside the TreeView and ListView pointing to the other class/object.  Hence my reason for suggesting SendMessage function.

I am open to any suggestions and advice. I have also attached my entire project for VS6.0.

Code can be found here
 
http://cid-be6353393c3f8d74.skydrive.live.com/self.aspx/EE/SuperFTPClient-2.zip
 
Then click on the Download link at the top left. 

Open in new window

VicMeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DanRollinsCommented:
As to the second part, the MFC Document/View architecure has a standard way to do this. In your CDocument-derived object, call:
    UpdateAllViews
    http://msdn.microsoft.com/en-us/library/eys41xfw(VS.80).aspx
Call this when the selection changes in the tree view. For instance:
    (in CMyTreeView)
    GetDocument()->UpdateAllViews( this, MYHINT_FOLDER_SEL_CHANGED );
Then your List View will get an OnUpdate call. That's where you will check to see if the document has changed and do anything that makes the view look correct.
In similar projects, I made my "document" an internal representation of the disk hierarchy -- in one case a single CStringArray with one item for every folder, in another case, my "document" was a more complex linked-list structure... but the idea is the same.
0
VicMeAuthor Commented:
Thanks Dan. I got the second part working in my project. Appreciate the reply. Any chance you can take a look at the code posted to find out why the first part does not work ?
0
DanRollinsCommented:
There is some good example code here:
    populating tree control from text file
    http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/Q_21049150.html
Including links to two projects that include "populating the tree from disk" logic:
    http://www.codeproject.com/treectrl/pathpicker.asp
    http://www.codeproject.com/treectrl/filetree.asp

Be aware that if you use a recursive function, it may take a very long time to populate the entire tree.  Hard disks these days are huge.  Even if you only seek the names of folders, it might take several minutes.  Try the DOS command
   TREE C:\
to see what I mean.  Windows needs to do a FindFirst/FindNext sequence.  The first time you run it, it is rather slow.  The second time, the folders are in cache and it's faster.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

eh936Commented:
Thanks again for the advice. I have decided to abandon the recursion for now partly because II have found the following article/code which I am hoping to port over.

http://www.codeguru.com/cpp/controls/treeview/directorybrowsers/article.php/c717

There is a class called CDirTreeCtrl : public CTreeCtrl that this author has created that does all of the populating that I could possible need within the CTreeView. What I need help in now is how do I go about integrating this class along with the class CSortStringArray which the author appears to have linked to the CDirTreeCtrl ?

I have also taken a look at the following article which the author (different) talks about implementing a CTreeView or CListView using a SDI application also.

http://www.codeguru.com/Cpp/W-D/doc_view/controlviews/article.php/c3269

If you can possible step me through all of this because I am confused about on how to integrate this class. There is a method called GetTreeCtrl(); which is part of the frameworks CTreeView do I use this or do I create or declare my own ? Please keep in mind that my application if you see the project attachment uses a 4 way splitter first view is dereived from CTreeView and the next two are CListView and there is a smaller one also which uses the standard View which the project uses when created.

Thanks again
0
eh936Commented:
Guess what Dan ?

I got it working by using both the links you had posted and the one I had above posted. But what really got me frustrated and very unsure of what I was doing was that the handler  ON_NOTIFY_REFLECT(TVN_ITEMEXPANDED, OnItemexpanded) implemented in the CDirTreeCtrl class  was not being called by the framework so my TreeCtrl was not being populated at all except for the root node/drive.

I found the work around by reading the below article at CodeGuru and following the suggestions by Microsoft. I guess I was close but really appreciate the links you gave. I downloaded both of them and followed the code closely.

http://www.codeguru.com/forum/archive/index.php/t-243197.html
http://support.microsoft.com/default.aspx?scid=kb;en-us;148533
0
VicMeAuthor Commented:
Thanks Dan again. Sorry for the wrong user name posting. I forgot that I had two accounts. Cheers
0
DanRollinsCommented:
Excellent!  
I'm glad that your own research was able to focus in th right places.  Thanks for the grade and the points.  If you run into related problems,  be sure to click the "Ask Related Question" (in this thread) so that I will be notified.
-- Dan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.