逃跑窗体问题!VB!

来源:百度知道 编辑:UC知道 时间:2024/05/16 01:01:22
Command1.Enabled = False
Command1.Caption = "来点啊"
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X < Command1.Left Then Exit Sub
If Y < Command1.Top Then Exit Sub
If X > Command1.Left + Command1.Width Then Exit Sub
If Y > Command1.Top + Command1.Height Then Exit Sub
Command1.Left = Int((Form1.ScaleHeight - Command1.Width) * Rnd)
Command1.Top = Int((Form1.ScaleHeight - Command1.Height) * Rnd)

这个是按扭会逃跑~~我要一个鼠标逃跑的!!!!谁能修改下~~!!!谢谢!!!
注意!!!我要修改一个是当鼠标靠近按扭时~~!!!是鼠标到随机位置!!!!!!!!

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Left = Int((Form1.ScaleWidth - Command1.Width) * Rnd)
Command1.Top = Int((Form1.ScaleHeight - Command1.Height) * Rnd)
End Sub

http://www.cnblogs.com/rainstormmaster/archive/2006/01/18/319887.html

本答案绝对是鼠标逃跑的
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
SetCursorPos 1000 * Rnd, 1000 * Rnd
End Sub