我想在Visual Basic 2010中的应用程序中创建一个函数:
我该如何使用此功能?
答案 0 :(得分:0)
我认为这就是你要找的东西
If Windows.Forms.Cursor.Position = Button2.PointToScreen(New Point(Button2.Width / 2, Button2.Height / 2)) Then
Timer1.Enabled = False
Button2_MouseDown(New Button, New MouseEventArgs(MouseButtons.Left, 1, Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y, 0))
End If
If Windows.Forms.Cursor.Position.X <> Button2.PointToScreen(New Point(Button2.Width / 2, Button2.Height / 2)).X Then
If Windows.Forms.Cursor.Position.X > Button2.PointToScreen(New Point(Button2.Width / 2, Button2.Height / 2)).X Then
Windows.Forms.Cursor.Position = New Point(Windows.Forms.Cursor.Position.X - 1, Windows.Forms.Cursor.Position.Y)
ElseIf Windows.Forms.Cursor.Position.X < Button2.PointToScreen(New Point(Button2.Width / 2, Button2.Height / 2)).X Then
Windows.Forms.Cursor.Position = New Point(Windows.Forms.Cursor.Position.X + 1, Windows.Forms.Cursor.Position.Y)
End If
End If
If Windows.Forms.Cursor.Position.Y <> Button2.PointToScreen(New Point(Button2.Width / 2, Button2.Height / 2)).Y Then
If Windows.Forms.Cursor.Position.Y > Button2.PointToScreen(New Point(Button2.Width / 2, Button2.Height / 2)).Y Then
Windows.Forms.Cursor.Position = New Point(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y - 1)
ElseIf Windows.Forms.Cursor.Position.Y < Button2.PointToScreen(New Point(Button2.Width / 2, Button2.Height / 2)).Y Then
Windows.Forms.Cursor.Position = New Point(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y + 1)
End If
End If
这里发帖有点长,所以我创建了一个简单的项目。
示例程序Here
完整来源Here