如窗体的MouseUp事件: Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 2 Then PopupMenu pop_menu,,x,y End IfEnd Sub
这样为何还不行啊? private Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long Private Type POINTAPI x As Long y As Long End TypePrivate Sub MDIForm_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) Dim Mousepoint As POINTAPI ret = GetCursorPos(Mousepoint)If Button = 2 Then PopupMenu pop_menu, 0, Mousepoint.x, Mousepoint.y End If End Sub
POPUPMENU方法原形为
OBJECT.POPUPMENU MENUNAME,FLAGS,X,Y,BOLDCOMMAND
其中X,Y即为弹出位置。
2、建立FRAME控件
把你的表单内容都放在FRAME里
然后FRAME的MOUSE UP事件
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)If Button = 2 Then
PopupMenu pop_menu,,x,y
End IfEnd Sub
private Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End TypePrivate Sub MDIForm_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim Mousepoint As POINTAPI
ret = GetCursorPos(Mousepoint)If Button = 2 Then
PopupMenu pop_menu, 0, Mousepoint.x, Mousepoint.y
End If
End Sub