add some more native functions for Highlighter
This commit is contained in:
21
Pilz.Win32/Native/POINT.vb
Normal file
21
Pilz.Win32/Native/POINT.vb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Imports System.Runtime.InteropServices
|
||||||
|
|
||||||
|
Namespace Native
|
||||||
|
|
||||||
|
<StructLayout(LayoutKind.Sequential)>
|
||||||
|
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
|
||||||
82
Pilz.Win32/Native/RECT.vb
Normal file
82
Pilz.Win32/Native/RECT.vb
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
Imports System.Drawing
|
||||||
|
Imports System.Runtime.InteropServices
|
||||||
|
|
||||||
|
Namespace Native
|
||||||
|
|
||||||
|
<Serializable, StructLayout(LayoutKind.Sequential)>
|
||||||
|
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
|
||||||
17
Pilz.Win32/Native/User32.vb
Normal file
17
Pilz.Win32/Native/User32.vb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
Imports System.Runtime.InteropServices
|
||||||
|
|
||||||
|
Namespace Native
|
||||||
|
|
||||||
|
Public Class User32
|
||||||
|
|
||||||
|
<DllImport("user32")>
|
||||||
|
Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef r As RECT) As Boolean
|
||||||
|
End Function
|
||||||
|
|
||||||
|
<DllImport("user32.dll")>
|
||||||
|
Public Shared Function ChildWindowFromPointEx(ByVal hWndParent As IntPtr, ByVal pt As POINT, ByVal uFlags As UInteger) As IntPtr
|
||||||
|
End Function
|
||||||
|
|
||||||
|
End Class
|
||||||
|
|
||||||
|
End Namespace
|
||||||
11
Pilz.Win32/Native/WindowFromPointFlags.vb
Normal file
11
Pilz.Win32/Native/WindowFromPointFlags.vb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Namespace Native
|
||||||
|
|
||||||
|
<Flags>
|
||||||
|
Public Enum WindowFromPointFlags
|
||||||
|
CWP_ALL = &H0
|
||||||
|
CWP_SKIPINVISIBLE = &H1
|
||||||
|
CWP_SKIPDISABLED = &H2
|
||||||
|
CWP_SKIPTRANSPARENT = &H4
|
||||||
|
End Enum
|
||||||
|
|
||||||
|
End Namespace
|
||||||
Reference in New Issue
Block a user