, , . "" , GetMessagePos, GET_X_LPARAM GET_Y_LPARAM, Windows SDK. GetMessagePos, , . LOWORD HIWORD, , .
, , GET_X_LPARAM GET_Y_LPARAM C VB.NET. # , unchecked:
int GetXValue(UInt32 lParam)
{
return unchecked((short)(long)lParam);
}
int GetYValue(UInt32 lParam)
{
return unchecked((short)((long)lParam >> 16));
}
VB.NET # unchecked, . # , , .
VB.NET, . UInt32, . x- , . y- . Short:
Public Function GetXValue(lParam As UInt32) As Short
Return CShort(lParam And &HFFFF)
End Function
Public Function GetYValue(lParam As UInt32) As Short
Return CShort((lParam >> 16) And &HFFFF)
End Function
- , , , , , . C-, VB.NET , :
<StructLayout(LayoutKind.Explicit)> _
Public Structure CoordUnion
<FieldOffset(0)> Public LParam As UInt32
<FieldOffset(0)> Public XCoord As Short
<FieldOffset(2)> Public YCoord As Short
Public Sub New(lParam As UInt32)
LParam = lParam
End Sub
End Structure
:
Dim temp As CoordUnion = New CoordUnion(GetMessagePos())
Dim pt As Point = New Point(temp.XCoord, temp.YCoord)
' ...
, P/Invoke GetMessagePos, UInt32:
<System.Runtime.InteropServices.DllImport("user32.dll", ExactSpelling:=True)>
Private Shared Function GetMessagePos() As UInt32
End Function
IntPtr / UInt32. , , , , lParam (, WndProc ).