Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rightclick on treeview 6
Message
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows NT
Database:
MS SQL Server
Miscellaneous
Thread ID:
01074674
Message ID:
01074776
Views:
16
>Hallo.
>I have made a shortcut menu for a treeview list (MS Treview 6.0)
>But a problem just showed up. There is no rightclick event to us in the treeview. (I did'nt look for it before, because there is a rightclick event in almost every object.)
>Ar there any one who has a suggestion how to activate/trig a shortcut menu when the user rightclick the mouse on a node in the tree.
>
>Thanks for any answer
>/Kjell
 * RCTV.PRG Right Click Tree View
PUBLIC oform,unLTVX,unLTVY
xxGetDisplayMetrics()
oform=CREATEOBJECT('myform')
oform.addobject('ocxTreeView','ocxTreeViewClass',;
                              'MSComctlLib.TreeCtrl.2')
* Add some test Nodes
oTV=oform.ocxTreeView
WITH oTV
oTV.width=oform.width
oTV.height=oform.height
.linestyle=1
oTV.nodes.add(,1,"R1","Root Node 1")
oTV.nodes.add("R1",4,"R1C1","Root Node 1 Child 1")
oTV.nodes.add("R1",4,"R1C2","Root Node 1 Child 2")
oTV.nodes.add(,1,"R2","Root Node 2")
oTV.nodes.add("R2",4,"R2C1","Root Node 2 Child 1")
ENDWITH 
oform.visible=.t.

DEFINE CLASS myform as Form
PROCEDURE resize
this.ocxTreeView.height=this.Height
this.ocxTreeView.width=this.Width
ENDPROC
autocenter=.t.
ENDDEFINE &&myform

DEFINE CLASS ocxTreeViewClass as OleControl
visible=.t.
top=0
PROCEDURE mousedown (button, shift, x, y)
IF button=2 && Right Mouse
   oNode=this.HitTest(X*unLTVX,Y*unLTVY)
   this.nodeclick(oNode)
   MESSAGEBOX(this.SelectedItem.text,0,[TV - Right Mouse Down])
ELSE
ENDIF 
ENDPROC &&MouseDown

PROCEDURE nodeclick(Node)
node.selected=.t.
ENDPROC
ENDDEFINE &&ocxTreeView

PROCEDURE xxGetDisplayMetrics
LOCAL liHwnd,liHDC,liPixelsPerInchX,liPixelsPerInchY
declare integer GetActiveWindow in WIN32API
declare integer GetDC in WIN32API integer iHDC
declare integer GetDeviceCaps in WIN32API integer iHDC,integer iIndex
* Device context
liHwnd=GetActiveWindow()
liHDC=GetDC(liHwnd)
* Pixels per Inch
liPixelsPerInchX=GetDeviceCaps(liHDC,88)
liPixelsPerInchY=GetDeviceCaps(liHDC,90)
* Twips per pixel and store
unLTVX=1440/liPixelsPerInchX
unLTVY=1440/liPixelsPerInchY
CLEAR DLLS
ENDPROC &&xxGetDisplayMetrics
* END RCTV
Imagination is more important than knowledge
Previous
Reply
Map
View

Click here to load this message in the networking platform