View previous topic :: View next topic |
Author |
Message |
Lynn
Joined: 27 Aug 2004 Posts: 89
|
Posted: Wed Dec 22, 2004 2:57 pm Post subject: HowTo: TVS_SINGLEEXPAND for TreeView? |
|
|
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 |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Thu Dec 23, 2004 8:52 am Post subject: |
|
|
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 |
|
|
Lynn
Joined: 27 Aug 2004 Posts: 89
|
Posted: Thu Dec 23, 2004 11:55 am Post subject: |
|
|
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 |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Thu Dec 23, 2004 12:38 pm Post subject: |
|
|
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 |
|
|
|