2017-09-16 144 views
0

我试着做一个迷宫。当鼠标碰到墙时,它需要返回到panel1的位置,并且它会返回,但是当我移动鼠标时,它会回到我碰到墙的地方,这个事件是无用的。我可以穿过墙壁去完成。 Video LinkVb.net鼠标位置

Public Sub New() 
    InitializeComponent() 
    Start() 
End Sub 

Private Sub Start() 
    Dim StartPoint = Panel1.Location() 
    StartPoint.Offset(20, 20) 
    Cursor.Position = PointToScreen(StartPoint) 
End Sub 

Private Sub Finish_MouseEnter(sender As Object, e As EventArgs) Handles Label17.MouseEnter 
    MessageBox.Show("Gz") 
End Sub 

Private Sub WallHit_MouseEnter(sender As Object, e As EventArgs) Handles Label1.MouseEnter, Panel1.MouseEnter, Label9.MouseEnter, Label8.MouseEnter, Label7.MouseEnter, Label6.MouseEnter, Label5.MouseEnter, Label4.MouseEnter, Label3.MouseEnter, Label2.MouseEnter, Label16.MouseEnter, Label15.MouseEnter, Label14.MouseEnter, Label13.MouseEnter, Label12.MouseEnter 
    Start() 
End Sub 

回答

0

尝试:

Windows.Forms.Cursor.Position = PointToScreen(StartPoint) 

当我想你的代码红粉我警告只使用Windows.Forms.Cursor代替光标的计划。

我不知道答案在第一次... :) :)

0

解决。 我在虚拟机中运行我的应用程序(Windows 10)。当我在vm中运行时出现问题,但是当我在vm外运行它时,我的应用程序正常工作。