如何用VB如何使鼠标移动到窗口,窗口在屏幕四周移动
先用VB做一个窗口,在top0left0的位置。使鼠标一移动到窗口,窗口就跑到屏幕右上角再移动到屏幕右上角,就跑到右下角,接着在屏幕右下角的窗口里移动又跑到左下角,最后在...
先用VB做一个窗口,在top0 left0 的位置。使鼠标一移动到窗口,窗口就跑到屏幕右上角再移动到屏幕右上角,就跑到右下角,接着在屏幕右下角的窗口里移动又跑到左下角,最后在屏幕左下角的窗口里移动又跑回原来的位置。就这样不断循环。这是我跟网上学,写的代码,但是移到右上角的时候就不动了。谁能告诉我错在哪了,帮我改一下Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Form1.Top = 0 Then
Form1.Top = 0
Form1.Left = 16000
ElseIf Form1.Left = 16000 Then
Form1.Top = 9500
Form1.Left = 16000
ElseIf Form1.Top = 9500 Then
Form1.Top = 9500
Form1.Left = 0
ElseIf Form1.Left = 0 Then
Form1.Top = 0
Form1.Left = 0
End If
End Sub 展开
If Form1.Top = 0 Then
Form1.Top = 0
Form1.Left = 16000
ElseIf Form1.Left = 16000 Then
Form1.Top = 9500
Form1.Left = 16000
ElseIf Form1.Top = 9500 Then
Form1.Top = 9500
Form1.Left = 0
ElseIf Form1.Left = 0 Then
Form1.Top = 0
Form1.Left = 0
End If
End Sub 展开
2014-01-01
展开全部
你的程序可能是错在它对屏幕四角的概念的解释上吧,不同分辨率的屏幕的长宽都是不一定的,所以不应该用固定的数值来做这个程序,我用另一个方法写了这个程序,下面是代码,希望对你会有帮助Dim a As IntegerPrivate Sub Form_Load()
a = 0
Form1.Top = 0
Form1.Left = 0
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case a
Case 0
a = 1
Form1.Left = Screen.Width - Form1.Width
Case 1
a = 2
Form1.Top = Screen.Height - Form1.Height
Case 2
a = 3
Form1.Left = 0
Case 3
a = 0
Form1.Top = 0
End Select
End Sub
a = 0
Form1.Top = 0
Form1.Left = 0
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case a
Case 0
a = 1
Form1.Left = Screen.Width - Form1.Width
Case 1
a = 2
Form1.Top = Screen.Height - Form1.Height
Case 2
a = 3
Form1.Left = 0
Case 3
a = 0
Form1.Top = 0
End Select
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询