In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

ttreeviewitem position

Xailer English public forum
Responder
Roberto
Mensajes: 177
Registrado: Mar Oct 16, 2007 11:53 pm

ttreeviewitem position

Mensaje 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.
jlalin
Mensajes: 926
Registrado: Sab Dic 25, 2010 11:10 pm

ttreeviewitem position

Mensaje 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
Roberto
Mensajes: 177
Registrado: Mar Oct 16, 2007 11:53 pm

ttreeviewitem position

Mensaje 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.
jlalin
Mensajes: 926
Registrado: Sab Dic 25, 2010 11:10 pm

ttreeviewitem position

Mensaje por jlalin »

Roberto,
I think it can't be done that way. Maybe this works:
aRect := ::oTree:GetItemRect( oItem:nIndex )
Saludos,
José Lalí­n
Responder