TextPattern.RangeFromPoint(Point) 方法

定义

返回与指定屏幕坐标最接近的退化(空)文本范围。Returns the degenerate (empty) text range nearest to the specified screen coordinates.

public:
 System::Windows::Automation::Text::TextPatternRange ^ RangeFromPoint(System::Windows::Point screenLocation);
public System.Windows.Automation.Text.TextPatternRange RangeFromPoint (System.Windows.Point screenLocation);
member this.RangeFromPoint : System.Windows.Point -> System.Windows.Automation.Text.TextPatternRange
Public Function RangeFromPoint (screenLocation As Point) As TextPatternRange

参数

screenLocation
Point

以屏幕坐标的形式表示的位置。The location in screen coordinates.

返回

与指定位置最接近的退化范围。A degenerate range nearest the specified location. 从不返回 NullNull is never returned.

例外

给定点位于与文本模式关联的 AutomationElement 的外部。A given point is outside the AutomationElement associated with the text pattern.

示例

private TextPatternRange GetRangeFromPoint()
{
    return targetTextPattern.RangeFromPoint(
        _root.Current.BoundingRectangle.TopLeft);
}
Private Function GetRangeFromPoint() As TextPatternRange
    Return targetTextPattern.RangeFromPoint( _
    _root.Current.BoundingRectangle.TopLeft)
End Function

注解

如果屏幕坐标在图像、超链接、Microsoft ExcelMicrosoft Excel 电子表格或其他嵌入对象的坐标范围内,则将返回包装子对象的文本范围。A text range that wraps a child object is returned if the screen coordinates are within the coordinates of an image, hyperlink, Microsoft ExcelMicrosoft Excel spreadsheet, or other embedded object.

由于 RangeFromPoint不会忽略隐藏文本,因此将返回与给定点最近的可见文本中的退化范围。Because hidden text is not ignored by RangeFromPoint, a degenerate range from the visible text closest to the given point is returned.

适用于

另请参阅