小弟想通过在某一控件上单击鼠标右键执行一条命令,可是该控件上没有该事件可供选择,请问大哥大姐如何定义该控件的鼠标右键单击事件呢?

解决方案 »

  1.   

    mouseup时判断鼠标按钮,
    或者,在mousedown时记录下鼠标按钮,然后在click中处理
      

  2.   

    一个简单的例子
    Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     If Button = vbRightButton Then Print 111
    End Sub
      

  3.   

    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 2 Then MsgBox "点击了鼠标右键"
    End Sub
      

  4.   

    Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
    '............    ’你的命令
    End If
    End Sub
      

  5.   

    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 2 Then MsgBox "右键"
    End Sub
      

  6.   

    楼上3位都对
    回复人:hnzhc(王林)(▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲)信誉:60000