关于VB获取鼠标坐标的问题
我现在有个程序,能获取当前鼠标的坐标点,但是其实我想要的是,利用一个timer获取当前鼠标的坐标点和下一毫秒的鼠标坐标点,然后同时显示在四个text框中,也就是说在第1毫...
我现在有个程序,能获取当前鼠标的坐标点,但是其实我想要的是,利用一个timer获取当前鼠标的坐标点和下一毫秒的鼠标坐标点,然后同时显示在四个text框中,也就是说在第1毫秒时,获取到鼠标的坐标点x1和y1,首先显示在两个text中,第2毫秒时,获取到鼠标的坐标点x2和y2,连同x1和y1,同时显示在4个text中,依次类推,第3毫秒时,获取到x3和y3,连同x2和y2,显示在4个text中,请问这个该怎么弄,以下是我目前的程序:
Private Sub Timer1_Timer()
s = GetCursorPos(position)
Form1.Text1.Text = Str(position.X)
Form1.Text2.Text = Str(position.Y)
End Sub 展开
Private Sub Timer1_Timer()
s = GetCursorPos(position)
Form1.Text1.Text = Str(position.X)
Form1.Text2.Text = Str(position.Y)
End Sub 展开
2个回答
展开全部
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim position As POINTAPI
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
GetCursorPos position
Text3 = Text1
Text4 = Text2
Text1 = p.x
Text2 = p.y
End Sub
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim position As POINTAPI
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
GetCursorPos position
Text3 = Text1
Text4 = Text2
Text1 = p.x
Text2 = p.y
End Sub
追问
还想请问一下,如果我用TEXT5来显示第2毫秒和第1毫秒之间的鼠标坐标位置之差,该怎么写,谢谢了
追答
Private Sub Timer1_Timer()
GetCursorPos position
Text3 = Text1
Text4 = Text2
Text5 = p.x - Text3
Text6 = p.y - Text4
Text1 = p.x
Text2 = p.y
End Sub
2011-07-22
展开全部
Private Sub Timer1_Timer()
s = GetCursorPos(position)
Form1.Text1.Text = Form1.Text3.Text
Form1.Text2.Text =Form1.Text4.Text
Form1.Text3.Text = Str(position.X)
Form1.Text4.Text = Str(position.Y)
End Sub
s = GetCursorPos(position)
Form1.Text1.Text = Form1.Text3.Text
Form1.Text2.Text =Form1.Text4.Text
Form1.Text3.Text = Str(position.X)
Form1.Text4.Text = Str(position.Y)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询