
This interface provides the access methods for the selection object representing the active selection, a highlighted block of text and/or other elements in the document upon which a user or a script can carry out some action. You typically use the selection object as input from the user identifying what portion of the document to act on, or as output to the user showing the results of an action.
Users and scripts both can create selections. Users create selections by dragging the mouse over a portion of the document. Scripts create them by calling the select method on a text range or similar object. You can retrieve the active selection by applying the selection keyword to the document object. To carry out work on a selection, you can create a text range object from the selection by using the createRange method.
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.
IHTMLSelectionObject Methods
| createRange | empty |
| clear | get_type |
HRESULT createRange(
IDispatch **range
);
Creates a text range from the current selection.
See also IHTMLTxtRange
HRESULT empty(void);
Deselects the current selection, sets the selection type to "none", and sets the item property to NULL.
HRESULT clear(
void
);
Clears the contents of the selection.
HRESULT get_type(
BSTR *p
);
Retrieves the type of selection.
| None | The selection is an insertion point (no text is selected). |
| Text | The selection is a text selection. |
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.