Board index » delphi » need help with programmatic assignment of Popup menu using TTreeView component

need help with programmatic assignment of Popup menu using TTreeView component

Hey all,

I'm in the process of making an "Explorer" look & feel alike interface for
DB application and encountered an obstacle I don't know how to go around.

Windows Explorer's left pane uses the TreeView control and if you
experiment with the items in the listing you will notice that the popup
menu that appears when you right click on any entry can change from one
type of listing to another.  Folders all share the same popup menu, but
items other than Folders (directories) differ.

I want to control what kind of popup menu appears when my users right click
on items in the TTreeView component, and I want it all done
programmatically at runtime.  My explorer interface has numerous types of
listings, each with very specific actions that need to be performed, so
I've already put together a series of popup menus (eight in total) for each
type of listing category.

I've set the TTreeView component's "RightClickSelected" property to True,
however when you right click on an item, it momentarily highlights the item
you right clicked but when you release the mouse button the highlighted
selection goes back to the selection that was made prior to the right mouse
click.  How do I make the selection follow the highlight?  My Delphi help
file (nor the printed manuals for that matter) does not cover this property
at all so I have no way of reading up on this and experimentation is not
bringing out desired results.

Based on the type of listing that was right clicked I would like to assign
the TTreeView's "PopupMenu" property the value of one of these popup menu's
I've made and then call its "Popup" method.  

Secondary to this (important, but not as important as the above), I'd like
the popup menu to appear near to the spot where I right-clicked.  The
TTreeView's "OnChange" event is the event I hoped to utilize in this
process and it does not include the X,Y screen cursor coordinates, so I
need to figure out how to set the popup menu's Top and Left property values
somehow.

What I want to do is not out of the ordinary (several Microsoft products
all look/feel this way from Windows Explorer to Front Page Explorer), yet
it appears that my ideas are very out of the ordinary given the fact that
TTreeView lacks an "OnRightClick" event as well as the fact that the
property "RightClickSelected" does not work in the manner that it elludes
to.

Any help would be greatly appreciated.  If you have a project already built
which illustrates this, I'd beg borrow and steal to see the code since it
appears that there are flavors of nuances to this technique.

Respectfully,

Perry Way

===========================================
don't use News reader "reply" feature if you want to send
me private email.  Embedded email address in post is a
moronic habitual spammer.

instead.. click here to send me email.. m...@wascoinc.com
===========================================

 

Re:need help with programmatic assignment of Popup menu using TTreeView component


I use Delphi3 on NT and IE4, and the following method works for me.
1) Set the rightclickselect property to false
2) In the OnChange event of the tree control, assign the popup menu you want
displayed to the
    popupmenu property of the tree control
3) set the autopopup property of the menu to true

This should work in exactly the way you are hoping

Hope this helps

Phil

Quote
Perry Way wrote in message <01bd31e1$d7f67da0$0b646464@mis>...
>Hey all,

>I'm in the process of making an "Explorer" look & feel alike interface for
>DB application and encountered an obstacle I don't know how to go around.

<SNIP>
I want to control what kind of popup menu appears when my users right click
Quote
>on items in the TTreeView component, and I want it all done
>programmatically at runtime.  My explorer interface has numerous types of
>listings, each with very specific actions that need to be performed, so
>I've already put together a series of popup menus (eight in total) for each
>type of listing category.
<SNIP>
>Any help would be greatly appreciated.  If you have a project already built
>which illustrates this, I'd beg borrow and steal to see the code since it
>appears that there are flavors of nuances to this technique.

>Respectfully,

>Perry Way

>===========================================
>don't use News reader "reply" feature if you want to send
>me private email.  Embedded email address in post is a
>moronic habitual spammer.

>instead.. click here to send me email.. m...@wascoinc.com
>===========================================

Other Threads