Expand items using code

The place for threads about version 2.x of TimoSoft ExplorerTreeView.
Post Reply
c.haarmeijer
Cadet
Posts: 2
Joined: 26 Dec 2005, 13:47

Expand items using code

Post by c.haarmeijer »

Hi Timo,

I have selected an item that is also deep in the tree. I now want to expand the tree towards the newly selected item. Is there a function that does this ?

Kind regards,

Chris Haarmeijer
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Post by TiKu »

Hi,

the EnsureVisible method should be what you're looking for.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Guest

Post by Guest »

Hi Timu,

It seems that I only have a function EnsureVisible that returns TRUE or FALSE, so a get property, not a set property. What did I do wrong ?

Chris
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Post by TiKu »

The EnsureVisible method ensures that an item is visible, i. e. if it is not visible, it is scrolled into view and parent items are expanded just as necessary. The return value of this method tells you whether any item expansions took place in order to make the item visible.
Isn't that what you want? Maybe I misunderstood your question. If you want to simply set the expansion state of an item, take a look at its ExpansionState property and/or its Collapse and Expand methods.

TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Guest

Post by Guest »

Hi Timo,

The problem is, I thought I could set the visibility using the EnsureVisible method, but I only have a function EnsureVisible that <returns> the visibility status, not one that I can use to <set> the visibility.

Kind regards,

Chris
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Post by TiKu »

Ah, you want to hide items. Well, this is not possible.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Guest

Post by Guest »

:-)

No, no hiding. The thing I want is that when a user selects an item in a different control, I want to jump straight to that item in the treeview. EnsureVisible sounds right, but the problem is this:

inline VARIANT_BOOL ITreeViewItem::EnsureVisible ( ) {
VARIANT_BOOL _result = 0;
HRESULT _hr = raw_EnsureVisible(&_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _result;
}

A piece of code generated by the ocx. As you can see here, I cannot change the property of an item using the ensurevisible function. It is a <get> property, not a <set> property. I do not want to hide an item, but I want to jump straight to it (expands all parents until that item is reached). I can do this in a couple of lines of code, but in the original tree control of Windows, you can use the expand function to do this.

Sorry for the hassle and mixup in what I want to do.

Chris
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Post by TiKu »

So you probably have not understood how EnsureVisible is working. You get the ITreeViewItem interface of the item for which you want to ensure visibility and call EnsureVisible on this item. EnsureVisible wraps the TVM_ENSUREVISIBLE message.
If you can't get it working, you may also use something like this:

Code: Select all

//pseudo code
SendMessage(hWndTvw, TVM_ENSUREVISIBLE, 0, LongToHandle(pTreeViewItem->get_Handle()));
HTH
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Guest

Post by Guest »

Ok, I will use the SendMessage method then. The problem still remains: I cannot invoke the EnsureVisible function. This function only returns a true or false value. This does allow me to set the visibility. For this, I need a EnsureVisible(true/false) function.

Kind regards,

Chris
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Post by TiKu »

What do you want to pass to EnsureVisible? You don't pass any boolean value with TVM_ENSUREVISIBLE either. So what do you want to pass to the EnsureVisible method? :dontknow:
/edit: EnsureVisible is not a property, it is a method.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Guest

Post by Guest »

Argl! I was under the impression that EnsureVisible was a put/get method that acts like a property under COM. Stupid. Thanks!
Post Reply