X
x taol
'event module
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
Button1_Click
End Sub
'general module
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI)
As Long
Public Type POINTAPI
X As Long
Y As Long
End Type
Sub Button1_Click()
Dim mousePoint As POINTAPI
Dim z1 As CommandBarPopup, z2 As CommandBarPopup
On Error Resume Next: Application.CommandBars("popMnu").Delete: On Error
GoTo 0
Set cb = CommandBars.Add(Name:="popMnu", Position:=msoBarPopup,
MenuBar:=0, Temporary:=1)
For i = 0 To 2
Set z1 = cb.Controls.Add(msoControlPopup)
z1.Caption = VBA.Rnd * 100
For j = 0 To 2
Set z2 = z1.Controls.Add(msoControlPopup)
z2.Caption = VBA.Rnd * 50
For k = 1 To 2
Set cm = z2.Controls.Add(msoControlButton)
sr = Choose(k, "rw", "r")
cm.Caption = sr
cm.OnAction = "ho"
Next
Next
Next
GetCursorPos mousePoint
cb.ShowPopup mousePoint.X, mousePoint.Y
End Sub
Sub ho()
CommandBars.ActionControl.Parent.Caption
'the following code does not work.
'i want to get caption of the parent menu of clicked menu.
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
Button1_Click
End Sub
'general module
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI)
As Long
Public Type POINTAPI
X As Long
Y As Long
End Type
Sub Button1_Click()
Dim mousePoint As POINTAPI
Dim z1 As CommandBarPopup, z2 As CommandBarPopup
On Error Resume Next: Application.CommandBars("popMnu").Delete: On Error
GoTo 0
Set cb = CommandBars.Add(Name:="popMnu", Position:=msoBarPopup,
MenuBar:=0, Temporary:=1)
For i = 0 To 2
Set z1 = cb.Controls.Add(msoControlPopup)
z1.Caption = VBA.Rnd * 100
For j = 0 To 2
Set z2 = z1.Controls.Add(msoControlPopup)
z2.Caption = VBA.Rnd * 50
For k = 1 To 2
Set cm = z2.Controls.Add(msoControlButton)
sr = Choose(k, "rw", "r")
cm.Caption = sr
cm.OnAction = "ho"
Next
Next
Next
GetCursorPos mousePoint
cb.ShowPopup mousePoint.X, mousePoint.Y
End Sub
Sub ho()
CommandBars.ActionControl.Parent.Caption
'the following code does not work.
'i want to get caption of the parent menu of clicked menu.
End Sub
*** Sent via Developersdex http://www.developersdex.com ***