IHTMLDocument2::selection Property

Gets an interface pointer to an object representing the active selection. The active selection can be an insertion point, a highlighted block of text, or another element in the document that the user or a script can carry out an action on.

Syntax

HRESULT IHTMLDocument2::get_selection(IHTMLSelectionObject **p);

Parameters

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The selection object identifies the portion of the document to act on, or returns the results of an action.

The user, a script, or an object can create a selection. The user creates a selection by dragging the mouse over a portion of the document. A script or an object creates a selection by calling the IHTMLTextAreaElement::select method on a text range or similar object.

A document can have only one selection at a time. The selection has a type that determines whether it is empty or contains a contiguous block of consecutive text and/or elements. Although an empty selection contains nothing, it is useful for marking a position in the document.