Board index » delphi » right-click popup menu for an ITEM in a treeview

right-click popup menu for an ITEM in a treeview

Anyone here know how to create a popup menu for an item in a treeview,
simmilar to how some other programs work? I tried using the popupmenu
property of the entire treeview itself, but it will still popup even if the
user didnt right click over an item (it shouldnt do this.. look at how
outlook express works)

any ideas?

-EB

 

Re:right-click popup menu for an ITEM in a treeview


Quote
Wolf wrote in message <7if8r1$6...@forums.borland.com>...
>Anyone here know how to create a popup menu for an item in a treeview,
>simmilar to how some other programs work? I tried using the popupmenu
>property of the entire treeview itself, but it will still popup even if the
>user didnt right click over an item (it shouldnt do this.. look at how
>outlook express works)

You can popup a menu yourself by calling PopupMenu.Popup.

To determine where to pop it up, handle the MouseDown event of the treeview.

There are also methods in the treeview to let you find out which node (if
any) the mouse was clicked over by passing the mouse position (which you can
also get via GetCursorPos). This will let you customize the popup menu based
on any particular treeview node.

--
Wayne Niddery - WinWright Consulting
Delphi, C++Builder, JBuilder, InterDev --
http://home.ican.net/~wniddery/RADBooks.html
"It is not true that the function of law is to regulate our consciences, our
ideas, our wills, our education, our opinions, our work, our trade, our
talents or our pleasures. The function of law is to protect the free
exercise of these rights." - Frederic Bastiat, 1850

Re:right-click popup menu for an ITEM in a treeview


Which functions/methods are the ones that let me determine which node/line
it is over, if any?

Wayne Niddery (TeamB) <winwri...@chaffhome.com> wrote in message
news:7ifm7c$u93@forums.borland.com...

Quote
> Wolf wrote in message <7if8r1$6...@forums.borland.com>...
> >Anyone here know how to create a popup menu for an item in a treeview,
> >simmilar to how some other programs work? I tried using the popupmenu
> >property of the entire treeview itself, but it will still popup even if
the
> >user didnt right click over an item (it shouldnt do this.. look at how
> >outlook express works)

> You can popup a menu yourself by calling PopupMenu.Popup.

> To determine where to pop it up, handle the MouseDown event of the
treeview.

> There are also methods in the treeview to let you find out which node (if
> any) the mouse was clicked over by passing the mouse position (which you
can
> also get via GetCursorPos). This will let you customize the popup menu
based
> on any particular treeview node.

> --
> Wayne Niddery - WinWright Consulting
> Delphi, C++Builder, JBuilder, InterDev --
> http://home.ican.net/~wniddery/RADBooks.html
> "It is not true that the function of law is to regulate our consciences,
our
> ideas, our wills, our education, our opinions, our work, our trade, our
> talents or our pleasures. The function of law is to protect the free
> exercise of these rights." - Frederic Bastiat, 1850

Re:right-click popup menu for an ITEM in a treeview


Quote
In article <7ih8rv$2...@forums.borland.com>, Wolf wrote:
> Which functions/methods are the ones that let me determine which node/line
> it is over, if any?

The MouseDown event handler passes X & Y parameters which you can use in the
TTreeView.GetNodeAt method.

 Mike Orriss (TeamB)
 (No e-mail replies, please, unless explicitly requested!)

Re:right-click popup menu for an ITEM in a treeview


Quote
>Wolf wrote:

>Which functions/methods are the ones that let me determine which >node/line it is over, if any?

TreeView.GetNodeAt(X, Y: Integer): TTreeNode;
or more sophisticated  
TreeView.GetHittestInfoAt(X, Y: Integer): THitTests;

_________
Andreas

Other Threads