永发信息网

如何在Vb上用shape控件跟随鼠标下方移动,并产生shape控件阴影

答案:1  悬赏:20  手机版
解决时间 2021-04-23 12:45
  • 提问者网友:嘚啵嘚啵
  • 2021-04-23 00:21
如:windows自带的鼠标移动轨迹一样
最佳答案
  • 五星知识达人网友:你可爱的野爹
  • 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

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯