BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Move a treenode

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Steven
Guest





PostPosted: Thu Apr 20, 2006 10:03 pm    Post subject: Move a treenode Reply with quote



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





PostPosted: Thu Apr 20, 2006 11:03 pm    Post subject: Re: Move a treenode Reply with quote



"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





PostPosted: Fri Apr 21, 2006 3:03 am    Post subject: Re: Move a treenode Reply with quote



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





PostPosted: Fri Apr 21, 2006 3:03 am    Post subject: Re: Move a treenode Reply with quote

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





PostPosted: Fri Apr 21, 2006 6:03 am    Post subject: Re: Move a treenode Reply with quote

"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





PostPosted: Fri Apr 21, 2006 1:03 pm    Post subject: Re: Move a treenode Reply with quote

Quote:
Use this instead:

Appreciate it Gambit


Steven
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
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, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.