好像在我这里可以阿 Dim prex As Integer, prey As IntegerPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) prex = X prexy = YEnd SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If (Button And 3) = 3 Then Text1.Move Text1.Left + X - prex, Text1.Top + Y + prey End Sub 同时按下作邮件,则可以移动text1
以前人家的帖子Option Explicit Dim MouseBtn As IntegerPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MouseBtn = 0 Then MouseBtn = Button ElseIf MouseBtn = vbLeftButton Then If Button = vbRightButton Then MsgBox "左键 + 右键" MouseBtn = 0 End If ElseIf MouseBtn = vbRightButton Then If Button = vbLeftButton Then MsgBox "右键 + 左键" MouseBtn = 0 End If End If
End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseBtn = 0
End Sub
if(button and 3)=3 then '该语句的意思是同时按下左右鼠标,因为有可能先按左再按右。。 if button and 3 then '该语句是判断结果是否为true,有3种情况为true,即按下左键再按下右键或同时按下左右键 对于MouseDown和MouseUp只能判断按下或松开某一个键,不能判断两个键被同时按下或松开。 可以用MouseMove事件来判断 Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If (Button And 3) = 3 Then msgbox "同时按下了左右鼠标" End If End Sub
在mousedown事件里写 if button=2 then . . else if button=1 then . . else . . end if end if 2代表是右键,1代表是左键
应该这样: :))Option ExplicitPrivate mbLeftDown As Boolean Private mbRightDown As BooleanPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If (Button And vbLeftButton) Then mbLeftDown = True If (Button And vbRightButton) Then mbRightDown = True
If mbLeftDown And mbRightDown Then Me.Caption = "see this?" & Time End If
End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If (Button And vbLeftButton) Then mbLeftDown = False If (Button And vbRightButton) Then mbRightDown = FalseEnd Sub
Dim prex As Integer, prey As IntegerPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
prex = X
prexy = YEnd SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And 3) = 3 Then Text1.Move Text1.Left + X - prex, Text1.Top + Y + prey
End Sub
同时按下作邮件,则可以移动text1
Dim MouseBtn As IntegerPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MouseBtn = 0 Then
MouseBtn = Button
ElseIf MouseBtn = vbLeftButton Then
If Button = vbRightButton Then
MsgBox "左键 + 右键"
MouseBtn = 0
End If
ElseIf MouseBtn = vbRightButton Then
If Button = vbLeftButton Then
MsgBox "右键 + 左键"
MouseBtn = 0
End If
End If
End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseBtn = 0
End Sub
if button and 3 then '该语句是判断结果是否为true,有3种情况为true,即按下左键再按下右键或同时按下左右键
对于MouseDown和MouseUp只能判断按下或松开某一个键,不能判断两个键被同时按下或松开。
可以用MouseMove事件来判断
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And 3) = 3 Then
msgbox "同时按下了左右鼠标"
End If
End Sub
if button=2 then
.
.
else
if button=1 then
.
.
else
.
.
end if
end if
2代表是右键,1代表是左键
Private mbRightDown As BooleanPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) Then mbLeftDown = True
If (Button And vbRightButton) Then mbRightDown = True
If mbLeftDown And mbRightDown Then
Me.Caption = "see this?" & Time
End If
End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) Then mbLeftDown = False
If (Button And vbRightButton) Then mbRightDown = FalseEnd Sub