Click to See Complete Forum and Search --> : trees trees help me im goin nutz!
yosh scout
June 9th, 1999, 02:28 AM
ok now dont laugh because i am new to this ive tried all kinds of stuff to make a tree and im goin nutz! right now im tryin somethin crazy.
CTreeCtrl::InsertItem(TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, "Root", 0,
1, NULL, NULL, NULL,
TVI_ROOT, TVI_FIRST);
ive got a dialog box with a tree in the editor im tryin to edit it. now try to find a spot in a dialog prog this would fit and this is bad code but its what im tryin oh and it isnt derived i just want to dispal the root but every book says somethin different and they all dont work plez help me im goin nutz!
Jason Teagle
June 9th, 1999, 04:03 AM
Here is how to insert some text, include the image, and change the state of the item from plain text to bold. You MUST have created a CImageList and set it into the tree control with SetImageList() before using this:
---// Add the root item, with its own icon (params: text for label, HTREEITEM
// (= branch) to add to).
hRoot = pTree->InsertItem("C:\\", TVI_ROOT);
// Set the image to be used for this branch (params: branch, index into image
// list (image strip) for basic image, same again for selected image (I use the
// same) ). IMAGE_ROOT is my own definition, and is an index into the parts of
// the bitmap used for the image list.
pTree->SetItemImage(hRoot, IMAGE_ROOT, IMAGE_ROOT);
// Make the root bold letters (params: branch, combination of state bits, mask
// specifying which bits in the combination value are valid (therefore, usually
// both the same value to set just one state at a time) ).
pTree->SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD);
---
You will get more info in the demo project I sent you...
bala.j
May 16th, 2001, 01:36 PM
Hi,
But how will i change the bold state to the normal state after selecting someother item on the tree. Kindly let me know.
Thanks,
Bala.
Jason Teagle
May 16th, 2001, 01:43 PM
I believe this will do what you want:
pTree->SetItemState(hItem, 0, TVIS_BOLD);
In other words, we are saying that only the bold state is to be changed, and we specify 0 (i.e., NOT bold) as the new state.
bala.j
May 16th, 2001, 01:55 PM
Thank you very much.. it works fine now..
bala.j
May 16th, 2001, 02:21 PM
Hi Jason,
Can you also let me know, how to get the focus rectangle on the tree when the tree ctrl does not have the foucs.
I had given the TVS_SHOWSELALWAYS
style. But this displays a grey background on the tree item when it does not have the focus.
I wanted to have like the one seen on VC++ tree (Class, Resourc, File View) where we have rectangle around the text. how can we get this.
Thanks,
Bala.
Jason Teagle
May 16th, 2001, 02:43 PM
To go against the system in that manner kind of violates the Windows thing, but if you really want to do it, you're going to have to implement a custom drawn tree and use DrawFocusRect() regardless of whether it has the focus or not. Not recommended.
bala.j
May 16th, 2001, 02:50 PM
If that is not advisable doing, then kindly advice me on this :
How will i change the seleted item's text and background color to user defined colors. Can this be done and if so kinldy let me know.
Thanks,
Bala.
Jason Teagle
May 16th, 2001, 02:55 PM
I'm afraid this would also involve a custom drawn tree. {:v(
bala.j
May 16th, 2001, 03:00 PM
Can you help me, by having this done using a custom draw control, because i have not worked on custom drawn controls. Ur help would be greatly appreciated.
Thx,
Bala.
Jason Teagle
May 16th, 2001, 03:02 PM
I won't make any promises, but by this time tomorrow (as it is late here where I am now) I will try to get an example project to you.
bala.j
May 16th, 2001, 03:06 PM
that will be great Jason..
thx anyhow for spending ur valuable time helping me.
Should i send u a mail for this, if so kinldy send me ur email id.
My id is balasubramaniam.j@mphasis.com.
Thanks,
Bala.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.