IUIAutomationTextPattern::GetSelection method

Retrieves a collection of text ranges that represents the currently selected text in a text-based control.

Syntax


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

Parameters

ranges [out, retval]

Type: IUIAutomationTextRangeArray**

Receives a pointer to the collection of text ranges.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

If the control supports the selection of multiple, non-contiguous spans of text, the ranges collection receives one text range for each selected span.

If the control contains only a single span of selected text, the ranges collection receives a single text range.

If the control contains a text insertion point but no text is selected, the ranges collection receives a degenerate (empty) text range at the position of the text insertion point.

If the control does not contain a text insertion point or does not support text selection, ranges is set to NULL.

Use the IUIAutomationTextPattern::SupportedTextSelection property to test whether a control supports text selection.

Requirements

Minimum supported client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista, Windows XP with SP3 and Platform Update for Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008, Windows Server 2003 with SP2 and Platform Update for Windows Server 2008 [desktop apps only]

Header

UIAutomationClient.h (include UIAutomation.h)

IDL

UIAutomationClient.idl

See also

IUIAutomationTextPattern
UI Automation Support for Textual Content

 

 

Show: