2个回答
2013-10-10
展开全部
一楼方法不行,我就单独是click也会相应mousedown事件,方法如下:
'''窗体上添加一个Label, 一个Timer1
Option Explicit
Private btnFlag As Boolean, mButton As Integer
Private Sub Form_Load()
Label1.Caption = "未按下鼠标任何键"
Label1.AutoSize = True
Timer1.Enabled = False
Timer1.Interval = 800 '鼠标按住800毫秒以上判断为鼠标处理按住状态, 可以根据具体需要调整
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = True
mButton = Button
btnFlag = True
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
btnFlag = False
Label1.Caption = "未按下鼠标任何键"
End Sub
Private Sub Timer1_Timer()
If btnFlag Then
Select Case mButton
Case 1
Label1.Caption = "按下鼠标左键中..."
Case 2
Label1.Caption = "按下鼠标右键中..."
Case 4
Label1.Caption = "按下鼠标中间键中..."
End Select
Else
Timer1.Enabled = False
End If
End Sub
'''窗体上添加一个Label, 一个Timer1
Option Explicit
Private btnFlag As Boolean, mButton As Integer
Private Sub Form_Load()
Label1.Caption = "未按下鼠标任何键"
Label1.AutoSize = True
Timer1.Enabled = False
Timer1.Interval = 800 '鼠标按住800毫秒以上判断为鼠标处理按住状态, 可以根据具体需要调整
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = True
mButton = Button
btnFlag = True
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
btnFlag = False
Label1.Caption = "未按下鼠标任何键"
End Sub
Private Sub Timer1_Timer()
If btnFlag Then
Select Case mButton
Case 1
Label1.Caption = "按下鼠标左键中..."
Case 2
Label1.Caption = "按下鼠标右键中..."
Case 4
Label1.Caption = "按下鼠标中间键中..."
End Select
Else
Timer1.Enabled = False
End If
End Sub
2013-10-10
展开全部
Private sub form_MOUSEdown(button as integer)
if button=1 then '1按住左键
Msgbox "你按住的为左键"
else
Msgbox "你按住的为右键"
END SUB
if button=1 then '1按住左键
Msgbox "你按住的为左键"
else
Msgbox "你按住的为右键"
END SUB
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询