Link to home
Start Free TrialLog in
Avatar of Mindo
Mindo

asked on

Microsoft TreeView ActiveX control version 6.0

I must write a simple demo which demonstrates the use of this control. I couldn't find any documentation in MSDN.

The following would be enough:

Add 5 items (strings) to the TreeView ActiveX control.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of fstab
fstab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fstab
fstab

I forgot to add that please substitute your own variables in places where you find undefined variables - in other words, I've pasted some code from one of my own apps so you might find some of them ..
Avatar of Mindo

ASKER

My tree control doesn't have a GetTreeCtrl() method. This is what my compiler says.

So the following code doesn't work for me:

m_tree.GetTreeCtrl();

// m_tree is an instance of CTreeView

I'm using the Microsoft TreeView ActiveX control version 6.0. It's not an MFC CTreeView class. Although i think it's made using this class.

Can you help me?
OK .. here's what you probably have - you must be having a Treeview control on your dialog. If yes, please do the following :

Open Classwizard in your project, switch the tab to Member variables. Click on the Treeview control ID, and add a variable m_Tree.

Also remove all references to GetTreeCtrl in the code which I gave you and recompile.

If you're trying to create a TreeView control on the "fly" in code, I'd advise you to go with my approach - which is add a TreeView control to your dialog box using the Dialog editor in Visual Studio.

Let me know what happens ..
fstab.
Avatar of Mindo

ASKER

I've added a member variable for my dialog already. In y previous comment i've pasted the following:

m_tree.GetTreeCtrl();

the m_tree is my member variable of the TreeView ActiveX control.

And it says there's no such method :-(
Please remove this method of m_Tree which you're trying to call .. it is not required.
Avatar of Mindo

ASKER

Hmm,

What do you mean by saying to remove the method i'm trying to call?

I need this method to add items to the TreeView. How to add the items? To get the tree by GetCtrlTree() and add items to it. Is there any other way?

But as i told you before this method doesn't work for me.

I meant to say that you don't need the GetTreeCtrl method to get a reference to the Tree control, since you've already added it as a variable from Classwizard.

Please see the code which I've pasted in my proposed answer, leaving out the line where it calls GetTreeCtrl.

Instead of using pTree in my code use m_Tree.

GetTreeCtrl, FYI is only to be used from a CTreeView object inorder to get a reference to the underlying Tree control.

Hope that makes things clear - if not, please show me your code and we'll take it from there.
I meant to say that you don't need the GetTreeCtrl method to get a reference to the Tree control, since you've already added it as a variable from Classwizard.

Please see the code which I've pasted in my proposed answer, leaving out the line where it calls GetTreeCtrl.

Instead of using pTree in my code use m_Tree.

GetTreeCtrl, FYI is only to be used from a CTreeView object inorder to get a reference to the underlying Tree control.

Hope that makes things clear - if not, please show me your code and we'll take it from there.