Click here to Skip to main content
15,894,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing an MFC explorer style application. I am trying to update the tree view which on the left, and is called CTreeView.

In CMyApp I have caught a message in
ON_COMMAND(ID_WORKSPACE_OPEN, &CBWE8App::OnWorkspaceOpen)

CMyApp::OnWorkspaceOpen()
{
...
// code to read workspace file contents
}
I want to be able to read the contents of a file to update the left tree view, so I need to get hold of the left view (CLeftView) from this file so that I can do

CTreeCtrl& Tree = GetTreeCtrl();
//and then aftet some code, I can update the tree-view
HTREEITEM hti1 = Tree.InsertItem(lpszItem1, 0, TVI_LAST);


But I don't know how to get hold of the tree view from CMyApp - please could somebody help!
Posted

1 solution

This might be of interest Creating a Windows Explorer-Style MFC Application[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-Jul-11 13:53pm    
Right place to start, my 5.
--SA
Espen Harlinn 7-Jul-11 14:23pm    
Thank you Sergey!
Jackie Lloyd 8-Jul-11 6:07am    
Thankyou, that is a good start, but I am still confused as to how an explorer application with two views and one doc can displal data from different documents in each view. For example, a list of files is shown in the left view and the contents of one of thefiles in the right view. It seems like two documents are being shown here: one which list all the files, the other has the contents of a file, so isn't this two docs, so not SDI?
Espen Harlinn 8-Jul-11 6:37am    
Exactly what is that you are building? Remember that it's possible to create many different View/Document classes. When you want to display something else just change the View/Document in the right pane - that is: destroy current View/Document and create the correct View/Document based on info from your tree - i.e. type of node.


In most cases MFC makes many things harder, not easier, as it's original purpose was to provide a framework for office style document oriented applications where the effort is focused on rendering a visual representation of the document data using GDI.


Depending on your situation, I would take a long look at WCF, possibly using http://caliburn.codeplex.com/ - not that caliburn is a requirement for MVVM, but it does make some things easier.

As a C++ developer you shouldn't have a problem with c# - unless you are really into templates. Personally I mix and match languages as needs require. When something is easier to express in c++ I use c++ - WCF and XAML does make a lot of things easier. Charles Petzolds' book on WCF, http://charlespetzold.com/wpf/, provides a good, if somewhat dull, introduction to WCF. It's only after you've worked your way through his stuff, that you'll come to appreciate the level of understanding that his approach provides.

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