TextBox怎么会没有MouseUP事件呢? Public isMove As Boolean Public bX, bY As LongPrivate Sub Form_Load() isMove = False End SubPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then isMove = True bX = X bY = Y End If End SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 And isMove Then Text1.Move X + Text1.Left - bX, Y + Text1.Top - bY End If End SubPrivate Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) isMove = False End Sub
这是一个改变控件大小的例子,我用的是PictureBoxPublic bX, bY As Long Public bW, bH As LongPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.MousePointer = 0 End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 And Me.MousePointer = 8 Then bX = X bY = Y bW = Picture1.Width bH = Picture1.Height End If End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 0 Then If X > Picture1.Width - 150 And X < Picture1.Width + 50 And Y > Picture1.Height - 150 And Y < Picture1.Height + 50 Then Me.MousePointer = 8 Else Me.MousePointer = 0 End If ElseIf Button = 1 Then If bW + X - bX <= 0 Or bH + Y - bY <= 0 Then Exit Sub Picture1.Width = bW + X - bX Picture1.Height = bH + Y - bY End If End Sub
我用的是TEXT控件
怎么没出发MOUCE-UP事件?
text1.height=XXXXX
Public isMove As Boolean
Public bX, bY As LongPrivate Sub Form_Load()
isMove = False
End SubPrivate Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
isMove = True
bX = X
bY = Y
End If
End SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And isMove Then
Text1.Move X + Text1.Left - bX, Y + Text1.Top - bY
End If
End SubPrivate Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
isMove = False
End Sub
Public bW, bH As LongPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.MousePointer = 0
End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And Me.MousePointer = 8 Then
bX = X
bY = Y
bW = Picture1.Width
bH = Picture1.Height
End If
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 0 Then
If X > Picture1.Width - 150 And X < Picture1.Width + 50 And Y > Picture1.Height - 150 And Y < Picture1.Height + 50 Then
Me.MousePointer = 8
Else
Me.MousePointer = 0
End If
ElseIf Button = 1 Then
If bW + X - bX <= 0 Or bH + Y - bY <= 0 Then Exit Sub
Picture1.Width = bW + X - bX
Picture1.Height = bH + Y - bY
End If
End Sub