vb System.Windows.Automation.Provider.IRawElementProviderFragmentRoot.ElementProviderFromPoint类(方法)实例源码

下面列出了vb System.Windows.Automation.Provider.IRawElementProviderFragmentRoot.ElementProviderFromPoint 类(方法)源码代码实例,从而了解它的用法。

作者:VB.NET开发    项目:System.Windows.Automation.Provide   
Delegate Function MyDelegate(ByVal clientRect As Rectangle) As Rectangle

''' <summary>
''' Gets the child element that is at the specified point.
''' </summary>
''' <param name="x">Distance from the left of the application window.</param>
''' <param name="y">Distance from the top of the application window.</param>
''' <returns>The provider for the element at that point.</returns>
Function ElementProviderFromPoint(ByVal x As Double, ByVal y As Double) As IRawElementProviderFragment _
    Implements IRawElementProviderFragmentRoot.ElementProviderFromPoint

    Dim pointX As Integer = CInt(x)
    Dim pointY As Integer = CInt(y)

    ' The RectangleToScreen method on the control can't be called directly from 
    ' this thread, so use delegation.
    Dim converterDelegate As MyDelegate = New MyDelegate(AddressOf Me.RectangleToScreen)
    Dim screenRectangle As Rectangle = DirectCast(Me.Invoke(converterDelegate, _
        New Object() {Me.DisplayRectangle}), Rectangle)
    If screenRectangle.Contains(pointX, pointY) Then
        Dim index As Integer = CInt((pointY - screenRectangle.Y) \ itemHeight)
        If index < myItems.Count Then
            Return DirectCast(myItems(index), IRawElementProviderFragment)
        Else
            Return DirectCast(Me, IRawElementProviderFragment)
        End If
    Else
        Return Nothing
    End If
End Function


问题


面经


文章

微信
公众号

扫码关注公众号