FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HowTo: TVS_SINGLEEXPAND for TreeView?

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
Lynn



Joined: 27 Aug 2004
Posts: 89

PostPosted: Wed Dec 22, 2004 2:57 pm    Post subject: HowTo: TVS_SINGLEEXPAND for TreeView? Reply with quote

Is there a way to define a TreeView control such that it has the property of TVS_SINGLEEXPAND? I would prefer that only one of the left-most main nodes be open at a time.

Many/most of the other properties of the treeview control have boolean counterparts using wstyle. Is this something that is done by sending a message via the Win32 api after getting a handle? Is there a parent class that can accept a style override?

Also, here are some TVS definitions not in winapi.d. Are these from a later version of the treeview control?

TVS_DISABLEDRAGDROP = 0x0010,
TVS_RTLREADING = 0x0040,
TVS_NOTOOLTIPS = 0x0080,
TVS_SINGLEEXPAND = 0x0400,
TVS_INFOTIP = 0x0800,
TVS_NONEVENHEIGHT = 0x4000,
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Thu Dec 23, 2004 8:52 am    Post subject: Reply with quote

I'll add a property for it in the next version.
You can use something like this for now:
Code:
class MyForm: Form
{
   TreeView treeview;
...
   protected override void onHandleCreated(EventArgs ea)
   {
      SetWindowLongA(treeview.handle, GWL_STYLE, GetWindowLongA(treeview.handle, GWL_STYLE) | 0x0400);
   }
}


I only added stuff to winapi.d that I used. I didn't want to copy and paste everything from the windows headers due to copyright issues.
- Chris
Back to top
View user's profile Send private message
Lynn



Joined: 27 Aug 2004
Posts: 89

PostPosted: Thu Dec 23, 2004 11:55 am    Post subject: Reply with quote

Works fine. Thanks.

It also works fine by calling the SetWindowLongA just after creating the TreeView and after setting the parent to "this". The onHandleCreated override didn't seem to be necessary.

But am I overlooking something that will cause subsequent problems?
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Thu Dec 23, 2004 12:38 pm    Post subject: Reply with quote

Oops, super.onHandleCreated(ea) should be called in the overridden onHandleCreated so that it can finish initializing and fire some events.

Lynn wrote:
Works fine. Thanks.

It also works fine by calling the SetWindowLongA just after creating the TreeView and after setting the parent to "this". The onHandleCreated override didn't seem to be necessary.

But am I overlooking something that will cause subsequent problems?

That works fine. Referencing the handle property causes it, the parent, and other child controls to be immediately created.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group