ITextSelection interface (tom.h)

A text selection is a text range with selection highlighting.

Inheritance

The ITextSelection interface inherits from ITextRange. ITextSelection also has these types of members:

Methods

The ITextSelection interface has these methods.

 
ITextSelection::EndKey

Mimics the functionality of the End key.
ITextSelection::GetFlags

Gets the text selection flags.
ITextSelection::GetType

Gets the type of text selection.
ITextSelection::HomeKey

Generalizes the functionality of the Home key.
ITextSelection::MoveDown

Mimics the functionality of the Down Arrow and Page Down keys.
ITextSelection::MoveLeft

Generalizes the functionality of the Left Arrow key.
ITextSelection::MoveRight

Generalizes the functionality of the Right Arrow key.
ITextSelection::MoveUp

Mimics the functionality of the Up Arrow and Page Up keys.
ITextSelection::SetFlags

Sets the text selection flags.
ITextSelection::TypeText

Types the string given by bstr at this selection as if someone typed it. This is similar to the underlying SetText method, but is sensitive to the Insert/Overtype key state and UI settings like AutoCorrect and smart quotes.

Remarks

The selection is associated with some kind of view, and has some UI-oriented methods that allow one to emulate keyboard input. Thus, an application can use the ITextRange methods on a text selection, as well as the ITextSelection methods.

For keyboard input emulation, ranges used in selections use the concept of the active end, which is typically the end that was last moved. For example, if an ITextRange::Move* method operates on a range that is actually a text selection, the most recently moved end is the active one. The most familiar examples of the active end are those involving Shift+Arrow Key handling, where the active end is the one that moves. Accordingly, the ITextSelection methods include move methods for the active end, such as MoveLeft or MoveRight, and methods to get and set the active end status. These methods manipulate selections in ways similar to the standard cursor-keypad operations. This allows you to implement, for example, a macro recorder facility.

To see how the cursor-keypad methods work, see the following table. A given method corresponds to a cursor-keypad key with the Ctrl and Shift keys. The Unit parameter is selected by pressing or not pressing the Ctrl key, while the Extend parameter is selected by pressing or not pressing the Shift key. Note, MoveUp and MoveDown correspond to more than one keypad key. For more information, see the descriptions of the methods.

Method Cursor-keypad key Unit given by CTRL pressed (not pressed) Extend given by SHIFT pressed (not pressed)
EndKey End tomStory (tomLine) tomExtend (tomMove)
HomeKey Home tomStory (tomLine) tomExtend (tomMove)
MoveLeft Left Arrow tomWord (tomCharacter) tomExtend (tomMove)
MoveRight Right Arrow tomWord (tomCharacter) tomExtend (tomMove)
MoveUp Up Arrow tomParagraph (tomLine) tomExtend (tomMove)
MoveDown Down Arrow tomParagraph (tomLine) tomExtend (tomMove)
MoveUp Page Up tomWindow (tomScreen) tomExtend (tomMove)
MoveDown Page Down tomWindow (tomScreen) tomExtend (tomMove)
 

Applications typically do not implement the ITextSelection interface. Instead, Microsoft text solutions such as rich edit controls implement ITextSelection as part of their Text Object Model (TOM) implementation.

Applications can retrieve an ITextSelection pointer by calling the GetSelection method.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header tom.h