Question

I'm trying to paint VirtualStringTree's cell differently when mouse is over it. How can I detect the coords of hot node? I know there's a HotNode property but it returns only Node that is under mouse cursor. I need to get cell coords (X,Y) of that node.

Was it helpful?

Solution

You can get the coordinates of any node with the GetDisplayRect method. Also, InvalidateNode will tell you the coordinates of the node you just invalidated.

For your purposes, I don't think you need to know the coordinates of any arbitrary node, though. Instead, you need to know, when you're painting the node, whether the node you're painting is the hot one. All the node-specific owner-draw events tell you both the current node and the coordinates, except for OnPaintText, which only tells you the node. There's no need to track the current hot node yourself, though. Just check whether Node = Sender.HotNode to determine what style to use for painting the node and its text.

You might be able to avoid the whole issue, though. The control has a fair amount of hot-node-specific code already, so it might just be a matter of finding what properties to configure instead of having to paint everything yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top