Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an mfc sdi APP.
A load of files are shown in the tree-view on the left. This tree-view is populated from the document, which lists files and folders with their hierarchy.

Now, I want to right-click on a file and select a pop-up menu option to open the file into the right-hand pane. I can do the right-click and pop-up menu bit. However, the document that populates the tree-view is not the same document that opens into the right-hand pane.

I have done this by just passing the path of the file selected from the tree view straight into the CRightHandView class and reading the file and calling SetWindowText. It works but I am not sure I am using MFC framework in the way it is intended. Is there a more correct or elegant way?
Posted
Updated 24-Oct-11 22:55pm
v2
Comments
Chandrasekharan P 25-Oct-11 0:49am    
Can you improve your last part of the query. its confusing us too

It's a while since I used MFC but as I recall the model, you should connect the CView to a CDocument (ClassWizard does it for you). Then when the user requests a file to be opened, the CDocument class should handle it and read it into memory and then call the associated CView class to display the data in whatever way is necessary. This also allows for the document to be updated and then signal any connected views to update their displays. There are probably still some MFC tutorials around with examples of this.
 
Share this answer
 
Comments
Espen Harlinn 25-Oct-11 8:42am    
That's about it, good reply :)
If you are using SDI, by definition there can only be one open document at the time.
Sounds like your design concept is correct. Tree view represents the document, the right side view can be anything - effectively files are opened as necessary, as items get selected in the tree view.
If you need to do some editing in the right view (not sure if you have to), then you will have to use your own customized handlers for these operations as your in-built serialization mechanism will only help with changes in the tree view.
All good I think.
 
Share this answer
 
Comments
Jackie Lloyd 26-Oct-11 6:21am    
Many thanks for the vote of confidence. Sometimes I am not sure if I am using MFC the right way and whether I am heading for problems later!

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