Página 1 de 1

ttreeviewitem position

Publicado: Mié Ene 23, 2013 8:17 pm
por Roberto
how to get the position (x, y) of a ttreeview item? I need it to open a popup menu when the user press the context key.

ttreeviewitem position

Publicado: Mié Ene 23, 2013 8:45 pm
por jlalin
Roberto,
double click the OnContextMenu event and add this code:
METHOD TreeContextMenu( oSender, nPosX, nPosY ) CLASS TForm1
//Change ::oTree to your treeview name
LOCAL oItem := ::oTree:HitTest( nPosX, nPosY )
LOCAL oMenu
IF oItem != Nil
oItem:Select()
MENU oMenu POPUP
MENUITEM "First"
MENUITEM "Second"
ENDMENU
::oTree:ShowPopupMenu( oMenu, nPosX, nPosY )
// You can create the menu from the IDE and use it here
// ::oTree:ShowPopupMenu( ::oMenu1, nPosX, nPosY )
ENDIF
ENDIF
IF oMenu != Nil
oMenu:Destroy()
ENDIF
RETURN 1
Saludos,
José Lalí­n

ttreeviewitem position

Publicado: Mié Ene 23, 2013 9:11 pm
por Roberto
tks so much.
by the way, how can I use the property Handle of a ttreeviewitem? I tried to use it with screentoclient to get the position but did not work.

ttreeviewitem position

Publicado: Jue Ene 24, 2013 4:45 pm
por jlalin
Roberto,
I think it can't be done that way. Maybe this works:
aRect := ::oTree:GetItemRect( oItem:nIndex )
Saludos,
José Lalí­n