2017-09-16 174 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外運行它時,我的應用程序正常工作。