Board index » cppbuilder » A question about TreeView

A question about TreeView


2003-09-13 10:11:27 PM
cppbuilder54
I have a TreeView. Clicking on one of its nodes Modify Parameters) calls
MyForm->ShowModal (Where MyForm if the form where some parameters can be
modified). I did it using OnChange event of the TreeView.
Now the following case:
MyForm was closed and I did not move to another nodes ("Modify
Parameters" node stays highlighted). I want to show MyForm again, click
on this node, and nothing happens. I can understand why - the node is
not changed, and thus no OnChange event. I tried different events but
they did not help. I also tried to use OnMouseDown event +
GetNodeAt(X,Y) instead of OnChange. It works, and all is OK with the
problem above. But if I click mouse somewhare near the node line, i.e.
not on the node itself (it is not highlighted), GetNodeAt(X,Y) returns
address of the node. Therefore, the program behalfs as the user clicked
the node (but the node is not highlighted!) and it seems strange to him.
Can you advise me how to solve this problem?
Thanks in advance
T.
 
 

Re:A question about TreeView

"Tanya" < XXXX@XXXXX.COM >wrote in message
Quote
But if I click mouse somewhare near the node line, i.e.
not on the node itself (it is not highlighted), GetNodeAt(X,Y) returns
address of the node. Therefore, the program behalfs as the user clicked
the node (but the node is not highlighted!) and it seems strange to him.

Can you advise me how to solve this problem?
Have a look at TCustomTreeView::GetHitTestInfoAt(). This function
determines exactly what was clicked. Combine with the
TCustomTreeView::GetNodeAt(), which you're already using. Something like;
TTreeNode* Node = TreeView->GetNodeAt(X, Y);
if(Node) {
THitTests ht = TreeView->GetHitTestInfoAt(X, Y);
if( ht.Contains(htOnItem) ) {
// do stuff
}
}
Ralph
 

Re:A question about TreeView

It works now! Thank you very much!
Tanya
Quote

Have a look at TCustomTreeView::GetHitTestInfoAt(). This function
determines exactly what was clicked. Combine with the
TCustomTreeView::GetNodeAt(), which you're already using. Something like;


TTreeNode* Node = TreeView->GetNodeAt(X, Y);

if(Node) {
THitTests ht = TreeView->GetHitTestInfoAt(X, Y);

if( ht.Contains(htOnItem) ) {

// do stuff

}
}


Ralph


 

{smallsort}