?
Solved

How to add list & tree control in splitter window

Posted on 2006-05-07
8
Medium Priority
?
298 Views
Last Modified: 2013-11-20
Hi

Iam doing a project that uses Splitter window.The window is divided into two columns - the left pane and the right pane.Can anyone give me the code that uses a list control in the right view and a tree control in the let view.I have associated the right pane with the CListView in the CreateView function and left pane with CTreeView as follows:

m_splitter.CreateStatic ( this, 1, 2 ) ;
m_splitter.CreateView ( 0, 0, RUNTIME_CLASS (leftview ), CSize ( 128, 0 ), p ) ;
m_splitter.CreateView ( 0, 1, RUNTIME_CLASS (rightview ), CSize ( 0, 0 ), p ) ;

leftview is a class derived from CTreeView and rightview is a class derived from CListView.I have written this in OnCreateClient function.

I would like to know how to actually create a tree control and list control and use them. Where do I write the Create function for creating list control and how will I add columns and items in this control.

Thanks

Jejo

0
Comment
Question by:jejob007
  • 3
  • 3
6 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 16628329
CTreeView in the left side and CListView in the right side - this is exactly what MFC Application Wizard can generate. Create new SDI or MDI application, and select Explorer Style in one of Wizard steps.
0
 

Author Comment

by:jejob007
ID: 16628919
Once I did that too but iam not getting the tree and list control.how do i insert columns...

Jejo
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 150 total points
ID: 16629116
Left view is class derived from CTreeView. CTreeView has function GetTreeCtrl which returnce reference to CTreeCtrl. You can use it to access tree control:

CTreeCtrl& tree = GetTreeCtrl();
tree. ...            // add items

Right view is derived from CListView. You can use GetListCtrl function:

void CRightView::OnInitialUpdate()
{
   CListView::OnInitialUpdate();

   // Gain a reference to the list control itself
   CListCtrl& theCtrl = GetListCtrl();

   theCtrl.InsertColumn(0, _T("Column 1"), LVCFMT_LEFT);
   ...

}
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:jejob007
ID: 16673226
Thanks AlexFM for ur valuable comment.

But unfortunately i cannot get the desired ouput from ur code.when i insert a few columns using the reference, even though the code is compiling without any errors i do not get to see the list control. I think there is some function to show the list control in the right pane. Hope u would be able to help me with this...

Thanks

Jejo
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16673250
Did you set list control to report style?

CListCtrl& theCtrl = GetListCtrl();
theCtrl.ModifyStyle(LVS_TYPEMASK,LVS_REPORT & LVS_TYPEMASK);
0
 

Author Comment

by:jejob007
ID: 16675663
Hey Thanks AlexFM , you are just great. I added the ModifyStyle function and its working cool.

I have one more problem now regarding this , hope u can clarify that too.

Rightnow i add the items in the list control in the OnInitialUpdate function and its working cool. But later on in my project i need to add items when the control is in some other function.For example i have a menu item called insert.Whenevr i click insert i need to add a particular item in the list control.The corresponding member function for insert is in another class called myframe derived from CFrameWnd.I tried to solve the problem by
using a global variable as follows:

            CListCtrl&  tablist;
and wrote the following statment in OnInitialUpdate
            tablist=theCtrl;

Unfortunately i get 2 errors...1)all references must be initialised....2)operator '=' cannot be defined.....  both the errors corresponds to the above two stmts.

Can u tell me how to solve this problem so that i can go forward with my project.

Thanks

Jejo

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Integration Management Part 2
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question