如何在Vb上用shape控件跟随鼠标下方移动,并产生shape控件阴影
- 提问者网友:嘚啵嘚啵
- 2021-04-23 00:21
- 五星知识达人网友:你可爱的野爹
- 2021-04-23 00:44
我给你做了一个,一个窗体,4个TIMER,4个SHAPE1(0-3),你运行一下看看适合不
Dim distance As Integer
Dim MOVEX
Dim movey
Private Sub Form_Load()
Me.Height = 10000
Me.Width = 10000
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Dim MOVEX As Integer, movey As Integer
MOVEX = X - Shape1(0).Width / 2
movey = Y - Shape1(0).Height / 2
If (MOVEX < 0) Or (MOVEX + Shape1(0).Width > Me.ScaleWidth) Or (movey < 0) Or (movey + Shape1(0).Height > Me.ScaleHeight) Then
Exit Sub
End If
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
Timer4.Enabled = True
End Sub
Private Sub Timer1_Timer()
Shape1(0).Move MOVEX, movey
End Sub
Private Sub Timer2_Timer()
Shape1(1).Move MOVEX + 100, movey + 100
End Sub
Private Sub Timer3_Timer()
Shape1(2).Move MOVEX + 200, movey + 200
End Sub
Private Sub Timer4_Timer()
Shape1(3).Move MOVEX + 300, movey + 300
End Sub