diff --git a/Pilz.Win32/Native/POINT.vb b/Pilz.Win32/Native/POINT.vb new file mode 100644 index 0000000..e967331 --- /dev/null +++ b/Pilz.Win32/Native/POINT.vb @@ -0,0 +1,21 @@ +Imports System.Runtime.InteropServices + +Namespace Native + + + Public Structure POINT + Public Sub New(ByVal p As System.Drawing.Point) + Me.x = p.X + Me.y = p.Y + End Sub + + Public Sub New(ByVal x As Integer, ByVal y As Integer) + Me.x = x + Me.y = y + End Sub + + Public x As Integer + Public y As Integer + End Structure + +End Namespace diff --git a/Pilz.Win32/Native/RECT.vb b/Pilz.Win32/Native/RECT.vb new file mode 100644 index 0000000..650ecba --- /dev/null +++ b/Pilz.Win32/Native/RECT.vb @@ -0,0 +1,82 @@ +Imports System.Drawing +Imports System.Runtime.InteropServices + +Namespace Native + + + Public Structure RECT + Public Left As Integer + Public Top As Integer + Public Right As Integer + Public Bottom As Integer + + Public Sub New(ByVal left_ As Integer, ByVal top_ As Integer, ByVal right_ As Integer, ByVal bottom_ As Integer) + Left = left_ + Top = top_ + Right = right_ + Bottom = bottom_ + End Sub + + Public Sub New(ByVal r As Rectangle) + Left = r.Left + Top = r.Top + Right = r.Right + Bottom = r.Bottom + End Sub + + Public ReadOnly Property Height As Integer + Get + Return Bottom - Top + End Get + End Property + + Public ReadOnly Property Width As Integer + Get + Return Right - Left + End Get + End Property + + Public ReadOnly Property Size As System.Drawing.Size + Get + Return New System.Drawing.Size(Width, Height) + End Get + End Property + + Public ReadOnly Property Location As System.Drawing.Point + Get + Return New System.Drawing.Point(Left, Top) + End Get + End Property + + Public Function ToRectangle() As Rectangle + Return Rectangle.FromLTRB(Left, Top, Right, Bottom) + End Function + + Public Shared Function FromRectangle(ByVal rectangle As Rectangle) As RECT + Return New RECT(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom) + End Function + + Public Overrides Function GetHashCode() As Integer + Return Left ^ ((Top << 13) Or (Top >> &H13)) _ + ^ ((Width << &H1A) Or (Width >> 6)) _ + ^ ((Height << 7) Or (Height >> &H19)) + End Function + + Public Shared Function FromXYWH(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As RECT + Return New RECT(x, y, x + width, y + height) + End Function + + Public Shared Widening Operator CType(ByVal rect As RECT) As Rectangle + Return Rectangle.FromLTRB(rect.Left, rect.Top, rect.Right, rect.Bottom) + End Operator + + Public Shared Widening Operator CType(ByVal rect As Rectangle) As RECT + Return New RECT(rect.Left, rect.Top, rect.Right, rect.Bottom) + End Operator + + Public Overrides Function ToString() As String + Return "Left=" & Me.Left & ", Top=" & Me.Top & ", Right=" & Me.Right & ", Bottom=" & Me.Bottom + End Function + End Structure + +End Namespace diff --git a/Pilz.Win32/Native/User32.vb b/Pilz.Win32/Native/User32.vb new file mode 100644 index 0000000..d10c083 --- /dev/null +++ b/Pilz.Win32/Native/User32.vb @@ -0,0 +1,17 @@ +Imports System.Runtime.InteropServices + +Namespace Native + + Public Class User32 + + + Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef r As RECT) As Boolean + End Function + + + Public Shared Function ChildWindowFromPointEx(ByVal hWndParent As IntPtr, ByVal pt As POINT, ByVal uFlags As UInteger) As IntPtr + End Function + + End Class + +End Namespace diff --git a/Pilz.Win32/Native/WindowFromPointFlags.vb b/Pilz.Win32/Native/WindowFromPointFlags.vb new file mode 100644 index 0000000..e127c8c --- /dev/null +++ b/Pilz.Win32/Native/WindowFromPointFlags.vb @@ -0,0 +1,11 @@ +Namespace Native + + + Public Enum WindowFromPointFlags + CWP_ALL = &H0 + CWP_SKIPINVISIBLE = &H1 + CWP_SKIPDISABLED = &H2 + CWP_SKIPTRANSPARENT = &H4 + End Enum + +End Namespace \ No newline at end of file