CTextRange2.MoveLeftmethod
Generalizes the functionality of the Left Arrow key.
Syntax
FUNCTION MoveLeft (BYVAL Unit AS LONG = tomCharacter, BYVAL Count AS LONG = 1, BYVAL Extend AS LONG = 0) AS LONG
Parameters
| Name | Description | |
|---|---|---|
Unit | Unit to use. It can be one of the following (see table below). | |
Count | Number of Units to move past. The default value is 1. If Count is less than zero, movement is to the right. | |
Extend | Flag that indicates how to change the selection. If Extend is zero (or tomMove), the method collapses the selection to an insertion point at the active end and then moves it. If Extend is 1 (or tomExtend), the method moves the active end and leaves the other end alone. The default value is zero. A nonzero Extend value corresponds to the Shift key being pressed in addition to the key combination described in Unit. |
Return value
The actual count of units the insertion point or active end is moved left. Collapsing the selection, when Extend is 0, counts as one unit.
Description
Generalizes the functionality of the Left Arrow key.
Note: If Count is less than zero, movement is to the right.
Remarks
The WordBasic move methods like CharRight, CharLeft, WordRight, and WordLeft are hybrids that can do four things that are closely related to the standard arrow-key edit behavior:
- Move the current insertion point if there's no selection.
- Move the active end of the selection if there is a selection.
- Turn an insertion point into a selection and vice versa.
- Return a Boolean stating if movement occurred.
The Extend argument of MoveLeft and MoveRight enables you to be consistent with the three items above. For example, given a selection consisting of a single range, you have the following correspondences (for left-to-right characters).
As in WordBasic, if Count is less than zero, the meanings of left and right are interchanged, that is MoveLeft (Unit, Count, Extend) is equivalent to MoveRight (Unit, -Count, Extend).
Similar to WordBasic and the Left Arrow key UI behavior, calling MoveLeft(Unit, Count) on a degenerate selection moves the insertion point the specified number of Units. On a degenerate range, calling MoveLeft(Unit, Count, 1) where Count is greater than zero causes the range to become nondegenerate with the left end being the active end.
When Extend is tomExtend (or is nonzero), MoveLeft moves only the active end of the selection, leaving the other end where it is. However, if Extend equals zero and the selection starts as a nondegenerate range, MoveLeft(Unit, Count) where Count is greater than zero moves the active end Count - 1 units left, and then moves the other end to the active end. In other words, it makes an insertion point at the active end. Collapsing the range counts as one unit. Thus, MoveLeft(tomCharacter) converts a nondegenerate selection into a degenerate one at the selection's left end. Here, Count has the default value of 1 and Extend has the default value of zero. This example corresponds to pressing the Left Arrow key. MoveLeft and MoveRight are related to the ITextRange move methods, but differ in that they explicitly use the active end (the end moved by pressing the Shift key).
Reference
- Defined in AfxNova/CTextRange2.inc:766
- Documented in Windows/WIndows Controls/RichEdit/CTextRange2 Class.md
- Topic: CTextRange2 Class