| View previous topic :: View next topic |
| Author |
Message |
Steven Guest
|
Posted: Thu Apr 20, 2006 10:03 pm Post subject: Move a treenode |
|
|
How do you move a treenode from one place to another
without dragging the node? For example, move it with
the click of a button.
Thanks! |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Apr 20, 2006 11:03 pm Post subject: Re: Move a treenode |
|
|
"Steven" <stef (AT) bondo (DOT) edu> wrote in message
news:4447fe46 (AT) newsgroups (DOT) borland.com...
| Quote: | How do you move a treenode from one place to
another without dragging the node?
|
Have you looked at the TTreeNode::MoveTo() method yet?
Gambit |
|
| Back to top |
|
 |
Steven Guest
|
Posted: Fri Apr 21, 2006 3:03 am Post subject: Re: Move a treenode |
|
|
| Quote: | Have you looked at the TTreeNode::MoveTo() method yet?
|
Great I got it, what was confusing me was how to get a checked
node, and move that node to the selected node. This code seems
to work while testing.
TreeView1->Items->Item[36]->MoveTo(TreeView1->Selected,
naAddChildFirst);
Thanks. |
|
| Back to top |
|
 |
Steven Guest
|
Posted: Fri Apr 21, 2006 3:03 am Post subject: Re: Move a treenode |
|
|
| Quote: | Have you looked at the TTreeNode::MoveTo() method yet?
|
Seems I may have jumped the gun too quickly. I am adding
checkboxes in my treeview via this code.
#ifndef TVS_CHECKBOXES
#define TVS_CHECKBOXES 0x0100
#endif
DWORD dwStyle = GetWindowLong(TreeView1->Handle, GWL_STYLE);
dwStyle = dwStyle | TVS_CHECKBOXES | TVS_SHOWSELALWAYS;
SetWindowLong(TreeView1->Handle, GWL_STYLE, dwStyle);
I am not getting the concept of getting all the checked nodes and
moving them
to the node that I am selected on.
I am trying to iterate the tree with some simple code.
TTreeNode *Node = TreeView1->Items->GetFirstNode();
while(Node)
{
TreeView1->Items->Item[]->MoveTo(TreeView1->Selected,
naAddChildFirst);
Node = Node->GetNext();
}
Kinda stuck.... |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Apr 21, 2006 6:03 am Post subject: Re: Move a treenode |
|
|
"Steven" <stef (AT) bondo (DOT) edu> wrote in message
news:444840af$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Seems I may have jumped the gun too quickly. I am adding
checkboxes in my treeview via this code.
I am not getting the concept of getting all the checked
nodes and moving them to the node that I am selected on.
|
That is because your code is wrong to begin with. You are not querying the
checked status of each node at all, and you are not looping through the
nodes correctly anyway.
Use this instead:
bool __fastcall NodeIsChecked(TTreeNode *Node)
{
TVITEM tvItem = {0};
tvItem.mask = TVIF_HANDLE | TVIF_STATE;
tvItem.hItem = Node->ItemId;
tvItem.stateMask = TVIS_STATEIMAGEMASK;
TreeView_GetItem(Node->Handle, &tvItem);
return ((tvItem.state >> 12) - 1);
}
{
TTreeNode *Selected = TreeView1->Selected;
if( Selected )
{
TTreeNode *Node = TreeView1->Items->GetFirstNode();
TTreeNode *Next;
while( Node )
{
Next = Node->GetNext();
if( NodeIsChecked(Node) && (Node != Selected) )
Node->MoveTo(Selected, naAddChildFirst);
Node = Next;
}
}
}
Gambit |
|
| Back to top |
|
 |
Steven Guest
|
Posted: Fri Apr 21, 2006 1:03 pm Post subject: Re: Move a treenode |
|
|
Appreciate it Gambit
Steven |
|
| Back to top |
|
 |
|