【发布时间】:2013-12-12 09:20:37
【问题描述】:
当我在 WndProc 中收到WM_MOUSEMOVE 消息时,lParam 包含光标坐标。我把这个参数翻译成Point结构:
Friend Shared Function LParamToPoint(ByVal lParam As IntPtr) As Point
Return New Point(LOWORD(lParam.ToInt32()), HIWORD(lParam.ToInt32()))
End Function
Friend Shared Function HIWORD(ByVal value As Integer) As Short
Return CShort((value >> 16))
End Function
Friend Shared Function LOWORD(ByVal value As Integer) As Short
Return CShort((value And UShort.MaxValue))
End Function
我的问题是,当光标的 x 坐标变为负数时,LOWORD 函数会失败并出现溢出异常。根据 MSDN,您应该使用 GET_X_LPARAM 和 GET_Y_LPARAM 宏而不是 HI/LO WORD 宏。但是在 vb.net 中没有这样的功能。
那该怎么办呢?
【问题讨论】:
标签: .net vb.net winforms windows-ce compact-framework2.0