?
Solved

Microsoft TreeView ActiveX control version 6.0

Posted on 1999-12-06
9
Medium Priority
?
583 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Mindo
  • 6
  • 3
9 Comments
 
LVL 1

Accepted Solution

by:
fstab earned 100 total points
ID: 2259617
Use this code :

TV_INSERTSTRUCT tvinsert;
HTREEITEM *hParents;

CTreeCtrl &pTree = GetTreeCtrl();

tvinsert.hParent = NULL;
tvinsert.hInsertAfter = TVI_LAST;
tvinsert.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
tvinsert.item.hItem = NULL;
tvinsert.item.state = 0;
tvinsert.item.stateMask = 0;
tvinsert.item.cchTextMax = 6;
tvinsert.item.iSelectedImage = 1;
tvinsert.item.cChildren = 0;
tvinsert.item.lParam = 0;

hParents = new HTREEITEM[rootdircount];
char parent[512];
memset(parent,0,512);
tvinsert.item.pszText = "Your text";
hParents[count] = pTree.InsertItem(&tvinsert);

for(int i=0;i<5;i++) {
tvinsert.hParent = h;
lstrcpy(tvinsert.item.pszText, "Child text" );
HTREEITEM newhandle = pTree.InsertItem(&tv);
}
delete hParents;
return TRUE;


Let me know if it works ..
0
 
LVL 1

Expert Comment

by:fstab
ID: 2259625
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 ..
0
 
LVL 2

Author Comment

by:Mindo
ID: 2259683
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?
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
LVL 1

Expert Comment

by:fstab
ID: 2259786
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.
0
 
LVL 2

Author Comment

by:Mindo
ID: 2260042
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 :-(
0
 
LVL 1

Expert Comment

by:fstab
ID: 2262342
Please remove this method of m_Tree which you're trying to call .. it is not required.
0
 
LVL 2

Author Comment

by:Mindo
ID: 2262678
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.

0
 
LVL 1

Expert Comment

by:fstab
ID: 2262698
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.
0
 
LVL 1

Expert Comment

by:fstab
ID: 2262705
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.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
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.
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.

601 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