Share via


IUIAutomationTextPattern::GetSelection 方法 (uiautomationclient.h)

擷取文字範圍的集合,代表文字型控件中目前選取的文字。

語法

HRESULT GetSelection(
  [out, retval] IUIAutomationTextRangeArray **ranges
);

參數

[out, retval] ranges

類型: IUIAutomationTextRangeArray**

接收文字範圍的集合指標。

傳回值

類型: HRESULT

如果此方法成功,則會傳回 S_OK。 否則,它會傳回 HRESULT 錯誤碼。

備註

如果控件支持選取多個非連續文字範圍, 則 ranges 集合會針對每個選取的範圍接收一個文字範圍。

如果控件只包含選取文字的單一範圍, 則 ranges 集合會收到單一文字範圍。

如果控件包含文字插入點但未選取任何文字, 則範圍 集合會收到在文字插入點位置的空白 (空白) 文字範圍。

如果控件不包含文字插入點或不支援文字選取範圍, 範圍會 設定為 NULL

使用 IUIAutomationTextPattern::SupportedTextSelection 屬性來測試控件是否支援文字選取。

規格需求

需求
最低支援的用戶端 Windows 7、Windows Vista SP2 和 Platform Update for Windows Vista、Windows XP 含 SP3 和適用於 Windows Vista 的平臺更新 [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2008 R2、Windows Server 2008 SP2 和 Platform Update for Windows Server 2008、Windows Server 2003 SP2 和 Platform Update for Windows Server 2008 [僅限桌面應用程式]
目標平台 Windows
標頭 uiautomationclient.h (包含 UIAutomation.h)

另請參閱

IUIAutomationTextPattern

使用者介面自動化 文字內容的支援