語言

TextPattern.RangeFromPoint(Point) 方法

定義

回傳最接近指定螢幕座標的退化(空)文字範圍。

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

螢幕座標中的位置。

傳回

一個退化範圍,最接近指定位置。 Null 從未被歸還。

例外狀況

某個點位於與文字模式相關聯之外 AutomationElement 。

範例

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 Excel 試算表或其他嵌入物件的座標內,則回傳包裹子物件的文字範圍。

由於隱藏文字不會被 RangeFromPoint忽略,會回傳一個從最接近該點可見文字的退化範圍。

適用於

另請參閱