ITextSelection interface

A text selection is a text range with selection highlighting.

Members

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

Methods

The ITextSelection interface has these methods.

MethodDescription
EndKey

Mimics the functionality of the End key.

GetFlags

Gets the text selection flags.

GetType

Gets the type of text selection.

HomeKey

Generalizes the functionality of the Home key.

MoveDown

Mimics the functionality of the Down Arrow and Page Down keys.

MoveLeft

Generalizes the functionality of the Left Arrow key.

MoveRight

Generalizes the functionality of the Right Arrow key.

MoveUp

Mimics the functionality of the Up Arrow and Page Up keys.

SetFlags

Sets the text selection flags.

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.

MethodCursor-keypad keyUnit given by CTRL pressed (not pressed)Extend given by SHIFT pressed (not pressed)
EndKeyEndtomStory (tomLine)tomExtend (tomMove)
HomeKeyHometomStory (tomLine)tomExtend (tomMove)
MoveLeftLeft ArrowtomWord (tomCharacter)tomExtend (tomMove)
MoveRightRight ArrowtomWord (tomCharacter)tomExtend (tomMove)
MoveUpUp ArrowtomParagraph (tomLine)tomExtend (tomMove)
MoveDownDown ArrowtomParagraph (tomLine)tomExtend (tomMove)
MoveUpPage UptomWindow (tomScreen)tomExtend (tomMove)
MoveDownPage DowntomWindow (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

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Tom.h

DLL

Msftedit.dll

 

 

Community Additions

ADD
Show:
© 2014 Microsoft