-2

using delphi ex-5

as of now, I can display the popupmenu on right click of a selected node

is it possible to display a icon on a treeview node (right side) on a moveover? When the icon is moused over, display a popupmenu?

thanx

EDIT: Inclusion of two screenshots to better convey my need (Yes, this was taken forom a webpage - it is what I am trying to do)

https://dl.dropboxusercontent.com/u/73677254/Delphi%20Demos/screenshot1.png

https://dl.dropboxusercontent.com/u/73677254/Delphi%20Demos/screenshot2.png

JakeSays
  • 2,048
  • 8
  • 29
  • 43
  • I'm not sure if that's what you're asking, but if you set `HotTrack` to True, you may try to implement something like [`this`](http://pastebin.com/Qum3Yp5n). – TLama Dec 12 '13 at 17:00
  • sorry, i am asking if i move my mouse over a node in a tree, if a icon can appear. If i move mouse over icon, the popup menu appears. Let me redit the post – JakeSays Dec 12 '13 at 17:47
  • That's two unrelated questions. One at a time please. – David Heffernan Dec 12 '13 at 19:42
  • @sholmes And they can also see all the answers and help that I give here. Many of which are to your questions as it happens. – David Heffernan Dec 16 '13 at 15:35
  • @TLama, thanks for the response. Hot track is set to true. Not sure that has anything to do with displaying icons though. It seems to just highlight the node you are on. – JakeSays Dec 16 '13 at 15:42
  • I thought you were going to show that icon if you hover the node. And that's what the hot track is the best, I think. – TLama Dec 16 '13 at 15:43
  • I said please. I asked nicely. We like to see one question at a time. What's the problem? – David Heffernan Dec 16 '13 at 15:51
  • @DavidHeffernan, this is what I was referring to. I rest my case. It is one question (maybe not by YOUR standards) I have edited my question to include screenshots to better convey my needs. Happy Holidays – JakeSays Dec 16 '13 at 16:03

1 Answers1

1

If you want the icon on the left side, you can use the TTreeNode.StateIndex property. But to put an icon on the right side, you have to owner-draw the TTreeView nodes instead.

Either way, use the TTreeView.OnMouseMove event to keep track of which node is currently under the mouse at all times, and when you detect a different node then you can reset the StateIndex of the previous node and update the StateIndex of the new node, or trigger a repaint and draw the icon only on the new node, depending on which approach you take.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • thanks for the positive response. I am interested in the right side, and figured I needed to do some owner-draw functionality if I need the icon in the node item. I was actually wondering about displaying the icon maybe in a TImage? One that displays as you move the mouse over the nodes in the tree and when clicked displays the popup menu? – JakeSays Dec 16 '13 at 15:37
  • 1
    In my experience, owner-drawing tends to yield better results and cleaner code, rather than trying to manage and sync embedded controls. – Remy Lebeau Dec 16 '13 at 16:53
  • Thanks, I have gone that route – JakeSays Dec 17 '13 at 15:21