vb.net 谁能帮我把这个获取鼠标位置的模块给改成.net的模块啊?谢谢了

PublicDeclareSubmouse_eventLib"user32"(ByValdwFlagsAsLong,ByValdxAsLong,ByValdyAsLong... Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long

模块内容:
Public Type POINTAPI
X As Long
Y As Long
End Type

Public Function GetX() As Long
Dim n As POINTAPI
GetCursorPos n
GetX = n.X
End Function
'Download by http://www.codefans.net
Public Function GetY() As Long
Dim n As POINTAPI
GetCursorPos n
GetY = n.Y
End Function

窗体内容:

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseExit As Boolean
MouseExit = (0 <= X) And (X <= Picture1.Width) And (0 <= Y) And (Y <= Picture1.Height)
If MouseExit Then
Label3.Caption = "鼠标进入了图片"
SetCapture Picture1.hWnd
Else
Label3.Caption = "鼠标离开了图片"
ReleaseCapture
End If
End Sub

Private Sub Timer1_Timer()
Dim n As POINTAPI
GetCursorPos n
Text1.Text = n.X
Text2.Text = n.Y
End Sub

求帮我改成vb.net语言,谢谢了!
展开
 我来答
1291389703
2014-05-16 · 超过21用户采纳过TA的回答
知道答主
回答量:62
采纳率:50%
帮助的人:27.2万
展开全部
Private Sub PictureBox1_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox1.MouseLeave
Label1.Text = "鼠标离开图片"
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
Label1.Text = "鼠标进入图片"
Text1.Text = e.X
Text2.Text = e.Y
End Sub

'vb.net获取鼠标位置很容易,都不用声明API,直接在事件里获取就行了
追问
Dim n As POINTAPI
GetCursorPos n
Text1.Text = n.X
Text2.Text = n.Y

这段用vb.net 怎么表达啊、
追答
Public Structure POINTAPI
Dim X As Long
Dim Y As Long
End Structure

Public Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Long

Sub dosomething()
Dim n As New POINTAPI
GetCursorPos(n)
Text1.Text = n.X
Text2.Text = n.Y
End Sub

'如果你使用的vb.net开发平台是 Visual Studio 2012 及以上的,要注意API参数的类型(有些long类型为int32类型),否则会引发未知错误
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
难以形容的啊
2014-06-01 · 超过39用户采纳过TA的回答
知道答主
回答量:86
采纳率:0%
帮助的人:95.2万
展开全部
参考答案: 问候不一定要慎重其事,但一定要真诚感人。
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式