VB获取光标处坐标

[复制链接]
查看11 | 回复1 | 2010-9-12 22:15:33 | 显示全部楼层 |阅读模式
Public Class Form1

Private Structure abc

Dim x As Long

Dim y As Long

End Structure

Private Declare Function GetCursorPos Lib "user32 " (ByVal lpPoint As abc) As Long

Dim z As abc

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown

GetCursorPos(z)
'得到鼠标

Label1.Text = z.x

Label2.Text = z.y

End Sub
End Class
为什么运行后,鼠标不论在何处,label1,label2的值总是0

回复

使用道具 举报

千问 | 2010-9-12 22:15:33 | 显示全部楼层
form1添加1个LABEL,名:lblMouse。一个Timer:名:timMPos,interval:100Public Sub MouseGetCursorPos()
Dim lpPoint As POINTAPI
Dim summyAs Long
'
summy = GetCursorPos(lpPoint)
'
m_x = lpPoint.X
m_y = lpPoint.YEnd SubPrivate Sub timMPos_Timer()
'
MouseGetCursorPos
lblMouse.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行