sdflh
This commit is contained in:
@@ -163,18 +163,42 @@ Public Class Window
|
||||
''' <summary>
|
||||
''' Returns Bounds of the focused control. Relative to current form and `Anchor` value.
|
||||
''' </summary>
|
||||
Public Function GetFocusedControlLocation(Optional Anchor As Anchor = Anchor.TopLeft) As RectangleInfo
|
||||
Public Function GetFocusedControlLocation(WindowHandle As IntPtr, Anchor As Anchor) As RectangleInfo
|
||||
Dim oWindowRect As New NativeMethods.RectangleAPI
|
||||
Dim oControlRect As New NativeMethods.RectangleAPI
|
||||
Dim oForegroundWindow As IntPtr
|
||||
Dim oFocusedControl As IntPtr
|
||||
Dim oForegroundWindow As WindowInfo
|
||||
Dim oFocusedControl As WindowInfo
|
||||
Dim oResult As New RectangleInfo
|
||||
|
||||
Try
|
||||
oForegroundWindow = NativeMethods.GetForegroundWindow()
|
||||
oFocusedControl = NativeMethods.GetFocus()
|
||||
oForegroundWindow = GetWindowInfo()
|
||||
oFocusedControl = GetFocusedControl(WindowHandle)
|
||||
|
||||
Return GetControlLocation(oFocusedControl, oForegroundWindow, Anchor)
|
||||
Return GetControlLocation(oFocusedControl.hWnd, oForegroundWindow.hWnd, Anchor)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFocusedControlLocation(WindowHandle As IntPtr) As Dictionary(Of String, RectangleInfo)
|
||||
Dim oWindowRect As New NativeMethods.RectangleAPI
|
||||
Dim oControlRect As New NativeMethods.RectangleAPI
|
||||
Dim oForegroundWindow As WindowInfo
|
||||
Dim oFocusedControl As WindowInfo
|
||||
Dim oResult As New RectangleInfo
|
||||
|
||||
Try
|
||||
oForegroundWindow = GetWindowInfo()
|
||||
oFocusedControl = GetFocusedControl(WindowHandle)
|
||||
|
||||
Dim oDict As New Dictionary(Of String, RectangleInfo)
|
||||
|
||||
For Each oAnchor As Anchor In [Enum].GetValues(GetType(Anchor))
|
||||
oDict.Add(oAnchor.ToString.ToUpper, GetControlLocation(oFocusedControl.hWnd, oForegroundWindow.hWnd, oAnchor))
|
||||
Next
|
||||
|
||||
Return oDict
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return Nothing
|
||||
|
||||
Reference in New Issue
Block a user