ITextProvider::GetSelection method

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

Syntax

HRESULT GetSelection(
  SAFEARRAY **pRetVal
);

Parameters

pRetVal

Type: SAFEARRAY**

Receives the address of an array of pointers to the ITextRangeProvider interfaces of the text ranges, one for each selected span of text. This parameter is passed uninitialized.

Return Value

Type: HRESULT

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

Remarks

For UI Automation providers that support text selection, the provider should implement this method and also return a ITextProvider::SupportedTextSelection value.

If the control contains only a single span of selected text, the pRetVal array should contain a single text range.

If the control contains a text insertion point but no text is selected, the pRetVal array should contain a degenerate (empty) text range at the position of the text insertion point.

If the control contains no selected text, or if the control does not contain a text insertion point, set pRetVal to NULL.

Requirements

   
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header uiautomationcore.h (include UIAutomation.h)

See Also

Best Practices for Using Safe Arrays

Conceptual

ITextProvider

ITextRangeProvider

Reference

UI Automation Providers Overview